/* The home page's TV (crt.mjs): the room behind a CRT's glass. Every layer is pointer-transparent and sits over the
   room and the cube; the page's words and controls stay in front of the glass, crisp. */
#fd .crt-layer { display: none; position: absolute; inset: 0; z-index: 40; pointer-events: none; }
#fd.fd-room :is(.home-side, .home-play, .home-links, .home-page, .home-legal) { z-index: 42; }
/* The header above those too: its language and Screen and Sound menus open downward over them. */
#fd.fd-room .fd-top { z-index: 43; }
#fd.crt-on .crt-layer { display: block; }
/* A gaming monitor's picture, not a worn tape: an RGB signal on a fine-pitch Trinitron. Sharp edges, deep blacks, vivid
   color, no noise, no color fringing. */
/* Scanlines that follow the beam: overlay blending keeps the gaps dark where the picture is dark and lets bright lines
   bloom over them, the way a PVM's scanlines nearly vanish in the highlights. */
#fd.crt-on .crt-lines { background: repeating-linear-gradient(to bottom, rgba(0,0,0,0) 0 var(--crt-gap, 2px), rgba(0,0,0,.5) var(--crt-gap, 2px) var(--crt-line, 3px)); mix-blend-mode: overlay; }
/* The aperture grille: fine, unbroken vertical stripes of red, green and blue phosphor, seen only up close. */
#fd.crt-on .crt-grille { --s: var(--crt-stripe, 1px); background: repeating-linear-gradient(to right, rgba(255,0,40,.12) 0 var(--s), rgba(0,255,70,.1) var(--s) calc(2 * var(--s)), rgba(30,80,255,.12) calc(2 * var(--s)) calc(3 * var(--s))); mix-blend-mode: overlay; }
/* The glass: a Trinitron's flat-faced tube, deep black, with nearly square corners in its bezel, the faintest falloff
   at the edges and the aperture grille's two hairline damper wires. */
#fd.crt-on .crt-glass { inset: clamp(3px, .6vmin, 8px); border-radius: clamp(6px, 1.2vmin, 16px) / clamp(5px, 1vmin, 12px);
  background:
    linear-gradient(to bottom, transparent calc(25% - .5px), rgba(0,0,0,.22) calc(25% - .5px) calc(25% + .5px), transparent calc(25% + .5px) calc(75% - .5px), rgba(0,0,0,.22) calc(75% - .5px) calc(75% + .5px), transparent calc(75% + .5px)),
    radial-gradient(ellipse 120% 120% at 50% 50%, transparent 70%, rgba(0,0,0,.35) 100%);
  box-shadow: 0 0 0 40px #020203, inset 0 0 clamp(6px, 1.4vmin, 18px) rgba(0,0,0,.8); }
/* RGB color: the room and the cube a touch richer and punchier, with the phosphor's glow around what is bright. */
#fd.crt-on .fd-gl { filter: saturate(1.18) contrast(1.06); }
#fd.crt-on .fd-cube { filter: saturate(1.18) contrast(1.06) drop-shadow(0 0 14px rgba(255,255,255,.12)); }

/* Switching on: a bright line opens into the picture. Switching off: the picture folds to a line, then a dot. A clip
   and a flash only, so the room and the cube keep their real size while it plays. */
#fd .crt-flash { display: none; position: absolute; inset: 0; z-index: 41; pointer-events: none; background: #fff; opacity: 0; }
#fd.crt-power-on { animation: crt-on .6s cubic-bezier(.2,.7,.2,1) backwards; }
#fd.crt-power-on .crt-flash { display: block; animation: crt-flash-on .6s ease-out backwards; }
@keyframes crt-on {
  0% { clip-path: inset(49.8% 47% 49.8% 47%); }
  22% { clip-path: inset(49.8% 0 49.8% 0); }
  55% { clip-path: inset(0 0 0 0); }
}
@keyframes crt-flash-on { 0%, 22% { opacity: .9; } 50% { opacity: .06; } 100% { opacity: 0; } }
#fd.crt-power-off { animation: crt-off .34s cubic-bezier(.6,0,.9,.4) forwards; }
#fd.crt-power-off .crt-flash { display: block; animation: crt-flash-off .34s ease-in forwards; }
@keyframes crt-off {
  0% { clip-path: inset(0 0 0 0); }
  55% { clip-path: inset(49.8% 0 49.8% 0); }
  100% { clip-path: inset(49.8% 49.8% 49.8% 49.8%); }
}
@keyframes crt-flash-off { 0% { opacity: 0; } 55%, 100% { opacity: 1; } }

/* The Screen and Sound menu: a quiet TV button beside the language menu; its switches open downward beneath it. */
#fd .home-tv { position: relative; z-index: 5; margin-left: auto; margin-right: -8px; font: 500 clamp(15px, 1.05vw, 18px) var(--body); }
#fd .home-tv > button { display: grid; place-items: center; width: 44px; height: 44px; padding: 0; border: 0; border-radius: 50%; background: rgba(255,255,255,.08); color: #fff; cursor: pointer; transition: background-color .15s ease; }
#fd .home-tv > button svg { width: 22px; height: 22px; }
#fd .home-tv > button[aria-expanded="true"] { background: rgba(255,255,255,.16); }
@media (hover: hover) and (pointer: fine) { #fd .home-tv > button:hover { background: rgba(255,255,255,.16); } }
#fd .home-tv-list { position: absolute; right: 0; top: calc(100% + 8px); display: grid; gap: 2px; min-width: 200px; padding: 6px; border-radius: 16px; background: rgba(21,21,27,.94); -webkit-backdrop-filter: blur(18px) saturate(1.4); backdrop-filter: blur(18px) saturate(1.4); box-shadow: inset 0 0 0 1px rgba(255,255,255,.1), 0 18px 40px rgba(0,0,0,.5); }
#fd .home-tv-list[hidden] { display: none; }
@media (prefers-reduced-motion: no-preference) { #fd .home-tv-list { animation: s64-drop .16s ease-out; } }
#fd .home-tv-list button { display: flex; align-items: center; justify-content: space-between; gap: 16px; width: 100%; min-height: 44px; padding: 0 12px; border: 0; border-radius: 10px; background: none; color: rgba(255,255,255,.75); font: inherit; text-align: left; white-space: nowrap; cursor: pointer; }
#fd .home-tv-list button::after { content: ""; flex: none; width: 34px; height: 20px; border-radius: 999px; background: rgba(255,255,255,.18) radial-gradient(circle 7px at 10px 50%, #fff 6.5px, transparent 7px); transition: background-color .15s ease, background-position .15s ease; }
#fd .home-tv-list button[aria-pressed="true"] { color: #fff; }
#fd .home-tv-list button[aria-pressed="true"]::after { background: #29c761 radial-gradient(circle 7px at 24px 50%, #fff 6.5px, transparent 7px); }
@media (hover: hover) and (pointer: fine) { #fd .home-tv-list button:hover { color: #fff; background-color: rgba(255,255,255,.1); } }
#fd .home-tv button:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
