/* ===========================================================
   GEOhandbook — design tokens & base
   Editorial + technical. Signal-oriented palette.
   =========================================================== */

:root {
  /* Palette — deep ink, warm paper, one confident signal accent */
  --ink: #0e1116;
  --ink-2: #1b1f27;
  --muted: #5c6473;
  --muted-2: #8a92a1;
  --line: #e6e4dc;
  --line-2: #d6d3c8;
  --paper: #f6f3ec;      /* warm off-white */
  --paper-2: #ece8dd;
  --card: #ffffff;

  /* Signal accent — vivid citrine, evokes "signal" / highlight */
  --signal: #ff5b1f;
  --signal-2: #ff8a4c;
  --signal-ink: #7a2a0d;

  /* Deep ink for cited-source hover */
  --link: #0e1116;
  --link-underline: rgba(14, 17, 22, 0.35);

  /* Type scale — clamps for responsive scaling */
  --text-xs: clamp(0.75rem, 0.72rem + 0.15vw, 0.85rem);
  --text-sm: clamp(0.875rem, 0.85rem + 0.15vw, 0.95rem);
  --text-base: clamp(1rem, 0.98rem + 0.2vw, 1.075rem);
  --text-lg: clamp(1.125rem, 1.08rem + 0.3vw, 1.25rem);
  --text-xl: clamp(1.5rem, 1.35rem + 0.9vw, 2rem);
  --text-2xl: clamp(2rem, 1.7rem + 1.6vw, 3rem);
  --text-3xl: clamp(2.5rem, 2rem + 2.6vw, 4.25rem);
  --text-hero: clamp(3rem, 2.3rem + 3.6vw, 5.5rem);

  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  --space-10: 2.5rem;
  --space-12: 3rem;
  --space-16: 4rem;
  --space-20: 5rem;
  --space-24: 6rem;
  --space-32: 8rem;

  --wrap: 1200px;
  --wrap-narrow: 720px;

  --radius: 4px;
  --radius-lg: 10px;

  --font-display: "Cabinet Grotesk", "General Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-sans: "General Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  --shadow-sm: 0 1px 2px rgba(14, 17, 22, 0.06);
  --shadow-md: 0 4px 20px rgba(14, 17, 22, 0.08);
}

@media (prefers-color-scheme: dark) {
  :root {
    --ink: #f2efe6;
    --ink-2: #d9d5c9;
    --muted: #a2a8b4;
    --muted-2: #7c8290;
    --line: #262a33;
    --line-2: #333844;
    --paper: #0e1116;
    --paper-2: #161a22;
    --card: #171b23;
    --signal: #ff7a3d;
    --signal-2: #ffa06b;
    --signal-ink: #ffd0b6;
    --link: #f2efe6;
    --link-underline: rgba(242, 239, 230, 0.35);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 4px 24px rgba(0, 0, 0, 0.4);
  }
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  font-feature-settings: "ss01", "cv11";
}

img, svg, video { max-width: 100%; display: block; height: auto; }
a { color: var(--link); text-decoration: underline; text-decoration-color: var(--link-underline); text-underline-offset: 3px; text-decoration-thickness: 1px; }
a:hover { text-decoration-color: var(--signal); }
::selection { background: var(--signal); color: white; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden;
  clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}
.skip-link {
  position: absolute; top: -40px; left: var(--space-4);
  background: var(--ink); color: var(--paper); padding: 0.5rem 0.75rem;
  border-radius: var(--radius); z-index: 100;
}
.skip-link:focus { top: var(--space-4); }

/* ===== Layout wraps ===== */
.wrap { width: 100%; max-width: var(--wrap); margin-inline: auto; padding-inline: var(--space-6); }
.wrap--narrow { max-width: var(--wrap-narrow); }
@media (min-width: 720px) { .wrap { padding-inline: var(--space-8); } }

/* ===== Header ===== */
.site-header {
  position: sticky; top: 0; z-index: 40;
  background: color-mix(in oklab, var(--paper) 92%, transparent);
  backdrop-filter: saturate(140%) blur(10px);
  border-bottom: 1px solid var(--line);
}
.header__wrap { display: flex; align-items: center; justify-content: space-between; gap: var(--space-6); min-height: 68px; }
.brand { display: inline-flex; align-items: center; gap: 0.6rem; text-decoration: none; color: var(--ink); font-family: var(--font-display); font-weight: 800; letter-spacing: -0.01em; }
.brand__mark { color: var(--signal); }
.brand__word { font-size: 1.125rem; }
.brand__geo { color: var(--ink); }
.brand__book { color: var(--muted); font-weight: 700; }
.brand--footer { color: var(--ink); font-size: 1rem; gap: 0.5rem; }

.site-nav__list { display: flex; gap: var(--space-6); list-style: none; padding: 0; margin: 0; }
.site-nav__list a { text-decoration: none; color: var(--muted); font-size: var(--text-sm); font-weight: 500; padding: 0.5rem 0; }
.site-nav__list a:hover { color: var(--ink); }
.site-nav__list a[aria-current="page"] { color: var(--ink); position: relative; }
.site-nav__list a[aria-current="page"]::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: -2px; height: 2px;
  background: var(--signal); border-radius: 2px;
}
.site-nav__toggle {
  display: none; background: none; border: 1px solid var(--line-2); border-radius: var(--radius);
  padding: 0.5rem; cursor: pointer; align-items: center; justify-content: center; gap: 3px;
  flex-direction: column;
}
.site-nav__bar { width: 20px; height: 2px; background: var(--ink); border-radius: 2px; }

@media (max-width: 720px) {
  .site-nav__toggle { display: inline-flex; }
  .site-nav__list {
    position: absolute; top: 68px; left: 0; right: 0;
    background: var(--paper); border-bottom: 1px solid var(--line);
    flex-direction: column; padding: var(--space-4) var(--space-6);
    gap: var(--space-2); display: none;
  }
  .site-nav[aria-expanded="true"] .site-nav__list { display: flex; }
  .site-nav__list.is-open { display: flex; }
}

/* ===== Typography helpers ===== */
h1, h2, h3, h4 { font-family: var(--font-display); color: var(--ink); letter-spacing: -0.02em; line-height: 1.1; margin: 0; }
h2 { font-size: var(--text-xl); font-weight: 700; }
h3 { font-size: var(--text-lg); font-weight: 700; }
p { margin: 0 0 var(--space-4); }
.eyebrow {
  font-family: var(--font-mono); font-size: var(--text-xs);
  text-transform: uppercase; letter-spacing: 0.14em; color: var(--muted);
  margin: 0 0 var(--space-4);
}
.eyebrow a { text-decoration: none; color: inherit; }
.eyebrow a:hover { color: var(--ink); }
.lede { font-size: var(--text-lg); color: var(--ink-2); max-width: 60ch; }

/* ===== Hero (home) ===== */
.hero {
  position: relative; overflow: hidden;
  padding: clamp(var(--space-16), 12vw, var(--space-32)) 0 clamp(var(--space-16), 10vw, var(--space-24));
  border-bottom: 1px solid var(--line);
}
.hero::before {
  content: ""; position: absolute; inset: 0;
  background:
    radial-gradient(circle at 78% 22%, color-mix(in oklab, var(--signal) 20%, transparent) 0%, transparent 50%),
    repeating-linear-gradient(90deg, transparent 0 39px, color-mix(in oklab, var(--ink) 5%, transparent) 39px 40px);
  mask-image: linear-gradient(180deg, black 60%, transparent 100%);
  pointer-events: none;
}
.hero__inner { position: relative; }
.hero__eyebrow {
  display: inline-flex; align-items: center; gap: 0.55rem;
  font-family: var(--font-mono); font-size: var(--text-xs);
  text-transform: uppercase; letter-spacing: 0.16em; color: var(--signal-ink);
  background: color-mix(in oklab, var(--signal) 15%, transparent);
  padding: 0.35rem 0.7rem; border-radius: 999px;
  border: 1px solid color-mix(in oklab, var(--signal) 30%, transparent);
}
.hero__pulse { width: 8px; height: 8px; border-radius: 50%; background: var(--signal); box-shadow: 0 0 0 0 var(--signal); animation: pulse 2.2s infinite; }
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 color-mix(in oklab, var(--signal) 60%, transparent); }
  70% { box-shadow: 0 0 0 12px transparent; }
  100% { box-shadow: 0 0 0 0 transparent; }
}
.hero__title {
  font-size: var(--text-hero); font-weight: 800; margin: var(--space-6) 0 var(--space-6);
  max-width: 16ch; letter-spacing: -0.035em;
}
.hero__title em { font-style: normal; color: var(--signal); }
.hero__lede { font-size: var(--text-lg); color: var(--ink-2); max-width: 58ch; }
.hero__cta { display: flex; gap: var(--space-3); margin-top: var(--space-8); flex-wrap: wrap; }

.btn {
  display: inline-flex; align-items: center; gap: 0.5rem;
  padding: 0.85rem 1.15rem; border-radius: var(--radius);
  font-family: var(--font-sans); font-weight: 600; font-size: var(--text-sm);
  text-decoration: none; border: 1px solid transparent;
  transition: transform 120ms ease, box-shadow 120ms ease, background 120ms ease;
}
.btn--primary { background: var(--ink); color: var(--paper); }
.btn--primary:hover { background: var(--signal); color: white; transform: translateY(-1px); }
.btn--ghost { background: transparent; color: var(--ink); border-color: var(--line-2); }
.btn--ghost:hover { border-color: var(--ink); }
.btn__arrow { transition: transform 200ms ease; }
.btn:hover .btn__arrow { transform: translateX(3px); }

/* ===== Home stat strip ===== */
.stat-strip {
  display: grid; gap: var(--space-6);
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  padding: var(--space-12) 0; border-bottom: 1px solid var(--line);
}
.stat { }
.stat__num { font-family: var(--font-display); font-weight: 800; font-size: var(--text-2xl); color: var(--ink); letter-spacing: -0.03em; }
.stat__num em { color: var(--signal); font-style: normal; }
.stat__label { font-size: var(--text-sm); color: var(--muted); margin-top: 0.25rem; }
.stat__label a { color: inherit; }

/* ===== Section shell ===== */
.section { padding: clamp(var(--space-16), 10vw, var(--space-24)) 0; border-bottom: 1px solid var(--line); }
.section--paper2 { background: var(--paper-2); }
.section__head { display: grid; gap: var(--space-3); margin-bottom: var(--space-10); max-width: 62ch; }
.section__title { font-size: var(--text-2xl); font-weight: 800; letter-spacing: -0.03em; }

/* ===== Pillar / feature cards ===== */
.pillars { display: grid; gap: var(--space-6); grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.pillar {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius-lg); padding: var(--space-6);
  display: flex; flex-direction: column; gap: var(--space-3);
  transition: border-color 180ms ease, transform 180ms ease;
}
.pillar:hover { border-color: var(--ink); transform: translateY(-2px); }
.pillar__num { font-family: var(--font-mono); font-size: var(--text-xs); color: var(--signal); letter-spacing: 0.14em; }
.pillar__title { font-size: var(--text-lg); font-weight: 700; }
.pillar__body { font-size: var(--text-sm); color: var(--muted); margin: 0; }

/* ===== Featured / article cards ===== */
.articles-grid { display: grid; gap: var(--space-8); grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.card {
  display: flex; flex-direction: column; gap: var(--space-3);
  padding: var(--space-6) 0; border-top: 1px solid var(--line);
}
.card__eyebrow { font-family: var(--font-mono); font-size: var(--text-xs); color: var(--muted); text-transform: uppercase; letter-spacing: 0.14em; }
.card__title { font-family: var(--font-display); font-size: var(--text-lg); font-weight: 700; letter-spacing: -0.02em; }
.card__title a { text-decoration: none; color: var(--ink); background-image: linear-gradient(var(--signal), var(--signal)); background-size: 0% 2px; background-repeat: no-repeat; background-position: 0 100%; transition: background-size 220ms ease; padding-bottom: 2px; }
.card__title a:hover { background-size: 100% 2px; }
.card__excerpt { color: var(--muted); font-size: var(--text-sm); margin: 0; }
.card__meta { font-family: var(--font-mono); font-size: var(--text-xs); color: var(--muted-2); }

/* ===== Prose (article body) ===== */
.prose { font-size: var(--text-base); line-height: 1.75; max-width: 65ch; }
.prose > * + * { margin-top: 1.1em; }
.prose h2 { font-size: var(--text-xl); font-weight: 800; margin-top: 2.2em; margin-bottom: 0.6em; letter-spacing: -0.02em; position: relative; }
.prose h2::before {
  content: ""; position: absolute; left: -1.25rem; top: 0.35em; width: 6px; height: 0.85em;
  background: var(--signal); border-radius: 2px;
}
.prose h3 { font-size: var(--text-lg); font-weight: 700; margin-top: 1.8em; margin-bottom: 0.5em; }
.prose a { color: var(--ink); text-decoration: underline; text-decoration-color: var(--signal); text-underline-offset: 3px; }
.prose a:hover { text-decoration-thickness: 2px; }
.prose ul, .prose ol { padding-left: 1.35rem; }
.prose li + li { margin-top: 0.35em; }
.prose blockquote {
  border-left: 3px solid var(--signal); padding: 0 0 0 var(--space-6); margin: 1.5em 0;
  color: var(--ink-2); font-family: var(--font-display); font-size: var(--text-lg); font-style: normal;
}
.prose code {
  font-family: var(--font-mono); font-size: 0.92em; background: var(--paper-2);
  padding: 0.15em 0.35em; border-radius: 3px; border: 1px solid var(--line);
}
.prose pre {
  background: var(--ink); color: var(--paper); padding: var(--space-4) var(--space-6);
  border-radius: var(--radius-lg); overflow: auto; line-height: 1.5; font-size: 0.9em;
}
.prose pre code { background: transparent; border: 0; padding: 0; color: inherit; }
/* Scroll wide tables inside their own box so the page never scrolls sideways */
.prose .table-scroll { overflow-x: auto; margin: 1.5em 0; -webkit-overflow-scrolling: touch; }
.prose table { width: 100%; border-collapse: collapse; font-size: 0.95em; }
.prose .table-scroll table { min-width: 30rem; margin: 0; }
.prose th, .prose td { text-align: left; padding: 0.65em 0.75em; border-bottom: 1px solid var(--line); vertical-align: top; }
.prose th { font-family: var(--font-display); font-weight: 700; background: var(--paper-2); }
.prose hr { border: 0; height: 1px; background: var(--line); margin: 2.5em 0; }
.prose .callout {
  border: 1px solid var(--line-2); border-left: 4px solid var(--signal);
  background: var(--card); padding: var(--space-4) var(--space-6); border-radius: var(--radius-lg);
}

/* Page/article headers */
/*
  Use padding-block, NOT the `padding` shorthand. These elements also carry
  .wrap, which supplies the horizontal gutter via padding-inline. A shorthand
  here resets padding-left/right to 0 and the hero text goes flush to both
  screen edges on narrow viewports.
*/
.page__header, .article__header { padding-block: clamp(var(--space-12), 8vw, var(--space-20)) var(--space-8); }
.page__title, .article__title {
  font-family: var(--font-display); font-weight: 800; font-size: var(--text-3xl);
  letter-spacing: -0.03em; margin: var(--space-3) 0 var(--space-4); line-height: 1.05;
}
.article__meta { font-family: var(--font-mono); font-size: var(--text-xs); color: var(--muted); text-transform: uppercase; letter-spacing: 0.12em; margin-top: var(--space-4); }
/* padding-block, not shorthand — also carries .wrap (see note at .article__header) */
.article__footer { padding-block: var(--space-8) var(--space-16); border-top: 1px solid var(--line); }
.back-link { font-family: var(--font-mono); text-decoration: none; color: var(--muted); font-size: var(--text-sm); }
.back-link:hover { color: var(--ink); }

/* ===== Ads ===== */
.ad {
  display: block; margin: var(--space-10) auto; text-align: center;
  padding-block: var(--space-2);
}
.ad__label {
  display: block; font-family: var(--font-mono); font-size: 10px;
  text-transform: uppercase; letter-spacing: 0.18em; color: var(--muted-2);
  margin-bottom: 0.5rem;
}
.ad__placeholder {
  border: 1.5px dashed var(--line-2);
  background:
    repeating-linear-gradient(45deg, transparent 0 10px, color-mix(in oklab, var(--muted) 6%, transparent) 10px 11px),
    var(--paper-2);
  border-radius: var(--radius-lg);
  display: flex; align-items: center; justify-content: center;
  width: 100%; height: 100%;
}
.ad__placeholder-inner { display: grid; gap: 0.25rem; padding: var(--space-6); text-align: center; }
.ad__placeholder-title { font-family: var(--font-display); font-weight: 700; color: var(--muted); }
.ad__placeholder-slot { font-family: var(--font-mono); font-size: var(--text-xs); color: var(--muted-2); text-transform: uppercase; letter-spacing: 0.14em; }
.ad__placeholder-id { font-family: var(--font-mono); font-size: 10px; color: var(--muted-2); }

/*
  Per-slot container sizing.
  Applied to .ad--<slot> directly so it governs BOTH the .ad__placeholder
  (dev / preview) and the live <ins class="adsbygoogle"> element (production).
  Rules:
    - min-height reserves layout space (prevents CLS while AdSense fills)
    - max-width matches Google AdSense responsive breakpoints for each slot
    - width: 100% lets AdSense responsive (data-ad-format="auto",
      data-full-width-responsive="true") pick the right size within the box
    - No fixed height on live "ins" — AdSense needs vertical flexibility
*/
.ad--header,
.ad--footer { min-height: 90px; max-width: 728px; margin-left: auto; margin-right: auto; }
.ad--in-article { min-height: 250px; max-width: 720px; margin-left: auto; margin-right: auto; }
.ad--sidebar { min-height: 600px; max-width: 300px; }

/*
  Accidental-click separation.
  AdSense policy warns that placing links and navigation buttons near ads can
  generate accidental clicks and trigger a violation even when unintentional
  (support.google.com/adsense/answer/1346295). The end-of-content unit sits
  directly above the "All articles" navigation, so it gets extra clearance
  and a rule to visually separate ad from navigation.
*/
.ad--footer { margin-bottom: var(--space-16); }

/* Ensure the live <ins> stretches to fill the reserved container */
.ad .adsbygoogle { display: block; width: 100%; min-height: inherit; }

/* Preserve placeholder-only inner sizing for the dev-state dashed box */
.ad--header .ad__placeholder,
.ad--footer .ad__placeholder { min-height: 90px; }
.ad--in-article .ad__placeholder { min-height: 250px; }
.ad--sidebar .ad__placeholder { min-height: 600px; }

@media (max-width: 720px) {
  .ad--header,
  .ad--footer { max-width: 320px; min-height: 100px; }
  .ad--in-article { min-height: 250px; max-width: 100%; }
  .ad--header .ad__placeholder,
  .ad--footer .ad__placeholder { min-height: 100px; }
}

/* ===== Footer ===== */
.site-footer { background: var(--paper-2); border-top: 1px solid var(--line); margin-top: var(--space-16); }
.footer__wrap { display: grid; gap: var(--space-10); grid-template-columns: 1.4fr 2fr; padding-top: var(--space-16); padding-bottom: var(--space-10); align-items: start; }
.footer__tag { color: var(--muted); font-size: var(--text-sm); max-width: 40ch; margin-top: var(--space-3); }
.footer__nav { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--space-8); }
.footer__nav h2 { font-family: var(--font-mono); font-size: var(--text-xs); text-transform: uppercase; letter-spacing: 0.14em; color: var(--muted); font-weight: 500; margin-bottom: var(--space-3); }
.footer__nav ul { list-style: none; padding: 0; margin: 0; display: grid; gap: 0.4rem; }
.footer__nav a { color: var(--ink); text-decoration: none; font-size: var(--text-sm); }
.footer__nav a:hover { text-decoration: underline; text-decoration-color: var(--signal); }
.footer__meta { border-top: 1px solid var(--line); padding: var(--space-6) var(--space-6); display: flex; justify-content: space-between; gap: var(--space-4); flex-wrap: wrap; font-size: var(--text-xs); color: var(--muted); }
.footer__meta p { margin: 0; }

@media (max-width: 720px) {
  .footer__wrap { grid-template-columns: 1fr; }
  .footer__nav { grid-template-columns: repeat(2, 1fr); }
}

/* ===== Utility ===== */
.center { text-align: center; }
.mt-8 { margin-top: var(--space-8); }
