/* I Am Sitting in a Model — the room is dark, the text is the light source. */

:root {
  --room: oklch(11% 0 0);
  --ink-dim: oklch(38% 0 0);
  --ink-mid: oklch(62% 0 0);
  --ink-hi: oklch(96% 0 0);
}

html,
body {
  height: 100%;
}

body.piece {
  margin: 0;
  padding: 0;
  background: var(--room);
  color: var(--ink-mid);
  font-family: var(--font-mono, ui-monospace, "SF Mono", Menlo, Consolas, monospace);
  overflow: hidden;
  height: 100dvh;
  display: grid;
  grid-template-rows: 1fr auto 1fr;
  cursor: default;
}

/* ---------------------------------------------------------- strata ---- */
#strata {
  align-self: end;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
  max-height: 100%; /* never overflow the grid row into the brand line */
  padding: 3.2rem 1rem 2.2rem;
  mask-image: linear-gradient(to bottom, transparent, black 55%);
  -webkit-mask-image: linear-gradient(to bottom, transparent, black 55%);
}

.stratum {
  white-space: nowrap;
  overflow: hidden;
  max-width: 100%;
  font-size: 11px;
  line-height: 1.75;
  letter-spacing: 0.02em;
  color: var(--ink-hi);
  transition: opacity 1.2s ease;
  mask-image: linear-gradient(90deg, transparent, black 6%, black 94%, transparent);
  -webkit-mask-image: linear-gradient(90deg, transparent, black 6%, black 94%, transparent);
}

/* --------------------------------------------------------- sentence ---- */
#stage {
  display: flex;
  justify-content: center;
  padding: 0 1.2rem;
}

#sentence {
  margin: 0;
  max-width: 64ch;
  font-size: clamp(16px, 1.15vw + 10px, 26px);
  line-height: 2.05;
  letter-spacing: 0.01em;
  word-spacing: 0.12em;
}

/* long texts (like the full score) set smaller, leaving air for the strata */
#sentence.long {
  max-width: 72ch;
  font-size: clamp(14px, 0.85vw + 8px, 21px);
  line-height: 1.95;
}

#sentence .w {
  transition: color 0.9s ease, text-shadow 0.9s ease;
  white-space: pre-wrap;
}

#sentence .w.masking {
  color: oklch(50% 0 0);
  animation: mask-shimmer 0.45s steps(2) infinite;
}

@keyframes mask-shimmer {
  50% {
    opacity: 0.55;
  }
}

#sentence .w.fresh {
  animation: fresh 1.4s ease-out;
}

@keyframes fresh {
  0% {
    color: oklch(99% 0 0);
    text-shadow: 0 0 26px oklch(99% 0 0 / 0.85);
  }
}

#sentence .w.settle {
  animation: settle 0.9s ease-out;
}

@keyframes settle {
  0% {
    text-shadow: 0 0 22px oklch(97% 0 0 / 0.7);
  }
}

/* ----------------------------------------------------------- status ---- */
#statusrow {
  align-self: start;
  display: flex;
  justify-content: center;
  align-items: flex-end;
  padding: 2.4rem 1rem 1.6rem;
}

#status {
  font-size: 11px;
  letter-spacing: 0.04em;
  color: oklch(48% 0 0);
  text-align: center;
  max-width: 90ch;
}

#status .sep {
  color: oklch(30% 0 0);
}

#meter {
  position: fixed;
  left: 0;
  bottom: 0;
  height: 1px;
  width: 0%;
  background: oklch(85% 0 0 / 0.55);
  transition: width 1.2s ease;
}

/* ------------------------------------------------------------ brand ---- */
#brand {
  position: fixed;
  top: 0.9rem;
  left: 1.1rem;
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: oklch(45% 0 0);
}

#brand a {
  color: oklch(58% 0 0);
  text-decoration: none;
  transition: color 0.15s ease;
}

#brand a:hover {
  color: var(--ink-hi);
}

body.kiosk #brand,
body.kiosk #status {
  opacity: 0.25;
}

/* ------------------------------------------------------------- veil ---- */
#veil {
  position: fixed;
  inset: 0;
  background: var(--room);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.6rem;
  padding: 1.5rem;
  text-align: center;
  transition: opacity 1.6s ease;
  z-index: 10;
}

#veil.gone {
  opacity: 0;
  pointer-events: none;
}

#veil h1 {
  margin: 0;
  font-size: clamp(19px, 3.4vw, 30px);
  font-weight: 400;
  letter-spacing: 0.34em;
  text-transform: uppercase;
  color: var(--ink-hi);
}

#veil .intro {
  max-width: 52ch;
  font-size: 13px;
  line-height: 1.9;
  color: oklch(60% 0 0);
}

#veil-status {
  font-size: 11px;
  letter-spacing: 0.08em;
  color: oklch(45% 0 0);
  min-height: 1.2em;
}

#veil .row {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  justify-content: center;
}

#enter {
  font-family: inherit;
  font-size: 12px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  background: transparent;
  color: var(--ink-hi);
  border: 1px solid oklch(50% 0 0);
  padding: 0.85em 2.2em;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

#enter:hover:enabled {
  background: var(--ink-hi);
  color: var(--room);
  border-color: var(--ink-hi);
}

#enter:disabled {
  opacity: 0.35;
  cursor: wait;
}

#veil .aboutlink {
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: oklch(55% 0 0);
  text-decoration: none;
  border-bottom: 1px solid oklch(35% 0 0);
  padding-bottom: 2px;
  transition: color 0.15s ease, border-color 0.15s ease;
}

#veil .aboutlink:hover {
  color: var(--ink-hi);
  border-color: var(--ink-hi);
}

/* ---------------------------------------------------------- typebox ---- */
#typebox {
  position: fixed;
  inset: 0;
  background: oklch(11% 0 0 / 0.94);
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.4rem;
  padding: 1.5rem;
  z-index: 20;
}

#typebox.open {
  display: flex;
}

#typeinput {
  width: min(70ch, 92vw);
  background: transparent;
  border: none;
  border-bottom: 1px solid oklch(45% 0 0);
  color: var(--ink-hi);
  font-family: inherit;
  font-size: clamp(15px, 2vw, 22px);
  line-height: 1.8;
  padding: 0.4em 0.2em;
  outline: none;
  resize: none;
  text-align: center;
}

#typenote {
  font-size: 11px;
  letter-spacing: 0.06em;
  color: oklch(48% 0 0);
}

/* --------------------------------------------------------- noscript ---- */
.noscript-note {
  position: fixed;
  inset: 0;
  background: var(--room);
  color: var(--ink-mid);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  text-align: center;
  font-size: 14px;
  line-height: 2;
  z-index: 50;
}

/* ------------------------------------------------- reduced motion ------ */
@media (prefers-reduced-motion: reduce) {
  #sentence .w,
  .stratum,
  #meter,
  #veil {
    transition: none;
  }
  #sentence .w.masking,
  #sentence .w.fresh,
  #sentence .w.settle {
    animation: none;
  }
}

/* ----------------------------------------------------------- mobile ---- */
@media (max-width: 768px) {
  #strata {
    max-height: 26vh;
    padding-bottom: 1.4rem;
  }
  #sentence {
    line-height: 1.95;
  }
}

@media (max-width: 480px) {
  #strata {
    max-height: 20vh;
  }
  #status {
    font-size: 10px;
  }
  #brand {
    font-size: 10px;
    letter-spacing: 0.1em;
  }
}
