/* =============================================================================
   LOADING SCREEN
   Shown on every page load until Firebase resolves auth state.
   Uses var(--bg) so it matches the saved theme instantly (no flash).
   The data-theme attribute is set in <head> before first paint.
   ============================================================================= */
[data-theme="light"] { --bg: #ffffff; --accent: #E53935; --border: #e0e0e0; --text: #1a1a1a; }
[data-theme="dark"]  { --bg: #121212; --accent: #7C4DFF; --border: #2e2e2e; --text: #f0f0f0; }

/* Typography scale — matches public version exactly */
:root {
  --font-header: 17px;   /* text-big in public — overlay titles */
  --font-body:   16px;   /* text-medium in public — standard body text */
  --font-small:  15px;   /* text-small in public */
}

#screen-loading {
  position: fixed;
  inset: 0;
  background: var(--bg, #ffffff);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  transition: opacity 0.2s ease;
}

#screen-loading.fade-out {
  opacity: 0;
  pointer-events: none;
}


/* =============================================================================
   RESET & BASE
   ============================================================================= */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  height: 100%;
  width: 100%;
  overflow: hidden;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 16px;
  background: var(--bg, #ffffff);
  color: var(--text, #1a1a1a);
  -webkit-font-smoothing: antialiased;
}

/* =============================================================================
   SCREENS
   Full-viewport layers. Only one visible at a time.
   ============================================================================= */
#screen-login,
#screen-app {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
}

.hidden {
  display: none !important;
}

/* =============================================================================
   LOGIN SCREEN
   ============================================================================= */
#screen-login {
  background: var(--bg, #ffffff);
  display: flex;
  align-items: center;
  justify-content: center;
  /* safe area for notched phones */
  padding: env(safe-area-inset-top) env(safe-area-inset-right)
           env(safe-area-inset-bottom) env(safe-area-inset-left);
}

#login-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 32px;
  width: 100%;
  max-width: 320px;
  padding: 0 24px;
}

#login-title {
  font-size: 36px;
  font-weight: 700;
  letter-spacing: -0.5px;
  color: var(--text, #1a1a1a);
}

#login-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  width: 100%;
  padding: 14px 20px;
  border: none;
  border-radius: 14px;
  background: var(--accent, #E53935);
  color: #ffffff;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s ease;
  -webkit-user-select: none;
  user-select: none;
}

#login-btn:active {
  opacity: 0.8;
}

#login-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

#login-error {
  font-size: 13px;
  color: #e53935;
  text-align: center;
}

/* =============================================================================
   APP SCREEN
   ============================================================================= */
#screen-app {
  display: flex;
  flex-direction: column;
  background: var(--bg, #ffffff);
}

/* Main scrollable content — sits above the nav bar */
#view-container {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  /* push content above the nav bar */
  padding-bottom: calc(60px + env(safe-area-inset-bottom));
  padding-top: env(safe-area-inset-top);
}

/* =============================================================================
   BOTTOM NAV BAR
   ============================================================================= */
#nav-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: calc(60px + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--bg, #ffffff);
  border-top: 1px solid var(--border, #e0e0e0);
  display: flex;
  align-items: stretch;
  z-index: 100;
}

.nav-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--nav-text, #1a1a1a);
  transition: color 0.2s ease;
  -webkit-user-select: none;
  user-select: none;
}

.nav-btn.active {
  color: var(--nav-active, #E53935);
}

.nav-btn:active {
  opacity: 0.6;
}

.nav-icon {
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.nav-icon svg {
  width: 100%;
  height: 100%;
}

/* =============================================================================
   EPISODE LIST — copied from public/style.css
   ============================================================================= */

.season-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 20px;
  font-weight: 700;
  cursor: pointer;
  color: var(--text);
  border-bottom: 1px solid var(--border);
}

.season-chevron {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
  transition: transform 0.34s cubic-bezier(0.4,0,0.2,1);
  color: var(--text);
}

.episode-table {
  width: 100%;
  border-collapse: collapse;
}

.episode-table tr {
  border-bottom: 1px solid var(--border);
}

.episode-table td {
  padding: 10px 8px;
  color: var(--text);
  vertical-align: middle;
}

.episode-table td:first-child {
  padding-left: 20px;
  padding-right: 0;
}

.episode-table td:last-child {
  padding-right: 12px;
  padding-left: 8px;
}

.ep-num {
  width: 60px;
  font-weight: 700;
  color: var(--accent);
  flex-shrink: 0;
  padding-right: 0;
  white-space: nowrap;
}

.ep-title {
  font-weight: 400;
  padding-left: 8px;
  width: 100%;
  vertical-align: middle;
}

.ep-check-wrap {
  flex-shrink: 0;
}

.ep-check-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  -webkit-tap-highlight-color: transparent;
  flex-shrink: 0;
  width: 32px;
  height: 32px;
}

.check-icon {
  width: 28px;
  height: 28px;
  display: block;
  transition: fill 0.15s, stroke 0.15s;
}

.check-icon .check-circle {
  stroke: var(--text);
  fill: none;
}

.check-icon .check-mark {
  stroke: var(--text);
}

.check-icon.check-watched .check-circle {
  stroke: var(--accent);
  fill: var(--accent);
}

.check-icon.check-watched .check-mark {
  stroke: #fff;
}

.settings-section-label {
  padding: 10px 20px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text);
  font-size: 15px;
}

/* =============================================================================
   SCROLLBAR SUPPRESSION — no scrollbars anywhere in the app
   ============================================================================= */
* {
  scrollbar-width: none;
  -ms-overflow-style: none;
}
*::-webkit-scrollbar {
  display: none;
}

/* =============================================================================
   EPISODE OVERLAY — episode.js
   ============================================================================= */

/* Episode strip */
.ep-strip-wrap {
  flex-shrink: 0;
  overflow-x: auto;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}

.ep-strip {
  display: flex;
  width: max-content;
}

/* Carousel */
.ep-carousel-viewport {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  position: relative;
}

.ep-carousel-track {
  display: flex;
  height: 100%;
  will-change: transform;
}

.ep-panel {
  flex-shrink: 0;
  height: 100%;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.ep-panel-inner {
  display: flex;
  flex-direction: column;
  min-height: 100%;
}

.ep-panel-spinner {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.ep-panel-content {
  display: flex;
  flex-direction: column;
}

/* =============================================================================
   NEXT EPISODE PILL — show.js
   ============================================================================= */
.next-ep-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 8px 20px;
  padding: 8px 12px 8px 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  cursor: pointer;
}
.next-ep-pill-primary {
  background: var(--accent);
  border-color: var(--accent);
}

.next-ep-thumb {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(255,255,255,0.25) center/cover no-repeat;
}

.next-ep-info {
  flex: 1;
  display: flex;
  align-items: baseline;
  gap: 6px;
  min-width: 0;
  overflow: hidden;
}

.next-ep-code {
  font-weight: 700;
  flex-shrink: 0;
  color: #fff;
  font-size: var(--font-body);
}

.next-ep-name {
  font-weight: 400;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: var(--font-body);
}

.next-ep-check {
  flex-shrink: 0;
}

.next-ep-pill-primary .check-circle { stroke: rgba(255,255,255,0.9); fill: none; }
.next-ep-pill-primary .check-mark   { stroke: rgba(255,255,255,0.9); }
.next-ep-pill-primary .check-icon.check-watched .check-circle { stroke: #fff; fill: rgba(255,255,255,0.25); }
.next-ep-pill-primary .check-icon.check-watched .check-mark   { stroke: #fff; }

/* Episode backdrop pill — glossy pill centered at bottom of backdrop image */
.ep-backdrop-pill {
  position: absolute;
  bottom: 14px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 10px;                          /* tighter gap between icons */
  border-radius: 999px;
  padding: 7px 16px;                  /* smaller pill, same icon size */
  z-index: 2;
  /* Dark mode default — semi-transparent white frost */
  background: rgba(255, 255, 255, 0.18);
  border: 1px solid rgba(255, 255, 255, 0.30);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

/* Light mode — darker scrim so icons stay readable on bright backdrops */
[data-theme="light"] .ep-backdrop-pill {
  background: rgba(0, 0, 0, 0.38);
  border: 1px solid rgba(0, 0, 0, 0.18);
}

/* Shared button reset — both buttons identical size */
.ep-backdrop-pill-btn {
  background: none;
  border: none;
  padding: 0;
  width: 26px;
  height: 26px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
}

/* Icon wrapper inside each button — same 26px as the button */
.ep-backdrop-pill-icon {
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
}

/* Force check SVG to match — overrides the global .check-icon 28px */
.ep-backdrop-pill .check-icon {
  width: 26px;
  height: 26px;
}

/* Light mode — keep white (scrim is dark) */
[data-theme="light"] .ep-backdrop-pill-icon {
  color: #ffffff;
}

/* ── Check icon colors inside the backdrop pill ── */
/* Unwatched — white outline */
.ep-backdrop-pill .check-circle { stroke: rgba(255,255,255,0.90); fill: none; }
.ep-backdrop-pill .check-mark   { stroke: rgba(255,255,255,0.90); }

/* Watched — accent fill + white tick (same as episode list) */
.ep-backdrop-pill .check-icon.check-watched .check-circle { stroke: var(--accent); fill: var(--accent); }
.ep-backdrop-pill .check-icon.check-watched .check-mark   { stroke: #fff; }

/* Cast preview */
.cast-preview-row {
  display: flex;
  flex-direction: row;
  overflow: hidden;
  padding: 8px 20px 14px;
  gap: 14px;
}

.cast-preview-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex-shrink: 0;
  width: 56px;
  gap: 4px;
}

.cast-avatar {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--border) center/cover no-repeat;
  flex-shrink: 0;
}

/* Placeholder state — no photo */
.cast-avatar--placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Person icon inside placeholder circle */
.cast-avatar-icon {
  width: 22px;
  height: 22px;
  color: var(--text-secondary);
  flex-shrink: 0;
}

.cast-name {
  text-align: center;
  width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: var(--font-small);
  font-weight: 500;
  color: var(--text);
  line-height: 1.2;
  word-break: break-word;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

/* Cast full overlay */
.cast-full-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 20px;
}

.cast-full-avatar {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--border) center/cover no-repeat;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.cast-full-info {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}

.cast-full-info .cast-full-name {
  font-size: var(--font-small);
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cast-full-info .cast-full-char {
  font-size: var(--font-small);
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.show-status-pill {
  position: absolute;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--accent);
  color: #fff;
  padding: 6px 14px 6px 10px;
  border-radius: 999px;
  white-space: nowrap;
  pointer-events: none;
  font-family: 'Inter', sans-serif;
  font-size: 18px;
  font-weight: 700;
}

.show-status-pill-add {
  background: linear-gradient(160deg, rgba(255,255,255,0.55) 0%, rgba(255,255,255,0.18) 100%);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255,255,255,0.5);
  color: #fff;
  pointer-events: auto;
  text-shadow: 0 1px 3px rgba(0,0,0,0.35);
  box-shadow: 0 2px 12px rgba(0,0,0,0.18), inset 0 1px 0 rgba(255,255,255,0.4);
}

.show-status-pill svg {
  width: 20px;
  height: 20px;
  stroke: #fff;
  fill: none;
  flex-shrink: 0;
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}
