/* =========================================================================
   Trusty TV: an old wooden TV set whose picture tube is the YouTube player.
   YouTube's embed rules: nothing may sit on top of the player, and it must be
   at least 200 x 200 px, so all the decoration lives around the screen.
   ========================================================================= */
.tv-head { padding-block: clamp(24px, 4vw, 44px) 0; }
.tv-head .lead { max-width: 52ch; }
.tv-layout { display: grid; gap: clamp(24px, 4vw, 44px); align-items: start; padding-top: clamp(8px, 2vw, 20px); }
@media (min-width: 1024px) {
  .tv-layout { grid-template-columns: minmax(0, 1fr) 300px; }
}
.tv-main { min-width: 0; }

.tv { --ant: clamp(52px, 8vw, 84px); position: relative; max-width: 880px; margin-inline: auto; padding-top: var(--ant); }

/* Rabbit ears */
.tv-antenna { position: absolute; top: 0; left: 50%; width: 80px; height: var(--ant); transform: translateX(-50%); pointer-events: none; }
.tv-antenna::before {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -3px;
  width: 70px;
  height: 26px;
  transform: translateX(-50%);
  border: 3px solid var(--ink);
  border-bottom: 0;
  border-radius: 40px 40px 0 0;
  background: #6b4526;
}
.tv-antenna span {
  position: absolute;
  left: 50%;
  bottom: 16px;
  width: 3px;
  height: calc((var(--ant) - 22px) * 1.23);
  margin-left: -1.5px;
  border-radius: 2px;
  background: var(--ink);
  transform-origin: 50% 100%;
}
.tv-antenna span:first-child { transform: rotate(-36deg); }
.tv-antenna span:last-child { transform: rotate(30deg); }
.tv-antenna span::after {
  content: "";
  position: absolute;
  top: -6px;
  left: 50%;
  width: 11px;
  height: 11px;
  margin-left: -5.5px;
  border-radius: 50%;
  background: var(--ink);
}

/* Cabinet */
.tv-body {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) clamp(92px, 13%, 124px);
  gap: clamp(12px, 2vw, 22px);
  padding: clamp(12px, 2.2vw, 24px);
  border: 3px solid var(--ink);
  border-radius: 34px 28px 36px 30px / 30px 36px 28px 34px;
  background:
    repeating-linear-gradient(96deg, rgba(70, 35, 8, .09) 0 2px, transparent 2px 9px, rgba(70, 35, 8, .05) 9px 10px, transparent 10px 23px),
    linear-gradient(180deg, #c98a4b 0%, #b1703a 100%);
  box-shadow: var(--shadow-ink-lg);
}
.tv-front { display: grid; gap: 10px; min-width: 0; }

/* Picture tube: a dark bezel with a rounded glass rim around a plain rectangular screen */
.tv-bezel {
  padding: clamp(10px, 1.8vw, 18px);
  border: 3px solid var(--ink);
  border-radius: 26px;
  background:
    radial-gradient(120% 140% at 20% 0%, rgba(255, 255, 255, .12), transparent 45%),
    #2a2a2f;
  box-shadow: inset 0 0 0 4px #3b3b42, inset 0 8px 18px rgba(0, 0, 0, .5);
}
.tv-screen {
  position: relative;
  aspect-ratio: 16 / 9;
  background: #0d0d10;
  box-shadow: 0 0 0 3px #111, 0 0 18px 4px rgba(120, 170, 255, .12);
  container-type: inline-size;
}
.tv-screen > iframe, .tv-screen > #player { position: absolute; inset: 0; display: block; width: 100%; height: 100%; border: 0; }
.tv-static, .tv-message { display: none; }
.tv-screen.is-static > iframe { visibility: hidden; }
.tv-screen.is-static .tv-static { display: block; position: absolute; inset: 0; width: 100%; height: 100%; image-rendering: pixelated; }
.tv-screen.is-static .tv-message:not([hidden]) {
  display: block;
  position: absolute;
  top: 50%;
  left: 50%;
  max-width: 86%;
  margin: 0;
  padding: .35em .8em;
  border-radius: 10px;
  background: rgba(0, 0, 0, .72);
  color: #fff;
  font-family: var(--font-marker);
  font-size: clamp(1rem, 4cqi, 1.8rem);
  line-height: 1.2;
  text-align: center;
  transform: translate(-50%, -50%);
}
.tv-screen:fullscreen { width: 100%; height: 100%; aspect-ratio: auto; background: #000; box-shadow: none; }

/* Name plate under the screen: channel badge, sound button and the live light */
.tv-plate { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; padding: 0 4px; }
.tv-plate-name {
  margin: 0;
  font-family: var(--font-marker);
  font-size: clamp(.95rem, 2vw, 1.25rem);
  line-height: 1;
  color: #fff4e2;
  text-shadow: 1px 1px 0 var(--ink), -1px -1px 0 var(--ink), 1px -1px 0 var(--ink), -1px 1px 0 var(--ink);
}
.tv-plate-name span { display: inline-block; margin-left: .15em; padding: .08em .3em; border: 2px solid var(--ink); border-radius: 6px; background: #fff4e2; color: var(--ink); font-size: .8em; text-shadow: none; }
.tv-plate-live {
  display: flex;
  align-items: center;
  gap: .45em;
  margin: 0;
  padding: .3em .6em;
  border: 2px solid var(--ink);
  border-radius: 6px;
  background: var(--red);
  color: #fff;
  font: 800 .72rem/1 var(--font-body);
  letter-spacing: .08em;
  text-transform: uppercase;
}
.live-dot { display: inline-block; width: .6em; height: .6em; border-radius: 50%; background: currentColor; animation: live-pulse 1.4s ease-in-out infinite; }
@keyframes live-pulse { 50% { opacity: .25; } }
.tv-cue {
  margin-left: auto;
  padding: .45em 1em;
  border: 2px solid var(--ink);
  border-radius: 999px;
  background: var(--highlight);
  color: var(--ink);
  font: 800 .9rem/1 var(--font-body);
  box-shadow: 2px 2px 0 var(--ink);
  cursor: pointer;
  animation: cue-bob 2s ease-in-out infinite;
}
.tv-cue:active { transform: translate(2px, 2px); box-shadow: none; }
.tv.sound-on .tv-cue { display: none; }
@keyframes cue-bob { 50% { transform: translateY(-3px); } }

/* Knobs, speaker and power light */
.tv-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 12px 8px;
  border: 3px solid var(--ink);
  border-radius: 18px 14px 20px 16px;
  background: #ead7b0;
  box-shadow: inset 0 0 0 3px rgba(255, 255, 255, .35);
  position: relative;
}
.tv-brand { font-family: var(--font-marker); font-size: 1.15rem; line-height: 1; transform: rotate(-4deg); }
.tv-knobs { display: grid; gap: 12px; justify-items: center; }
.tv-knob-wrap { display: grid; justify-items: center; gap: 5px; }
.tv-knob {
  --turn: 0deg;
  position: relative;
  width: clamp(44px, 6vw, 60px);
  aspect-ratio: 1;
  padding: 0;
  border: 3px solid var(--ink);
  border-radius: 50%;
  background: radial-gradient(circle at 34% 30%, #fff 0 10%, #e4dccb 40%, #b8ad96 100%);
  box-shadow: 2px 3px 0 var(--ink);
  cursor: pointer;
  transform: rotate(var(--turn));
  transition: transform .35s var(--ease-out);
}
.tv-knob::after {
  content: "";
  position: absolute;
  top: 10%;
  left: 50%;
  width: 4px;
  height: 32%;
  margin-left: -2px;
  border-radius: 2px;
  background: var(--ink);
}
.tv-knob:focus-visible { outline: 3px solid var(--blue); outline-offset: 3px; }
#volume-knob { --turn: -135deg; touch-action: none; cursor: grab; }
#volume-knob.is-turning { transition: none; }
.tv-knob-label { font: 800 .6rem/1 var(--font-body); letter-spacing: .1em; text-transform: uppercase; color: var(--ink-soft); }
/* Pops up over the speaker grille, so it never covers the screen. */
.tv-knob-note {
  position: absolute;
  z-index: 2;
  bottom: 40px;
  left: 50%;
  width: max-content;
  max-width: 130px;
  margin: 0;
  padding: 8px 12px;
  border: 2px solid var(--ink);
  border-radius: 12px;
  background: var(--note-yellow);
  box-shadow: 2px 2px 0 var(--ink);
  font-family: var(--font-hand);
  font-weight: 700;
  font-size: 1.15rem;
  line-height: 1.1;
  text-align: center;
  transform: translateX(-50%) rotate(-3deg);
}
.tv-knob-note[hidden] { display: none; }
.tv-speaker {
  flex: 1;
  width: 100%;
  min-height: 56px;
  border-radius: 10px;
  background: repeating-linear-gradient(0deg, rgba(27, 27, 31, .75) 0 3px, transparent 3px 8px);
}
.tv-led { width: 12px; height: 12px; border: 2px solid var(--ink); border-radius: 50%; background: #ff5b5b; box-shadow: 0 0 8px #ff5b5b; }

.tv-legs { display: flex; justify-content: space-between; padding-inline: 14%; }
.tv-legs span { width: clamp(14px, 2vw, 20px); height: clamp(16px, 2.6vw, 28px); border-radius: 0 0 6px 6px; background: var(--ink); }
.tv-legs span:first-child { transform: skewX(14deg); }
.tv-legs span:last-child { transform: skewX(-14deg); }

.tv-controls { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin-top: 18px; }

/* What's on */
.tv-side { display: grid; gap: 18px; min-width: 0; }
.tv-onair { display: flex; align-items: center; gap: 8px; margin: 0 0 8px; font: 800 .75rem/1 var(--font-body); letter-spacing: .08em; text-transform: uppercase; color: var(--red); }
.tv-onair .live-dot { width: 10px; height: 10px; }
.tv-now-title { margin: 0 0 14px; font-size: clamp(1.3rem, 3vw, 1.7rem); }
.tv-progress { height: 12px; overflow: hidden; border: 2px solid var(--ink); border-radius: 999px; background: var(--paper); }
.tv-progress span { display: block; height: 100%; background: var(--highlight); transform: scaleX(0); transform-origin: left; transition: transform 1s linear; }
.tv-now-meta { margin: 8px 0 0; font-size: .9rem; color: var(--pencil); }
.tv-guide { display: grid; gap: 10px; margin: 0; padding: 0; list-style: none; }
.tv-guide li { display: grid; grid-template-columns: 5.4em minmax(0, 1fr); gap: 10px; align-items: baseline; }
.tv-guide time { font-weight: 800; font-variant-numeric: tabular-nums; color: var(--blue); }
.tv-note { margin: 0; font-size: .9rem; color: var(--pencil); }

@media (max-width: 640px) {
  .tv-body { grid-template-columns: minmax(0, 1fr); }
  .tv-panel { flex-direction: row; justify-content: space-between; gap: 12px; padding: 8px 12px; }
  .tv-knobs { display: flex; gap: 14px; }
  .tv-knob-note { top: 50%; right: 10px; bottom: auto; left: auto; max-width: 150px; transform: translateY(-50%) rotate(-3deg); }
  .tv-speaker { min-height: 0; height: 36px; }
  .tv-legs { padding-inline: 10%; }
}
/* Phones: YouTube's player must be at least 200px tall, so the screen gets taller (the video letterboxes). */
@media (max-width: 480px) {
  .tv-cue { flex: 1 0 100%; }
  .tv-bezel { container-type: inline-size; padding: 8px; }
  .tv-screen { aspect-ratio: auto; height: max(204px, 75cqi); }
}

@media (prefers-reduced-motion: reduce) {
  .live-dot, .tv-cue { animation: none; }
  .tv-knob, .tv-progress span { transition: none; }
}
