/* raocow tv */

:root {
  color-scheme: dark;

  --bg: #0c0b0e;
  --bg-glow: #1c1420;
  --surface: #16141a;
  --surface-hover: #1f1c24;
  --border: #2a2630;
  --text: #ece8f0;
  --text-muted: #a39cab;
  --text-faint: #8a8292;
  --accent: #ffb347;
  --accent-soft: rgb(255 179 71 / 0.16);
  --focus: #ffd08a;

  /* the TV */
  --wood-light: #6b4528;
  --wood: #4a2e1a;
  --wood-dark: #2b190d;
  --metal-light: #4a4550;
  --metal: #2c2830;
  --metal-dark: #17151a;
  --brass: #c9a46b;

  --radius: 10px;
  --gutter: clamp(16px, 4vw, 40px);
  --max-width: 1320px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, Ubuntu, sans-serif;
  --font-mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  background: var(--bg);
  scroll-padding-top: 16px;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(ellipse 90% 60% at 50% -10%, var(--bg-glow), transparent 70%),
    var(--bg);
  color: var(--text);
  font: 16px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
}

a {
  color: inherit;
}

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

[hidden] {
  display: none !important;
}

.skip-link {
  position: absolute;
  left: 8px;
  top: -100px;
  padding: 8px 12px;
  background: var(--accent);
  color: #000;
  border-radius: 6px;
  z-index: 10;
}

.skip-link:focus {
  top: 8px;
}

/* --- Header and footer ---------------------------------------------------- */

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  width: 100%;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 20px var(--gutter) 6px;
}

.logo {
  font-size: 1.6rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  text-decoration: none;
  white-space: nowrap;
}

.logo-tv {
  display: inline-block;
  margin-left: 2px;
  padding: 0 0.25em 0.05em;
  border: 2px solid currentColor;
  border-radius: 0.25em;
  color: var(--accent);
  font-weight: 700;
}

.site-nav {
  display: flex;
  gap: 4px;
}

.site-nav a {
  padding: 6px 12px;
  border-radius: 999px;
  color: var(--text-muted);
  text-decoration: none;
  font-weight: 600;
}

.site-nav a:hover {
  color: var(--text);
  background: var(--surface);
}

.site-nav a[aria-current="page"] {
  color: var(--accent);
  background: var(--accent-soft);
}

main {
  flex: 1;
  width: 100%;
  padding: 0 var(--gutter);
}

/* The TV may be wider than the rest of the page. */
.view {
  max-width: var(--max-width);
  margin: 0 auto;
}

.site-footer {
  padding: 40px var(--gutter);
  color: var(--text-faint);
  text-align: center;
  font-size: 0.875rem;
}

.site-footer a {
  color: var(--text-muted);
}

/* --- The TV ---------------------------------------------------------------- */
/* The frame picture and its measurements live in tv-frame.css. */

.tv-section {
  /* As wide as allowed, but short enough to fit the whole set in the window. */
  --tv-width: min(100%, var(--tv-max-width), calc((100svh - 86px) * var(--tv-frame-aspect)));
  padding-top: 0;
}

.tv {
  position: relative;
  width: var(--tv-width);
  margin: 0 auto;
  aspect-ratio: var(--tv-frame-aspect);
  filter: drop-shadow(0 30px 40px rgb(0 0 0 / 0.7));
}

/* The frame sits on top of the video, but lets clicks through to it. */
.tv-frame {
  position: absolute;
  inset: 0;
  z-index: 2;
  background: var(--tv-frame-image) center / 100% 100% no-repeat;
  pointer-events: none;
}

.tv-screen {
  position: absolute;
  z-index: 1;
  left: calc(var(--tv-screen-left) - var(--tv-overscan));
  top: calc(var(--tv-screen-top) - var(--tv-overscan));
  width: calc(var(--tv-screen-width) + 2 * var(--tv-overscan));
  height: calc(var(--tv-screen-height) + 2 * var(--tv-overscan));
  overflow: hidden;
  background: #050505;
}

.tv-player,
.tv-player iframe,
.tv-static,
.tv-glass {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

.tv-static {
  image-rendering: pixelated;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s;
}

.tv-static.on {
  opacity: 0.9;
}

/* Curved glass: glare and a soft vignette. Clicks pass through to the player. */
.tv-glass {
  pointer-events: none;
  background:
    radial-gradient(ellipse 60% 35% at 28% 8%, rgb(255 255 255 / 0.08), transparent 70%),
    radial-gradient(ellipse at center, transparent 60%, rgb(0 0 0 / 0.4) 100%);
}

/* The channel buttons sit on the set's side panel. Sizes are in
   cqw (1% of the TV's width; 9.2 units of tv.svg) so they scale with the TV. */
.tv {
  container-type: inline-size;
}

.tv-panel {
  position: absolute;
  z-index: 3;
  left: var(--tv-panel-left);
  top: var(--tv-panel-top);
  width: var(--tv-panel-width);
  height: var(--tv-panel-height);
  display: flex;
}

.tv-channel-buttons {
  flex: 1;
  display: flex;
  gap: 1.09cqw;
  padding: 1.09cqw 1.2cqw 1.41cqw;
}

.tv-button {
  flex: 1;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0.6cqw solid #24150b;
  border-radius: 1.3cqw;
  background: #efe3c2;
  box-shadow: 0 0.49cqw 0 #24150b;
  color: #24150b;
  cursor: pointer;
  transition: transform 0.06s, box-shadow 0.06s;
}

.tv-button svg {
  width: 2.83cqw;
  height: 2.83cqw;
  fill: none;
  stroke: currentColor;
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.tv-button:hover {
  background: #fff4d8;
}

.tv-button:active {
  transform: translateY(0.38cqw);
  box-shadow: 0 0.11cqw 0 #24150b;
}

.tv-button:disabled {
  color: #8a7a5c;
  background: #d9cba6;
  cursor: default;
  transform: none;
}

.tv-dial {
  position: absolute;
  z-index: 3;
  left: var(--tv-dial-left);
  top: var(--tv-dial-top);
  width: var(--tv-dial-width);
  aspect-ratio: 1;
  border-radius: 50%;
  cursor: grab;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.tv-dial.grabbing {
  cursor: grabbing;
}

.tv-dial svg {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.tv-dial:focus {
  outline: none;
}

/* On phones the frame would make the screen tiny, so show just the screen,
   with the channel buttons in a row underneath. */
@media (max-width: 560px) {
  .tv-section {
    padding-top: 8px;
  }

  .tv {
    display: flex;
    flex-direction: column;
    gap: 14px;
    aspect-ratio: auto;
    filter: none;
  }

  .tv-frame,
  .tv-dial {
    display: none;
  }

  .tv-screen {
    position: relative;
    inset: auto;
    width: 100%;
    height: auto;
    aspect-ratio: 4 / 3;
    border-radius: 14px;
    box-shadow: 0 0 0 1px var(--border);
  }

  .tv-panel {
    position: static;
    width: auto;
    height: auto;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 12px;
  }


  .tv-channel-buttons {
    flex: none;
    gap: 12px;
    padding: 0;
  }

  .tv-button {
    flex: none;
    width: 52px;
    height: 46px;
    border-width: 3px;
    border-radius: 12px;
    box-shadow: 0 4px 0 #24150b;
  }

  .tv-button svg {
    width: 24px;
    height: 24px;
  }
}

/* --- Now playing ----------------------------------------------------------- */

.now-playing {
  width: var(--tv-width);
  margin: 22px auto 0;
}

.now-playing-context {
  margin: 0;
  color: var(--accent);
  font-size: 0.8125rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.now-playing-context a {
  text-decoration-color: rgb(255 179 71 / 0.4);
  text-underline-offset: 3px;
}

.now-playing-title {
  margin: 4px 0 6px;
  font-size: clamp(1.25rem, 2.6vw, 1.75rem);
  line-height: 1.25;
  letter-spacing: -0.01em;
  overflow-wrap: anywhere;
}

.now-playing-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 16px;
  margin: 0;
  color: var(--text-muted);
  font-size: 0.9375rem;
}

.now-playing-meta a {
  color: var(--text-muted);
}

.now-playing-meta a:hover {
  color: var(--text);
}

/* --- Sections and grids ---------------------------------------------------- */

.view:focus {
  outline: none;
}

.section {
  margin-top: 48px;
}

.section-heading {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px 24px;
  margin-bottom: 18px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.section-heading h2 {
  margin: 0;
  font-size: 1.375rem;
  letter-spacing: -0.01em;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 250px), 1fr));
  gap: 24px 18px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.tile {
  display: block;
  height: 100%;
  border-radius: var(--radius);
  text-decoration: none;
}

.thumb {
  position: relative;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 0 0 1px var(--border);
  transition: box-shadow 0.15s, transform 0.15s;
}

.thumb img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.thumb-empty {
  width: 100%;
  height: 100%;
  background: repeating-linear-gradient(45deg, var(--surface) 0 10px, var(--surface-hover) 10px 20px);
}

.tile:hover .thumb {
  transform: translateY(-2px);
  box-shadow: 0 0 0 1px var(--border), 0 10px 24px -8px rgb(0 0 0 / 0.8);
}

.tile.playing .thumb {
  box-shadow: 0 0 0 2px var(--accent), 0 0 24px -4px rgb(255 179 71 / 0.6);
}

.tile.playing .thumb::after {
  content: "now playing";
  position: absolute;
  top: 8px;
  left: 8px;
  padding: 2px 8px;
  border-radius: 4px;
  background: var(--accent);
  color: #1a1008;
  font-size: 0.75rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.tile.playing .badge-number {
  display: none;
}

.badge {
  position: absolute;
  padding: 1px 6px;
  border-radius: 4px;
  background: rgb(0 0 0 / 0.82);
  color: #fff;
  font-size: 0.8125rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  line-height: 1.4;
}

.badge-duration {
  right: 6px;
  bottom: 6px;
}

.badge-number {
  top: 6px;
  left: 6px;
}

.badge-live {
  background: #c4302b;
  text-transform: uppercase;
}

.tile-body {
  padding: 10px 2px 0;
}

.tile-title {
  display: -webkit-box;
  margin: 0;
  overflow: hidden;
  font-size: 0.975rem;
  font-weight: 600;
  line-height: 1.35;
  overflow-wrap: anywhere;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
}

.tile:hover .tile-title {
  color: var(--accent);
}

.tile-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0 12px;
  margin: 4px 0 0;
  color: var(--text-muted);
  font-size: 0.875rem;
}

.more-button {
  display: block;
  margin: 24px auto 0;
  padding: 10px 22px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.more-button:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* --- Playlists -------------------------------------------------------------- */

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.input {
  min-width: 0;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 0.9375rem;
}

input.input {
  width: 260px;
  max-width: 100%;
}

.input:focus-visible {
  outline-offset: 0;
  border-color: var(--focus);
}

.input::placeholder {
  color: var(--text-faint);
}

@media (max-width: 560px) {
  .controls,
  input.input {
    width: 100%;
  }

  input.input {
    flex: 1 1 160px;
  }
}

.result-count {
  margin: 0 0 16px;
  color: var(--text-muted);
  font-size: 0.875rem;
}

.thumb-stack {
  overflow: visible;
}

.thumb-stack img,
.thumb-stack .thumb-empty {
  border-radius: inherit;
}

/* A second card peeking out from behind, so playlists read as stacks. */
.thumb-stack::before {
  content: "";
  position: absolute;
  left: 8px;
  right: 8px;
  top: -6px;
  height: 20px;
  z-index: -1;
  border-radius: var(--radius) var(--radius) 0 0;
  background: var(--surface-hover);
  box-shadow: 0 0 0 1px var(--border);
}

.playlist-grid {
  padding-top: 6px;
  isolation: isolate;
}

.pagination {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
  margin-top: 32px;
}

.page-link {
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  text-decoration: none;
  font-weight: 600;
  justify-self: start;
}

.page-link[rel="next"] {
  justify-self: end;
}

.page-link:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.page-status {
  color: var(--text-muted);
  font-size: 0.875rem;
}

.playlist-header {
  margin-bottom: 24px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--border);
}

.playlist-header h2 {
  margin: 4px 0 6px;
  font-size: clamp(1.4rem, 3vw, 2rem);
  letter-spacing: -0.02em;
  overflow-wrap: anywhere;
}

.eyebrow {
  margin: 0;
  font-size: 0.875rem;
}

.eyebrow a {
  color: var(--text-muted);
  text-decoration: none;
}

.eyebrow a:hover {
  color: var(--accent);
}

.playlist-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 16px;
  margin: 0;
  color: var(--text-muted);
  font-size: 0.9375rem;
}

.playlist-meta a {
  color: var(--text-muted);
}

.playlist-description {
  margin-top: 12px;
  color: var(--text-muted);
}

.playlist-description summary {
  cursor: pointer;
  font-size: 0.875rem;
}

.playlist-description p {
  max-width: 70ch;
  white-space: pre-line;
  overflow-wrap: anywhere;
}

/* --- Messages ---------------------------------------------------------------- */

.message,
.empty {
  padding: 48px 0;
  text-align: center;
  color: var(--text-muted);
}

.message h2 {
  margin: 0 0 8px;
  color: var(--text);
}

.message a {
  color: var(--accent);
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition: none !important;
    scroll-behavior: auto !important;
  }
}
