/* ============================================================
   SafeTube TV — dual-broadcast player
   Deck A = phosphor cyan · Deck B = amber (also used by the
   Android app, so the two products stay recognisably the same)
   Surfaces use the brand navy from the marketing site.
   TV-safe: big type, fat focus rings, overscan margins
   ============================================================ */

:root {
  --bg: #070b24;
  --panel: #0e1540;
  --panel-2: #161f52;
  --ink: #f2f5ff;
  --ink-dim: #8e9ac8;
  --line: #232f6b;
  --cyan: #2de2e6;
  --amber: #ffc61a;
  --danger: #ff5468;
  --radius: 18px;
  --font-display: "Baloo 2", "Trebuchet MS", cursive;
  --font-body: "Nunito", "Segoe UI", sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body { height: 100%; }

body {
  background:
    radial-gradient(1200px 600px at 18% -10%, rgba(45, 226, 230, 0.09), transparent 60%),
    radial-gradient(1200px 600px at 82% -10%, rgba(255, 198, 26, 0.09), transparent 60%),
    var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 18px;
  overflow: hidden;
  /* overscan safety for TV panels */
  padding: 1.6vh 2vw;
  display: flex;
  flex-direction: column;
  gap: 1.2vh;
  cursor: default;
}

/* faint CRT scanlines over everything, very subtle */
.scanlines {
  pointer-events: none;
  position: fixed;
  inset: 0;
  background: repeating-linear-gradient(
    to bottom,
    rgba(255, 255, 255, 0.015) 0px,
    rgba(255, 255, 255, 0.015) 1px,
    transparent 1px,
    transparent 4px
  );
}

/* ---------------- top bar ---------------- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 0.4vw;
  gap: 1vw;
  flex-shrink: 0;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.65em;
  text-decoration: none;
  color: inherit;
  flex-shrink: 0;
}
.brand-logo {
  width: clamp(36px, 3.2vw, 48px);
  height: clamp(36px, 3.2vw, 48px);
  border-radius: 14px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.35);
  flex-shrink: 0;
}
.brand-text {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(22px, 2.5vw, 36px);
  letter-spacing: -0.01em;
  line-height: 1;
}
/* matches the marketing footer: white "Safe", sunny "Tube" */
.brand-safe { color: #fff; }
.brand-tube { color: var(--amber); }
.brand-tv {
  margin-left: 0.5em;
  font-size: 0.42em;
  font-weight: 800;
  color: var(--bg);
  background: var(--ink);
  padding: 0.2em 0.5em;
  border-radius: 999px;
  vertical-align: middle;
}

/* lock / unlock switch */
.lock-switch {
  display: flex;
  align-items: center;
  gap: 0.5em;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(12px, 1.05vw, 16px);
  letter-spacing: 0.08em;
  color: var(--ink);
  background: var(--panel-2);
  border-radius: 999px;
  padding: 0.55em 1.1em;
  cursor: pointer;
  --accent: var(--cyan);
  --accent-soft: rgba(45, 226, 230, 0.16);
}
.lock-switch.unlocked {
  color: var(--bg);
  background: var(--danger);
  box-shadow: 0 0 22px rgba(255, 84, 104, 0.45);
  --accent: #fff;
  --accent-soft: rgba(255, 255, 255, 0.25);
  animation: pulse 1.6s ease-in-out infinite;
}
@keyframes pulse {
  50% { box-shadow: 0 0 34px rgba(255, 84, 104, 0.7); }
}

.keyhints { display: flex; gap: 1.6em; color: var(--ink-dim); font-size: clamp(13px, 1.1vw, 17px); }
.hint b {
  color: var(--ink);
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0.1em 0.5em;
  margin-right: 0.35em;
  font-weight: 600;
}

/* ---------------- decks layout ---------------- */

.decks {
  flex: 1;
  min-height: 0;
  display: flex;
  gap: 1vw;
}

.divider {
  width: 2px;
  border-radius: 2px;
  background: linear-gradient(to bottom, var(--cyan), var(--amber));
  opacity: 0.5;
}

.deck {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
.deck-a { --accent: var(--cyan);  --accent-soft: rgba(45, 226, 230, 0.16); }
.deck-b { --accent: var(--amber); --accent-soft: rgba(255, 198, 26, 0.16); }

.deck-label {
  display: flex;
  align-items: center;
  gap: 0.6em;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(12px, 1.05vw, 16px);
  letter-spacing: 0.12em;
  color: var(--accent);
  padding: 1vh 1.2vw 0.6vh;
}
.deck-dot {
  width: 0.65em; height: 0.65em;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 10px var(--accent);
}

.deck-body {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 0 1.2vw 1.4vh;
  gap: 1vh;
}

.deck-heading {
  color: var(--ink-dim);
  font-size: clamp(13px, 1.1vw, 17px);
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.deck-heading em { color: var(--ink); font-style: normal; }

/* ---------------- focusable tiles ---------------- */

.focusable {
  outline: none;
  border: 3px solid transparent;
  transition: transform 0.12s ease, border-color 0.12s ease, box-shadow 0.12s ease;
}
.focusable:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.6), 0 0 24px var(--accent-soft), 0 0 14px var(--accent-soft) inset;
  transform: scale(1.03);
  z-index: 2;
}

/* channel grid */
.grid {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 1vh 0.8vw;
  align-content: start;
  padding: 4px;
  scrollbar-width: none;
}
.grid::-webkit-scrollbar { display: none; }

.channel-tile {
  background: var(--panel-2);
  border-radius: var(--radius);
  padding: 1.6vh 0.8vw;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.8vh;
}
.channel-glyph {
  width: 2.4em; height: 2.4em;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(20px, 2vw, 30px);
  color: var(--bg);
  background: var(--accent);
  border-radius: 14px;
  box-shadow: 0 6px 22px var(--accent-soft);
}
.channel-name {
  font-weight: 600;
  font-size: clamp(14px, 1.2vw, 19px);
  line-height: 1.25;
  overflow-wrap: anywhere;
}

/* video grid */
.video-tile {
  background: var(--panel-2);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
}
/* explicit thumbnail height — no aspect-ratio or percentage-padding
   tricks, which collapse on some TV browsers. flex:none and the
   min-height on the img itself guard against old flex engines
   shrinking the image inside the tile's column layout. */
.thumb-box {
  flex: none;
  width: 100%;
  height: 6.5vw;
  min-height: 96px;
  background: #000;
  overflow: hidden;
  /* tile no longer clips children, so round our own top corners */
  border-radius: var(--radius) var(--radius) 0 0;
}
.video-thumb {
  width: 100%;
  height: 100%;
  min-height: 96px;
  object-fit: cover;
  display: block;
}
.video-title {
  padding: 0.9vh 0.7vw 1.1vh;
  font-size: clamp(13px, 1.05vw, 17px);
  font-weight: 500;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: 2.6em;
  max-height: 2.6em;
}

/* ---------------- player ---------------- */

.player-wrap {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 1vh;
}
.player-frame {
  flex: 1;
  min-height: 0;
  background: #000;
  border-radius: var(--radius);
  overflow: hidden;
  position: relative;
  border: 1px solid var(--line);
}
.player-frame iframe { position: absolute; inset: 0; width: 100%; height: 100%; }

.now-title {
  font-size: clamp(14px, 1.15vw, 18px);
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.controls { display: flex; gap: 0.6vw; flex-wrap: wrap; }
.btn {
  font-family: var(--font-body);
  font-weight: 700;
  font-size: clamp(13px, 1.05vw, 17px);
  color: var(--ink);
  background: var(--panel-2);
  border-radius: 999px;
  padding: 1vh 1.2vw;
  cursor: pointer;
  user-select: none;
}
.btn .ico { margin-right: 0.4em; }
.btn-accent { background: var(--accent); color: var(--bg); }

/* muted-state badge on the player */
.audio-badge {
  position: absolute;
  top: 10px; right: 10px;
  z-index: 3;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.08em;
  padding: 0.4em 0.9em;
  border-radius: 8px;
  background: rgba(10, 13, 20, 0.85);
  color: var(--accent);
  border: 1px solid var(--accent);
  display: none;
}
.audio-badge.show { display: block; }

/* ---------------- status / errors ---------------- */

.status {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.4vh;
  text-align: center;
  color: var(--ink-dim);
  padding: 2vh 2vw;
}
.status .big {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(16px, 1.6vw, 24px);
  color: var(--ink);
}
.status.error .big { color: var(--danger); }

.spinner {
  width: 44px; height: 44px;
  border-radius: 50%;
  border: 4px solid var(--line);
  border-top-color: var(--accent);
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* view bar: back button + heading above video grids */
.view-bar { display: flex; align-items: center; gap: 0.8vw; }
.view-bar .btn { padding: 0.6vh 0.8vw; flex-shrink: 0; }
.view-bar .deck-heading { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------------- search row ---------------- */

.search-row { display: flex; gap: 0.5vw; }
.search-input {
  flex: 1;
  min-width: 0;
  font-family: var(--font-body);
  font-size: clamp(14px, 1.15vw, 18px);
  color: var(--ink);
  background: var(--panel-2);
  border-radius: 12px;
  padding: 1vh 1vw;
}
.search-input::placeholder { color: var(--ink-dim); }
.search-note {
  color: var(--ink-dim);
  font-size: clamp(12px, 1vw, 15px);
}
.search-note em { color: var(--amber); font-style: normal; }

/* ---------------- passcode modal ---------------- */

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(6, 10, 32, 0.85);
  backdrop-filter: blur(3px);
}
.modal-backdrop[hidden] { display: none; }

.modal {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 3.4vh 3vw;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2.2vh;
  --accent: var(--cyan);
  --accent-soft: rgba(45, 226, 230, 0.16);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6);
}
.modal-title {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(16px, 1.55vw, 23px);
  letter-spacing: 0.1em;
  color: var(--cyan);
}
.modal-hint { color: var(--ink-dim); font-size: clamp(12px, 1vw, 15px); }

.pin-dots { display: flex; gap: 1em; }
.pin-dots span {
  width: 1em; height: 1em;
  border-radius: 50%;
  border: 2px solid var(--ink-dim);
  transition: background 0.1s, border-color 0.1s;
}
.pin-dots span.filled {
  background: var(--cyan);
  border-color: var(--cyan);
  box-shadow: 0 0 12px rgba(45, 226, 230, 0.6);
}
.pin-dots.wrong span { border-color: var(--danger); }
.modal.shake { animation: shake 0.4s; }
@keyframes shake {
  20% { transform: translateX(-10px); }
  40% { transform: translateX(10px); }
  60% { transform: translateX(-7px); }
  80% { transform: translateX(7px); }
}

.keypad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.9vh 0.5vw;
}
.key {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(16px, 1.6vw, 24px);
  color: var(--ink);
  background: var(--panel-2);
  border-radius: 14px;
  width: 2.6em;
  height: 1.9em;
  cursor: pointer;
}

/* ---------------- cinema (fullscreen) mode ----------------
   Just the two screens edge to edge: no chrome, no scrolling. */

body.cinema { padding: 0; gap: 0; }
body.cinema .topbar,
body.cinema .deck-label,
body.cinema .deck-heading,
body.cinema .view-bar,
body.cinema .search-row,
body.cinema .search-note,
body.cinema .now-title,
body.cinema .controls,
body.cinema .divider,
body.cinema .site-footer { display: none; }
body.cinema .decks { gap: 0; }
body.cinema .deck {
  border: none;
  border-radius: 0;
  background: #000;
  animation: none;
}
body.cinema .deck-body { padding: 0; gap: 0; }
body.cinema .player-frame { border: none; border-radius: 0; }
body.cinema .grid { overflow: hidden; padding: 1vh 1vw; }

/* exit button: hidden normally, floats over the seam in cinema mode */
.cinema-exit { display: none; }
body.cinema .cinema-exit {
  display: block;
  position: fixed;
  top: 12px;
  left: 50%;
  margin-left: -90px;
  z-index: 20;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 14px;
  letter-spacing: 0.08em;
  color: var(--ink);
  background: rgba(7, 11, 36, 0.8);
  border-radius: 999px;
  padding: 0.7em 1.3em;
  cursor: pointer;
  opacity: 0.45;
  --accent: var(--cyan);
  --accent-soft: rgba(45, 226, 230, 0.16);
}
body.cinema .cinema-exit:focus { opacity: 1; }

/* entrance */
.deck { animation: rise 0.5s ease both; }
.deck-b { animation-delay: 0.12s; }
@keyframes rise {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: none; }
}

/* ---------------- site footer ---------------- */

.site-footer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6em;
  flex-shrink: 0;
  padding: 0.4vh 0;
  color: var(--ink-dim);
  font-size: clamp(12px, 1vw, 15px);
}
.footer-link {
  color: var(--amber);
  text-decoration: none;
  font-weight: 600;
}
.footer-link:hover,
.footer-link:focus {
  text-decoration: underline;
}
.footer-sep { opacity: 0.5; }
