/* Access to Work | Île-de-France. Loaded automatically by Dash (assets_folder = app/static).
   Tokens from Mobility_Atlas_Figma_Handoff/design_tokens.json. */

:root {
  --bg: #f6f7f3;
  --card: #ffffff;
  --ink: #172e30;
  --muted: #5d6f6e;      /* slightly darker than the token (#687A79) to pass WCAG AA at 11-12px */
  --line: #e1e9e4;
  --nav: #102b30;
  --teal: #126f73;
  --mint: #b9dbd2;
  --car: #e38c58;
  --car-ink: #a8541f;    /* orange dark enough for text */
  --warn: #b64f4b;
  --r-card: 16px;
  --r-pill: 9px;
  --r-tool: 13px;
  --gap: 12px;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, Arial, sans-serif;
  font-size: 13px;
  line-height: 1.45;
}

h1,
h2,
h3,
p {
  margin: 0;
}

.hidden {
  display: none !important;
}

/* --- Shell --------------------------------------------------------------- */

.app {
  display: grid;
  grid-template-columns: 222px minmax(0, 1fr);
  height: 100vh;
  min-height: 680px;
}

.sidebar {
  background: var(--nav);
  color: #dfe9e6;
  padding: 20px 14px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.brand {
  display: flex;
  flex-direction: column;
  padding: 0 8px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.brand-name {
  font-size: 17px;
  font-weight: 750;
  letter-spacing: 0.02em;
  color: #fff;
}

.brand-sub {
  font-size: 12px;
  color: #a9c3bd;
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav label {
  display: flex !important;
  align-items: center;
  padding: 9px 12px;
  border-radius: 10px;
  color: #c5d6d2;
  font-weight: 600;
  cursor: pointer;
}

.nav label:hover {
  background: rgba(255, 255, 255, 0.06);
}

.nav label:has(input:checked) {
  background: #1d4a4e;
  color: #fff;
}

.nav input,
.pills input[type="radio"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.nav label:focus-within,
.pills label:focus-within,
.btn:focus-visible,
.btn-step:focus-visible,
.btn-ghost:focus-visible {
  outline: 3px solid #ffbf47;
  outline-offset: 2px;
}

.side-note {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 12px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.06);
  font-size: 11px;
  color: #c5d6d2;
}

.side-note strong {
  color: #fff;
  font-size: 12px;
}

.side-note .overline {
  color: #8fb3ab;
}

.main {
  display: flex;
  flex-direction: column;
  gap: var(--gap);
  padding: 16px 24px 16px;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

/* --- Header and story ------------------------------------------------------ */

.topbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
}

.overline {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--teal);
}

h1 {
  font-size: 27px;
  line-height: 1.15;
  font-weight: 750;
  letter-spacing: -0.01em;
}

h2 {
  font-size: 17px;
  line-height: 1.2;
  font-weight: 740;
}

h3 {
  font-size: 14px;
  font-weight: 700;
}

.sub {
  color: var(--muted);
  font-size: 12px;
}

.btn,
.btn-step,
.btn-ghost {
  font: inherit;
  font-weight: 650;
  border-radius: var(--r-pill);
  padding: 8px 14px;
  cursor: pointer;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink);
  white-space: nowrap;
}

.btn {
  background: var(--teal);
  border-color: var(--teal);
  color: #fff;
}

.story {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 14px;
  border-radius: var(--r-tool);
  background: #e9f3ef;
  border: 1px solid var(--mint);
}

.story-steps {
  display: flex;
  gap: 6px;
}

.story.step-1 #story-1,
.story.step-2 #story-2,
.story.step-3 #story-3 {
  background: var(--teal);
  border-color: var(--teal);
  color: #fff;
}

.story-text {
  flex: 1;
  font-size: 13px;
}

/* --- Toolbar ----------------------------------------------------------------- */

.toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 14px;
  padding: 8px 12px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-tool);
}

.tool {
  display: flex;
  align-items: center;
  gap: 8px;
}

.tool-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}

.tool-search {
  flex: 1;
  min-width: 150px;
  justify-content: flex-end;
}

.tool-search > div {
  width: 100%;
  max-width: 260px;
}

.pills {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.pills label {
  display: inline-flex !important;
  align-items: center;
  margin: 0 !important;
  padding: 6px 9px;
  border: 1px solid var(--line);
  border-radius: var(--r-pill);
  background: var(--card);
  font-weight: 650;
  font-size: 11.5px;
  cursor: pointer;
  white-space: nowrap;
}

.pills label:has(input:checked) {
  background: var(--teal);
  border-color: var(--teal);
  color: #fff;
}

.pills.is-disabled label {
  opacity: 0.45;
  cursor: not-allowed;
}

.pills.is-disabled label:has(input:checked) {
  background: var(--card);
  border-color: var(--line);
  color: var(--ink);
}

/* --- Views -------------------------------------------------------------------- */

.view {
  flex: 1;
  min-height: 0;
  display: grid;
  gap: var(--gap);
}

.view-explore {
  grid-template-columns: minmax(0, 1.75fr) minmax(320px, 1fr);
  grid-template-rows: auto minmax(0, 1fr);
}

.view-explore .kpis {
  grid-column: 1 / -1;
}

.view-commune {
  grid-template-columns: minmax(0, 1.75fr) minmax(320px, 1fr);
}

.view-equity {
  grid-template-columns: minmax(0, 1.3fr) minmax(360px, 1fr);
  grid-template-rows: minmax(0, 1fr) minmax(0, 1fr);
}

.view-equity .map-card {
  grid-row: 1 / -1;
}

.view-compare {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr) auto;
}

.view-compare .cmp-head,
.view-compare .cmp-foot {
  grid-column: 1 / -1;
}

.view-priorities {
  grid-template-columns: minmax(0, 1.9fr) minmax(300px, 1fr);
}

.view-method {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-card);
  padding: 14px 16px;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.card-head > div:first-child {
  flex: 1;
  min-width: 0;
}

.map-mode {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex-shrink: 0;
}

.map-mode .pills {
  flex-wrap: nowrap;
}

.metric-select {
  display: flex;
  flex-direction: column;
  gap: 2px;
  width: 205px;
  flex-shrink: 0;
}

.map-wrap,
.chart-wrap,
.table-wrap {
  flex: 1;
  min-height: 0;
  position: relative;
}

.map-wrap {
  background: #eceeea;   /* light warm-grey canvas: every class, including the palest, stands out */
  border-radius: 12px;
  overflow: hidden;
}

/* Floating map legend (bottom left) and zoom presets (top left). */
.map-legend {
  position: absolute;
  left: 10px;
  bottom: 10px;
  z-index: 5;
  width: 300px;
  max-width: calc(100% - 20px);
  padding: 8px 12px 7px;
  background: rgba(255, 255, 255, 0.93);
  border: 1px solid var(--line);
  border-radius: 10px;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-size: 10.5px;
}

.map-legend:empty {
  display: none;
}

.map-legend.inline {
  position: static;
  width: 340px;
  border: 0;
  padding: 0;
  background: none;
}

.map-legend .legend-title {
  font-size: 9.5px;
  line-height: 1.3;
  margin: 0;
}

.legend-bar {
  display: flex;
  height: 10px;
  border-radius: 3px;
  overflow: hidden;
  border: 1px solid rgba(23, 46, 48, 0.25);
}

.legend-bar i {
  flex: 1;
}

.legend-ticks {
  position: relative;
  height: 13px;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.legend-ticks span {
  position: absolute;
  top: 0;
  transform: translateX(-50%);
  white-space: nowrap;
}

.legend-ticks .end-left {
  transform: none;
}

.legend-ticks .end-right {
  transform: translateX(-100%);
}

.legend-extras {
  display: flex;
  flex-wrap: wrap;
  gap: 2px 10px;
}

.map-tools {
  position: absolute;
  left: 10px;
  top: 10px;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 8px;
  background: rgba(255, 255, 255, 0.93);
  border: 1px solid var(--line);
  border-radius: 10px;
}

.map-tools .pills label {
  padding: 4px 8px;
  font-size: 11px;
}

.map-wrap > .dash-graph,
.chart-wrap > .dash-graph {
  position: absolute;
  inset: 0;
}

.table-wrap {
  overflow: auto;
}

.panel {
  overflow-y: auto;
  gap: 8px;
}

.panel .overline {
  margin-top: 6px;
}

/* --- KPIs ---------------------------------------------------------------------- */

.kpis {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--gap);
}

.kpi {
  background: var(--card);
  border: 1px solid var(--line);
  border-left: 4px solid var(--teal);
  border-radius: var(--r-card);
  padding: 10px 16px;
}

.kpi-warn {
  border-left-color: var(--warn);
}

.kpi-car {
  border-left-color: var(--car);
}

.kpi .overline {
  color: var(--muted);
}

.kpi > div {
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.kpi strong {
  font-size: 30px;
  line-height: 1.1;
  font-weight: 750;
  font-variant-numeric: tabular-nums;
}

.kpi-warn strong {
  color: var(--warn);
}

.kpi span {
  color: var(--muted);
  font-size: 12px;
}

/* --- Panel pieces ------------------------------------------------------------------ */

.big {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.big strong {
  font-size: 38px;
  line-height: 1;
  font-weight: 750;
  color: var(--warn);
  font-variant-numeric: tabular-nums;
}

.big span {
  color: var(--ink);
  font-size: 13px;
}

.bars {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.bar-row {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr) 40px;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  color: var(--muted);
}

.bar-track {
  height: 8px;
  border-radius: 999px;
  background: #edf2ef;
  overflow: hidden;
}

.bar-track > div {
  height: 100%;
  border-radius: 999px;
  opacity: 0.55;
}

.bar-value {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-weight: 650;
}

.bar-row.is-selected {
  color: var(--ink);
  font-weight: 750;
}

.bar-row.is-selected .bar-track {
  height: 11px;
}

.bar-row.is-selected .bar-track > div {
  opacity: 1;
}

.insight {
  padding: 9px 12px;
  border-radius: 10px;
  background: #eef5f2;
  font-weight: 600;
  font-size: 12px;
}

.caveat,
.hint {
  color: var(--muted);
  font-size: 11px;
}

.caveat.warn {
  color: var(--warn);
  font-weight: 600;
}

.finding {
  font-weight: 650;
  font-size: 13px;
}

.mini-graph {
  height: 180px;
  flex-shrink: 0;
}

.mini-graph.tall {
  height: 230px;
}

.detail summary {
  cursor: pointer;
  font-weight: 650;
  color: var(--teal);
  font-size: 12px;
}

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

.stat-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 22px;
}

.stat {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.stat-grid .stat {
  padding: 8px 10px;
  border-radius: 10px;
  background: #f4f8f6;
}

.stat-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.stat strong {
  font-size: 20px;
  line-height: 1.2;
  font-weight: 750;
  color: var(--teal);
  font-variant-numeric: tabular-nums;
}

.stat.car strong {
  color: var(--car-ink);
}

.stat.warn strong {
  color: var(--warn);
}

.stat-note {
  font-size: 11px;
  color: var(--muted);
}

.notes {
  margin: 0;
  padding-left: 18px;
  color: var(--ink);
  font-size: 12.5px;
}

.notes li {
  margin-bottom: 6px;
}

/* --- Legend ------------------------------------------------------------------------- */

.legend {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 12px;
  font-size: 11px;
  color: var(--ink);
}

.legend-title {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin-right: 4px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
}

.chip i {
  width: 14px;
  height: 10px;
  border-radius: 3px;
  border: 1px solid rgba(23, 46, 48, 0.18);
}

/* --- Compare -------------------------------------------------------------------------- */

.cmp-head {
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.cmp-side {
  display: flex;
  align-items: center;
  gap: 22px;
  flex: 1;
}

.delta {
  padding: 8px 14px;
  border-radius: 10px;
  background: #eef5f2;
  font-size: 18px;
  font-weight: 750;
  color: var(--teal);
  white-space: nowrap;
}

.delta.up {
  background: #f9e9e4;
  color: var(--warn);
}

.cmp-foot {
  gap: 8px;
}

/* --- Dash components ------------------------------------------------------------------- */

.Select-control,
.dash-dropdown .Select-control {
  border-color: var(--line) !important;
  border-radius: var(--r-pill) !important;
  font-size: 12px;
}

@media (max-width: 1520px) {
  .map-card h2 {
    font-size: 15px;
  }

  .kpi strong {
    font-size: 26px;
  }
}

/* --- Tablet ------------------------------------------------------------------------------ */

@media (max-width: 1180px) {
  .app {
    grid-template-columns: 170px minmax(0, 1fr);
  }

  .view-explore,
  .view-commune {
    grid-template-columns: minmax(0, 1.3fr) minmax(280px, 1fr);
  }

  h1 {
    font-size: 22px;
  }
}

/* --- Mobile: map first, panels stacked, page scrolls ------------------------------------- */

@media (max-width: 820px) {
  .app {
    display: block;
    height: auto;
    min-height: 0;
  }

  .sidebar {
    flex-direction: row;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    padding: 10px 12px;
  }

  .brand {
    border: 0;
    padding: 0 8px 0 0;
  }

  .nav {
    flex-direction: row;
    flex-wrap: wrap;
  }

  .nav label {
    padding: 6px 10px;
  }

  .side-note {
    display: none;
  }

  .main {
    overflow: visible;
    padding: 12px;
    max-width: 100vw;
  }

  .tool {
    flex-wrap: wrap;
    min-width: 0;
  }

  .tool-search {
    flex-basis: 100%;
    justify-content: flex-start;
  }

  .tool-search > div {
    max-width: none;
  }

  .kpi > div,
  .big {
    flex-wrap: wrap;
  }

  h1 {
    font-size: 21px;
  }

  .topbar {
    flex-direction: column;
    align-items: flex-start;
  }

  .story {
    flex-direction: column;
    align-items: flex-start;
  }

  .view,
  .view-explore,
  .view-commune,
  .view-equity,
  .view-compare,
  .view-priorities,
  .view-method {
    display: flex;
    flex-direction: column;
  }

  .kpis {
    grid-template-columns: minmax(0, 1fr);
  }

  .map-card {
    height: 440px;
  }

  .chart-card {
    height: 330px;
  }

  .table-card {
    height: 520px;
  }

  .panel {
    overflow: visible;
  }

  .card-head,
  .cmp-head,
  .cmp-side {
    flex-direction: column;
    align-items: flex-start;
  }

  .metric-select {
    width: 100%;
  }

  .stat-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* Keep the map card's text on fixed-height lines, so the map area never changes size after the
   map is drawn (a late size change leaves the map cropped until the next redraw). */
.map-card .card-head h2,
.map-card .card-head .sub,
.map-card > .caveat,
.map-card > .sub {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-height: 1.45em;
}

.kpis {
  min-height: 68px;
}

/* Checkbox pills (map overlays): keep the box visible so on/off is not shown by colour alone. */
.pills input[type="checkbox"] {
  margin: 0 5px 0 0;
  accent-color: var(--teal);
}
