/* 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; }
@media (max-width: 700px) {
  .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; }
}

/* Hidden terminal, opened from the header icon, or with / or > outside a text field. */
.hidden-terminal { position: fixed; right: 16px; top: 72px; z-index: 60; width: min(440px, calc(100vw - 32px)); background: #14130F; color: #D6D6D9; border: 1px solid #3A362E; border-radius: 8px; box-shadow: 0 18px 50px rgba(20, 19, 15, .35); font: 400 13px/1.65 'Array', 'Spline Sans Mono', ui-monospace, monospace; letter-spacing: .02em; overflow: hidden; transform-origin: top right; }
.hidden-terminal[hidden] { display: none; }
/* Column layout so the log scrolls when the panel is capped to the visible area. */
.hidden-terminal { display: flex; flex-direction: column; }
.hidden-terminal > * { flex: none; }
.hidden-terminal > .hidden-terminal__log { flex: 0 1 auto; min-height: 0; }
.hidden-terminal:focus { outline: none; }
.hidden-terminal__bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 12px; border-bottom: 1px solid #2A2722; font-size: 11px; letter-spacing: .09em; text-transform: uppercase; color: #7C9CFF; }
.hidden-terminal__bar button { min-height: 32px; padding: 0 4px; border: 0; background: transparent; color: #A9A395; font: inherit; letter-spacing: inherit; text-transform: inherit; }
.hidden-terminal__bar button:focus-visible, .hidden-terminal__input:focus-visible { outline: 2px solid #7C9CFF; outline-offset: 2px; }
.hidden-terminal__quick { display: flex; flex-wrap: wrap; gap: 6px; padding: 10px 14px 0; }
.hidden-terminal__quick button { display: inline-flex; align-items: center; gap: 6px; min-height: 32px; padding: 0 10px; border: 1px solid #3A362E; border-radius: 4px; background: transparent; color: #F0F0F2; font: inherit; }
.hidden-terminal__quick svg { width: 14px; height: 14px; flex: none; }
.hidden-terminal__quick button:hover { border-color: #7C9CFF; }
.hidden-terminal__quick button:focus-visible { outline: 2px solid #7C9CFF; outline-offset: 2px; }
.hidden-terminal__log { max-height: min(240px, 40vh); overflow-y: auto; padding: 10px 14px 0; }
.hidden-terminal__log p { margin: 0; overflow-wrap: anywhere; }
.hidden-terminal__log .is-dim { color: #6B665C; }
.hidden-terminal__log .is-ok { color: #07BE43; }
.hidden-terminal__log .is-cmd { color: #7C9CFF; }
.hidden-terminal__commands { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0 4px; }
.hidden-terminal__commands button { min-height: 32px; padding: 0 9px; border: 1px solid #3A362E; border-radius: 4px; background: transparent; color: #F0F0F2; font: inherit; }
.hidden-terminal__commands button::before { content: '> '; color: #07BE43; }
.hidden-terminal__commands button:hover { border-color: #7C9CFF; color: #fff; }
.hidden-terminal__commands button:focus-visible { outline: 2px solid #7C9CFF; outline-offset: 2px; }
.hidden-terminal__form { display: flex; align-items: center; gap: 10px; padding: 8px 14px 12px; }
.hidden-terminal__prompt { color: #7C9CFF; flex: none; }
.hidden-terminal__input { flex: 1; min-width: 0; min-height: 32px; border: 0; background: transparent; color: #F0F0F2; font: inherit; caret-color: #07BE43; }
.hidden-terminal__input::placeholder { color: #6B665C; }
/* iOS Safari zooms the whole page when a field under 16px is focused, which cropped the terminal on both sides. */
@media (max-width: 700px), (pointer: coarse) {
  .hidden-terminal__input { font-size: 16px; }
}
.hidden-terminal.is-opening { animation: hidden-terminal-in 220ms cubic-bezier(.23, 1, .32, 1); }
@keyframes hidden-terminal-in { from { opacity: 0; transform: translateY(-8px) scale(.97); } }
.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; }

@media (prefers-reduced-motion: reduce) {
  .hidden-terminal.is-opening { 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; left: auto; right: 16px; 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: translateY(8px) scale(.97); } }
@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; } }
