/* ─────────────────────────────────────────────
   DESIGN TOKENS
   ───────────────────────────────────────────── */
:root {

  /* Panel */
  --color-panel-bg: #BAC4BA;           /* muted sage green */

  /* Title */
  --color-title: #21362C;              /* deep terracotta red */

  /* Player – configurable variables */
  --color-play-triangle:  #F9E1B7;     /* gold – play/pause icon fill */
  --color-play-circle:    #21362C;     /* play button ellipse background */
  --color-bar-filled:     #21362C;     /* elapsed portion of progress bar */
  --color-bar-empty:      #D9D9D9; /* remaining portion */
  --color-time-text:      #16161d;     /* timestamp digits */

  /* Global */
  --color-outer-bg:       #16161d;
  --color-panel-text:     #16161d;

  /* Layout */
  --side-pad:  24px;
  --panel-pad-bottom: 48px;
  --max-width: 500px;
}

/* ─────────────────────────────────────────────
   RESET / BASE
   ───────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  background: var(--color-outer-bg);
  font-family: 'Roboto', sans-serif;
}

/* ─────────────────────────────────────────────
   OUTER WRAPPER  (desktop centering)
   ───────────────────────────────────────────── */
.outer {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  min-height: 100vh;
  background: var(--color-outer-bg);
}

/* ─────────────────────────────────────────────
   MAIN CONTAINER
   ───────────────────────────────────────────── */
.container {
  position: relative;
  width: 100%;
  max-width: var(--max-width);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--color-panel-bg);
  overflow: hidden;
}

/* ─────────────────────────────────────────────
   HERO IMAGE  (fills remaining height above panel)
   ───────────────────────────────────────────── */
.hero {
  position: relative;
  flex: 1 1 auto;
  min-height: 200px;
  overflow: hidden;
}

.hero__img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
}

.hero__logo-wrap {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
}

.hero__logo {
  width: 50%;
  max-width: 260px;
  min-width: 150px;
  height: auto;
  filter: drop-shadow(2px 2px 8px rgba(0,0,0,1));
}

/* ─────────────────────────────────────────────
   CONTENT PANEL
   ───────────────────────────────────────────── */
.panel {
  flex: 0 0 auto;
  padding: 24px var(--side-pad) var(--panel-pad-bottom);
  background: var(--color-panel-bg);
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* ─────────────────────────────────────────────
   TOP ROW  (language selector + chapter menu toggle)
   ───────────────────────────────────────────── */
.top-row {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

/* ─────────────────────────────────────────────
   LANGUAGE SELECTOR
   ───────────────────────────────────────────── */
.lang-selector {
  display: flex;
  flex-direction: row;
  gap: 8px;
  align-items: center;
}

.lang-btn {
  font-family: 'Roboto', sans-serif;
  font-weight: 400;
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--color-panel-text);
  background: transparent;
  border: 1px solid rgba(33, 54, 44, 0.3);
  border-radius: 2px;
  padding: 5px 11px;
  cursor: pointer;
  opacity: 0.5;
  transition: opacity 0.15s ease, border-color 0.15s ease, background 0.15s ease;
  -webkit-tap-highlight-color: transparent;
  outline: none;
}

.lang-btn:hover { opacity: 0.75; }

.lang-btn:focus-visible {
  outline: 2px solid var(--color-bar-filled);
  outline-offset: 2px;
}

.lang-btn.active {
  opacity: 1;
  background: rgba(33, 54, 44, 0.1);
  border-color: rgba(33, 54, 44, 0.55);
}

.lang-divider {
  width: 1px;
  height: 11px;
  background: rgba(33, 54, 44, 0.25);
  flex-shrink: 0;
}

/* ─────────────────────────────────────────────
   CHAPTER MENU TOGGLE  (same styling as lang-btn)
   ───────────────────────────────────────────── */
.chapter-btn {
  font-family: 'Roboto', sans-serif;
  font-weight: 600;
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--color-panel-text);
  background: transparent;
  border: 1px solid rgba(33, 54, 44, 0.8);
  border-radius: 2px;
  padding: 7px 11px;
  cursor: pointer;
  opacity: 0.75;
  transition: opacity 0.15s ease, border-color 0.15s ease, background 0.15s ease;
  -webkit-tap-highlight-color: transparent;
  outline: none;
  flex-shrink: 0;
}

.chapter-btn:hover { opacity: 1; }

.chapter-btn:focus-visible {
  outline: 2px solid var(--color-bar-filled);
  outline-offset: 2px;
}

.chapter-btn[aria-expanded="true"] {
  opacity: 1;
  background: rgba(33, 54, 44, 0.1);
  border-color: rgba(33, 54, 44, 0.55);
}

/* ─────────────────────────────────────────────
   CHAPTER OVERLAY
   ───────────────────────────────────────────── */
.chapter-overlay-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 900;
  display: none;
}

.chapter-overlay-backdrop.open { display: block; }

.chapter-overlay {
  position: fixed;
  inset: 0;
  margin: 40px 32px 48px 32px;
  background-color: #21362C;
  border-radius: 4px;
  z-index: 1000;
  padding: 32px;
  overflow-y: auto;
  display: none;
  -webkit-overflow-scrolling: touch;
}

.chapter-overlay.open {
  display: block;
}

.chapter-overlay__close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 40px;
  height: 40px;
  border: none;
  background: transparent;
  color: #F9E1B7;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  -webkit-tap-highlight-color: transparent;
  outline: none;
}

.chapter-overlay__close svg {
  width: 22px;
  height: 22px;
}

.chapter-overlay__close:focus-visible {
  outline: 2px solid #F9E1B7;
  outline-offset: 2px;
  border-radius: 2px;
}

/* Language selector inside the chapter overlay */
.lang-selector--overlay {
  margin-top: 24px;
  margin-bottom: 32px;
}

.lang-selector--overlay .lang-btn {
  color: #F9E1B7;
  border-color: rgba(249, 225, 183, 0.4);
}

.lang-selector--overlay .lang-btn:hover {
  opacity: 0.85;
}

.lang-selector--overlay .lang-btn:focus-visible {
  outline: 2px solid #F9E1B7;
}

.lang-selector--overlay .lang-btn.active {
  background: #F9E1B7;
  color: #21362C;
  border-color: #F9E1B7;
}

.lang-selector--overlay .lang-divider {
  background: rgba(249, 225, 183, 0.3);
}

.chapter-overlay__list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 20px;
  margin-top: 0;
}

.chapter-overlay__item button {
  font-family: "shift", serif;
  font-weight: 400;
  font-style: normal;
  font-size: 24px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: #F9E1B7;
  background: transparent;
  border: none;
  text-align: left;
  padding: 0;
  cursor: pointer;
  opacity: 0.7;
  transition: opacity 0.15s ease;
  -webkit-tap-highlight-color: transparent;
  outline: none;
}

.chapter-overlay__item button:hover {
  opacity: 1;
}

.chapter-overlay__item button:focus-visible {
  outline: 2px solid #F9E1B7;
  outline-offset: 4px;
}

.chapter-overlay__item.active button {
  opacity: 1;
}

/* ─────────────────────────────────────────────
   EPISODE TITLE
   ───────────────────────────────────────────── */
.episode-title {
  color: var(--color-title);
  font-family: "shift", serif;
  font-weight: 200;
  font-style: normal;
  font-size: 32px;
  line-height: 1.1;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

/* ─────────────────────────────────────────────
   PLAYER
   ───────────────────────────────────────────── */
.player {
  display: grid;
  grid-template-columns: 48px 1fr;
  grid-template-rows: auto auto;
  column-gap: 32px;
  row-gap: 0;
  align-items: center;
}

/* Play / Pause button */
.player__btn {
  grid-column: 1;
  grid-row: 1 / 3;
  align-self: center;

  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  background: var(--color-play-circle);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;

  /* physical-button animation */
  transition: transform 0.12s ease, box-shadow 0.12s ease;
  -webkit-tap-highlight-color: transparent;
  outline: none;
}

.player__btn:active,
.player__btn.pressed {
  transform: scale(0.95);
}

.player__btn:focus-visible {
  outline: 2px solid var(--color-play-circle);
  outline-offset: 3px;
}

.icon-play,
.icon-pause {
  width: 24px;
  height: 24px;
  fill: var(--color-play-triangle);
}

.icon-play {
  /* optical nudge: shift play triangle slightly right */
  transform: translateX(1px);
}

/* Progress bar area */
.player__track {
  grid-column: 2;
  grid-row: 1;
  display: flex;
  align-items: center;
  height: 40px;
}

.player__bar-wrap {
  position: relative;
  width: 100%;
  height: 4px;
  cursor: pointer;
  /* expand hit area */
  padding: 8px 0;
  margin: -8px 0;
}

.player__bar-bg {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  left: 0; right: 0;
  height: 4px;
  border-radius: 2px;
  background: var(--color-bar-empty);
}

.player__bar-fill {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  left: 0;
  width: 0%;
  height: 4px;
  border-radius: 2px;
  background: var(--color-bar-filled);
  transition: width 0.1s linear;
}

.player__thumb {
  position: absolute;
  top: 50%;
  left: 0%;
  transform: translate(-50%, -50%);
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--color-bar-filled);
  box-shadow: 0 1px 4px rgba(0,0,0,0.22);
  transition: left 0.1s linear;
  pointer-events: none;
}

/* Timestamps */
.player__times {
  grid-column: 2;
  grid-row: 2;
  display: flex;
  justify-content: space-between;
}

.player__time {
  font-family: 'Roboto', sans-serif;
  font-weight: 400;
  font-size: 14px;
  color: var(--color-time-text);
  line-height: 1;
  /* tabular nums so digits don't shift width */
  font-variant-numeric: tabular-nums;
  letter-spacing: 0;
}

/* ─────────────────────────────────────────────
   TABLET LAYOUT  (600px–1024px)
   ───────────────────────────────────────────── */
@media (min-width: 600px) and (max-width: 1024px) {
  :root {
    --max-width: 100%;
    --side-pad: 48px;
  }

  .outer {
    align-items: stretch;
  }

  .container {
    flex-direction: row;
    max-width: 100%;
    min-height: 100vh;
  }

  /* Hero takes left half */
  .hero {
    flex: 1 1 55%;
    min-height: 100vh;
  }

  /* Panel sits right, vertically centered */
  .panel {
    flex: 1 1 45%;
    justify-content: center;
    padding: 48px var(--side-pad) 48px;
    gap: 32px;
  }

  .episode-title {
    font-size: 40px;
  }
}

/* ─────────────────────────────────────────────
   DESKTOP  (>1024px)
   ───────────────────────────────────────────── */
@media (min-width: 1025px) {
  .container {
    /* Centred column, phone-width column */
    min-height: 100vh;
    box-shadow: 0 0 60px rgba(0,0,0,0.6);
  }
}

/* ─────────────────────────────────────────────
   REDUCED MOTION
   ───────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  .player__btn,
  .player__bar-fill,
  .player__thumb {
    transition: none;
  }
}