/* ==========================================================================
   OIEBC — Organización de Impacto Económico de Baja California
   Editorial data-journalism design system. Navy + gold on warm paper.
   ========================================================================== */

:root {
  --ink:            oklch(0.24 0.05 250);
  --ink-2:          oklch(0.30 0.055 250);
  --ink-3:          oklch(0.36 0.05 250);
  --gold:           oklch(0.72 0.13 78);
  --gold-deep:      oklch(0.585 0.13 68);
  --paper:          oklch(0.985 0.006 85);
  --paper-2:        oklch(0.965 0.008 85);
  --card:           oklch(0.975 0.008 85);
  --line:           oklch(0.885 0.012 250);
  --line-strong:    oklch(0.80 0.02 250);
  --body:           oklch(0.33 0.025 250);
  --heading:        oklch(0.26 0.05 250);
  --muted:          oklch(0.52 0.025 250);
  --paper-on-ink:   oklch(0.93 0.01 85);
  --muted-on-ink:   oklch(0.76 0.025 250);
  --line-on-ink:    oklch(0.42 0.04 250);

  --serif: "Charter", "Iowan Old Style", "Palatino Linotype", "Cambria", Georgia, "Times New Roman", serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", system-ui, sans-serif;
  --mono: "SFMono-Regular", ui-monospace, "Menlo", "Consolas", monospace;

  --measure: 68ch;
  --wrap: 1120px;
  --wrap-narrow: 760px;

  --step--1: clamp(0.82rem, 0.8rem + 0.1vw, 0.875rem);
  --step-0:  1.0625rem;
  --step-1:  clamp(1.2rem, 1.12rem + 0.4vw, 1.4rem);
  --step-2:  clamp(1.5rem, 1.35rem + 0.7vw, 1.85rem);
  --step-3:  clamp(1.9rem, 1.6rem + 1.4vw, 2.6rem);
  --step-4:  clamp(2.5rem, 2.0rem + 2.6vw, 4rem);

  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  margin: 0;
  font-family: var(--sans);
  font-size: var(--step-0);
  line-height: 1.65;
  color: var(--body);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4 {
  font-family: var(--serif);
  color: var(--heading);
  line-height: 1.12;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin: 0;
}

p { margin: 0 0 1.1rem; max-width: var(--measure); }
a { color: var(--gold-deep); text-underline-offset: 2px; text-decoration-thickness: 1px; }
a:hover { color: var(--ink); }
a.ext::after { content: "\2197"; font-size: 0.72em; margin-left: 0.1em; color: var(--muted); font-weight: 600; }
a.ext:hover::after { color: var(--gold-deep); }
strong { color: var(--heading); font-weight: 700; }
img, svg { max-width: 100%; }
hr { border: none; border-top: 1px solid var(--line); margin: 2.5rem 0; }

::selection { background: var(--gold); color: var(--ink); }
:focus-visible { outline: 2.5px solid var(--gold-deep); outline-offset: 3px; border-radius: 2px; }

/* ---- Layout primitives ------------------------------------------------- */
.wrap { width: min(100% - 2.5rem, var(--wrap)); margin-inline: auto; }
.wrap-narrow { width: min(100% - 2.5rem, var(--wrap-narrow)); margin-inline: auto; }
.section { padding-block: clamp(3rem, 6vw, 5.5rem); }
.section--tight { padding-block: clamp(2rem, 4vw, 3.5rem); }

.eyebrow {
  font-family: var(--sans);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--gold-deep);
  margin: 0 0 0.9rem;
  display: flex;
  align-items: center;
  gap: 0.7rem;
}
.eyebrow::before {
  content: "";
  width: 26px; height: 2px;
  background: var(--gold-deep);
  flex: none;
}
.eyebrow--plain::before { display: none; }

.lede { font-size: var(--step-1); line-height: 1.5; color: var(--ink-3); max-width: 60ch; }
.section-title { font-size: var(--step-3); margin-bottom: 0.75rem; }
.kicker-sub { color: var(--muted); max-width: 62ch; }

/* ---- Skip link --------------------------------------------------------- */
.skip {
  position: absolute; left: -999px; top: 0.5rem; z-index: 200;
  background: var(--ink); color: var(--paper-on-ink);
  padding: 0.6rem 1rem; border-radius: 4px;
}
.skip:focus { left: 0.75rem; }

/* ---- Header / nav ------------------------------------------------------ */
.site-header {
  position: sticky; top: 0; z-index: 100;
  background: color-mix(in oklab, var(--paper) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(8px);
  border-bottom: 1px solid var(--line);
}
/* Two-tier masthead: brand + switcher on top, section nav on its own row below. */
.header-top {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  min-height: 62px;
}
.brand { display: flex; align-items: center; gap: 0.7rem; text-decoration: none; color: var(--ink); }
.brand:hover { color: var(--ink); }
.brand img { width: 40px; height: 40px; flex: none; }
.brand-text { display: flex; flex-direction: column; line-height: 1.05; }
.brand-name { font-family: var(--serif); font-weight: 700; font-size: 1.02rem; letter-spacing: -0.01em; }
.brand-sub { font-family: var(--sans); font-size: 0.62rem; letter-spacing: 0.13em; text-transform: uppercase; color: var(--muted); }
.header-actions { display: flex; align-items: center; gap: 0.75rem; flex: none; }

.header-nav { border-top: 1px solid var(--line); }
.header-nav > .wrap { display: flex; justify-content: center; }
.nav-links {
  display: flex; align-items: center; justify-content: center; flex-wrap: wrap;
  gap: 0.15rem; list-style: none; margin: 0; padding: 0.3rem 0;
}
.nav-links a {
  display: block; padding: 0.5rem 0.9rem; border-radius: 5px;
  color: var(--ink-3); text-decoration: none; white-space: nowrap;
  font-size: 0.94rem; font-weight: 500;
  transition: background 0.18s var(--ease-out), color 0.18s var(--ease-out);
}
.nav-links a:hover { background: var(--paper-2); color: var(--ink); }
.nav-links a[aria-current="page"] { color: var(--ink); box-shadow: inset 0 -2px 0 var(--gold-deep); border-radius: 0; }

.lang-switch {
  display: inline-flex; align-items: center; gap: 0.1rem;
  font-size: 0.78rem; font-weight: 700; letter-spacing: 0.04em;
  border: 1px solid var(--line-strong); border-radius: 6px; overflow: hidden; flex: none;
}
.lang-switch a {
  display: inline-flex; align-items: center; gap: 0.35rem;
  padding: 0.3rem 0.5rem; text-decoration: none; color: var(--muted);
  transition: background 0.18s var(--ease-out), color 0.18s var(--ease-out);
}
.lang-switch a[aria-current="true"] { background: var(--ink); color: var(--paper-on-ink); }
.lang-switch a:not([aria-current="true"]):hover { background: var(--paper-2); color: var(--ink); }
.lang-switch .flag { width: 19px; height: 13px; border-radius: 2px; display: block; flex: none; box-shadow: inset 0 0 0 1px oklch(0 0 0 / 0.12); }
.lang-switch a:not([aria-current="true"]) .flag { opacity: 0.82; }

.nav-toggle {
  display: none;
  background: none; border: 1px solid var(--line-strong); border-radius: 6px;
  width: 42px; height: 38px; cursor: pointer; color: var(--ink);
  align-items: center; justify-content: center;
}
.nav-toggle svg { width: 20px; height: 20px; }

@media (max-width: 720px) {
  .nav-toggle { display: inline-flex; }
  .header-nav { border-top: none; }
  .header-nav > .wrap { display: block; padding: 0; }
  .nav-links {
    position: fixed; inset: 62px 0 auto 0;
    flex-direction: column; align-items: stretch; justify-content: flex-start;
    flex-wrap: nowrap; gap: 0;
    background: var(--paper); border-bottom: 1px solid var(--line);
    box-shadow: 0 18px 30px -18px oklch(0.24 0.05 250 / 0.45);
    padding: 0.5rem 1.25rem 1.25rem;
    transform: translateY(-8px); opacity: 0; pointer-events: none;
    transition: opacity 0.2s var(--ease-out), transform 0.2s var(--ease-out);
  }
  .nav-links.open { transform: translateY(0); opacity: 1; pointer-events: auto; }
  .nav-links a { padding: 0.7rem 0.5rem; border-bottom: 1px solid var(--line); font-size: 1rem; }
  .nav-links a[aria-current="page"] { box-shadow: inset 3px 0 0 var(--gold-deep); }
}

/* ---- Hero -------------------------------------------------------------- */
.hero { background: var(--paper); border-bottom: 1px solid var(--line); }
.hero-inner { padding-block: clamp(3rem, 7vw, 6rem); }
.hero h1 { font-size: var(--step-4); max-width: 15ch; margin-bottom: 1.4rem; }
.hero .lede { max-width: 56ch; }
.hero-meta {
  margin-top: 2rem; padding-top: 1.3rem; border-top: 1px solid var(--line);
  display: flex; flex-wrap: wrap; gap: 1.5rem 2.5rem;
  font-size: var(--step--1); color: var(--muted);
}
.hero-meta b { color: var(--ink-3); font-weight: 700; }

/* ---- Clarification note ------------------------------------------------ */
.note {
  background: var(--paper-2);
  border: 1px solid var(--line);
  border-top: 3px solid var(--gold);
  padding: 1.2rem 1.4rem; border-radius: 3px;
  font-size: 0.98rem; color: var(--ink-3);
}
.note strong { color: var(--ink); }

/* ---- Big-number data blocks (signature device) ------------------------- */
.stat-grid {
  display: grid; gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(215px, 1fr));
}
.stat {
  background: var(--ink); color: var(--paper-on-ink);
  padding: 1.5rem 1.4rem 1.4rem; border-radius: 4px;
  display: flex; flex-direction: column;
}
.stat-num {
  font-family: var(--serif); font-weight: 700;
  font-size: clamp(1.9rem, 1.55rem + 1.5vw, 2.55rem);
  color: var(--gold); line-height: 1.05; letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums; white-space: nowrap;
}
.stat-num .stat-unit {
  font-size: 0.44em; font-weight: 700; letter-spacing: 0.01em;
  color: var(--gold); opacity: 0.9; margin-left: 0.15em;
}
.stat-label { margin-top: 0.7rem; font-size: 0.9rem; line-height: 1.4; color: var(--muted-on-ink); }
.stat-label b { color: var(--paper-on-ink); font-weight: 600; }

/* ---- City / feature columns ------------------------------------------- */
.cols { display: grid; gap: 1.5rem 2rem; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.col-item { padding-top: 1rem; border-top: 2px solid var(--ink); }
.col-item h3 { font-size: var(--step-1); margin-bottom: 0.15rem; }
.col-item .figure { color: var(--gold-deep); font-weight: 700; font-size: 0.95rem; margin-bottom: 0.5rem; }
.col-item p { font-size: 0.95rem; color: var(--body); margin: 0; }

/* ---- Definition list of small items ------------------------------------ */
.deflist { display: grid; gap: 0.9rem 2.5rem; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); margin: 0; }
.deflist > div { display: flex; gap: 0.7rem; }
.deflist dt { flex: none; color: var(--gold-deep); font-weight: 700; }
.deflist dd { margin: 0; font-size: 0.97rem; color: var(--body); }

/* ---- Prose article ----------------------------------------------------- */
.prose h2 { font-size: var(--step-2); margin: 2.8rem 0 0.8rem; }
.prose h2:first-child { margin-top: 0; }
.prose h3 { font-size: var(--step-1); margin: 2rem 0 0.5rem; }
.prose ul { margin: 0 0 1.3rem; padding-left: 0; list-style: none; max-width: var(--measure); }
.prose ul li { position: relative; padding-left: 1.4rem; margin-bottom: 0.7rem; }
.prose ul li::before { content: ""; position: absolute; left: 0.15rem; top: 0.62em; width: 6px; height: 6px; background: var(--gold-deep); border-radius: 50%; }
.prose ul li strong { color: var(--heading); }

/* ---- Two-column lede layout for section pages -------------------------- */
.lede-split { display: grid; gap: 1.5rem 3rem; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); align-items: start; }
.lede-split .aside { font-size: 0.95rem; color: var(--muted); border-top: 2px solid var(--gold); padding-top: 0.9rem; }
@media (max-width: 760px) { .lede-split { grid-template-columns: 1fr; } }

/* ---- Data tables ------------------------------------------------------- */
.table-scroll { overflow-x: auto; margin: 1.5rem 0; -webkit-overflow-scrolling: touch; }
table.data {
  width: 100%; border-collapse: collapse; font-size: 0.95rem;
  font-variant-numeric: tabular-nums;
}
table.data caption { text-align: left; font-size: 0.8rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--gold-deep); font-weight: 700; padding-bottom: 0.6rem; }
table.data th, table.data td { padding: 0.65rem 0.9rem; text-align: left; border-bottom: 1px solid var(--line); }
table.data thead th { color: var(--ink); font-family: var(--sans); font-size: 0.78rem; letter-spacing: 0.06em; text-transform: uppercase; border-bottom: 2px solid var(--ink); }
table.data td.num, table.data th.num { text-align: right; }
table.data tbody tr:hover { background: var(--paper-2); }
table.data tr.total td { border-top: 2px solid var(--line-strong); font-weight: 700; color: var(--ink); }

/* ---- Bar chart (CSS) --------------------------------------------------- */
.barchart { display: grid; gap: 0.75rem; margin: 1.5rem 0; max-width: 640px; }
.bar-row { display: grid; grid-template-columns: minmax(90px, 30%) 1fr auto; align-items: center; gap: 0.9rem; }
.bar-row .bar-label { font-size: 0.9rem; color: var(--ink-3); }
.bar-track { background: var(--paper-2); border: 1px solid var(--line); border-radius: 3px; height: 24px; overflow: hidden; }
.bar-fill { display: block; width: 100%; height: 100%; background: var(--ink); border-radius: 2px 0 0 2px; transform-origin: left; transform: scaleX(var(--v, 0)); transition: transform 0.9s var(--ease-out); }
.bar-fill.gold { background: var(--gold); }
.bar-row .bar-val { font-size: 0.88rem; color: var(--muted); font-variant-numeric: tabular-nums; }

/* ---- Source line ------------------------------------------------------- */
.source { font-size: 0.78rem; color: var(--muted); letter-spacing: 0.01em; margin-top: 0.5rem; }
.source::before { content: "Source: "; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; font-size: 0.72rem; color: var(--gold-deep); }
html[lang="es"] .source::before { content: "Fuente: "; }

/* ---- Pull takeaway (navy panel) ---------------------------------------- */
.takeaway { background: var(--ink); color: var(--paper-on-ink); padding: clamp(1.8rem, 4vw, 3rem); border-radius: 5px; }
.takeaway .eyebrow { color: var(--gold); }
.takeaway .eyebrow::before { background: var(--gold); }
.takeaway p { font-family: var(--serif); font-size: var(--step-2); line-height: 1.35; color: var(--paper-on-ink); max-width: 40ch; margin: 0; }

/* ---- Sector index cards (home) ----------------------------------------- */
.sectors { display: grid; gap: 1.25rem; grid-template-columns: repeat(auto-fit, minmax(270px, 1fr)); }
.sector-card {
  display: flex; flex-direction: column; text-decoration: none; color: var(--body);
  background: var(--paper); border: 1px solid var(--line); border-radius: 5px;
  padding: 1.4rem 1.4rem 1.2rem;
  transition: border-color 0.2s var(--ease-out), transform 0.2s var(--ease-out), box-shadow 0.2s var(--ease-out);
}
.sector-card:hover { border-color: var(--line-strong); transform: translateY(-3px); box-shadow: 0 12px 30px -18px oklch(0.24 0.05 250 / 0.5); color: var(--body); }
.sector-card .num { font-family: var(--mono); font-size: 0.78rem; color: var(--gold-deep); letter-spacing: 0.05em; }
.sector-card h3 { font-size: var(--step-1); margin: 0.5rem 0 0.4rem; }
.sector-card p { font-size: 0.93rem; color: var(--muted); margin: 0 0 1rem; }
.sector-card .go { margin-top: auto; font-size: 0.85rem; font-weight: 600; color: var(--ink); display: inline-flex; align-items: center; gap: 0.35rem; }
.sector-card:hover .go { color: var(--gold-deep); }
.sector-card:hover .go svg { transform: translateX(3px); }
.sector-card .go svg { width: 15px; height: 15px; transition: transform 0.2s var(--ease-out); }

/* ---- Race schedule cards ----------------------------------------------- */
.races { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
.race { border: 1px solid var(--line); border-radius: 4px; padding: 1.1rem 1.2rem; background: var(--paper); }
.race.flagship, .race.flagship { background: var(--ink); color: var(--paper-on-ink); border-color: var(--ink); }
.race h3 { font-size: var(--step-1); margin-bottom: 0.3rem; }
.race.flagship h3 { color: var(--gold); }
.race .when { font-size: 0.78rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.race.flagship .when { color: var(--muted-on-ink); }

/* ---- Page hero (section pages) ----------------------------------------- */
.page-hero { border-bottom: 1px solid var(--line); }
.page-hero .wrap { padding-block: clamp(2.5rem, 5vw, 4rem); }
.page-hero h1 { font-size: var(--step-3); max-width: 18ch; margin-bottom: 1rem; }
.breadcrumb { font-size: 0.8rem; color: var(--muted); margin-bottom: 1.2rem; }
.breadcrumb a { color: var(--muted); text-decoration: none; }
.breadcrumb a:hover { color: var(--gold-deep); }

/* ---- Prev/next sector nav ---------------------------------------------- */
.pager { display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; border-top: 1px solid var(--line); padding-top: 1.5rem; margin-top: 3rem; }
.pager a { text-decoration: none; color: var(--ink); font-weight: 600; display: flex; flex-direction: column; }
.pager a span { font-size: 0.72rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); font-weight: 700; }
.pager a:hover { color: var(--gold-deep); }
.pager a.next { text-align: right; margin-left: auto; }

/* ---- Footer ------------------------------------------------------------ */
.site-footer { background: var(--ink); color: var(--muted-on-ink); margin-top: 2rem; }
.site-footer .wrap { padding-block: 3rem 2rem; }
.footer-top { display: grid; gap: 2rem; grid-template-columns: 1.5fr 1fr 1fr; }
@media (max-width: 700px) { .footer-top { grid-template-columns: 1fr; } }
.footer-brand { display: flex; align-items: center; gap: 0.7rem; margin-bottom: 0.9rem; }
.footer-brand img { width: 42px; height: 42px; }
.footer-brand .brand-name { color: var(--paper-on-ink); }
.footer-brand .brand-sub { color: var(--muted-on-ink); }
.site-footer p { color: var(--muted-on-ink); font-size: 0.9rem; max-width: 42ch; }
.footer-col h4 { color: var(--paper-on-ink); font-family: var(--sans); font-size: 0.75rem; letter-spacing: 0.12em; text-transform: uppercase; margin-bottom: 0.9rem; }
.footer-col ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.5rem; }
.footer-col a { color: var(--muted-on-ink); text-decoration: none; font-size: 0.92rem; }
.footer-col a:hover { color: var(--gold); }
.footer-bottom { margin-top: 2.5rem; padding-top: 1.5rem; border-top: 1px solid var(--line-on-ink); display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; font-size: 0.8rem; color: var(--muted-on-ink); }

/* ---- Scroll reveal ----------------------------------------------------- */
.reveal { opacity: 0; transform: translateY(16px); transition: opacity 0.6s var(--ease-out), transform 0.6s var(--ease-out); }
.reveal.in { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) { .reveal { opacity: 1; transform: none; transition: none; } }

/* ---- Utilities --------------------------------------------------------- */
.mt-0 { margin-top: 0; } .mb-0 { margin-bottom: 0; }
.stack > * + * { margin-top: 1.2rem; }
.stack-lg > * + * { margin-top: 2.5rem; }
