/* ==========================================================================
   Sky News TV — mobile PWA base layout.
   Owned by the Lead. Controls, cast guide and install sheet are styled in
   css/ui.css (owned by mobile-ui).
   Targets: iPhone SE/13/15 (320-430 pt wide), Android Pixel/Galaxy, portrait
   and landscape, standalone home-screen mode and normal browser tabs.
   ========================================================================== */

:root {
  --bg: #04070b;
  --bg-deep: #020407;
  --panel: rgba(9, 16, 25, 0.94);
  --panel-strong: #0b1622;
  --ink: #f5f9fc;
  --ink-dim: #d3dee8;
  --muted: #9fb0c2;
  --accent: #35c2f2;
  --accent-ink: #041720;
  --live: #e11d2e;
  --danger: #ff9b8c;
  --radius: 14px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, Roboto, Arial, sans-serif;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: #000;
  color: var(--ink);
  font-family: var(--font);
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}

body { cursor: default; }

.app {
  position: fixed;
  inset: 0;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  background: var(--bg-deep);
}

/* ------------------------------- video stage ---------------------------- */

.stage {
  position: absolute;
  inset: 0;
  background: #000;
}

.player-container {
  position: absolute;
  inset: 0;
  background: #000;
}

.player-container iframe,
.player-container > div {
  position: absolute !important;
  inset: 0 !important;
  width: 100% !important;
  height: 100% !important;
  border: 0;
  display: block;
  /* Taps can never reach YouTube; only our controls react. */
  pointer-events: none !important;
}

.stage-shade {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.55) 0%, rgba(0, 0, 0, 0) 26%);
  opacity: 0;
  transition: opacity 200ms ease;
}

body.controls-visible .stage-shade { opacity: 1; }

/* --------------------------- tap-to-watch card -------------------------- */

.tap-to-watch {
  position: absolute;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: calc(24px + var(--safe-top)) 22px calc(24px + var(--safe-bottom));
  background:
    radial-gradient(circle at 50% 38%, rgba(53, 194, 242, 0.18) 0%, rgba(4, 7, 11, 0) 55%),
    linear-gradient(180deg, #071019 0%, #03060a 100%);
  transition: opacity 260ms ease, visibility 260ms ease;
}

.tap-to-watch.is-hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.tap-card {
  width: min(420px, 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 10px;
}

.tap-logo {
  width: 88px;
  height: 88px;
  border-radius: 22px;
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.5);
}

.tap-title {
  margin: 6px 0 0;
  font-size: clamp(26px, 7.2vw, 34px);
  font-weight: 800;
  letter-spacing: -0.02em;
}

.tap-sub {
  margin: 0 0 16px;
  color: var(--muted);
  font-size: clamp(15px, 4.2vw, 18px);
}

.big-play {
  appearance: none;
  border: 0;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  width: min(320px, 82vw);
  min-height: 68px;
  padding: 12px 18px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-ink);
  font-family: inherit;
  font-size: clamp(20px, 5.6vw, 26px);
  font-weight: 800;
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.5), 0 0 0 8px rgba(53, 194, 242, 0.12);
  touch-action: manipulation;
  transition: transform 90ms ease, opacity 150ms ease;
}

.big-play svg { width: 1.05em; height: 1.05em; }
.big-play:active { transform: scale(0.98); }
.big-play:disabled { opacity: 0.55; cursor: default; }
.big-play:focus-visible { outline: 3px solid #fff; outline-offset: 4px; }

.tap-hint {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: clamp(13px, 3.6vw, 15px);
}

/* ------------------------------ status card ----------------------------- */

.status-overlay {
  position: absolute;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 22px;
  background: rgba(3, 7, 12, 0.93);
  backdrop-filter: blur(6px);
  text-align: center;
}

.status-card {
  width: min(430px, 100%);
  padding: 26px 22px 24px;
  border-radius: 22px;
  background: var(--panel);
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.6);
}

.spinner {
  width: 42px;
  height: 42px;
  margin: 0 auto 18px;
  border-radius: 50%;
  border: 4px solid rgba(255, 255, 255, 0.14);
  border-top-color: var(--accent);
  animation: spin 900ms linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.status-overlay h2 {
  margin: 0 0 8px;
  font-size: clamp(22px, 6vw, 28px);
  font-weight: 700;
}

.status-overlay p {
  margin: 0 0 16px;
  color: var(--muted);
  font-size: clamp(15px, 4.2vw, 18px);
  line-height: 1.45;
}

.status-overlay.is-error .spinner { display: none; }
.status-overlay.is-error .status-card { border-color: rgba(255, 155, 140, 0.4); }

/* --------------------------------- buttons ----------------------------- */

.btn {
  appearance: none;
  border: 1px solid rgba(255, 255, 255, 0.22);
  background: rgba(14, 24, 36, 0.9);
  color: var(--ink);
  border-radius: 14px;
  min-height: 52px;
  padding: 12px 16px;
  font-family: inherit;
  font-size: 17px;
  font-weight: 650;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  touch-action: manipulation;
}

.btn:active { transform: scale(0.985); }
.btn:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

.btn-primary { background: #fff; border-color: #fff; color: #06131c; }
.btn-accent { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }

/* ---------------------------- offline banner ---------------------------- */

.offline-banner {
  position: absolute;
  top: calc(10px + var(--safe-top));
  left: 50%;
  transform: translateX(-50%);
  z-index: 45;
  max-width: calc(100vw - 32px);
  padding: 9px 14px;
  border-radius: 999px;
  background: rgba(255, 155, 140, 0.16);
  border: 1px solid rgba(255, 155, 140, 0.45);
  color: #ffd9d3;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ------------------------- recents / cast frames ------------------------ */

.recents-screen,
.cast-guide {
  position: absolute;
  inset: 0;
  z-index: 50;
  overflow: hidden;
  background: var(--bg);
}

.cast-guide { z-index: 60; }

/* -------------------------- landscape / short --------------------------- */
@media (orientation: landscape) and (max-height: 480px) {
  .tap-logo { width: 64px; height: 64px; border-radius: 16px; }
  .tap-title { font-size: 24px; }
  .tap-sub { margin-bottom: 10px; font-size: 14px; }
  .big-play { min-height: 58px; font-size: 20px; width: min(300px, 60vw); }
  .tap-hint { font-size: 12px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
  }
}
