/* =============================================================================
   PeachPuffTL story page: theme polish + mobile friendly controls
   ============================================================================= */

.story {
  --pp-tap: 2.25rem;
}

.story button,
.story .button,
.story a {
  -webkit-tap-highlight-color: transparent;
}

.story .button,
.story .tabs__item,
.story .story__toggle,
.story .chapter-group__folding-toggle {
  touch-action: manipulation;
}

/* ---- Header ---- */

.story__identity h1 {
  font-size: clamp(24px, 2.2vw + 14px, 34px);
  font-weight: 800;
  line-height: 1.15;
  letter-spacing: 0.005em;
  text-wrap: balance;
}

.story__identity-meta {
  color: var(--fg-700);
  font-family: var(--ff-note);
  font-size: var(--fs-s, 0.95rem);
  font-style: normal;
  font-weight: var(--font-weight-semi-strong);
}

.story__identity-meta a {
  text-decoration: none;
}

.story__thumbnail a {
  border-radius: 16px;
}

.story__thumbnail img {
  border-radius: 14px;
}

/* ---- Description ---- */

.story__summary {
  font-family: var(--ff-base);
  font-size: 1rem;
  line-height: 1.7;
}

.story__summary a:not(.pp-cta__btn):not(.pp-cta__link) {
  color: var(--primary-500);
  font-weight: var(--font-weight-strong);
  text-decoration: none;
}

/* Tags and warnings under the description */

.story__tags-and-warnings {
  margin-top: 0.5rem;
}

/* ---- Buttons under the description ---- */

.story__after-summary {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem 1rem;
}

.story__after-summary .media-buttons {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem;
}

.story__after-summary .media-buttons__item {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2.5rem;
  min-height: 2.5rem;
  border-radius: 50%;
}

/* Share / feed icons are removed (inc/share-buttons.php), no empty row left behind */
.story__after-summary .media-buttons:empty,
.chapter .media-buttons:empty {
  display: none;
}

.story__actions {
  flex-wrap: wrap;
  gap: 0.5rem;
}

.story__actions > .button,
.story__actions > .button:first-child,
.story__actions > .button:last-child {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  width: auto;
  height: auto;
  min-height: 2.75rem;
  padding: 0.5rem 1.2rem;
  font-family: var(--ff-heading);
  font-size: 1.02rem;
  font-weight: 700;
  line-height: 1.1;
  background: var(--pp-card);
  border-radius: 999px;
  box-shadow: inset 0 0 0 2px var(--pp-rule-strong);
  transition: background-color var(--transition-duration), box-shadow var(--transition-duration);
}

.story__actions > .button:hover {
  background: var(--pp-card-2);
  box-shadow: inset 0 0 0 2px var(--pp-coral);
}

.story__actions > .button > div:first-child {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

/* ---- Tabs and chapter toggles ---- */

.story__tabs {
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.75rem;
}

.story__tabs .tabs {
  gap: 0.4rem;
}

.story__tabs .tabs__item,
.story__tabs .tabs__item:first-of-type,
.story__tabs .tabs__item:last-of-type {
  min-height: 2.25rem;
  padding: 0.5rem 1rem;
  font-family: var(--ff-heading);
  font-size: 0.95rem;
  font-weight: 700;
  border-radius: 999px;
}

.story__chapter-list-toggles {
  display: flex;
  gap: 0.4rem;
}

.story__toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2.5rem;
  min-height: 2.5rem;
  border-radius: 50%;
}

.story__toggle:hover {
  background: var(--pp-card-2);
}

/* ---- Chapter list ---- */

.story__chapters .chapter-group__list-item {
  position: relative;
  min-height: 3.25rem;
  border-radius: 14px;
}

/* The whole row opens the chapter, not only the title */
.story__chapters a.chapter-group__list-item-link[href]::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
}

.story__chapters .chapter-group__list-item-checkmark {
  position: relative;
  z-index: 2;
}

.story__chapters a.chapter-group__list-item-link[href]:focus-visible {
  outline: none;
}

.story__chapters .chapter-group__list-item:has(a.chapter-group__list-item-link[href]:focus-visible) {
  outline: 3px solid var(--pp-gold);
  outline-offset: 2px;
}

.chapter-group__list-item:active:has(a[href]) {
  background: var(--pp-card-2);
}

/* "Show 26 more" */

.story .chapter-group .chapter-group__folding-toggle {
  min-height: 3rem;
  padding: 0.75rem 1rem;
  color: var(--fg-500);
  font-family: var(--ff-heading);
  font-size: 1rem;
  font-weight: 700;
  border: 2px dashed var(--pp-rule-strong);
  border-radius: 14px;
  transition: color var(--transition-duration), border-color var(--transition-duration), background-color var(--transition-duration);
}

.story .chapter-group .chapter-group__folding-toggle:hover {
  color: var(--primary-500);
  background: var(--pp-surface);
  border-color: var(--pp-coral);
}

/* ---- Footer ---- */

.story__footer {
  align-items: center;
  gap: 0.75rem 1rem;
}

.story__meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 0.4rem 1rem;
}

.story__meta-checkmark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2.25rem;
  min-height: 2.25rem;
}

/* ---- Sticky bottom bar (phones) ---- */

.pp-sticky {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 90;
  display: none;
  gap: 0.6rem;
  padding: 0.45rem 0.6rem calc(0.45rem + env(safe-area-inset-bottom, 0px));
  background: var(--card-bg-color, var(--bg-100));
  border-top: 3px solid var(--pp-peach);
  box-shadow: 0 -8px 24px -10px color-mix(in srgb, var(--pp-shadow-c) 35%, transparent);
  transform: translateY(110%);
  transition: transform 0.25s ease;
}

.pp-sticky[hidden] {
  display: none !important;
}

.pp-sticky.is-visible {
  transform: none;
}

.pp-sticky__main,
.pp-sticky__list {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.5rem;
  font-family: var(--ff-heading);
  font-size: 0.95rem;
  font-weight: 700;
  line-height: 1.1;
  text-decoration: none;
  border-radius: 999px;
}

.pp-sticky__main {
  flex: 1 1 auto;
  min-width: 0;
  flex-direction: column;
  padding: 0.3rem 0.9rem;
  color: #fff;
  background: var(--button-primary-background, var(--pp-coral));
  box-shadow: var(--button-box-shadow, 0 2px 0 rgb(0 0 0 / 20%));
}

:root:not([data-mode="light"]) .pp-sticky__main {
  color: var(--fg-100);
}

.pp-sticky__main:active {
  box-shadow: none;
  transform: translateY(1px);
}

.pp-sticky__list {
  flex: 0 0 auto;
  gap: 0.35rem;
  padding: 0.4rem 0.9rem;
  color: var(--fg-300);
  white-space: nowrap;
  background: var(--pp-card);
  border: 0;
  box-shadow: inset 0 0 0 2px var(--pp-rule-strong);
  cursor: pointer;
}

.pp-sticky__plus::before {
  content: "+";
  display: inline-block;
  width: 1.1rem;
  height: 1.1rem;
  color: #fff;
  font-size: 0.9rem;
  line-height: 1.1rem;
  text-align: center;
  background: var(--pp-coral);
  border-radius: 50%;
}

.pp-sticky__list[aria-pressed="true"] {
  color: var(--green-600, #43603a);
  background: color-mix(in srgb, var(--pp-leaf) 16%, transparent);
  box-shadow: inset 0 0 0 2px var(--pp-leaf);
}

:root:not([data-mode="light"]) .pp-sticky__list[aria-pressed="true"] {
  color: var(--green-400);
}

.pp-sticky__list[aria-pressed="true"] .pp-sticky__plus::before {
  content: "\2713";
  background: var(--pp-leaf);
}


.pp-sticky__main:focus-visible,
.pp-sticky__list:focus-visible {
  outline: 3px solid var(--pp-gold);
  outline-offset: 2px;
}

#tabs-anchor,
.story__tabs {
  scroll-margin-top: calc(var(--nav-height, 48px) + 1rem);
}

/* ---- Phones and small tablets ---- */

@media (max-width: 760px) {
  .pp-sticky {
    display: flex;
  }

  /* Leave room so the bar never covers the page footer */
  body.pp-has-sticky .footer {
    padding-bottom: 5rem;
  }

  /* The bottom bar replaces the Continue / Shelf buttons in the page */
  body.pp-has-sticky .pp-cta {
    display: none;
  }
}

@media (max-width: 640px) {
  /* Chapter rows: bigger text, bigger rows */
  .story__chapters {
    --chapter-list-link-font-size: 15.5px;
    --chapter-list-subrow-font-size: 12.5px;
  }

  .story__chapters .chapter-group__list-item {
    min-height: 3.75rem;
    padding-top: 0.7rem;
    padding-bottom: 0.7rem;
  }

  .story__chapters .chapter-group__list-item-checkmark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: var(--pp-tap);
    min-height: var(--pp-tap);
    margin: -0.5rem -0.5rem -0.5rem 0;
  }

  .story .chapter-group .chapter-group__folding-toggle {
    min-height: 3.5rem;
    font-size: 1.05rem;
  }

  /* Buttons under the description: easy to hit, evenly sized */
  .story__after-summary {
    flex-direction: column;
    align-items: stretch;
  }

  .story__after-summary .media-buttons {
    justify-content: center;
    gap: 0.5rem;
  }

  .story__after-summary .media-buttons__item {
    min-width: var(--pp-tap);
    min-height: var(--pp-tap);
    background: var(--pp-card);
  }

  .story__actions {
    display: flex;
    align-items: stretch;
  }

  .story__actions > .button,
  .story__actions > .button:first-child,
  .story__actions > .button:last-child {
    flex: 1 1 0;
    width: auto;
    height: auto;
  }

  .story__actions > .button,
  .story__actions > .button:first-child,
  .story__actions > .button:last-child {
    min-height: var(--pp-tap);
  }

  /* Start here / Continue reading and the shelf button side by side */
  .pp-cta {
    gap: 0.6rem;
    margin: 1.25rem 0 1rem;
  }

  .pp-cta .pp-cta__btn {
    flex: 0 1 auto;
    min-width: 0;
    padding-right: 1rem;
    padding-left: 1rem;
    font-size: 0.95rem;
  }


  .story__tabs .tabs__item {
    min-height: var(--pp-tap);
  }

  .story__toggle {
    min-width: var(--pp-tap);
    min-height: var(--pp-tap);
  }

  /* Footer: stats on one line, details below */
  .story__footer {
    flex-direction: column;
    align-items: stretch;
  }

  .story__meta {
    justify-content: flex-start;
  }
}

@media (prefers-reduced-motion: reduce) {
  .pp-sticky,
  .story__actions > .button,
}

/* ---- Phones: compact controls (whole chapter rows stay easy to tap) ---- */

@media (max-width: 640px) {
  .story .pp-cta {
    gap: 0.5rem;
    margin: 1rem 0 0.75rem;
  }

  .story .pp-cta .pp-cta__btn {
    min-height: 2.2rem;
    padding: 0.25rem 0.8rem;
    font-size: 0.88rem;
    white-space: nowrap;
  }

  .story .pp-cta .pp-cta__icon::before {
    width: 1.1rem;
    height: 1.1rem;
    font-size: 0.9rem;
    line-height: 1.1rem;
  }

  .story__after-summary {
    gap: 0.5rem;
  }

  .story__after-summary .media-buttons__item {
    min-width: 2.25rem;
    min-height: 2.25rem;
    font-size: 0.9rem;
  }

  .story__actions {
    gap: 0.4rem;
    flex-wrap: nowrap;
  }

  .story__actions > .button,
  .story__actions > .button:first-child,
  .story__actions > .button:last-child {
    flex: 1 1 auto;
    min-height: 2.45rem;
    padding: 0.3rem 0.8rem;
    font-size: 0.92rem;
    white-space: nowrap;
  }

  .story__tabs .tabs__item,
  .story__tabs .tabs__item:first-of-type,
  .story__tabs .tabs__item:last-of-type {
    min-height: 2.1rem;
    padding: 0.35rem 0.9rem;
    font-size: 0.85rem;
  }


  .story__toggle {
    min-width: 2.25rem;
    min-height: 2.25rem;
  }

  .story__chapters {
    --chapter-list-link-font-size: 14.5px;
  }

  .story__chapters .chapter-group__list-item {
    min-height: 3.25rem;
    padding-top: 0.55rem;
    padding-bottom: 0.55rem;
  }

  .story .chapter-group .chapter-group__folding-toggle {
    min-height: 2.75rem;
    font-size: 0.95rem;
  }

  .pp-sticky__main,
  .pp-sticky__list {
    min-height: 2.5rem;
  }
}

/* ---- Very small Subscribe / Read Later / Follow buttons (all screen sizes) ---- */

.story .story__actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-start;
  gap: 0.3rem;
}

.story .story__actions > .button,
.story .story__actions > .button:first-child,
.story .story__actions > .button:last-child {
  flex: 0 0 auto;
  min-height: 0;
  height: auto;
  padding: 0.12rem 0.5rem;
  gap: 0.25rem;
  font-size: 0.68rem;
  line-height: 1.1;
  box-shadow: inset 0 0 0 1px var(--pp-rule-strong);
}

.story .story__actions > .button:hover {
  box-shadow: inset 0 0 0 1px var(--pp-coral);
}

.story .story__actions > .button > div:first-child {
  gap: 0.25rem;
}

.story .story__actions > .button i,
.story .story__actions > .button svg {
  font-size: 0.65rem;
  width: 0.7rem;
  height: 0.7rem;
}
