:root {
  --void: #04060b;
  --ivory: #ece6d8;
  --dust: #8e94a0;
  --gilt: #c8a96b;
  --line: rgba(236, 230, 216, 0.14);
  --glass: rgba(8, 11, 18, 0.78);
  --serif: 'Instrument Serif', 'Times New Roman', serif;
  --sans: 'Manrope', system-ui, sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; min-height: 100%; background: var(--void); color: var(--ivory); font: 15px/1.6 var(--sans); }
body { overflow: hidden; overscroll-behavior: none; }
body.reading { overflow-y: auto; }
html { scrollbar-width: thin; scrollbar-color: rgba(236, 230, 216, 0.18) transparent; }
button, a { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--gilt); outline-offset: 3px; }

#stage, #passthrough { position: fixed; inset: 0; width: 100%; height: 100%; }
#stage { touch-action: none; }
#passthrough { object-fit: cover; }

/* Film grain: one static noise tile, nudged around so it never sits still. */
#grain {
  position: fixed; inset: -50%; z-index: 2; pointer-events: none; opacity: 0.07; mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  animation: grain 0.9s steps(4) infinite;
}
@keyframes grain { 0% { transform: translate(0, 0); } 25% { transform: translate(-3%, 2%); } 50% { transform: translate(2%, -3%); } 75% { transform: translate(-2%, -1%); } }

.label {
  pointer-events: none; white-space: nowrap; font-size: 12px; letter-spacing: 0.02em;
  color: var(--ivory); text-shadow: 0 0 6px var(--void), 0 0 2px var(--void);
}
.label.concept { color: var(--dust); font-size: 11px; }

/* ---------- Beat 1: the curtain ---------- */
#curtain {
  position: fixed; inset: 0; z-index: 10; background: var(--void);
  transition: opacity 1.4s ease, visibility 1.4s;
}
#curtain.gone { opacity: 0; visibility: hidden; }
#c-words {
  position: absolute; left: 50%; top: 42%; transform: translate(-50%, -50%);
  margin: 0; font-size: 14px; white-space: nowrap; color: var(--ivory);
  transition: left 1.8s cubic-bezier(0.65, 0, 0.35, 1), top 1.8s cubic-bezier(0.65, 0, 0.35, 1);
}
#c-rest {
  position: absolute; left: 0; right: 0; top: calc(42% + 40px); text-align: center; padding: 0 16px;
  opacity: 0; transition: opacity 1.6s ease;
}
#curtain.ready #c-rest { opacity: 1; }
#c-line { margin: 0 0 28px; font: 1.5rem/1.3 var(--serif); }
#enter {
  padding: 12px 34px; border-radius: 999px; border: 1px solid rgba(236, 230, 216, 0.4); background: none;
  cursor: pointer; letter-spacing: 0.06em; transition: background 0.3s, color 0.3s, border-color 0.3s;
}
#enter:hover { background: var(--ivory); color: var(--void); border-color: var(--ivory); }
#c-hint { margin: 16px 0 0; font-size: 12px; color: var(--dust); }
#xr-overlay { position: fixed; inset: 0; touch-action: none; } /* takes the two-finger zoom in phone AR */
#xr-exit {
  position: absolute; left: 50%; bottom: max(24px, env(safe-area-inset-bottom)); transform: translateX(-50%); pointer-events: auto;
  padding: 12px 22px; border-radius: 999px; border: 1px solid var(--line); background: var(--glass); cursor: pointer;
}

#nogl { position: absolute; inset: auto 16px 15%; text-align: center; color: var(--dust); }

/* ---------- The wordmark ---------- */
#title {
  position: fixed; top: max(30px, env(safe-area-inset-top)); left: 0; right: 0; z-index: 3;
  text-align: center; padding: 0 16px; pointer-events: none;
}
#title h1 {
  margin: 0 -0.3em 0 0; font: 400 clamp(2.6rem, 9vw, 6.4rem)/0.95 var(--serif); text-transform: uppercase;
  letter-spacing: 0.3em; opacity: 0;
}
#title .sub { margin: 0.55rem 0 0; color: var(--dust); letter-spacing: 0.08em; opacity: 0; }
#line { margin: 1.1rem auto 0; max-width: 32em; font: 1.2rem/1.4 var(--serif); opacity: 0; transition: opacity 1.6s ease; }
body.hit #title h1 { animation: land 2.6s cubic-bezier(0.16, 1, 0.3, 1) forwards; }
body.hit #title .sub { animation: rise 2s 0.8s ease forwards; }
body.hit #line { opacity: 1; transition-delay: 1.6s; }
body.deep #line, body.exploring #line { opacity: 0; transition-delay: 0s; }
#title { transition: opacity 1.2s ease; }
body.deep #title, body.exploring #title, body.inside #title { opacity: 0; }
@keyframes land { from { opacity: 0; letter-spacing: 0.7em; filter: blur(10px); } to { opacity: 1; letter-spacing: 0.3em; filter: blur(0); } }
@keyframes rise { to { opacity: 1; } }

#skip, #mute {
  position: fixed; z-index: 4; bottom: max(20px, env(safe-area-inset-bottom)); padding: 8px 15px; border-radius: 999px;
  background: var(--glass); border: 1px solid var(--line); color: var(--dust); cursor: pointer; font-size: 13px;
}
#skip { right: 16px; }
#mute { right: 16px; }
#skip:hover, #mute:hover { color: var(--ivory); border-color: var(--gilt); }

/* ---------- Act two ---------- */
#story { position: relative; z-index: 3; }
.chapter { min-height: 100vh; display: flex; align-items: center; padding: 18vh 6vw; }
.chapter.hero { align-items: flex-end; justify-content: center; padding-bottom: 6vh; }
.cue { margin: 0; font-size: 13px; color: var(--dust); text-align: center; opacity: 0; transition: opacity 1.4s; }
.cue::after { content: ''; display: block; width: 1px; height: 44px; margin: 12px auto 0; background: linear-gradient(var(--dust), transparent); animation: drip 2.4s ease-in-out infinite; }
body.settled .cue { opacity: 1; }
@keyframes drip { 0%, 100% { transform: scaleY(0.4); transform-origin: top; } 50% { transform: scaleY(1); } }

.card {
  width: min(440px, 100%); padding: 30px 30px 26px; border-radius: 20px;
  background: var(--glass); border: 1px solid var(--line);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
}
.card h2 { margin: 0 0 0.7rem; font: 400 clamp(2rem, 4.4vw, 2.9rem)/1.05 var(--serif); }
.card p { margin: 0; color: #cfc9bc; }
.apps { list-style: none; margin: 1.4rem 0 0; padding: 0; }
.apps li { display: grid; grid-template-columns: 34px 1fr auto; align-items: center; gap: 12px; padding: 9px 0; border-top: 1px solid var(--line); }
.apps .mark { width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center; font-size: 12px; font-weight: 600; overflow: hidden; }
.apps .mark img { width: 100%; height: 100%; object-fit: cover; }
.apps b { display: block; font-weight: 600; font-size: 14px; }
.apps small { color: var(--dust); font-size: 12px; }
.apps a { font-size: 13px; color: var(--gilt); text-decoration: none; }
.apps a:hover { text-decoration: underline; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 1.4rem; }
.actions button, .actions a, #controls button {
  padding: 10px 18px; border-radius: 999px; border: 1px solid var(--line); background: var(--glass);
  cursor: pointer; text-decoration: none; transition: border-color 0.2s, background 0.2s, color 0.2s;
}
.actions .primary { background: var(--ivory); color: var(--void); border-color: var(--ivory); font-weight: 600; }
.actions button:hover, .actions a:hover, #controls button:hover { border-color: var(--gilt); }
.actions .primary:hover { background: #fff; }

#controls { position: fixed; z-index: 4; left: 16px; bottom: max(20px, env(safe-area-inset-bottom)); display: flex; flex-wrap: wrap; gap: 8px; max-width: calc(100% - 32px); }
#controls button[aria-pressed='true'] { border-color: var(--gilt); color: var(--gilt); }

#tip {
  position: fixed; z-index: 6; max-width: 300px; padding: 10px 12px; pointer-events: none;
  background: var(--glass); border: 1px solid var(--line); border-radius: 10px; font-size: 13px; line-height: 1.45;
}
#tip b { display: block; font-weight: 600; margin-bottom: 2px; }
#tip span { color: var(--dust); }

#panel {
  position: fixed; z-index: 5; top: 16px; right: 16px; bottom: 16px; width: min(380px, calc(100% - 32px)); overflow-y: auto;
  padding: 28px 26px; background: var(--glass); border: 1px solid var(--line); border-radius: 18px;
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
}
#p-icon { width: 56px; height: 56px; border-radius: 14px; display: block; margin-bottom: 14px; }
#panel h2 { margin: 0.2rem 0 0.1rem; font: 400 2.6rem/1.05 var(--serif); }
#panel h3 { margin: 1.8rem 0 0.6rem; font-size: 13px; font-weight: 600; color: var(--dust); }
#panel .status { margin: 0; font-size: 13px; color: var(--gilt); }
#panel .tagline { margin: 0 0 1rem; font: 1.2rem/1.35 var(--serif); color: var(--dust); }
#p-close { position: absolute; top: 12px; right: 12px; width: 36px; height: 36px; border: 0; border-radius: 50%; background: none; font-size: 24px; cursor: pointer; color: var(--dust); }
#p-close:hover { color: var(--ivory); }
#p-links { list-style: none; margin: 0; padding: 0; }
#p-links li { padding: 10px 0; border-top: 1px solid var(--line); font-size: 14px; }
#p-links button { background: none; border: 0; padding: 0; cursor: pointer; font-weight: 600; text-decoration: underline; text-decoration-color: var(--line); text-underline-offset: 3px; }
#p-links small { display: block; color: var(--dust); font-size: 12px; }
.visit { display: block; margin-top: 1.6rem; padding: 13px 18px; text-align: center; text-decoration: none; font-weight: 600; border-radius: 999px; background: var(--ivory); color: var(--void); }
.visit:hover { background: #fff; }

@media (max-width: 760px) {
  .chapter { align-items: flex-end; padding: 50vh 12px 10vh; }
  .card { padding: 24px 22px 20px; }
  #panel { top: auto; left: 12px; right: 12px; bottom: 12px; width: auto; max-height: 62vh; padding: 22px 20px; }
  #panel h2 { font-size: 2.1rem; }
}
@media (prefers-reduced-motion: reduce) {
  #grain { animation: none; }
  .cue::after { animation: none; }
  body.hit #title h1, body.hit #title .sub { animation: none; opacity: 1; }
}
