/*
 * soma(som) landing · public web presence
 * Consumes /assets/fonts.css + /assets/soma-tokens.css + /assets/soma-tokens-dark.css.
 *
 * Harmonized layout system — one stylesheet for all pages (landing, perspectives, impressum).
 *
 * Breakpoint ladder (mobile-first, min-width):
 *   base (<480px)   — small mobile (iPhone SE, Galaxy Fold)
 *   480px   — large mobile landscape
 *   640px   — phablet / small tablet portrait
 *   768px   — tablet portrait (iPad)
 *   1024px  — tablet landscape / small laptop
 *   1280px  — desktop
 *   1536px  — large desktop
 *   1920px  — full HD cap (content stops stretching)
 *
 * Fluid typography + spacing via clamp() give continuous scaling WITHOUT discrete jumps.
 * Breakpoints are reserved for genuine layout changes (grid → stack, nav → menu, etc.).
 */

/* ────────────────────────────────────────────────────────────────────────────
   TOKENS — page-scoped (canonical palette comes from /assets/soma-tokens.css)
   ──────────────────────────────────────────────────────────────────────────── */

:root {
  /* Fluid type scale — min at 320px vw, max at 1920px vw. */
  --font-xs:    clamp(0.75rem,  0.72rem + 0.15vw, 0.875rem);
  --font-sm:    clamp(0.875rem, 0.84rem + 0.17vw, 1rem);
  --font-base:  clamp(1rem,     0.95rem + 0.25vw, 1.125rem);
  --font-md:    clamp(1.125rem, 1.05rem + 0.37vw, 1.375rem);
  --font-lg:    clamp(1.375rem, 1.25rem + 0.63vw, 1.75rem);
  --font-xl:    clamp(1.75rem,  1.5rem + 1.25vw, 2.5rem);
  --font-2xl:   clamp(2rem,     1.6rem + 2vw,    3.25rem);
  --font-3xl:   clamp(2.5rem,   2rem + 2.5vw,    4.5rem);

  /* Fluid space scale. */
  --sp-2xs: clamp(0.25rem, 0.22rem + 0.15vw, 0.4rem);
  --sp-xs:  clamp(0.375rem, 0.3rem + 0.37vw, 0.625rem);
  --sp-sm:  clamp(0.625rem, 0.5rem + 0.625vw, 1rem);
  --sp-md:  clamp(1rem,     0.75rem + 1.25vw, 2rem);
  --sp-lg:  clamp(1.5rem,   1rem + 2.5vw,     3.5rem);
  --sp-xl:  clamp(2.5rem,   1.5rem + 5vw,     6rem);
  --sp-2xl: clamp(3.5rem,   2rem + 7.5vw,     8rem);

  /* Container widths. */
  --w-wide:  1200px;
  --w-prose: 86ch;  /* widened from 68ch per user feedback — long-form perspectives felt column-starved at 1920 */

  /* Horizontal page gutter — same at every breakpoint, scales fluidly. */
  --pad-x: clamp(1rem, 0.5rem + 2.5vw, 2.5rem);

  /* Vertical rhythm. */
  --topbar-h:   clamp(3rem, 2.5rem + 1.5vw, 3.75rem);
}

/* ─── LANDING-LOCAL BRAND SHIFT ───────────────────────────────────────────────
   Canonical palette (/assets/soma-tokens.css) sets brand-primary to aqua-800
   + ruby-800. Per user direction (prototype on landing), nudge to -700 for a
   warmer, less-ink primary. Dark-theme pair shifts -400 → -500 (deeper
   visible). Canonical substrate is untouched; if this direction holds, promote
   to /assets/ in a separate chartered scope.
   ──────────────────────────────────────────────────────────────────────────── */

:root {
  --color-primary:       var(--soma-aqua-700);
  --color-primary-hover: var(--soma-aqua-600);
  --color-primary-active: var(--soma-aqua-800);
  --color-text-brand:    var(--soma-aqua-700);
  --color-accent:        var(--soma-ruby-700);
  --color-accent-hover:  var(--soma-ruby-600);
  --color-text-accent:   var(--soma-ruby-700);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --color-primary:       var(--soma-aqua-500);
    --color-primary-hover: var(--soma-aqua-400);
    --color-primary-active: var(--soma-aqua-600);
    --color-text-brand:    var(--soma-aqua-500);
    --color-accent:        var(--soma-ruby-500);
    --color-accent-hover:  var(--soma-ruby-400);
    --color-text-accent:   var(--soma-ruby-500);
  }
}
:root[data-theme="dark"] {
  --color-primary:       var(--soma-aqua-500);
  --color-primary-hover: var(--soma-aqua-400);
  --color-primary-active: var(--soma-aqua-600);
  --color-text-brand:    var(--soma-aqua-500);
  --color-accent:        var(--soma-ruby-500);
  --color-accent-hover:  var(--soma-ruby-400);
  --color-text-accent:   var(--soma-ruby-500);
}

/* ────────────────────────────────────────────────────────────────────────────
   RESET
   ──────────────────────────────────────────────────────────────────────────── */

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

html {
  -webkit-text-size-adjust: 100%;
  color-scheme: light dark;
  scroll-behavior: smooth;
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-serif);
  font-size: var(--font-base);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

img, svg { max-width: 100%; height: auto; display: block; }

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-display);
  font-weight: 400;
  line-height: 1.2;
  margin: 0;
  color: var(--color-text);
}

p { margin: 0; }

ul, ol { margin: 0; padding-left: 1.25em; }

:focus-visible {
  outline: 2px solid var(--color-focus-ring);
  outline-offset: 3px;
  border-radius: 2px;
}

a {
  color: var(--color-primary);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}
a:hover { color: var(--color-primary-hover); }

/* ────────────────────────────────────────────────────────────────────────────
   A11Y UTILITIES
   ──────────────────────────────────────────────────────────────────────────── */

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0);
  white-space: nowrap; border: 0;
}

.skip-link {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0);
  white-space: nowrap; border: 0;
  background: var(--color-primary);
  color: var(--color-text-inverse);
  text-decoration: none;
  border-radius: 4px;
  z-index: 100;
  font-family: var(--font-mono);
  font-size: var(--font-sm);
}
.skip-link:focus,
.skip-link:focus-visible {
  position: absolute !important;
  top: var(--sp-sm);
  left: var(--sp-sm);
  width: auto; height: auto;
  padding: var(--sp-xs) var(--sp-sm);
  margin: 0;
  overflow: visible; clip: auto;
}

/* ────────────────────────────────────────────────────────────────────────────
   WORDMARK — dual-swap pattern (dual-guard: media + [data-theme])
   ──────────────────────────────────────────────────────────────────────────── */

.wordmark { display: block; width: 100%; height: auto; }
.wordmark-light { display: block; }
.wordmark-dark  { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .wordmark-light { display: none; }
  :root:not([data-theme="light"]) .wordmark-dark  { display: block; }
}
:root[data-theme="dark"]  .wordmark-light { display: none; }
:root[data-theme="dark"]  .wordmark-dark  { display: block; }
:root[data-theme="light"] .wordmark-light { display: block; }
:root[data-theme="light"] .wordmark-dark  { display: none; }

/* ────────────────────────────────────────────────────────────────────────────
   TOPBAR — unified across all pages
   ──────────────────────────────────────────────────────────────────────────── */

.topbar {
  position: sticky; top: 0; z-index: 50;
  /* Fully opaque — the previous 88% + blur variant let scrolled-under content
     bleed through, which looked like "topbar is in the wrong place" when
     scrolled over wide diagrams. Solid bg = clean overlap. */
  background: var(--color-bg);
  border-bottom: 1px solid var(--color-border);
  min-height: var(--topbar-h);
  display: flex;
  align-items: center;
}
.topbar-inner {
  width: 100%;
  max-width: var(--w-wide);
  margin: 0 auto;
  padding: var(--sp-sm) var(--pad-x);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-sm);
}
.brand {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
  color: inherit;
  flex-shrink: 0;
}
.wordmark-small {
  width: clamp(120px, 10vw + 80px, 160px);
  height: auto;
}
.topbar-actions {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-xs);
}

.theme-toggle {
  width: 2.25rem; height: 2.25rem;
  display: inline-flex;
  align-items: center; justify-content: center;
  background: transparent;
  color: var(--color-text);
  border: 1px solid var(--color-border);
  border-radius: 999px;
  cursor: pointer;
  font-family: var(--font-serif);
  font-size: 1.125rem; line-height: 1;
  transition: background 180ms ease, border-color 180ms ease, color 180ms ease;
}
.theme-toggle:hover {
  background: var(--color-bg-subtle);
  border-color: var(--color-border-strong);
}
.theme-icon-sun  { display: none; }
.theme-icon-moon { display: inline; }
:root[data-theme="dark"]  .theme-icon-sun  { display: inline; }
:root[data-theme="dark"]  .theme-icon-moon { display: none; }
:root[data-theme="light"] .theme-icon-sun  { display: none; }
:root[data-theme="light"] .theme-icon-moon { display: inline; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-icon-sun  { display: inline; }
  :root:not([data-theme="light"]) .theme-icon-moon { display: none; }
}

/* ────────────────────────────────────────────────────────────────────────────
   MAIN containers
   ──────────────────────────────────────────────────────────────────────────── */

main {
  flex: 1 0 auto;
  width: 100%;
  max-width: var(--w-wide);
  margin: 0 auto;
  padding: var(--sp-lg) var(--pad-x);
}
/* Prose-tier pages (perspective, impressum): same 1200px main shell as landing.
   Content fills main — no inner reading-column constraint (user direction:
   visual consistency with landing hero/tour at 1200px, accepting that line
   length runs ~110-120ch, past the classic 45-75ch typographic sweet spot).
   If reading comfort later needs restoring, add back max-width + margin-inline
   on specific text elements (p, ul, ol) rather than on main's direct children. */

/* ────────────────────────────────────────────────────────────────────────────
   HERO (landing index only)
   ──────────────────────────────────────────────────────────────────────────── */

.hero {
  text-align: center;
  padding: var(--sp-xl) 0 var(--sp-lg);
  border-bottom: 1px solid var(--color-border);
  margin-bottom: var(--sp-xl);
}
.hero-wordmark {
  margin: 0 auto var(--sp-lg);
  max-width: min(420px, 72vw);
}
.hero-wordmark img { margin: 0 auto; width: 100%; }
.hero-strap {
  font-family: var(--font-display);
  font-size: var(--font-2xl);
  line-height: 1.2;
  color: var(--color-text);
  margin: 0 0 var(--sp-md);
  font-weight: 400;
}
.hero-sub {
  max-width: 46rem;
  margin: 0 auto var(--sp-md);
  font-size: var(--font-md);
  line-height: 1.45;
  color: var(--color-text-muted);
  padding: 0 var(--sp-sm);
}
.hero-cite {
  margin: 0;
  font-family: var(--font-mono);
  font-size: var(--font-sm);
  letter-spacing: 0.02em;
}
.hero-cite a {
  color: var(--color-text-brand);
  text-decoration: none;
  border-bottom: 1px solid var(--color-border-strong);
  padding-bottom: 2px;
}
.hero-cite a:hover {
  color: var(--color-primary-hover);
  border-bottom-color: var(--color-primary-hover);
}

/* ────────────────────────────────────────────────────────────────────────────
   TOUR PANELS (landing index only)
   ──────────────────────────────────────────────────────────────────────────── */

.tour { margin-bottom: var(--sp-2xl); }

.tour-panel {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--sp-md);
  align-items: center;
  padding: var(--sp-lg) 0;
  border-bottom: 1px solid var(--color-border);
}
.tour-panel:last-child { border-bottom: none; }

@media (min-width: 768px) {
  .tour-panel {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: var(--sp-lg);
    padding: var(--sp-xl) 0;
  }
  /* Alternate figure/text sides automatically (no per-panel class needed). */
  .tour-panel:nth-of-type(even) .tour-fig { order: -1; }
  .tour-panel-reverse .tour-fig { order: -1; }  /* legacy class kept for compatibility */
}

.hero-notation {
  font-family: var(--font-mono);
  font-size: 0.92em;
  letter-spacing: 0.02em;
  color: var(--color-text-brand);
}

.tour-text .eyebrow {
  font-family: var(--font-mono);
  font-size: var(--font-sm);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-text-accent);
  margin: 0 0 var(--sp-xs);
}
.tour-text h3 {
  font-family: var(--font-display);
  font-size: var(--font-xl);
  line-height: 1.2;
  color: var(--color-text);
  margin: 0 0 var(--sp-sm);
  font-weight: 400;
}
.tour-text p {
  margin: 0 0 var(--sp-sm);
  font-size: var(--font-md);
  line-height: 1.5;
  color: var(--color-text);
}
.tour-text .pull {
  font-family: var(--font-display);
  font-style: italic;
  font-size: var(--font-md);
  color: var(--color-text-brand);
  border-left: 2px solid var(--color-primary);
  padding-left: var(--sp-sm);
  margin-top: var(--sp-md);
}

.tour-fig { margin: 0; text-align: center; }
.tour-fig img {
  margin: 0 auto;
  max-height: clamp(260px, 45vw, 560px);
  width: 100%;
  object-fit: contain;
  transition: filter 120ms ease;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .tour-fig img { filter: invert(0.92) hue-rotate(180deg); }
}
:root[data-theme="dark"]  .tour-fig img { filter: invert(0.92) hue-rotate(180deg); }
:root[data-theme="light"] .tour-fig img { filter: none; }

.tour-fig figcaption {
  font-family: var(--font-mono);
  font-size: var(--font-sm);
  color: var(--color-text-subtle);
  margin-top: var(--sp-xs);
}
.tour-fig figcaption .fig-label,
.perspective-fig figcaption .fig-label {
  color: var(--color-text-accent);
  font-weight: 600;
  letter-spacing: 0.06em;
  margin-right: 0.55em;
}

.six-questions {
  list-style: none;
  padding: 0;
  margin: var(--sp-sm) 0 0;
  display: grid;
  gap: var(--sp-xs);
  counter-reset: question;
}
.six-questions li {
  position: relative;
  padding-left: 2.5em;
  font-size: var(--font-base);
  line-height: 1.5;
  color: var(--color-text);
  counter-increment: question;
}
.six-questions li::before {
  content: counter(question, decimal-leading-zero);
  position: absolute;
  left: 0; top: 0.1em;
  font-family: var(--font-mono);
  font-size: var(--font-sm);
  color: var(--color-text-accent);
  font-weight: 600;
  letter-spacing: 0.08em;
}

/* ────────────────────────────────────────────────────────────────────────────
   DOORS (landing index only)
   ──────────────────────────────────────────────────────────────────────────── */

.doors { margin-bottom: var(--sp-2xl); }

.doors-heading {
  text-align: center;
  max-width: 42rem;
  margin: 0 auto var(--sp-lg);
  padding: 0 var(--sp-sm);
}
.doors-heading .eyebrow {
  font-family: var(--font-mono);
  font-size: var(--font-sm);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-text-accent);
  margin: 0 0 var(--sp-xs);
}
.doors-heading h2 {
  font-family: var(--font-display);
  font-size: var(--font-xl);
  line-height: 1.2;
  color: var(--color-text);
  margin: 0 0 var(--sp-sm);
  font-weight: 400;
}
.doors-lede {
  font-size: var(--font-md);
  line-height: 1.45;
  color: var(--color-text-muted);
  margin: 0;
}

.doors-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--sp-md);
}
@media (min-width: 768px)  { .doors-list { grid-template-columns: 1fr 1fr; } }
@media (min-width: 1024px) { .doors-list { grid-template-columns: 1fr 1fr 1fr; } }

.door { margin: 0; }
.door-link {
  display: grid;
  grid-template-rows: auto auto auto 1fr auto;
  gap: var(--sp-xs);
  padding: var(--sp-md);
  min-height: 18rem;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  background: var(--color-bg-subtle);
  color: var(--color-text);
  text-decoration: none;
  transition: border-color 220ms ease, background 220ms ease, transform 220ms ease;
}
.door-link:hover,
.door-link:focus-visible {
  border-color: var(--color-primary);
  background: var(--color-bg);
  transform: translateY(-2px);
}
.door-num {
  font-family: var(--font-mono);
  font-size: var(--font-sm);
  letter-spacing: 0.12em;
  color: var(--color-text-accent);
  font-weight: 600;
}
.door-eyebrow {
  font-family: var(--font-mono);
  font-size: var(--font-xs);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-text-muted);
}
.door-title {
  font-family: var(--font-display);
  font-size: var(--font-lg);
  line-height: 1.2;
  color: var(--color-text);
  font-weight: 400;
}
.door-blurb {
  font-size: var(--font-base);
  line-height: 1.5;
  color: var(--color-text);
}
.door-cta {
  font-family: var(--font-mono);
  font-size: var(--font-sm);
  color: var(--color-primary);
  letter-spacing: 0.02em;
  margin-top: var(--sp-2xs);
}

/* ────────────────────────────────────────────────────────────────────────────
   CLOSING (landing index only)
   ──────────────────────────────────────────────────────────────────────────── */

.closing {
  text-align: center;
  padding: var(--sp-xl) 0 var(--sp-md);
  border-top: 1px solid var(--color-border);
}
.closing-line {
  font-family: var(--font-display);
  font-size: var(--font-xl);
  line-height: 1.25;
  color: var(--color-text);
  margin: 0 0 var(--sp-md);
  font-weight: 400;
  font-style: italic;
}
.closing-cite {
  font-family: var(--font-mono);
  font-size: var(--font-sm);
  color: var(--color-text-muted);
  margin: 0;
  padding: 0 var(--sp-sm);
}
.closing-cite a {
  color: var(--color-text-brand);
  text-decoration: none;
  border-bottom: 1px solid var(--color-border-strong);
  padding-bottom: 2px;
  margin: 0 var(--sp-xs);
}
.closing-cite a:hover {
  color: var(--color-primary-hover);
  border-bottom-color: var(--color-primary-hover);
}
.closing-cite .sep { margin: 0 var(--sp-xs); color: var(--color-text-subtle); }

/* ────────────────────────────────────────────────────────────────────────────
   PROSE PAGES (perspective + impressum)
   ──────────────────────────────────────────────────────────────────────────── */

.breadcrumb {
  margin-bottom: var(--sp-md);
  font-family: var(--font-mono);
  font-size: var(--font-sm);
  color: var(--color-text-muted);
}
.breadcrumb ol {
  list-style: none;
  padding: 0; margin: 0;
  display: flex; flex-wrap: wrap;
  gap: var(--sp-xs);
}
.breadcrumb li + li::before {
  content: "/ ";
  color: var(--color-text-subtle);
  margin-right: var(--sp-xs);
}
.breadcrumb a {
  color: var(--color-text-muted);
  text-decoration: none;
}
.breadcrumb a:hover { color: var(--color-primary-hover); }
.breadcrumb [aria-current] { color: var(--color-text); }

/* Prose-page header: shared by perspective + impressum. */
.prose-header,
.perspective-header {
  margin: 0 0 var(--sp-lg);
  padding-bottom: var(--sp-md);
  border-bottom: 1px solid var(--color-border);
}
.prose-eyebrow,
.perspective-door {
  font-family: var(--font-mono);
  font-size: var(--font-md);
  letter-spacing: 0.08em;
  color: var(--color-text-accent);
  margin: 0 0 var(--sp-xs);
  font-weight: 600;
}
.prose-header h1,
.perspective-header h1 {
  font-family: var(--font-display);
  font-size: var(--font-2xl);
  line-height: 1.15;
  color: var(--color-text);
  margin: 0 0 var(--sp-sm);
  font-weight: 400;
}
.prose-lede,
.perspective-audience {
  font-size: var(--font-md);
  line-height: 1.5;
  color: var(--color-text-muted);
  font-style: italic;
  margin: 0;
}

/* Prose content — shared by perspective + impressum .legal. */
.perspective section,
.legal section {
  margin-bottom: var(--sp-lg);
}
.perspective h2,
.legal h2 {
  font-family: var(--font-display);
  font-size: var(--font-xl);
  line-height: 1.2;
  color: var(--color-text);
  margin: 0 0 var(--sp-sm);
  font-weight: 400;
}
.perspective h3,
.legal h3 {
  font-family: var(--font-display);
  font-size: var(--font-lg);
  line-height: 1.25;
  color: var(--color-text);
  margin: var(--sp-md) 0 var(--sp-sm);
  font-weight: 400;
}
.perspective p,
.legal p,
.legal address {
  margin: 0 0 var(--sp-sm);
  font-size: var(--font-md);
  line-height: 1.55;
  color: var(--color-text);
  font-style: normal;
}
.perspective ul, .perspective ol,
.legal ul, .legal ol {
  margin: 0 0 var(--sp-sm);
  padding-left: 1.5em;
}
.perspective li,
.legal li {
  margin-bottom: var(--sp-xs);
  font-size: var(--font-md);
  line-height: 1.55;
}
.perspective .named-list { list-style: none; padding-left: 0; }
.perspective .named-list li {
  padding-left: 1.1em;
  position: relative;
  margin-bottom: var(--sp-xs);
}
.perspective .named-list li::before {
  content: "·";
  position: absolute; left: 0.3em; top: 0;
  color: var(--color-text-accent);
  font-weight: 700;
}
.perspective .pull {
  font-family: var(--font-display);
  font-style: italic;
  font-size: var(--font-lg);
  color: var(--color-text-brand);
  border-left: 2px solid var(--color-primary);
  padding: var(--sp-xs) 0 var(--sp-xs) var(--sp-sm);
  margin: var(--sp-md) 0;
  line-height: 1.35;
}

.perspective-fig {
  margin: var(--sp-lg) 0;
  text-align: center;
}
.perspective-fig img {
  margin: 0 auto;
  max-height: clamp(280px, 55vw, 720px);
  width: 100%;
  object-fit: contain;
  transition: filter 120ms ease;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .perspective-fig img { filter: invert(0.92) hue-rotate(180deg); }
}
:root[data-theme="dark"]  .perspective-fig img { filter: invert(0.92) hue-rotate(180deg); }
:root[data-theme="light"] .perspective-fig img { filter: none; }

/* fig2-composition ships as two SVG variants (light + dark), each already in
   brand palette. Swap via dual-guard pattern like the wordmark. The dark-mode
   invert filter would mangle the intentional colors, so disable for .fig-themed. */
.perspective-fig .fig-themed { filter: none !important; }

.perspective-fig .fig-light { display: block; }
.perspective-fig .fig-dark  { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .perspective-fig .fig-light { display: none; }
  :root:not([data-theme="light"]) .perspective-fig .fig-dark  { display: block; }
}
:root[data-theme="dark"]  .perspective-fig .fig-light { display: none; }
:root[data-theme="dark"]  .perspective-fig .fig-dark  { display: block; }
:root[data-theme="light"] .perspective-fig .fig-light { display: block; }
:root[data-theme="light"] .perspective-fig .fig-dark  { display: none; }
.perspective-fig figcaption {
  font-family: var(--font-mono);
  font-size: var(--font-sm);
  color: var(--color-text-subtle);
  margin-top: var(--sp-xs);
  line-height: 1.4;
}

/* Legal-specific — contact link + lang-note. */
.legal address a { word-break: break-word; }
.legal .lang-note {
  margin-top: var(--sp-lg);
  padding-top: var(--sp-md);
  border-top: 1px solid var(--color-border);
  font-family: var(--font-mono);
  font-size: var(--font-sm);
  color: var(--color-text-muted);
  font-style: italic;
}

/* Code block + table (perspective 02 + 03). */
.code-block {
  font-family: var(--font-mono);
  font-size: clamp(0.72rem, 0.65rem + 0.3vw, 0.85rem);
  line-height: 1.4;
  background: var(--color-bg-muted);
  border: 1px solid var(--color-border);
  border-radius: 4px;
  padding: var(--sp-sm);
  margin: var(--sp-sm) 0;
  overflow-x: auto;
  color: var(--color-text);
  scrollbar-width: thin;
  scrollbar-color: var(--color-border-strong) transparent;
  white-space: pre-wrap;
  overflow-wrap: break-word;
}
.code-block code { font-family: inherit; }
.code-block::-webkit-scrollbar { height: 8px; }
.code-block::-webkit-scrollbar-thumb { background: var(--color-border-strong); border-radius: 4px; }
.code-block::-webkit-scrollbar-track { background: transparent; }

.table-scroll {
  margin: var(--sp-md) 0;
  overflow-x: auto;
  border: 1px solid var(--color-border);
  border-radius: 4px;
}
.rel-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--font-base);
  line-height: 1.4;
}
.rel-table caption {
  caption-side: top;
  text-align: left;
  padding: var(--sp-xs);
  font-family: var(--font-mono);
  font-size: var(--font-sm);
  color: var(--color-text-muted);
}
.rel-table th,
.rel-table td {
  padding: var(--sp-xs) var(--sp-sm);
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid var(--color-border);
}
.rel-table thead th {
  font-family: var(--font-mono);
  font-size: var(--font-sm);
  letter-spacing: 0.04em;
  color: var(--color-text-accent);
  background: var(--color-bg-subtle);
  border-bottom: 2px solid var(--color-border-strong);
}
.rel-table tbody th {
  font-weight: 600;
  background: var(--color-bg-subtle);
  color: var(--color-text);
}
.rel-table tbody tr:last-child td,
.rel-table tbody tr:last-child th { border-bottom: none; }

.closing-section {
  padding-top: var(--sp-md);
  border-top: 1px solid var(--color-border);
  margin-top: var(--sp-lg);
}
.perspective .closing-section .closing-line {
  font-family: var(--font-display);
  font-style: italic;
  font-size: var(--font-lg);
  line-height: 1.3;
  color: var(--color-text-brand);
  text-align: center;
  margin: var(--sp-md) 0 0;
  font-weight: 400;
}

/* ────────────────────────────────────────────────────────────────────────────
   PERSPECTIVE NAV (end of article → the other two)
   ──────────────────────────────────────────────────────────────────────────── */

.perspective-nav {
  margin: var(--sp-xl) 0 var(--sp-lg);
  padding-top: var(--sp-lg);
  border-top: 1px solid var(--color-border);
}
.perspective-nav ol {
  list-style: none;
  padding: 0; margin: 0;
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--sp-sm);
}
@media (min-width: 640px) {
  .perspective-nav ol { grid-template-columns: 1fr 1fr; }
}
.perspective-nav li { margin: 0; padding: 0; }
.perspective-nav a {
  display: grid; gap: var(--sp-2xs);
  padding: var(--sp-md);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  background: var(--color-bg-subtle);
  color: var(--color-text);
  text-decoration: none;
  transition: border-color 220ms ease, background 220ms ease, transform 220ms ease;
}
.perspective-nav a:hover,
.perspective-nav a:focus-visible {
  border-color: var(--color-primary);
  background: var(--color-bg);
  transform: translateY(-2px);
}
.pn-num {
  font-family: var(--font-mono);
  font-size: var(--font-sm);
  letter-spacing: 0.12em;
  color: var(--color-text-accent);
  font-weight: 600;
}
.pn-eyebrow {
  font-family: var(--font-mono);
  font-size: var(--font-xs);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--color-text-muted);
}
.pn-title {
  font-family: var(--font-display);
  font-size: var(--font-md);
  line-height: 1.25;
  color: var(--color-text);
  font-weight: 400;
}

/* ────────────────────────────────────────────────────────────────────────────
   SITE FOOTER — unified across all pages
   ──────────────────────────────────────────────────────────────────────────── */

.site-footer {
  margin-top: var(--sp-xl);
  padding: var(--sp-lg) var(--pad-x);
  border-top: 1px solid var(--color-border);
  background: var(--color-bg-subtle);
  font-family: var(--font-mono);
  font-size: var(--font-sm);
  color: var(--color-text-muted);
}
.site-footer-inner {
  max-width: var(--w-wide);
  margin: 0 auto;
  text-align: center;
}
.foot-nav {
  list-style: none;
  padding: 0;
  margin: 0 0 var(--sp-sm);
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-xs) var(--sp-md);
  justify-content: center;
}
.foot-nav a {
  color: var(--color-text-muted);
  text-decoration: none;
}
.foot-nav a:hover { color: var(--color-primary-hover); }
.foot-nav [aria-current] { color: var(--color-text); }
.foot-cite {
  margin: 0;
  font-size: var(--font-xs);
  color: var(--color-text-subtle);
}
.foot-cite a {
  color: var(--color-text-subtle);
  text-decoration: underline;
}

/* ────────────────────────────────────────────────────────────────────────────
   LARGE-DESKTOP CAP — content stops growing at 1200px wide (per --w-wide).
   Beyond ~1536px the gutters just widen; this is intentional (avoids
   over-long measure that hurts readability on 4K displays).
   ──────────────────────────────────────────────────────────────────────────── */

@media (min-width: 1536px) {
  :root {
    --pad-x: 2.5rem;
  }
}

@media (min-width: 1920px) {
  :root {
    --pad-x: 3rem;
  }
}

/* ────────────────────────────────────────────────────────────────────────────
   PRINT
   ──────────────────────────────────────────────────────────────────────────── */

@media print {
  :root, :root[data-theme="dark"] { color-scheme: light; }
  .topbar, .theme-toggle, .perspective-nav, .site-footer { display: none; }
  main { max-width: none; padding: 0; }
  body { background: #fff; color: #000; }
  a { color: inherit; text-decoration: none; }
  .perspective-fig img,
  .tour-fig img { max-height: none; filter: none !important; }
  section, figure { break-inside: avoid; }
  h1, h2, h3 { break-after: avoid; }
}
