/* ============================================================================
   Atlas — the design language of the Dock Atlas, as a drop-in stylesheet.
   Industry design system tokens (color, type, spacing) plus the conventions
   layered on top: near-white ground, hairline panels, condensed numerals,
   one steel accent, rust reserved for negative data.

   Usage:
     <link rel="stylesheet" href="atlas.css">
     <link href="https://fonts.googleapis.com/css2?family=Barlow:wght@400;500;600&family=Barlow+Condensed:wght@400;500;600;700&display=swap" rel="stylesheet">

   Everything is a variable or a class. Never hard-code a hex, a font or a
   spacing value that already exists below.
   ========================================================================= */

:root {
  /* — ground and ink ————————————————————————————————— */
  --at-bg:          #FBFBFA;   /* page */
  --at-panel:       #FFFFFF;   /* panels, cards, popovers */
  --at-sunken:      #F1F0EC;   /* map wells, inert areas */
  --at-tint:        #F1F4F8;   /* selected row / active control */
  --at-hover:       #F5F4F1;   /* row hover */

  --at-ink:         #1D1F20;   /* primary text */
  --at-muted:       #6E6F70;   /* secondary text, table cells */
  --at-faint:       #9A9B9C;   /* labels, captions, axis text */

  --at-line:        #EFEEEA;   /* hairline inside a panel */
  --at-border:      #E7E6E2;   /* panel edge */
  --at-border-firm: #D9D8D4;   /* axis baselines, popover edge */
  --at-field:       #E0DFDB;   /* input and control borders */

  /* — accent (Industry steel) ——————————————————————————— */
  --at-accent:      #5980A6;
  --at-accent-100:  #EEF6FF;
  --at-accent-600:  #597EA3;   /* hover */
  --at-accent-700:  #416180;   /* pressed, and accent text at body size */
  --at-accent-900:  #1D2D3D;

  /* — data ————————————————————————————————————————————
     Two poles only. Steel is positive/gain, rust is negative/loss, and the
     midpoint is a true neutral. Rust is a data color, never decoration. */
  --at-pos:         #5980A6;
  --at-neg:         #A8503A;
  --at-mid:         #E6E5E1;

  /* — type ————————————————————————————————————————————— */
  --at-font-display: "Barlow Condensed", system-ui, sans-serif;
  --at-font-body:    "Barlow", system-ui, sans-serif;

  /* — spacing (Industry scale, 0.85× density) ——————————————— */
  --at-1: 3.4px;
  --at-2: 6.8px;
  --at-3: 10.2px;
  --at-4: 13.6px;
  --at-6: 20.4px;
  --at-8: 27.2px;

  --at-radius: 3px;            /* panels. Controls use 2px. Nothing is pill-shaped. */
  --at-shadow: 0 10px 30px rgba(29, 31, 32, .12);   /* popovers only */
}

/* ============================================================================
   BASE
   ========================================================================= */

body {
  margin: 0;
  background: var(--at-bg);
  color: var(--at-ink);
  font-family: var(--at-font-body);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--at-accent-700); text-decoration: none; }
a:hover { color: var(--at-ink); }
::selection { background: #D6E4F0; }
input, select, button, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--at-accent); outline-offset: 2px; }

/* Headings are condensed; body copy is not. Numbers are always tabular. */
h1, h2, h3, h4, .at-display {
  font-family: var(--at-font-display);
  font-weight: 600;
  line-height: 1.12;
  letter-spacing: -.015em;
  margin: 0;
}
h1 { font-size: 52px; line-height: 1; letter-spacing: -.02em; }
h2 { font-size: 19px; letter-spacing: -.005em; }
h3 { font-size: 15px; }

/* ============================================================================
   TEXT ROLES
   ========================================================================= */

.at-lede      { font-size: 15.5px; line-height: 1.6; color: #54565A; max-width: 64ch; text-wrap: pretty; }
.at-body      { font-size: 13.5px; line-height: 1.65; color: #54565A; }
.at-body b    { color: var(--at-ink); font-weight: 600; }
.at-note      { font-size: 12.5px; line-height: 1.6; color: var(--at-muted); }
.at-caption   { font-size: 11.5px; line-height: 1.55; color: var(--at-faint); }

/* The uppercase micro-label above every value, control group and section.
   This is the workhorse of the layout — it carries hierarchy so panels
   don't have to. */
.at-label {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--at-faint);
}

/* Any figure a reader might compare down a column. */
.at-num {
  font-family: var(--at-font-display);
  font-weight: 600;
  letter-spacing: -.015em;
  font-variant-numeric: tabular-nums;
  line-height: 1.05;
}
.at-num-lg { font-size: 30px; }
.at-num-md { font-size: 21px; }
.at-num-sm { font-size: 15px; }
.at-num-pos { color: var(--at-pos); }
.at-num-neg { color: var(--at-neg); }

/* ============================================================================
   SHELL
   ========================================================================= */

.at-topbar {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; justify-content: space-between; gap: var(--at-8);
  height: 52px; padding: 0 var(--at-8);
  background: rgba(251, 251, 250, .92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--at-border);
}
.at-brand {
  font-family: var(--at-font-display); font-weight: 600; font-size: 15px;
  letter-spacing: .16em; text-transform: uppercase;
}
.at-main { max-width: 1680px; margin: 0 auto; padding: 0 var(--at-8) 72px; }

/* Sections are separated by a rule, not by a gap and a shadow. */
.at-section { padding: var(--at-6) 0; border-bottom: 1px solid var(--at-border); }
.at-section-last { border-bottom: 0; }

/* ============================================================================
   PANEL
   The only container. Flat white, hairline edge, square-ish corners, no
   shadow. Elevation is reserved for things that float (popovers, tooltips).
   ========================================================================= */

.at-panel {
  background: var(--at-panel);
  border: 1px solid var(--at-border);
  border-radius: var(--at-radius);
}
.at-panel-head {
  display: flex; align-items: baseline; justify-content: space-between; gap: var(--at-4);
  padding: var(--at-4) var(--at-6) var(--at-3);
}
.at-panel-head p { margin: 0; font-size: 12.5px; color: var(--at-faint); }
.at-panel-body { padding: var(--at-4) var(--at-6) var(--at-6); }
.at-panel-divide { border-top: 1px solid var(--at-line); }

/* ============================================================================
   STAT STRIP
   Figures divided by hairlines rather than boxed into cards. Use for any row
   of headline numbers; it reads as one object instead of four.
   ========================================================================= */

.at-stats { display: flex; align-items: stretch; gap: 0; }
.at-stat { padding: 0 var(--at-8); }
.at-stat + .at-stat { border-left: 1px solid var(--at-border); }
.at-stat .at-label { display: block; margin-bottom: 6px; }
.at-stat-note {
  font-size: 11.5px; color: var(--at-faint); margin-top: 3px; max-width: 16ch;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* The same pattern inside a panel, as a grid of derived figures. */
.at-figures { display: grid; grid-template-columns: repeat(4, 1fr); border-top: 1px solid var(--at-line); }
.at-figure { padding: var(--at-4) var(--at-6); }
.at-figure + .at-figure { border-left: 1px solid var(--at-line); }
.at-figure .at-label { display: block; margin-bottom: 6px; }
.at-figure p { margin: 6px 0 0; font-size: 12px; line-height: 1.5; color: var(--at-muted); }

/* ============================================================================
   CONTROLS
   ========================================================================= */

.at-input {
  width: 100%; padding: 7px 9px; font-size: 13.5px;
  background: var(--at-bg);
  border: 1px solid var(--at-field);
  border-radius: 2px;
}
.at-input:hover { border-color: #C9C8C4; }
.at-input:focus-visible { border-color: var(--at-accent); outline-offset: 0; }

.at-select {
  width: 100%; padding: 6px 8px; font-size: 13px;
  background: var(--at-bg);
  border: 1px solid var(--at-field);
  border-radius: 2px;
}

/* Square chips, never pills. Active is a solid accent fill — the one solid
   object on the page. */
.at-chips { display: flex; gap: 6px; flex-wrap: wrap; }
.at-chip {
  padding: 5px 11px; font-family: var(--at-font-display); font-size: 12.5px;
  letter-spacing: .02em; cursor: pointer;
  background: var(--at-panel); color: var(--at-ink);
  border: 1px solid var(--at-field); border-radius: 2px;
}
.at-chip:hover { background: var(--at-hover); }
.at-chip:active { background: var(--at-accent-100); }
.at-chip[aria-pressed="true"],
.at-chip.is-on { background: var(--at-accent); border-color: var(--at-accent); color: #FFFFFF; }

/* A vertical radio list that reads as navigation, not as a form. */
.at-optlist { display: flex; flex-direction: column; gap: 1px; }
.at-opt {
  display: flex; align-items: center; gap: 8px; width: 100%; text-align: left;
  padding: 6px 8px; font-size: 13px; cursor: pointer;
  background: transparent; color: var(--at-muted); border: 0; border-radius: 2px;
}
.at-opt::before {
  content: ""; width: 7px; height: 7px; border-radius: 50%; flex: none;
  background: #D4D3CF;
}
.at-opt:hover { background: var(--at-hover); }
.at-opt[aria-selected="true"],
.at-opt.is-on { background: var(--at-tint); color: var(--at-ink); }
.at-opt[aria-selected="true"]::before,
.at-opt.is-on::before { background: var(--at-accent); }

.at-range { width: 100%; height: 20px; cursor: pointer; accent-color: var(--at-accent); }

/* Buttons. Primary is the accent fill; secondary is a hairline outline. */
.at-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font-family: var(--at-font-display); font-weight: 600; font-size: 14px; line-height: 1.2;
  padding: var(--at-2) var(--at-4); cursor: pointer;
  background: transparent; color: var(--at-ink);
  border: 1px solid transparent; border-radius: 2px;
}
.at-btn-primary { background: var(--at-accent); color: #FFFFFF; }
.at-btn-primary:hover { background: var(--at-accent-600); }
.at-btn-primary:active { background: var(--at-accent-700); }
.at-btn-secondary { border-color: var(--at-field); }
.at-btn-secondary:hover { background: var(--at-hover); }
.at-btn:disabled { opacity: .45; cursor: not-allowed; }

/* ============================================================================
   HOUR STRIP
   A time control that is also the distribution it selects from: one column
   per hour, height = share of activity, click to choose. Replaces a slider
   plus a chart with one object. Generalises to any bucketed dimension.
   ========================================================================= */

.at-strip { display: flex; align-items: flex-end; gap: 2px; height: 84px; flex: 1; }
.at-strip-col {
  flex: 1; display: flex; flex-direction: column; justify-content: flex-end; gap: 5px;
  height: 100%; padding: 0; background: transparent; border: 0; cursor: pointer;
}
.at-strip-bar { display: block; width: 100%; background: #DEDDD8; transition: background .12s; }
.at-strip-col:hover .at-strip-bar { background: #CFCEC9; }
.at-strip-col.is-on .at-strip-bar { background: var(--at-accent); }
.at-strip-tick { font-size: 10px; font-variant-numeric: tabular-nums; color: var(--at-faint); line-height: 1; }
.at-strip-col.is-on .at-strip-tick { color: var(--at-ink); font-weight: 600; }

/* The readout that sits beside it. */
.at-readout { display: flex; flex-direction: column; min-width: 150px; }
.at-readout-value { font-family: var(--at-font-display); font-size: 30px; font-weight: 600;
  line-height: 1.1; letter-spacing: -.01em; font-variant-numeric: tabular-nums; }
.at-readout-note { font-size: 11.5px; color: var(--at-faint); margin-top: 2px; }

/* ============================================================================
   TABLE
   Header is a micro-label row; rows are separated by hairlines only.
   Numeric columns are right-aligned and tabular, always.
   ========================================================================= */

.at-table { width: 100%; border-collapse: collapse; }
.at-table th {
  text-align: left; padding: 7px 8px;
  font-size: 10.5px; font-weight: 600; letter-spacing: .11em; text-transform: uppercase;
  color: var(--at-faint);
  border-bottom: 1px solid var(--at-border-firm);
}
.at-table td { padding: 7px 8px; font-size: 13px; border-bottom: 1px solid var(--at-line); }
.at-table .at-td-num { text-align: right; font-variant-numeric: tabular-nums; }
.at-table th.at-td-num { text-align: right; }
.at-table .at-td-quiet { color: var(--at-muted); }
.at-table tbody tr[data-clickable] { cursor: pointer; }
.at-table tbody tr[data-clickable]:hover { background: var(--at-hover); }

/* Ranked list: an index column in faint ink, and a bar behind the figure so
   rank reads before the number does. The bar is the data color at 14% — it
   must never compete with the numeral. */
.at-rank-index { width: 26px; padding: 7px 4px 7px 0; text-align: right;
  font-size: 11.5px; font-variant-numeric: tabular-nums; color: #C3C2BE; }
.at-cell-bar { position: relative; }
.at-cell-bar > .at-bar {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  height: 14px; max-width: 88px; background: var(--at-neg); opacity: .14;
}
.at-cell-bar > span:last-child { position: relative; }

/* Two columns of a single ranking, so a 12-row list fills a wide panel
   without becoming a 12-row column of white space. */
.at-rank-split { display: grid; grid-template-columns: repeat(auto-fit, minmax(420px, 1fr)); gap: 0 40px; }

/* Key/value block for a detail panel. */
.at-kv { display: grid; grid-template-columns: 1fr auto; gap: 0 var(--at-4); margin: 0; }
.at-kv dt { color: var(--at-muted); font-size: 13px; padding: 4px 0; }
.at-kv dd {
  margin: 0; text-align: right; padding: 4px 0;
  font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums;
}

/* ============================================================================
   VERDICT — a plain-language conclusion above the numbers that produced it.
   A colored dot carries the state; no tinted box, no left-border accent bar.
   ========================================================================= */

.at-verdict {
  display: flex; align-items: flex-start; gap: var(--at-3);
  padding: var(--at-3) 0;
  border-top: 1px solid var(--at-line);
  border-bottom: 1px solid var(--at-line);
}
.at-verdict-dot { width: 9px; height: 9px; border-radius: 50%; flex: none; margin-top: 5px; background: var(--at-mid); }
.at-verdict-text { font-size: 15px; font-weight: 600; line-height: 1.35; }

/* ============================================================================
   POPOVER / TOOLTIP — the only elevated surfaces.
   ========================================================================= */

.at-pop {
  background: var(--at-panel);
  border: 1px solid var(--at-border-firm);
  border-radius: 2px;
  box-shadow: var(--at-shadow);
}
.at-tip { position: fixed; z-index: 60; pointer-events: none; max-width: 280px;
  padding: 9px 11px; font-size: 12.5px; opacity: 0; transition: opacity .1s; }
.at-tip.is-on { opacity: 1; }
.at-tip-title { font-family: var(--at-font-display); font-size: 15px; font-weight: 600; margin-bottom: 4px; }
.at-tip-row { display: flex; justify-content: space-between; gap: var(--at-4);
  color: var(--at-muted); font-variant-numeric: tabular-nums; }
.at-tip-row b { color: var(--at-ink); font-weight: 600; }

.at-results { max-height: 280px; overflow: auto; }
.at-result {
  display: flex; align-items: center; gap: 8px; padding: 7px 10px; cursor: pointer;
  border-bottom: 1px solid var(--at-line); font-size: 12.5px;
}
.at-result:hover, .at-result.is-on { background: var(--at-tint); }

/* ============================================================================
   DATA VISUALISATION
   Charts inherit the same ink. Rules: gridlines in --at-line, baseline in
   --at-border-firm, axis text in --at-faint at 10px tabular, series in
   --at-pos / --at-neg, fills at 10-13% opacity, highlight bands in the
   accent at 10%. No gradients, no rainbow scales, no legends where a direct
   label will do.
   ========================================================================= */

.at-chart { display: block; width: 100%; overflow: visible; }
.at-gridline { stroke: var(--at-line); }
.at-baseline  { stroke: var(--at-border-firm); }
.at-axlab { fill: var(--at-faint); font-size: 10px; font-variant-numeric: tabular-nums; }
.at-serieslab { fill: var(--at-ink); font-size: 12px; font-weight: 600; }
.at-series-pos { stroke: var(--at-pos); fill: none; stroke-width: 2; stroke-linejoin: round; }
.at-series-neg { stroke: var(--at-neg); fill: none; stroke-width: 2; stroke-linejoin: round; }
.at-area-pos { fill: var(--at-pos); opacity: .10; stroke: none; }
.at-band     { fill: var(--at-pos); opacity: .13; stroke: none; }
.at-highlight{ fill: var(--at-accent); opacity: .10; }
.at-marker { stroke: var(--at-panel); stroke-width: 1.8; }

/* Diverging ramp for a legend swatch. In code, interpolate between
   --at-neg → --at-mid → --at-pos; never use a hue rotation. */
.at-ramp { height: 8px; width: 100%; background: linear-gradient(90deg, var(--at-neg), var(--at-mid), var(--at-pos)); }
.at-ramp-seq { height: 8px; width: 100%; background: linear-gradient(90deg, var(--at-mid), var(--at-neg)); }
.at-ramp-ends { display: flex; justify-content: space-between; margin-top: 5px; font-size: 11.5px; color: var(--at-muted); }

/* A legend belongs on the thing it explains, not in a side rail. */
.at-map-legend {
  position: absolute; left: 12px; bottom: 12px; width: 236px; padding: 11px 12px;
  background: rgba(255, 255, 255, .94);
  border: 1px solid var(--at-field); border-radius: 2px;
}

/* Cross-highlighting: a hovered row lights its mark on the map. Set these
   attributes on the SVG node directly rather than re-rendering the layer. */
.at-mark { stroke: rgba(29, 31, 32, .28); stroke-width: .8; fill-opacity: .9; cursor: pointer; }
.at-mark.is-active, .at-mark.is-selected { stroke: var(--at-ink); stroke-width: 2; }

/* Muted basemap tiles, so the data reads as the subject and the streets do not. */
.at-basemap img { filter: saturate(.06) contrast(.92) brightness(1.04); }
.at-map-well { position: relative; overflow: hidden; background: var(--at-sunken); cursor: grab; touch-action: none; user-select: none; }
.at-map-well.is-dragging { cursor: grabbing; }
/* A working view fills the screen; it is not a 640px card in a scroll page. */
.at-map-fill { height: calc(100vh - 168px); min-height: 560px; }

/* ============================================================================
   LAYOUT HELPERS
   ========================================================================= */

/* rail | content | detail — the analyst layout. */
.at-workspace { display: grid; grid-template-columns: 236px minmax(0, 1fr) 336px; gap: var(--at-6); align-items: start; }
.at-rail { position: sticky; top: 72px; display: flex; flex-direction: column; gap: var(--at-6); padding: var(--at-6) var(--at-4); }
.at-rail-group { display: flex; flex-direction: column; gap: 8px; }

.at-split { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); gap: var(--at-6); }
.at-prose { display: grid; grid-template-columns: 180px minmax(0, 1fr); gap: var(--at-8); }
.at-prose-cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 26px 40px; max-width: 1100px; }

@media (max-width: 1280px) {
  .at-workspace { grid-template-columns: 220px minmax(0, 1fr); }
  .at-workspace > :last-child { grid-column: 1 / -1; position: static; }
  .at-split { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  h1 { font-size: 38px; }
  .at-workspace { grid-template-columns: 1fr; }
  .at-rail { position: static; }
  .at-stats { flex-wrap: wrap; }
  .at-figures { grid-template-columns: repeat(2, 1fr); }
  .at-prose { grid-template-columns: 1fr; gap: var(--at-4); }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
