/* ================================================
   GPX Lane Snapper — Stylesheet
   style.css  ·  used by index.html only
   ================================================ */

@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@400;500;600;700&family=DM+Mono:wght@400;500&display=swap');

/* ── Design tokens ── */
:root
{
  --bg:            #eef4f0;
  --surface:       #ffffff;
  --surface2:      #e8f0ea;
  --accent:        #1d7552;
  --accent-dim:    #165c41;
  --accent-bg:     rgba(29,117,82,0.08);
  --text:          #16201c;
  --text-muted:    #5a6762;
  --text-dim:      #8a9791;
  --border:        rgba(0,0,0,0.08);
  --shadow:        0 4px 24px rgba(0,0,0,0.08);

  --track:         #b4472f;
  --track-line:    #f7ece6;
  --raw:           #2266c4;
  --snapped:       #ffcf33;
  --warn:          #a1590d;

  --font-display:  'Outfit', sans-serif;
  --font-mono:     'DM Mono', monospace;

  /* common.css hooks */
  --back-color:      var(--text-muted);
  --back-hover:      var(--accent);
  --scrollbar-thumb: rgba(0,0,0,0.15);
  --back-nav-width:     1240px;   /* align with .gs-page (1240 max incl. 2x20 page padding) */
  --back-nav-gutter:    20px;
  --back-nav-gutter-sm: 20px;
}

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

/* ── Body ── */
body
{
  font-family: var(--font-display);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

.gs-page
{
  max-width: 1240px;
  margin: 0 auto;
  padding: 8px 20px 60px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.gs-hidden { display: none !important; }

.gs-stack { display: flex; flex-direction: column; gap: 20px; }

.gs-visually-hidden
{
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

/* ── Header ── */
.gs-header
{
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 8px 20px;
  padding-top: 8px;
}

.gs-header h1
{
  font-size: 26px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 10px;
}

.gs-header h1 .icon
{
  background: var(--accent);
  border-radius: 10px;
  width: 38px;
  height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}

.gs-header p { font-size: 13.5px; color: var(--text-muted); line-height: 1.6; max-width: 620px; margin-top: 8px; }

.gs-file
{
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-muted);
  overflow-wrap: anywhere;
}

/* ── Card ── */
.gs-card
{
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: var(--shadow);
}

/* ── Workspace: map on the left, controls on the right ── */
.gs-workspace
{
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 20px;
  align-items: start;
}

.gs-view
{
  position: relative;
  min-width: 0;
  overflow: hidden;
}

.gs-view.drag-over { outline: 2px dashed var(--accent); outline-offset: -6px; }

.gs-map { height: 580px; background: var(--surface2); }

.gs-empty
{
  position: absolute;
  inset: 0 0 auto 0;
  height: 580px;
  z-index: 500;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-align: center;
  padding: 20px;
  background: color-mix(in srgb, var(--surface) 80%, transparent);
  pointer-events: none;
}

.gs-empty .dz-icon { font-size: 36px; }
.gs-empty .dz-label { font-size: 14px; font-weight: 600; }
.gs-empty .dz-sub { font-size: 12px; color: var(--text-muted); }

/* ── Scrubber and map legend ── */
.gs-scrubber
{
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 6px 14px;
  align-items: center;
  padding: 14px 18px;
  border-top: 1px solid var(--border);
}

.gs-scrubber output
{
  grid-column: 1 / -1;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-muted);
  overflow-wrap: anywhere;
}

.gs-map-legend
{
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  font-size: 12.5px;
  color: var(--text-muted);
}

.gs-map-legend span { display: inline-flex; align-items: center; gap: 6px; }

.gs-swatch
{
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
}

.gs-swatch.raw { background: var(--raw); }
.gs-swatch.snapped { background: var(--snapped); border: 1px solid var(--track); }

/* ── Controls ── */
.gs-controls { display: grid; }

.gs-group
{
  padding: 16px 20px;
  display: grid;
  gap: 10px;
  border-top: 1px solid var(--border);
}

.gs-group:first-child { border-top: 0; }

.gs-label
{
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-dim);
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

.gs-label b
{
  font-weight: 500;
  letter-spacing: 0;
  text-transform: none;
  color: var(--text);
  font-size: 12px;
}

.gs-lanes
{
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  gap: 4px;
}

.gs-lanes button
{
  font-family: inherit;
  font-weight: 700;
  font-size: 15px;
  padding: 6px 0;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text);
  cursor: pointer;
  transition: border-color .2s;
}

.gs-lanes button:hover { border-color: var(--track); }

.gs-lanes button[aria-pressed="true"]
{
  background: var(--track);
  border-color: var(--track);
  color: var(--track-line);
}

.gs-note { font-size: 12px; color: var(--text-muted); line-height: 1.5; }
.gs-note.warn { color: var(--warn); }

.gs-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.gs-row input[type="range"] { flex: 1 1 140px; min-width: 0; }

input[type="range"] { accent-color: var(--accent); width: 100%; }

input[type="number"]
{
  width: 74px;
  font-family: var(--font-mono);
  font-size: 12px;
  padding: 4px 6px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface2);
  color: var(--text);
}

.gs-check
{
  display: flex;
  gap: 8px;
  align-items: flex-start;
  font-size: 13px;
  cursor: pointer;
}

.gs-check input { accent-color: var(--accent); margin-top: 3px; }

.gs-btn
{
  background: var(--surface2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 9px 14px;
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: border-color .2s, color .2s, background .2s;
}

.gs-btn:hover { border-color: var(--accent); color: var(--accent); }

.gs-btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.gs-btn.primary:hover { background: var(--accent-dim); border-color: var(--accent-dim); color: #fff; }

.gs-btn:focus-visible,
.gs-lanes button:focus-visible,
.gs-nudge button:focus-visible,
input:focus-visible,
summary:focus-visible
{
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

details summary { cursor: pointer; font-size: 13px; color: var(--text-muted); }

.gs-dims
{
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 6px 10px;
  align-items: center;
  font-size: 13px;
  margin-top: 10px;
}

.gs-nudge
{
  display: grid;
  grid-template-columns: repeat(3, 40px);
  gap: 4px;
}

.gs-nudge button
{
  height: 34px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text);
  font: 600 14px var(--font-display);
  cursor: pointer;
}

.gs-nudge button:hover { border-color: var(--accent); color: var(--accent); }

.gs-copy-box
{
  width: 100%;
  height: 120px;
  font-family: var(--font-mono);
  font-size: 11px;
  background: var(--surface2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
}

/* ── Summary stats ── */
.gs-stats { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); }

.gs-stat
{
  padding: 18px 20px;
  border-left: 1px solid var(--border);
  min-width: 0;
}

.gs-stat:first-child { border-left: 0; }

.gs-stat dt
{
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-dim);
}

.gs-stat dd
{
  margin: 4px 0 0;
  font-weight: 700;
  font-size: 26px;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

.gs-stat dd small
{
  font-weight: 500;
  font-size: 13px;
  color: var(--text-muted);
  margin-left: 4px;
}

.gs-stat-sub { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

/* ── Splits table and pace chart ── */
.gs-results
{
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
  gap: 20px;
  align-items: start;
}

.gs-results h2 { font-size: 18px; font-weight: 700; padding: 18px 20px 0; }
.gs-results .gs-note { padding: 2px 20px 0; }

.gs-table-wrap { overflow: auto; max-height: 420px; margin-top: 10px; }

table
{
  width: 100%;
  border-collapse: collapse;
  font-family: var(--font-mono);
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
}

th
{
  position: sticky;
  top: 0;
  background: var(--surface);
  text-align: right;
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-dim);
  padding: 6px 20px;
  border-bottom: 1px solid var(--border);
}

td { text-align: right; padding: 6px 20px; border-bottom: 1px solid var(--border); }
th:first-child, td:first-child { text-align: left; }

.gs-tag
{
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 600;
  color: var(--warn);
  border: 1px solid currentColor;
  border-radius: 999px;
  padding: 0 6px;
  margin-left: 6px;
}

tr.gs-partial td { color: var(--text-muted); }

.gs-chart canvas { display: block; width: 100%; height: 300px; }

.gs-chart-legend
{
  display: flex;
  gap: 16px;
  padding: 4px 20px 16px;
  font-size: 12.5px;
  color: var(--text-muted);
}

.gs-chart-legend i
{
  display: inline-block;
  width: 16px;
  height: 3px;
  border-radius: 2px;
  vertical-align: middle;
  margin-right: 6px;
}

/* ── Leaflet overrides ── */
.leaflet-container { font-family: var(--font-display); }

.gs-handle
{
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 2px solid #ffffff;
  box-shadow: 0 1px 4px rgba(0,0,0,0.45);
  font: 700 15px/1 var(--font-display);
  color: #ffffff;
  cursor: grab;
}

.gs-handle-move { background: var(--accent); }
.gs-handle-rotate { background: var(--track); }

/* ── Responsive ── */
@media (max-width: 920px)
{
  .gs-workspace, .gs-results { grid-template-columns: minmax(0, 1fr); }
  .gs-map { height: 440px; }
  .gs-empty { height: 440px; }
}

@media (max-width: 600px)
{
  .gs-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .gs-stat { border-left: 0; border-top: 1px solid var(--border); }
  .gs-stat:nth-child(-n+2) { border-top: 0; }
  .gs-stat:nth-child(even) { border-left: 1px solid var(--border); }
  .gs-stat:last-child { grid-column: 1 / -1; border-left: 0; }
  .gs-map, .gs-empty { height: 360px; }
  .gs-header h1 { font-size: 22px; }
}
