/* Editorial Financial Component Styles
 * Inspired by Financial Times Visual Journalism & Bloomberg Graphics:
 * crisp typographic hierarchy, hairline rules, dotted evidence links, bespoke SVG data viz.
 */

/* ── Editorial Typography ─────────────────────────────────────────────── */
.eyebrow {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: var(--fs-micro);
  font-weight: 600;
  color: var(--vermilion);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 6px;
}

.eyebrow-rule {
  flex: 1;
  height: 1px;
  background: var(--rule);
}

.headline {
  font-family: var(--font-display);
  font-size: var(--fs-h1);
  font-weight: 600;
  line-height: 1.22;
  margin: 0 0 8px;
  color: var(--ink);
  letter-spacing: -0.015em;
}

.lead {
  font-size: var(--fs-body);
  color: var(--ink-2);
  margin: 0 0 16px;
  line-height: 1.62;
}

.subhead {
  font-family: var(--font-display);
  font-size: var(--fs-h2);
  font-weight: 600;
  margin: 18px 0 6px;
  color: var(--ink);
  line-height: 1.3;
}

.caption {
  font-size: var(--fs-micro);
  color: var(--ink-muted);
  line-height: 1.48;
  margin-top: 6px;
}

/* ── Editorial Hero Metric Rail ───────────────────────────────────────── */
.hero-rail {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  border-top: 1.5px solid var(--rule-strong);
  border-bottom: 1px solid var(--rule);
  margin: 14px 0 16px;
}

.hero-cell {
  padding: 11px 8px 10px 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.hero-cell + .hero-cell {
  border-inline-start: 1px solid var(--rule);
  padding-inline-start: 11px;
}

.hero-num {
  font-family: var(--font-serif-en);
  font-size: 1.65rem;
  font-weight: 600;
  line-height: 1.05;
  color: var(--ink);
}

.hero-num.pos { color: var(--forest); }
.hero-num.neg { color: var(--vermilion); }
.hero-num.muted { color: var(--ink-muted); }

.hero-label {
  font-size: 0.72rem;
  color: var(--ink-muted);
  line-height: 1.3;
}

/* ── Clickable Evidence Numbers (Signature Trust Layer) ───────────────── */
.ev-link {
  appearance: none;
  background: none;
  border: 0;
  padding: 0 1px;
  font: inherit;
  color: inherit;
  cursor: pointer;
  border-bottom: 1.5px dotted currentColor;
  transition: background-color var(--t-fast), color var(--t-fast);
}

.ev-link:hover,
.ev-link:focus-visible {
  background: var(--vermilion-soft);
  color: var(--vermilion);
  outline: none;
  border-radius: 2px;
}

/* ── Confidence / Tier Badges ─────────────────────────────────────────── */
.tier-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.7rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 2px;
  border: 1px solid var(--rule);
  background: var(--paper-sunk);
  color: var(--ink-2);
  white-space: nowrap;
}

.tier-badge::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.tier-badge.tier-quasi_exp   { color: var(--forest); border-color: color-mix(in srgb, var(--forest) 35%, transparent); background: var(--forest-soft); }
.tier-badge.tier-correlational { color: var(--slate); border-color: color-mix(in srgb, var(--slate) 35%, transparent); background: var(--slate-soft); }
.tier-badge.tier-watchlist   { color: var(--ochre); border-color: color-mix(in srgb, var(--ochre) 40%, transparent); background: var(--ochre-soft); }
.tier-badge.tier-descriptive { color: var(--ink-muted); }

/* ── Story Progress Dots & Inline Callouts ────────────────────────────── */
.story-dots {
  display: flex;
  align-items: center;
  gap: 6px;
}

.story-dot {
  width: 22px;
  height: 3px;
  border: 0;
  padding: 0;
  border-radius: 1px;
  background: var(--rule);
  cursor: pointer;
  transition: background-color var(--t-fast), width var(--t-med) var(--ease-editorial);
}

.story-dot.is-done { background: var(--ink-muted); }
.story-dot.is-current { background: var(--vermilion); width: 34px; }

/* Visual Map-to-Chart Key (instant orientation on first glance) */
.visual-key {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 12px 0 14px;
  padding: 10px 12px;
  background: var(--paper-sunk);
  border: 1px solid var(--rule);
  border-radius: var(--r-xs);
}

.vk-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 0.76rem;
  line-height: 1.38;
  color: var(--ink-2);
}

.vk-item strong {
  display: block;
  color: var(--ink);
  font-size: 0.78rem;
}

.vk-ring {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  flex-shrink: 0;
  margin-top: 2px;
}

.vk-ring.treated {
  border: 2px solid light-dark(#0e7490, #5ef0ff);
  background: light-dark(rgb(14 116 144 / 0.14), rgb(56 232 255 / 0.16));
}

.vk-ring.control {
  border: 1.8px dashed var(--slate);
  background: transparent;
}

.callout-box {
  border-inline-start: 3px solid var(--vermilion);
  background: var(--paper-sunk);
  padding: 11px 13px;
  border-radius: 0 var(--r-xs) var(--r-xs) 0;
  margin: 12px 0;
  font-size: var(--fs-small);
  color: var(--ink-2);
}

html[dir="rtl"] .callout-box {
  border-radius: var(--r-xs) 0 0 var(--r-xs);
}

.callout-box strong { color: var(--ink); }

/* Interactive inline trap-flipper inside Story Ch. 4 */
.trap-toggle {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin: 12px 0;
}

.trap-btn {
  text-align: start;
  padding: 10px 11px;
  border: 1px solid var(--rule);
  border-radius: var(--r-xs);
  background: var(--paper-elevated);
  color: var(--ink-2);
  cursor: pointer;
  font-family: var(--font-body);
  transition: border-color var(--t-fast), background-color var(--t-fast);
}

.trap-btn.is-active {
  border-color: var(--vermilion);
  background: var(--vermilion-soft);
  color: var(--ink);
}

.trap-btn-num {
  display: block;
  font-family: var(--font-serif-en);
  font-size: 1.45rem;
  font-weight: 600;
  line-height: 1.1;
  margin-bottom: 3px;
}

.trap-btn-lbl {
  display: block;
  font-size: 0.72rem;
  color: var(--ink-muted);
}

/* ── Live Lab Compact Matrix & Dynamic Verdict ────────────────────────── */
.corridor-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 10px;
}

.lab-verdict {
  font-size: 0.78rem;
  line-height: 1.48;
  color: var(--ink-2);
  background: var(--paper-sunk);
  border-inline-start: 2.5px solid var(--forest);
  padding: 7px 10px;
  border-radius: 0 var(--r-xs) var(--r-xs) 0;
  margin: -6px 0 10px;
}

html[dir="rtl"] .lab-verdict {
  border-radius: var(--r-xs) 0 0 var(--r-xs);
}

.lab-verdict.is-warn {
  border-inline-start-color: var(--vermilion);
  background: var(--vermilion-soft);
}

.lab-verdict strong { color: var(--ink); }

.delta-pill {
  display: inline-flex;
  align-items: center;
  font-family: var(--font-mono);
  font-size: 0.67rem;
  font-weight: 600;
  padding: 1px 5px;
  border-radius: 2px;
  margin-inline-start: 5px;
  vertical-align: middle;
  background: var(--paper-sunk);
  color: var(--ink-2);
  border: 1px solid var(--rule);
}

.delta-pill.up { color: var(--forest); background: var(--forest-soft); border-color: transparent; }
.delta-pill.down { color: var(--vermilion); background: var(--vermilion-soft); border-color: transparent; }

.lab-matrix {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 10px;
  padding: 10px 11px;
  margin: 10px 0;
  background: var(--paper-sunk);
  border: 1px solid var(--rule);
  border-radius: var(--r-xs);
}

.lab-cell {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.lab-cell-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.69rem;
  font-weight: 600;
  color: var(--ink-muted);
}

.seg-bar {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: 3px;
  padding: 2px;
  gap: 2px;
}

.seg-btn {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--ink-muted);
  font-family: var(--font-body);
  font-size: 0.71rem;
  font-weight: 500;
  padding: 4px 4px;
  border-radius: 2px;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: background-color var(--t-fast), color var(--t-fast);
}

.seg-btn:hover { color: var(--ink); }

.seg-btn[aria-pressed="true"] {
  background: var(--ink);
  color: var(--paper);
  font-weight: 600;
}

.seg-btn.is-warn[aria-pressed="true"] {
  background: var(--vermilion);
  color: #fff;
}

.preset-strip {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
  margin-top: 8px;
}

.preset-chip {
  appearance: none;
  border: 1px dashed var(--rule-strong);
  background: transparent;
  color: var(--ink-2);
  font-family: var(--font-body);
  font-size: 0.69rem;
  font-weight: 500;
  padding: 3px 8px;
  border-radius: var(--r-pill);
  cursor: pointer;
  opacity: 0.8;
  transition: opacity var(--t-fast), border-color var(--t-fast), background-color var(--t-fast);
}

.preset-chip:hover {
  opacity: 1;
  border-style: solid;
  border-color: var(--vermilion);
  background: var(--vermilion-soft);
  color: var(--ink);
}

.spec-readout {
  display: block;
  font-size: 0.71rem;
  color: var(--ink-muted);
  min-height: 18px;
  margin-bottom: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.robust-pill {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 2px;
  background: var(--forest-soft);
  color: var(--forest);
  white-space: nowrap;
}

.robust-pill.is-fragile {
  background: var(--vermilion-soft);
  color: var(--vermilion);
}

/* ── Econometric Lab Controls ─────────────────────────────────────────── */
.lab-group {
  margin-bottom: 12px;
}

.lab-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.74rem;
  font-weight: 600;
  color: var(--ink-muted);
  margin-bottom: 5px;
}

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

.pill {
  appearance: none;
  border: 1px solid var(--rule);
  background: var(--paper-elevated);
  color: var(--ink-2);
  font-family: var(--font-body);
  font-size: 0.76rem;
  font-weight: 500;
  padding: 5px 10px;
  border-radius: var(--r-xs);
  cursor: pointer;
  transition: all var(--t-fast);
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.pill:hover {
  border-color: var(--ink-muted);
  color: var(--ink);
}

.pill[aria-pressed="true"] {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--paper);
  font-weight: 600;
}

.pill-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
}

.worker-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: var(--forest);
  background: var(--forest-soft);
  padding: 2px 7px;
  border-radius: 2px;
}

/* ── Chart Containers ─────────────────────────────────────────────────── */
.chart-card {
  margin: 14px 0;
  padding-top: 12px;
  border-top: 1px solid var(--rule);
}

.chart-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}

.chart-title {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--ink);
}

.chart-sub {
  font-size: 0.72rem;
  color: var(--ink-muted);
}

.chart-svg {
  width: 100%;
  display: block;
  overflow: visible;
  direction: ltr; /* Charts and time axes always flow left-to-right */
}

/* ── Station Ranking / Gap Finder Table ───────────────────────────────── */
.station-list {
  display: flex;
  flex-direction: column;
  border-top: 1px solid var(--rule-strong);
  margin-top: 10px;
}

.station-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: 10px;
  padding: 9px 6px;
  border-bottom: 1px solid var(--rule);
  background: transparent;
  border-inline: 0;
  border-top: 0;
  text-align: start;
  cursor: pointer;
  color: var(--ink);
  font-family: var(--font-body);
  transition: background-color var(--t-fast);
}

.station-row:hover,
.station-row.is-active {
  background: var(--paper-hover);
}

.station-name {
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--ink);
  display: flex;
  align-items: center;
  gap: 6px;
}

.station-meta {
  font-size: 0.71rem;
  color: var(--ink-muted);
  margin-top: 1px;
}

.station-bar-wrap {
  width: 72px;
  height: 10px;
  position: relative;
  display: flex;
  align-items: center;
  direction: ltr;
}

.station-bar-zero {
  position: absolute;
  left: 30%;
  top: 0;
  bottom: 0;
  width: 1px;
  background: var(--rule-strong);
  opacity: 0.35;
}

.station-bar-fill {
  position: absolute;
  height: 5px;
  border-radius: 1px;
}

.station-shift {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  font-weight: 600;
  min-width: 52px;
  text-align: end;
}

/* ── Editorial Buttons ────────────────────────────────────────────────── */
.btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 36px;
  padding: 0 14px;
  border-radius: var(--r-xs);
  border: 1px solid var(--rule);
  background: var(--paper-elevated);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: var(--fs-small);
  font-weight: 600;
  cursor: pointer;
  transition: all var(--t-fast);
}

.btn:hover {
  border-color: var(--ink-muted);
  background: var(--paper-hover);
}

.btn.primary {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--paper);
}

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

.btn.ghost {
  background: transparent;
  border-color: transparent;
  color: var(--ink-muted);
  padding: 0 8px;
}

.btn.ghost:hover {
  color: var(--ink);
  background: var(--paper-hover);
}

.btn.sm {
  height: 30px;
  padding: 0 10px;
  font-size: 0.76rem;
}

/* ── Saudi / Riyadh Bridge Card ───────────────────────────────────────── */
.bridge-card {
  margin-top: 16px;
  padding: 13px 14px;
  border: 1px solid var(--rule);
  border-top: 2px solid var(--forest);
  background: var(--paper-elevated);
  border-radius: var(--r-xs);
}

.bridge-card h4 {
  margin: 0 0 5px;
  font-family: var(--font-display);
  font-size: 0.96rem;
  color: var(--ink);
}

.bridge-card p {
  margin: 0;
  font-size: 0.78rem;
  color: var(--ink-2);
  line-height: 1.55;
}

/* ── Evidence Drawer Interior ─────────────────────────────────────────── */
.ev-head {
  padding: 15px 18px 12px;
  border-bottom: 1px solid var(--rule);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.ev-body {
  padding: 16px 18px 20px;
  overflow-y: auto;
  flex: 1;
  font-size: var(--fs-small);
  color: var(--ink-2);
}

.ev-formula {
  font-family: var(--font-mono);
  font-size: 0.74rem;
  background: var(--paper-sunk);
  border: 1px solid var(--rule);
  padding: 9px 11px;
  border-radius: var(--r-xs);
  color: var(--ink);
  direction: ltr;
  overflow-x: auto;
  margin: 10px 0;
}

.ev-kv {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 6px 12px;
  padding: 6px 0;
  border-bottom: 1px solid var(--rule);
  font-size: 0.79rem;
}

.ev-kv dt { color: var(--ink-muted); }
.ev-kv dd { margin: 0; font-weight: 600; color: var(--ink); }

/* ── Ask Bar Dialog Interior ──────────────────────────────────────────── */
.ask-input-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--rule);
}

.ask-input {
  flex: 1;
  border: 0;
  background: transparent;
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 1rem;
  outline: none;
}

.ask-results {
  max-height: 52vh;
  overflow-y: auto;
  padding: 8px;
}

.ask-group-title {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--ink-faint);
  padding: 6px 10px 4px;
}

.ask-item {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 10px;
  border: 0;
  border-radius: var(--r-xs);
  background: transparent;
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 0.86rem;
  text-align: start;
  cursor: pointer;
}

.ask-item:hover,
.ask-item.is-selected {
  background: var(--paper-hover);
}

.ask-item-tag {
  font-size: 0.7rem;
  color: var(--ink-muted);
  font-family: var(--font-mono);
}

/* ── MapLibre Station Markers (Editorial Broadsheet Style) ────────────── */
.map-station-pin {
  display: flex;
  align-items: center;
  gap: 5px;
  cursor: pointer;
  user-select: none;
  transform: translate(-50%, -50%);
}

.map-station-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 2px solid var(--paper-elevated);
  box-shadow: 0 1px 4px rgb(0 0 0 / 0.35);
  transition: transform var(--t-fast);
}

.map-station-pin:hover .map-station-dot,
.map-station-pin.is-active .map-station-dot {
  transform: scale(1.45);
  border-color: var(--ink);
}

.map-station-label {
  direction: ltr;
  font-family: var(--font-sans-en);
  font-size: 11px;
  font-weight: 600;
  color: var(--ink);
  background: var(--paper-glass);
  border: 1px solid var(--rule);
  padding: 1px 6px;
  border-radius: 2px;
  white-space: nowrap;
  box-shadow: 0 1px 3px rgb(0 0 0 / 0.12);
}

.map-station-badge {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  padding: 0 4px;
  border-radius: 2px;
  margin-inline-start: 3px;
}
.map-station-badge.pos { color: var(--forest); background: var(--forest-soft); }
.map-station-badge.neg { color: var(--vermilion); background: var(--vermilion-soft); }
.map-station-badge.watch { color: var(--ochre); background: var(--ochre-soft); }

/* MapLibre controls positioned cleanly above the bottom timeline & styled in Editorial tokens */
.maplibregl-ctrl-bottom-right,
.maplibregl-ctrl-bottom-left {
  bottom: calc(var(--scrubber-h) + var(--edge) + 10px) !important;
  z-index: 10;
}

html[dir="rtl"] .maplibregl-ctrl-bottom-right {
  right: auto !important;
  left: var(--edge) !important;
}

html[dir="ltr"] .maplibregl-ctrl-bottom-right {
  right: var(--edge) !important;
}

.maplibregl-ctrl-group {
  background: var(--paper-glass) !important;
  border: 1px solid var(--rule) !important;
  border-radius: var(--r-xs) !important;
  box-shadow: var(--shadow-sheet) !important;
  backdrop-filter: blur(10px);
}

.maplibregl-ctrl-group button + button {
  border-top: 1px solid var(--rule) !important;
}

:root:has(> head > meta[name="color-scheme"][content="dark"]) .maplibregl-ctrl-group button .maplibregl-ctrl-icon {
  filter: invert(0.92) sepia(0.08);
}

.maplibregl-ctrl-attrib {
  background: var(--paper-glass) !important;
  color: var(--ink-muted) !important;
  font-size: 10px !important;
  border: 1px solid var(--rule) !important;
  border-radius: 3px !important;
  margin-bottom: 4px !important;
}
.maplibregl-ctrl-attrib a { color: var(--ink-2) !important; }
