/* Omnia — an atlas of everything. Porcelain paper, indigo ink, one star-yellow wink. */

@font-face {
  font-family: "Bodoni Moda";
  src: url("/assets/fonts/bodoni-moda-latin-wght-normal.woff2") format("woff2");
  font-weight: 400 900;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Bodoni Moda";
  src: url("/assets/fonts/bodoni-moda-latin-wght-italic.woff2") format("woff2");
  font-weight: 400 900;
  font-style: italic;
  font-display: swap;
}
@font-face {
  font-family: "Bricolage Grotesque";
  src: url("/assets/fonts/bricolage-grotesque-latin-wght-normal.woff2") format("woff2");
  font-weight: 200 800;
  font-style: normal;
  font-display: swap;
}

:root {
  --paper: #F3F4FA;
  --paper-raised: #FFFFFF;
  --ink: #1B2140;
  --ink-soft: #4A5175;
  --cobalt: #2F3EBF;
  --cobalt-ink: #FFFFFF;
  --star: #F2C14E;
  --mist: #C9CCE0;
  --mist-soft: #E3E5F1;
  --ok: #2E7D5B;
  --warn: #A3461F;

  --display: "Bodoni Moda", "Didot", "Bodoni 72", Georgia, serif;
  --text: "Bricolage Grotesque", system-ui, -apple-system, "Segoe UI", sans-serif;

  --step--1: 0.875rem;
  --step-0: 1.0625rem;
  --step-1: 1.3rem;
  --step-2: 1.65rem;
  --step-3: 2.2rem;
  --step-4: clamp(2.4rem, 5vw, 3.6rem);
  --step-5: clamp(2.8rem, 8.5vw, 6.4rem);

  --gutter: 16px;
  --measure: 68ch;
  --radius-pill: 999px;
  --radius-soft: 14px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #12162B;
    --paper-raised: #1A1F3A;
    --ink: #E7E9F6;
    --ink-soft: #A9AECB;
    --cobalt: #8C98FF;
    --cobalt-ink: #12162B;
    --star: #F2C14E;
    --mist: #353B61;
    --mist-soft: #232846;
    --ok: #6FD3A4;
    --warn: #FFA37A;
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--text);
  font-size: var(--step-0);
  line-height: 1.55;
  font-variation-settings: "wdth" 100;
}
img, video, iframe { max-width: 100%; }
a { color: var(--cobalt); text-underline-offset: 0.18em; text-decoration-thickness: 1px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 3px solid var(--star); outline-offset: 2px; border-radius: 4px; }
select:not(:disabled) { cursor: pointer; }
button:not(:disabled) { cursor: pointer; }
button:disabled { cursor: default; opacity: 0.55; }
.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

/* ---------- Masthead ---------- */
.masthead {
  display: flex; align-items: center; gap: 1rem;
  padding: 14px var(--gutter);
  max-width: 1200px; margin: 0 auto;
}
.brand { display: inline-flex; align-items: center; gap: 0.5rem; color: var(--ink); text-decoration: none; }
.brand-mark { width: 34px; height: 34px; }
.brand-planet { fill: var(--ink); }
.brand-ring { fill: none; stroke: var(--ink); stroke-width: 1.6; }
.brand-star { fill: var(--star); }
.brand-name { font-family: var(--display); font-style: italic; font-size: 1.6rem; font-weight: 600; letter-spacing: 0.01em; }
.masthead-search { flex: 1; display: flex; justify-content: center; min-width: 0; }
.lang-switch { color: var(--ink-soft); text-decoration: none; font-size: var(--step--1); white-space: nowrap; }
.lang-switch:hover { color: var(--ink); text-decoration: underline; }

.mini-ask { width: min(420px, 100%); }
.mini-ask input {
  width: 100%; font: inherit; font-size: var(--step--1); color: var(--ink);
  background: var(--paper-raised); border: 1px solid var(--mist); border-radius: var(--radius-pill);
  padding: 0.45rem 1rem;
}

/* ---------- Home ---------- */
.hero {
  position: relative;
  max-width: 1100px; margin: 0 auto;
  padding: clamp(3rem, 10vh, 7rem) var(--gutter) 3rem;
  text-align: center;
  isolation: isolate;
}
.hero-question {
  font-family: var(--display);
  font-weight: 500;
  font-size: var(--step-5);
  line-height: 0.98;
  letter-spacing: -0.015em;
  margin: 0 auto 2rem;
  max-width: 12ch;
  text-wrap: balance;
}
.hero-tagline { color: var(--ink-soft); margin: 1.5rem 0 0; }

/* The one orchestrated motion: concepts drifting on an elliptical orbit around the question. */
.drift { position: absolute; inset: 0; z-index: -1; pointer-events: none; }
.drift span {
  position: absolute; left: 0; top: 0;
  font-family: var(--display); font-style: italic;
  color: var(--ink-soft); white-space: nowrap; will-change: transform;
}
@media (max-width: 720px) { .drift { display: none; } }

.ask { position: relative; max-width: 640px; margin: 0 auto; display: flex; gap: 0.5rem; }
.ask-input {
  flex: 1; min-width: 0;
  font: inherit; font-size: var(--step-1); color: var(--ink);
  background: var(--paper-raised);
  border: 1.5px solid var(--ink);
  border-radius: var(--radius-pill);
  padding: 0.85rem 1.4rem;
}
.ask-input::placeholder { color: var(--ink-soft); opacity: 0.8; }
.ask-submit, .button {
  font: inherit; font-weight: 600;
  background: var(--cobalt); color: var(--cobalt-ink);
  border: 0; border-radius: var(--radius-pill);
  padding: 0.85rem 1.5rem; text-decoration: none; display: inline-block;
}
.ask-submit:hover, .button:hover { filter: brightness(1.08); }
.button-quiet {
  font: inherit; background: transparent; color: var(--ink);
  border: 1px solid var(--mist); border-radius: var(--radius-pill); padding: 0.5rem 1rem;
}
.ask-suggestions {
  position: absolute; z-index: 5; left: 0; right: 0; top: calc(100% + 6px);
  list-style: none; margin: 0; padding: 6px;
  background: var(--paper-raised); border: 1px solid var(--mist); border-radius: var(--radius-soft);
  text-align: left; box-shadow: 0 12px 30px -18px rgba(27, 33, 64, 0.45);
}
.ask-suggestions li { padding: 0.55rem 0.8rem; border-radius: 10px; cursor: pointer; display: flex; justify-content: space-between; gap: 1rem; }
.ask-suggestions li[aria-selected="true"], .ask-suggestions li:hover { background: var(--mist-soft); }
.ask-suggestions .hint { color: var(--ink-soft); font-size: var(--step--1); }
.ask-message { position: absolute; top: calc(100% + 8px); left: 0; right: 0; margin: 0; color: var(--warn); font-size: var(--step--1); }

.shelf { max-width: 1000px; margin: 0 auto; padding: 1.5rem var(--gutter); }
.shelf-title { font-family: var(--display); font-weight: 500; font-size: var(--step-2); margin: 0 0 1rem; }
.shelf-empty { color: var(--ink-soft); margin: 0; }
.constellation { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 0.6rem; }
.constellation a {
  display: inline-flex; align-items: center; gap: 0.5rem;
  padding: 0.5rem 1rem; border-radius: var(--radius-pill);
  border: 1px solid var(--mist); background: var(--paper-raised);
  color: var(--ink); text-decoration: none;
}
.constellation a:hover { border-color: var(--ink); }
.constellation a::before {
  content: ""; width: 7px; height: 7px; border-radius: 50%;
  background: var(--mist); flex: none;
}
.constellation a.is-ready::before { background: var(--star); }

/* ---------- Concept ---------- */
.concept { max-width: 1200px; margin: 0 auto; padding: 1.5rem var(--gutter) 2rem; }
.concept-head { max-width: 900px; margin: 0 0 2rem; }
.concept-title {
  font-family: var(--display); font-weight: 600;
  font-size: var(--step-4); line-height: 1.02; letter-spacing: -0.01em;
  margin: 0.5rem 0 0.75rem; text-wrap: balance;
}
.concept-lede { font-family: var(--display); font-style: italic; font-size: var(--step-1); margin: 0 0 0.75rem; max-width: 50ch; }
.concept-meta { color: var(--ink-soft); font-size: var(--step--1); margin: 0; }

.concept-controls { display: flex; flex-wrap: wrap; gap: 0.75rem 1.5rem; align-items: center; margin-top: 1.25rem; }
.switcher { display: inline-flex; flex-wrap: wrap; gap: 4px; padding: 4px; border-radius: var(--radius-pill); background: var(--mist-soft); border: 0; margin: 0; }
.switcher legend { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.switcher button {
  font: inherit; font-size: var(--step--1); color: var(--ink-soft);
  background: transparent; border: 0; border-radius: var(--radius-pill); padding: 0.35rem 0.9rem;
}
.switcher button[aria-pressed="true"] { background: var(--paper-raised); color: var(--ink); box-shadow: 0 1px 0 var(--mist); font-weight: 600; }
.fav-toggle {
  font: inherit; font-size: 1.4rem; line-height: 1; background: none; border: 0; padding: 0.25rem;
  color: var(--mist);
}
.fav-toggle[aria-pressed="true"] { color: var(--star); }
.sources-link { font-size: var(--step--1); }

.concept-body { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 3rem; align-items: start; }
@media (max-width: 900px) { .concept-body { grid-template-columns: 1fr; gap: 2rem; } }

.prose { max-width: var(--measure); }
.prose h2, .prose h3 { font-family: var(--display); font-weight: 600; line-height: 1.15; }
.prose h2 { font-size: var(--step-2); margin: 2.2rem 0 0.6rem; }
.prose h3 { font-size: var(--step-1); margin: 1.6rem 0 0.4rem; }
.prose p, .prose li { line-height: 1.65; }
.prose sup a { text-decoration: none; font-family: var(--text); font-size: 0.6em; margin-left: 2px; }
.summary-long { font-size: var(--step-1); line-height: 1.55; }
.doc-section.depth-deep h2::after {
  content: "✦"; color: var(--star); font-size: 0.6em; margin-left: 0.4rem; vertical-align: middle;
}

.timeline { list-style: none; padding: 0; margin: 0; border-left: 2px solid var(--mist); }
.timeline li { position: relative; padding: 0 0 1rem 1.25rem; }
.timeline li::before {
  content: ""; position: absolute; left: -6px; top: 0.55em; width: 10px; height: 10px; border-radius: 50%;
  background: var(--paper); border: 2px solid var(--cobalt);
}
.timeline-date { font-family: var(--display); font-weight: 700; margin-right: 0.4rem; }

.related h2 { font-family: var(--display); font-weight: 600; font-size: var(--step-1); margin: 0 0 0.75rem; }
.related ul { list-style: none; margin: 0; padding: 0; }
.related-item { padding: 0.65rem 0; border-top: 1px solid var(--mist); }
.related-item a { font-weight: 600; text-decoration: none; color: var(--ink); display: inline-flex; align-items: center; gap: 0.45rem; }
.related-item a::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--mist); }
.related-item.is-ready a::before { background: var(--star); }
.related-item a:hover { color: var(--cobalt); }
.related-why { display: block; color: var(--ink-soft); font-size: var(--step--1); margin-top: 0.15rem; }

.sources { max-width: var(--measure); margin-top: 3rem; padding-top: 1.5rem; border-top: 1px solid var(--mist); }
.sources h2 { font-family: var(--display); font-weight: 600; font-size: var(--step-1); }
.sources li { margin-bottom: 0.4rem; }
.source-publisher { color: var(--ink-soft); font-size: var(--step--1); margin-left: 0.35rem; }

/* Status cards: researching, failed, refused, not found */
.status-card {
  max-width: 560px; padding: 2rem; border-radius: var(--radius-soft);
  background: var(--paper-raised); border: 1px solid var(--mist);
}
.status-card h2 { font-family: var(--display); font-weight: 600; font-size: var(--step-3); margin: 0 0 0.5rem; }
.status-card p { margin: 0 0 1rem; color: var(--ink-soft); }
.status-researching h2::after { content: ""; display: inline-block; width: 0.3em; }
.researching-orbit { width: 120px; height: 120px; margin: 0 0 1rem; }
.researching-orbit .ring { fill: none; stroke: var(--mist); stroke-width: 1.5; }
.researching-orbit .core { fill: var(--ink); }
.researching-orbit .moon { fill: var(--star); transform-origin: 60px 60px; animation: spin 2.4s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .researching-orbit .moon { animation: none; } }

/* ---------- Modes ---------- */
.mode-enjoy .summary-short { font-family: var(--display); font-size: var(--step-2); line-height: 1.3; font-weight: 500; }
.curiosities { list-style: none; padding: 0; display: grid; gap: 1rem; }
.curiosities li { padding: 1rem 1.25rem; background: var(--paper-raised); border-radius: var(--radius-soft); border-left: 4px solid var(--star); }

.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 1rem; }
.gallery figure { margin: 0; }
.gallery img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: var(--radius-soft); background: var(--mist-soft); display: block; }
.gallery figcaption { font-size: var(--step--1); color: var(--ink-soft); margin-top: 0.35rem; }

.reel { max-width: var(--measure); }
.scene { padding: 2rem; border-radius: var(--radius-soft); background: var(--ink); color: var(--paper); min-height: 280px; display: flex; flex-direction: column; justify-content: flex-end; }
.scene-count { font-size: var(--step--1); opacity: 0.7; margin: 0 0 0.5rem; }
.scene h2 { font-family: var(--display); font-weight: 600; font-size: var(--step-3); margin: 0 0 0.75rem; }
.scene p { font-family: var(--display); font-size: var(--step-1); line-height: 1.5; margin: 0; }
.scene a { color: var(--star); }
.scene img { width: 100%; max-height: 280px; object-fit: cover; border-radius: 10px; margin-bottom: 1rem; }
.reel-nav { display: flex; justify-content: space-between; gap: 1rem; margin-top: 1rem; }

.quiz { max-width: 640px; }
.quiz-count { color: var(--ink-soft); font-size: var(--step--1); margin: 0; }
.quiz-q { font-family: var(--display); font-weight: 600; font-size: var(--step-2); margin: 0.25rem 0 1rem; line-height: 1.2; }
.quiz-options { list-style: none; padding: 0; margin: 0 0 1rem; display: grid; gap: 0.5rem; }
.quiz-options button {
  width: 100%; text-align: left; font: inherit; color: var(--ink);
  background: var(--paper-raised); border: 1.5px solid var(--mist); border-radius: var(--radius-soft); padding: 0.8rem 1rem;
}
.quiz-options button:hover:not(:disabled) { border-color: var(--ink); }
.quiz-options button.is-correct { border-color: var(--ok); background: color-mix(in srgb, var(--ok) 12%, var(--paper-raised)); }
.quiz-options button.is-wrong { border-color: var(--warn); }
.quiz-feedback { min-height: 1.5em; }
.quiz-score { font-family: var(--display); font-size: var(--step-3); }

.notes textarea {
  width: 100%; min-height: 160px; font: inherit; color: var(--ink);
  background: var(--paper-raised); border: 1px solid var(--mist); border-radius: var(--radius-soft); padding: 0.8rem 1rem;
}
.notes .hint { color: var(--ink-soft); font-size: var(--step--1); }

/* ---------- Orbit interface ---------- */
.orbit-stage {
  position: relative; width: min(100%, 760px); aspect-ratio: 1; margin: 0 auto;
}
.orbit-ring {
  position: absolute; inset: 9%; border-radius: 50%;
  border: 1px dashed var(--mist);
}
.orbit-core {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: 42%; aspect-ratio: 1; border-radius: 50%;
  background: var(--ink); color: var(--paper);
  display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center;
  padding: 1.5rem;
}
.orbit-core h2 { font-family: var(--display); font-weight: 600; font-size: clamp(1.2rem, 3.2vw, 2rem); line-height: 1.05; margin: 0 0 0.5rem; }
.orbit-core p { font-size: clamp(0.75rem, 1.6vw, 0.95rem); margin: 0; opacity: 0.85; }
.orbit-node {
  position: absolute; transform: translate(-50%, -50%);
  max-width: 24%; text-align: center;
}
.orbit-node a {
  display: inline-block; padding: 0.4rem 0.8rem; border-radius: var(--radius-pill);
  background: var(--paper-raised); border: 1px solid var(--mist); color: var(--ink);
  text-decoration: none; font-weight: 600; font-size: var(--step--1); line-height: 1.25;
}
.orbit-node a:hover, .orbit-node a:focus-visible { border-color: var(--ink); }
.orbit-node.is-ready a { box-shadow: inset 0 -3px 0 var(--star); }
.orbit-why {
  position: absolute; left: 50%; top: calc(100% + 6px); transform: translateX(-50%);
  width: max-content; max-width: 220px; padding: 0.5rem 0.7rem; border-radius: 10px;
  background: var(--ink); color: var(--paper); font-size: 0.8rem; z-index: 3;
  opacity: 0; pointer-events: none; transition: opacity 120ms;
}
.orbit-node:hover .orbit-why, .orbit-node:focus-within .orbit-why { opacity: 1; }
.orbit-drawer { max-width: var(--measure); margin: 2rem auto 0; }
.orbit-corner { position: absolute; right: 0; bottom: 0; width: 160px; }
@media (max-width: 640px) {
  .orbit-stage { aspect-ratio: auto; display: flex; flex-direction: column; gap: 0.75rem; }
  .orbit-ring, .orbit-corner { display: none; }
  .orbit-core { position: static; transform: none; width: 100%; aspect-ratio: auto; border-radius: var(--radius-soft); }
  .orbit-node { position: static; transform: none; max-width: none; text-align: left; }
  .orbit-why { position: static; opacity: 1; transform: none; background: none; color: var(--ink-soft); padding: 0.2rem 0 0; max-width: none; }
}

/* ---------- Ads ---------- */
.ad-slot { max-width: 1000px; margin: 2rem auto; padding: 0 var(--gutter); }
.concept-side .ad-slot { margin: 2rem 0 0; padding: 0; }
.ad-placeholder {
  display: flex; align-items: center; justify-content: center;
  min-height: 110px; border: 1.5px dashed var(--mist); border-radius: var(--radius-soft);
  color: var(--ink-soft); font-size: var(--step--1);
}
.concept-side .ad-placeholder { min-height: 250px; }

/* ---------- Dialog (quota) ---------- */
.dialog { border: 0; border-radius: var(--radius-soft); padding: 2rem; max-width: min(460px, calc(100vw - 32px)); background: var(--paper-raised); color: var(--ink); }
.dialog::backdrop { background: rgba(18, 22, 43, 0.55); }
.dialog h2 { font-family: var(--display); font-weight: 600; font-size: var(--step-2); margin: 0 0 0.5rem; }
.dialog form { display: grid; gap: 0.6rem; margin: 1.25rem 0; }
.dialog input { font: inherit; padding: 0.7rem 1rem; border: 1px solid var(--mist); border-radius: var(--radius-pill); background: var(--paper); color: var(--ink); }
.dialog .error { color: var(--warn); min-height: 1.3em; margin: 0; font-size: var(--step--1); }
.dialog-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; justify-content: space-between; }

/* ---------- Debug panel ---------- */
.debug-toggle {
  position: fixed; right: 16px; bottom: 16px; z-index: 50;
  font: inherit; font-size: var(--step--1); font-weight: 700;
  background: var(--star); color: #1B2140; border: 0; border-radius: var(--radius-pill); padding: 0.55rem 1rem;
}
.debug-panel {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 49; width: min(560px, 100vw);
  background: var(--paper-raised); border-left: 1px solid var(--mist); overflow-y: auto;
  padding: 1rem 1rem 4rem; font-size: var(--step--1);
  box-shadow: -20px 0 40px -30px rgba(27, 33, 64, 0.5);
}
.debug-panel h2 { font-family: var(--display); margin: 0 0 0.75rem; }
.debug-job { border-top: 1px solid var(--mist); padding: 0.6rem 0; }
.debug-job summary { cursor: pointer; display: flex; flex-wrap: wrap; gap: 0.35rem 0.75rem; }
.debug-job .state { font-weight: 700; }
.debug-job .state-failed { color: var(--warn); }
.debug-job .state-done { color: var(--ok); }
.debug-job pre { white-space: pre-wrap; word-break: break-word; max-height: 360px; overflow: auto; background: var(--mist-soft); padding: 0.6rem; border-radius: 8px; font-size: 0.78rem; }

/* ---------- Footer / 404 ---------- */
.colophon { max-width: 1200px; margin: 3rem auto 0; padding: 1.5rem var(--gutter) 3rem; color: var(--ink-soft); font-size: var(--step--1); border-top: 1px solid var(--mist); }
.lost { max-width: 640px; margin: 0 auto; padding: 6rem var(--gutter); text-align: center; }
.lost-title { font-family: var(--display); font-weight: 600; font-size: var(--step-4); margin: 0 0 1rem; }

/* Orbit takes the whole width of the concept body. */
.concept-body.is-orbit { display: block; }
.masthead .mini-ask { margin: 0; }
