:root {
  --ink: rgba(235, 248, 247, 0.92);
  --ink-soft: rgba(235, 248, 247, 0.6);
  --ink-faint: rgba(235, 248, 247, 0.38);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  background: #02080c;
  overflow: hidden;
  font-family: Georgia, "Times New Roman", serif;
  color: var(--ink);
}

#journey-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  cursor: crosshair;
}

#camera-feed {
  position: fixed;
  width: 2px;
  height: 2px;
  opacity: 0;
  pointer-events: none;
}

.veil {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 1.4rem;
  text-align: center;
  /* The page is already water: only the faintest edge vignette — the
     living surface shows through, and pointer events fall through to it.
     Touching the title page ripples the water before "begin" is pressed. */
  background: radial-gradient(
    ellipse at 50% 36%,
    rgba(2, 8, 12, 0) 0%,
    rgba(2, 8, 12, 0.14) 58%,
    rgba(2, 8, 12, 0.55) 100%
  );
  transition: opacity 1.4s ease, visibility 1.4s;
  z-index: 10;
  padding: 24vh 2rem 6vh;
  pointer-events: none;
}

.veil button,
.veil .linklike {
  pointer-events: auto;
}

.veil.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.veil h1 {
  /* One clean line — held to a modest width by size and tracking, not
     by breaking the phrase. */
  font-size: clamp(1.9rem, 4.6vw, 3.1rem);
  font-weight: 200;
  letter-spacing: 0.3em;
  text-indent: 0.3em;
  line-height: 1.2;
  margin: 0 0 0.6rem;
  text-transform: lowercase;
  /* The title breathes on the same 9s clock as the water. */
  animation: title-breath 9s ease-in-out infinite;
  text-shadow: 0 0 26px rgba(160, 220, 230, 0.18);
}

@keyframes title-breath {
  0%, 100% { opacity: 0.78; }
  50% { opacity: 1; }
}

.veil .thesis {
  font-style: italic;
  font-size: clamp(0.8rem, 1.5vw, 0.95rem);
  letter-spacing: 0.2em;
  line-height: 2;
  color: var(--ink-faint);
  opacity: 0.66;
  margin: 0 0 6vh;
}

.veil .micro {
  margin-top: auto;
  font-size: 0.72rem;
  letter-spacing: 0.18em;
  color: var(--ink-faint);
  opacity: 0.5;
  font-style: italic;
}

.veil .linklike {
  appearance: none;
  background: none;
  border: none;
  border-radius: 0;
  padding: 0;
  margin: 0;
  font: inherit;
  letter-spacing: inherit;
  text-indent: 0;
  color: inherit;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 0.35em;
  text-decoration-color: rgba(235, 248, 247, 0.3);
  transition: text-decoration-color 0.5s ease, opacity 0.5s ease;
}

.veil .linklike:hover {
  text-decoration-color: rgba(235, 248, 247, 0.8);
  background: none;
  border: none;
  transform: none;
}

.veil p {
  margin: 0;
  font-style: italic;
  font-size: clamp(0.95rem, 2vw, 1.1rem);
  color: var(--ink-soft);
  letter-spacing: 0.14em;
  max-width: 30em;
  line-height: 1.8;
}

.veil button {
  appearance: none;
  background: transparent;
  border: 1px solid rgba(235, 248, 247, 0.3);
  border-radius: 999px;
  color: var(--ink);
  font-family: inherit;
  font-size: 0.98rem;
  letter-spacing: 0.52em;
  text-indent: 0.52em;
  text-transform: lowercase;
  padding: 0.95em 3.4em;
  cursor: pointer;
  transition: border-color 0.6s ease, background 0.6s ease,
    box-shadow 0.6s ease, transform 0.6s ease;
}

.veil button:hover {
  border-color: rgba(235, 248, 247, 0.65);
  background: rgba(235, 248, 247, 0.05);
  box-shadow: 0 0 24px rgba(140, 220, 225, 0.16);
  transform: translateY(-1px);
}

.veil .quiet {
  border: none;
  color: var(--ink-faint);
  font-size: 0.8rem;
  letter-spacing: 0.22em;
  padding: 0.6em 1em;
}

.veil .quiet:hover {
  background: transparent;
  color: var(--ink-soft);
}

#camera-note {
  min-height: 1.4em;
  font-size: 0.85rem;
  color: var(--ink-faint);
  font-style: italic;
  letter-spacing: 0.12em;
}

#hint {
  position: fixed;
  left: 50%;
  bottom: 18vh;
  transform: translateX(-50%);
  font-style: italic;
  font-size: clamp(1.08rem, 2.4vw, 1.38rem);
  letter-spacing: 0.18em;
  /* Before the world: neutral silver — no cyan exists yet. A heavy dark
     halo keeps it readable over bright camera backgrounds. */
  color: rgba(248, 250, 252, 0.96);
  text-align: center;
  max-width: 80vw;
  opacity: 0;
  transition: opacity 1.1s ease;
  pointer-events: none;
  z-index: 5;
  text-shadow:
    0 0 5px rgba(6, 12, 16, 0.7),
    0 1px 12px rgba(3, 8, 12, 0.9),
    0 0 30px rgba(2, 6, 10, 0.95);
}

/* Inside the world the text turns bioluminescent — floating on a soft
   breath of darkened water (an elliptical scrim that dissolves at its
   edges), so it reads against cyan glass without ever wearing a box. */
body[data-state="world"] #hint {
  /* Pure verse, no panel: each letter carries its own contrast — a
     near-white core wrapped in a tight dark skin, then the glow. */
  color: rgba(247, 255, 253, 0.98);
  text-shadow:
    0 0 1px rgba(0, 8, 10, 0.95),
    0 1px 2px rgba(0, 8, 10, 0.95),
    0 0 4px rgba(0, 9, 12, 0.65),
    0 0 8px rgba(125, 240, 225, 0.75),
    0 0 16px rgba(110, 235, 222, 0.45),
    0 0 32px rgba(90, 220, 210, 0.4);
}

body[data-state="world"] #encounter {
  color: rgba(240, 253, 250, 0.96);
  text-shadow:
    0 0 1px rgba(0, 8, 10, 0.9),
    0 1px 2px rgba(0, 8, 10, 0.9),
    0 0 4px rgba(0, 9, 12, 0.55),
    0 0 10px rgba(120, 235, 220, 0.68),
    0 0 22px rgba(100, 228, 215, 0.35);
}

#hint.visible {
  opacity: 1;
}

#mode-whisper {
  position: fixed;
  left: 50%;
  top: 14vh;
  transform: translateX(-50%);
  font-style: italic;
  font-size: 0.98rem;
  letter-spacing: 0.3em;
  text-transform: lowercase;
  color: var(--ink-faint);
  text-align: center;
  white-space: nowrap;
  opacity: 0;
  transition: opacity 1.1s ease;
  pointer-events: none;
  z-index: 5;
  text-shadow: 0 1px 14px rgba(2, 8, 12, 0.8);
}

#mode-whisper.visible {
  opacity: 0.78;
}

/* Encounter captions: the quietest voice — a slow breath of text naming
   what the body just brushed. */
#encounter {
  position: fixed;
  left: 50%;
  top: 18vh; /* one narration zone: just beneath the mode whisper */
  transform: translateX(-50%);
  font-style: italic;
  font-size: 1.24rem;
  letter-spacing: 0.24em;
  text-transform: lowercase;
  color: rgba(226, 252, 247, 0.96);
  text-align: center;
  white-space: nowrap;
  opacity: 0;
  /* leaving: a slow dissolve */
  transition: opacity 2.6s ease;
  pointer-events: none;
  z-index: 4;
  text-shadow: 0 0 10px rgba(120, 235, 220, 0.5), 0 1px 14px rgba(2, 8, 12, 0.85);
}

#encounter.swap {
  transition: opacity 0.55s ease;
}

#encounter.visible {
  opacity: 0.86;
  /* arriving: while the sound still rings */
  transition: opacity 1.1s ease;
}

/* Game-style keycaps inside hints, in the world's bioluminescent language. */
#hint kbd {
  display: inline-block;
  font-family: ui-monospace, Menlo, monospace;
  font-style: normal;
  font-size: 0.8em;
  line-height: 1;
  padding: 0.24em 0.55em 0.3em;
  margin: 0 0.22em;
  border: 1px solid rgba(140, 240, 228, 0.55);
  border-bottom-width: 2px;
  border-radius: 7px;
  background: rgba(120, 240, 225, 0.1);
  box-shadow:
    0 0 10px rgba(110, 235, 220, 0.28),
    inset 0 0 6px rgba(110, 235, 220, 0.14);
  letter-spacing: 0.08em;
  text-indent: 0;
  vertical-align: 0.05em;
}

body[data-state="world"] #mode-whisper {
  color: rgba(238, 253, 249, 0.95);
  text-shadow:
    0 0 1px rgba(0, 8, 10, 0.92),
    0 1px 2px rgba(0, 8, 10, 0.92),
    0 0 4px rgba(0, 9, 12, 0.55),
    0 0 7px rgba(125, 240, 225, 0.7),
    0 0 16px rgba(100, 228, 215, 0.32);
}

.corner {
  position: fixed;
  z-index: 6;
  appearance: none;
  background: transparent;
  border: none;
  color: var(--ink-faint);
  font-family: inherit;
  font-size: 0.74rem;
  letter-spacing: 0.26em;
  text-transform: lowercase;
  cursor: pointer;
  padding: 0.8em 1em;
  transition: color 0.5s ease, opacity 1.2s ease;
}

.corner:hover {
  color: var(--ink);
}

#sound-toggle {
  right: 1.2rem;
  top: 1rem;
}

#surface-return {
  left: 1.2rem;
  top: 1rem;
  opacity: 0;
  pointer-events: none;
}

#surface-return.visible {
  opacity: 1;
  pointer-events: auto;
}

#debug {
  position: fixed;
  left: 0.8rem;
  bottom: 0.8rem;
  z-index: 9;
  font-family: ui-monospace, Menlo, monospace;
  font-size: 11px;
  line-height: 1.5;
  color: rgba(160, 240, 230, 0.8);
  white-space: pre-wrap;
  display: none;
  pointer-events: none;
}

#debug.visible {
  display: block;
}

body[data-state="crossing"] .corner,
body[data-state="returning"] .corner {
  opacity: 0;
  pointer-events: none;
}


/* The dive demo, two dialects: touch mode shows a pulsing press-ring;
   camera mode shows an open palm easing toward the viewer. It sits just
   above the hint line — a diagram beside the words, never over the
   player's reflected face — in the mirror act's neutral silver. */
#dive-demo {
  position: fixed;
  left: 50%;
  bottom: 27vh;
  width: 64px;
  height: 76px;
  margin-left: -32px;
  opacity: 0;
  pointer-events: none;
  z-index: 4;
  transition: opacity 1.2s ease;
}
#dive-demo.visible {
  opacity: 1;
}
#dive-demo .ring {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 56px;
  height: 56px;
  margin: -28px 0 0 -28px;
  border: 1.5px solid rgba(235, 248, 247, 0.55);
  border-radius: 50%;
  box-shadow: 0 0 18px rgba(220, 240, 245, 0.25),
    inset 0 0 12px rgba(220, 240, 245, 0.14);
  display: none;
}
#dive-demo.visible.touch .ring {
  display: block;
  animation: dive-pulse 2s ease-in-out infinite;
}
@keyframes dive-pulse {
  0%, 100% { transform: scale(0.74); opacity: 0.4; }
  50% { transform: scale(1.06); opacity: 0.85; }
}

/* Privacy promise + the unseen option, lifted right under the begin
   button so they're actually seen — not sunk to the footer. */
.veil .intro-note {
  margin: 1.4rem 0 0;
  font-size: 0.78rem;
  font-style: italic;
  letter-spacing: 0.14em;
  line-height: 2.1;
  color: var(--ink-faint);
  opacity: 0.74;
  max-width: 34em;
}


/* Live grade panel (#tune in the URL) — dev instrument, project dialect. */
#tune-panel {
  position: fixed;
  right: 1rem;
  top: 3.2rem;
  z-index: 30;
  width: 216px;
  padding: 14px 16px 12px;
  background: rgba(4, 13, 19, 0.82);
  border: 1px solid rgba(140, 200, 205, 0.18);
  border-radius: 12px;
  backdrop-filter: blur(6px);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  color: var(--ink-soft);
}
#tune-panel .tune-title {
  font-style: italic;
  letter-spacing: 0.3em;
  color: var(--ink-faint);
  margin-bottom: 10px;
}
#tune-panel label {
  display: block;
  margin: 0 0 10px;
}
#tune-panel label span {
  float: right;
  font-family: ui-monospace, Menlo, monospace;
  font-size: 0.66rem;
  color: var(--ink-faint);
}
#tune-panel input[type="range"] {
  width: 100%;
  margin-top: 4px;
  accent-color: #7fd8cc;
}
#tune-panel input[type="color"] {
  display: block;
  width: 100%;
  height: 26px;
  margin-top: 4px;
  border: 1px solid rgba(140, 200, 205, 0.25);
  border-radius: 6px;
  background: transparent;
  padding: 1px;
}
#tune-panel .tune-copy {
  width: 100%;
  margin-top: 2px;
  background: transparent;
  border: 1px solid rgba(140, 200, 205, 0.3);
  border-radius: 8px;
  color: var(--ink-soft);
  font: inherit;
  padding: 6px 0;
  cursor: pointer;
}
#tune-panel .tune-copy:hover {
  border-color: rgba(140, 200, 205, 0.6);
  color: var(--ink);
}

/* Mobile look pad: four chevrons that turn the head, never the body —
   the touch-screen twin of waving a hand. Shown only in the world act
   on touch devices (main.js gates by tier). */
#look-pad {
  position: fixed;
  right: 14px;
  bottom: 16px;
  z-index: 6;
  display: none;
  grid-template-columns: repeat(3, 46px);
  grid-template-rows: repeat(3, 46px);
  gap: 2px;
  opacity: 0;
  transition: opacity 1.2s ease;
}
body[data-state="world"] #look-pad.enabled {
  display: grid;
  opacity: 0.85;
}
#look-pad button {
  appearance: none;
  background: rgba(6, 16, 22, 0.38);
  border: 1px solid rgba(235, 248, 247, 0.22);
  border-radius: 50%;
  color: rgba(235, 248, 247, 0.78);
  width: 46px;
  height: 46px;
  padding: 10px;
  cursor: pointer;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
}
#look-pad button:active {
  background: rgba(125, 235, 222, 0.16);
  border-color: rgba(150, 235, 222, 0.5);
}
#look-pad svg { width: 100%; height: 100%; display: block; }
#look-pad [data-look="up"] { grid-area: 1 / 2; }
#look-pad [data-look="left"] { grid-area: 2 / 1; }
#look-pad [data-look="right"] { grid-area: 2 / 3; }
#look-pad [data-look="down"] { grid-area: 3 / 2; }

/* The small-screen truth, quiet but legible on the title page. */
#mobile-note {
  margin-top: 0.9rem;
  opacity: 0.85;
  color: var(--ink-soft);
}

/* Drone A/B switch (?drone) — dev instrument, hear the tonal layer change. */
#drone-switch {
  position: fixed;
  left: 50%;
  top: 12px;
  transform: translateX(-50%);
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  background: rgba(4, 13, 19, 0.82);
  border: 1px solid rgba(140, 200, 205, 0.18);
  border-radius: 999px;
  backdrop-filter: blur(6px);
}
#drone-switch .ds-label {
  font-size: 0.7rem;
  letter-spacing: 0.22em;
  color: var(--ink-faint);
  padding: 0 6px;
  font-style: italic;
}
#drone-switch button {
  appearance: none;
  background: transparent;
  border: 1px solid rgba(235, 248, 247, 0.18);
  border-radius: 999px;
  color: var(--ink-soft);
  font: inherit;
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  padding: 5px 12px;
  cursor: pointer;
  transition: all 0.3s ease;
}
#drone-switch button:hover {
  border-color: rgba(150, 235, 222, 0.5);
}
#drone-switch button.on {
  background: rgba(125, 235, 222, 0.16);
  border-color: rgba(150, 235, 222, 0.6);
  color: var(--ink);
}

/* Cinematic opening between begin and the mirror: the title fades to
   black, lines rise and dissolve, then the world resolves in. */
#interstitial {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: #02080c;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 1.6s ease, visibility 1.6s;
}
#interstitial.visible {
  opacity: 1;
  visibility: visible;
}
#interstitial .intro-line {
  margin: 0;
  max-width: 80vw;
  text-align: center;
  font-family: Georgia, "Times New Roman", serif;
  font-style: italic;
  font-size: clamp(1.05rem, 2.4vw, 1.45rem);
  letter-spacing: 0.26em;
  line-height: 1.9;
  color: rgba(235, 248, 247, 0.9);
  opacity: 0;
  transform: translateY(22px);
  transition: opacity 1.6s ease, transform 1.6s ease;
  text-shadow: 0 0 24px rgba(120, 200, 210, 0.18);
}
#interstitial .intro-line.in { opacity: 1; transform: translateY(0); }
#interstitial .intro-line.out { opacity: 0; transform: translateY(-22px); }
