/* "Listen to this page" read-aloud control.
   Markup: src/_includes/partials/page-reader.njk
   Behavior: src/js/page-reader.js
   Docs: docs/layouts-and-partials.md, "Page reader"
   A quiet byline under the page's h1: small text-style buttons, no box on
   a light background. It follows the heading's own alignment. Colors come
   from client.css tokens only.

   On the inside-page banner (#inside-header) the byline is small text on
   the brand gradient, whose bright end can drop white text under 4.5:1. So
   there it sits on a soft pill in --primary-color-dark, the color the
   template already puts white text on (button hover), which keeps 4.5:1
   wherever the pill lands on the gradient. */

.page-reader[hidden],
.page-reader [hidden] {
  display: none !important;
}

.page-reader {
  display: block;
  margin-top: 0.375rem;
  font-size: 0.9rem;
  line-height: 1.5;
  color: var(--text-secondary, #6c757d);
  text-align: inherit;
}

#inside-header .page-reader {
  margin-top: 0.5rem;
  color: var(--text-white, #ffffff);
}

#inside-header .page-reader-controls,
#inside-header .page-reader-note {
  display: inline-block;
  padding: 0.125rem 0.875rem;
  border-radius: 999px;
  background-color: var(--primary-color-dark);
}

.page-reader-btn {
  display: inline-block;
  min-height: 24px;
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  line-height: 24px;
  vertical-align: baseline;
  cursor: pointer;
}

.page-reader-btn:hover .page-reader-label,
.page-reader-btn:focus-visible .page-reader-label {
  text-decoration: underline;
  text-underline-offset: 0.15em;
}

/* The global focus ring is --primary-color, which would vanish on the
   banner's pill; there it is drawn in white. */
#inside-header .page-reader-btn:focus-visible {
  outline-color: var(--text-white, #ffffff);
}

.page-reader-sep {
  margin: 0 0.5em;
}

.page-reader-note {
  margin: 0;
  font-size: inherit;
  color: inherit;
}

/* The block being read: a soft brand tint plus a bar on its left, drawn
   with box-shadow so the text never moves. */
.page-reader-current {
  background-color: rgba(0, 0, 0, 0.06);
  background-color: color-mix(in srgb, var(--primary-color) 12%, transparent);
  box-shadow: -6px 0 0 0 rgba(0, 0, 0, 0.06), -10px 0 0 0 var(--primary-color);
  box-shadow: -6px 0 0 0 color-mix(in srgb, var(--primary-color) 12%, transparent), -10px 0 0 0 var(--primary-color);
  border-radius: 2px;
  transition: background-color 0.2s ease, box-shadow 0.2s ease;
}

/* On the brand banner and the dark treatment bands a brand tint would not
   show, so the highlight is white. */
#inside-header .page-reader-current,
.treatment-band-dark .page-reader-current {
  background-color: rgba(255, 255, 255, 0.14);
  box-shadow: -6px 0 0 0 rgba(255, 255, 255, 0.14), -10px 0 0 0 var(--text-white, #ffffff);
}

/* Phones: grow each control's hit area from 24px to 44px tall. The equal
   negative margin keeps the byline exactly where it sits. */
@media (max-width: 767.98px) {
  .page-reader-btn {
    padding-top: 0.625rem;
    padding-bottom: 0.625rem;
    margin-top: -0.625rem;
    margin-bottom: -0.625rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .page-reader-current {
    transition: none;
  }
}

@media print {
  .page-reader {
    display: none !important;
  }
  .page-reader-current {
    background-color: transparent;
    box-shadow: none;
  }
}
