/* === The Red Light Review — site styles === */

:root {
  /* Brand crimson — single source of truth.
     Use var(--red) for solid color and rgb(var(--red-rgb) / <alpha>) for tints. */
  --red-rgb:    220 31 38;          /* #DC1F26 */
  --red:        rgb(var(--red-rgb));
  --red-deep:   #9A0F12;
  --red-glow:   #F02830;
  --red-button: #B0151B;            /* deeper crimson for solid CTAs */
  --ink:        #1A1A1A;
  --ink-soft:   #2A2826;
  --muted:      #6B6862;
  --faint:      #BAB9B4;
  --page:       #FAF8F5;
  --surface:    #FFFFFF;
  --border:     #E2DED5;
  --shadow:     0 1px 2px rgba(20,15,15,.06), 0 8px 24px rgba(20,15,15,.06);
  --serif:      "Playfair Display", "Times New Roman", serif;
  --sans:       "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --radius:     10px;
  --maxw:       1200px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --page:    #0E0C0B;
    --surface: #161311;
    --ink:     #F1ECE3;
    --ink-soft:#D5CFC4;
    --muted:   #9C988F;
    --faint:   #5C5851;
    --border:  #2A2521;
    --shadow:  0 1px 2px rgba(0,0,0,.5), 0 12px 32px rgba(0,0,0,.5);
    /* Brand red is the same crimson in both modes; only the deep variant
       shifts slightly so hover states still read on the darker background. */
    --red-deep:   #B0151B;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.65;
  color: var(--ink);
  background: var(--page);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--red); text-decoration: none; transition: color .18s ease, border-color .18s ease, background-color .18s ease; }
a:hover { color: var(--red-deep); text-decoration: underline; }
img { max-width: 100%; height: auto; display: block; }

h1, h2, h3 { font-family: var(--serif); font-weight: 700; line-height: 1.08; letter-spacing: -.015em; margin: 0 0 .4em; }
h1 { font-size: clamp(2.4rem, 3.4vw + 1rem, 3.8rem); text-wrap: balance; }
h2 { font-size: clamp(1.8rem, 2vw + 1rem, 2.6rem); }
h3 { font-size: 1.2rem; }

/* === Header === */
.site-header {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 24px;
  background: color-mix(in oklab, var(--page) 80%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); }
.brand:hover { text-decoration: none; color: var(--red); }
.brand-mark {
  width: 36px; height: 36px;
  display: block;
  background: #0a0908;
  border-radius: 6px;
  object-fit: contain;
  flex-shrink: 0;
  transition: transform .2s ease, box-shadow .2s ease;
}
.brand:hover .brand-mark {
  transform: scale(1.05);
  box-shadow: 0 0 18px rgb(var(--red-rgb) / 0.55);
}
.brand-text { font-family: var(--serif); font-size: 18px; font-weight: 700; letter-spacing: .2px; }
.site-header nav { display: flex; gap: 22px; align-items: center; }
.site-header nav a { color: var(--ink-soft); font-size: 15px; font-weight: 500; transition: color .18s ease; }
.site-header nav a:hover { color: var(--red); text-decoration: none; }
@media (max-width: 640px) {
  .site-header nav a:not(#nav-auth) { display: none; }
  .brand-text { display: none; }
}

/* === Auth avatar + popover ===
 * Replaces the "Sign in" link when /api/auth/me returns a user. The disc
 * shows the OAuth-provided avatar; on click it opens a small dropdown
 * anchored to the disc with Sign out (and room for future actions). */
.nav-avatar-wrap { position: relative; display: inline-flex; }
.nav-avatar {
  width: 36px; height: 36px;
  padding: 0; border: 0; cursor: pointer;
  border-radius: 50%;
  background: color-mix(in oklab, var(--red) 18%, transparent);
  box-shadow: inset 0 0 0 1px var(--border);
  display: inline-flex; align-items: center; justify-content: center;
  overflow: hidden;
  color: var(--ink);
  font-family: var(--serif); font-weight: 700; font-size: 15px;
  transition: transform .15s ease, box-shadow .15s ease;
}
.nav-avatar:hover { transform: translateY(-1px); box-shadow: 0 0 0 2px color-mix(in oklab, var(--red) 40%, transparent); }
.nav-avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.nav-avatar-initial { line-height: 1; }

.nav-menu {
  position: absolute; right: 0; top: calc(100% + 8px);
  min-width: 220px; max-width: 280px;
  background: var(--page);
  border: 1px solid var(--border); border-radius: 10px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, .35);
  overflow: hidden;
  z-index: 100;
}
.nav-menu[hidden] { display: none; }
.nav-menu-header {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  background: color-mix(in oklab, var(--page) 60%, transparent);
}
.nav-menu-name { font-weight: 600; font-size: 14px; color: var(--ink); margin: 0 0 2px; }
.nav-menu-email { font-size: 12px; color: var(--muted); word-break: break-all; line-height: 1.3; }
.nav-menu-items { padding: 6px; }
.nav-menu-item {
  display: block; padding: 8px 10px;
  font-size: 14px; color: var(--ink-soft);
  text-decoration: none; border-radius: 6px;
  transition: background .12s ease, color .12s ease;
}
.nav-menu-item:hover { background: color-mix(in oklab, var(--red) 10%, transparent); color: var(--ink); text-decoration: none; }
.nav-menu-signout { color: var(--red); }
.nav-menu-signout:hover { background: color-mix(in oklab, var(--red) 15%, transparent); color: var(--red-deep); }

/* === Hero === */
.hero {
  max-width: var(--maxw); margin: 0 auto;
  padding: 36px 24px 32px;
}
.hero-grid {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) 1.3fr;
  gap: clamp(24px, 4vw, 64px);
  align-items: center;
}
@media (max-width: 760px) {
  .hero-grid { grid-template-columns: 1fr; }
  .hero-art { max-width: 360px; margin: 0 auto; }
}
.hero-art img {
  width: 100%; aspect-ratio: 1/1;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}
.hero-copy h1 { color: var(--ink); margin-bottom: .25em; }
.tagline {
  font-family: var(--serif); font-style: italic;
  font-size: 1.3rem; color: var(--red);
  margin: 0 0 14px;
  line-height: 1.3;
  text-wrap: balance;
}
.lede { color: var(--ink-soft); font-size: 1.05rem; max-width: 56ch; line-height: 1.6; margin: 0 0 10px; }
.lede-meta { color: var(--ink-soft); font-size: 0.95rem; margin: 0; letter-spacing: 0.01em; }
.lede-meta strong { color: var(--ink); }
.hero-cta { display: flex; gap: 12px; margin-top: 22px; flex-wrap: wrap; }
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 12px 22px;
  border-radius: 999px;
  font-weight: 600; font-size: 15px;
  border: 1px solid transparent;
  transition: transform .18s ease, background-color .18s ease, color .18s ease, border-color .18s ease, box-shadow .25s ease;
}
.btn:hover { transform: translateY(-1px); text-decoration: none; }
/* Primary button: deeper crimson body. On hover the background stays put
   but a lantern-like red glow blooms around it. */
.btn-primary {
  background: var(--red-button);
  color: white;
  box-shadow: 0 0 0 0 rgb(var(--red-rgb) / 0);
}
.btn-primary:hover {
  background: var(--red-button);
  color: white;
  box-shadow:
    0 0 0 1px rgb(var(--red-rgb) / 0.5),
    0 0 18px 2px rgb(var(--red-rgb) / 0.55),
    0 0 36px 6px rgb(var(--red-rgb) / 0.35);
}
.btn-ghost { background: transparent; border-color: var(--border); color: var(--ink); }
.btn-ghost:hover { border-color: var(--red); color: var(--red); }

/* Admin-only buttons: dashed border + ADMIN tag so it's visually obvious
   this control is internal-only. Only rendered when the viewer is an admin. */
.btn-admin {
  background: rgb(var(--red-rgb) / 0.08);
  border: 1px dashed var(--red);
  color: var(--red);
  font-weight: 600;
}
.btn-admin:hover { background: rgb(var(--red-rgb) / 0.16); }
.admin-tag {
  display: inline-block;
  background: var(--red);
  color: #fff;
  font-size: 0.7em;
  font-weight: 700;
  letter-spacing: 0.06em;
  padding: 2px 6px;
  border-radius: 3px;
  margin-right: 6px;
  vertical-align: 1px;
}

.hero-player {
  margin-top: 42px;
  padding: 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.hero-player iframe { display: block; border-radius: 6px; }

/* === Episodes === */
.episodes {
  max-width: var(--maxw); margin: 0 auto;
  padding: 64px 24px;
}
.section-head { margin-bottom: 28px; }
.section-head p { color: var(--muted); margin: 0 0 18px; }
.filter-bar { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  padding: 8px 16px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink-soft);
  border-radius: 999px;
  font-size: 14px; font-weight: 500;
  font-family: var(--sans);
  cursor: pointer;
  transition: border-color .15s, color .15s, background .15s;
}
.chip:hover { border-color: var(--red); color: var(--red); }
.chip-active { background: var(--ink); color: var(--page); border-color: var(--ink); }

.episode-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 20px;
}
.ep-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex; flex-direction: column;
  transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease;
}
.ep-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow);
  border-color: var(--red);
  text-decoration: none;
}
.ep-card-art {
  position: relative;
  aspect-ratio: 1/1;
  background: var(--ink);
}
.ep-card-art img { width: 100%; height: 100%; object-fit: cover; }
.ep-card-num {
  position: absolute; top: 10px; left: 10px;
  background: rgba(0,0,0,.7); color: white;
  font-family: var(--sans); font-weight: 700; font-size: 12px;
  letter-spacing: 1px;
  padding: 4px 8px; border-radius: 4px;
}
.ep-card-body { padding: 14px 16px 18px; flex: 1; display: flex; flex-direction: column; }
.ep-card-title {
  font-family: var(--serif); font-weight: 700;
  font-size: 1.05rem; color: var(--ink);
  line-height: 1.25;
  margin: 0 0 6px;
}
.ep-card-sub {
  font-size: 13px; color: var(--muted);
  margin: 0 0 8px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
}
.ep-card-meta {
  display: flex; gap: 8px; align-items: center;
  margin-top: auto;
  font-size: 12px; color: var(--muted);
}
.ep-card-status {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; border-radius: 999px;
  background: rgb(var(--red-rgb) / 0.12); color: var(--red);
  font-weight: 600; font-size: 11px; letter-spacing: .3px;
  text-transform: uppercase;
}
.ep-card-status.published { background: rgba(67,122,34,.12); color: #437A22; }
.ep-card-date { font-variant-numeric: tabular-nums; }

/* === Listen === */
.listen { background: var(--surface); border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.listen, .about { max-width: var(--maxw); margin: 0 auto; padding: 56px 24px; }
.listen { max-width: none; }
.listen > * { max-width: var(--maxw); margin-left: auto; margin-right: auto; }
.platforms { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 28px; }
.platform {
  padding: 10px 18px;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--ink-soft);
  font-weight: 500; font-size: 14px;
}
.platform:hover { border-color: var(--red); color: var(--red); text-decoration: none; }
.platform[data-pending] { opacity: .5; cursor: not-allowed; }
.platform[data-pending]::after { content: " — coming soon"; font-size: 11px; color: var(--faint); }

.footer-player {
  background: var(--page);
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

/* === About === */
.about p { color: var(--ink-soft); max-width: 70ch; }
.about .contact { margin-top: 18px; color: var(--muted); }

/* === Footer === */
.site-footer {
  margin-top: 80px;
  border-top: 1px solid var(--border);
  background: linear-gradient(180deg, var(--surface) 0%, var(--page) 100%);
  font-size: 14px;
  color: var(--ink-soft);
}
.footer-inner {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 56px 24px 28px;
}
.footer-grid {
  display: grid;
  grid-template-columns: minmax(0, 2fr) 1fr 1fr;
  gap: 48px;
  align-items: start;
  margin: 0 0 40px;
}
.footer-brand { max-width: 38ch; }
.footer-brand .footer-logo {
  display: flex; align-items: center; gap: 10px;
  font-family: var(--serif); font-size: 18px; font-weight: 700; color: var(--ink);
  margin-bottom: 10px;
}
.footer-brand .footer-logo img { width: 28px; height: 28px; border-radius: 5px; background: #0a0908; }
.footer-brand p { margin: 0; color: var(--muted); line-height: 1.55; }
.footer-col h4 {
  font-family: var(--sans);
  font-size: 12px; font-weight: 600;
  letter-spacing: .12em; text-transform: uppercase;
  color: var(--muted); margin: 4px 0 14px;
}
.footer-col ul { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.footer-col a {
  color: var(--ink-soft);
  text-decoration: none;
  transition: color .15s ease;
}
.footer-col a:hover { color: var(--red); text-decoration: none; }
.footer-bar {
  display: flex; flex-wrap: wrap; gap: 12px 24px;
  align-items: center; justify-content: space-between;
  padding-top: 24px;
  border-top: 1px solid var(--border);
  color: var(--faint);
  font-size: 12.5px;
}
.footer-bar .footer-meta { display: flex; flex-wrap: wrap; gap: 6px 18px; }
.footer-bar a { color: var(--faint); }
.footer-bar a:hover { color: var(--red); text-decoration: none; }
@media (max-width: 720px) {
  .footer-grid { grid-template-columns: 1fr; gap: 32px; margin-bottom: 28px; }
  .footer-inner { padding: 44px 20px 24px; }
}

/* === Episode page === */
.ep-page { max-width: 880px; margin: 0 auto; padding: 32px 24px 64px; }
.ep-back { color: var(--muted); font-size: 14px; }
.ep-hero {
  display: grid; grid-template-columns: 240px 1fr; gap: 28px;
  margin: 24px 0 32px;
}
@media (max-width: 640px) { .ep-hero { grid-template-columns: 1fr; } }
.ep-hero img { border-radius: var(--radius); box-shadow: var(--shadow); }
.ep-meta { color: var(--muted); font-size: 14px; margin-bottom: 8px; }
.ep-tags { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.ep-tag {
  font-size: 11px; padding: 2px 8px; border-radius: 999px;
  background: rgb(var(--red-rgb) / 0.12); color: var(--red); font-weight: 500;
  text-transform: lowercase;
}
.ep-player { margin: 24px 0 32px; }
.ep-summary { font-size: 1.05rem; color: var(--ink-soft); margin-bottom: 18px; }
.ep-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 28px; }

/* Episode description (long-form, multi-paragraph) */
.ep-description {
  margin: 0 0 40px;
  max-width: 64ch;
  font-size: 1.05rem;
  line-height: 1.75;
  color: var(--ink-soft);
  text-wrap: pretty;
}
.ep-description p { margin: 0 0 1.4em; }
.ep-description p:last-child { margin-bottom: 0; }
.ep-description p:first-child {
  font-size: 1.12rem;
  color: var(--ink);
  margin-bottom: 1.6em;
}
.ep-description p:first-child::first-letter {
  font-family: var(--serif);
  font-weight: 700;
  font-size: 3.2em;
  line-height: .92;
  float: left;
  margin: 6px 12px -4px 0;
  color: var(--red);
}
/* Subtle separator between hook (first paragraph) and the rest */
.ep-description p:first-child + p {
  margin-top: .2em;
}

/* Coming-soon placeholder (replaces player when episode unpublished) */
.ep-coming-soon {
  display: flex; align-items: center; gap: 18px;
  padding: 22px 24px;
  border: 1px solid var(--border);
  border-left: 3px solid var(--red);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink-soft);
}
.ep-coming-soon strong {
  display: block;
  font-family: var(--serif); font-size: 1.15rem;
  color: var(--ink); margin-bottom: 4px;
}
.ep-coming-soon p { margin: 0; font-size: .95rem; color: var(--muted); }
.ep-coming-soon-glyph {
  flex: 0 0 auto;
  width: 38px; height: 38px;
  display: grid; place-items: center;
  border-radius: 50%;
  background: rgb(var(--red-rgb) / 0.12);
  color: var(--red);
  font-size: 14px;
  animation: pulse-soon 2.4s ease-in-out infinite;
}
@keyframes pulse-soon {
  0%, 100% { box-shadow: 0 0 0 0 rgb(var(--red-rgb) / 0.35); }
  50%      { box-shadow: 0 0 0 10px rgb(var(--red-rgb) / 0); }
}
@media (prefers-reduced-motion: reduce) {
  .ep-coming-soon-glyph { animation: none; }
}

/* Inline "Coming soon" badge in episode meta */
.ep-badge-soon {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  background: rgb(var(--red-rgb) / 0.14);
  color: var(--red);
  font-weight: 600;
  font-size: 12px;
  letter-spacing: .04em;
  text-transform: uppercase;
}

/* === Comments === */
.comments-section h2 { font-family: var(--serif); margin-top: 24px; }
.comment-form {
  margin-bottom: 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
}
.comment-form textarea {
  width: 100%; resize: vertical;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px;
  font: inherit;
  background: var(--page);
  color: var(--ink);
  min-height: 90px;
}
.comment-form textarea:focus { outline: 2px solid var(--red); outline-offset: 1px; }
.comment-form .row { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 10px; }
.comment-form small { color: var(--muted); font-size: 12px; }
.comment-list { display: flex; flex-direction: column; gap: 14px; }
.comment {
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}
.comment-children { margin-left: 28px; padding-left: 16px; border-left: 2px solid var(--border); margin-top: 12px; display: flex; flex-direction: column; gap: 12px; }
.comment-head { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.comment-avatar { width: 28px; height: 28px; border-radius: 50%; background: var(--border); }
.comment-author { font-weight: 600; font-size: 14px; }
.comment-time { color: var(--muted); font-size: 12px; }
.comment-body { white-space: pre-wrap; word-wrap: break-word; font-size: 15px; line-height: 1.55; color: var(--ink-soft); }
.comment-actions { display: flex; align-items: center; gap: 12px; margin-top: 10px; font-size: 13px; color: var(--muted); }
.vote-btn, .reply-btn, .delete-btn {
  background: none; border: none; color: var(--muted);
  cursor: pointer; padding: 4px 6px; border-radius: 4px;
  font: inherit; font-size: 13px;
}
.vote-btn:hover, .reply-btn:hover, .delete-btn:hover { color: var(--red); background: rgb(var(--red-rgb) / 0.08); }
.vote-btn.active { color: var(--red); font-weight: 600; }
.vote-count { font-variant-numeric: tabular-nums; min-width: 16px; }
.deleted { color: var(--faint); font-style: italic; }
.admin-bar { background: rgba(255,200,0,.12); padding: 6px 10px; border-radius: 4px; font-size: 12px; color: #6B5300; margin-top: 8px; }
.admin-bar input { width: 60px; margin: 0 4px; padding: 2px 6px; border: 1px solid #d0c490; background: #fffef0; border-radius: 3px; }

/* === Login === */
.login-wrap { max-width: 440px; margin: 80px auto; padding: 36px 28px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); text-align: center; box-shadow: var(--shadow); }
.login-wrap h1 { font-size: 1.8rem; margin-bottom: 18px; }
.login-wrap p { color: var(--muted); margin-bottom: 24px; }
.oauth-btn {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  width: 100%; padding: 12px;
  border-radius: 6px; border: 1px solid var(--border);
  background: var(--page); color: var(--ink);
  font-weight: 600; margin-bottom: 10px;
  cursor: pointer; font-size: 15px;
}
.oauth-btn:hover { border-color: var(--red); }

/* === Utility === */
.hidden { display: none !important; }
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--ink); color: var(--page);
  padding: 12px 18px; border-radius: 999px;
  font-size: 14px; font-weight: 500;
  box-shadow: var(--shadow);
  z-index: 100;
  animation: toast-in .25s ease;
}
@keyframes toast-in { from { transform: translate(-50%, 20px); opacity: 0; } to { transform: translateX(-50%); opacity: 1; } }
