/* Shared design system for consciousness-map, grounding-the-unconscious, genealogies-of-desire */

:root {
  --ground: #EDF0F4;
  --panel: #F7F9FC;
  --panel-2: #EEF2F7;
  --ink: #161C28;
  --muted: #58627A;
  --faint: #8B94A8;
  --line: rgba(20, 28, 48, 0.14);
  --grid: rgba(20, 28, 48, 0.07);
  --cross: rgba(20, 28, 48, 0.16);
  --cyan: #0E7F94;
  --cyan-soft: rgba(14, 127, 148, 0.12);
  --violet: #6B46C1;
  --violet-soft: rgba(107, 70, 193, 0.12);
  --gold: #9C6F1C;
  --shadow: 0 1px 2px rgba(20, 28, 48, 0.06), 0 8px 30px rgba(20, 28, 48, 0.07);
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, "Times New Roman", serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --ground: #0B0F1C;
    --panel: #121829;
    --panel-2: #0E1424;
    --ink: #D8DFEC;
    --muted: #8A96AE;
    --faint: #626E88;
    --line: rgba(255, 255, 255, 0.13);
    --grid: rgba(255, 255, 255, 0.06);
    --cross: rgba(255, 255, 255, 0.16);
    --cyan: #3BC1D6;
    --cyan-soft: rgba(59, 193, 214, 0.14);
    --violet: #A987F5;
    --violet-soft: rgba(169, 135, 245, 0.15);
    --gold: #D9B15E;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 12px 40px rgba(0, 0, 0, 0.45);
  }
}

:root[data-theme="light"] {
  --ground: #EDF0F4;
  --panel: #F7F9FC;
  --panel-2: #EEF2F7;
  --ink: #161C28;
  --muted: #58627A;
  --faint: #8B94A8;
  --line: rgba(20, 28, 48, 0.14);
  --grid: rgba(20, 28, 48, 0.07);
  --cross: rgba(20, 28, 48, 0.16);
  --cyan: #0E7F94;
  --cyan-soft: rgba(14, 127, 148, 0.12);
  --violet: #6B46C1;
  --violet-soft: rgba(107, 70, 193, 0.12);
  --gold: #9C6F1C;
  --shadow: 0 1px 2px rgba(20, 28, 48, 0.06), 0 8px 30px rgba(20, 28, 48, 0.07);
}

:root[data-theme="dark"] {
  --ground: #0B0F1C;
  --panel: #121829;
  --panel-2: #0E1424;
  --ink: #D8DFEC;
  --muted: #8A96AE;
  --faint: #626E88;
  --line: rgba(255, 255, 255, 0.13);
  --grid: rgba(255, 255, 255, 0.06);
  --cross: rgba(255, 255, 255, 0.16);
  --cyan: #3BC1D6;
  --cyan-soft: rgba(59, 193, 214, 0.14);
  --violet: #A987F5;
  --violet-soft: rgba(169, 135, 245, 0.15);
  --gold: #D9B15E;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 12px 40px rgba(0, 0, 0, 0.45);
}

html { background: #0b0f1c; }
@media (prefers-color-scheme: light) { html { background: #edf0f4; } }
:root[data-theme="light"] { background: #edf0f4; }
:root[data-theme="dark"] { background: #0b0f1c; }

* { box-sizing: border-box; }
body { margin: 0; }
img { max-width: 100%; }

.wrap {
  background: var(--ground);
  color: var(--ink);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
  line-height: 1.55;
  padding: clamp(20px, 5vw, 64px) clamp(16px, 5vw, 56px) 72px;
}
.inner { max-width: 1120px; margin: 0 auto; }
.wrap.essay .inner,
.wrap.essay { max-width: 960px; }

.site-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
  align-items: baseline;
  margin: 0 0 28px;
  padding: 0 0 14px;
  border-bottom: 1px solid var(--line);
  font-family: var(--sans);
  font-size: 0.85rem;
}
.site-bar a {
  color: var(--muted);
  font-weight: 500;
  text-decoration: none;
  border-bottom: none;
}
.site-bar a:hover { color: var(--ink); }
.site-bar .sep { color: var(--faint); user-select: none; opacity: 1; }

.eyebrow {
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--cyan);
  margin: 0 0 18px;
  display: flex;
  gap: 0.6em;
  align-items: center;
  flex-wrap: wrap;
}
.eyebrow .dot { color: var(--violet); }
.eyebrow .dot2 { color: var(--cyan); }

h1 {
  font-family: var(--serif);
  font-weight: 600;
  font-size: clamp(2.1rem, 5.4vw, 3.5rem);
  line-height: 1.04;
  letter-spacing: -0.015em;
  text-wrap: balance;
  margin: 0 0 18px;
}
h1 em { font-style: italic; color: var(--muted); }

.lede,
.dek {
  max-width: 62ch;
  font-size: clamp(1rem, 1.6vw, 1.16rem);
  color: var(--muted);
  margin: 0;
}
.lede b { color: var(--ink); font-weight: 600; }
.dek { font-style: italic; text-wrap: balance; }

.rule {
  height: 1px;
  background: var(--line);
  border: 0;
  margin: clamp(28px, 4vw, 44px) 0;
}

a {
  color: var(--cyan);
  text-decoration: none;
  border-bottom: 1px solid transparent;
}
a:hover { border-bottom-color: currentColor; }
:focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: 3px;
  border-radius: 3px;
}

.mono { font-family: var(--mono); }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}

@media print {
  @page {
    margin: 14mm 12mm;
  }

  html,
  :root,
  :root[data-theme="dark"],
  :root[data-theme="light"] {
    background: #fff !important;
    color-scheme: light;
    --ground: #fff;
    --panel: #fff;
    --panel-2: #f4f4f4;
    --ink: #111;
    --muted: #333;
    --faint: #555;
    --line: rgba(0, 0, 0, 0.2);
    --grid: rgba(0, 0, 0, 0.08);
    --cross: rgba(0, 0, 0, 0.18);
    --cyan: #0a5f70;
    --cyan-soft: rgba(10, 95, 112, 0.08);
    --violet: #4a2f8a;
    --violet-soft: rgba(74, 47, 138, 0.08);
    --gold: #7a5614;
    --shadow: none;
  }

  body {
    background: #fff !important;
    color: #111 !important;
  }

  .wrap {
    background: #fff !important;
    color: #111 !important;
    padding: 0 !important;
    max-width: none !important;
  }

  .site-bar,
  .essay-toc,
  .essay-toc-toggle,
  .essay-toc-backdrop,
  .essay-toc-close,
  .back-to-top,
  .booklet-screen-only,
  .map-toolbar,
  .map-sidebar,
  .map-chrome {
    display: none !important;
  }

  .essay-layout {
    display: block !important;
    max-width: none !important;
    padding: 0 !important;
  }

  a {
    color: inherit !important;
    border-bottom: none !important;
    text-decoration: none !important;
  }

  a[href^="http"]::after {
    content: " (" attr(href) ")";
    font-size: 0.75em;
    color: #555;
    word-break: break-all;
  }

  a[href^="/"]::after,
  a[href^="#"]::after {
    content: none;
  }

  section.thinker,
  section.mapsec,
  section.glossary,
  section.synthesis,
  .booklet-chapter,
  .booklet-timeline {
    break-inside: auto;
  }

  .booklet-chapter,
  .booklet-timeline,
  section.mapsec,
  section.glossary,
  section.synthesis {
    break-before: page;
    page-break-before: always;
  }

  .booklet-chapter:first-of-type {
    break-before: auto;
    page-break-before: auto;
  }

  section.thinker {
    break-inside: avoid;
    page-break-inside: avoid;
  }

  section.thinker + section.thinker {
    break-before: auto;
    page-break-before: auto;
  }

  header.masthead {
    break-before: auto;
    page-break-before: auto;
  }

  h1, h2, h3 {
    break-after: avoid;
    page-break-after: avoid;
  }

  .map-scroll,
  .table-scroll {
    overflow: visible !important;
  }

  svg.genealogy,
  .mapsec svg,
  table {
    max-width: 100% !important;
    width: 100% !important;
    height: auto !important;
  }

  table {
    min-width: 0 !important;
    font-size: 0.75rem !important;
  }

  aside.margin {
    border-left: 2px solid #0a5f70 !important;
    background: transparent !important;
  }

  .tier,
  .frame-note,
  .table-scroll {
    box-shadow: none !important;
  }
}
