/* Nicole Cardoza — the TV page. A photo of a TV, with the video, dials and power
   knob laid over the matching spots. tv.js does the positioning. */
:root {
  --room-light: 0;              /* how much the picture lights the room, 0 to 1 */
  --tint: 255 255 255;          /* colour of that light */
  --glow: 0 0 0;                /* colour of the picture */
  --stage-w: min(100vw, calc(100svh * 2667 / 1500));
}

*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: #060504;
  overflow: hidden;
}
.sr-only {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

/* The part of the photo that must always fit. The rest of the room runs past it. */
.stage {
  position: absolute; left: 50%; top: 50%;
  width: var(--stage-w);
  aspect-ratio: 2667 / 1500;
  transform: translate(-50%, -50%);
}
.photo { position: absolute; max-width: none; height: auto; display: block; }

/* The same photo, brighter, fading in with the picture and falling off with distance */
.photo-lit {
  position: absolute; inset: 0; pointer-events: none;
  opacity: var(--room-light);
}
.photo-lit::after {
  content: ''; position: absolute; left: -100vw; right: -100vw; top: -100vh; bottom: -100vh;
  background: radial-gradient(circle at 50% 50%, rgb(var(--tint) / .1), transparent 45%);
  mix-blend-mode: screen;
}
.photo-lit .photo {
  -webkit-mask-image: radial-gradient(circle at 48% 51%, #000 18%, rgba(0,0,0,.6) 38%, transparent 70%);
  mask-image: radial-gradient(circle at 48% 51%, #000 18%, rgba(0,0,0,.6) 38%, transparent 70%);
}

/* ---------- The picture: a fixed-size box bent onto the photo's screen ---------- */
.tube {
  position: absolute; left: 0; top: 0;
  width: 590px; height: 480px;
  transform-origin: 0 0;
  overflow: hidden;
  border-radius: 13% / 16%;
  background: #000;
  box-shadow: 0 0 70px rgb(var(--glow) / .55);
  transition: opacity .25s linear;
}
.tube.is-off { opacity: 0; pointer-events: none; }
.tube video, .tube canvas {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
}
/* An old tube: softer, warmer, a little faded */
.tube video { filter: sepia(.28) saturate(.78) contrast(1.06) brightness(1.04) blur(.35px); }
.tube canvas { opacity: 0; pointer-events: none; image-rendering: pixelated; }
.tube canvas.on { opacity: 1; }

.glass {
  position: absolute; inset: 0; pointer-events: none;
  border-radius: inherit;
  background:
    repeating-linear-gradient(to bottom, rgba(0,0,0,.2) 0 1px, transparent 1px 3px),
    radial-gradient(ellipse at 26% 10%, rgba(255,250,235,.14), transparent 38%),
    radial-gradient(ellipse at center, transparent 50%, rgba(0,0,0,.62) 100%);
}

/* Channel number, shown for a moment after the dial moves */
.osd {
  position: absolute; top: 26px; right: 34px;
  color: #F0DFA8;
  font: 64px/1 'Forum', Georgia, serif;
  text-shadow: 0 0 8px rgba(0,0,0,.9);
  opacity: 0; transition: opacity .3s;
  pointer-events: none;
}
.osd.on { opacity: 1; }

/* The link chosen with the lower dial */
.screen-link {
  position: absolute; top: 32px; left: 38px;
  color: #F0DFA8;
  font: 40px/1 'Forum', Georgia, serif;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 5px;
  text-shadow: 0 0 7px rgba(0,0,0,.95), 0 0 2px rgba(0,0,0,.9);
}
.screen-link[hidden] { display: none; }
.screen-link:hover, .screen-link:focus-visible { color: #fff; }

.tap-to-play {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  background: rgba(0,0,0,.45);
}
.tap-to-play[hidden] { display: none; }
.tap-to-play button {
  font: 30px 'Forum', Georgia, serif;
  color: #17140F; background: #E1BD65;
  border: 0; padding: 10px 24px; cursor: pointer;
}

/* ---------- The photo's own dials, cut out so they can turn ---------- */
.dial {
  position: absolute;
  border-radius: 50%;
  cursor: grab;
  touch-action: none;
  user-select: none; -webkit-user-select: none;
}
.dial:active { cursor: grabbing; }
/* Easier to hit than the dial is big */
.dial::after { content: ''; position: absolute; inset: -45%; border-radius: 50%; }
.dial:focus-visible, .power:focus-visible { outline: 2px solid #F0DFA8; outline-offset: 3px; }
.dial__knob {
  position: absolute; inset: 0;
  border-radius: 50%;
  overflow: hidden;
  transition: transform .22s cubic-bezier(.3, 1.5, .6, 1);
}
.dial__lit { opacity: var(--room-light); }
/* The knobs are plain metal, so a small mark shows them turning */
.dial__mark {
  position: absolute; left: 50%; top: 6%;
  width: 9%; height: 34%; transform: translateX(-50%);
  background: #F4EEDC; border-radius: 2px;
  box-shadow: 0 0 1px rgba(0,0,0,.8);
}

.power {
  position: absolute; padding: 0;
  border: 0; border-radius: 50%;
  background: transparent; cursor: pointer;
}
.power::after { content: ''; position: absolute; inset: -60%; border-radius: 50%; }

/* Phones held upright: move in close so the dials are big enough to use */
@media (max-aspect-ratio: 1/1) {
  .dial::after { inset: -110%; }
  :root { --stage-w: min(150vw, calc(100svh * 2667 / 1500)); }
  /* A tall window runs past the photo, so fade its top and bottom into the dark */
  .stage > .photo {
    -webkit-mask-image: linear-gradient(to bottom, transparent, #000 12%, #000 80%, transparent);
    mask-image: linear-gradient(to bottom, transparent, #000 12%, #000 80%, transparent);
  }
  .photo-lit .photo {
    -webkit-mask-image: radial-gradient(circle at 48% 51%, #000 14%, rgba(0,0,0,.5) 26%, transparent 40%);
    mask-image: radial-gradient(circle at 48% 51%, #000 14%, rgba(0,0,0,.5) 26%, transparent 40%);
  }
}

@media (prefers-reduced-motion: reduce) {
  .dial__knob { transition: none; }
}
