/* Retro interactions: pixel pointer, scroll pixel edges, token odometer and hidden terminal. */

/* Old-school pixel pointer, mouse and trackpad only. */
@media (hover: hover) and (pointer: fine) {
  html { cursor: url('/assets/cursors/arrow.svg') 0 0, default; }
  :is(a[href], button, summary, select, label[for], [role="button"], [style*="cursor:pointer"], [style*="cursor: pointer"]):not(:disabled):not([aria-disabled="true"]):not(.portrait-open) {
    cursor: url('/assets/cursors/hand.svg') 5 0, pointer !important;
  }
  :is(input:not([type="button"]):not([type="submit"]):not([type="checkbox"]):not([type="radio"]), textarea, [contenteditable="true"]) { cursor: text; }
}

/* Section edges become a pixel staircase driven by scroll. */
[data-section-transition].pixel-edge { position: relative; background-image: none; -webkit-mask-image: none; mask-image: none; }
[data-section-transition].pixel-edge > canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }

/* Token odometer overlays the real figure only while it rolls. */
[data-token-value].is-rolling { position: relative; -webkit-text-fill-color: transparent; }
.token-odometer { pointer-events: none; }
.token-odometer__col { position: absolute; top: 0; height: var(--step, 1.5em); overflow: hidden; text-align: center; }
.token-odometer__roll { display: block; transition: transform 1300ms cubic-bezier(.33, 1, .68, 1); transition-delay: var(--delay, 0ms); }
.token-odometer__sep { position: absolute; top: 0; white-space: pre; }
.token-odometer__roll i { display: block; height: var(--step, 1.5em); line-height: var(--step, 1.5em); font-style: normal; }

/* Header trigger: the MV BRAND pixel code icon. */
.terminal-trigger { min-height: 44px; min-width: 44px; display: inline-flex; align-items: center; justify-content: center; gap: 10px; margin-left: 6px; padding: 0 6px; border: 0; border-radius: 6px; background: transparent; color: #413D35; font: 400 15px 'Array', ui-monospace, monospace; }
.terminal-trigger img { width: 22px; height: 16px; object-fit: contain; image-rendering: pixelated; flex: none; }
.terminal-trigger:hover { background: #D6D6D9; }
.terminal-trigger:focus-visible { outline: 2px solid #0B3FCF; outline-offset: 4px; }
.terminal-trigger[aria-expanded="true"] { background: #D6D6D9; }
.terminal-trigger__label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; }
/* Below 1000px the header links fold into the Menu, where the trigger shows its label. */
@media (max-width: 1000px) {
  .terminal-trigger { justify-content: flex-start; margin-left: 0; padding: 14px 0; min-height: 48px; }
  .terminal-trigger__label { position: static; width: auto; height: auto; overflow: visible; clip: auto; }
  .terminal-trigger[aria-expanded="true"] { background: transparent; }
}

/* Gigi Intelligence terminal: a dark window (study 29, "B dark"). Opened from the header icon, the floating keycap,
   or with / or > outside a text field. Only the panel is dark; the site stays light.
   Over the ink sections it stays distinct through the lifted panel, the lighter bar and the light 1 px frame. */
.hidden-terminal { position: fixed; right: 16px; top: 72px; z-index: 80; width: min(460px, calc(100vw - 32px)); max-height: calc(100dvh - 96px);
  display: flex; flex-direction: column; overflow: hidden;
  background: #1E1D19; color: #E8E8EA; border: 1px solid #8A8477; border-radius: 6px; box-shadow: 7px 7px 0 #050504;
  font: 400 14px/1.6 'Array', 'Spline Sans Mono', ui-monospace, monospace; letter-spacing: .01em; transform-origin: top right; }
.hidden-terminal[hidden] { display: none; }
.hidden-terminal:focus { outline: none; }
.hidden-terminal kbd { font: inherit; font-size: 11px; letter-spacing: .04em; padding: 0 5px; border: 1px solid #77726A; border-bottom-width: 2px; border-radius: 3px; background: #2A2823; color: #D6D2C8; }
.hidden-terminal button { font: inherit; color: inherit; }
.hidden-terminal__icon { display: inline-block; width: 16px; height: 16px; flex: none; background: currentColor; -webkit-mask: var(--icon) center / contain no-repeat; mask: var(--icon) center / contain no-repeat; }
.hidden-terminal__icon--close { --icon: url('/assets/icons/close.svg'); }
.hidden-terminal__icon--up { --icon: url('/assets/icons/chevron-up.svg'); }

.hidden-terminal__bar { flex: none; display: flex; align-items: center; gap: 12px; min-height: 44px; padding: 0 0 0 14px; background: #33312B; border-bottom: 1px solid #8A8477; box-shadow: 0 1px 0 #5A564D inset; }
.hidden-terminal__title { flex: 1; font-size: 13px; color: #F0F0F2; }
.hidden-terminal .hidden-terminal__close { display: inline-flex; align-items: center; gap: 10px; min-width: 44px; min-height: 44px; padding: 0 14px 0 10px; border: 0; border-left: 1px solid #5A564D; background: transparent; color: #D6D2C8; }
.hidden-terminal .hidden-terminal__close:hover { background: #3E3B34; color: #FFFFFF; }

.hidden-terminal__log { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 14px 16px 6px; overscroll-behavior: contain; }
.hidden-terminal__log p { margin: 0 0 2px; overflow-wrap: anywhere; }
.hidden-terminal__log .is-dim { color: #ABA597; }
.hidden-terminal__log .is-ok { color: #3FD173; }
.hidden-terminal__log .is-ok::before { content: ''; display: inline-block; width: 6px; height: 6px; margin: 0 8px 2px 0; background: #07BE43; }
.hidden-terminal__log .is-warn { color: #E2BC66; }
.hidden-terminal__log .is-echo { color: #9DB3FF; margin-top: 10px; }
.hidden-terminal__list { list-style: none; margin: 6px -8px 8px; padding: 0; border-top: 1px dashed #47443C; }
.hidden-terminal__list li { border-bottom: 1px dashed #47443C; }
.hidden-terminal__list button { width: 100%; min-height: 40px; display: flex; align-items: baseline; justify-content: space-between; gap: 16px; padding: 9px 8px; border: 0; background: transparent; text-align: left; }
.hidden-terminal__cmd { color: #9DB3FF; }
.hidden-terminal__dest { color: #ABA597; font-family: 'Sohne', 'Instrument Sans', sans-serif; font-size: 14px; letter-spacing: -.01em; }
.hidden-terminal__list button:hover { background: #2A2823; }
.hidden-terminal__list button:hover .hidden-terminal__dest { color: #F0F0F2; }

.hidden-terminal__actions { flex: none; display: flex; gap: 8px; padding: 8px 16px 12px; }
.hidden-terminal__actions button { display: inline-flex; align-items: center; gap: 8px; min-height: 40px; padding: 0 12px; border: 1px solid #8A8477; border-radius: 4px; background: #2E2C27; color: #F0F0F2; box-shadow: 2px 2px 0 #050504, 0 1px 0 #4A473F inset; }
.hidden-terminal__actions button:hover { background: #3A3832; }
.hidden-terminal__actions button:active { transform: translate(2px, 2px); box-shadow: none; }

.hidden-terminal__form { flex: none; display: flex; align-items: center; gap: 10px; min-height: 52px; padding: 0 16px; background: #12110E; border-top: 1px solid #8A8477; }
.hidden-terminal__form:focus-within { box-shadow: inset 0 -2px 0 #9DB3FF; }
.hidden-terminal__prompt { color: #9DB3FF; flex: none; }
.hidden-terminal__input { flex: 1; min-width: 0; min-height: 44px; border: 0; padding: 0; background: transparent; color: #F0F0F2; font: inherit; caret-color: #3FD173; outline: none; }
.hidden-terminal__input::placeholder { color: #938D80; }
.hidden-terminal__hint { flex: none; display: flex; align-items: center; gap: 8px; color: #ABA597; font-size: 13px; white-space: nowrap; }

.hidden-terminal button:focus-visible { outline: 2px solid #9DB3FF; outline-offset: -2px; }
.hidden-terminal .sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

.hidden-terminal.is-opening { animation: hidden-terminal-in 180ms cubic-bezier(.23, 1, .32, 1); }
@keyframes hidden-terminal-in { from { opacity: 0; transform: translate(-4px, -6px); box-shadow: 0 0 0 #050504; } }
/* Exit: the entrance reversed, shorter and ease-in. */
.hidden-terminal.is-closing { animation: hidden-terminal-out 120ms cubic-bezier(.55, 0, 1, .45) forwards; pointer-events: none; }
@keyframes hidden-terminal-out { to { opacity: 0; transform: translate(-4px, -6px); box-shadow: 0 0 0 #050504; } }

/* Touch: 44 px targets. iOS Safari zooms the page when a field under 16px is focused. */
@media (pointer: coarse), (max-width: 700px) {
  .hidden-terminal__list button, .hidden-terminal__actions button { min-height: 44px; }
  .hidden-terminal__input { font-size: 16px; }
}
@media (max-width: 700px) {
  .hidden-terminal { left: 8px; right: 12px; width: auto; box-shadow: 4px 4px 0 #050504; }
  .hidden-terminal__log p { font-size: 15px; }
  .hidden-terminal__hint kbd { display: none; }
  /* Phones: a 3 x 3 command grid so all nine commands fit above the keyboard without scrolling. */
  .hidden-terminal__list { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; margin: 8px 0 10px; border: 0; }
  .hidden-terminal__list li { border: 0; }
  .hidden-terminal__list button { min-height: 44px; padding: 4px 8px; border: 1px solid #77726A; border-radius: 4px; background: #2A2823; align-items: center; }
  .hidden-terminal__dest { display: none; }
}
/* No Escape key on touch: hide the esc keycap there. */
@media (pointer: coarse) { .hidden-terminal__close kbd { display: none; } }

@media (prefers-reduced-motion: reduce) {
  .hidden-terminal.is-opening, .hidden-terminal.is-closing { animation: none; }
  .token-odometer__roll { transition: none; }
}

/* Floating trigger: keycap in the bottom-right corner, shown once the header is off screen. It replaces Back to top. */
.terminal-float { position: fixed; right: 16px; bottom: calc(16px + env(safe-area-inset-bottom)); z-index: 70; isolation: isolate; display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; padding: 0; border: 0; background: transparent; animation: home-enter .22s ease-out; }
.terminal-float[hidden] { display: none; }
.terminal-float::before { content: ''; position: absolute; inset: 3px 3px 1px; z-index: -2; background: #C8C8CA; border: 1px solid #89898D; border-radius: 6px; box-shadow: 0 2px 4px #14130F20; }
.terminal-float::after { content: ''; position: absolute; inset: 4px 7px 8px; z-index: -1; background: #EFEFF0; border: 1px solid #B5B5B8; border-radius: 4px; box-shadow: 0 1px 0 #FFFFFF inset; transition: transform .13s ease-out; }
.terminal-float img { width: 18px; height: 13px; image-rendering: pixelated; transform: translateY(-2px); transition: transform .13s ease-out; }
.terminal-float:active img { transform: translateY(1px); }
.terminal-float:active::after { transform: translateY(3px); }
/* Cobalt ring inside a light halo: visible on both the light and the dark sections. */
.terminal-float:focus-visible { outline: 2px solid #0B3FCF; outline-offset: 2px; border-radius: 6px; box-shadow: 0 0 0 6px #EFEFF0; }
.hidden-terminal.is-floating { top: auto; bottom: calc(72px + env(safe-area-inset-bottom)); transform-origin: bottom right; }
.hidden-terminal.is-floating.is-opening { animation-name: hidden-terminal-up; }
@keyframes hidden-terminal-up { from { opacity: 0; transform: translate(-4px, 6px); box-shadow: 0 0 0 #050504; } }
.hidden-terminal.is-floating.is-closing { animation-name: hidden-terminal-down; }
@keyframes hidden-terminal-down { to { opacity: 0; transform: translate(-4px, 6px); box-shadow: 0 0 0 #050504; } }
@media (max-width: 700px) { .terminal-float { right: 11px; bottom: calc(11px + env(safe-area-inset-bottom)); } }
@media (prefers-reduced-motion: reduce) { .terminal-float { animation: none; } .terminal-float::after, .terminal-float img { transition: none; } }

/* ---------- Agent Arcade entry (Gigi section): ink handheld that powers on, crew cheers from behind it, joystick + Play ---------- */
.arcade-entry { margin: clamp(32px, 4vw, 48px) auto 0; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.arcade-entry__link { display: inline-flex; flex-direction: column; align-items: center; color: #14130F; text-decoration: none; font-family: 'Array', 'Spline Sans Mono', ui-monospace, monospace; font-size: 14px; line-height: 1; -webkit-tap-highlight-color: transparent; }
.arcade-entry__link:focus-visible { outline: none; }
.arcade-entry__link:focus-visible .arcade-entry__console { outline: 2px solid #0B3FCF; outline-offset: 4px; clip-path: none; }
/* The crew sits behind the console (z-index 0 vs 1) and rests 30px down, hidden by the console body.
   Its 46px box keeps 20px of headroom so every jump stays inside the link's hit area. */
.arcade-entry__crew { position: relative; z-index: 0; display: flex; justify-content: center; align-items: flex-end; gap: 2px; width: 100%; height: 46px; margin-bottom: -2px; }
.arcade-entry__crew img { display: block; width: 26px; height: 26px; image-rendering: pixelated; transform: translateY(30px); transform-origin: 50% 100%; }
/* Per-agent jump height and offset so the loop never moves in lockstep. */
.arcade-entry__crew img:nth-child(1) { --h: 16px; --j: 0ms; }
.arcade-entry__crew img:nth-child(2) { --h: 12px; --j: 220ms; }
.arcade-entry__crew img:nth-child(3) { --h: 16px; --j: 60ms; }
.arcade-entry__crew img:nth-child(4) { --h: 14px; --j: 300ms; }
.arcade-entry__crew img:nth-child(5) { --h: 16px; --j: 120ms; }
.arcade-entry__crew img:nth-child(6) { --h: 12px; --j: 260ms; }
.arcade-entry__console { display: flex; align-items: center; gap: 9px; padding: 8px 10px 8px 12px; background: #14130F; clip-path: polygon(0 6px, 2px 6px, 2px 2px, 6px 2px, 6px 0, calc(100% - 6px) 0, calc(100% - 6px) 2px, calc(100% - 2px) 2px, calc(100% - 2px) 6px, 100% 6px, 100% calc(100% - 6px), calc(100% - 2px) calc(100% - 6px), calc(100% - 2px) calc(100% - 2px), calc(100% - 6px) calc(100% - 2px), calc(100% - 6px) 100%, 6px 100%, 6px calc(100% - 2px), 2px calc(100% - 2px), 2px calc(100% - 6px), 0 calc(100% - 6px)); position: relative; z-index: 1; transition: transform .05s steps(1); }
.arcade-entry__bezel { display: flex; flex-direction: column; gap: 3px; padding: 4px 4px 3px; background: #2A2924; }
.arcade-entry__led { display: block; width: 4px; height: 4px; margin-left: 1px; background: #33312B; transition: background 0s .3s; }
.arcade-entry__screen { position: relative; display: flex; align-items: center; justify-content: center; height: 38px; padding: 0 10px; overflow: hidden; background: #1E1D19 repeating-linear-gradient(to bottom, rgba(255,255,255,.045) 0, rgba(255,255,255,.045) 1px, transparent 1px, transparent 3px); color: #A9A395; clip-path: polygon(0 2px, 2px 2px, 2px 0, calc(100% - 2px) 0, calc(100% - 2px) 2px, 100% 2px, 100% calc(100% - 2px), calc(100% - 2px) calc(100% - 2px), calc(100% - 2px) 100%, 2px 100%, 2px calc(100% - 2px), 0 calc(100% - 2px)); }
.arcade-entry__screen::after { content: ""; position: absolute; inset: 0; background: #F5F5F6; transform: scale(0, 0); pointer-events: none; }
.arcade-entry__name { white-space: pre; transition: color 0s .3s, text-shadow 0s .3s; }
.arcade-entry__action { display: flex; flex-direction: column; align-items: center; gap: 3px; }
.arcade-entry__stick { display: block; flex: none; }
.arcade-entry__play { font-size: 12px; color: #F5F5F6; }
.arcade-entry__link:is(:hover, :focus-visible, .is-on) .arcade-entry__screen::after { animation: arcade-power .5s steps(10) forwards; }
.arcade-entry__link:is(:hover, :focus-visible, .is-on) .arcade-entry__name { color: #3FD173; text-shadow: 0 0 6px rgba(63, 209, 115, .55); }
.arcade-entry__link:is(:hover, :focus-visible, .is-on) .arcade-entry__led { background: #07BE43; }
.arcade-entry__link:is(:hover, :focus-visible, .is-on) .arcade-entry__name { animation: arcade-type .6s steps(12) .45s both; }
.arcade-entry__link:is(:hover, :focus-visible, .is-on) .arcade-entry__crew img { animation: arcade-cheer 4.8s linear calc(.9s + var(--i) * 130ms + var(--j, 0ms)) infinite both; }
.arcade-entry__link.is-paused .arcade-entry__crew img { animation-play-state: paused; }
@keyframes arcade-type { from { clip-path: inset(0 100% 0 0); } to { clip-path: inset(0 0 0 0); } }
/* One 4.8s cheer: hidden, peek over the edge, pop out, squash, jump with a stretch ("yeah!"),
   land, small second hop, stand, then duck back behind the console. Stepped like sprite frames. */
@keyframes arcade-cheer {
  0%, 10% { transform: translateY(30px); animation-timing-function: steps(2, end); }
  14% { transform: translateY(18px); animation-timing-function: steps(1, end); }
  19% { transform: translateY(18px); animation-timing-function: steps(3, end); }
  23% { transform: translateY(0); animation-timing-function: steps(1, end); }
  25% { transform: translateY(0) scale(1.15, .8); animation-timing-function: steps(4, end); }
  33% { transform: translateY(calc(var(--h, 16px) * -1)) scale(.88, 1.12); animation-timing-function: steps(1, end); }
  37% { transform: translateY(calc(var(--h, 16px) * -1)) scale(.88, 1.12); animation-timing-function: steps(3, end); }
  43% { transform: translateY(0) scale(1); animation-timing-function: steps(1, end); }
  45% { transform: translateY(0) scale(1.18, .78); animation-timing-function: steps(1, end); }
  48% { transform: translateY(0) scale(1); animation-timing-function: steps(2, end); }
  52% { transform: translateY(-6px) scale(.94, 1.06); animation-timing-function: steps(2, end); }
  56% { transform: translateY(0) scale(1); animation-timing-function: steps(1, end); }
  57% { transform: translateY(0) scale(1.1, .88); animation-timing-function: steps(1, end); }
  59% { transform: translateY(0) scale(1); animation-timing-function: steps(1, end); }
  73% { transform: translateY(0) scale(1); animation-timing-function: steps(1, end); }
  75% { transform: translateY(0) scale(1.1, .88); animation-timing-function: steps(5, end); }
  81%, 100% { transform: translateY(30px); }
}
@keyframes arcade-power { 0% { transform: scale(.04, .03); opacity: 1; } 35% { transform: scale(1, .03); opacity: 1; } 65% { transform: scale(1, 1); opacity: .85; } 100% { transform: scale(1, 1); opacity: 0; } }
/* Joystick: four pre-drawn frames. Neutral at rest, a left-right wiggle once powered on, pushed down while pressed. */
.ae-f { opacity: 0; }
.ae-f--n { opacity: 1; }
.arcade-entry__link:is(:hover, :focus-visible, .is-on) .ae-f { animation: 1.8s step-end .6s 3; }
.arcade-entry__link:is(:hover, :focus-visible, .is-on) .ae-f--n { animation-name: arcade-st-n; }
.arcade-entry__link:is(:hover, :focus-visible, .is-on) .ae-f--l { animation-name: arcade-st-l; }
.arcade-entry__link:is(:hover, :focus-visible, .is-on) .ae-f--r { animation-name: arcade-st-r; }
@keyframes arcade-st-n { 0% { opacity: 0; } 12% { opacity: 1; } 24% { opacity: 0; } 36% { opacity: 1; } 48% { opacity: 0; } 60% { opacity: 1; } }
@keyframes arcade-st-l { 0% { opacity: 1; } 12% { opacity: 0; } 48% { opacity: 1; } 60% { opacity: 0; } }
@keyframes arcade-st-r { 0% { opacity: 0; } 24% { opacity: 1; } 36% { opacity: 0; } }
.arcade-entry__link:active .arcade-entry__console { transform: translateY(1px); }
.arcade-entry__link:active .ae-f { opacity: 0 !important; }
.arcade-entry__link:active .ae-f--p { opacity: 1 !important; }
.arcade-entry__hint { margin: 0; font-size: 13px; color: #413D35; }
.arcade-entry__hint kbd, .arcade-entry__hint code { font-family: 'Array', 'Spline Sans Mono', ui-monospace, monospace; font-size: 12px; padding: 1px 5px; border: 1px solid #8A8477; background: #F5F5F6; color: #14130F; }
@media (hover: none) { .arcade-entry__hint { display: none; } }
/* Reduced motion rests powered on with the crew standing on the console, held still. */
@media (prefers-reduced-motion: reduce) {
.arcade-entry__link .arcade-entry__screen::after { animation: arcade-power .5s steps(10) forwards; }
.arcade-entry__link .arcade-entry__name { color: #3FD173; text-shadow: 0 0 6px rgba(63, 209, 115, .55); }
.arcade-entry__link .arcade-entry__led { background: #07BE43; }
.arcade-entry__crew { height: 30px; }
.arcade-entry__link .arcade-entry__crew img { transform: translateY(0); }
}
@media (prefers-reduced-motion: reduce) { .arcade-entry__link, .arcade-entry__link * { animation: none !important; transition: none !important; } .arcade-entry__screen::after { display: none; } }
