/* neverness.ai — one word, its meaning, a field of light. */

:root {
  --bg: #000;
  --ink: #e6f4f9;
  --dim: #71838c;
  --ipa: #9db1ba;
  --cyan: #5fe0ff;
  --font-word: "Michroma", "Syncopate", "Helvetica Neue", Arial, sans-serif;
  --font-body: "Space Grotesk", "Helvetica Neue", Arial, system-ui, sans-serif;
  --font-mono: "Space Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

html {
  background: var(--bg);
  color: var(--ink);
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  min-height: 100dvh;
  overflow: hidden;
  font-family: var(--font-body);
  position: relative;
  cursor: crosshair;
}

/* Vignette */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background: radial-gradient(ellipse at center, transparent 52%, rgba(0, 0, 0, 0.78) 100%);
}

#field {
  position: fixed;
  inset: 0;
  z-index: 0;
  display: block;
  width: 100%;
  height: 100%;
  background: #000;
  touch-action: none;
}

/* ---------- the entry ---------- */

.entry {
  position: absolute;
  z-index: 2;
  left: 50%;
  top: 57%;
  transform: translateX(-50%);
  width: min(88vw, 1100px);
  padding-top: 1.8rem;
  text-align: center;
}

/* Without JS the headword is plain text and the whole entry is centred. */
.no-js .entry {
  top: 50%;
  transform: translate(-50%, -50%);
}

.word {
  font-family: var(--font-word);
  font-weight: 400;
  font-size: clamp(1.9rem, 9.5vw, 8rem);
  letter-spacing: 0.04em;
  line-height: 1;
  color: #fff;
  text-shadow: 0 0 24px rgba(95, 224, 255, 0.55), 0 0 2px rgba(255, 255, 255, 0.8);
  margin-bottom: 2.6rem;
}

/* With JS the canvas draws the headword; keep it for assistive tech and search. */
.js .word,
.js .sense-text {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.meta {
  position: relative;
  font-family: var(--font-mono);
  font-size: clamp(0.68rem, 1.05vw, 0.86rem);
  letter-spacing: 0.2em;
  color: var(--dim);
  display: flex;
  justify-content: center;
  align-items: baseline;
  gap: 1.8em;
  margin-bottom: 1.35rem;
}

/* thin rule, always just above the meta line (between the word and the entry) */
.meta::before {
  content: "";
  position: absolute;
  left: 50%;
  top: -1.75rem;
  width: 72px;
  height: 1px;
  transform: translateX(-50%);
  background: linear-gradient(90deg, transparent, var(--cyan), transparent);
  opacity: 0.85;
}

.meta .ipa {
  letter-spacing: 0.06em;
  color: var(--ipa);
}

.meta .label {
  color: var(--cyan);
  opacity: 0.8;
}

.sense {
  font-weight: 300;
  font-size: clamp(1.02rem, 2.05vw, 1.58rem);
  line-height: 1.55;
  letter-spacing: 0.015em;
  color: var(--ink);
  max-width: 36ch;
  margin: 0 auto;
  min-height: 2.5em;
}

.sense-fx { white-space: pre-wrap; }

/* Reveal choreography (JS adds .is-visible once the word has formed) */
.js .entry {
  opacity: 0;
  transform: translateX(-50%) translateY(10px);
  transition: opacity 1.4s ease, transform 1.4s ease;
}

.js .entry.is-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ---------- the whisper ---------- */

.tag {
  position: fixed;
  z-index: 2;
  left: 50%;
  bottom: max(1.7rem, calc(env(safe-area-inset-bottom, 0px) + 1.2rem));
  transform: translateX(-50%);
  font-family: var(--font-mono);
  font-size: clamp(0.58rem, 0.95vw, 0.72rem);
  letter-spacing: 0.52em;
  padding-left: 0.52em; /* balance the trailing letter-space so the glyphs centre */
  text-transform: uppercase;
  white-space: nowrap;
  color: rgba(125, 141, 148, 0.62);
}

/* fades in a beat after the entry */
.js .tag {
  opacity: 0;
  transition: opacity 1.8s ease 1.2s;
}

.js .entry.is-visible ~ .tag { opacity: 1; }

/* ---------- overlays ---------- */

.scanlines {
  position: fixed;
  inset: 0;
  z-index: 3;
  pointer-events: none;
  background: repeating-linear-gradient(
    0deg,
    rgba(255, 255, 255, 0.028) 0 1px,
    transparent 1px 3px
  );
}

.grain {
  position: fixed;
  inset: -50%;
  z-index: 3;
  pointer-events: none;
  opacity: 0.055;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='240' height='240'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 1 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
  background-size: 240px 240px;
  animation: grain 0.9s steps(3) infinite;
}

@keyframes grain {
  0%   { transform: translate(0, 0); }
  33%  { transform: translate(-3%, 2%); }
  66%  { transform: translate(2%, -3%); }
  100% { transform: translate(0, 0); }
}

/* ---------- motion preferences ---------- */

@media (prefers-reduced-motion: reduce) {
  .grain { animation: none; }
  .js .entry {
    opacity: 1;
    transform: translateX(-50%);
    transition: none;
  }
  .js .tag { opacity: 1; transition: none; }
}

/* Short landscape viewports: tighten vertical rhythm */
@media (max-height: 520px) {
  .entry { top: 58%; }
  .tag { bottom: 0.9rem; font-size: 0.55rem; }
  .entry { padding-top: 1rem; }
  .meta::before { top: -1rem; }
  .meta { margin-bottom: 0.7rem; }
  .word { margin-bottom: 1.2rem; }
}
