/* ------------------------------------------------------------------
   econ.css — dark terminal theme for the Economics section.
   Scoped to body[data-section="econ"]. Harmonised with F1 dark base.
   ------------------------------------------------------------------ */

/* ── Tokens ──────────────────────────────────────────────────────── */

body[data-section="econ"] {
  --bg:              #0b0f17;
  --bg-card:         #131823;
  --bg-card-hero:    #181f2e;
  --border:          #1f2633;
  --border-hover:    #2a3344;
  --text-primary:    #e8dfd3;
  --text-secondary:  #9e9789;
  --text-tertiary:   #878072;
  --accent:          #d9a441;
  --accent-dim:      #8a6930;
  --positive:        #6ec087;
  --negative:        #d97068;
  --neutral:         #9e9789;
  --font-mono:       "JetBrains Mono", "Fira Code", "Cascadia Code", ui-monospace, monospace;

  color-scheme: dark;
  color: var(--text-primary);

  background-color: var(--bg);
  background-image:
    radial-gradient(1200px 600px at 75% -10%, rgba(217,164,65,0.045), transparent 60%),
    linear-gradient(to right, rgba(255,255,255,0.025) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(255,255,255,0.025) 1px, transparent 1px);
  background-size: auto, 24px 24px, 24px 24px;
  background-attachment: fixed;
}

/* ── Chrome overrides ────────────────────────────────────────────── */

body[data-section="econ"] .site-header {
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  border-bottom-color: var(--border);
  backdrop-filter: blur(12px);
}

body[data-section="econ"] .site-nav__link[aria-current="page"] {
  color: var(--accent);
}

/* ── Page header ─────────────────────────────────────────────────── */

.econ-hero-header {
  padding: 2.5rem 1.5rem 1.25rem;
  max-width: 72rem;
  margin: 0 auto;
}

.econ-title {
  font-size: clamp(1.75rem, 4vw, 2.25rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0 0 0.4rem;
  color: var(--text-primary);
}

.econ-desc {
  font-size: 0.9rem;
  color: var(--text-secondary);
  max-width: 60ch;
  line-height: 1.5;
  margin: 0 0 0.4rem;
}

.econ-subtitle {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-tertiary);
  margin: 0;
  font-variant-numeric: tabular-nums;
}

/* ── Sections ────────────────────────────────────────────────────── */

.econ-section {
  padding: 0 1.5rem 2rem;
  max-width: 72rem;
  margin: 0 auto;
  position: relative;
}

/* Top border + 40px accent tab on the left */
.econ-section + .econ-section {
  border-top: 1px solid var(--border);
  padding-top: 1.75rem;
}

.econ-section + .econ-section::before {
  content: "";
  position: absolute;
  top: -1px;
  left: 1.5rem;
  width: 40px;
  height: 2px;
  background: var(--accent);
  border-radius: 0 0 2px 2px;
}

.econ-section__header {
  margin-bottom: 1rem;
}

.econ-section__title {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-secondary);
  margin: 0 0 0.2rem;
}

.econ-section__desc {
  font-size: 0.75rem;
  color: var(--text-tertiary);
  margin: 0;
}

/* ── Grids ───────────────────────────────────────────────────────── */

.econ-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 0.75rem;
}

.econ-grid--hero      { /* same 220px min as base */ }
.econ-grid--recession { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); max-width: 700px; }
.econ-grid--markets   { /* same 220px min as base */ }

/* ── Cards ───────────────────────────────────────────────────────── */

.econ-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  transition:
    border-color 200ms ease,
    transform 200ms ease,
    box-shadow 200ms ease;
}

.econ-card:hover {
  border-color: var(--border-hover);
  transform: translateY(-1px);
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
}

.econ-card--hero {
  background: var(--bg-card-hero);
  border: 1px solid var(--accent-dim);
  padding: 1.25rem;
  box-shadow: inset 0 0 0 1px rgba(217,164,65,0.08);
}

.econ-card--hero:hover {
  border-color: var(--accent);
  box-shadow:
    inset 0 0 0 1px rgba(217,164,65,0.12),
    0 8px 24px rgba(0,0,0,0.5);
}

/* ── Card typography ─────────────────────────────────────────────── */

.econ-card__label {
  font-size: 0.65rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-secondary);
}

.econ-card__value {
  font-family: var(--font-mono);
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}

.econ-card--hero .econ-card__value {
  font-size: 1.75rem;
  color: var(--accent);
}

.econ-card__unit {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--text-secondary);
  margin-left: 0.15em;
  font-variant-numeric: tabular-nums;
}

.econ-card__date {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  color: var(--text-tertiary);
  font-variant-numeric: tabular-nums;
  margin-top: 0.1rem;
}

/* ── Delta elements ──────────────────────────────────────────────── */

.econ-card__change {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0;
}

.econ-card__change--up      { color: var(--positive); }
.econ-card__change--down    { color: var(--negative); }
.econ-card__change--neutral { color: var(--neutral); }

/* ── Recession signal badges ─────────────────────────────────────── */

.econ-chip--green {
  border-color: rgba(110, 192, 135, 0.3);
}

.econ-chip--yellow {
  border-color: rgba(217, 164, 65, 0.35);
}

.econ-chip--red {
  border-color: rgba(217, 112, 104, 0.35);
}

.econ-chip__signal {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.6rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  padding: 2px 6px;
  border-radius: 3px;
  margin-top: 0.25rem;
  border: 1px solid;
  width: fit-content;
}

.econ-chip__signal--green {
  color: var(--positive);
  background: rgba(110, 192, 135, 0.1);
  border-color: rgba(110, 192, 135, 0.25);
}

.econ-chip__signal--yellow {
  color: var(--accent);
  background: rgba(217, 164, 65, 0.1);
  border-color: rgba(217, 164, 65, 0.25);
}

.econ-chip__signal--red {
  color: var(--negative);
  background: rgba(217, 112, 104, 0.1);
  border-color: rgba(217, 112, 104, 0.25);
}

/* ── Sparklines ──────────────────────────────────────────────────── */

.econ-sparkline {
  margin-top: 0.5rem;
}

.econ-sparkline svg {
  display: block;
  width: 100%;
  height: 40px;
  overflow: visible;
}

.econ-sparkline--empty {
  height: 40px;
  position: relative;
}

.econ-sparkline--empty::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  border-top: 1px dashed var(--border-hover);
  opacity: 0.6;
}

/* ── Yield curve ─────────────────────────────────────────────────── */

.econ-yield-card {
  grid-column: 1 / -1;
  max-width: 480px;
  width: 100%;
  margin: 0 auto;
}

.econ-yield-chart {
  margin: 0.5rem 0 0.25rem;
}

.econ-yield-chart svg {
  /* width:100% + intrinsic 480:110 ratio from viewBox → scales proportionally */
  width: 100%;
  height: auto;
  display: block;
  overflow: visible;
}

/* ── Error state ─────────────────────────────────────────────────── */

.econ-card--error {
  opacity: 0.35;
  pointer-events: none;
}

.econ-card--error .econ-card__value {
  font-size: 1rem;
  color: var(--text-tertiary);
}

/* ── Mobile ──────────────────────────────────────────────────────── */

@media (max-width: 560px) {
  .econ-hero-header {
    padding: 1.75rem 1rem 1rem;
  }

  .econ-section {
    padding-left: 1rem;
    padding-right: 1rem;
  }

  .econ-section + .econ-section::before {
    left: 1rem;
  }

  .econ-card--hero .econ-card__value {
    font-size: 1.5rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .econ-card {
    transition: none;
  }
}

/* ── Card subtitle ───────────────────────────────────────────────── */

.econ-card__subtitle {
  font-family: var(--font-sans, system-ui, sans-serif);
  font-size: 0.72rem;
  color: var(--text-secondary);
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Info Button ─────────────────────────────────────────────────── */

.econ-card__label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.4rem;
}

.econ-info-btn {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  padding: 0;
  border: 1px solid var(--accent-dim);
  border-radius: 50%;
  background: transparent;
  color: var(--accent);
  font-size: 0.6rem;
  line-height: 1;
  cursor: pointer;
  opacity: 0.8;
  transition: opacity 150ms ease, border-color 150ms ease;
  font-family: inherit;
}

.econ-info-btn:hover,
.econ-info-btn:focus-visible {
  opacity: 1;
  border-color: var(--accent);
  outline: none;
}

.econ-info-btn:focus-visible {
  box-shadow: 0 0 0 2px rgba(217, 164, 65, 0.4);
}

/* ── Popover ─────────────────────────────────────────────────────── */

.econ-popover {
  position: fixed;
  z-index: 1000;
  width: 320px;
  max-width: calc(100vw - 16px);
  background: #131823;
  border: 1px solid var(--border, #1f2633);
  border-top: 2px solid var(--accent, #d9a441);
  border-radius: 8px;
  padding: 1.25rem 1.25rem 1rem;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.75);
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 120ms ease, transform 120ms ease;
  pointer-events: none;
}

.econ-popover--open {
  opacity: 1;
  transform: none;
  pointer-events: auto;
}

.econ-popover__title {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--accent, #d9a441);
  margin: 0 0 0.75rem;
}

.econ-popover__section {
  margin-bottom: 0.75rem;
}

.econ-popover__section:last-of-type {
  margin-bottom: 0;
}

.econ-popover__label {
  display: block;
  font-size: 0.6rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-secondary, #8c8579);
  margin-bottom: 0.25rem;
}

.econ-popover__text {
  margin: 0;
  font-size: 0.8rem;
  line-height: 1.55;
  color: var(--text-primary, #e8dfd3);
}

.econ-popover__footer {
  margin-top: 0.875rem;
  padding-top: 0.625rem;
  border-top: 1px solid var(--border, #1f2633);
  font-size: 0.65rem;
  color: var(--text-tertiary, #5a564e);
  font-family: var(--font-mono);
}

.econ-popover__src-link {
  color: var(--accent, #d9a441);
  text-decoration: none;
}

.econ-popover__src-link:hover {
  text-decoration: underline;
}

/* Mobile bottom-sheet variant */
.econ-popover--mobile {
  left: 8px !important;
  right: 8px !important;
  top: auto !important;
  bottom: 0 !important;
  width: auto !important;
  max-width: none;
  border-radius: 12px 12px 0 0;
  border-top: 2px solid var(--accent, #d9a441);
  border-left: 1px solid var(--border, #1f2633);
  border-right: 1px solid var(--border, #1f2633);
  border-bottom: none;
  /* Override default transform/opacity so only slide handles the animation */
  opacity: 1;
  transform: translateY(100%);
  transition: transform 200ms ease;
  padding-bottom: max(1.25rem, env(safe-area-inset-bottom));
}

.econ-popover--mobile.econ-popover--open {
  transform: translateY(0);
}

/* Backdrop for mobile modal */
.econ-popover-backdrop {
  position: fixed;
  inset: 0;
  z-index: 999;
  background: rgba(0, 0, 0, 0);
  transition: background 200ms ease;
  /* Allow pointer events so tapping it closes the popover */
}

.econ-popover-backdrop--visible {
  background: rgba(0, 0, 0, 0.55);
}

@media (prefers-reduced-motion: reduce) {
  .econ-popover,
  .econ-popover--mobile,
  .econ-popover-backdrop {
    transition: none;
  }
}
