:root {
  --bg: #000;
  --fg: #f2f2ee;
  --dim: rgba(242, 242, 238, 0.62);
  --accent: #ff3b2f;
  --glass: rgba(0, 0, 0, 0.45);
  --mono: "JetBrains Mono", ui-monospace, monospace;
  --display: "Metal Mania", "Archivo Black", Impact, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--fg); font-family: var(--mono); overflow: hidden; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
a { color: inherit; }

.stage { position: fixed; inset: 0; display: grid; place-items: center; }

/* Blurred poster behind vertical videos so the frame never feels empty */
.backdrop {
  position: absolute; inset: -40px;
  background-size: cover; background-position: center;
  filter: blur(40px) brightness(0.35) saturate(1.2);
  transition: background-image 0.6s;
}

.screen { position: relative; width: 100%; height: 100%; display: grid; place-items: center; }
.screen .media {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: contain; display: block; background: transparent;
  opacity: 0;
}
.screen .media.live { opacity: 1; }

/* TV static between clips */
.static {
  position: absolute; inset: 0; width: 100%; height: 100%; z-index: 2;
  image-rendering: pixelated; opacity: 0; pointer-events: none;
  transition: opacity 0.08s linear;
}
.static.on { opacity: 1; }

/* Color bars when a clip is slow to load */
.bars { position: absolute; inset: 0; z-index: 2; display: flex; flex-direction: column; background: #000; }
.bars[hidden] { display: none; }
.bars > div { display: flex; }
.bars i { flex: 1; }
.bars-top { flex: 67; }
.bars-mid { flex: 8; }
.bars-bot { flex: 25; }
.standby {
  position: absolute; left: 50%; top: 30%; transform: translate(-50%, -50%); margin: 0;
  padding: 10px 22px; background: #000; color: #fff; font-family: var(--mono);
  font-size: clamp(14px, 3vw, 24px); letter-spacing: 0.2em; text-transform: uppercase; white-space: nowrap;
}

/* Scanline + vignette for the "TV" feel */
.stage::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background:
    repeating-linear-gradient(0deg, rgba(255,255,255,0.025) 0 1px, transparent 1px 3px),
    radial-gradient(ellipse at center, transparent 55%, rgba(0,0,0,0.65) 100%);
}

.progress { position: absolute; left: 0; right: 0; top: 0; height: 3px; background: rgba(255,255,255,0.12); z-index: 3; }
.progress span { display: block; height: 100%; width: 0; background: var(--accent); }

.top {
  position: absolute; top: 0; left: 0; right: 0; z-index: 3;
  display: flex; justify-content: space-between; align-items: center;
  padding: max(18px, env(safe-area-inset-top)) 20px 18px;
  background: linear-gradient(to bottom, rgba(0,0,0,0.6), transparent);
}
.wordmark { display: flex; flex-direction: column; text-decoration: none; line-height: 1; }
.wm-main { font-family: var(--display); font-size: 34px; letter-spacing: 0.01em; text-shadow: 0 2px 12px rgba(0,0,0,0.6); }
.wm-main em { font-style: normal; color: var(--accent); }
.wm-sub { font-family: var(--mono); font-size: 11px; letter-spacing: 0.32em; text-transform: lowercase; color: var(--dim); margin: 6px 0 0 3px; }
.badge { display: flex; align-items: center; gap: 8px; font-size: 12px; letter-spacing: 0.12em; color: var(--dim); }
.badge i { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); animation: pulse 1.6s infinite; }
@keyframes pulse { 50% { opacity: 0.25; } }

.meta {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 3;
  padding: 80px 20px calc(84px + env(safe-area-inset-bottom));
  background: linear-gradient(to top, rgba(0,0,0,0.85), transparent);
  pointer-events: none;
}
.meta > * { max-width: 720px; }
.caption {
  margin: 0 0 10px; font-size: 14px; line-height: 1.5; white-space: pre-line;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.meta-row { display: flex; gap: 18px; font-size: 12px; color: var(--dim); }
.meta-row a { pointer-events: auto; text-decoration: none; border-bottom: 1px solid currentColor; }

.controls {
  position: absolute; z-index: 4; left: 50%; transform: translateX(-50%);
  bottom: calc(18px + env(safe-area-inset-bottom));
  display: flex; gap: 4px; padding: 6px; border-radius: 999px;
  background: var(--glass); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255,255,255,0.1);
}
.controls button { width: 42px; height: 42px; border-radius: 50%; font-size: 17px; line-height: 1; transition: background 0.15s; }
.controls button:hover { background: rgba(255,255,255,0.12); }
.controls button.on { color: var(--accent); }

/* Auto-hide chrome when idle */
.idle .top, .idle .meta, .idle .controls { opacity: 0; transition: opacity 0.6s; }
.idle { cursor: none; }
.top, .meta, .controls { transition: opacity 0.25s; }

.start {
  position: absolute; z-index: 5; display: flex; flex-direction: column; align-items: center; gap: 14px;
  font-size: 13px; letter-spacing: 0.1em; text-transform: uppercase;
}
.start .play {
  width: 84px; height: 84px; border-radius: 50%; display: grid; place-items: center;
  background: var(--accent); font-size: 30px; padding-left: 6px; box-shadow: 0 0 60px rgba(255,59,47,0.5);
}
.start[hidden] { display: none; }


/* Browse grid */
.grid { position: fixed; inset: 0; z-index: 10; background: rgba(0,0,0,0.94); overflow-y: auto; padding: 0 16px 40px; }
.grid[hidden] { display: none; }
.grid-head {
  position: sticky; top: 0; display: flex; justify-content: space-between; align-items: center;
  padding: 18px 4px; background: rgba(0,0,0,0.94); z-index: 1;
}
.grid-head h2 { margin: 0; font-family: var(--display); font-weight: 400; font-size: 20px; }
.grid-head h2 span { font-family: var(--mono); font-size: 12px; color: var(--dim); margin-left: 8px; }
.grid-head button { font-size: 20px; width: 40px; height: 40px; }
.grid-items { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 6px; }
.tile { position: relative; aspect-ratio: 4 / 5; background: #111 center / cover no-repeat; border-radius: 3px; overflow: hidden; }
.tile::after { content: ""; position: absolute; inset: 0; background: rgba(0,0,0,0); transition: background 0.15s; }
.tile:hover::after { background: rgba(0,0,0,0.3); }
.tile .type { position: absolute; top: 6px; right: 8px; font-size: 13px; text-shadow: 0 1px 4px #000; z-index: 1; }
.tile.current { outline: 2px solid var(--accent); outline-offset: -2px; }

@media (max-width: 520px) {
  .wm-main { font-size: 26px; }
  .wm-sub { font-size: 10px; }
  .controls button { width: 38px; height: 38px; font-size: 15px; }
  .grid-items { grid-template-columns: repeat(3, 1fr); gap: 3px; }
}

/* Phone held sideways: picture fills the screen, captions out of the way */
@media (orientation: landscape) and (max-height: 500px) {
  .meta { display: none; }
  .top { padding: max(10px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) 10px max(16px, env(safe-area-inset-left)); }
  .wm-main { font-size: 22px; }
  .wm-sub { font-size: 9px; margin-top: 3px; }
  .controls { bottom: max(10px, env(safe-area-inset-bottom)); }
  .controls button { width: 36px; height: 36px; font-size: 15px; }
  .backdrop { display: none; }
}

.fs-hint {
  position: absolute; z-index: 6; left: 50%; top: 50%; transform: translate(-50%, -50%);
  padding: 10px 18px; border-radius: 999px; background: rgba(0,0,0,0.7);
  border: 1px solid rgba(255,255,255,0.2); font-size: 12px; letter-spacing: 0.15em;
  text-transform: uppercase; pointer-events: none; animation: hintfade 3.5s forwards;
}
.fs-hint[hidden] { display: none; }
@keyframes hintfade { 0%, 70% { opacity: 1; } 100% { opacity: 0; } }
