/* ---------- Top navigation ---------- */
.nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--nav-h);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 var(--page-x);
  z-index: 100;
  /* A top scrim (cheap gradient) instead of a live backdrop-filter blur —
     blur would repaint the whole nav strip every scroll frame on a TV GPU. */
  background: linear-gradient(to bottom, rgba(8, 9, 16, 0.9), rgba(8, 9, 16, 0));
  transition: background var(--t-med) var(--ease), box-shadow var(--t-med) var(--ease);
}
.nav.solid {
  background: rgba(10, 11, 20, 0.97);
  box-shadow: 0 1px 0 var(--line);
}

.nav-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.3rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  margin-right: 20px;
  border-radius: var(--radius-s);
  padding: 6px 10px;
}
.nav-logo .logo-mark {
  width: 26px;
  height: 26px;
  border-radius: 8px;
  background: conic-gradient(from 210deg, #6c58ff, #b76cff, #4ea3ff, #6c58ff);
  box-shadow: 0 0 18px rgba(124, 100, 255, 0.55);
}

.nav-item {
  padding: 8px 16px;
  border-radius: 999px;
  color: var(--text-dim);
  font-weight: 600;
  font-size: 0.95rem;
  transition:
    color var(--t-fast),
    background var(--t-fast),
    box-shadow var(--t-fast);
  white-space: nowrap;
}
.nav-item:hover {
  color: var(--text);
}
.nav-item.active {
  color: var(--text);
  background: var(--surface);
}
.nav-item:focus {
  color: #0b0c14;
  background: #fff;
  box-shadow: var(--focus-ring);
}

.nav-spacer {
  flex: 1;
}

.nav-profile {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 5px 14px 5px 6px;
  border-radius: 999px;
  background: var(--surface);
  font-weight: 600;
  font-size: 0.9rem;
  transition:
    background var(--t-fast),
    box-shadow var(--t-fast);
}
.nav-profile:hover {
  background: var(--surface-hover);
}
.nav-profile:focus {
  box-shadow: var(--focus-ring);
}
.avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 13px 26px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 1rem;
  letter-spacing: 0.01em;
  background: var(--surface);
  /* Hairline inner ring gives glass buttons a defined edge on dark art */
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.07);
  transition:
    transform var(--t-fast) var(--ease),
    background var(--t-fast),
    box-shadow var(--t-fast);
}
.btn:hover {
  background: var(--surface-hover);
  transform: translateY(-1px);
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.14),
    0 8px 22px rgba(0, 0, 0, 0.35);
}
.btn:focus {
  box-shadow: var(--focus-ring);
}
.btn:active {
  transform: scale(0.97);
}
.btn svg {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

.btn-primary {
  /* Soft top-light: reads as a physical white key, not a flat fill */
  background: linear-gradient(to bottom, #ffffff 0%, #eceef7 100%);
  color: #0b0c14;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.38);
}
.btn-primary:hover {
  background: linear-gradient(to bottom, #ffffff 0%, #e0e3f0 100%);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.48);
}

.btn-icon {
  width: 48px;
  height: 48px;
  padding: 0;
  justify-content: center;
  border-radius: 50%;
}

.btn.small {
  padding: 9px 18px;
  font-size: 0.9rem;
}

/* ---------- Cards ---------- */
.card {
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--bg-raised);
  flex-shrink: 0;
  transition:
    transform var(--t-med) var(--ease),
    box-shadow var(--t-med) var(--ease);
  cursor: pointer;
}
.card:hover,
.card:focus {
  transform: scale(1.055);
  /* Tighter than the global focus ring so the shadow isn't clipped by the
     scroller's overflow; the 3px white ring is the key 10-foot focus cue. */
  box-shadow: 0 0 0 3px #fff, 0 14px 30px rgba(0, 0, 0, 0.55);
  z-index: 5;
}

.card-poster {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.card.poster {
  width: 176px;
  aspect-ratio: 2 / 3;
}
.card.wide {
  width: 300px;
  aspect-ratio: 16 / 9;
}

.card-fallback {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 14px;
  text-align: center;
  font-weight: 700;
  color: var(--text-dim);
  background: linear-gradient(160deg, #1b1d31, #101120);
  font-size: 1rem;
}

.card-shade {
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(5, 6, 12, 0.92) 0%, transparent 45%);
  opacity: 0;
  transition: opacity var(--t-fast);
  pointer-events: none;
}
.card:hover .card-shade,
.card:focus .card-shade,
.card.wide .card-shade {
  opacity: 1;
}

.card-label {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 10px;
  font-size: 0.9rem;
  font-weight: 700;
  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.8);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  pointer-events: none;
}
.card-sub {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-dim);
}

.card-progress {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 8px;
  height: 4px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.25);
  overflow: hidden;
  pointer-events: none;
}
.card-progress > div {
  height: 100%;
  background: var(--progress);
  border-radius: 2px;
}
.card-progress ~ .card-label {
  bottom: 20px;
}

.card-new {
  position: absolute;
  top: 10px;
  left: 10px;
  padding: 3px 9px;
  border-radius: 7px;
  background: var(--accent-strong);
  color: #fff;
  font-size: 0.68rem;
  font-weight: 900;
  letter-spacing: 0.1em;
  pointer-events: none;
  box-shadow: 0 4px 14px rgba(108, 88, 255, 0.5);
}

/* "STREAM" tag on unified Movies/Shows cards (torrent-streamable titles) */
.card-tag.stream {
  position: absolute;
  top: 10px;
  left: 10px;
  padding: 3px 8px;
  border-radius: 7px;
  background: rgba(6, 8, 16, 0.72);
  color: #cbd2e6;
  font-size: 0.62rem;
  font-weight: 900;
  letter-spacing: 0.12em;
  border: 1px solid rgba(255, 255, 255, 0.16);
  backdrop-filter: blur(4px);
  pointer-events: none;
}

.card-remove {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.65);
  font-size: 0.85rem;
  font-weight: 800;
  opacity: 0;
  transition:
    opacity var(--t-fast),
    background var(--t-fast);
  cursor: pointer;
}
.card:hover .card-remove,
.card:focus .card-remove {
  opacity: 1;
}
.card-remove:hover {
  background: rgba(220, 60, 60, 0.9);
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.35);
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: var(--text-dim);
  text-transform: uppercase;
}

/* ---------- Rows (horizontal shelves) ---------- */
.row {
  margin-top: 22px;
}
.row-title {
  font-size: var(--fs-row);
  font-weight: 800;
  letter-spacing: -0.01em;
  margin-bottom: 14px;
  padding: 0 var(--page-x);
}
.row-scroller {
  display: flex;
  gap: 14px;
  overflow-x: auto;
  /* overflow-x:auto forces overflow-y to auto, which would clip the card
     scale-up + focus ring. Generous vertical padding gives them room. */
  padding: 30px var(--page-x) 46px;
  margin: -20px 0 -30px;
  scroll-behavior: smooth;
  scrollbar-width: none;
}
.row-scroller::-webkit-scrollbar {
  display: none;
}

/* ---------- Grid (browse pages) ---------- */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 18px 18px;
  padding: 22px var(--page-x) 40px;
}
.grid .card.poster {
  width: 100%;
}

/* ---------- Toasts ---------- */
#toasts {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 400;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: 360px;
  padding: 13px 18px;
  border-radius: var(--radius);
  background: rgba(20, 22, 34, 0.98);
  border: 1px solid var(--line);
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.5);
  font-size: 0.92rem;
  font-weight: 600;
  animation: toast-in var(--t-med) var(--ease);
  transition:
    opacity 0.4s,
    transform 0.4s;
}
.toast.hide {
  opacity: 0;
  transform: translateX(24px);
}
@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateX(24px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(4, 5, 9, 0.82);
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fade-in var(--t-fast);
}
@keyframes fade-in {
  from {
    opacity: 0;
  }
}

.modal {
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius-l);
  padding: 28px;
  max-width: 520px;
  width: calc(100% - 48px);
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.6);
  animation: modal-in var(--t-med) var(--ease);
}
@keyframes modal-in {
  from {
    opacity: 0;
    transform: scale(0.95) translateY(12px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}
.modal h2 {
  font-size: 1.4rem;
  margin-bottom: 18px;
  letter-spacing: -0.01em;
}

.field {
  margin-bottom: 16px;
}
.field label {
  display: block;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-dim);
  margin-bottom: 7px;
}
.field input[type="text"],
.field input[type="password"] {
  width: 100%;
  padding: 12px 16px;
  border-radius: var(--radius-s);
  background: var(--surface);
  border: 1px solid var(--line);
  transition:
    border-color var(--t-fast),
    box-shadow var(--t-fast);
}
.field input[type="password"] { margin-top: 8px; }
.field input[type="text"]:focus,
.field input[type="password"]:focus {
  border-color: rgba(255, 255, 255, 0.5);
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.15);
}
.pw-error { color: #ff7a7a; font-size: 0.82rem; font-weight: 700; margin-top: 8px; }
.pw-error.hidden { display: none; }

/* Lock badge on a password-protected profile tile */
.profile-lock {
  position: absolute;
  right: -2px;
  bottom: -2px;
  font-size: 0.9rem;
  background: var(--bg);
  border-radius: 50%;
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(0,0,0,0.5);
}

/* Your-profile row in Preferences */
.pref-profile { display: flex; align-items: center; gap: 16px; max-width: 640px; }
.pref-profile .big-avatar.small {
  width: 56px; height: 56px; font-size: 1.6rem; border-radius: 14px;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.pref-profile-name { font-weight: 800; font-size: 1.05rem; }

/* ---------- Menu (popover list, e.g. subtitles) ---------- */
.menu {
  position: absolute;
  min-width: 240px;
  max-height: 46vh;
  overflow-y: auto;
  background: rgba(20, 22, 34, 0.98);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 6px;
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.6);
  z-index: 60;
}
.menu-title {
  padding: 8px 12px 4px;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-faint);
}
.menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  text-align: left;
  padding: 11px 12px;
  border-radius: var(--radius-s);
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition:
    background var(--t-fast),
    color var(--t-fast);
}
.menu-item:hover,
.menu-item:focus {
  background: var(--surface-hover);
  color: var(--text);
}
.menu-item.active {
  color: var(--text);
}
.menu-item.active::before {
  content: "✓";
  font-weight: 800;
}
.menu-item:not(.active)::before {
  content: "";
  width: 13px;
}
.menu-item .tag {
  margin-left: auto;
  font-size: 0.65rem;
  letter-spacing: 0.08em;
  color: var(--text-faint);
  text-transform: uppercase;
}
/* Subtitle-timing nudge row in the CC menu */
.sub-sync {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 8px 6px;
}
.sub-sync button {
  padding: 8px 10px;
  border-radius: var(--radius-s);
  background: var(--surface);
  border: 1px solid var(--line);
  font-weight: 700;
  font-size: 0.82rem;
  color: var(--text-dim);
  transition: background var(--t-fast), color var(--t-fast), box-shadow var(--t-fast);
}
.sub-sync button:hover { background: var(--surface-hover); color: var(--text); }
.sub-sync button:focus { box-shadow: var(--focus-ring); color: var(--text); }
.sub-sync .tag {
  min-width: 44px;
  text-align: center;
  font-size: 0.8rem;
  font-weight: 800;
  color: var(--text);
  text-transform: none;
  letter-spacing: 0;
}

/* ---------- Empty state ---------- */
.empty {
  padding: 90px var(--page-x);
  text-align: center;
  color: var(--text-dim);
}
.empty .glyph {
  font-size: 3rem;
  margin-bottom: 12px;
}
