/* =============================================================
   AI-Ya! — Podcast player, mini player, homepage module, toasts.
   Loaded on every page that has a player (podcast pages + home).
   Ported from the Claude Design podcast section (podcast-player.css).
   Tokens come from design-tokens.css; nav/footer/buttons from app.css.
   ============================================================= */

.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* Focus: ink + cyan double ring reads on cream and on teal. Scoped to podcast UI. */
:where(.pod-page, .pod-home, .mini) :where(a, button, input, select, [tabindex]):focus-visible { outline: none; box-shadow: 0 0 0 2px var(--ink-900), 0 0 0 5px var(--cyan-500) !important; border-radius: 10px; }

/* ─────────── shared bits ─────────── */
.pod-dot { width: 3px; height: 3px; border-radius: 50%; background: currentColor; opacity: .55; flex: none; }
.lang-tag { display: inline-flex; align-items: center; gap: 4px; font-family: var(--font-display); font-weight: 800; font-size: 11px; letter-spacing: .03em; padding: 2px 8px 2px 6px; border-radius: 999px; border: 1.5px solid currentColor; line-height: 1.3; white-space: nowrap; }
.lang-tag svg { width: 12px; height: 12px; }
.cover-ph { width: 100%; height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; background: repeating-linear-gradient(135deg, var(--teal-100) 0 10px, var(--cream) 10px 20px); color: var(--teal-700); text-align: center; padding: 8px; font-family: var(--font-display); font-weight: 900; font-size: 14px; line-height: 1.1; }
.cover-ph small { font-family: var(--font-body); font-weight: 600; font-size: 10px; color: var(--ink-500); }

/* ═════════════ PLAYER (shared) ═════════════ */
.pl-toggle, .pb { position: relative; flex: none; display: grid; place-items: center; border: 2px solid var(--ink-900); background: var(--gold-500); color: var(--ink-900); border-radius: 50%; cursor: pointer; box-shadow: 3px 3px 0 0 var(--ink-900); transition: transform 120ms var(--ease-out), box-shadow 120ms var(--ease-out), background 120ms; }
.pl-toggle:hover, .pb:hover { background: var(--gold-600); transform: translate(-1px, -1px); box-shadow: 4px 4px 0 0 var(--ink-900); }
.pl-toggle:active, .pb:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 0 var(--ink-900); }
.pl-toggle svg, .pb svg, .i-spin { display: none; }
.pl-toggle { width: 56px; height: 56px; } .pl-toggle svg { width: 26px; height: 26px; }
.pb { width: 48px; height: 48px; } .pb svg { width: 22px; height: 22px; }
[data-player][data-state="idle"] .pl-toggle .i-play, [data-player][data-state="paused"] .pl-toggle .i-play,
.pb[data-state="idle"] > .i-play, .pb[data-state="paused"] > .i-play { display: block; margin-left: 2px; }
[data-player][data-state="playing"] .pl-toggle .i-pause, .pb[data-state="playing"] > .i-pause { display: block; }
[data-player][data-state="loading"] .pl-toggle .i-spin, .pb[data-state="loading"] > .i-spin { display: block; }
[data-player][data-state="error"] .pl-toggle .i-retry, .pb[data-state="error"] > .i-retry { display: block; }
[data-player][data-state="loading"] .pl-toggle, .pb[data-state="loading"] { background: var(--cream); cursor: progress; }
[data-player][data-state="error"] .pl-toggle, .pb[data-state="error"] { background: var(--coral-500); }
.pb[data-state="playing"], [data-player][data-state="playing"] .pl-toggle { background: var(--cyan-500); }
.i-spin { width: 44%; height: 44%; border-radius: 50%; border: 3px solid var(--ink-300); border-top-color: var(--ink-900); animation: pl-spin .8s linear infinite; }
@keyframes pl-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .i-spin, .pl-spin-s { animation-duration: 2.4s; } }

.pl-btn { width: 44px; height: 44px; flex: none; display: grid; place-items: center; border-radius: 50%; border: 2px solid var(--ink-900); background: var(--white); color: var(--ink-900); cursor: pointer; transition: background 120ms; }
.pl-btn:hover { background: var(--cyan-200); }
.pl-btn svg { width: 26px; height: 26px; }
.pl-rate { min-width: 56px; height: 36px; padding: 0 10px; border-radius: 999px; border: 2px solid var(--ink-900); background: var(--cream); color: var(--ink-900); font-family: var(--font-display); font-weight: 900; font-size: 14px; cursor: pointer; font-variant-numeric: tabular-nums; }
.pl-rate:hover { background: var(--gold-200); }

.pl-scrub-row { display: flex; align-items: center; gap: 10px; font-family: var(--font-mono); font-size: 12px; color: var(--ink-700); font-variant-numeric: tabular-nums; }
.pl-el, .pl-tot { flex: none; min-width: 38px; }
.pl-tot { text-align: right; }
.pl-scrub { -webkit-appearance: none; appearance: none; flex: 1; min-width: 0; height: 28px; margin: 0; background: transparent; cursor: pointer; border-radius: 999px; }
.pl-scrub::-webkit-slider-runnable-track { height: 8px; border-radius: 999px; border: 2px solid var(--ink-900); background: linear-gradient(to right, var(--gold-500) var(--p, 0%), var(--white) var(--p, 0%)); }
.pl-scrub::-webkit-slider-thumb { -webkit-appearance: none; width: 20px; height: 20px; margin-top: -8px; border-radius: 50%; background: var(--white); border: 2.5px solid var(--ink-900); box-shadow: 2px 2px 0 0 var(--ink-900); }
.pl-scrub::-moz-range-track { height: 8px; border-radius: 999px; border: 2px solid var(--ink-900); background: var(--white); }
.pl-scrub::-moz-range-progress { height: 8px; border-radius: 999px; background: var(--gold-500); }
.pl-scrub::-moz-range-thumb { width: 18px; height: 18px; border-radius: 50%; background: var(--white); border: 2.5px solid var(--ink-900); }
.pl-scrub:focus-visible { box-shadow: none !important; }
.pl-scrub:focus-visible::-webkit-slider-thumb { box-shadow: 0 0 0 3px var(--ink-900), 0 0 0 6px var(--cyan-500); }
.pl-scrub:focus-visible::-moz-range-thumb { box-shadow: 0 0 0 3px var(--ink-900), 0 0 0 6px var(--cyan-500); }
[data-state="loading"] .pl-scrub, [data-state="error"] .pl-scrub { opacity: .45; }

.pl-status { margin: 0; font-size: 13px; color: var(--ink-700); display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.pl-status:empty { display: none; }
[data-state="error"] .pl-status { color: var(--coral-600); font-weight: 600; }
.pl-spin-s { width: 13px; height: 13px; border-radius: 50%; border: 2px solid var(--ink-300); border-top-color: var(--ink-900); animation: pl-spin .8s linear infinite; }
.pl-retry { font-family: var(--font-display); font-weight: 800; font-size: 13px; padding: 5px 12px; border-radius: 999px; border: 2px solid var(--ink-900); background: var(--white); color: var(--ink-900); cursor: pointer; min-height: 32px; }
.pl-retry:hover { background: var(--gold-200); }

/* inline (hero) */
.pl-inline { display: flex; align-items: flex-start; gap: 16px; background: var(--white); border: 2px solid var(--ink-900); border-radius: var(--r-md); box-shadow: 5px 5px 0 0 var(--ink-900); padding: 16px 18px; color: var(--ink-900); }
.pl-inline .pl-toggle { width: 64px; height: 64px; } .pl-inline .pl-toggle svg { width: 30px; height: 30px; }
.pl-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.pl-kicker { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; font-size: 12.5px; color: var(--ink-500); font-weight: 600; }
.pl-k-latest { font-family: var(--font-display); font-weight: 800; font-size: 11px; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-900); background: var(--coral-200); border: 1.5px solid var(--coral-600); padding: 1px 8px; border-radius: 999px; }
.pl-title { font-family: var(--font-display); font-weight: 800; font-size: 19px; line-height: 1.22; color: var(--ink-900); text-decoration: none; text-wrap: pretty; }
.pl-title:hover { color: var(--teal-700); text-decoration: underline; text-underline-offset: 3px; }

/* large (episode page) */
.pl-large { display: flex; flex-direction: column; gap: 14px; }
.pl-controls { display: flex; align-items: center; justify-content: center; gap: 18px; }
.pl-large .pl-toggle { width: 80px; height: 80px; box-shadow: 4px 4px 0 0 var(--ink-900); } .pl-large .pl-toggle svg { width: 36px; height: 36px; }
.pl-large .pl-btn { width: 52px; height: 52px; } .pl-large .pl-btn svg { width: 30px; height: 30px; }
.pl-large .pl-rate { position: relative; }
.pl-large .pl-scrub-row { font-size: 13px; }

/* ═════════════ MINI PLAYER ═════════════ */
.mini { position: fixed; z-index: 120; left: 50%; bottom: 16px; transform: translateX(-50%); width: min(780px, calc(100% - 32px)); background: var(--white); border: 2px solid var(--ink-900); border-radius: var(--r-md); box-shadow: 5px 5px 0 0 var(--ink-900); padding: 10px 14px 8px; display: flex; flex-direction: column; gap: 4px; color: var(--ink-900); animation: mini-in 260ms var(--ease-out); }
.mini[hidden] { display: none; }
@keyframes mini-in { from { transform: translate(-50%, 24px); opacity: 0; } to { transform: translate(-50%, 0); opacity: 1; } }
.mini-in { display: flex; align-items: center; gap: 10px; }
.mini-cover { width: 48px; height: 48px; flex: none; border-radius: 10px; overflow: hidden; border: 2px solid var(--ink-900); background: var(--cream); display: block; }
.mini-cover img, .mini-cover .cover-ph { width: 100%; height: 100%; object-fit: cover; font-size: 7px; padding: 2px; }
.mini-cover .cover-ph small { display: none; }
.mini-txt { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.mini-title { font-family: var(--font-display); font-weight: 800; font-size: 14.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-decoration: none; color: var(--ink-900); }
.mini-title:hover { text-decoration: underline; }
.mini-sub { font-size: 12px; color: var(--ink-500); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mini .pl-toggle { width: 48px; height: 48px; box-shadow: 2px 2px 0 0 var(--ink-900); } .mini .pl-toggle svg { width: 22px; height: 22px; }
.mini .pl-btn { width: 40px; height: 40px; border-color: transparent; } .mini .pl-btn:hover { border-color: var(--ink-900); }
.mini-x { width: 40px; height: 40px; flex: none; display: grid; place-items: center; border-radius: 50%; border: 2px solid transparent; background: transparent; color: var(--ink-700); cursor: pointer; }
.mini-x:hover { border-color: var(--ink-900); background: var(--coral-200); }
.mini-x svg { width: 20px; height: 20px; }
.mini .pl-scrub-row { font-size: 11px; gap: 8px; }
.mini .pl-scrub { height: 22px; }
.mini .pl-status { font-size: 12px; }
body.has-mini { padding-bottom: 120px; }
@media (max-width: 640px) {
  .mini { left: 0; right: 0; bottom: 0; transform: none; width: 100%; border-radius: 16px 16px 0 0; border-width: 2px 0 0; box-shadow: 0 -6px 18px rgba(21,37,42,.14); padding: 8px 12px calc(8px + env(safe-area-inset-bottom)); animation-name: mini-in-m; }
  @keyframes mini-in-m { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }
  .mini-skip { display: none !important; }
  .mini-cover { width: 44px; height: 44px; }
  body.has-mini { padding-bottom: 116px; }
}

/* ═════════════ HOMEPAGE MODULE ═════════════ */
.ep-prog { position: absolute; left: 0; right: 0; bottom: 0; height: 4px; background: transparent; }
.ep-prog i { display: block; height: 100%; width: 0; background: var(--gold-500); transition: width 250ms linear; }
.pod-home { position: relative; display: grid; grid-template-columns: 148px minmax(0, 1fr); gap: 24px; align-items: center; background: var(--teal-700); color: var(--white); border: 2px solid var(--ink-900); border-radius: var(--r-lg); box-shadow: 6px 6px 0 0 var(--ink-900); padding: 20px 24px 20px 20px; overflow: hidden; }
.ph-cover { width: 148px; aspect-ratio: 1; border-radius: 16px; overflow: hidden; border: 2px solid var(--ink-900); background: var(--cream); display: block; }
.ph-cover img { width: 100%; height: 100%; object-fit: cover; }
.ph-body { min-width: 0; display: flex; flex-direction: column; gap: 8px; }
.ph-kicker { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-family: var(--font-display); font-weight: 800; font-size: 13px; color: var(--cyan-200); }
.ph-new { font-size: 11px; letter-spacing: .06em; text-transform: uppercase; background: var(--coral-500); color: var(--ink-900); border: 1.5px solid var(--ink-900); border-radius: 999px; padding: 2px 10px; }
.ph-title { color: var(--white); margin: 0; font-family: var(--font-display); font-weight: 900; font-size: 24px; line-height: 1.18; text-wrap: pretty; }
.ph-title a { color: var(--white); text-decoration: none; } .ph-title a:hover { text-decoration: underline; text-underline-offset: 3px; color: var(--white); }
.ph-sub { margin: 0; color: var(--cyan-200); font-size: 15px; }
.ph-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 13px; color: var(--cyan-200); font-weight: 600; }
.ph-meta .lang-tag { color: var(--gold-500); }
.ph-actions { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; margin-top: 6px; }
.pb-wide { width: auto; height: 48px; border-radius: 14px; padding: 0 20px 0 16px; display: inline-flex; gap: 10px; font-family: var(--font-display); font-weight: 800; font-size: 15px; }
.pb-wide svg, .pb-wide .i-spin { width: 20px; height: 20px; }
.pb-l { display: none; }
.pb[data-state="idle"] .l-play, .pb[data-state="paused"] .l-play { display: inline; }
.pb[data-state="playing"] .l-pause { display: inline; } .pb[data-state="loading"] .l-load { display: inline; } .pb[data-state="error"] .l-err { display: inline; }
.pb-wide .i-spin { border-width: 2.5px; }
.ph-link { display: inline-flex; align-items: center; gap: 6px; font-family: var(--font-display); font-weight: 800; font-size: 14.5px; color: var(--gold-500); text-decoration: none; min-height: 44px; }
.ph-link:hover { color: var(--white); text-decoration: underline; text-underline-offset: 3px; }
.ph-link svg { width: 16px; height: 16px; }
.pod-home .ep-prog { height: 5px; }
.pod-home.is-empty .ph-cover { opacity: .9; }
/* Directly after another plain section (home: Featured article), avoid a double gap. */
.section:not(.alt) + .pod-home-section { padding-top: 0; }
@media (max-width: 760px) {
  .pod-home { grid-template-columns: 88px minmax(0, 1fr); gap: 14px; padding: 14px; align-items: start; }
  .ph-cover { width: 88px; border-radius: 12px; }
  .ph-title { font-size: 18px; }
  .ph-actions { grid-column: 1 / -1; }
}

/* ═════════════ TOASTS ═════════════ */
.pod-toasts { position: fixed; top: 84px; left: 50%; transform: translateX(-50%); z-index: 300; display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
.pod-toast { display: flex; align-items: center; gap: 10px; background: var(--ink-900); color: var(--white); border-radius: 999px; padding: 10px 16px 10px 10px; font-size: 14px; font-weight: 600; box-shadow: var(--shadow-soft-md); transition: opacity .3s, transform .3s; }
.pod-toast.out { opacity: 0; transform: translateY(-6px); }
.pt-ic { width: 24px; height: 24px; border-radius: 50%; background: var(--gold-500); color: var(--ink-900); display: grid; place-items: center; }
.pt-ic svg { width: 14px; height: 14px; }
