/* The little TV (js/shorts.js): the owner's songs playing in the bottom
   corner, on a set with rabbit ears, a plate with the song's name and two
   knobs (the right one changes the channel). A tap on the picture turns the sound off or on; − shrinks it to a
   pinned tab with a note and the name; ✕ turns it off.
   Movie night and game night share it; each builds the set from the tokens its
   own sheets already set, through data-page, as the feedback box does
   (site.css and weberplex.css for the movie page, arcade.css for game night).
   Movie night's is a walnut cabinet with a gilt screen and a brass plate;
   game night's is a white-edged console blue with A and B buttons. */
.short-tv[data-page='movie'] {
  --st-lift: 70px; /* the bottom tabs on a phone: 10px + 50px + 10px (weberplex.css, .tabs .program) */
  --st-in: short-in 0.6s cubic-bezier(0.2, 0.9, 0.25, 1.12) both;
  --st-out: short-out 0.3s ease-in forwards;
  --st-tilt: 5deg;
  --st-cabinet:
    linear-gradient(180deg, rgb(255 222 170 / 0.16), transparent 38%),
    repeating-linear-gradient(97deg, rgb(26 17 12 / 0.14) 0 2px, transparent 2px 6px, rgb(26 17 12 / 0.07) 6px 7px, transparent 7px 11px),
    linear-gradient(180deg, var(--wood), var(--wood-2));
  --st-edge: 1px solid rgb(26 17 12 / 0.9);
  --st-radius: 10px;
  --st-shadow: inset 0 1px 0 rgb(255 226 180 / 0.3), inset 0 -2px 0 rgb(26 17 12 / 0.45), 0 16px 32px -10px rgb(0 0 0 / 0.8);
  --st-bezel: 3px solid #c99a3e; /* the screening room's gilt */
  --st-screen-radius: 14px / 16px;
  --st-glass:
    radial-gradient(130% 100% at 26% 10%, rgb(255 246 223 / 0.16), transparent 40%),
    repeating-linear-gradient(0deg, rgb(5 2 3 / 0.16) 0 1px, transparent 1px 3px),
    radial-gradient(ellipse at 50% 50%, transparent 58%, rgb(5 2 3 / 0.55));
  --st-plate: linear-gradient(180deg, #ecc878, #c99a3e 55%, #a87d2e);
  --st-plate-ink: var(--board-ink);
  --st-plate-font: 700 11px/1 var(--f-body);
  --st-plate-stretch: 75%;
  --st-plate-track: 0.12em;
  --st-plate-radius: 2px;
  --st-plate-pad: 4px 6px;
  --st-plate-shadow: inset 0 1px 0 rgb(255 246 223 / 0.55), 0 1px 0 rgb(26 17 12 / 0.4);
  --st-knob-1: radial-gradient(circle at 35% 30%, #6a4e3a, var(--board-ink) 72%);
  --st-knob-2: var(--st-knob-1);
  --st-knob-radius: 50%;
  --st-knob-ring: 0 0 0 1.5px #c99a3e;
  --st-ears:
    radial-gradient(circle at 50% 3px, var(--frame-ink-2) 0 2.6px, transparent 3px),
    linear-gradient(var(--frame-ink-2), var(--frame-ink-2)) 50% 100% / 2px calc(100% - 4px) no-repeat;
  --st-base: var(--wood-2);
  --st-base-radius: 13px 13px 0 0;
  --st-legs: var(--wood-2);
  --st-close: var(--frame);
  --st-close-edge: 1px solid var(--rule-strong);
  --st-close-ink: var(--screen);
  --st-close-radius: 50%;
  --st-cap: round;
  --st-chip: rgb(10 4 7 / 0.72);
  --st-chip-ink: var(--screen);
  --st-chip-radius: 999px;
  --st-call: var(--bulb); /* the tap that plays it is this set's main call */
  --st-call-ink: var(--board-ink);
}
.short-tv[data-page='game'] {
  --st-lift: 69px; /* the chapter bar on a phone: a 3px rule + 6px + 54px + 6px (arcade.css, .tabs .chapters) */
  --st-in: short-in 0.42s steps(6, end) both;
  --st-out: short-out 0.24s steps(4, end) forwards;
  --st-tilt: 0deg;
  --st-cabinet: var(--panel);
  --st-edge: 3px solid var(--line);
  --st-radius: 4px;
  --st-shadow: 0 0 0 3px var(--bg), 6px 6px 0 3px rgb(0 0 0 / 0.45);
  --st-bezel: 3px solid var(--bg);
  --st-screen-radius: 2px;
  --st-glass: radial-gradient(ellipse at 50% 50%, transparent 64%, rgb(5 7 26 / 0.5)); /* the page's own scanlines run over it */
  --st-plate: var(--bg);
  --st-plate-ink: var(--gold);
  --st-plate-font: 400 16px/0.75 var(--f-pixel);
  --st-plate-stretch: normal;
  --st-plate-track: 0.02em;
  --st-plate-radius: 0;
  --st-plate-pad: 4px 4px 3px;
  --st-plate-shadow: none;
  --st-knob-1: var(--lime);
  --st-knob-2: var(--pink);
  --st-knob-radius: 0;
  --st-knob-ring: 0 0 0 2px var(--bg);
  --st-ears:
    linear-gradient(var(--line), var(--line)) 50% 0 / 6px 6px no-repeat,
    linear-gradient(var(--line), var(--line)) 50% 100% / 2px 100% no-repeat;
  --st-base: var(--line);
  --st-base-radius: 0;
  --st-legs: var(--line);
  --st-close: var(--bg);
  --st-close-edge: 3px solid var(--line);
  --st-close-ink: var(--text);
  --st-close-radius: 0;
  --st-cap: square;
  --st-chip: rgb(5 7 26 / 0.8);
  --st-chip-ink: var(--text);
  --st-chip-radius: 0;
  --st-call: var(--gold);
  --st-call-ink: var(--bg);
}

/* Bottom right, over the page and under every overlay (40 and up); the box
   holds the ears above the set and the legs under it, and lets taps through
   everywhere but the set and ✕. */
.short-tv {
  position: fixed; right: 12px; bottom: calc(16px + env(safe-area-inset-bottom, 0px)); z-index: 39;
  width: min(40vw, 13rem); padding: 22px 0 6px; pointer-events: none;
  animation: var(--st-in);
}
.short-tv.measuring { visibility: hidden; animation: none; } /* shorts.js checks where it would land first */
@media (max-width: 759px) {
  .tabs .short-tv { bottom: calc(var(--st-lift) + 10px + env(safe-area-inset-bottom, 0px)); } /* above the bottom tabs */
}
@media (max-height: 520px) { .short-tv { width: min(28vw, 10rem); } } /* a landscape phone keeps most of its screen */
.short-tv.leaving { animation: var(--st-out); }
/* while it slides in, for a moment after it lands (shorts.js), and while it
   slides out, it takes no taps: one meant for what was there goes through */
.short-tv:is(.arriving, .leaving) :is(.short-set, .short-close) { pointer-events: none; }

/* the rabbit ears, standing on a little base behind the set */
.short-tv::before, .short-tv::after {
  content: ''; position: absolute; top: 0; left: calc(50% - 3px); width: 6px; height: 28px;
  background: var(--st-ears); transform-origin: 50% 100%; pointer-events: none;
}
.short-tv::before { rotate: -32deg; }
.short-tv::after { rotate: 24deg; }

.short-set {
  position: relative; z-index: 1; padding: 7px 7px 6px; pointer-events: auto;
  border: var(--st-edge); border-radius: var(--st-radius); background: var(--st-cabinet); box-shadow: var(--st-shadow);
}
.short-set::before { /* the ears' base */
  content: ''; position: absolute; left: 50%; bottom: 100%; width: 26px; height: 7px; translate: -50% 0;
  border-radius: var(--st-base-radius); background: var(--st-base);
}
.short-set::after { /* the legs */
  content: ''; position: absolute; top: 100%; left: 16%; right: 16%; height: 6px;
  background: linear-gradient(90deg, var(--st-legs) 0 7px, transparent 7px calc(100% - 7px), var(--st-legs) calc(100% - 7px));
}

/* The screen: 16:9 behind the glass. YouTube's player gets a viewport three
   times the size, shrunk to fit, so its own small print stays small. */
.short-screen {
  position: relative; aspect-ratio: 16 / 9; overflow: hidden;
  border: var(--st-bezel); border-radius: var(--st-screen-radius); background: #050203;
}
.short-screen iframe {
  position: absolute; top: 0; left: 0; width: 300%; height: 300%; border: 0;
  transform: scale(0.33334); transform-origin: 0 0; pointer-events: none;
}
/* the static before the picture comes in (shorts.js), fading as it tunes in */
.short-snow {
  position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none;
  image-rendering: pixelated; transition: opacity 0.25s ease-out;
}
.short-snow.tuned { opacity: 0; }
/* the glass takes the tap (the picture never does), with a muted speaker in its corner */
.short-play {
  position: absolute; inset: 0; margin: 0; padding: 0; border: 0; border-radius: 0;
  background: var(--st-glass); color: var(--st-chip-ink); cursor: pointer; -webkit-tap-highlight-color: transparent;
}
.short-play svg {
  position: absolute; left: 5px; bottom: 5px; width: 22px; height: 22px; padding: 3px;
  border-radius: var(--st-chip-radius); background: var(--st-chip); fill: currentColor;
}
.short-play:is(:hover, :focus-visible) { color: var(--st-call-ink); }
.short-play:is(:hover, :focus-visible) svg { background: var(--st-call); }
.short-play:focus-visible { outline: 2px solid var(--st-call); outline-offset: -4px; border-radius: 0; }

.short-foot { display: flex; align-items: center; gap: 5px; margin-top: 6px; }
.short-plate {
  flex: 1 1 auto; min-width: 0; padding: var(--st-plate-pad); overflow: hidden; white-space: nowrap; text-overflow: ellipsis; text-align: center;
  border-radius: var(--st-plate-radius); background: var(--st-plate); color: var(--st-plate-ink); box-shadow: var(--st-plate-shadow);
  font: var(--st-plate-font); font-stretch: var(--st-plate-stretch); letter-spacing: var(--st-plate-track); text-transform: uppercase;
}
.short-knob { flex: none; width: 10px; height: 10px; border-radius: var(--st-knob-radius); background: var(--st-knob-1); box-shadow: var(--st-knob-ring); }
.short-knob:last-child { background: var(--st-knob-2); }
/* the channel knob: a little bigger, with a wider reach, and a quarter turn when it's turned */
.short-chan {
  position: relative; width: 13px; height: 13px; margin: 0; padding: 0; border: 0; cursor: pointer;
  -webkit-tap-highlight-color: transparent; transition: transform 0.25s ease-out;
}
.short-chan::before { content: ''; position: absolute; inset: -6px -8px -12px; }
.short-chan:is(:hover, :focus-visible) { box-shadow: var(--st-knob-ring), 0 0 0 3px var(--st-call); }
.short-tv.turned .short-chan { transform: rotate(90deg); }
/* Waiting for a tap (the browser won't play sound yet): a word over the static. */
.short-hint {
  display: none; position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); white-space: nowrap;
  padding: 4px 9px; border-radius: var(--st-chip-radius); background: var(--st-chip); color: var(--st-chip-ink);
  font: 700 12px/1.2 system-ui, sans-serif;
}
.short-tv.waiting .short-hint { display: block; }
/* Refused even after a tap (an iPhone): the glass lets the tap through to YouTube's own player. */
.short-tv.handover .short-play { pointer-events: none; background: none; }

/* ✕ and −, on the set's top corner; each tap reaches 44px */
:is(.short-close, .short-min) {
  position: absolute; top: 0; right: -6px; z-index: 2; width: 30px; height: 30px; margin: 0; padding: 0;
  display: grid; place-items: center;
  border: var(--st-close-edge); border-radius: var(--st-close-radius); background: var(--st-close); color: var(--st-close-ink);
  cursor: pointer; pointer-events: auto; -webkit-tap-highlight-color: transparent;
}
:is(.short-close, .short-min)::before { content: ''; position: absolute; inset: -7px; }
.short-close:focus-visible { border-radius: var(--st-close-radius); }
/* −, beside ✕ */
.short-min { right: 30px; }
:is(.short-close, .short-min):active { translate: 0 1px; }
:is(.short-close, .short-min) svg { width: 14px; height: 14px; }
:is(.short-close, .short-min) path { stroke-linecap: var(--st-cap); }

/* full screen, in the picture's other corner */
.short-full {
  position: absolute; right: 5px; bottom: 5px; z-index: 1; width: 22px; height: 22px; margin: 0; padding: 3px;
  display: grid; place-items: center; border: 0;
  border-radius: var(--st-chip-radius); background: var(--st-chip); color: var(--st-chip-ink);
  cursor: pointer; -webkit-tap-highlight-color: transparent;
}
.short-full::before { content: ''; position: absolute; inset: -11px; } /* a 44px reach */
.short-full svg { width: 100%; height: 100%; }
.short-full:is(:hover, :focus-visible) { background: var(--st-call); color: var(--st-call-ink); }
/* Full: the screen fills the display (the browser's full screen) or, where a
   page can't ask for that (an iPhone), the window. The player fills it too. */
.short-screen:fullscreen { border: 0; border-radius: 0; aspect-ratio: auto; }
.short-tv.filled { z-index: 1000; }
.short-tv.filled .short-screen { position: fixed; inset: 0; z-index: 1000; aspect-ratio: auto; border: 0; border-radius: 0; }
.short-tv.full .short-screen iframe { width: 100%; height: 100%; transform: none; }
.short-tv.full .short-full { right: 16px; bottom: calc(16px + env(safe-area-inset-bottom, 0px)); width: 36px; height: 36px; padding: 6px; }
.short-tv.full .short-play svg { left: 16px; bottom: calc(16px + env(safe-area-inset-bottom, 0px)); }

/* the speaker in the picture's corner: crossed out while it's silent, waves once it's heard */
.short-play .short-waves, .short-play.loud .short-hush { display: none; }
.short-play.loud .short-waves { display: inline; }

/* Shrunk: only a small pinned tab is left (the player waits, paused), the
   note and the song's name on it; a tap brings the TV back. */
.short-tab {
  display: none; align-items: center; gap: 6px; max-width: 100%; min-height: 44px; margin: 0 0 0 auto; padding: 0 12px;
  border: var(--st-close-edge); border-radius: var(--st-chip-radius); background: var(--st-close); color: var(--st-close-ink);
  font: var(--st-plate-font); letter-spacing: var(--st-plate-track); text-transform: uppercase;
  cursor: pointer; pointer-events: auto; box-shadow: var(--st-shadow); -webkit-tap-highlight-color: transparent;
}
.short-tab svg { flex: none; width: 18px; height: 18px; fill: currentColor; }
.short-tab-title { min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.short-tv.mini { padding-top: 0; }
.short-tv.mini::before, .short-tv.mini::after, .short-tv.mini :is(.short-set, .short-min, .short-close) { display: none; }
.short-tv.mini .short-tab { display: flex; }
.short-tv:is(.arriving, .leaving) .short-tab { pointer-events: none; }
/* Put aside while something else has the stage (or the next-tab card is under it): unseen, untouchable, paused. */
.short-tv.aside { visibility: hidden; }
.short-tv.aside * { pointer-events: none !important; }

@keyframes short-in { from { transform: translateX(calc(100% + 28px)) rotate(var(--st-tilt)); } }
@keyframes short-out { to { transform: translateX(calc(100% + 28px)); } }
@media (prefers-reduced-motion: reduce) { .short-tv, .short-tv.leaving { animation: none; } } /* it's simply there, then gone */
