/*
 * GPX Editor — lab.johlem.net
 * Brutalist, monochrome-with-one-accent UI. All radii 0, all borders flat.
 * Uses local JetBrains Mono from /fonts/fonts.css (already served by the lab),
 * so the page does not make a single external request.
 */

:root {
  --bg:         #0a0a0a;   /* page background */
  --surface:    #1a1a1a;   /* panels, inputs */
  --rule:       #444;      /* default borders */
  --rule-soft:  #222;      /* low-emphasis dividers */
  --muted:      #888;      /* secondary text */
  --fg:         #f0f0f0;   /* body text */
  --accent:     #E8350A;   /* structural accent — active, focus, primary */
  --accent-dim: rgba(232, 53, 10, 0.20); /* fills / hover wash */

  --font-mono:  'JetBrains Mono', 'IBM Plex Mono', 'Courier New', monospace;

  --header-h:   48px;
  --sidebar-w:  320px;
  --profile-h:  160px;
  --stats-h:    40px;
}

/* ---------- Reset ---------- */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;            /* full viewport app, no page scroll */
}

button, input, select, textarea {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 0;
  padding: 6px 10px;
  outline: none;
}

button { cursor: pointer; text-transform: uppercase; letter-spacing: 0.08em; }

button:hover,
button:focus-visible { border-color: var(--accent); }

button:disabled { opacity: 0.4; cursor: not-allowed; }

input:focus,
textarea:focus,
select:focus { border-color: var(--accent); }

/* ---------- App shell ---------- */

.app {
  display: grid;
  grid-template-columns: 1fr var(--sidebar-w);
  grid-template-rows: var(--header-h) 1fr var(--profile-h) var(--stats-h);
  grid-template-areas:
    "header  header"
    "canvas  sidebar"
    "profile profile"
    "stats   stats";
  height: 100dvh;
  width: 100vw;
}

/* ---------- Header ---------- */

.header {
  grid-area: header;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  background: var(--bg);
  border-bottom: 2px solid var(--accent);
}

.header h1 {
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.header h1 .accent { color: var(--accent); }

.header .actions { display: flex; gap: 8px; align-items: center; }
.header .file-label {
  display: inline-block;
  padding: 6px 12px;
  border: 1px solid var(--rule);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  cursor: pointer;
  background: var(--surface);
}
.header .file-label:hover { border-color: var(--accent); }
.header input[type="file"] { display: none; }

/* ---------- Canvas area ---------- */

.canvas-wrap {
  grid-area: canvas;
  position: relative;
  background: var(--bg);
  border-right: 1px solid var(--rule-soft);
  overflow: hidden;
}

#map-canvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: crosshair;
}

.hud {
  position: absolute;
  bottom: 10px;
  left: 10px;
  font-size: 11px;
  color: var(--muted);
  background: rgba(10, 10, 10, 0.7);
  border: 1px solid var(--rule);
  padding: 4px 8px;
  pointer-events: none;
  white-space: pre;
}

.hud-zoom {
  position: absolute;
  top: 10px;
  right: 10px;
  font-size: 11px;
  color: var(--muted);
  background: rgba(10, 10, 10, 0.7);
  border: 1px solid var(--rule);
  padding: 4px 8px;
  pointer-events: none;
}

/* Tile basemap attribution — required by OSM/CARTO licence. */
.map-attrib {
  position: absolute;
  bottom: 10px;
  right: 10px;
  font-size: 10px;
  color: var(--muted);
  background: rgba(10, 10, 10, 0.7);
  border: 1px solid var(--rule);
  padding: 3px 7px;
  letter-spacing: 0.02em;
  text-transform: none;
  z-index: 2;
}
.map-attrib a { color: var(--fg); text-decoration: none; border-bottom: 1px dotted var(--rule); }
.map-attrib a:hover { color: var(--accent); border-bottom-color: var(--accent); }

.dropzone {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.15em;
  text-align: center;
  padding: 24px;
  border: 1px dashed transparent;
  pointer-events: none;          /* hover handled on canvas-wrap */
}
.dropzone.active {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-dim);
}
.dropzone .big { font-size: 18px; }
.dropzone .hint { font-size: 11px; color: var(--muted); }

/* ---------- Sidebar ---------- */

.sidebar {
  grid-area: sidebar;
  background: var(--surface);
  border-left: 1px solid var(--rule-soft);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.panel {
  border-bottom: 1px solid var(--rule-soft);
  padding: 12px 14px;
}
.panel h2 {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--accent);
  margin-bottom: 10px;
  font-weight: 500;
}

.kv {
  display: grid;
  grid-template-columns: 90px 1fr;
  gap: 4px 8px;
  font-size: 11px;
}
.kv dt { color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
.kv dd { color: var(--fg); word-break: break-all; }

.field { display: block; margin-bottom: 8px; }
.field label {
  display: block;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  margin-bottom: 3px;
}
.field input, .field textarea, .field select {
  width: 100%;
}
.field textarea { min-height: 60px; resize: vertical; }

.btn-row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.btn-row button { flex: 1 0 auto; padding: 6px 8px; font-size: 11px; }

.btn-danger { border-color: var(--accent); color: var(--accent); }
.btn-danger:hover { background: var(--accent); color: var(--bg); }

.empty {
  color: var(--muted);
  font-size: 11px;
  font-style: italic;
}

/* ---------- Elevation profile ---------- */

.profile-wrap {
  grid-area: profile;
  position: relative;
  border-top: 1px solid var(--rule-soft);
  background: var(--bg);
}
#profile-canvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: crosshair;
}
.profile-tooltip {
  position: absolute;
  pointer-events: none;
  background: rgba(10,10,10,0.85);
  border: 1px solid var(--accent);
  color: var(--fg);
  font-size: 11px;
  padding: 4px 8px;
  white-space: pre;
  display: none;
}

/* ---------- Stats bar ---------- */

.stats-bar {
  grid-area: stats;
  display: flex;
  align-items: stretch;
  background: var(--surface);
  border-top: 1px solid var(--rule);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  overflow-x: auto;
}
.stats-bar .stat {
  flex: 1 1 0;
  padding: 4px 12px;
  border-right: 1px solid var(--rule-soft);
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-width: 110px;
}
.stats-bar .stat:last-child { border-right: none; }
.stats-bar .stat .label { color: var(--muted); font-size: 9px; letter-spacing: 0.14em; }
.stats-bar .stat .value { color: var(--fg); font-size: 12px; }
.stats-bar .stat .value.accent { color: var(--accent); }

/* ---------- Toast ---------- */

.toast {
  position: fixed;
  bottom: 12px;
  right: 12px;
  background: var(--surface);
  border: 1px solid var(--accent);
  color: var(--fg);
  font-size: 11px;
  padding: 8px 12px;
  max-width: 360px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  z-index: 99;
}
.toast.error { border-color: var(--accent); color: var(--accent); }

/* ---------- Scrollbars (subtle) ---------- */

.sidebar::-webkit-scrollbar,
.stats-bar::-webkit-scrollbar { width: 8px; height: 8px; }
.sidebar::-webkit-scrollbar-thumb,
.stats-bar::-webkit-scrollbar-thumb { background: var(--rule); }
.sidebar::-webkit-scrollbar-track,
.stats-bar::-webkit-scrollbar-track { background: var(--surface); }

/* ---------- Small viewport fallback ---------- */

@media (max-width: 720px) {
  .app {
    grid-template-columns: 1fr;
    grid-template-rows: var(--header-h) 50vh auto var(--profile-h) var(--stats-h);
    grid-template-areas:
      "header"
      "canvas"
      "sidebar"
      "profile"
      "stats";
  }
  .sidebar { border-left: none; border-top: 1px solid var(--rule-soft); max-height: 40vh; }
}
