/* hidden terminal */
.term-open {
  position: fixed; right: 1rem; bottom: 1rem; z-index: 35;
  font: inherit; font-size: .75rem; color: var(--muted); background: rgba(11,12,14,.7);
  border: 1px solid rgba(255,255,255,.16); padding: .35rem .6rem; cursor: pointer; opacity: .45;
  transition: opacity .2s ease, color .2s ease, border-color .2s ease;
}
.term-open:hover, .term-open:focus-visible { opacity: 1; color: var(--cool); border-color: var(--cool); }
body.booting .term-open { display: none; }

.term { position: fixed; inset: 0; z-index: 70; display: none; }
.term.open { display: block; }
.term-back { position: absolute; inset: 0; background: rgba(0,0,0,.5); }
.term-panel {
  position: absolute; left: 0; right: 0; bottom: 0; height: min(max(62%, 14rem), 30rem);
  display: flex; flex-direction: column;
  background: rgba(11,12,14,.97); border-top: 1px solid rgba(232,227,212,.5);
  font-size: .8rem; line-height: 1.55; color: var(--text);
  animation: termin .2s steps(5);
}
@keyframes termin { from { transform: translateY(100%); } to { transform: translateY(0); } }
.term-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: .55rem 1.1rem; border-bottom: 1px solid rgba(255,255,255,.1); color: var(--muted); font-size: .72rem; letter-spacing: .08em;
}
.term-x { font: inherit; color: var(--muted); background: transparent; border: 1px solid rgba(255,255,255,.2); padding: .1rem .5rem; cursor: pointer; }
.term-x:hover, .term-x:focus-visible { color: var(--cool); border-color: var(--cool); }
.term-out { flex: 1; overflow-y: auto; padding: .8rem 1.1rem; white-space: pre-wrap; word-break: break-word; }
.term-line.dim { color: var(--muted); }
.term-line.cmd { color: var(--paper); }
.term-line.err { color: #ff7a8c; }
.term-line.ok { color: var(--cool); }
.term-form { display: flex; gap: .6rem; align-items: center; padding: .6rem 1.1rem .9rem; border-top: 1px solid rgba(255,255,255,.1); }
.term-prompt { color: var(--cool); white-space: nowrap; }
.term-in { flex: 1; min-width: 0; font: inherit; color: var(--paper); background: transparent; border: 0; outline: 0; caret-color: var(--paper); }
.term-in:focus-visible { outline: none; }
/* iOS zooms the whole page into any text box smaller than 16px, so the terminal input is never smaller */
@media (pointer: coarse), (max-width: 820px) { .term-in { font-size: 16px; } }
@media (max-width: 520px) { .term-prompt { display: none; } .term-form::before { content: '$'; color: var(--cool); } }
@media (prefers-reduced-motion: reduce) { .term-panel { animation: none; } }


/* ---------- the "hack" sequence (hack.js) ---------- */
body.hack-on { overflow: hidden; }
body.hack-on[data-view] .scene-canvas.ready { opacity: .95; }
body.hack-1 .g-text, body.hack-1 .g-rgb { animation: none !important; }
body.hack-1 #app { animation: hackshake .2s steps(2) infinite; }
@keyframes hackshake {
  0%   { translate: 0 0; filter: none; }
  25%  { translate: -5px 2px; filter: drop-shadow(5px 0 0 rgba(255,30,60,.8)) drop-shadow(-5px 0 0 rgba(90,0,12,.9)); }
  50%  { translate: 4px -2px; filter: none; }
  75%  { translate: -2px 1px; filter: drop-shadow(-8px 0 0 rgba(255,30,60,.7)) drop-shadow(8px 0 0 rgba(90,0,12,.8)); }
  100% { translate: 0 0; filter: none; }
}

.hack-fx { position: fixed; inset: 0; z-index: 64; pointer-events: none; overflow: hidden;
  background: repeating-linear-gradient(0deg, rgba(0,0,0,.18) 0 1px, transparent 1px 3px); }
.hack-tear { position: absolute; mix-blend-mode: difference; opacity: .85; }
.hack-err { position: absolute; padding: .15em .5em; font-weight: 500; letter-spacing: .08em; white-space: nowrap; color: var(--ink); }
.hack-err.red { background: rgb(255,40,80); }
.hack-err.dark { background: #2a0007; color: #ff4a60; }

.hack { position: fixed; inset: 0; z-index: 66; display: none; flex-direction: column; justify-content: center; align-items: center; padding: 1.5rem;
  background: rgba(22,0,5,.58); color: var(--text); font-size: .85rem; line-height: 1.6; }
.hack.show { display: flex; }
.hack.flash { background: #e8e3d4; }
.hack.flash > * { visibility: hidden; }
.hack::before { content: ''; position: absolute; inset: 0; pointer-events: none;
  background: repeating-linear-gradient(0deg, rgba(0,0,0,.22) 0 1px, transparent 1px 3px); }
.hack-boot { width: min(34rem, 100%); transition: opacity .25s ease; }
.hack-boot.gone { opacity: 0; position: absolute; pointer-events: none; }
.hack-line { color: var(--paper); }
.hack-line::after { content: '_'; animation: hackcur .7s steps(1) infinite; }
@keyframes hackcur { 50% { opacity: 0; } }
.hack-stage { display: none; flex-direction: column; align-items: flex-start; width: min(46rem, 100%); }
.hack-stage.show { display: flex; }
.hack-tag { margin: 0 0 1rem; color: var(--paper); letter-spacing: .14em; font-size: .75rem; }
.hack-title { margin: 0; font-family: 'Archivo', sans-serif; font-weight: 900; text-transform: uppercase; line-height: .95; letter-spacing: -.02em;
  font-size: clamp(2rem, 8vw, 5.4rem); padding: .08em .28em; background: var(--paper); color: var(--ink); transform: rotate(-1.4deg) translate(calc(var(--k, 0) * 4px), calc(var(--k, 0) * -3px));
  clip-path: polygon(0 4%, 3% 0, 97% 2%, 100% 0, 99% 96%, 96% 100%, 4% 98%, 1% 100%); overflow-wrap: anywhere; }
.hack-title.g-rgb { filter: drop-shadow(6px 0 0 rgba(255,30,60,.85)) drop-shadow(-6px 0 0 rgba(60,0,8,.9)); animation: hackjit .34s steps(5); }
.hack-title.g-tear { filter: drop-shadow(9px 0 0 rgba(255,30,60,.8)) drop-shadow(-9px 0 0 rgba(60,0,8,.9)); animation: hackjit .3s steps(4); }
.hack-title.g-flicker { animation: hackflick .34s steps(1); }
.glitch .hack-title { filter: drop-shadow(6px 0 0 rgba(255,30,60,.8)) drop-shadow(-6px 0 0 rgba(60,0,8,.9)); }
@keyframes hackjit { 0% { translate: -12px 0; } 20% { translate: 16px 2px; } 40% { translate: -7px -2px; } 60% { translate: 10px 0; } 80% { translate: -3px 2px; } 100% { translate: 0 0; } }
@keyframes hackflick { 0% { opacity: 1; } 15% { opacity: .15; } 30% { opacity: 1; } 45% { opacity: 0; } 60% { opacity: .9; } 78% { opacity: .2; } 100% { opacity: 1; } }
.hack-sub { margin: 1.4rem 0 1.2rem; color: var(--text); }
.hack-bar { width: 100%; height: 3px; background: rgba(255,255,255,.14); }
.hack-bar i { display: block; height: 100%; width: 0; background: var(--paper); }
.hack-time { margin: .6rem 0 0; color: var(--text); font-size: .78rem; }
.hack-note { margin: .8rem 0 0; color: var(--paper); font-size: .78rem; min-height: 1.2em; }
.hack .btn.hack-exit { margin-top: 1.4rem; font: inherit; font-size: .85rem; background: transparent; cursor: pointer; color: var(--text); }
.hack.lost .hack-title { opacity: .85; }

@media (prefers-reduced-motion: reduce) {
  body.hack-1 #app { animation: none; }
  .hack-title.g-rgb, .hack-title.g-tear, .hack-title.g-flicker { animation: none; filter: none; }
  .hack-line::after { animation: none; }
}

/* the red wash: multiplying by red leaves only the red channel, so the whole page turns red and black */
.hack-tint { position: fixed; inset: 0; z-index: 67; pointer-events: none; background: #ff1a38; mix-blend-mode: multiply; opacity: 0; transition: opacity 1.4s ease; }
.hack-tint.on { opacity: 1; }
@media (prefers-reduced-motion: reduce) { .hack-tint { transition: none; } }
