/* ─────────────────────────────────────────────────────────────────────────────
   Rove web viewer — design system + screens.
   Tokens are the exact values from the Figma "Design System" page.
   ───────────────────────────────────────────────────────────────────────────── */

:root {
  /* Surfaces */
  --bg: #0A0C10;
  --sunken: #07080B;
  --surface-1: #12151B;
  --surface-2: #171B22;
  --surface-3: #1E232C;
  --surface-hover: #232936;
  --brand-grad-a: #10192E;

  /* Borders */
  --border: #222732;
  --border-strong: #313846;

  /* Text */
  --text: #FFFFFF;
  --text-2: #9BA6B8;
  --text-3: #6B7585;
  --text-heading: #E8ECF4;

  /* Accent / brand */
  --accent: #4F8EF7;
  --accent-hover: #6BA0FF;
  --accent-press: #3B72D6;
  --accent-subtle: #1B2C4D;
  --link: #6BA0FF;
  --violet: #8B7CF6;

  /* Status */
  --success: #4ADE80;
  --success-subtle: #14351F;
  --warning: #F5B445;
  --warning-subtle: #3A2E14;
  --danger: #E05252;
  --danger-subtle: #3A1A1A;

  /* Radii */
  --r-sm: 6px;
  --r-md: 8px;
  --r-lg: 10px;
  --r-xl: 12px;
  --r-2xl: 20px;

  --nav-h: 72px;
  --pad-x: 48px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, p { margin: 0; }

.hidden { display: none !important; }

.screen { display: flex; flex-direction: column; min-height: 100vh; }
.screen.hidden { display: none !important; }

/* ── Nav ─────────────────────────────────────────────────────────────────── */
.nav {
  height: var(--nav-h);
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--pad-x);
  border-bottom: 1px solid var(--border);
}
.nav-actions { display: flex; align-items: center; gap: 12px; }

.brand { display: inline-flex; align-items: center; gap: 10px; }
.brand .mark {
  width: 32px; height: 32px; border-radius: 9px;
  background: linear-gradient(135deg, var(--accent), var(--violet));
  display: grid; place-items: center;
  font-weight: 700; font-size: 18px; color: #fff;
}
.brand .word { font-weight: 700; font-size: 20px; letter-spacing: -0.5px; color: var(--text-heading); }

.handle { color: var(--text-2); font-size: 13px; }

/* ── Buttons ─────────────────────────────────────────────────────────────── */
.btn {
  font: inherit;
  font-weight: 600;
  font-size: 15px;
  border: 1px solid transparent;
  border-radius: var(--r-lg);
  padding: 13px 24px;
  cursor: pointer;
  transition: background .15s ease, border-color .15s ease, opacity .15s ease, transform .08s ease;
  color: var(--text);
  background: transparent;
}
.btn:active { transform: scale(.985); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn:focus-visible { outline: 2px solid var(--accent-hover); outline-offset: 2px; }

.btn-block { display: block; width: 100%; }
.btn-compact { padding: 10px 18px; font-size: 14px; }

.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }

.btn-secondary {
  background: var(--surface-3);
  border-color: var(--border-strong);
  color: var(--text-heading);
}
.btn-secondary:hover:not(:disabled) { background: var(--surface-hover); }

.btn-ghost { color: var(--text-2); padding: 10px 18px; font-size: 14px; }
.btn-ghost:hover { color: var(--text); background: var(--surface-hover); }

.btn-sm {
  font-size: 13px; font-weight: 600;
  padding: 8px 14px; border-radius: var(--r-md);
  background: var(--surface-3); border: 1px solid var(--border-strong); color: var(--text-heading);
  cursor: pointer;
}
.btn-sm:hover:not(:disabled) { background: var(--surface-hover); }

.btn-watch { display: inline-flex; align-items: center; justify-content: center; white-space: nowrap; }
.btn-watch.is-requesting { background: var(--accent-subtle); border-color: transparent; color: var(--accent-hover); }

.link {
  font: inherit; font-size: 14px;
  background: none; border: 0; padding: 0;
  color: var(--link); cursor: pointer;
}
.link:hover { text-decoration: underline; }
.link:focus-visible { outline: 2px solid var(--accent-hover); outline-offset: 2px; border-radius: 3px; }

/* ── Auth ────────────────────────────────────────────────────────────────── */
.auth-body {
  position: relative;
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 24px;
  overflow: hidden;
}
.glow {
  position: absolute;
  top: -140px; left: 50%;
  transform: translateX(-50%);
  width: 1100px; height: 900px;
  border-radius: 50%;
  background: var(--accent);
  opacity: .12;
  filter: blur(180px);
  pointer-events: none;
}

.auth-card {
  position: relative;
  width: 440px;
  max-width: 100%;
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--r-2xl);
  padding: 40px;
}
.auth-view { display: flex; flex-direction: column; gap: 18px; }

.auth-view h1 { font-size: 32px; font-weight: 700; letter-spacing: -0.5px; color: var(--text); }
.auth-view .sub { color: var(--text-2); font-size: 14px; line-height: 22px; }

.field { display: flex; flex-direction: column; gap: 8px; }
.field label { color: var(--text-2); font-size: 14px; font-weight: 500; }

.field input {
  width: 100%;
  height: 48px;
  padding: 0 16px;
  font: inherit;
  font-size: 14px;
  color: var(--text-heading);
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  outline: none;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.field input::placeholder { color: var(--text-3); }
.field input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(79,142,247,.18); }
.field input.invalid { border-color: var(--danger); }

.field-hint { margin: 0; color: var(--text-3); font-size: 12px; line-height: 18px; }
.password-checks {
  list-style: none; margin: 0; padding: 0;
  display: flex; flex-wrap: wrap; gap: 4px 14px;
  font-size: 12px; color: var(--text-3);
}
.password-checks[hidden] { display: none; }
.password-checks li.ok { color: var(--success); }

.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 24px; }
.check { display: inline-flex; align-items: center; gap: 8px; color: var(--text-2); font-size: 14px; cursor: pointer; }
.check input { accent-color: var(--accent); width: 16px; height: 16px; }

.divider { display: flex; align-items: center; gap: 12px; color: var(--text-3); font-size: 13px; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--border); }

.footer-row { text-align: center; color: var(--text-2); font-size: 14px; }

.form-status { min-height: 20px; font-size: 13px; color: var(--danger); text-align: center; }
.form-status.ok { color: var(--success); }

/* ── GOV.UK error handling ────────────────────────────────────────────────
   Component markup, class names and behaviour follow the GOV.UK Design System
   (error summary + error message); the colours bind to Rove's status tokens. */
.govuk-visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  margin: 0; padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.govuk-error-summary {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 16px;
  background: var(--danger-subtle);
  border-left: 4px solid var(--danger);
  border-radius: var(--r-md);
}
.govuk-error-summary[hidden] { display: none; }
.govuk-error-summary:focus { outline: 3px solid var(--accent); outline-offset: 2px; }
.govuk-error-summary__title {
  font-size: 16px;
  font-weight: 600;
  line-height: 24px;
  color: var(--text-heading);
}
.govuk-error-summary__list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.govuk-error-summary__list a {
  color: var(--danger);
  font-size: 14px;
  font-weight: 500;
  line-height: 20px;
  text-decoration: underline;
}
.govuk-error-summary__list a:hover { color: var(--text-heading); }

.govuk-error-message {
  margin: 0;
  color: var(--danger);
  font-size: 14px;
  font-weight: 500;
  line-height: 20px;
}
.govuk-error-message[hidden] { display: none; }

.field.govuk-form-group--error input { border-color: var(--danger); }
.field input.govuk-input--error { border-color: var(--danger); }
.field input.govuk-input--error:focus { border-color: var(--danger); box-shadow: 0 0 0 3px rgba(224,82,82,.18); }

/* ── Picker ──────────────────────────────────────────────────────────────── */
.picker-body { flex: 1; width: 100%; max-width: 1000px; margin: 0 auto; padding: 40px var(--pad-x) 64px; }
.picker-body h1 { font-size: 32px; font-weight: 700; letter-spacing: -0.5px; }
.picker-body .sub { color: var(--text-2); margin-top: 8px; }
.picker-body h2 { font-size: 18px; font-weight: 700; margin: 36px 0 12px; color: var(--text-heading); }

.list { display: flex; flex-direction: column; gap: 10px; margin-top: 20px; }
.list h2 + & { margin-top: 12px; }

.list-row {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  padding: 14px 18px;
  transition: border-color .15s ease, background .15s ease;
}
.list-row:hover { border-color: var(--border-strong); }
.list-row.is-watchable { cursor: pointer; }
.list-row.is-watchable:hover { border-color: var(--accent); }
.list-row.is-watchable:focus-visible { outline: 2px solid var(--accent-hover); outline-offset: 1px; }
.list-main { display: flex; align-items: center; gap: 14px; min-width: 0; }
.avatar {
  flex: 0 0 auto;
  width: 40px; height: 40px; border-radius: 50%;
  background: var(--accent-subtle); color: var(--accent-hover);
  display: grid; place-items: center;
  font-weight: 700; font-size: 14px;
}
.list-name { font-weight: 600; color: var(--text); }
.list-sub { color: var(--text-3); font-size: 12px; margin-top: 2px; }
.list-actions { display: flex; align-items: center; gap: 10px; flex: 0 0 auto; }

.badge { font-size: 12px; font-weight: 600; padding: 4px 10px; border-radius: 999px; white-space: nowrap; }
.badge.online { background: var(--success-subtle); color: var(--success); }
.badge.degraded { background: var(--warning-subtle); color: var(--warning); }
.badge.offline { background: var(--surface-3); color: var(--text-3); }

.empty {
  color: var(--text-3);
  background: var(--surface-1);
  border: 1px dashed var(--border);
  border-radius: var(--r-xl);
  padding: 20px;
  text-align: center;
}

/* ── Account ─────────────────────────────────────────────────────────────── */
.account-body { flex: 1; width: 100%; max-width: 760px; margin: 0 auto; padding: 40px var(--pad-x) 64px; }
.account-body h1 { font-size: 32px; font-weight: 700; letter-spacing: -0.5px; }
.account-body .sub { color: var(--text-2); margin-top: 8px; }

.account-card {
  margin-top: 28px;
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  padding: 24px;
}
.account-card h2 { font-size: 18px; font-weight: 700; color: var(--text-heading); margin-bottom: 18px; }

.account-form { display: flex; flex-direction: column; gap: 18px; }
.account-form .btn-primary { align-self: flex-start; padding: 12px 22px; font-size: 14px; }
.field-optional { color: var(--text-3); font-weight: 400; }

/* ── Viewer ──────────────────────────────────────────────────────────────── */
#viewer-screen { align-items: center; padding: 16px; }
.viewer-bar {
  width: 100%; max-width: 1200px;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 4px;
}
.viewer-info { color: var(--text-2); font-size: 13px; }
.viewer-fps { display: none; color: var(--text-2); font-size: 13px; font-variant-numeric: tabular-nums; }

#player {
  position: relative;
  width: 100%; max-width: 1200px;
  aspect-ratio: 16 / 9;
  background: #000;
  border-radius: var(--r-xl);
  overflow: hidden;
  margin-top: 12px;
}
#player:fullscreen { width: 100vw; height: 100vh; max-width: none; aspect-ratio: auto; border-radius: 0; margin: 0; }

.video-surface { position: absolute; inset: 0; width: 100%; height: 100%; background: #000; object-fit: contain; display: block; }

#controls-bar {
  position: absolute; left: 0; right: 0; bottom: 0;
  display: flex; align-items: center; gap: 6px;
  padding: 26px 12px 10px;
  background: linear-gradient(to top, rgba(0,0,0,.78), transparent);
  opacity: 1; transition: opacity .25s ease; z-index: 20;
}
#player.idle #controls-bar { opacity: 0; pointer-events: none; }

.ctrl-btn {
  flex: 0 0 auto;
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px;
  padding: 0; border: 0; border-radius: var(--r-sm);
  background: transparent; color: #fff; cursor: pointer;
}
.ctrl-btn:hover { background: rgba(255,255,255,.16); }
.ctrl-btn:focus-visible { outline: 2px solid var(--accent-hover); outline-offset: 1px; }
.ctrl-btn svg { flex: 0 0 auto; width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.ctrl-btn.is-active { color: var(--accent-hover); }
.ctrl-btn .icon-off { display: none; }
.ctrl-btn.is-active .icon-on { display: none; }
.ctrl-btn.is-active .icon-off { display: block; }

.ctrl-btn-label {
  width: auto; padding: 0 12px;
  font-size: 12px; font-weight: 600; color: #fff;
  border: 1px solid rgba(255,255,255,.35);
}
.ctrl-btn-label.on { color: var(--accent-hover); border-color: var(--accent-hover); background: rgba(79,142,247,.15); }

#vol-wrap { display: inline-flex; align-items: center; flex: 0 1 130px; min-width: 48px; padding: 0 4px; }
#vol-slider { width: 100%; accent-color: var(--accent); cursor: pointer; }
.controls-spacer { flex: 1 1 auto; }

#sound-blocked {
  position: absolute; top: 12px; right: 12px; z-index: 30;
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 16px;
  font: inherit; font-size: 13px; font-weight: 600; color: #fff;
  background: rgba(79,142,247,.92); border: 0; border-radius: var(--r-md);
  cursor: pointer; box-shadow: 0 4px 16px rgba(0,0,0,.4);
}
#sound-blocked svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.status-line { min-height: 16px; margin: 10px 0; color: var(--text-3); font-size: 12px; }

#stats-overlay {
  display: none; position: absolute; top: 8px; left: 8px; z-index: 10; pointer-events: none;
  font-family: "Cascadia Code", Consolas, "SF Mono", monospace;
  font-size: 11px; line-height: 1.55; white-space: pre;
  color: #7fd4ff;
  background: rgba(10,12,16,.68);
  border: 1px solid rgba(79,142,247,.25);
  border-radius: var(--r-sm);
  padding: 6px 10px;
}

/* ── Toast ───────────────────────────────────────────────────────────────── */
#toast {
  position: fixed; left: 50%; bottom: 24px; z-index: 100;
  transform: translateX(-50%) translateY(20px);
  padding: 10px 18px;
  font-size: 13px;
  color: #f0a0a0;
  background: #2a1a1a;
  border: 1px solid var(--danger);
  border-radius: var(--r-lg);
  opacity: 0; pointer-events: none;
  transition: opacity .2s ease, transform .2s ease;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ── Mobile ──────────────────────────────────────────────────────────────── */
@media (max-width: 640px) {
  :root { --nav-h: 64px; --pad-x: 20px; }
  .auth-body { align-items: flex-start; padding: 24px 20px; }
  .auth-card { padding: 24px; border-radius: 16px; }
  .auth-view h1 { font-size: 26px; }
  .picker-body { padding: 24px 20px 48px; }
  .picker-body h1 { font-size: 26px; }
  .account-body { padding: 24px 20px 48px; }
  .account-body h1 { font-size: 26px; }
  .account-card { padding: 18px; }
  .account-form .btn-primary { align-self: stretch; }
  .list-row { padding: 12px 14px; }
  .list-actions .badge { display: none; }
  #viewer-screen { padding: 8px; }
  .ctrl-btn-label { display: none; }
  #vol-wrap { flex-basis: 90px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}

/* ── Premium / billing ───────────────────────────────────────────────────── */
.btn-upgrade {
  background: linear-gradient(135deg, var(--accent), var(--violet));
  color: #fff;
  border: 0;
  padding: 10px 18px;
  font-size: 14px;
}
.btn-upgrade:hover:not(:disabled) { filter: brightness(1.08); }

.plan-badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .3px;
  text-transform: uppercase;
  background: var(--surface-3);
  color: var(--text-2);
}
.plan-badge.premium {
  background: linear-gradient(135deg, var(--accent), var(--violet));
  color: #fff;
}

.plan-row { display: flex; align-items: center; gap: 14px; margin-bottom: 18px; }
.plan-desc { color: var(--text-2); font-size: 14px; line-height: 20px; }

.upsell-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
  padding: 16px 20px;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-xl);
  background:
    radial-gradient(120% 140% at 0% 0%, rgba(79,142,247,.18), transparent 55%),
    var(--surface-1);
}
.upsell-banner strong { display: block; color: var(--text-heading); font-size: 15px; }
.upsell-banner span { color: var(--text-2); font-size: 13px; }

.premium-body { flex: 1; width: 100%; max-width: 1000px; margin: 0 auto; padding: 48px var(--pad-x) 72px; }
.premium-hero { text-align: center; max-width: 620px; margin: 0 auto 40px; }
.premium-hero h1 { font-size: 40px; font-weight: 700; letter-spacing: -0.8px; margin-top: 16px; }
.premium-hero .sub { color: var(--text-2); font-size: 16px; line-height: 24px; margin-top: 12px; }

.premium-grid { display: grid; grid-template-columns: 1.2fr 1fr; gap: 24px; align-items: start; }

.premium-features-card,
.premium-card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--r-2xl);
  padding: 28px;
}
.premium-features-card h2 { font-size: 18px; font-weight: 700; color: var(--text-heading); margin-bottom: 18px; }

.premium-features { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.premium-features li { position: relative; padding-left: 28px; color: var(--text); font-size: 14px; line-height: 20px; }
.premium-features li::before {
  content: "";
  position: absolute; left: 0; top: 3px;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: var(--accent-subtle);
  box-shadow: inset 0 0 0 2px var(--accent);
}
.premium-features.compact li { font-size: 13px; }

.premium-free-note { margin-top: 22px; color: var(--text-3); font-size: 13px; line-height: 19px; }

.premium-card { position: sticky; top: 24px; display: flex; flex-direction: column; gap: 18px; }

.price { display: flex; align-items: baseline; gap: 8px; }
.price-amount { font-size: 30px; font-weight: 700; color: var(--text-heading); letter-spacing: -0.5px; }
.price .per { color: var(--text-3); font-size: 13px; }

.premium-note { color: var(--text-3); font-size: 12px; line-height: 18px; text-align: center; }
.premium-card .form-status { margin-top: 4px; }

/* ── Upsell modal ────────────────────────────────────────────────────────── */
.modal { position: fixed; inset: 0; z-index: 200; display: grid; place-items: center; padding: 24px; }
.modal-scrim { position: absolute; inset: 0; background: rgba(7,8,11,.72); backdrop-filter: blur(3px); }
.modal-card {
  position: relative;
  width: 420px; max-width: 100%;
  background: var(--surface-1);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-2xl);
  padding: 28px;
  display: flex; flex-direction: column; gap: 14px;
  box-shadow: 0 24px 60px rgba(0,0,0,.5);
}
.modal-card h2 { font-size: 22px; font-weight: 700; color: var(--text-heading); letter-spacing: -0.4px; }
.modal-card > p { color: var(--text-2); font-size: 14px; line-height: 20px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 6px; }

@media (max-width: 640px) {
  .premium-body { padding: 28px 20px 56px; }
  .premium-hero h1 { font-size: 30px; }
  .premium-grid { grid-template-columns: 1fr; }
  .premium-card { position: static; }
  .upsell-banner { flex-direction: column; align-items: stretch; }
  .modal-actions { flex-direction: column-reverse; }
  .modal-actions .btn { width: 100%; }
}
