/* ============================================================
   Corryk Observations — shared styles
   Palette + type mirror the main site (index.html tokens)
   ============================================================ */
:root {
  /* terminal-light: ink on cream (matches Corryk Terminal + Perspectives) */
  --ivory: #1a140f;                          /* primary "ink" */
  --ivory-dim: rgba(26, 20, 15, 0.68);
  --ivory-faint: rgba(26, 20, 15, 0.42);
  --ivory-line: rgba(26, 20, 15, 0.26);
  --ivory-hairline: rgba(26, 20, 15, 0.13);
  --cream: #faf6ee;
  --dark: #faf6ee;                           /* page background (cream) */
  --dark-2: #f5f0e8;
  --dark-3: #efe8da;
  --panel: rgba(253, 250, 244, 0.92);
  --panel-solid: #fdfaf4;
  --amber: #3f7ba3;                          /* terracotta (terminal accent) */
  --amber-bright: #27506b;
  --serif: "Fraunces", "Times New Roman", Georgia, serif;
  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { min-height: 100%; -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--sans);
  color: var(--ivory);
  background: var(--dark);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* Site chrome (header, buttons, mobile menu, footer) lives in chrome.css */

/* ===== Observations landing ===== */
.obs-hero { padding: 80px 56px 48px; max-width: 920px; margin: 0 auto; }
.obs-hero__kicker {
  font-size: 12px; font-weight: 600; letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--amber); margin-bottom: 18px;
}
.obs-hero__title {
  font-family: var(--serif); font-weight: 300; font-size: clamp(44px, 6.4vw, 72px);
  letter-spacing: -0.02em; line-height: 1.0; max-width: 760px;
}
.obs-hero__sub {
  margin-top: 22px; font-size: 17px; line-height: 1.6; color: var(--ivory-dim); max-width: 640px;
}
.obs-grid {
  max-width: 920px; margin: 24px auto 120px; padding: 0 56px;
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px;
}
.obs-card {
  border: 1px solid var(--ivory-hairline); border-radius: 3px;
  padding: 26px 24px 22px; text-decoration: none; color: var(--ivory);
  background: linear-gradient(160deg, rgba(245,240,232,0.03), rgba(245,240,232,0.0));
  transition: border-color 0.2s ease, transform 0.2s ease; position: relative; overflow: hidden;
  display: flex; flex-direction: column; min-height: 210px;
}
.obs-card:hover { border-color: var(--ivory-line); transform: translateY(-2px); }
.obs-card--soon { opacity: 0.55; pointer-events: none; }
.obs-card__num {
  font-family: var(--serif); font-size: 13px; color: var(--ivory-faint); margin-bottom: 14px;
}
.obs-card__title { font-family: var(--serif); font-weight: 400; font-size: 24px; margin-bottom: 10px; }
.obs-card__desc { font-size: 14px; line-height: 1.55; color: var(--ivory-dim); flex: 1; }
.obs-card__tag {
  margin-top: 18px; font-size: 11px; font-weight: 600; letter-spacing: 0.12em;
  text-transform: uppercase; color: var(--amber);
}
.obs-card--soon .obs-card__tag { color: var(--ivory-faint); }

/* ===== Instrument page layout ===== */
.viewport { height: 100dvh; display: flex; flex-direction: column; }
.viewport > .header { flex: 0 0 auto; }
.instrument { position: relative; flex: 1 1 auto; min-height: 0; overflow: hidden; }
#map { position: absolute; inset: 0; background: var(--cream); }
.maplibregl-ctrl-attrib {
  background: rgba(250,246,238,0.75) !important; color: var(--ivory-faint);
  font-size: 10px !important;
}
.maplibregl-ctrl-attrib a { color: var(--ivory-faint) !important; }

/* Control rail (desktop: floating left card) */
.rail {
  position: absolute; top: 18px; left: 18px; z-index: 20;
  width: 300px; max-height: calc(100% - 36px);
  background: var(--panel); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--ivory-hairline); border-radius: 4px;
  box-shadow: 0 8px 28px rgba(26, 20, 15, 0.10);
  display: flex; flex-direction: column; overflow: hidden;
}
.rail--inflow { box-shadow: none; background: var(--panel-solid); backdrop-filter: none; -webkit-backdrop-filter: none; }
.rail__scroll { overflow-y: auto; padding: 18px 18px 14px; scrollbar-width: thin; }
.rail__title {
  font-family: var(--serif); font-weight: 400; font-size: 21px; margin-bottom: 2px;
}
.rail__subtitle { font-size: 12px; color: var(--ivory-faint); margin-bottom: 16px; }
.rail__group { margin-bottom: 16px; }
.rail__label {
  display: block; font-size: 11px; font-weight: 600; letter-spacing: 0.1em;
  text-transform: uppercase; color: var(--ivory-faint); margin-bottom: 8px;
}
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  font-family: var(--sans); font-size: 12.5px; font-weight: 500;
  padding: 6px 11px; border-radius: 2px; cursor: pointer;
  background: transparent; color: var(--ivory-dim);
  border: 1px solid var(--ivory-hairline); transition: all 0.15s ease;
}
.chip:hover { border-color: var(--ivory-line); color: var(--ivory); }
.chip--on { background: #1a140f; color: #faf6ee; border-color: #1a140f; }
select.obs-select {
  width: 100%; font-family: var(--sans); font-size: 13px; padding: 8px 10px;
  background: var(--dark-2); color: var(--ivory);
  border: 1px solid var(--ivory-hairline); border-radius: 2px; outline: none;
}
.slider-row { display: flex; align-items: center; gap: 10px; }
.slider-row input[type="range"] {
  flex: 1; accent-color: var(--amber); height: 3px; cursor: pointer;
}
.slider-row output {
  font-size: 12px; font-variant-numeric: tabular-nums; color: var(--ivory-dim);
  min-width: 42px; text-align: right;
}

/* Legend */
.legend { padding: 12px 18px 14px; border-top: 1px solid var(--ivory-hairline); }
.legend__bar { height: 8px; border-radius: 2px; margin-bottom: 6px; }
.legend__ticks {
  display: flex; justify-content: space-between; font-size: 10.5px;
  color: var(--ivory-faint); font-variant-numeric: tabular-nums;
}

/* Read-out strip */
.readout {
  position: absolute; top: 18px; left: 336px; right: 356px; z-index: 15;
  display: flex; justify-content: center; pointer-events: none;
}
.readout__card {
  pointer-events: auto; max-width: 640px;
  background: var(--panel); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--ivory-hairline); border-radius: 4px;
  box-shadow: 0 6px 22px rgba(26, 20, 15, 0.09);
  padding: 12px 20px; font-size: 13.5px; line-height: 1.5; color: var(--ivory-dim);
}
.readout__card strong { color: var(--ivory); font-weight: 600; }
.readout__card .hl { color: var(--amber-bright); font-weight: 600; }

/* Ranked panel (desktop right) */
.rank {
  position: absolute; top: 18px; right: 18px; bottom: 18px; z-index: 20;
  width: 320px; background: var(--panel); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--ivory-hairline); border-radius: 4px;
  box-shadow: 0 8px 28px rgba(26, 20, 15, 0.10);
  display: flex; flex-direction: column; overflow: hidden;
}
.rank__head { padding: 16px 18px 10px; border-bottom: 1px solid var(--ivory-hairline); }
.rank__title { font-family: var(--serif); font-size: 17px; font-weight: 400; }
.rank__sub { font-size: 11.5px; color: var(--ivory-faint); margin-top: 3px; }
.rank__list { overflow-y: auto; flex: 1; scrollbar-width: thin; }
.rank__row {
  display: grid; grid-template-columns: 26px 1fr auto; gap: 10px; align-items: center;
  padding: 9px 18px; cursor: pointer; border-bottom: 1px solid rgba(26,20,15,0.06);
  transition: background 0.12s ease;
}
.rank__row:hover, .rank__row--active { background: rgba(26,20,15,0.045); }
.rank__pos { font-family: var(--serif); font-size: 13px; color: var(--ivory-faint); }
.rank__name { font-size: 13px; font-weight: 500; line-height: 1.25; }
.rank__cc { font-size: 10.5px; color: var(--ivory-faint); letter-spacing: 0.06em; }
.rank__val {
  font-size: 13px; font-variant-numeric: tabular-nums; color: var(--amber-bright); font-weight: 600;
}
.rank__bar { grid-column: 2 / 4; height: 3px; background: rgba(26,20,15,0.08); border-radius: 2px; }
.rank__bar i { display: block; height: 100%; background: var(--amber); border-radius: 2px; }

/* Detail card (region click) */
.detail {
  position: absolute; z-index: 25; left: 18px; bottom: 18px; width: 300px;
  background: var(--panel-solid);
  border: 1px solid var(--ivory-line); border-radius: 4px; padding: 16px 18px;
  box-shadow: 0 8px 28px rgba(26, 20, 15, 0.12);
  display: none;
}
.detail--open { display: block; }
.detail__close {
  position: absolute; top: 8px; right: 10px; background: none; border: none;
  color: var(--ivory-faint); font-size: 18px; cursor: pointer; line-height: 1;
}
.detail__close:hover { color: var(--ivory); }
.detail__name { font-family: var(--serif); font-size: 19px; font-weight: 400; }
.detail__cc { font-size: 11px; color: var(--ivory-faint); letter-spacing: 0.08em; margin-bottom: 12px; }
.detail__rows { display: grid; gap: 7px; }
.detail__row { display: flex; justify-content: space-between; font-size: 12.5px; }
.detail__row span:first-child { color: var(--ivory-dim); }
.detail__row span:last-child { font-variant-numeric: tabular-nums; font-weight: 600; }

/* Tooltip */
.map-tip {
  position: absolute; z-index: 30; pointer-events: none; display: none;
  background: var(--panel-solid); border: 1px solid var(--ivory-line); border-radius: 3px;
  box-shadow: 0 4px 16px rgba(26, 20, 15, 0.14);
  padding: 8px 12px; font-size: 12px; line-height: 1.5; max-width: 240px;
  transform: translate(-50%, calc(-100% - 12px));
}
.map-tip strong { display: block; font-size: 13px; }
.map-tip em { font-style: normal; color: var(--amber-bright); font-weight: 600; }

/* Methodology drawer */
.method {
  position: absolute; bottom: 18px; right: 356px; z-index: 20;
}
.method__btn {
  font-size: 11.5px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--ivory-faint); background: var(--panel); border: 1px solid var(--ivory-hairline);
  border-radius: 3px; padding: 8px 14px; cursor: pointer;
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
}
.method__btn:hover { color: var(--ivory); border-color: var(--ivory-line); }
.method__panel {
  position: absolute; bottom: calc(100% + 10px); right: 0; width: 420px; max-width: 82vw;
  max-height: 55vh; overflow-y: auto;
  background: var(--panel-solid); border: 1px solid var(--ivory-line); border-radius: 4px;
  box-shadow: 0 8px 28px rgba(26, 20, 15, 0.12);
  padding: 18px 20px; display: none; scrollbar-width: thin;
}
.method__panel--open { display: block; }
.method__panel h3 { font-family: var(--serif); font-size: 17px; font-weight: 400; margin-bottom: 10px; }
.method__panel p, .method__panel li { font-size: 12.5px; line-height: 1.6; color: var(--ivory-dim); }
.method__panel ul { padding-left: 18px; margin: 8px 0; }
.method__panel h4 {
  font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--ivory-faint); margin: 14px 0 6px;
}

/* Mobile toggle buttons */
.m-toggles { display: none; }

/* ============ MOBILE ============ */
@media (max-width: 860px) {
  .header { padding: 16px 20px; }
  .header__actions .header__nav-link, .header__actions .btn { display: none; }
  .mobile-menu { display: block; }

  .obs-hero { padding: 48px 22px 28px; }
  .obs-grid { padding: 0 24px; grid-template-columns: 1fr; margin-bottom: 80px; }
  .obs-hero { padding: 48px 24px 32px; }

  

  /* rail becomes bottom sheet */
  .rail {
    top: auto; left: 0; right: 0; bottom: 0; width: 100%;
    max-height: 46dvh; border-radius: 12px 12px 0 0;
    border-left: none; border-right: none; border-bottom: none;
    transform: translateY(calc(100% - 52px));
    transition: transform 0.28s cubic-bezier(0.25, 0.9, 0.3, 1);
  }
  .rail--open { transform: translateY(0); }
  .rail__handle {
    display: flex; align-items: center; justify-content: center; gap: 8px;
    padding: 15px 0 13px; cursor: pointer; flex-shrink: 0;
  }
  .rail__handle::before {
    content: ""; width: 36px; height: 4px; border-radius: 2px;
    background: var(--ivory-line);
  }
  .rail__handle-label {
    font-size: 11px; font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase;
    color: var(--ivory-dim);
  }
  .rail__scroll { padding-top: 0; }

  .readout {
    top: 12px; left: 12px; right: 12px; justify-content: flex-start;
  }
  .readout__card { font-size: 12px; padding: 10px 14px; }

  .rank {
    top: auto; left: 0; right: 0; bottom: 0; width: 100%;
    max-height: 60dvh; border-radius: 12px 12px 0 0;
    border-left: none; border-right: none; border-bottom: none;
    transform: translateY(100%); transition: transform 0.28s cubic-bezier(0.25, 0.9, 0.3, 1);
  }
  .rank--open { transform: translateY(0); }

  .detail { left: 12px; right: 12px; width: auto; bottom: 64px; }
  .method { display: none; }

  .m-toggles {
    display: flex; gap: 8px; position: absolute; z-index: 22;
    bottom: 62px; right: 12px; flex-direction: column;
  }
  .m-toggle {
    font-size: 11px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase;
    background: var(--panel-solid); color: var(--ivory-dim);
    border: 1px solid var(--ivory-line); border-radius: 3px; padding: 9px 12px; cursor: pointer;
    box-shadow: 0 4px 14px rgba(26, 20, 15, 0.12);
  }
}

@media (min-width: 861px) {
  .rail__handle { display: none; }
}

/* selected chip keeps dark text on hover */
.chip--on:hover { color: #faf6ee; border-color: #1a140f; }
@media (max-width: 860px) {
  .maplibregl-ctrl-bottom-right .maplibregl-ctrl-group { display: none; }
}

/* ===== Observations dropdown ===== */
.nav-drop { position: relative; display: inline-block; }
.nav-drop__menu {
  position: absolute; top: 100%; left: 50%; transform: translateX(-50%);
  min-width: 218px; padding: 8px 0; display: none; z-index: 90;
  background: #fdfaf4; border: 1px solid rgba(26, 20, 15, 0.16); border-radius: 3px;
  box-shadow: 0 10px 30px rgba(26, 20, 15, 0.14);
}
.nav-drop:hover .nav-drop__menu, .nav-drop:focus-within .nav-drop__menu { display: block; }
.nav-drop__item {
  display: block; padding: 8px 18px; font-size: 13.5px; font-weight: 500;
  color: rgba(26, 20, 15, 0.72); text-decoration: none; white-space: nowrap;
}
a.nav-drop__item:hover { color: #1a140f; background: rgba(26, 20, 15, 0.05); }
.nav-drop__item--soon { color: rgba(26, 20, 15, 0.35); cursor: default; }
.nav-drop__item--soon::after { content: " · soon"; font-size: 11px; letter-spacing: 0.04em; }

/* Bloomberg-grade numerals: tabular figures everywhere numbers appear */
body { font-variant-numeric: tabular-nums; font-feature-settings: "tnum" 1; }
.rank__val, .detail__row span:last-child, .legend__ticks, .slider-row output { text-align: right; }

/* ===== Chart-page shared layout ===== */
.charts-col {
  position: absolute; top: 18px; bottom: 18px; left: 336px; right: 356px;
  display: flex; flex-direction: column; gap: 14px; min-width: 0;
  overflow-y: auto; scrollbar-width: thin;
}
.chart-card {
  background: var(--panel-solid); border: 1px solid var(--ivory-hairline); border-radius: 4px;
  padding: 14px 16px 10px;
  display: flex; flex-direction: column; flex-shrink: 0;
}
.chart-card__title { font-family: var(--serif); font-size: 16px; font-weight: 400; }
.chart-card__sub { font-size: 11px; color: var(--ivory-faint); margin-top: 2px; }
.chart-card__plot { width: 100%; }
.statgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 10px; margin-top: 12px; }
.stat {
  border: 1px solid var(--ivory-hairline); border-radius: 3px; padding: 12px 14px;
  background: linear-gradient(160deg, rgba(26,20,15,0.02), rgba(26,20,15,0));
}
.stat__num { font-family: var(--serif); font-size: 26px; color: #27506b; line-height: 1.1; }
.stat__label { font-size: 11.5px; line-height: 1.45; color: var(--ivory-dim); margin-top: 6px; }
.stat__src { font-size: 10px; color: var(--ivory-faint); margin-top: 6px; letter-spacing: 0.04em; }
@media (max-width: 860px) {
  .charts-col { position: static; height: auto; padding: 0 12px 8px; overflow: visible; }
  .rail--inflow, .rank--inflow {
    position: static; transform: none; width: auto; max-height: none;
    border-radius: 4px; margin: 12px; box-shadow: none; transition: none;
  }
  .rail--inflow { margin-bottom: 0; }
  .rail--inflow .rail__handle { display: none; }
  .rank--inflow { margin-top: 0; }
  .rank--inflow .rank__list { max-height: 420px; }
  .method--inflow { display: block; position: static; margin: 0 12px 24px; }
  .method--inflow .method__panel { position: static; width: auto; max-width: none; margin-top: 8px; }
}

/* methodology as footnote */
.methnotes h3 { display:none; }
.methnotes h4 { font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--ivory-faint); margin: 12px 0 5px; }
.methnotes ul { padding-left: 18px; margin: 6px 0; }
.methnotes p, .methnotes li { font-size: 12.5px; line-height: 1.6; color: var(--ivory-dim); }

/* Wide stat cards — for blocks carrying an argument rather than a number grid */
.statgrid--wide { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.statgrid--wide .stat__label { font-size: 11px; line-height: 1.5; }

/* Mobile: instrument pages must flow so the full content is scrollable and the
   footer sits after it — the desktop 100dvh + overflow:hidden clips content on
   phones. (Catchment Map handles this via body.page-map; this covers the chart
   pages: Price of Care, Companion Economy, Retirement Cliff.) */
@media (max-width: 860px) {
  .viewport { height: auto; min-height: 100dvh; }
  .instrument { height: auto; min-height: 0; overflow: visible; }
}
