/* ===== Podcast kit — docked player, chapters, notes panel ===== */

/* Color tokens (light/dark friendly) */
:root{
  --dock-bg: var(--background, #fff);
  --dock-border: rgba(0,0,0,.10);
  --dock-shadow: 0 6px 24px rgba(0,0,0,.10);
  --pill-bg: #fff;
  --pill-border: rgba(0,0,0,.12);
  --pill-border-hover: rgba(0,0,0,.28);
  --pill-shadow: 0 1px 8px rgba(0,0,0,.06);
  --notes-bg: #fff;
  --notes-backdrop: rgba(0,0,0,.45);
}

/* -------- A) Audio dock (inserted under the post header; sticks under site header) -------- */
.audio-dock{
  background: var(--dock-bg);
  border: 1px solid var(--dock-border);
  box-shadow: var(--dock-shadow);
  border-radius: 12px;
  padding: .5rem 1rem;
  width: min(92vw, 840px);
  margin: .5rem auto 1rem;
  position: sticky;
  top: var(--dock-top, 0px); /* set in JS to site header height */
  z-index: 1000;
}
.audio-dock audio{
  width: 100%;
  height: 40px;
}

/* Hide Podbean iframe if native player exists */
body.has-audio-dock iframe[data-name="pb-iframe-player"]{
  display: none !important;
}

/* -------- B) Chapters UI -------- */
.chapters-wrap{ margin: 1rem 0 1.25rem; }
.chapters-desc {
  font-size: 1.4rem;  /* larger text */
  font-weight: 600;   /* optional: make it bolder */
  opacity: .95;
  margin-bottom: .75rem;
}

.chapters-list{
  display: grid;
  grid-template-columns: 1fr;
  gap: .5rem;
}
.chapter-pill{
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: .75rem;
  width: 100%;
  padding: .85rem 1rem;
  border: 1px solid var(--pill-border);
  border-radius: .75rem;
  background: var(--pill-bg);
  cursor: pointer;
  text-align: start;
  transition: border-color .15s ease, box-shadow .15s ease, transform .03s ease;
  font: inherit;
}
.chapter-pill:hover{ border-color: var(--pill-border-hover); box-shadow: var(--pill-shadow); }
.chapter-pill:active{ transform: translateY(1px); }
.cp-title{ overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cp-time{ opacity: .8; font-variant-numeric: tabular-nums; }

/* -------- C) Show notes slide-over -------- */
.notes-panel{
  position: fixed;
  top: 0;
  inset-inline-end: 0;          /* right in LTR, left in RTL */
  width: min(480px, 92vw);
  height: 100dvh;
  background: var(--notes-bg);
  box-shadow: 0 10px 30px rgba(0,0,0,.12);
  transform: translateX(110%);  /* off-screen by default */
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: transform .35s ease, opacity .2s ease, visibility 0s linear .35s;
  z-index: 10050;
}
.notes-panel.is-open{
  transform: translateX(0);
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transition: transform .35s ease, opacity .2s ease;
}

.notes-backdrop{
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.35);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity .25s ease, visibility 0s linear .25s;
  z-index: 10040;
}
.notes-backdrop.is-open{
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transition: opacity .25s ease;
}

.notes-head{
  display: flex; align-items: center; justify-content: space-between;
  padding: 1rem 1rem 0.75rem; border-bottom: 1px solid var(--dock-border);
}
.notes-title{ font-size: clamp(1.4rem, 1.7rem, 1.9rem); margin: 0; }
.notes-close{ font-size: 1.5rem; line-height: 1; background: none; border: 0; cursor: pointer; }
.notes-body{ overflow: auto; padding: 1rem; }
.notes-content :where(p,li){ line-height: 1.8; }

/* -------- D) Make jumps land below header+player (the key fix) -------- */
/* JS adds: html { scroll-padding-top: calc(head + dock + 12px) } */
body.has-audio-dock .script-body h1,
body.has-audio-dock .script-body h2,
body.has-audio-dock .script-body h3,
body.has-audio-dock .script-body h4,
body.has-audio-dock .script-body h5,
body.has-audio-dock .script-body h6{
  scroll-margin-top: calc(var(--head-h, 0px) + var(--dock-h, 0px) + 12px);
}
/* Optional: extend to any element you might scroll to */
body.has-audio-dock .script-body *{
  scroll-margin-top: calc(var(--head-h, 0px) + var(--dock-h, 0px) + 12px);
}

/* -------- E) Small-screen tweaks -------- */
@media (max-width: 640px){
  .audio-dock{ width: 100%; border-radius: 0; margin: 0; }
  .chapter-pill{ padding: .75rem .9rem; }
}

/* Make slide a column so .notes-body can flex and scroll */
.notes-panel{
  display: flex;
  flex-direction: column;
  height: 100vh;        /* fallback */
  height: 100dvh;       /* modern mobile */
}

/* The scrolling region inside the slide */
.notes-body{
  flex: 1 1 auto;
  overflow: auto;
  overscroll-behavior: contain;    /* stop scroll chaining to page */
  -webkit-overflow-scrolling: touch; /* smooth iOS scroll */
  min-height: 0;
}

/* When the slide is open, prevent page scroll underneath */
body.notes-open{
  overflow: hidden;
}

/* Make the inner wrapper a column flex container */
.notes-inner {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;  /* important so .notes-body can shrink within viewport */
}

/* Bigger, easier-to-tap close button for notes slide */
:root{
  /* tweak these if you want larger/smaller */
  --notes-close-size: 44px;   /* recommended tap target ≥44px */
  --notes-close-font: 36px;   /* the “×” glyph size */
}

.notes-head{
  display: flex;               /* ensure proper layout */
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
}

.notes-close{
  inline-size: var(--notes-close-size);
  block-size: var(--notes-close-size);
  display: inline-grid;        /* perfectly center the glyph */
  place-items: center;
  font-size: var(--notes-close-font);
  line-height: 1;
  border: 0;
  background: transparent;
  border-radius: 999px;        /* round tap target */
  cursor: pointer;
  transition: background .15s ease, transform .03s ease, box-shadow .15s ease;
  /* pull slightly toward the corner if header has padding */
  margin-inline-start: -.25rem;
}

@media (hover:hover) and (pointer:fine){
  .notes-close:hover{
    background: rgba(0,0,0,.06);
  }
}
.notes-close:active{ transform: translateY(1px); }
.notes-close:focus-visible{
  outline: 2px solid rgba(0,0,0,.25);
  outline-offset: 2px;
}

/* Dark mode hover/focus polish */
.dark-mode .notes-close:hover{
  background: rgba(255,255,255,.10);
}
.dark-mode .notes-close:focus-visible{
  outline-color: rgba(255,255,255,.5);
}
