/* =========================================================
   DIRTY EDDY TV: additions layered on top of crt.css
   Load AFTER crt.css. crt.css itself is unchanged.
   ========================================================= */

/* ---------------------------------------------------------
   Physical controls: D-pad + extras
   --------------------------------------------------------- */

.knob .glyph {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  pointer-events: none;

  color: var(--knob-line);
  font: calc(var(--d) * .42)/1 var(--hand);
  text-shadow: none;
}

.knob .glyph-text {
  font-size: calc(var(--d) * .3);
  letter-spacing: .04em;
}

.knob-pad .knob-face {
  background: #3fae8a;
}

.knob-ok .knob-face,
.knob-back .knob-face {
  background:
    radial-gradient(circle, #43b290 0 60%, #37a583 61% 100%);
}

.knob-back .knob-face {
  background:
    radial-gradient(circle, var(--knob) 0 40%, transparent 41%),
    repeating-conic-gradient(
      from 8deg,
      var(--knob-dark) 0 6deg,
      var(--knob) 6deg 30deg
    );
}

.knob-dot .glyph-text {
  font-size: calc(var(--d) * .26);
}

.knob:focus-visible {
  outline: 3px dashed #fff;
  outline-offset: 4px;
  border-radius: 50%;
}

.tag {
  top: calc(var(--u) * 1362);
  font-size: max(9px, calc(var(--u) * 26));
}

/* Narrow TVs: fold the controls into an 8 x 2 grid inside the
   cabinet's lower strip, so nothing overlaps and every control
   keeps a usable tap size. Needs .tv to be a size container. */
@container (max-width: 640px) {
  .tv-controls {
    inset: auto;
    left: 3%;
    right: 3%;
    top: 79%;
    bottom: 3%;

    display: grid;
    grid-template-columns: repeat(8, 1fr);
    grid-template-rows: 1fr 1fr;
    place-items: center;
  }

  .knob {
    --d: clamp(30px, 9.2cqw, 52px);
    position: static;
    transform: none;
  }

  .tag {
    display: none;
  }
}


/* ---------------------------------------------------------
   Screen layers
   --------------------------------------------------------- */

.broadcast-video {
  position: absolute;
  inset: 0;
  z-index: 1;
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #000;
}

.broadcast-video[hidden] {
  display: none;
}

.app-content {
  position: absolute;
  inset: 0;
  z-index: 2;
  overflow: hidden;
}

.screen-main.has-strip .app-content {
  bottom: 9.5cqw;
}

.screen-main.vhs-pause .broadcast-video {
  filter: contrast(1.4) saturate(.4) blur(.25cqw);
  animation: vhs-jitter .35s steps(3) infinite;
}

@keyframes vhs-jitter {
  0%   { transform: translateX(-.5%) skewX(.4deg); }
  50%  { transform: translateX(.6%); }
  100% { transform: translateX(0) skewX(-.3deg); }
}

.static-burst {
  position: absolute;
  inset: 0;
  z-index: 6;
  pointer-events: none;
  opacity: 0;

  background:
    repeating-linear-gradient(
      0deg,
      #fff 0 1px,
      #000 1px 2px,
      #8a8a8a 2px 3px,
      #222 3px 4px
    );
  mix-blend-mode: screen;
}

.static-burst.on {
  animation: burst .4s steps(6) forwards;
}

@keyframes burst {
  0%   { opacity: .85; background-position: 0 0; }
  50%  { opacity: .55; background-position: 7px 11px; }
  100% { opacity: 0;   background-position: 3px 5px; }
}


/* ---------------------------------------------------------
   On-screen messages (volume bar, channel digits)
   --------------------------------------------------------- */

.osd {
  position: absolute;
  top: 1.5cqw;
  left: 2cqw;
  z-index: 8;

  display: flex;
  align-items: center;
  gap: 1.4cqw;

  padding: .6cqw 1.6cqw;
  border-radius: 1cqw;
  background: rgba(0, 8, 60, .72);
  color: #7dff7d;
  text-shadow: .3cqw .3cqw 0 #000;

  font: 5cqw/1 var(--display);
  letter-spacing: .1em;

  opacity: 0;
  pointer-events: none;
  transition: opacity .15s;
}

.osd.on {
  opacity: 1;
}

.vol-bar {
  display: flex;
  gap: .5cqw;
}

.vol-bar i {
  width: 1.8cqw;
  height: 4.6cqw;
  background: rgba(125, 255, 125, .22);
}

.vol-bar i.on {
  background: #7dff7d;
}


/* ---------------------------------------------------------
   Menus (now real buttons / links)
   --------------------------------------------------------- */

.menu-item {
  appearance: none;
  width: 100%;
  margin: 0;
  border-width: 0 0 .45cqw 0;
  border-style: dashed;
  background: transparent;
  color: inherit;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}

.menu-item .mi-text {
  display: grid;
  gap: .6cqw;
  min-width: 0;
}

.menu-item small {
  color: var(--cream);
  text-shadow: none;
  font: 3.2cqw/1 var(--hand);
  letter-spacing: .12em;
}

.menu-item.active small {
  color: #1534c4;
}

.menu-item:focus-visible {
  outline-offset: -.7cqw;
}


/* ---------------------------------------------------------
   Broadcast HUD
   --------------------------------------------------------- */

.hud {
  position: absolute;
  inset: 0;
  color: #fff;
}

.hud-osd {
  position: absolute;
  top: 1.2cqw;
  right: 2cqw;
  color: #7dff7d;
  text-shadow: .5cqw .5cqw 0 #000;
  font: 13cqw/1 var(--display);
  animation: osd-fade 3.2s forwards;
}

@keyframes osd-fade {
  0%, 70% { opacity: 1; }
  100%    { opacity: 0; }
}

.hud-bug {
  position: absolute;
  top: 2cqw;
  left: 2cqw;
  padding: .4cqw 1.4cqw;
  border: .4cqw solid rgba(255, 255, 255, .7);
  border-radius: 1cqw;
  color: rgba(255, 255, 255, .8);
  font: 3.4cqw/1 var(--hand);
  letter-spacing: .2em;
}

.hud-lower {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  display: grid;
  gap: .5cqw;
  padding: 3cqw 2.4cqw 1.6cqw;
  background: linear-gradient(transparent, rgba(0, 0, 40, .88));
}

.hud-lower strong {
  font: 5.4cqw/1.05 var(--display);
  letter-spacing: .08em;
  text-transform: uppercase;
}

.hud-lower span {
  color: var(--cream);
  text-shadow: none;
  font: 3.2cqw/1.2 var(--hand);
  letter-spacing: .12em;
}

/* missing clip: a test card, so it looks intentional */
.testcard {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: grid;
  place-items: center;
  background:
    linear-gradient(
      90deg,
      #c8c8c8 0 14.28%,
      #c8c800 14.28% 28.56%,
      #00c8c8 28.56% 42.84%,
      #00c800 42.84% 57.12%,
      #c800c8 57.12% 71.4%,
      #c80000 71.4% 85.68%,
      #0000c8 85.68% 100%
    );
}

.testcard[hidden] {
  display: none;
}

.tc-msg {
  display: grid;
  gap: 1cqw;
  padding: 2.4cqw 4cqw;
  border: .6cqw solid #fff;
  background: rgba(0, 0, 30, .9);
  color: #fff;
  text-align: center;
  text-shadow: none;
}

.tc-msg b {
  font: 8cqw/1 var(--display);
  letter-spacing: .1em;
}

.tc-msg span {
  font: 3.6cqw/1.2 var(--hand);
  letter-spacing: .14em;
}

.tc-msg small {
  color: #9ad;
  font: 2.8cqw/1.2 monospace;
  word-break: break-all;
}


/* ---------------------------------------------------------
   TV GUIDE
   --------------------------------------------------------- */

.guide {
  height: 100%;
  display: flex;
  flex-direction: column;

  border: .6cqw solid #a7a7a7;
  background: #000b55;
  color: #f5f4e8;
  text-shadow: none;
  font-family: "Courier New", ui-monospace, monospace;
}

.g-times,
.g-row {
  display: grid;
  grid-template-columns: 15cqw repeat(3, minmax(0, 1fr));
  gap: .6cqw;
}

.g-times {
  flex: 0 0 auto;
  padding: .6cqw;
}

.g-times div {
  padding: .8cqw;
  border: .5cqw ridge #b8b8b8;
  background: #263f9b;
  color: #ffed28;
  text-align: center;
  font-weight: 700;
  font-size: 2.6cqw;
  white-space: nowrap;
  overflow: hidden;
}

.g-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 0 .6cqw;
  scrollbar-width: none;
}

.g-scroll::-webkit-scrollbar {
  display: none;
}

.g-row {
  margin-bottom: .6cqw;
}

.g-ch {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border: .6cqw ridge #a7a7a7;
  color: #ffed28;
}

.g-ch b {
  font-size: 4.2cqw;
  line-height: 1;
}

.g-ch span {
  font-size: 2.2cqw;
  font-weight: 700;
}

.g-cell {
  appearance: none;
  min-width: 0;
  min-height: 11cqw;
  padding: 1cqw;
  border: .6cqw ridge #a7a7a7;
  border-radius: 0;
  background: #000b55;
  color: #fff;
  text-align: left;
  font: inherit;
  cursor: pointer;
  overflow: hidden;
}

.g-cell b {
  display: block;
  font-size: 2.7cqw;
  line-height: 1.12;
  text-transform: uppercase;
  overflow-wrap: anywhere;
}

.g-cell small {
  display: block;
  margin-top: .6cqw;
  color: #7fe3ff;
  font-size: 2cqw;
  font-weight: 700;
}

.g-cell:hover {
  background: #132b83;
}

.g-cell.active {
  background: #ffed28;
  color: #000b55;
  border-color: #fff;
}

.g-cell.active small {
  color: #000b55;
}

.g-foot {
  flex: 0 0 auto;
  display: flex;
  justify-content: space-between;
  padding: .8cqw 2cqw;
  background: #172d7a;
  color: #ffed28;
  font-size: 2.2cqw;
  font-weight: 700;
  letter-spacing: .1em;
}

/* small tubes: two programme columns are all that will fit */
@container (max-width: 380px) {
  .g-times,
  .g-row {
    grid-template-columns: 15cqw repeat(2, minmax(0, 1fr));
  }

  .g-times div:nth-child(4),
  .g-cell:nth-of-type(3) {
    display: none;
  }

  .g-cell b {
    font-size: 3.6cqw;
  }

  .g-cell small,
  .g-times div {
    font-size: 3cqw;
  }
}


/* ---------------------------------------------------------
   Player page
   --------------------------------------------------------- */

/* The video window is positioned by CSS only. The slot on this page
   and the dock that holds the YouTube iframe use the very same
   width, height and corner (--stage-w), so they cannot drift apart
   when the TV is resized. */
.screen-main {
  --stage-w: 50cqw;
}

.player-view {
  height: 100%;
  display: grid;
  grid-template-columns: var(--stage-w) minmax(0, 1fr);
  gap: 3cqw;
  align-content: start;
}

.player-slot {
  width: var(--stage-w);
  height: calc(var(--stage-w) * 9 / 16);
  display: grid;
  place-items: center;
  border: .6cqw solid var(--phosphor);
  border-radius: 1cqw;
  background: #071046;
  color: rgba(255, 233, 107, .4);
  font: 3cqw var(--hand);
  letter-spacing: .3em;
}

.player-side {
  min-width: 0;
  display: grid;
  gap: 1.6cqw;
  align-content: start;
}

.np-label {
  color: var(--cream);
  text-shadow: none;
  font: 3cqw/1 var(--hand);
  letter-spacing: .2em;
}

.np-title {
  font: 5.2cqw/1.05 var(--display);
  letter-spacing: .06em;
  text-transform: uppercase;
  overflow-wrap: anywhere;
}

.np-meta {
  color: var(--cream);
  text-shadow: none;
  font: 3.2cqw/1.2 var(--hand);
  letter-spacing: .1em;
}

.np-status {
  display: flex;
  align-items: center;
  gap: 1.4cqw;
  font: 3.4cqw/1.1 var(--hand);
  letter-spacing: .1em;
}

.eq {
  display: inline-flex;
  align-items: flex-end;
  gap: .4cqw;
  height: 3.6cqw;
}

.eq i {
  display: block;
  width: .9cqw;
  height: 30%;
  background: var(--phosphor);
}

body.is-playing .eq i {
  animation: eq-bounce .7s ease-in-out infinite alternate;
}

body.is-playing .eq i:nth-child(2) { animation-delay: -.2s; }
body.is-playing .eq i:nth-child(3) { animation-delay: -.45s; }
body.is-playing .eq i:nth-child(4) { animation-delay: -.1s; }

@keyframes eq-bounce {
  from { height: 25%; }
  to   { height: 100%; }
}

.transport {
  display: flex;
  gap: 1.4cqw;
}

.transport button,
.np-yt {
  appearance: none;
  flex: 1;
  padding: 1.4cqw 1cqw;
  border: .5cqw solid var(--phosphor);
  border-radius: 1.4cqw;
  background: transparent;
  color: var(--phosphor);
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  font: 3.8cqw/1 var(--hand);
}

.np-yt {
  font-size: 3cqw;
  letter-spacing: .1em;
}

.transport button.active,
.np-yt.active {
  background: var(--phosphor);
  color: #1534c4;
  text-shadow: none;
}

@container (max-width: 380px) {
  .screen-main {
    --stage-w: 60cqw;
  }

  .player-view {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: calc(var(--stage-w) * 9 / 16) minmax(0, 1fr);
    gap: 1.6cqw;
  }

  .player-side {
    min-height: 0;
    overflow-y: auto;
    scrollbar-width: none;
  }
}

.np-src {
  color: var(--cream);
  text-shadow: none;
  font: 2.8cqw/1.25 var(--hand);
  letter-spacing: .06em;
  overflow-wrap: anywhere;
}

.np-src.warn {
  color: #ffb4a8;
}


/* ---------------------------------------------------------
   Now-playing strip + persistent YouTube dock
   --------------------------------------------------------- */

.np-strip {
  appearance: none;
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 4;

  display: flex;
  align-items: center;
  gap: 2cqw;
  height: 8.5cqw;
  padding: 0 2.4cqw;

  border: .5cqw solid var(--phosphor);
  border-radius: 1.4cqw;
  background: rgba(7, 16, 70, .92);
  color: var(--phosphor);
  text-align: left;
  cursor: pointer;
  font: 3.6cqw/1 var(--hand);
  letter-spacing: .08em;
}

.np-strip[hidden] {
  display: none;
}

.np-strip.active {
  background: var(--phosphor);
  color: #1534c4;
  text-shadow: none;
}

.np-strip.active .eq i {
  background: #1534c4;
}

#stripTitle {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-transform: uppercase;
}

#stripStatus {
  font-size: 3cqw;
  opacity: .8;
}

/*
  The dock holds the one and only YouTube iframe. It is never
  removed from the DOM and never display:none once playback has
  started; it is only moved.
    stage     : sits exactly over #playerSlot on the player page
    offscreen : parked out of view (audio continues)
    pip       : small visible window in the corner
*/
.yt-dock {
  position: absolute;
  z-index: 4;
  display: none;
  overflow: hidden;
  background: #000;
}

.yt-dock.on {
  display: block;
}

.yt-dock[data-mode="stage"] {
  left: 0;
  top: 0;
  width: var(--stage-w);
  height: calc(var(--stage-w) * 9 / 16);
  border: .6cqw solid var(--phosphor);
  border-radius: 1cqw;
}

.yt-dock[data-mode="offscreen"] {
  left: -9999px;
  top: 0;
  width: 320px;
  height: 180px;
}

.yt-dock[data-mode="pip"] {
  right: 1.5cqw;
  bottom: 1.5cqw;
  width: max(200px, 34cqw);
  aspect-ratio: 16 / 9;
  border: .5cqw solid var(--phosphor);
}

.screen-main.has-strip .yt-dock[data-mode="pip"] {
  bottom: 10cqw;
}

.yt-dock iframe,
#ytMount {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
}


/* ---------------------------------------------------------
   Plain pages (About)
   --------------------------------------------------------- */

.page-copy + .page-copy {
  margin-top: 2.4cqw;
}


/* ---------------------------------------------------------
   OK button: the clear centre of the D-pad
   --------------------------------------------------------- */

.knob-ok .knob-face {
  background: radial-gradient(circle, #5fd0a8 0 55%, #3fae8a 56% 100%);
}

.knob-ok .glyph {
  font-weight: 700;
  font-size: calc(var(--d) * .36);
  letter-spacing: .06em;
}

.knob-back .glyph-text {
  font-size: calc(var(--d) * .26);
}


/* ---------------------------------------------------------
   TV GUIDE banner (replaces the "10 and 40" block):
   Dirty Eddy TV Guide logo + DansePlus ad.
   Everything is in cqw, so it scales with the tube.
   --------------------------------------------------------- */

.g-banner {
  flex: 0 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 2cqw;
  padding: 1.4cqw 2cqw;

  background: linear-gradient(110deg, #f8df77 0 56%, #fff 56% 100%);
  border-bottom: .5cqw solid #dedede;
  color: #111;
  font-family: Arial, Helvetica, sans-serif;
}

.g-logo {
  min-width: 0;
  display: grid;
  gap: .8cqw;
  justify-items: start;
}

.g-logo b {
  display: inline-block;
  padding: .8cqw 2cqw;
  border: .5cqw solid #650000;
  background: #a00000;
  box-shadow: .5cqw .5cqw 0 #111;
  color: #fff;
  font-size: 5.2cqw;
  line-height: 1;
  font-weight: 900;
  letter-spacing: -.02em;
  white-space: nowrap;
}

.g-logo span {
  font: 3.4cqw/1 Georgia, serif;
  letter-spacing: .3em;
  color: #111;
}

.g-logo em {
  font: normal 700 3.2cqw/1 "Courier New", monospace;
  color: #7a0000;
}

.g-ad {
  flex: 0 0 auto;
  display: flex;
  align-items: stretch;
  gap: 1.4cqw;
  width: 37cqw;
  padding: .8cqw;

  border: .6cqw ridge #fff;
  background: #f6df70;
  box-shadow: .5cqw .6cqw 0 #000;
  color: #07124d;
  text-decoration: none;
  text-shadow: none;
  transform: rotate(1deg);
}

.g-ad img {
  display: block;
  flex: 0 0 auto;
  width: 13cqw;
  height: 13cqw;
  object-fit: cover;
  background: #111;
}

.g-ad span {
  min-width: 0;
  display: grid;
  align-content: center;
  gap: .8cqw;
}

.g-ad strong {
  font-size: 3.6cqw;
  line-height: 1;
  font-weight: 900;
}

.g-ad small {
  font-size: 2.6cqw;
  line-height: 1.1;
  font-weight: 700;
}

.g-ad.active {
  outline: .7cqw solid #a00000;
  outline-offset: .3cqw;
}

/* a touch larger listings so they read on the tube */
.g-times div { font-size: 2.8cqw; }
.g-cell      { min-height: 12.5cqw; }
.g-cell b    { font-size: 3.1cqw; }
.g-cell small { font-size: 2.4cqw; }
.g-ch b      { font-size: 4.6cqw; }
.g-ch span   { font-size: 2.5cqw; }
.g-foot      { font-size: 2.4cqw; }

@container (max-width: 380px) {
  .g-logo b { font-size: 4.4cqw; padding: .6cqw 1.4cqw; }
  .g-logo span { font-size: 3cqw; }
  .g-ad { width: 40cqw; }
  .g-ad img { width: 12cqw; height: 12cqw; }
  .g-ad strong { font-size: 3.4cqw; }
  .g-ad small { font-size: 2.6cqw; }
  .g-cell b { font-size: 3.8cqw; }
  .g-cell small { font-size: 3cqw; }
}


/* ---------------------------------------------------------
   Player page: on-screen volume
   --------------------------------------------------------- */

.volrow {
  display: flex;
  align-items: center;
  gap: 1.4cqw;
}

.volrow button {
  appearance: none;
  flex: 0 0 auto;
  min-width: 9cqw;
  padding: 1.2cqw 1.6cqw;
  border: .5cqw solid var(--phosphor);
  border-radius: 1.4cqw;
  background: transparent;
  color: var(--phosphor);
  cursor: pointer;
  font: 3.6cqw/1 var(--hand);
}

.volrow button.active {
  background: var(--phosphor);
  color: #1534c4;
  text-shadow: none;
}

.volrow span {
  flex: 1;
  text-align: center;
  font: 3.2cqw/1 var(--hand);
  letter-spacing: .1em;
}


/* ---------------------------------------------------------
   Antenna + reception
   --------------------------------------------------------- */

.antenna-hit {
  position: absolute;
  left: calc(var(--u) * 80);
  top: 0;
  width: calc(var(--u) * 420);
  height: calc(var(--u) * 190);
  z-index: 3;
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.antenna-hit:focus-visible {
  outline: 3px dashed #fff;
  outline-offset: 2px;
}

.rx-fx {
  position: absolute;
  inset: 0;
  z-index: 5;
  pointer-events: none;
  opacity: 0;
  mix-blend-mode: screen;
  background:
    repeating-linear-gradient(
      0deg,
      #fff 0 1px,
      #000 1px 2px,
      #8a8a8a 2px 3px,
      #222 3px 4px
    );
}

.rx-fx[data-level="1"] { opacity: .10; animation: rx-shift .3s steps(3) infinite; }
.rx-fx[data-level="2"] { opacity: .22; animation: rx-shift .22s steps(3) infinite; }
.rx-fx[data-level="3"] { opacity: .38; animation: rx-shift .15s steps(3) infinite; }

@keyframes rx-shift {
  0%   { background-position: 0 0; }
  50%  { background-position: 5px 9px; }
  100% { background-position: 2px 3px; }
}

.screen-main[data-rx="3"] .app-content {
  animation: vhs-jitter .5s steps(3) infinite;
}


/* ---------------------------------------------------------
   News ticker (bottom of broadcasts)
   --------------------------------------------------------- */

.hud-ticker {
  margin-top: .8cqw;
  overflow: hidden;
  white-space: nowrap;
  border-top: .4cqw solid rgba(255, 233, 107, .7);
  padding-top: .8cqw;
  color: var(--phosphor);
  font: 3cqw/1 var(--hand);
  letter-spacing: .12em;
}

.hud-ticker-run {
  display: inline-block;
  animation: ticker 40s linear infinite;
}

@keyframes ticker {
  from { transform: translateX(0); }
  to   { transform: translateX(-50%); }
}


/* ---------------------------------------------------------
   Screensaver
   --------------------------------------------------------- */

.saver {
  position: absolute;
  inset: 0;
  z-index: 7;
  overflow: hidden;
  background: #000;
  pointer-events: none;
}

.saver[hidden] {
  display: none;
}

.saver-logo {
  position: absolute;
  left: 0;
  top: 0;
  display: grid;
  gap: .8cqw;
  text-align: center;
  white-space: nowrap;
  animation:
    saver-x 11s linear infinite alternate,
    saver-y 7s linear infinite alternate,
    saver-hue 6s linear infinite;
}

.saver-logo b {
  font: 12cqw/1 var(--display);
  letter-spacing: .08em;
}

.saver-logo span {
  font: 3.4cqw/1 var(--hand);
  letter-spacing: .3em;
  color: var(--cream);
}

@keyframes saver-x { from { left: 2%;  } to { left: 38%; } }
@keyframes saver-y { from { top: 3%;   } to { top: 70%;  } }
@keyframes saver-hue {
  from { filter: hue-rotate(0deg); }
  to   { filter: hue-rotate(360deg); }
}
