/* cokrach: a cheap 2001 kitchen game. One stage (16:9 picture), overlays in % of it. */
@font-face { font-family: "Alfa Slab One"; src: url("/fonts/alfa-slab-one.woff2") format("woff2"); font-display: swap; }
@font-face { font-family: "Barlow"; font-weight: 500; src: url("/fonts/barlow-500.woff2") format("woff2"); font-display: swap; }
@font-face { font-family: "Barlow"; font-weight: 700; src: url("/fonts/barlow-700.woff2") format("woff2"); font-display: swap; }
@font-face { font-family: "Plex Mono"; font-weight: 500; src: url("/fonts/plex-mono-500.woff2") format("woff2"); font-display: swap; }

:root {
  --bg: #2a2226; --ink: #fff; --accent: #ffd23a;
  --tv-yellow: #ffd23a; --tv-red: #d8322a; --tv-blue: #1b2c8c; --tv-white: #fff;
  --font-display: "Alfa Slab One", Georgia, serif;
  --font-body: "Barlow", system-ui, sans-serif;
  --font-mono: "Plex Mono", ui-monospace, monospace;
  /* the stage: covers the viewport, anchored bottom-right so the TV always stays */
  --sw: max(100vw, 177.78vh);
  --sh: calc(var(--sw) * 0.5625);
}
html, body { background: var(--bg); }
body { overflow-x: hidden; }

.room { position: relative; height: 100vh; height: 100svh; overflow: hidden; }
.cam { position: absolute; inset: 0; animation: sway 11s ease-in-out infinite alternate; transform-origin: 70% 70%; }
.shake { position: absolute; inset: 0; }
.shake.hit { animation: shake .42s cubic-bezier(.3,.7,.4,1); }
.shake.big { animation: shake-big .9s cubic-bezier(.3,.7,.4,1); }
@keyframes sway { from { transform: scale(1.025) rotate(-.25deg) translate(-.3%, 0); } to { transform: scale(1.025) rotate(.25deg) translate(.3%, -.4%); } }
@keyframes shake { 0%,100% { transform: none; } 20% { transform: translate(-6px, 4px); } 45% { transform: translate(5px, -3px); } 70% { transform: translate(-3px, 2px); } }
@keyframes shake-big { 0%,100% { transform: none; } 10% { transform: translate(-14px, 9px) rotate(-.4deg); } 25% { transform: translate(12px, -8px) rotate(.3deg); } 45% { transform: translate(-8px, 5px); } 65% { transform: translate(5px, -3px); } 85% { transform: translate(-2px, 1px); } }

.win { position: absolute; inset: 0; overflow: hidden; }
.stage { position: absolute; right: 0; bottom: 0; width: var(--sw); height: var(--sh); }
.bg, .wreck { position: absolute; inset: 0; width: 100%; height: 100%; }
.wreck { opacity: 0; transition: opacity .25s ease-out;
  -webkit-mask-image: linear-gradient(90deg, #000 58%, transparent 68%); mask-image: linear-gradient(90deg, #000 58%, transparent 68%); }
.wreck.on { opacity: 1; }
.wreck.off { transition-duration: 1.2s; }

.fire { position: absolute; left: -10%; top: 5%; width: 34%; height: 60%; pointer-events: none;
  background: radial-gradient(closest-side, rgba(255,170,70,.55), rgba(255,120,40,.18) 55%, transparent);
  mix-blend-mode: screen; animation: flicker 1.6s steps(6) infinite; }
@keyframes flicker { 0% { opacity: .85; } 17% { opacity: .6; } 33% { opacity: 1; } 50% { opacity: .7; } 67% { opacity: .95; } 83% { opacity: .55; } }

/* the cook stands behind the front counter: his legs are cut by its edge */
.cookclip { position: absolute; inset: 0; clip-path: polygon(0 0, 100% 0, 100% 74%, 0 67.5%); pointer-events: none; }
.cook { position: absolute; left: 4%; bottom: -8%; height: 98%; width: auto; max-width: none;
  transform-origin: 50% 100%; transition: transform .25s ease-out; }
.cook.p1 { height: 113%; left: 6%; }
.cook.p2 { height: 98%; left: 5%; }
.cook.p3 { height: 117%; left: 3%; }
.cook.p4 { height: 92%; left: 3%; }
.cook.p5 { height: 103%; left: 5%; }
.cook.jolt { animation: jolt .3s ease-out; }
@keyframes jolt { 0% { transform: translateY(0) scaleY(1); } 30% { transform: translateY(1%) scaleY(.97); } 100% { transform: none; } }

.roach { position: absolute; left: 0; top: 0; width: 15%; height: auto; max-width: none; pointer-events: none;
  transition: translate var(--t, .45s) var(--ease, cubic-bezier(.2,.8,.3,1)), scale .12s ease-out; will-change: translate; }
.roach.gone { opacity: 0; }
.mess { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.flash { position: absolute; inset: 0; background: #fff3dc; opacity: 0; pointer-events: none; transition: opacity .7s ease-out; }
.flash.on { opacity: .9; transition-duration: .05s; }

/* KILL IT: the cook's slipper on the counter */
.slipper { position: absolute; left: 12%; top: 73%; width: 25%; padding: 0; min-height: 0; border: 0; background: none; cursor: pointer;
  transform-origin: 50% 90%; transition: transform .6s cubic-bezier(.2,.9,.3,1.2), filter .25s ease-out; filter: drop-shadow(0 1.2vw .8vw rgba(20,10,10,.55)); }
.slipper img { width: 100%; height: auto; }
.slipper:hover { transform: translateY(-3%) rotate(-2deg); filter: drop-shadow(0 1.6vw 1vw rgba(20,10,10,.5)) brightness(1.08); }
.slipper:active, .slipper.press { transform: scale(1.04, .9); transition-duration: 35ms; }
.slipper:focus-visible { outline-offset: -6px; border-radius: 40%; }

/* the remote lies flat on the counter */
.remote { position: absolute; left: -76.7%; top: 93%; width: 73.3%; aspect-ratio: 852 / 316;
  transform: perspective(900px) rotateX(38deg) rotateZ(-6deg); transform-origin: 50% 100%; container-type: inline-size; }
.remote-body { position: absolute; inset: 0; width: 100%; height: 100%; filter: drop-shadow(0 .6vw .5vw rgba(0,0,0,.6)); }
.ch { position: absolute; top: 14%; width: 19%; height: 72%; display: grid; place-items: center; text-decoration: none; color: #f2ede4; }
.ch:nth-of-type(1) { left: 30%; } .ch:nth-of-type(2) { left: 52%; } .ch:nth-of-type(3) { left: 74%; }
.ch .key { position: absolute; inset: 0 8% 30%; background: url(/img/sp/btn.webp) center / 100% 100% no-repeat; transition: transform .25s ease-out; }
.ch b { position: relative; font: 400 clamp(16px, 6.5cqi, 28px)/1 var(--font-display); color: #2b2426; margin-top: -26%; }
.ch small { position: absolute; bottom: -4%; font: 700 clamp(16px, 4.4cqi, 18px)/1 var(--font-body); letter-spacing: .08em; }
.ch:hover .key { transform: translateY(-4%); }
.ch:active .key, .ch[aria-current] .key { background-image: url(/img/sp/btn-d.webp); transform: translateY(4%); }
.ch[aria-current] small { color: var(--tv-yellow); }

/* the TV: a crop of the same picture, laid exactly over its pixels (x 70-100%, y 14-86%) */
.tv { position: absolute; right: 0; bottom: calc(var(--sh) * .14); width: calc(var(--sw) * .3); aspect-ratio: 502 / 678; container-type: inline-size; }
.tv-img { position: absolute; inset: 0; width: 100%; height: 100%; }
.screen { position: absolute; left: 20%; top: 47%; width: 70%; height: 36%; display: flex; flex-direction: column; justify-content: space-between;
  color: var(--tv-white); font-family: var(--font-body); }
.screen::after { content: ""; position: absolute; inset: -150% -12% -8%; pointer-events: none; opacity: .18;
  background: repeating-linear-gradient(0deg, rgba(0,0,0,.6) 0 1px, transparent 1px 3px); animation: roll 8s linear infinite; }
@keyframes roll { to { background-position: 0 60px; } }
.tagline { margin: 0; font: 700 clamp(14px, 4.4cqi, 24px)/1.15 var(--font-body); text-transform: uppercase; letter-spacing: .02em; }
.tick { font: 400 1.35em/1 var(--font-display); color: var(--tv-yellow); -webkit-text-stroke: .06em var(--tv-red); paint-order: stroke fill; margin-right: .25em; }
.order { display: grid; gap: 2px; }
.lab { font: 700 clamp(16px, 3.4cqi, 18px)/1 var(--font-body); color: var(--tv-yellow); letter-spacing: .1em; }
.order code { font: 500 clamp(16px, 3.9cqi, 21px)/1.25 var(--font-mono); color: #fff; text-shadow: 0 0 6px rgba(150,190,255,.6); }
.order code.wait { font-family: var(--font-body); font-weight: 700; text-transform: uppercase; }
.keys { display: flex; gap: 3%; }
.k { min-height: max(44px, 2.1em); display: flex; align-items: center; justify-content: center; gap: .35em; padding: .78em 1.12em; border: 0;
  font: 400 clamp(16px, 4cqi, 23px)/1 var(--font-display); color: #2a1c10; text-decoration: none; cursor: pointer;
  background: center / 100% 100% no-repeat; transition: transform .25s cubic-bezier(.2,.9,.3,1.3); }
.k img { width: 1.1em; height: 1.1em; }
.k-x { padding: 0 .9em; }
.k-y { background-image: url(/img/sp/key-y.webp); }
.k-copy { background-image: url(/img/sp/key-r.webp); color: #fff; }
.k:hover { transform: translateY(-3px); }
.k:active { transform: translateY(1px) scale(.98); transition-duration: 35ms; }
.k-y:active { background-image: url(/img/sp/key-y-d.webp); }
.k-copy:active { background-image: url(/img/sp/key-r-d.webp); }
.k.is-off { opacity: .5; }
.fine { margin: 0; font: 500 16px/1.2 var(--font-body); color: rgba(255,255,255,.72); }

/* phones and tall windows: the kitchen on top, the TV below on the same counter, the remote in front of it */
@media (max-aspect-ratio: 13/10) {
  .room { height: auto; overflow: hidden; }
  .cam, .shake { position: relative; animation: none; }
  .shake.hit, .shake.big { animation: shake .42s ease-out; }
  .win { position: relative; width: 100%; aspect-ratio: 11.2 / 9; inset: auto; }
  .stage { left: 0; right: auto; width: 142.86%; height: auto; aspect-ratio: 16 / 9; }
  .slipper { left: 14%; top: 71%; width: 30%; }
  /* the TV is wider than the phone: its screen (17-94% of the crop) fills the width, the bezel runs off the sides */
  .tv { position: relative; right: auto; bottom: auto; width: min(124vw, 680px); margin: -7% 0 0 calc(50vw - min(124vw, 680px) * .553); }
  .tv-img { -webkit-mask-image: linear-gradient(180deg, transparent 0, #000 7%, #000 90%, transparent); mask-image: linear-gradient(180deg, transparent 0, #000 7%, #000 90%, transparent); }
  .remote { left: 22.3%; top: 80%; width: 66%; transform: perspective(900px) rotateX(30deg) rotateZ(-3deg); }
  .room { padding-bottom: 18vw; }
}
@media (prefers-reduced-motion: reduce) {
  .cam, .fire, .screen::after { animation: none; }
}

/* channels 2 and 3: the same TV up close */
.chan .room { background: var(--bg); }
.chan .stage { right: auto; left: 50%; bottom: 0; transform: translateX(-50%); }
.chan .remote { left: 3%; top: 82%; width: 19%; }
.band { position: absolute; left: 27.5%; top: 62.4%; width: 52.5%; height: 8.6%; display: flex; align-items: center; transform: rotate(1.5deg); }
.band p { margin: 0; font: 700 clamp(20px, 1.3vw, 27px)/1.2 var(--font-body); color: #fff; text-wrap: balance; }
.band p b { color: var(--tv-yellow); font-weight: 700; margin-right: .35em; }
.card { position: absolute; left: 66.3%; top: 20.5%; width: 15.8%; height: 26%; color: #3a2416; display: flex; flex-direction: column; gap: .3em;
  transform: rotate(-.6deg); font-family: var(--font-body); }
.card h1 { margin: 0; font: 400 clamp(18px, 1.6vw, 34px)/1.05 var(--font-display); color: var(--tv-red); }
.card ol { margin: 0; padding-left: 1.2em; font: 700 clamp(16px, 1.2vw, 25px)/1.3 var(--font-body); }
.card li::marker { color: var(--tv-red); }
@media (max-aspect-ratio: 13/10) {
  /* the camera pushes in on the TV: its screen is wider than the phone */
  .chan .win { aspect-ratio: auto; height: 100svh; }
  .chan .stage { height: 100%; width: calc(100svh * 16 / 9); aspect-ratio: auto; left: calc(50vw - 100svh * 16 / 9 * var(--cx)); transform: none; }
  .chan.news { --cx: .53; }
  .chan.cookp { --cx: .72; }
  .chan .remote { left: calc(var(--cx) * 100% - min(42vw, 170px)); top: 84%; width: min(84vw, 340px); }
  /* the news lower third grows upward on a small screen, as TV graphics do */
  .band { left: calc(var(--cx) * 100% - 50vw); width: 100vw; top: auto; bottom: 29.4%; height: auto; min-height: 8.6%; padding: .6em 1.2em; transform: none;
    background: linear-gradient(#2433b8, #1d2a9c); }
  .band p { font-size: 18px; }
  .card h1 { font-size: 18px; }
  .card ol { font-size: 16px; padding-left: 1.1em; }
}
/* 404: the TV with no signal */
.nosig { position: absolute; left: 23%; top: 30%; width: 50%; display: grid; place-items: center; gap: 1em; text-align: center; }

/* channel change: the picture collapses to a line, then the next channel */
body.switching .shake { animation: crt-off .26s ease-in forwards; }
@keyframes crt-off { 60% { transform: scale(1, .02); filter: brightness(3); } 100% { transform: scale(0, .02); filter: brightness(3); } }
.chan .shake { animation: crt-on .35s ease-out; }
@keyframes crt-on { from { transform: scale(1, .02); filter: brightness(3); } to { transform: none; filter: none; } }
