@font-face {
  font-family: 'Cormorant Garamond';
  src: url('assets/cormorant-garamond.woff2') format('woff2');
  font-weight: 300 700;
  font-display: swap;
}

/* The world's palette arrives as rgb triplets (set from script on every world
   change), so glass, pearls and accents take its colours. */
:root {
  color-scheme: dark;
  --tint-rgb: 6, 11, 28;
  --mid-rgb: 36, 64, 125;
  --accent-rgb: 173, 107, 84;
  --light-rgb: 250, 204, 143;
  --bg: #070b12;
  --ink: #efeae0;
  --muted: #b3b9b8;
  --serif: 'Cormorant Garamond', Georgia, serif;
  --sans: system-ui, -apple-system, 'Segoe UI', sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--ink); }
body { font: 15px/1.6 var(--sans); -webkit-font-smoothing: antialiased; overflow: hidden; }
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 1px solid rgba(var(--light-rgb), 0.8); outline-offset: 4px; border-radius: 6px; }

/* The world fills the screen; the menu floats over it. */
.scene { position: fixed; inset: 0; overflow: hidden; background: #04070c url('assets/cosmic-still.jpg') center / cover; touch-action: manipulation; }
#sky { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.fallback { position: absolute; inset: 35% 15%; text-align: center; color: var(--muted); }

.glass {
  position: fixed; z-index: 2; left: clamp(16px, 5vw, 72px); top: 50%; transform: translateY(-50%);
  width: min(400px, calc(100vw - 32px)); height: min(600px, calc(100svh - 48px));
  display: flex; flex-direction: column;
  padding: 26px 30px 22px; border-radius: 24px;
  background: linear-gradient(165deg, rgba(var(--mid-rgb), 0.22), rgba(var(--tint-rgb), 0.58) 70%);
  border: 1px solid rgba(var(--light-rgb), 0.13);
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(var(--light-rgb), 0.08);
  -webkit-backdrop-filter: blur(24px) saturate(1.25); backdrop-filter: blur(24px) saturate(1.25);
  transition: background 2.4s ease, border-color 2.4s ease;
}

.topbar { flex: none; display: flex; align-items: center; justify-content: flex-end; margin-bottom: 18px; }
.body { flex: 1; min-height: 0; overflow: hidden auto; margin: 0 -6px; padding: 0 6px; scrollbar-width: thin; scrollbar-color: rgba(var(--light-rgb), 0.22) transparent; }
/* The logo in the corner of the window: glowing outline in the light colour
   of the world on show. */
.corner-logo { position: fixed; z-index: 3; top: clamp(14px, 3vh, 34px); right: clamp(16px, 3vw, 44px); border: 0; background: none; padding: 0; color: rgba(var(--light-rgb), 0.92); transition: color 2.4s ease, opacity 0.6s; }
.corner-logo .logo { display: block; height: clamp(84px, 15vh, 150px); width: auto; overflow: visible; filter: drop-shadow(0 0 3px rgba(var(--light-rgb), 0.6)) drop-shadow(0 0 12px rgba(var(--light-rgb), 0.25)); }
.corner-logo:hover { color: rgba(var(--light-rgb), 1); }
/* On a journey the logo stays, faint: a tap leaves words in this world. */
body.travelling .corner-logo { opacity: 0.38; }
body.travelling .corner-logo:hover, body.travelling .corner-logo:focus-visible { opacity: 1; }
body.travelling.calm .corner-logo { opacity: 0.12; }
.tools { display: flex; align-items: center; gap: 2px; }
.lang { display: flex; }
.tool { min-width: 34px; min-height: 34px; border: 0; background: none; border-radius: 17px; color: var(--muted); opacity: 0.55; font-size: 13px; letter-spacing: 0.08em; display: grid; place-items: center; }
.tool:hover, .tool[aria-pressed='true'] { opacity: 1; color: var(--ink); }
.tool svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.3; stroke-linecap: round; stroke-linejoin: round; }

/* One view, one step at a time. */
.view, .step { display: none; flex-direction: column; }
body[data-view='start'] .view[data-for='start'], body[data-view='write'] .view[data-for='write'], body[data-view='gift'] .view[data-for='gift'], body[data-view='about'] .view[data-for='about'] { display: flex; animation: arrive 0.9s ease both; }
body[data-step='to'] .step[data-step='to'], body[data-step='words'] .step[data-step='words'], body[data-step='light'] .step[data-step='light'], body[data-step='send'] .step[data-step='send'] { display: flex; animation: arrive 0.9s ease both; }
@keyframes arrive { from { opacity: 0; transform: translateY(6px); } }

/* The pearl: a small, breathing light in the world's colours. */
.pearl {
  display: block; flex: none; width: 58px; height: 58px; border-radius: 50%;
  background: radial-gradient(circle at 34% 30%, #fffdf6 0 5%, rgba(var(--light-rgb), 0.95) 17%, rgba(var(--accent-rgb), 0.9) 46%, rgba(var(--mid-rgb), 0.95) 82%, rgba(var(--tint-rgb), 1));
  box-shadow: 0 0 22px rgba(var(--light-rgb), 0.35), 0 0 70px rgba(var(--accent-rgb), 0.22);
  animation: breathe 7s ease-in-out infinite;
}
.pearl.tiny { width: 14px; height: 14px; margin-top: 7px; box-shadow: 0 0 8px rgba(var(--light-rgb), 0.35); animation-duration: 9s; }
.pearl.small { width: 26px; height: 26px; box-shadow: 0 0 12px rgba(var(--light-rgb), 0.35), 0 0 32px rgba(var(--accent-rgb), 0.2); }
@keyframes breathe { 50% { transform: scale(1.05); box-shadow: 0 0 30px rgba(var(--light-rgb), 0.5), 0 0 90px rgba(var(--accent-rgb), 0.3); } }

/* The quote, then one question and its three ways. */
.quote { margin: 2px 0 24px; }
.quote blockquote { margin: 0; font: italic 300 25px/1.35 var(--serif); color: var(--ink); }
.quote figcaption { margin-top: 10px; font-size: 11.5px; letter-spacing: 0.22em; text-transform: uppercase; color: rgba(var(--light-rgb), 0.6); }
.quote figcaption::before { content: '— '; }
/* Two answers, each a pearl on one silver thread that runs down the glass. */
.thread { position: relative; display: flex; flex-direction: column; gap: 26px; padding: 8px 0 8px 2px; }
.thread::before { content: ''; position: absolute; left: 15px; top: -10px; bottom: -10px; width: 1px; background: linear-gradient(to bottom, transparent, rgba(var(--light-rgb), 0.55) 18%, rgba(var(--light-rgb), 0.55) 82%, transparent); box-shadow: 0 0 6px rgba(var(--light-rgb), 0.4); }
.answer { position: relative; display: flex; gap: 18px; align-items: flex-start; border: 0; background: none; padding: 0; text-align: left; }
.answer .pearl { width: 28px; height: 28px; margin-top: 2px; }
.answer b { display: block; font: 300 23px/1.25 var(--serif); color: var(--ink); transition: color 0.5s; }
.answer small { display: block; margin-top: 4px; font-size: 13px; line-height: 1.45; color: var(--muted); }
.answer:hover .pearl, .answer:focus-visible .pearl { animation-duration: 2.6s; box-shadow: 0 0 18px rgba(var(--light-rgb), 0.6), 0 0 50px rgba(var(--accent-rgb), 0.35); }
.answer:hover b { color: #fff; }

.question { margin: 0 0 18px; font: 300 27px/1.25 var(--serif); letter-spacing: 0.01em; color: var(--ink); }
.whisper { align-self: flex-start; border: 0; background: none; padding: 6px 0; color: var(--muted); font-size: 13.5px; letter-spacing: 0.02em; }
button.whisper:hover, label.whisper:hover { color: var(--ink); }
.whisper.still { padding: 0; margin: 8px 0 0; line-height: 1.55; }
.small-label { margin: 26px 0 4px; font-size: 12px; letter-spacing: 0.16em; text-transform: uppercase; color: rgba(var(--light-rgb), 0.6); }

textarea, .line { width: 100%; border: 0; border-bottom: 1px solid rgba(var(--light-rgb), 0.22); border-radius: 0; background: transparent; padding: 6px 0 10px; outline-offset: 6px; }
textarea { min-height: 170px; resize: none; font: 300 21px/1.6 var(--serif); }
.line { font: 300 21px/1.4 var(--serif); }
textarea:focus, .line:focus { border-bottom-color: rgba(var(--light-rgb), 0.6); outline: none; }
::placeholder { color: rgba(var(--ink-rgb, 239, 234, 224), 0.35); }

.row { display: flex; gap: 16px; align-items: center; margin-top: 10px; }
.upload { position: relative; display: flex; align-items: center; gap: 10px; cursor: pointer; }
.upload input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.upload img { width: 28px; height: 28px; object-fit: cover; border-radius: 50%; }

/* Palettes as pearls. */
.pearls { display: flex; flex-wrap: wrap; gap: 14px; }
.swatch { position: relative; width: 36px; height: 36px; border-radius: 50%; border: 0; padding: 0; background: var(--swatch); box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.12) inset; transition: transform 0.4s; }
.swatch:hover { transform: scale(1.08); }
.swatch[aria-pressed='true'] { box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.12) inset, 0 0 0 2px rgba(var(--tint-rgb), 0.9), 0 0 0 3px rgba(var(--light-rgb), 0.85), 0 0 18px rgba(var(--light-rgb), 0.35); }
.swatch.own { background: conic-gradient(from 200deg, #e28a6a, #e6cf7c, #7fc49b, #6aa6d8, #a689d6, #e28a6a); }
.swatch.own[data-chosen] { background: var(--swatch); }
.swatch input[type='color'] { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; border: 0; padding: 0; }

.words { display: flex; gap: 22px; }
.words button { border: 0; background: none; padding: 6px 0; color: var(--muted); font: 300 19px/1.3 var(--serif); position: relative; }
.words button[aria-pressed='true'] { color: var(--ink); }
.words button[aria-pressed='true']::after { content: ''; position: absolute; left: 50%; bottom: -4px; width: 4px; height: 4px; margin-left: -2px; border-radius: 50%; background: rgba(var(--light-rgb), 0.9); }

.step-nav { flex: none; display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 18px; min-height: 44px; }
.step-nav > :only-child, .step-nav > #cardDrop { margin-left: auto; }
.dots { display: flex; gap: 8px; }
.dots i { width: 5px; height: 5px; border-radius: 50%; background: rgba(var(--light-rgb), 0.22); transition: background 0.6s; }
.dots i.on { background: rgba(var(--light-rgb), 0.9); }
.status { margin: 6px 0 0; min-height: 0; }
.status:empty { display: none; }
.pearl-button { display: inline-flex; align-items: center; gap: 14px; border: 0; background: none; padding: 4px 0; color: var(--ink); text-decoration: none; font: 300 21px/1.2 var(--serif); }
.pearl-button:disabled { opacity: 0.3; cursor: default; }
.pearl-button:disabled .pearl { animation: none; }
.actions { display: flex; flex-direction: column; gap: 6px; margin-top: 22px; }

.card-thumb { width: 132px; border-radius: 6px; margin: 4px 0 6px; box-shadow: 0 10px 34px rgba(0, 0, 0, 0.4); }

.result { display: flex; flex-direction: column; }

/* The silver thread: a story, what we believe, questions. */
.about section { margin-bottom: 30px; }
.about h2 { margin: 0 0 12px; font-size: 12px; font-weight: 500; letter-spacing: 0.2em; text-transform: uppercase; color: rgba(var(--light-rgb), 0.7); }
.about p { margin: 0 0 12px; font-size: 14px; line-height: 1.65; color: var(--muted); }
.about .tale { font: 300 19px/1.55 var(--serif); color: var(--ink); }
.about details { border-top: 1px solid rgba(var(--light-rgb), 0.12); }
.about details:last-child { border-bottom: 1px solid rgba(var(--light-rgb), 0.12); }
.about summary { cursor: pointer; padding: 11px 0; font: 300 18px/1.35 var(--serif); color: var(--ink); list-style: none; }
.about summary::-webkit-details-marker { display: none; }
.about summary::after { content: '+'; float: right; color: rgba(var(--light-rgb), 0.6); }
.about details[open] summary::after { content: '−'; }
.about details p { margin-top: -2px; }
.gift-title { margin: 2px 0 14px; font-size: 32px; }
#cardDrop.drag { color: var(--ink); }

/* Journey: the menu goes, the world stays. */
.journey { display: none; }
body.travelling .glass { display: none; }
body.travelling .scene { cursor: crosshair; }
body.travelling .journey { display: block; position: absolute; inset: 0; pointer-events: none; }
body.travelling.calm .scene { cursor: none; }

.message { position: absolute; right: clamp(24px, 6vw, 120px); top: 16vh; width: min(30vw, 380px); display: flex; flex-direction: column; gap: 18px; }
.message-title { margin: 0; font: 400 16px/1.4 var(--sans); letter-spacing: 0.14em; text-transform: uppercase; color: rgba(var(--light-rgb), 0.7); min-height: 22px; }
.message-text { max-height: 54vh; overflow: hidden; white-space: pre-wrap; overflow-wrap: anywhere; font: 300 clamp(21px, 1.8vw, 29px)/1.7 var(--serif); letter-spacing: 0.03em; color: #ebe6d8e0; text-shadow: 0 1px 10px #000d, 0 0 18px #0009; mask-image: linear-gradient(to bottom, transparent, #000 28px, #000); }
.slot { opacity: 0; transition: opacity 1.6s ease, text-shadow 3s ease; }
.slot.landed { opacity: 1; }
.message-picture { max-width: 100%; max-height: 22vh; object-fit: contain; opacity: 0.75; border-radius: 4px; }
.wisps { position: absolute; inset: 0; overflow: hidden; }
.wisp { position: absolute; width: 22px; height: 22px; border-radius: 50%; background: radial-gradient(circle, #fff7e0 0 8%, #f2e2b8aa 22%, #d6e1f033 55%, transparent 70%); mix-blend-mode: screen; }
.wisp.strong { width: 46px; height: 46px; }
.flyer { position: absolute; left: 0; top: 0; transform-origin: 0 0; white-space: pre; font: 300 clamp(21px, 1.8vw, 29px)/1.7 var(--serif); letter-spacing: 0.03em; color: #f4f0e6; text-shadow: 0 0 14px #c6dfea88, 0 1px 10px #000c; }
.countdown { position: absolute; left: 50%; bottom: 9vh; transform: translateX(-50%); margin: 0; font: 400 clamp(17px, 1.4vw, 23px)/1.5 var(--serif); color: #f1e3c8d0; text-shadow: 0 2px 20px #000; text-align: center; transition: opacity 1.2s; }
.countdown:empty { opacity: 0; }

.journey-controls { position: absolute; left: 16px; bottom: 16px; display: flex; gap: 8px; pointer-events: auto; opacity: 0.35; transition: opacity 0.6s; }
.journey-controls:hover, .journey-controls:focus-within { opacity: 1; }
body.calm .journey-controls { opacity: 0; }
.journey-controls button { width: 44px; height: 44px; border-radius: 50%; border: 1px solid #ffffff22; background: #080e18aa; display: grid; place-items: center; }
.journey-controls svg { width: 20px; height: 20px; fill: none; stroke: #d4dbd2; stroke-width: 1.4; stroke-linecap: round; stroke-linejoin: round; }
.journey-controls button[aria-pressed='false'] svg { opacity: 0.4; }

.intro { position: absolute; inset: 0; background: #020509; z-index: 5; }
.intro video { width: 100%; height: 100%; object-fit: cover; }

.notice { position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%); margin: 0; max-width: min(560px, 90vw); padding: 12px 18px; border: 1px solid rgba(var(--light-rgb), 0.15); border-radius: 14px; background: rgba(var(--tint-rgb), 0.85); -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px); font-size: 14px; opacity: 0; pointer-events: none; transition: opacity 0.5s; z-index: 20; }
.notice.show { opacity: 1; }

/* Phones: the glass rests at the bottom, the world above it. */
@media (max-width: 820px) {
  .glass { left: 10px; right: 10px; top: auto; bottom: max(10px, env(safe-area-inset-bottom)); transform: none; width: auto; height: min(560px, 68svh); padding: 20px 22px 16px; border-radius: 22px; }
  .topbar { margin-bottom: 14px; }
  .corner-logo .logo { height: 74px; }
  .quote { margin-bottom: 20px; }
  .quote blockquote { font-size: 22px; }
  .question { font-size: 24px; margin-bottom: 12px; }
  textarea { min-height: 120px; }
  .message { left: 20px; right: 20px; top: auto; bottom: 12vh; width: auto; }
  .message-text { max-height: 36vh; font-size: 21px; }
  .flyer { font-size: 21px; }
}

@media (prefers-reduced-motion: reduce) {
  .slot, .countdown, .notice, .glass { transition: none; }
  .pearl, .step { animation: none !important; }
}
