/* Dreamographer — "the dream atlas" (D53).
   Layout: a night-time atlas. Each dream is a numbered plate (film still + its real prevalence figure); prose sits
   in a single readable column; a live contour field drifts behind the hero like an isoline map of the sleeping mind.
   One committed dark look, taken from the films (Lucid Cinema): teal-black ink, brass linework, amber lamp light. */
:root {
  --ink: #071114;          /* page ground: the films' shadow tone */
  --ink-2: #0d1e27;        /* raised surfaces */
  --line: #24352e;         /* hairlines, plate borders */
  --teal: #5f8f86;         /* secondary text accents, links at rest */
  --paper: #e8e1cc;        /* body text: aged map paper */
  --muted: #a59d86;        /* captions, legends */
  --brass: #c5a86f;        /* the accent: compass brass */
  --amber: #e6a54a;        /* lamp light, used sparingly (play button, focus) */

  --display: "Cormorant Garamond", "Cormorant", "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  --body: "IBM Plex Sans", "Segoe UI", system-ui, -apple-system, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;

  --step--1: .82rem; --step-0: 1.02rem; --step-1: 1.3rem; --step-2: 1.75rem; --step-3: 2.6rem; --step-4: clamp(2.6rem, 7vw, 4.9rem);
  --gutter-l: max(16px, env(safe-area-inset-left, 0px));
  --gutter-r: max(16px, env(safe-area-inset-right, 0px));
  --wrap: 1120px; --prose: 66ch;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { background: var(--ink); -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--ink); color: var(--paper);
  font: 400 var(--step-0)/1.65 var(--body);
  text-rendering: optimizeLegibility; -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; height: auto; display: block; }
a { color: var(--brass); text-decoration-color: color-mix(in srgb, var(--brass) 45%, transparent); text-underline-offset: .18em; }
a:hover { color: var(--paper); text-decoration-color: var(--paper); }
:focus-visible { outline: 2px solid var(--amber); outline-offset: 3px; border-radius: 2px; }
::selection { background: color-mix(in srgb, var(--brass) 40%, transparent); color: var(--paper); }

h1, h2, h3 { font-family: var(--display); font-weight: 500; line-height: 1.08; text-wrap: balance; margin: 0; color: var(--paper); }
h1 { font-size: var(--step-4); letter-spacing: -.01em; }
h2 { font-size: var(--step-3); }
h3 { font-size: var(--step-1); font-family: var(--body); font-weight: 500; line-height: 1.3; }
p { margin: 0; }
em { font-style: italic; }

.wrap { max-width: var(--wrap); margin-inline: auto; padding-left: var(--gutter-l); padding-right: var(--gutter-r); }
.prose { max-width: var(--prose); }
.stack { display: grid; gap: 1.1rem; }
.eyebrow {
  font: 500 var(--step--1)/1.2 var(--mono); letter-spacing: .14em; text-transform: uppercase; color: var(--teal);
}
.legend { font: 400 var(--step--1)/1.5 var(--mono); color: var(--muted); font-variant-numeric: tabular-nums; }

/* ---------- site bar ---------- */
.bar {
  position: sticky; top: env(safe-area-inset-top, 0px); z-index: 10;
  background: color-mix(in srgb, var(--ink) 82%, transparent); backdrop-filter: blur(10px);
  border-bottom: 1px solid color-mix(in srgb, var(--line) 70%, transparent);
}
.bar .wrap { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding-block: .8rem; }
.mark { display: inline-flex; align-items: center; gap: .6rem; text-decoration: none; color: var(--paper); }
.mark svg { width: 28px; height: 28px; flex: none; }
.mark span { font: 600 1.35rem/1 var(--display); letter-spacing: .02em; }
.bar nav { display: flex; flex-wrap: wrap; gap: .3rem 1.2rem; font: 500 var(--step--1)/1 var(--mono); letter-spacing: .1em; text-transform: uppercase; }
.bar nav a { color: var(--muted); text-decoration: none; padding-block: .4rem; }
.bar nav a:hover, .bar nav a[aria-current="page"] { color: var(--brass); }

/* ---------- hero (home) ---------- */
.hero { position: relative; overflow: hidden; border-bottom: 1px solid var(--line); }
.hero canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; opacity: .9; }
.hero::after { /* the lamp: warm light pooling bottom-right, vignette at the edges */
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background:
    radial-gradient(60% 70% at 85% 95%, color-mix(in srgb, var(--amber) 16%, transparent), transparent 70%),
    radial-gradient(120% 90% at 50% 0%, transparent 55%, var(--ink) 100%);
}
.hero .wrap { position: relative; z-index: 1; display: grid; gap: 2.4rem; padding-block: clamp(3.5rem, 9vw, 7rem) clamp(3rem, 7vw, 5.5rem); }
.hero h1 { max-width: 13ch; }
.hero h1 em { color: var(--brass); font-style: italic; }
.hero .lede { font-size: var(--step-1); line-height: 1.55; max-width: 44ch; color: color-mix(in srgb, var(--paper) 88%, var(--muted)); }
.coords { display: flex; flex-wrap: wrap; gap: .4rem 1.6rem; }
.actions { display: flex; flex-wrap: wrap; gap: .8rem; }
.btn {
  display: inline-flex; align-items: center; gap: .55rem; padding: .78rem 1.2rem; border-radius: 999px;
  font: 500 .95rem/1 var(--body); text-decoration: none; border: 1px solid var(--brass); color: var(--ink); background: var(--brass);
  transition: transform .2s ease, background .2s ease, color .2s ease;
}
.btn:hover { background: var(--paper); border-color: var(--paper); color: var(--ink); transform: translateY(-1px); }
.btn.ghost { background: transparent; color: var(--paper); border-color: color-mix(in srgb, var(--paper) 35%, transparent); }
.btn.ghost:hover { border-color: var(--brass); color: var(--brass); background: transparent; }

.emblem { display: none; position: absolute; z-index: 1; right: max(16px, 6vw); top: 50%; width: clamp(200px, 25vw, 330px); height: auto; transform: translateY(-50%); filter: drop-shadow(0 0 40px color-mix(in srgb, var(--amber) 18%, transparent)); }
.compass-needle { transform-box: view-box; }
@media (min-width: 900px) { .emblem { display: block; } }
/* the compass: needle swings and settles once on load */
.compass-needle { transform-origin: 32px 32px; animation: settle 2.6s cubic-bezier(.2,.7,.2,1) .2s both; }
@keyframes settle {
  0% { transform: rotate(-140deg); } 35% { transform: rotate(38deg); } 55% { transform: rotate(-16deg); }
  72% { transform: rotate(7deg); } 86% { transform: rotate(-2.5deg); } 100% { transform: rotate(0deg); }
}

/* ---------- sections ---------- */
.section { padding-block: clamp(3.5rem, 8vw, 6rem); border-bottom: 1px solid var(--line); }
.section-head { display: grid; gap: .8rem; margin-bottom: 2.4rem; max-width: 60ch; }
.section-head p { color: var(--muted); }

/* ---------- the atlas: dream plates ---------- */
.plates { list-style: none; margin: 0; padding: 0; display: grid; gap: 2rem 1.6rem; grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); }
.plate { min-width: 0; }
.plate a { display: grid; gap: .7rem; align-content: start; text-decoration: none; color: var(--paper); height: 100%; }
.plate figure { margin: 0; position: relative; aspect-ratio: 4 / 5; max-width: 100%; overflow: hidden; border-radius: 4px; border: 1px solid var(--line); background: var(--ink-2); }
.plate figure img { width: 100%; height: 100%; object-fit: cover; object-position: 50% 42%; transform: scale(1.02); transition: transform 1.2s cubic-bezier(.2,.7,.2,1), filter .6s ease; filter: saturate(.92); }
.plate figure::after { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, transparent 50%, color-mix(in srgb, var(--ink) 88%, transparent)); }
.plate .num { position: absolute; left: .9rem; bottom: .75rem; z-index: 1; font: 500 2.4rem/1 var(--display); color: var(--paper); font-variant-numeric: lining-nums; }
.plate .num small { display: block; font: 400 .74rem/1.35 var(--mono); letter-spacing: .04em; color: color-mix(in srgb, var(--paper) 78%, var(--muted)); margin-top: .35rem; max-width: 26ch; }
.plate h3 { font: 500 1.45rem/1.15 var(--display); }
.plate p { color: var(--muted); font-size: .92rem; line-height: 1.5; }
.plate a:hover figure img { transform: scale(1.07); filter: saturate(1.05); }
.plate a:hover h3 { color: var(--brass); }

/* ---------- method (a real sequence) ---------- */
.steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 1px; background: var(--line); border: 1px solid var(--line); grid-template-columns: repeat(auto-fit, minmax(min(100%, 230px), 1fr)); counter-reset: step; }
.steps li { background: var(--ink); padding: 1.6rem 1.4rem; display: grid; gap: .6rem; align-content: start; min-width: 0; counter-increment: step; }
.steps li::before { content: counter(step, upper-roman) "."; font: 500 1.9rem/1 var(--display); color: var(--brass); }
.steps h3 { font-size: 1.05rem; }
.steps p { color: var(--muted); font-size: .94rem; line-height: 1.55; }

/* ---------- rules ---------- */
.rules { display: grid; gap: 1.6rem 2rem; grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr)); }
.rule { display: grid; gap: .45rem; padding-top: 1rem; border-top: 1px solid var(--brass); min-width: 0; }
.rule p { color: var(--muted); }

/* ---------- channels ---------- */
.channels { display: flex; flex-wrap: wrap; gap: .8rem; }

/* ---------- dream page ---------- */
.dream-hero { border-bottom: 1px solid var(--line); background:
  radial-gradient(70% 60% at 80% 20%, color-mix(in srgb, var(--teal) 14%, transparent), transparent 70%),
  radial-gradient(50% 50% at 10% 100%, color-mix(in srgb, var(--amber) 9%, transparent), transparent 70%); }
.dream-hero .wrap { display: grid; gap: 2.4rem; padding-block: clamp(2.5rem, 6vw, 4.5rem); align-items: center; grid-template-columns: minmax(0, 1.25fr) minmax(0, .9fr); }
.dream-hero .copy { display: grid; gap: 1.3rem; min-width: 0; }
.dream-hero h1 { font-size: clamp(2.4rem, 6vw, 4.2rem); }
.stat { display: flex; align-items: baseline; gap: .9rem; flex-wrap: wrap; padding-block: .9rem; border-block: 1px solid var(--line); }
.stat b { font: 500 clamp(2.4rem, 6vw, 3.4rem)/1 var(--display); color: var(--brass); font-variant-numeric: lining-nums; }
.stat span { color: var(--muted); font-size: .95rem; max-width: 34ch; }
.answer { font-size: var(--step-1); line-height: 1.55; color: var(--paper); max-width: 52ch; }
.short { margin: 0; justify-self: center; width: min(100%, 340px); display: grid; gap: .6rem; }
.short img { width: 100%; aspect-ratio: 9 / 16; max-width: 100%; object-fit: cover; border-radius: 6px; border: 1px solid var(--line); box-shadow: 0 30px 80px -30px color-mix(in srgb, var(--amber) 22%, transparent); }
.short iframe { width: 100%; aspect-ratio: 9 / 16; max-width: 100%; border: 0; border-radius: 6px; background: var(--ink-2); }
.short figcaption { font: 400 var(--step--1)/1.5 var(--mono); color: var(--muted); }
.yt { position: relative; display: block; width: 100%; padding: 0; border: 0; background: none; cursor: pointer; border-radius: 6px; }
.play { position: absolute; inset: 0; margin: auto; width: 76px; height: 76px; border-radius: 50%; display: grid; place-items: center;
  background: color-mix(in srgb, var(--ink) 55%, transparent); border: 1px solid var(--amber); color: var(--amber); backdrop-filter: blur(4px);
  transition: transform .25s ease, background .25s ease; }
.play svg { width: 26px; height: 26px; margin-left: 4px; }
.yt:hover .play { transform: scale(1.07); background: color-mix(in srgb, var(--amber) 22%, transparent); }

.article { padding-block: clamp(2.5rem, 6vw, 4.5rem); }
.article .wrap { display: grid; gap: 3rem; grid-template-columns: minmax(0, 1fr) 260px; align-items: start; }
.body { display: grid; gap: 2.6rem; min-width: 0; max-width: var(--prose); }
.body section { display: grid; gap: .9rem; }
.body h2 { font-size: var(--step-2); }
.body p { color: color-mix(in srgb, var(--paper) 92%, var(--muted)); }
.aside { position: sticky; top: 5.5rem; display: grid; gap: 1rem; padding: 1.2rem; border: 1px solid var(--line); border-radius: 4px; background: var(--ink-2); min-width: 0; }
.aside p { font-size: .9rem; color: var(--muted); line-height: 1.55; }
.faq { display: grid; gap: .6rem; }
.faq details { border-top: 1px solid var(--line); padding-block: .9rem; }
.faq details:last-child { border-bottom: 1px solid var(--line); }
.faq summary { cursor: pointer; list-style: none; display: flex; justify-content: space-between; gap: 1rem; font-weight: 500; }
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: "+"; color: var(--brass); font: 400 1.3rem/1 var(--mono); transition: transform .2s ease; }
.faq details[open] summary::after { transform: rotate(45deg); }
.faq details p { margin-top: .7rem; color: var(--muted); }
.sources { margin: 0; padding-left: 1.3em; display: grid; gap: .8rem; font: 400 .86rem/1.55 var(--mono); color: var(--muted); }
.sources li { overflow-wrap: anywhere; }
.note { font-size: .9rem; color: var(--muted); padding: 1rem 1.1rem; border-left: 2px solid var(--teal); background: color-mix(in srgb, var(--ink-2) 70%, transparent); }
.next { display: grid; gap: 1rem; }

/* ---------- plain pages (privacy, terms, 404) ---------- */
.plain { padding-block: clamp(2.5rem, 6vw, 4.5rem); }
.plain .wrap { display: grid; gap: 1.3rem; }
.plain h1 { font-size: var(--step-3); }
.plain h2 { font-size: var(--step-2); margin-top: 1.4rem; }
.plain p, .plain li { max-width: var(--prose); color: color-mix(in srgb, var(--paper) 92%, var(--muted)); }
.plain ul { margin: 0; padding-left: 1.2em; display: grid; gap: .5rem; }
.plain code { font: .88em var(--mono); color: var(--brass); }
.tag { color: var(--muted); font-style: italic; }

/* ---------- footer ---------- */
.foot { padding-block: 2.8rem calc(2.8rem + env(safe-area-inset-bottom, 0px)); }
.foot .wrap { display: grid; gap: 1.6rem; grid-template-columns: minmax(0, 1.4fr) repeat(2, minmax(0, 1fr)); }
.foot p, .foot a { font-size: .9rem; }
.foot p { color: var(--muted); max-width: 44ch; }
.foot ul { list-style: none; margin: 0; padding: 0; display: grid; gap: .5rem; }
.foot a { color: var(--paper); text-decoration: none; }
.foot a:hover { color: var(--brass); }
.foot .legal { grid-column: 1 / -1; padding-top: 1.2rem; border-top: 1px solid var(--line); }

/* ---------- arrival: content is visible at rest; this only adds a gentle rise ---------- */
@media (prefers-reduced-motion: no-preference) {
  .rise { animation: rise .9s cubic-bezier(.2,.7,.2,1) both; }
  .rise.d1 { animation-delay: .08s; } .rise.d2 { animation-delay: .18s; } .rise.d3 { animation-delay: .3s; } .rise.d4 { animation-delay: .42s; }
  @keyframes rise { from { transform: translateY(14px); } to { transform: none; } }
}
@media (prefers-reduced-motion: reduce) {
  .compass-needle { animation: none; }
  .plate figure img, .btn, .play { transition: none; }
}

@media (max-width: 860px) {
  .dream-hero .wrap, .article .wrap, .foot .wrap { grid-template-columns: minmax(0, 1fr); }
  .aside { position: static; }
  .short { width: min(100%, 300px); }
}
@media (max-width: 520px) {
  .bar nav { gap: .2rem .9rem; }
  .bar nav a.wide { display: none; }
  .hero .lede { font-size: 1.12rem; }
}
