/* ---------------------------------------------------------------------------
   Race Split Planner. Only what is genuinely specific to this tool: the map
   and the elevation profile. Layout, states and controls come from the shared
   shell, component and tool-page layers.
   --------------------------------------------------------------------------- */

/* --- Visualisation container ---------------------------------------------- */
.viz { display: grid; gap: var(--s-3); }
.viz__controls { display: flex; align-items: center; gap: var(--s-3); flex-wrap: wrap; }
.viz__play { margin-left: auto; }
.viz__facts { display: flex; gap: var(--s-5); flex-wrap: wrap; font-size: var(--text-sm); color: var(--ink-2); }
.viz__fact-label {
  font-size: var(--text-xs); font-weight: 600; letter-spacing: 0.09em;
  text-transform: uppercase; color: var(--muted); margin-right: 2px;
}

#map {
  height: 440px; border: 1px solid var(--line); border-radius: var(--radius-lg);
  background: var(--surface-2); z-index: 0;
}
.leaflet-container { font-family: var(--font-sans); border-radius: var(--radius-lg); }
.leaflet-control-attribution { font-size: 10px; }

.legend { display: flex; flex-wrap: wrap; gap: var(--s-2) var(--s-5); list-style: none; margin: 0; padding: 0;
  font-size: var(--text-sm); color: var(--muted); }
.legend__item { display: flex; align-items: center; gap: 6px; }
.legend__swatch { display: inline-block; width: 22px; height: 4px; border-radius: 2px; }
.legend__swatch--included { background: var(--accent); }
.legend__swatch--excluded { background: #8B939B; }

.flag-label {
  font: 600 var(--text-xs)/1.4 var(--font-sans) !important;
  padding: 1px 6px !important; border: 1px solid var(--line) !important;
  color: var(--ink) !important; box-shadow: none !important;
}

/* --- Elevation profile ---------------------------------------------------- */
.ele-wrap {
  border: 1px solid var(--line); border-radius: var(--radius-lg);
  background: var(--surface); overflow: hidden;
}
.ele-plot { position: relative; }
#eleSvg { display: block; width: 100%; height: 240px; cursor: crosshair; }

/* Axis labels are HTML, not SVG text: the profile deliberately scales
   non-uniformly (preserveAspectRatio="none") so it always fills its container,
   which would stretch any text drawn inside it. */
.ele-axis { position: absolute; inset: 0; pointer-events: none; }
.ele-axis__label {
  position: absolute; left: var(--s-2); transform: translateY(-50%);
  font-family: var(--font-mono); font-variant-numeric: tabular-nums;
  font-size: var(--text-xs); color: var(--muted); background: var(--surface);
  padding: 0 4px; border-radius: 2px;
}
.ele-ticks {
  display: flex; justify-content: space-between;
  /* 4.6% matches the profile's left gutter (ELE_X0 of a 1000-unit viewBox). */
  padding: 6px var(--s-3) 8px calc(4.6% + var(--s-2)); border-top: 1px solid var(--line-2);
  font-family: var(--font-mono); font-variant-numeric: tabular-nums;
  font-size: var(--text-xs); color: var(--muted);
}
.ele-tooltip {
  position: absolute; display: none; z-index: 3;
  background: var(--ink); color: #fff; padding: 4px 9px; border-radius: var(--radius-sm);
  font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-size: var(--text-sm);
  pointer-events: none; white-space: nowrap; transform: translate(-50%, -140%);
}

/* --- Responsive ----------------------------------------------------------- */
@media (max-width: 720px) {
  #map { height: 320px; }
  #eleSvg { height: 190px; }
  .viz__controls { gap: var(--s-2); }
  .viz__play { margin-left: 0; width: 100%; }
  .segmented { flex: 1; }
  .segmented__btn { flex: 1; }
}

/* Inline split editing: the field must not change the table's rhythm. */
.split-edit-input {
  width: 74px; padding: 3px 7px; text-align: right;
  font: 500 var(--text-base)/1.4 var(--font-mono); font-variant-numeric: tabular-nums;
}
