/* =============================================================================
   Fictioneer Child Theme V5 — chapter page (/chapter/xxx)

   Scoped to `body.fcv3-dark.single-fcn_chapter` (single fcn_chapter). Loaded
   after fcv3-home.css, which it depends on for the fcv3 tokens, the parent
   dark palette dump (dark mode only), the nav harmonization and the removal
   of the big parent site-title header (.header) — the ~330px of mostly empty
   space above every chapter page.

   Strategy: the parent's single-fcn_chapter.php markup, hooks and JS are NOT
   touched. Font stepper / formatting modal / fullscreen / bookmarks / index /
   subscribe / share / TTS / suggestions / comments all keep working — only
   the chrome around the chapter is restyled with fcv3 tokens.

   Reading text is deliberately left alone: the body font of the chapter
   content stays the parent's primary font (or whatever the reader picked in
   the formatting modal, which is applied inline). Only the chrome (actions,
   headline, index, comments, support links) uses Fredoka.

   The token remap below mirrors the one in fcv3-story.css — keep in sync.
   ========================================================================== */

/* == TOKEN REMAP ========================================================== */

/* `html` prefix on purpose: ties the dark palette dump's selector
   (html:not([data-mode=light]) body.fcv3-dark) and wins by source order, so
   the remaps hold in BOTH modes. */
html body.fcv3-dark.single-fcn_chapter {
  --layout-border-radius-small: var(--fcv3-radius-md);

  /* Secondary buttons (whole actions bars) → ghost pills */
  --button-secondary-background: rgba(var(--fcv3-card-rgb), 0.6);
  --button-secondary-color: var(--fcv3-fg);
  --button-secondary-border: 1px solid var(--fcv3-border-soft);
  --button-secondary-background-hover: rgba(var(--fcv3-card-rgb), 0.95);
  --button-secondary-color-hover: var(--fcv3-fg);
  --button-secondary-border-hover: 1px solid var(--fcv3-border-hover);

  /* Subscribe dropdown + modals (index / formatting / sharing) */
  --popup-menu-background: var(--fcv3-card);
  --popup-menu-color: var(--fcv3-fg);
  --popup-menu-background-hover: rgba(6, 182, 212, 0.12);
  --popup-menu-color-hover: var(--fcv3-primary);
  --modal-bg-color: var(--fcv3-card);
  --modal-box-shadow: var(--fcv3-shadow-panel);

  /* Chapter index rows */
  --content-li-background: rgba(var(--fcv3-bg-rgb), 0.7);
  --chapter-index-li-background: rgba(var(--fcv3-bg-rgb), 0.7);
  --current-content-li-background: rgba(6, 182, 212, 0.14);

  /* Links */
  --heading-link-color: var(--fcv3-fg);
  --heading-link-color-hover: var(--fcv3-primary);
  --inline-link-color: var(--fcv3-primary-strong, var(--fcv3-primary));
  --inline-link-color-hover: var(--fcv3-primary);

  /* Foreword / warnings / notes boxes */
  --infobox-background: rgba(var(--fcv3-bg-rgb), 0.6);

  /* Comment cards + form fields */
  --comment-background: rgba(var(--fcv3-bg-rgb), 0.6);
  --input-background: var(--fcv3-card);
  --input-color: var(--fcv3-fg);
  --input-border-radius: var(--fcv3-radius-md);
  --input-shadow: inset 0 0 0 1px var(--fcv3-border-soft);

  /* Reading progress bar */
  --progress-bar-color: var(--fcv3-primary);

  --layout-hr-border-dashed: 1px dashed var(--fcv3-border);

  /* Breathing room under the slim nav */
  --main-offset: 24px;
}

/* == PAGE + CARD ========================================================== */

body.fcv3-dark.single-fcn_chapter .main.chapter {
  color: var(--fcv3-fg);
}

/* The parent's .main__background is an opaque, clipped, textured plate. Turn
   it into the fcv3 content card (white / slate-900 in dark), same as the story
   page. Fullscreen reading keeps the parent's flat fullscreen background. */
body.fcv3-dark.single-fcn_chapter .main__background {
  background-color: var(--fcv3-card) !important;
  background-image: none !important;
  border: 1px solid var(--fcv3-border) !important;
  border-radius: var(--fcv3-radius-card) !important;
  box-shadow: var(--fcv3-shadow-card) !important;
  clip-path: none !important;
  filter: none !important;
}
body.fcv3-dark.single-fcn_chapter .main__background::before,
body.fcv3-dark.single-fcn_chapter .main__background::after {
  content: none !important;
}
:is(:fullscreen, :-webkit-full-screen) body.fcv3-dark.single-fcn_chapter .main__background {
  background-color: var(--fullscreen-background) !important;
  border: 0 !important;
  border-radius: 0 !important;
  box-shadow: none !important;
}

/* Parent: inset + 48px spacing → inset + 24px inside the card */
body.fcv3-dark.single-fcn_chapter .main__wrapper {
  padding-top: calc(var(--page-inset-top, 0px) + 24px);
}
:is(:fullscreen, :-webkit-full-screen) body.fcv3-dark.single-fcn_chapter .main__wrapper {
  padding-top: 0 !important;
}

/* Reading text keeps the parent's font (inline formatting wins anyway) */
body.fcv3-dark.single-fcn_chapter .chapter-formatting {
  font-family: var(--ff-base);
}

/* == TOP / BOTTOM ACTIONS ================================================= */

body.fcv3-dark.single-fcn_chapter .chapter__actions .chapter__actions-container {
  gap: 6px;
}
body.fcv3-dark.single-fcn_chapter .chapter__actions .chapter__actions-container .button {
  height: 34px;
  padding-inline: 12px;
  border-radius: var(--fcv3-radius-pill);
  font-family: var(--fcv3-font);
  font-size: 0.8125rem;
  font-weight: 600;
  letter-spacing: 0;
  transition: color 0.15s ease, border-color 0.15s ease, background-color 0.15s ease;
}
/* Font stepper group (− ▢ +): compact rounded squares, not pills */
body.fcv3-dark.single-fcn_chapter .chapter__actions .chapter__actions-left .button {
  padding-inline: 10px;
  border-radius: var(--fcv3-radius-md);
}
body.fcv3-dark.single-fcn_chapter .chapter__actions .chapter__actions-container .button:is(.open-fullscreen, .close-fullscreen) {
  width: 34px;
  padding: 0;
}
body.fcv3-dark.single-fcn_chapter .chapter__actions .anchor {
  padding-inline: 10px;
}
body.fcv3-dark.single-fcn_chapter .media-buttons__item {
  color: var(--fcv3-fg-muted);
  opacity: 0.7;
}
body.fcv3-dark.single-fcn_chapter .media-buttons__item:hover,
body.fcv3-dark.single-fcn_chapter .media-buttons__item:focus-visible {
  color: var(--fcv3-fg);
  opacity: 1;
}
body.fcv3-dark.single-fcn_chapter .chapter__footer.chapter__actions {
  margin-top: 2rem;
}
body.fcv3-dark.single-fcn_chapter .chapter__article .popup-menu {
  border: 1px solid var(--fcv3-border);
  border-radius: var(--fcv3-radius-lg);
  box-shadow: var(--fcv3-shadow-panel);
}

/* == HEADLINE ============================================================== */

body.fcv3-dark.single-fcn_chapter .chapter__headline {
  padding: 1.25rem 0 2rem;
}
/* Story link: small muted label above the chapter title */
body.fcv3-dark.single-fcn_chapter .chapter__headline > a {
  color: var(--fcv3-fg-muted);
  font-family: var(--fcv3-font);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
body.fcv3-dark.single-fcn_chapter .chapter__headline > a:hover {
  color: var(--fcv3-primary);
}
body.fcv3-dark.single-fcn_chapter .chapter__title {
  margin-top: 0.375rem;
  color: var(--fcv3-fg);
  font-family: var(--fcv3-font);
  font-weight: 600;
  letter-spacing: -0.01em;
}
body.fcv3-dark.single-fcn_chapter .chapter__author {
  margin-top: 0.375rem;
  color: var(--fcv3-fg-muted);
  font-family: var(--fcv3-font);
  font-size: 0.8125rem;
  font-style: normal;
}
body.fcv3-dark.single-fcn_chapter .chapter__author a:hover {
  color: var(--fcv3-primary);
}

/* == NOTES / FOREWORD / WARNINGS ========================================== */

body.fcv3-dark.single-fcn_chapter .chapter .infobox {
  border: 1px solid var(--fcv3-border-soft);
  border-radius: var(--fcv3-radius-md);
  background: var(--infobox-background);
}

/* == CHAPTER INDEX DIALOG + FORMATTING MODAL ============================== */

/* Hairline so white modal cards separate from the white page card */
body.fcv3-dark.single-fcn_chapter .dialog-modal._chapter-index,
body.fcv3-dark.single-fcn_chapter .modal__wrapper {
  border: 1px solid var(--fcv3-border);
}
body.fcv3-dark.single-fcn_chapter .dialog-modal._chapter-index {
  font-family: var(--fcv3-font);
}
body.fcv3-dark.single-fcn_chapter .chapter-index__back-link,
body.fcv3-dark.single-fcn_chapter .dialog-modal__close {
  color: var(--fcv3-fg);
}
body.fcv3-dark.single-fcn_chapter .dialog-modal__close:hover {
  color: var(--fcv3-primary);
}
body.fcv3-dark.single-fcn_chapter .chapter-index li {
  border-radius: var(--fcv3-radius-md);
  color: var(--fcv3-fg);
}
body.fcv3-dark.single-fcn_chapter .chapter-index li:hover {
  background-color: rgba(var(--fcv3-border-rgb), 0.3);
}
body.fcv3-dark.single-fcn_chapter .chapter-index li.current {
  color: var(--fcv3-primary);
}

/* == SUPPORT LINKS (Ko-fi etc.) =========================================== */

body.fcv3-dark.single-fcn_chapter .chapter__support {
  margin-top: 2rem;
  color: var(--fcv3-fg-muted);
  font-family: var(--fcv3-font);
}
body.fcv3-dark.single-fcn_chapter .chapter__support a {
  border-radius: var(--fcv3-radius-pill);
  color: var(--fcv3-fg-muted);
  font-size: 0.8125rem;
}
body.fcv3-dark.single-fcn_chapter .chapter__support a:hover {
  background-color: rgba(6, 182, 212, 0.12);
  color: var(--fcv3-primary);
}

/* == COMMENTS ============================================================= */

body.fcv3-dark.single-fcn_chapter .chapter__comments {
  margin-top: 1.5rem;
}
body.fcv3-dark.single-fcn_chapter .fictioneer-comments__title {
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--fcv3-border-soft);
  color: var(--fcv3-fg);
  font-family: var(--fcv3-font);
  font-size: 1.125rem;
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
}
body.fcv3-dark.single-fcn_chapter .load-more-comments-button {
  height: 36px;
  border-radius: var(--fcv3-radius-pill);
  font-family: var(--fcv3-font);
  font-size: 0.8125rem;
  font-weight: 600;
  letter-spacing: 0;
}
/* Comment cards + the respond form: quiet panels on the card. Sticky/private/
   deleted/offensive states keep their own backgrounds from the parent. */
body.fcv3-dark.single-fcn_chapter .fictioneer-comment:not(._sticky) > .fictioneer-comment__container {
  border: 1px solid var(--fcv3-border-soft);
  border-radius: var(--fcv3-radius-md);
}
body.fcv3-dark.single-fcn_chapter .fictioneer-respond__form-identity input,
body.fcv3-dark.single-fcn_chapter .fictioneer-respond__form-comment {
  font-family: var(--fcv3-font);
  color: var(--fcv3-fg);
}
body.fcv3-dark.single-fcn_chapter .fictioneer-respond__form-identity input:focus,
body.fcv3-dark.single-fcn_chapter .fictioneer-respond__form-comment:focus-within {
  box-shadow: inset 0 0 0 1px var(--fcv3-primary), var(--input-validation-shadow, 0 0 transparent);
}

/* == RESPONSIVE =========================================================== */

@media only screen and (max-width: 639px) {
  body.fcv3-dark.single-fcn_chapter .chapter__headline {
    padding: 1rem 0 1.5rem;
  }
  body.fcv3-dark.single-fcn_chapter .chapter__actions .chapter__actions-container {
    gap: 4px;
  }
  body.fcv3-dark.single-fcn_chapter .chapter__actions .chapter__actions-container .button {
    padding-inline: 10px;
  }
}
