:root {
  --ink: #030406;
  --mist: #dfe8ec;
  --mist-dim: rgba(223, 232, 236, 0.38);
  --serif: "Cormorant Garamond", "Iowan Old Style", Georgia, serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  background: var(--ink);
  color: var(--mist);
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}

body { cursor: default; }
body[data-state="dormant"] { cursor: pointer; }

#mist {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  /* CSS fallback mist when WebGL is unavailable */
  background:
    radial-gradient(60% 50% at 50% 50%, rgba(223, 232, 236, 0.10), transparent 70%),
    var(--ink);
}

#whisper {
  position: fixed;
  left: 0; right: 0;
  bottom: max(9vh, 56px);
  text-align: center;
  font-family: var(--serif);
  font-weight: 300;
  font-size: clamp(15px, 1.6vw, 19px);
  letter-spacing: 0.42em;
  text-indent: 0.42em;
  color: var(--mist-dim);
  opacity: 0;
  filter: blur(0.4px);
  animation: whisper 6s ease-in-out 1.6s infinite;
  pointer-events: none;
  transition: opacity 1.4s ease, filter 1.4s ease;
}
body:not([data-state="dormant"]) #whisper,
body.veil-open #whisper { animation: none; opacity: 0; filter: blur(8px); }

#notice {
  position: fixed;
  left: 16px; right: 16px;
  bottom: max(env(safe-area-inset-bottom), 14px);
  text-align: center;
  font-family: var(--serif);
  font-weight: 300;
  font-size: 13px;
  letter-spacing: 0.18em;
  color: rgba(223, 232, 236, 0.3);
  pointer-events: none;
  transition: opacity 1.4s ease;
}
body:not([data-state="dormant"]) #notice,
body.veil-open #notice { opacity: 0; }

@keyframes whisper {
  0%, 100% { opacity: 0; filter: blur(6px); }
  45%, 60% { opacity: 1; filter: blur(0.4px); }
}

#echo {
  position: fixed;
  left: 16px; right: 16px;
  bottom: max(9vh, 56px);
  text-align: center;
  font-family: var(--serif);
  font-weight: 300;
  font-style: italic;
  font-size: clamp(16px, 2vw, 22px);
  letter-spacing: 0.04em;
  color: var(--mist-dim);
  opacity: 0;
  filter: blur(6px);
  transition: opacity 0.9s ease, filter 0.9s ease;
  pointer-events: none;
  min-height: 1.4em;
}
#echo.on { opacity: 1; filter: blur(0.3px); }

/* The keyboard channel: present for focus and accessibility, invisible to the eye. */
#keys {
  position: fixed;
  left: 50%;
  bottom: 0;
  width: 1px;
  height: 1px;
  opacity: 0;
  border: 0;
  padding: 0;
  pointer-events: none;
  font-size: 16px; /* prevents iOS zoom */
}

/* ---------- currents: words drifting in the mist ---------- */
#currents {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 2;
}
.current {
  position: absolute;
  left: 0; top: 0;
  font-family: var(--serif);
  font-weight: 300;
  font-size: clamp(17px, 1.9vw, 25px);
  text-transform: lowercase;
  white-space: nowrap;
  color: var(--mist);
  background: none;
  border: 0;
  padding: 14px 18px;            /* generous touch target (≥ 44px) */
  min-height: 48px;
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  will-change: transform, opacity, filter;
  text-shadow: 0 0 18px rgba(223, 232, 236, 0.35);
}
#currents.live .current { pointer-events: auto; }
.current:focus-visible {
  outline: 1px solid var(--mist-dim);
  outline-offset: 4px;
  border-radius: 999px;
  opacity: 1 !important;
  pointer-events: auto;
}

/* ---------- the veil: content condensing out of smoke ---------- */
#veil {
  position: fixed;
  inset: 0;
  z-index: 3;
  display: grid;
  align-items: center;
  padding: max(8vh, 40px) 16px;
  overflow-y: auto;
  background: radial-gradient(70% 60% at 38% 50%, rgba(3, 4, 6, 0.72), rgba(3, 4, 6, 0.2) 70%, transparent);
  opacity: 0;
  transition: opacity 0.5s ease;
  user-select: text;
  -webkit-user-select: text;
}
#veil[hidden] { display: none; } /* author display:grid would otherwise override [hidden] */
#veil.open { opacity: 1; }
.veil-inner {
  max-width: 34rem;
  margin-left: clamp(0px, 14vw, 220px);   /* off-center on purpose: the mist keeps the rest */
  font-family: var(--serif);
  font-weight: 300;
}
.veil-inner > * {
  opacity: 0;
  filter: blur(14px);
  transform: translateY(10px);
  letter-spacing: 0.12em;
  transition: opacity 1.1s ease, filter 1.3s ease, transform 1.3s ease, letter-spacing 1.6s ease;
  transition-delay: calc(var(--i, 0) * 0.22s);
}
#veil.open .veil-inner > * { opacity: 1; filter: blur(0); transform: none; letter-spacing: 0.02em; }
.veil-inner h2 {
  font-weight: 300;
  font-size: clamp(30px, 4.4vw, 52px);
  line-height: 1.1;
  margin-bottom: 0.7em;
  outline: none;
}
.veil-inner p {
  font-size: clamp(18px, 1.7vw, 22px);
  line-height: 1.55;
  color: rgba(223, 232, 236, 0.82);
  margin-bottom: 0.65em;
}
.veil-inner p.coda { font-style: italic; color: var(--mist); margin-top: 1em; }
.veil-acts { display: flex; flex-wrap: wrap; gap: 10px 28px; margin-top: 1.8em; align-items: center; }
.veil-acts button {
  font-family: var(--serif);
  font-weight: 300;
  font-size: 19px;
  letter-spacing: 0.24em;
  color: var(--mist);
  background: none;
  border: 0;
  border-bottom: 1px solid rgba(223, 232, 236, 0.35);
  padding: 12px 2px;
  min-height: 44px;
  cursor: pointer;
  transition: border-color 0.2s ease, letter-spacing 0.4s ease;
}
.veil-acts button:hover { border-color: var(--mist); letter-spacing: 0.3em; }
.veil-acts button:focus-visible { outline: 1px solid var(--mist-dim); outline-offset: 6px; }
.veil-acts .back { color: var(--mist-dim); border-bottom-color: transparent; }

@media (max-width: 640px) {
  .veil-inner { margin-left: 0; }
  .current { font-size: 18px; }
}
@media (prefers-reduced-motion: reduce) {
  .veil-inner > * { transition-duration: 0.2s; transition-delay: 0s; transform: none; }
}

.sr-only {
  position: absolute !important;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

.noscript {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  font-family: var(--serif);
  letter-spacing: 0.2em;
  color: var(--mist-dim);
}

@media (prefers-reduced-motion: reduce) {
  #whisper { animation-duration: 12s; }
}
