/*
 * HejAudio Custom Web Receiver — 10-foot UI styles.
 *
 * WCAG 2.2 AA + 1.4.11 contrast + Google TV guidelines.
 *
 * Spec (sekcja 13.7 + 13.8 02-decyzja):
 * - Body text 24px minimum
 * - H3 30px, H2 36px, H1 48px
 * - Line-height 1.5
 * - Letter-spacing 0.02em
 * - Safe area: env(safe-area-inset-*) dla over/underscan TV
 * - prefers-reduced-motion: instant zmiana koloru zamiast 300ms transition
 *
 * Dynamic color — CSS custom properties ustawiane przez theme-renderer.js
 * z sender-side extracted dominantColor (decyzja N3 — eliminacja duplikatu logiki).
 */

:root {
  /* Default theme — neutralne tlo gdy brak okladki / dominantColor (decyzja sekcja 13.7 02-decyzja).
     Czarne tlo + biały tekst = AAA contrast 21:1, fallback bezpieczny. */
  --cast-bg: #1a1a1a;
  --cast-bg-elevated: #262626;
  --cast-text-primary: #ffffff;
  --cast-text-secondary: #d4d4d8;
  --cast-accent: #6366f1;
  --cast-accent-on: #ffffff;
  --cast-progress-track: #404040;
  --cast-progress-fill: #6366f1;
  --cast-focus-ring: #ffffff;
  --cast-safe-top: env(safe-area-inset-top, 24px);
  --cast-safe-right: env(safe-area-inset-right, 24px);
  --cast-safe-bottom: env(safe-area-inset-bottom, 24px);
  --cast-safe-left: env(safe-area-inset-left, 24px);
}

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

html,
body {
  height: 100%;
  overflow: hidden;
  font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, BlinkMacSystemFont, 'Helvetica Neue', sans-serif;
  font-size: 24px;
  line-height: 1.5;
  letter-spacing: 0.02em;
}

body.cast-receiver-body {
  background-color: var(--cast-bg);
  color: var(--cast-text-primary);
  transition: background-color 300ms ease;
}

/* prefers-reduced-motion — instant zmiana koloru zamiast 300ms transition (sekcja 13.10 02-decyzja). */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition: none !important;
    animation: none !important;
  }
  body.cast-receiver-body {
    transition: none;
  }
}

.cast-main {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 64px;
  height: 100vh;
  padding: var(--cast-safe-top) var(--cast-safe-right) var(--cast-safe-bottom) var(--cast-safe-left);
  align-items: center;
}

/* H1 nazwa podcastu — minimum 48px, w lewym gornym rogu. */
.cast-podcast-name {
  position: absolute;
  top: var(--cast-safe-top);
  left: var(--cast-safe-left);
  font-size: 48px;
  font-weight: 700;
  color: var(--cast-text-primary);
  letter-spacing: 0.01em;
}

.cast-now-playing {
  display: flex;
  flex-direction: column;
  gap: 24px;
  align-items: flex-start;
  padding: 32px;
}

/* Cover okladki — duza, central, zachowuje aspect ratio. */
.cast-cover-wrapper {
  width: 480px;
  height: 480px;
  border-radius: 24px;
  overflow: hidden;
  background-color: var(--cast-bg-elevated);
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.5);
}

.cast-cover {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* H2 tytul odcinka — minimum 36px. */
.cast-episode-title {
  font-size: 36px;
  font-weight: 600;
  color: var(--cast-text-primary);
  max-width: 800px;
  word-wrap: break-word;
}

/* H3 aktualny rozdzial — minimum 30px. */
.cast-current-chapter {
  font-size: 30px;
  font-weight: 500;
  color: var(--cast-text-secondary);
  max-width: 800px;
}

.cast-podcast-subtitle {
  font-size: 24px;
  color: var(--cast-text-secondary);
}

/* Progress bar — accessible (role=progressbar) + visual contrast. */
.cast-progress-wrapper {
  width: 100%;
  max-width: 800px;
  height: 8px;
  background-color: var(--cast-progress-track);
  border-radius: 4px;
  position: relative;
  margin-top: 32px;
}

.cast-progress-fill {
  height: 100%;
  background-color: var(--cast-progress-fill);
  border-radius: 4px;
  transition: width 300ms linear;
}

@media (prefers-reduced-motion: reduce) {
  .cast-progress-fill {
    transition: none;
  }
}

.cast-progress-time {
  position: absolute;
  top: 16px;
  left: 0;
  right: 0;
  display: flex;
  justify-content: space-between;
  font-size: 24px;
  color: var(--cast-text-secondary);
  font-variant-numeric: tabular-nums;
}

/* Aside chapters — prawy panel. */
.cast-chapters {
  padding: 32px;
  background-color: var(--cast-bg-elevated);
  border-radius: 24px;
  max-height: 80vh;
  overflow-y: auto;
}

.cast-chapters-heading {
  font-size: 36px;
  margin-bottom: 24px;
  color: var(--cast-text-primary);
}

.cast-chapters-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.cast-chapters-list li {
  font-size: 24px;
  padding: 12px 16px;
  border-radius: 8px;
  color: var(--cast-text-secondary);
  display: flex;
  justify-content: space-between;
  gap: 24px;
  transition: background-color 200ms;
}

@media (prefers-reduced-motion: reduce) {
  .cast-chapters-list li {
    transition: none;
  }
}

.cast-chapters-list li.cast-chapter-active {
  background-color: var(--cast-accent);
  color: var(--cast-accent-on);
  font-weight: 600;
}

.cast-chapters-list li .cast-chapter-time {
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}

/* Screen reader only — live regions sa ukryte wizualnie ale ogłaszane przez TalkBack. */
.cast-sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

/* Focus indicator — 3px solid + outline-offset 2px (sekcja 13.11 02-decyzja).
   UWAGA: receiver decision = display-only (Patryk 2026-04-25). Brak fokusu pilotem.
   Te style sa fallback gdy w przyszlosci dodajemy pilot navigation. */
:focus-visible {
  outline: 3px solid var(--cast-focus-ring);
  outline-offset: 2px;
}

/*
 * 4K viewport scaling — zachowuje proporcje na 3840x2160 ekranach.
 * Default body = 24px = 100% reference. Na 4K: 36px (1.5x scale).
 */
@media (min-width: 3000px) {
  html,
  body {
    font-size: 36px;
  }
  .cast-cover-wrapper {
    width: 720px;
    height: 720px;
  }
  .cast-podcast-name {
    font-size: 72px;
  }
  .cast-episode-title {
    font-size: 54px;
  }
  .cast-current-chapter {
    font-size: 45px;
  }
}
