/* The eye page (Oct 5). Navy stage, the gold eye, ten gold boxes, the small watching eye. No web fonts: nothing on this
   page is drawn as text (the digits are drawn as gold strokes by gate.js). */
:root {
  color-scheme: dark;
  --ground: #040817; --gold: #e3b662; --gold-lit: #f5d293; --ink: #17110a; --dull: #9a4a3c;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --R: clamp(64px, 18vmin, 210px);           /* the flat eye's radius before the 3D stage sizes it */
  --box: clamp(27px, 7.2vw, 58px);
  --gap: clamp(4px, 1.1vw, 13px);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--ground); color: var(--gold);
  -webkit-tap-highlight-color: transparent; -webkit-text-size-adjust: 100%; }
body { font: 16px / 1 system-ui, sans-serif; overscroll-behavior: none; }
.sr { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; border: 0; overflow: hidden;
  clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; margin: 0; cursor: pointer; }
:focus { outline: none; }

/* ---------------------------------------------------------------- the stage */
#stage { position: fixed; inset: 0; touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
  background: radial-gradient(ellipse at 50% 46%, #0b1430 0%, var(--ground) 62%); }
#stage.pointer { cursor: pointer; }
#stage.dragging, #stage.dragging .eye { cursor: grabbing; }
#gl { position: absolute; inset: 0; width: 100%; height: 100%; display: block; opacity: 0; transition: opacity 600ms var(--ease); }
html.three #gl { opacity: 1; }
html.flat #gl { display: none; }

/* The eye: one real button. Flat, it is the picture; with the 3D stage it is the invisible tap area, focus ring and
   screen reader button, moved and sized by eye-stage.js to sit on the drawn eye. */
.eye { position: absolute; left: calc(50% - var(--R) * 0.92); top: calc(50% - var(--R) * 0.92);
  width: calc(var(--R) * 1.84); height: calc(var(--R) * 1.84); border-radius: 50%; touch-action: none; z-index: 2; }
.eye-art { position: absolute; pointer-events: none;
  /* the drawing is 929 x 1170 SVG units, its iris at 471.38, 425.05, and 460 units make one eye radius */
  width: calc(var(--R) * 929 / 460); height: calc(var(--R) * 1170 / 460);
  left: calc(50% - var(--R) * 471.38 / 460); top: calc(50% - var(--R) * 425.05 / 460);
  background: center / 100% 100% no-repeat; transition: opacity 500ms var(--ease); }
html:not(.art) .eye-art { border-radius: 50%; width: calc(var(--R) * 1.5); height: calc(var(--R) * 1.5); left: calc(50% - var(--R) * 0.75); top: calc(50% - var(--R) * 0.75);
  border: 3px solid var(--gold); box-shadow: inset 0 0 0 calc(var(--R) * 0.32) var(--ground), inset 0 0 0 calc(var(--R) * 0.4) var(--gold); }
html.art .eye-art { background-image: var(--eye-art); filter: drop-shadow(0 0 calc(var(--R) * 0.12) rgba(227, 182, 98, 0.45)); }
html.three .eye-art { opacity: 0; }
/* the soft gold ring that pulses around the eye */
.eye::after { content: ''; position: absolute; inset: -14%; border-radius: 50%; pointer-events: none;
  border: 1px solid color-mix(in oklab, var(--gold) 55%, transparent); animation: ring 2.8s ease-out infinite; }
.eye:focus-visible { outline: 2px solid var(--gold-lit); outline-offset: 6px; }
html.opening .eye::after, html.inside .eye::after { animation: none; opacity: 0; }
html.inside .eye { visibility: hidden; }
@keyframes ring { from { transform: scale(0.9); opacity: 0.85; } to { transform: scale(1.22); opacity: 0; } }

/* ---------------------------------------------------------------- the event horizon */
#horizon { position: fixed; inset: 0; width: 100vw; height: 100vh; z-index: 6; pointer-events: none; display: none; }
#horizon.on { display: block; }
#horizon.fade { opacity: 0; transition: opacity 400ms var(--ease); }

/* ---------------------------------------------------------------- inside: the small eye and the ten boxes */
#code { position: fixed; left: 0; right: 0; top: 0; height: 100%; z-index: 7; display: none;
  flex-direction: column; align-items: center; justify-content: center; gap: clamp(22px, 5vh, 54px);
  padding: 16px; touch-action: manipulation; }
#code.on { display: flex; }
#code > * { opacity: 0; transition: opacity 420ms var(--ease), transform 420ms var(--ease); }
#code.show > * { opacity: 1; }

.mini { position: relative; width: clamp(76px, 13vmin, 150px); aspect-ratio: 1; border-radius: 50%; display: block; }
.mini svg { width: 100%; height: 100%; display: block; overflow: visible; }
.mini .mini-plate { fill: var(--ink); }
.mini .lid { fill: var(--gold); stroke: var(--ink); stroke-width: 7; transition: transform 260ms var(--ease); }
.mini::after { content: ''; position: absolute; inset: -12%; border-radius: 50%; pointer-events: none;
  border: 1px solid color-mix(in oklab, var(--gold) 55%, transparent); box-shadow: 0 0 22px rgba(227, 182, 98, 0.18);
  animation: ring 2.8s ease-out infinite; transition: border-color 200ms, box-shadow 200ms; }
.mini:focus-visible { outline: 2px solid var(--gold-lit); outline-offset: 8px; }
#code.narrow .lid-up { transform: translateY(50px); }
#code.narrow .lid-lo { transform: translateY(-50px); }
#code.asleep .lid-up { transform: translateY(70px); }
#code.asleep .lid-lo { transform: translateY(-70px); }
#code.asleep .mini::after { animation: none; opacity: 0.35; }
#code.dim .mini { opacity: 0.42; }
#code.dim .lid-up { transform: translateY(34px); }
#code.dim .mini::after { animation: none; opacity: 0.3; }
#code.wrong .mini::after { border-color: var(--dull); box-shadow: 0 0 30px rgba(154, 74, 60, 0.55); animation: none; opacity: 1; transform: scale(1.06); }

.boxes { position: relative; display: flex; gap: var(--gap); margin: 0; padding: 0; }
.box { position: relative; width: var(--box); height: calc(var(--box) * 1.34); border: 1px solid color-mix(in oklab, var(--gold) 48%, transparent);
  border-radius: 3px; background: rgba(227, 182, 98, 0.035); transition: border-color 160ms, box-shadow 160ms, background 160ms; }
.box:nth-child(3), .box:nth-child(6) { margin-right: calc(var(--gap) * 1.6); }
.box svg { position: absolute; inset: 16% 22%; width: 56%; height: 68%; overflow: visible; }
.box svg path { fill: none; stroke: var(--gold-lit); stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
.box.full { border-color: var(--gold); background: rgba(227, 182, 98, 0.09); box-shadow: 0 0 14px rgba(227, 182, 98, 0.16); }
.boxes:focus-within .box.cur { border-color: var(--gold-lit); box-shadow: 0 0 0 1px var(--gold-lit), 0 0 18px rgba(245, 210, 147, 0.35); }
.boxes:focus-within .box.cur::after { content: ''; position: absolute; left: 30%; right: 30%; bottom: 18%; height: 2px; background: var(--gold-lit);
  animation: caret 1.1s steps(1) infinite; }
@keyframes caret { 50% { opacity: 0; } }
/* the one real field, over the ten boxes: its own text and caret are clear, so only the boxes show */
#pin { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; padding: 0; border: 0; background: transparent;
  color: transparent; caret-color: transparent; font: 16px / 1 system-ui, sans-serif; letter-spacing: 0; text-indent: -9999px;
  outline: none; -webkit-appearance: none; appearance: none; cursor: pointer; }
#pin::selection { background: transparent; color: transparent; }
#code.busy .boxes { opacity: 0.72; }
#code.busy .box { animation: think 1.2s ease-in-out infinite; }
#code.busy .box:nth-child(2n) { animation-delay: 0.3s; }
@keyframes think { 50% { border-color: var(--gold-lit); } }
#code.asleep .boxes, #code.dim .boxes { opacity: 0.4; }
#code.wrong .boxes { animation: shake 440ms cubic-bezier(0.36, 0.07, 0.19, 0.97) both; }
#code.wrong .box { border-color: var(--dull); }
@keyframes shake { 10%, 90% { transform: translateX(-2px); } 20%, 80% { transform: translateX(5px); } 30%, 50%, 70% { transform: translateX(-10px); } 40%, 60% { transform: translateX(10px); } }
#code.sink .boxes { transform: scale(0.15) translateY(-40%); opacity: 0; transition: transform 520ms cubic-bezier(0.55, 0, 0.75, 0.2), opacity 520ms ease-in; }

/* the screen going dark on the way in */
#veil { position: fixed; inset: 0; z-index: 9; background: var(--ground); opacity: 0; pointer-events: none; transition: opacity 600ms ease-in; }
#veil.on { opacity: 1; }

/* Reduced motion: fades only (no fall, no shake, no zoom, no pulses) */
html.rm .eye::after, html.rm .mini::after, html.rm #code.busy .box, html.rm .boxes:focus-within .box.cur::after { animation: none !important; }
html.rm #code.wrong .boxes { animation: none !important; }
html.rm #code.sink .boxes { transform: none; }
html.rm .mini .lid { transition-duration: 1ms; }
@media (prefers-reduced-motion: reduce) {
  .eye::after, .mini::after, #code.busy .box, #code.wrong .boxes, .box.cur::after { animation: none !important; }
}
