/* ─────────────────────────────────────────────────────────────
   door.css · the eye door (test build, 2026-11-14)

   Raghava, 14 Nov 2026: the onboarding is boring. It was a settings
   form: a headline, two radio groups, a button. This door is one thing,
   the eye of the mark, shut. You poke it. It opens and looks back, the
   work passes through it, and one sentence writes itself underneath
   whose red words are the switches. Then you go through the eye.

   Lives inside #threshold / .th-sheet, whose paper, frost, skip button
   and old ending (.th-eye) stay as they are in the page's own <style>.
   Everything new is prefixed ed- (eye door). Runs with js/door.js.
   ───────────────────────────────────────────────────────────── */

.ed { align-items: center; text-align: center; gap: clamp(.7rem, 2.2vh, 1.2rem); }
.ed .th-h { font-size: clamp(1.75rem, 3.5vw, 3rem); line-height: 1.04; max-width: none; text-wrap: balance; }
.th-top .ed-sp { flex: 1; }

/* ── the eye ── */
.ed-eyebox { position: relative; display: grid; justify-items: center; }
.ed-eye { all: unset; box-sizing: border-box; position: relative; display: block; cursor: pointer;
  width: min(76vw, 36rem, calc((100svh - 2 * var(--th-in) - 22.5rem) * 1.613)); min-width: 13.5rem; aspect-ratio: 1234 / 765;
  transition: transform .25s var(--ease); -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
.ed-eye:focus-visible { outline: 1.5px solid var(--on-night); outline-offset: 12px; }
.ed-eye > span { position: absolute; inset: 0; display: block; pointer-events: none; }
/* the window: the almond of the mark, the work behind it */
.ed-win { background: #FCFCFA; overflow: hidden; clip-path: inset(50% 0 50% 0); transition: clip-path .5s var(--ease-io);
  -webkit-mask: url(../images/mark/eye-almond.svg) center / 100% 100% no-repeat; mask: url(../images/mark/eye-almond.svg) center / 100% 100% no-repeat; }
.ed-slide { position: absolute; inset: -4%; opacity: 0; transition: opacity .55s var(--ease); will-change: opacity; }
.ed-slide.on { opacity: 1; }
.ed-slide img { display: block; width: 100%; height: 100%; object-fit: cover; }
.ed-eye.restless .ed-slide.on img { animation: edDrift 5s linear both; }
@keyframes edDrift { from { transform: scale(1.02); } to { transform: scale(1.12) translate(-1.5%, -1%); } }
.ed-eye.kid .ed-slide img { object-fit: contain; background: #FCFCFA; animation: none; }
/* the lids and iris of the mark, drawn over the work in red (as on the home stage) */
.ed-eye > .ed-lids { inset: -.5px; background: var(--red); mix-blend-mode: multiply; opacity: 0;
  -webkit-mask: url(../images/mark/eye.svg) center / 100% 100% no-repeat; mask: url(../images/mark/eye.svg) center / 100% 100% no-repeat; }
.ed-shut { background: var(--red);
  -webkit-mask: url(../images/mark/eye-shut.svg) center / 100% 100% no-repeat; mask: url(../images/mark/eye-shut.svg) center / 100% 100% no-repeat; }
.ed-eye.open .ed-win { clip-path: inset(0 0 0 0); }
.ed-eye.open .ed-lids { opacity: 1; }
.ed-eye.open .ed-shut { opacity: 0; }
.ed-eye.open.blink .ed-win { clip-path: inset(50% 0 50% 0); transition: none; }
.ed-eye.open.blink .ed-lids { opacity: 0; }
.ed-eye.open.blink .ed-shut { opacity: 1; }
/* asleep: it breathes. Poked: it flinches. */
.ed-eye:not(.open) { animation: edSleep 3.4s ease-in-out infinite; }
@keyframes edSleep { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.025, .975); } }
.ed-eye.flinch { animation: edFlinch .16s ease-out both; }
@keyframes edFlinch { 50% { transform: scale(.95, .86); } }
/* PG16: the bar */
.ed-eye > .ed-bar { inset: auto; left: 8%; right: 6%; top: 27%; height: 30%; background: #111110; border-radius: 2px;
  transform: rotate(-2deg) scaleX(0); transform-origin: 0 50%; transition: transform .28s var(--ease-io); }
.ed-eye.open.pg .ed-bar { transform: rotate(-2deg) scaleX(1); }
/* 1997: the work arrives in blocks */
.ed-px { position: absolute; inset: 0; width: 100%; height: 100%; display: none; image-rendering: pixelated; image-rendering: crisp-edges; }
#threshold.y97 .ed-px { display: block; }
.ed-px.load { animation: edLoad 1.2s steps(8) both; }
@keyframes edLoad { from { clip-path: inset(0 0 100% 0); } to { clip-path: inset(0 0 0 0); } }

/* ── under the eye: the cue first, then the sentence, in the same place (nothing jumps) ── */
.ed-slot { display: grid; justify-items: center; align-items: start; width: 100%; }
.ed-slot > * { grid-area: 1 / 1; }
.ed-cue { font: 400 clamp(1.5rem, 2.6vw, 2rem)/1 var(--hand); color: var(--red); transform: rotate(-4deg); margin-top: .2rem;
  transition: opacity .25s; animation: edCue 1.6s var(--ease-io) infinite; }
.ed-cue::before { content: "↑"; display: inline-block; margin-right: .35em; font-family: var(--serif); }
@keyframes edCue { 0%, 100% { transform: rotate(-4deg) translateY(0); } 50% { transform: rotate(-4deg) translateY(-5px); } }
.ed.is-awake .ed-cue { opacity: 0; animation: none; pointer-events: none; }

.ed-say { font: italic 400 clamp(1.2rem, 2.1vw, 1.7rem)/1.75 var(--display); color: var(--on-night); max-width: 44rem; min-height: 1.75em; }
.ed-c { display: inline-block; white-space: nowrap; clip-path: inset(-30% 100% -30% 0); }
.ed-c.in { animation: edWrite .5s cubic-bezier(.4,.1,.6,1) forwards; }
@keyframes edWrite { to { clip-path: inset(-30% -6% -30% 0); } }
/* a red word: a switch */
.ed-w { all: unset; box-sizing: border-box; cursor: pointer; display: inline-block; white-space: nowrap;
  font: normal 400 1.2em/1.15 var(--hand); color: var(--red); padding: .06em .2em 0; margin: 0 .02em;
  background: linear-gradient(currentColor, currentColor) 0 100% / 100% 2px no-repeat;
  transition: background-color .15s ease, color .15s ease; -webkit-tap-highlight-color: transparent; -webkit-user-select: none; user-select: none; touch-action: manipulation; }
.ed-w:focus-visible { background-color: var(--red); color: #FCFCFA; }
@media (hover: hover) { .ed-w:hover { background-color: var(--red); color: #FCFCFA; } }
.ed-w.pop { animation: edPop .4s var(--ease-out) both; }
@keyframes edPop { from { transform: translateY(.25em) rotate(-5deg); opacity: .2; } to { transform: none; opacity: 1; } }
.ed-w.nudge { animation: edNudge .5s var(--ease-io) 2; }
@keyframes edNudge { 0%, 100% { transform: none; } 30% { transform: translateY(-4px) rotate(-3deg); } 70% { transform: translateY(1px) rotate(2deg); } }

.ed-hint { font-family: var(--mono); font-size: var(--mono-b); letter-spacing: var(--mono-b-track); text-transform: uppercase; color: var(--on-night-2);
  opacity: 0; transition: opacity .5s; }
.ed-act { display: flex; justify-content: center; opacity: 0; visibility: hidden; transform: translateY(8px);
  transition: opacity .5s var(--ease-out), transform .5s var(--ease-out), visibility 0s .5s; }
.ed.is-awake .ed-act { opacity: 1; visibility: visible; transform: none; transition-delay: 0s; }
.ed.is-said .ed-hint { opacity: 1; }
.ed:not(.is-awake) .ed-say { visibility: hidden; }

/* ── going through ── */
.ed-keep { position: absolute; left: 0; right: 0; top: calc(100% + .9rem); font-family: var(--display); font-style: italic; font-size: 1.3rem; color: rgba(17,17,16,.7);
  opacity: 0; transition: opacity .3s; pointer-events: none; }
#threshold.ed-going .ed > :not(.ed-eyebox), #threshold.ed-going .th-top { opacity: 0; pointer-events: none; transition: opacity .25s; }
#threshold.ed-going .ed-keep { opacity: 1; }
#threshold.ed-going.through .ed-keep { opacity: 0; }
.ed-fly { position: fixed; z-index: 5; margin: 0; pointer-events: none; }
.ed-fly .ed-eye { width: 100%; min-width: 0; animation: none; transform-origin: 57.4% 39.2%;
  transition: transform 1.1s var(--ease-io), opacity .9s var(--ease-io); }
.ed-fly.go .ed-eye { transform: scale(26); opacity: 0; }
#threshold.ed-flying .ed-eyebox .ed-eye { visibility: hidden; }

/* ── 1997, for as long as the word says so: 2026 content, 1997 manners ── */
#threshold.y97 .th-sheet { background: #c3c3c3; }
#threshold.y97 .th-h, #threshold.y97 .ed-say { font-family: Times, "Times New Roman", serif; font-style: normal; letter-spacing: 0; }
#threshold.y97 .th-h { font-weight: 700; }
#threshold.y97 .ed-w { font: inherit; color: #0000ee; background: none; text-decoration: underline; padding: 0 .1em; }
#threshold.y97 .ed-w:hover, #threshold.y97 .ed-w:focus-visible { background: none; color: #0000ee; }
#threshold.y97 .ed-slide img { animation: none; }

@media (max-width: 640px) {
  .ed { gap: .8rem; }
  .ed .th-h { font-size: clamp(1.7rem, 7.6vw, 2.1rem); }
  .ed-eye { width: min(82vw, calc((100svh - 2 * var(--th-in) - 27rem) * 1.613)); min-width: 12rem; }
  .ed-say { font-size: 1.22rem; line-height: 2; min-height: 4em; }
  .ed-w { padding: .22em .28em .12em; }
  .ed-act .th-go { width: 100%; justify-content: center; }
  .ed-act { width: 100%; }
}
@media (max-height: 700px) and (min-width: 641px) { .ed .th-h { font-size: clamp(1.5rem, 2.8vw, 2.2rem); } .ed { gap: .6rem; } }

@media (prefers-reduced-motion: reduce) {
  .ed-eye, .ed-eye:not(.open), .ed-cue, .ed-px.load, .ed-w.pop, .ed-w.nudge, .ed-eye.restless .ed-slide.on img { animation: none; }
  .ed-cue { transform: rotate(-4deg); }
  .ed-win { transition: none; }
  .ed-c, .ed-c.in { clip-path: none; animation: none; }
  .ed-fly .ed-eye { transition: opacity .3s linear; }
  .ed-fly.go .ed-eye { transform: none; }
}
