/* =========================================================
   Learn & Prep — Spanish B1 News Podcast
   ========================================================= */

:root {
  --ink: #0e1116;
  --ink-soft: #2b3038;
  --muted: #6b7280;
  --bg: #fbf8f4;
  --card: #ffffff;
  --line: #e9e2d9;
  --accent: #ff5c39;
  --accent-2: #ffb703;
  --tg: #229ed9;
  --tg-dark: #1b86ba;

  --radius: 18px;
  --radius-lg: 24px;
  --shadow: 0 10px 30px rgba(16, 20, 28, 0.07);
  --shadow-hover: 0 22px 45px rgba(16, 20, 28, 0.14);
  --shadow-lg: 0 40px 90px rgba(8, 10, 14, 0.35);

  --maxw: 1120px;
  --font-display: "Fraunces", Georgia, "Times New Roman", serif;
  --font-body: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }

/* Ensure the [hidden] attribute always wins over component display rules */
[hidden] { display: none !important; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--font-body);
  color: var(--ink);
  background: var(--bg);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4 { margin: 0; line-height: 1.15; }
p { margin: 0; }
a { color: inherit; text-decoration: none; }
button { font-family: inherit; }
img { max-width: 100%; display: block; }

.container {
  width: min(100% - 40px, var(--maxw));
  margin-inline: auto;
}

.icon { width: 20px; height: 20px; flex: none; }
.icon--sm { width: 16px; height: 16px; }

/* ---------------- Language switcher ---------------- */
.lang-switch {
  position: fixed;
  top: 18px;
  right: 18px;
  z-index: 60;
  display: flex;
  gap: 2px;
  padding: 4px;
  border-radius: 999px;
  background: rgba(14, 17, 22, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.18);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
}

.lang-switch button {
  border: 0;
  background: transparent;
  color: rgba(255, 255, 255, 0.82);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  padding: 7px 13px;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.18s ease, color 0.18s ease;
}

.lang-switch button:hover { color: #fff; }

.lang-switch button.is-active {
  background: #fff;
  color: var(--ink);
}

/* ---------------- Hero ---------------- */
.hero {
  position: relative;
  min-height: 66vh;
  display: flex;
  align-items: center;
  overflow: hidden;
  color: #fff;
  isolation: isolate;
}

.hero__bg {
  position: absolute;
  inset: 0;
  background-image: url("../assets/hero.jpg");
  background-size: cover;
  background-position: center;
  transform: scale(1.04);
  z-index: -2;
}

.hero__overlay {
  position: absolute;
  inset: 0;
  z-index: -1;
  background:
    linear-gradient(100deg, rgba(8, 10, 14, 0.94) 0%, rgba(8, 10, 14, 0.82) 40%, rgba(8, 10, 14, 0.42) 100%),
    radial-gradient(120% 90% at 90% 10%, rgba(255, 92, 57, 0.22), transparent 55%);
}

.hero__inner {
  position: relative;
  padding: 48px 0 40px;
  max-width: 780px;
}

.eyebrow {
  display: inline-block;
  font-size: 0.76rem;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: #ffd9a8;
  background: rgba(255, 183, 3, 0.14);
  border: 1px solid rgba(255, 183, 3, 0.35);
  padding: 7px 14px;
  border-radius: 999px;
  margin-bottom: 16px;
}

.hero__title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(2rem, 5vw, 3.5rem);
  letter-spacing: -0.015em;
  margin-bottom: 16px;
  text-wrap: balance;
}

.hero__subtitle {
  font-size: clamp(1rem, 1.6vw, 1.18rem);
  color: rgba(255, 255, 255, 0.82);
  max-width: 720px;
  margin-bottom: 24px;
}

.hero__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin-bottom: 28px;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 15px 26px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 0.98rem;
  border: 1px solid transparent;
  cursor: pointer;
  transition: transform 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
  white-space: nowrap;
}

.btn:active { transform: translateY(1px); }

.btn:disabled {
  cursor: progress;
  opacity: 0.75;
}

.btn.is-loading .icon { animation: pulse 1s ease-in-out infinite; }

@keyframes pulse { 50% { opacity: 0.3; } }

.btn--primary {
  background: var(--tg);
  color: #fff;
  box-shadow: 0 14px 30px rgba(34, 158, 217, 0.38);
}

.btn--primary:hover {
  background: var(--tg-dark);
  transform: translateY(-2px);
  box-shadow: 0 20px 40px rgba(34, 158, 217, 0.45);
}

.btn--ghost {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.28);
  color: #fff;
  backdrop-filter: blur(6px);
}

.btn--ghost:hover {
  background: rgba(255, 255, 255, 0.16);
  transform: translateY(-2px);
}

.hero__badges {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 12px 26px;
}

.hero__badges li {
  position: relative;
  padding-left: 24px;
  font-size: 0.92rem;
  color: rgba(255, 255, 255, 0.78);
}

.hero__badges li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 50%;
  width: 14px;
  height: 14px;
  transform: translateY(-50%);
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 0 0 4px rgba(255, 183, 3, 0.14);
}

/* ---------------- Archive ---------------- */
.archive {
  padding: 96px 0 110px;
  background:
    radial-gradient(80% 60% at 100% 0%, rgba(255, 183, 3, 0.1), transparent 60%),
    var(--bg);
}

.section-head {
  max-width: 640px;
  margin-bottom: 34px;
}

.section-head h2 {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(1.8rem, 3.6vw, 2.6rem);
  letter-spacing: -0.01em;
  margin-bottom: 10px;
}

.section-head p {
  color: var(--muted);
  font-size: 1.02rem;
}

.search {
  position: relative;
  max-width: 560px;
  margin-bottom: 18px;
}

.search__icon {
  position: absolute;
  left: 20px;
  top: 50%;
  transform: translateY(-50%);
  width: 19px;
  height: 19px;
  color: var(--muted);
  pointer-events: none;
}

.search input {
  width: 100%;
  padding: 16px 20px 16px 52px;
  font-size: 1rem;
  font-family: inherit;
  color: var(--ink);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 999px;
  box-shadow: var(--shadow);
  outline: none;
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

.search input::placeholder { color: #9aa1ac; }

.search input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(255, 92, 57, 0.14), var(--shadow);
}

.notice {
  display: inline-block;
  margin: 4px 0 12px;
  padding: 8px 14px;
  font-size: 0.85rem;
  color: #8a5a00;
  background: rgba(255, 183, 3, 0.16);
  border: 1px solid rgba(255, 183, 3, 0.4);
  border-radius: 10px;
}

.meta-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  min-height: 20px;
}

.count {
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 20px;
}

.card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 12px;
  text-align: left;
  padding: 24px 24px 22px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  cursor: pointer;
  overflow: hidden;
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.card::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  background: linear-gradient(180deg, var(--accent), var(--accent-2));
  opacity: 0;
  transition: opacity 0.2s ease;
}

.card:hover,
.card:focus-visible {
  transform: translateY(-4px);
  box-shadow: var(--shadow-hover);
  border-color: #ded4c7;
  outline: none;
}

.card:hover::before,
.card:focus-visible::before { opacity: 1; }

.card__date {
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
}

.card__topic {
  font-family: var(--font-display);
  font-size: 1.12rem;
  font-weight: 600;
  color: var(--ink);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card__intro {
  font-size: 0.92rem;
  color: var(--muted);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card__cta {
  margin-top: auto;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--tg);
}

.card__cta svg { width: 15px; height: 15px; transition: transform 0.2s ease; }
.card:hover .card__cta svg { transform: translateX(4px); }

.state {
  padding: 40px 0;
  text-align: center;
  color: var(--muted);
  font-size: 0.98rem;
}

.state--error { color: #b42318; }

/* ---------------- Footer ---------------- */
.footer {
  background: var(--ink);
  color: rgba(255, 255, 255, 0.66);
  padding: 34px 0;
}

.footer__inner {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 20px;
  align-items: center;
  justify-content: space-between;
  font-size: 0.88rem;
}

.footer__brand {
  font-family: var(--font-display);
  font-weight: 600;
  color: #fff;
  font-size: 1rem;
}

/* ---------------- Modal ---------------- */
.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 20px;
}

.modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(8, 10, 14, 0.62);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  animation: fade 0.2s ease;
}

.modal__panel {
  position: relative;
  display: flex;
  flex-direction: column;
  width: min(760px, 100%);
  max-height: 88vh;
  background: #fff;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  animation: pop 0.24s cubic-bezier(0.2, 0.8, 0.3, 1);
}

.modal__close {
  position: absolute;
  top: 16px;
  right: 16px;
  z-index: 2;
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: #fff;
  color: var(--ink-soft);
  cursor: pointer;
  transition: background 0.18s ease, transform 0.18s ease;
}

.modal__close svg { width: 18px; height: 18px; }
.modal__close:hover { background: #f4efe8; transform: rotate(90deg); }

.modal__head {
  padding: 30px 32px 20px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, #fffdfa, #fff);
}

.modal__date {
  display: inline-block;
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 10px;
}

.modal__title {
  font-family: var(--font-display);
  font-size: clamp(1.25rem, 2.6vw, 1.7rem);
  font-weight: 600;
  padding-right: 40px;
  white-space: pre-line;
}

.modal__body {
  padding: 24px 32px 28px;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.modal__section + .modal__section { margin-top: 30px; }

.modal__section h4 {
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 12px;
}

.transcript p {
  margin-bottom: 1em;
  color: var(--ink-soft);
  line-height: 1.78;
  font-size: 0.98rem;
}

.transcript p:last-child { margin-bottom: 0; }

.transcript strong {
  color: var(--ink);
  font-weight: 700;
  background: linear-gradient(180deg, transparent 58%, rgba(255, 183, 3, 0.42) 58%);
  border-radius: 3px;
  padding: 0 2px;
}

.transcript em { color: var(--ink-soft); font-style: italic; }

.sources a {
  display: block;
  padding: 9px 0;
  font-size: 0.9rem;
  color: var(--tg);
  border-bottom: 1px dashed var(--line);
  transition: color 0.16s ease, padding-left 0.16s ease;
}

.sources a:last-child { border-bottom: 0; }
.sources a:hover { color: var(--tg-dark); padding-left: 5px; }

.modal__foot {
  padding: 16px 32px;
  border-top: 1px solid var(--line);
  background: #fffdfa;
  display: flex;
  align-items: center;
  gap: 18px;
}

/* ---------------- Audio player ---------------- */
.player {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 14px;
}

.player__btn {
  flex: none;
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: var(--ink);
  color: #fff;
  cursor: pointer;
  transition: background 0.18s ease, transform 0.18s ease;
}

.player__btn:hover { background: #1d232c; transform: scale(1.06); }
.player__btn:active { transform: scale(0.96); }
.player__btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

.player__icon { width: 20px; height: 20px; }
.player__icon--pause { display: none; }
.player.is-playing .player__icon--play { display: none; }
.player.is-playing .player__icon--pause { display: block; }

.player__track {
  position: relative;
  flex: 1 1 auto;
  min-width: 60px;
  height: 6px;
  border-radius: 999px;
  background: #e9e2d9;
  cursor: pointer;
  touch-action: none;
  transition: background 0.18s ease;
}

.player__track:hover { background: #ded4c7; }
.player__track:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; }

.player__fill {
  position: absolute;
  inset: 0 auto 0 0;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
}

.player__time {
  flex: none;
  font-size: 0.78rem;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  white-space: nowrap;
}

.modal__loading {
  padding: 30px 0;
  text-align: center;
  color: var(--muted);
}

@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop {
  from { opacity: 0; transform: translateY(16px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* ---------------- Responsive ---------------- */
@media (max-width: 720px) {
  .hero { min-height: 62vh; }
  .hero__inner { padding: 40px 0 34px; }
  .hero__actions .btn { flex: 1 1 auto; justify-content: center; }
  .archive { padding: 72px 0 84px; }
  .cards { grid-template-columns: 1fr; }
  .modal { padding: 0; }
  .modal__panel {
    width: 100%;
    max-height: 100vh;
    height: 100%;
    border-radius: 0;
  }
  .modal__head { padding: 26px 20px 18px; }
  .modal__body { padding: 20px; }
  .modal__foot { padding: 16px 20px; flex-direction: column; align-items: stretch; gap: 14px; }
  .modal__foot .btn { width: 100%; justify-content: center; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
  }
}
