/*
 * `castfeed` — the theme of Castfeed (کست‌فید), castfeed.ir: a Persian podcast directory that is also a player.
 * Fetched, not compiled.
 *
 * Subject and visitor: someone on the bus or in bed looking for the next Persian podcast to hear, and pressing
 * play right away; a podcaster checking their show is listed.
 * Tone: a late-night radio console. Indigo panel, coral signal light, paper-white page; technical, not cosy.
 * The detail only this subject has: what is ON AIR. The newest episodes stand beside the page's title as a
 * console's cue list ([data-block='podcast-episodes'], each a play button), the genres are a waveband dial
 * (`#genre-dial`), and the player bar (the module's own) stays at the foot of every page, so the site has no
 * bottom bar of its own.
 *
 * Indigo for the header and footer; coral on play buttons, links and the one signal line under the header.
 * Estedad for everything (heavy for headings), Poppins on an English page. Plain CSS over published hooks only.
 */

:root.theme-castfeed {
  --background: #f6f4ef;
  --foreground: #16152e;
  --card: #fffdf9;
  --card-foreground: #16152e;
  --popover: #fffdf9;
  --popover-foreground: #16152e;
  --primary: #e2401f;
  --primary-foreground: #ffffff;
  --secondary: #e9e7f3;
  --secondary-foreground: #1c1a45;
  --muted: #eeebe3;
  --muted-foreground: #5f5d73;
  --accent: #ecebf6;
  --accent-foreground: #1c1a45;
  --destructive: #b42318;
  --destructive-foreground: #ffffff;
  --border: #e2ded4;
  --input: #d6d2c8;
  --ring: #e2401f;

  --primary-50: #fff3f0;
  --primary-100: #ffe3db;
  --primary-200: #ffc4b5;
  --primary-300: #ff9b84;
  --primary-400: #ff7455;
  --primary-500: #ff5533;
  --primary-600: #e2401f;
  --primary-700: #bb3216;
  --primary-800: #962a15;
  --primary-900: #7a2616;
  --primary-950: #421007;

  --brand-accent: var(--brand-secondary, #1c1a45);
  --brand-accent-foreground: var(--brand-secondary-foreground, #f4efe6);
  --chrome-ink: var(--brand-secondary, #1c1a45);
  --chrome-ink-foreground: var(--brand-secondary-foreground, #f4efe6);

  --surface-page: #f6f4ef;
  --surface-alt: #eeebe3;
  --surface-input: #fffdf9;
  --surface-panel: #eeebe3;
  --ink-secondary: #3b3a55;

  --radius-step-sm: 6px;
  --radius-step-md: 10px;
  --radius-step-lg: 14px;
  --radius-step-xl: 20px;

  --cf-console: var(--brand-secondary, #1c1a45);
  --cf-console-ink: var(--brand-secondary-foreground, #f4efe6);
  --cf-console-soft: oklch(from var(--brand-secondary, #1c1a45) calc(l + 0.08) c h);
  --cf-signal: var(--brand-primary, #ff5533);
  --cf-display: var(--app-font-display);
}

@media (prefers-color-scheme: dark) {
  :root:not(.light).theme-castfeed {
    --background: #100f24;
    --foreground: #eeecf8;
    --card: #19173a;
    --card-foreground: #eeecf8;
    --popover: #19173a;
    --popover-foreground: #eeecf8;
    --primary: #ff7455;
    --primary-foreground: #2a0a03;
    --secondary: #23214a;
    --secondary-foreground: #eeecf8;
    --muted: #1a1838;
    --muted-foreground: #a9a6c4;
    --accent: #262452;
    --accent-foreground: #eeecf8;
    --border: #2b2954;
    --input: #36345f;
    --ring: #ff7455;
    --surface-page: #100f24;
    --surface-alt: #161533;
    --surface-input: #19173a;
    --surface-panel: #161533;
    --ink-secondary: #cfcce6;
    --cf-console: #0a0918;
    --cf-console-soft: #1c1a45;
  }
}

/* Same palette as the media query above — change both. */
:root.dark.theme-castfeed {
  --background: #100f24;
  --foreground: #eeecf8;
  --card: #19173a;
  --card-foreground: #eeecf8;
  --popover: #19173a;
  --popover-foreground: #eeecf8;
  --primary: #ff7455;
  --primary-foreground: #2a0a03;
  --secondary: #23214a;
  --secondary-foreground: #eeecf8;
  --muted: #1a1838;
  --muted-foreground: #a9a6c4;
  --accent: #262452;
  --accent-foreground: #eeecf8;
  --border: #2b2954;
  --input: #36345f;
  --ring: #ff7455;
  --surface-page: #100f24;
  --surface-alt: #161533;
  --surface-input: #19173a;
  --surface-panel: #161533;
  --ink-secondary: #cfcce6;
  --cf-console: #0a0918;
  --cf-console-soft: #1c1a45;
}

/* ── Type ───────────────────────────────────────────────────────────────── */

.theme-castfeed :is(h1, h2, h3, .sb-heading) {
  font-family: var(--cf-display);
  font-weight: 900;
  line-height: 1.35;
  overflow-wrap: anywhere;
  min-width: 0;
}

.theme-castfeed .sb-page h1 {
  font-size: clamp(1.9rem, 1.2rem + 2.6vw, 3.1rem);
}

.theme-castfeed [data-block='text']:has(+ [data-block='heading']) p {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 700;
  color: var(--primary);
}

/* the console's ON AIR lamp before every line above a title */
.theme-castfeed [data-block='text']:has(+ [data-block='heading']) p::before {
  content: '';
  inline-size: 0.55rem;
  block-size: 0.55rem;
  border-radius: 999px;
  background: var(--cf-signal);
  box-shadow: 0 0 0 4px oklch(from var(--brand-primary, #ff5533) l c h / 0.2);
}

/* ── Header: the console ──────────────────────────────────────────────── */

.theme-castfeed [data-part='header'] {
  background: var(--cf-console);
  color: var(--cf-console-ink);
  border-block-end: 3px solid var(--cf-signal);
}

.theme-castfeed [data-part='header'] .sb-section-inner {
  align-items: center;
}

.theme-castfeed [data-part='header'] :is(a, button, .sb-chrome-logo > span) {
  color: var(--cf-console-ink);
}

.theme-castfeed [data-part='header'] .sb-chrome-menu-link {
  font-weight: 600;
  white-space: nowrap;
  opacity: 0.82;
  transition: opacity 150ms ease, color 150ms ease;
}

.theme-castfeed [data-part='header'] .sb-chrome-menu-link:hover,
.theme-castfeed [data-part='header'] .sb-chrome-menu-link:focus-visible,
.theme-castfeed [data-part='header'] .sb-chrome-menu-link[aria-current='page'] {
  opacity: 1;
  color: var(--cf-signal);
}

.theme-castfeed [data-part='header'] .sb-column:nth-child(2) > .sb-block {
  flex: 1;
}

.theme-castfeed [data-part='header'] form.sb-chrome-search {
  inline-size: 100%;
  border-radius: 999px;
  background: var(--cf-console-soft);
  border: 1px solid oklch(from var(--brand-secondary-foreground, #f4efe6) l c h / 0.14);
  padding-inline: 0.9rem;
  transition: border-color 150ms ease;
}

.theme-castfeed [data-part='header'] form.sb-chrome-search:focus-within {
  border-color: var(--cf-signal);
}

.theme-castfeed [data-part='header'] form.sb-chrome-search input {
  background: transparent;
  color: var(--cf-console-ink);
}

@media (max-width: 767px) {
  /* the drawer and the magnifier carry search on a phone; the wordmark keeps its room */
  .theme-castfeed [data-part='header'] .sb-column:nth-child(2) {
    display: none;
  }
}

/* ── The cue list: newest episodes ────────────────────────────────────── */

.theme-castfeed [data-block='podcast-episodes'] .sb-podcast-episodes {
  border-block-start: 1px solid var(--border);
}

.theme-castfeed .sb-section:first-child [data-block='podcast-episodes'] {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-step-xl);
  padding: 1.25rem;
}

.theme-castfeed .sb-section:first-child [data-block='podcast-episodes'] .sb-podcast-episodes {
  grid-template-columns: minmax(0, 1fr);
}

.theme-castfeed .sb-section:first-child [data-block='podcast-episodes'] .sb-podcasts-title {
  font-size: 1.25rem;
}

/* ── Podcast covers: a mic where the feed's picture is not yet read ──── */

.theme-castfeed .sb-podcasts-grid > a {
  transition: background-color 150ms ease;
}

.theme-castfeed .sb-podcasts-grid > a > span:first-child {
  background: var(--secondary);
}

.theme-castfeed .sb-podcasts-grid > a > span:first-child svg {
  color: var(--cf-signal);
}

/* ── The waveband dial: genres ─────────────────────────────────────────── */

.theme-castfeed #genre-dial ul {
  list-style: none;
  margin: 0;
  padding: 0.9rem 0;
  display: flex;
  gap: 0.6rem;
  overflow-x: auto;
  scrollbar-width: thin;
  background:
    repeating-linear-gradient(to left, transparent 0 11px, var(--border) 11px 12px) bottom / 100% 10px no-repeat;
}

.theme-castfeed #genre-dial li {
  flex: none;
}

.theme-castfeed #genre-dial a {
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
  padding: 0.5rem 1rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--foreground);
  font-weight: 600;
  text-decoration: none;
  transition: border-color 150ms ease, color 150ms ease;
}

.theme-castfeed #genre-dial a:hover,
.theme-castfeed #genre-dial a:focus-visible {
  border-color: var(--cf-signal);
  color: var(--primary);
}

/* ── Notes: the studio card and the house rules ───────────────────────── */

.theme-castfeed :is(#studio-note, #house-rules) {
  background: var(--cf-console);
  color: var(--cf-console-ink);
  border-radius: var(--radius-step-xl);
  padding: 1.5rem;
}

.theme-castfeed #studio-note p:first-child,
.theme-castfeed #house-rules p:first-child {
  font-family: var(--cf-display);
  font-weight: 900;
  font-size: 1.25rem;
  margin-block-end: 0.5rem;
}

.theme-castfeed :is(#studio-note, #house-rules) :is(p, li, div) {
  color: var(--cf-console-ink);
}

.theme-castfeed :is(#studio-note, #house-rules) a {
  color: var(--cf-signal);
}

.theme-castfeed #house-rules ol {
  padding-inline-start: 1.2rem;
  display: grid;
  gap: 0.5rem;
}

/* ── Footer ────────────────────────────────────────────────────────────── */

.theme-castfeed [data-part='footer'] {
  background: var(--cf-console);
  color: var(--cf-console-ink);
}

.theme-castfeed [data-part='footer'] a {
  color: var(--cf-console-ink);
  opacity: 0.85;
  transition: opacity 150ms ease, color 150ms ease;
}

.theme-castfeed [data-part='footer'] a:hover,
.theme-castfeed [data-part='footer'] a:focus-visible {
  opacity: 1;
  color: var(--cf-signal);
}

.theme-castfeed [data-part='footer'] .sb-chrome-tagline {
  font-family: var(--cf-display);
  font-weight: 900;
  font-size: 1.35rem;
  line-height: 1.5;
}

@media (prefers-reduced-motion: reduce) {
  .theme-castfeed * {
    transition: none !important;
  }
}
