/* UKAuthors long-form reading and accessibility enhancements. */
.single-reading {
  --reader-scale: 1;
  --reader-measure: 72ch;
  --reader-bg: #e2ded4;
  --reader-text: #24383f;
  background: var(--reader-bg);
}

.single-reading .article-header { background: var(--reader-bg); }
.single-reading .article-body {
  width: min(var(--reader-measure), calc(100% - 3rem));
  color: var(--reader-text);
  font-size: calc(clamp(1.125rem, 1rem + .35vw, 1.25rem) * var(--reader-scale));
  line-height: 1.8;
  overflow-wrap: anywhere;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}
.single-reading .article-body p { margin: 0 0 1.35em; }
.single-reading .article-body p:last-child { margin-bottom: 0; }
.single-reading .article-body h2,
.single-reading .article-body h3,
.single-reading .article-body h4 { scroll-margin-top: 2rem; text-wrap: balance; }
.single-reading .article-body a { text-decoration-thickness: .08em; text-underline-offset: .16em; }
.single-reading .article-body ul,
.single-reading .article-body ol { padding-left: 1.35em; }
.single-reading .article-body li + li { margin-top: .45em; }
.single-reading .article-body img,
.single-reading .article-body video,
.single-reading .article-body iframe,
.single-reading .article-body object { max-width: 100%; height: auto; }
.single-reading .article-body pre,
.single-reading .article-body table { display: block; max-width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.single-reading .article-body blockquote p:last-child { margin-bottom: 0; }

.reader-tools {
  position: sticky;
  top: .75rem;
  z-index: 20;
  width: min(780px, calc(100% - 2rem));
  margin: 1rem auto -3rem;
  display: flex;
  justify-content: flex-end;
  pointer-events: none;
}
.reader-tools details { pointer-events: auto; }
.reader-tools summary {
  display: inline-flex;
  align-items: center;
  gap: .45rem;
  min-height: 44px;
  padding: .65rem .9rem;
  color: #fff;
  background: #173540;
  border: 1px solid rgba(255,255,255,.25);
  border-radius: 999px;
  box-shadow: 0 8px 24px rgba(0,0,0,.16);
  font-size: .78rem;
  font-weight: 700;
  letter-spacing: .04em;
  cursor: pointer;
  list-style: none;
}
.reader-tools summary::-webkit-details-marker { display: none; }
.reader-tools summary:focus-visible,
.reader-control:focus-visible { outline: 3px solid #d3b878; outline-offset: 3px; }
.reader-tools-panel {
  width: min(330px, calc(100vw - 2rem));
  margin-top: .55rem;
  padding: 1rem;
  color: #24383f;
  background: #fffdf8;
  border: 1px solid #cfc4af;
  border-radius: 10px;
  box-shadow: 0 16px 40px rgba(0,0,0,.18);
}
.reader-tools-row { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .65rem; }
.reader-tools-label { margin: .8rem 0 0; font-size: .72rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.reader-tools-label:first-child { margin-top: 0; }
.reader-control {
  min-width: 44px;
  min-height: 44px;
  padding: .55rem .7rem;
  color: #24383f;
  background: #f4efe5;
  border: 1px solid #cfc4af;
  border-radius: 6px;
  font: inherit;
  cursor: pointer;
}
.reader-control[aria-pressed="true"] { color: #fff; background: #2f735d; border-color: #2f735d; }
.reader-reset { width: 100%; margin-top: .9rem; }

.single-reading.reader-font-large { --reader-scale: 1.14; }
.single-reading.reader-font-xlarge { --reader-scale: 1.28; }
.single-reading.reader-width-narrow { --reader-measure: 60ch; }
.single-reading.reader-width-wide { --reader-measure: 82ch; }
.single-reading.reader-sans .article-body { font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
.single-reading.reader-sepia { --reader-bg: #f2e7cf; --reader-text: #3d3428; }
.single-reading.reader-dark { --reader-bg: #172126; --reader-text: #edf2ee; }
.single-reading.reader-dark .article-header { border-bottom-color: #35454a; }
.single-reading.reader-dark .article-deck,
.single-reading.reader-dark .published-date,
.single-reading.reader-dark .post-stats { color: #c7d0cd; }
.single-reading.reader-dark .article-heading h1,
.single-reading.reader-dark .article-heading a,
.single-reading.reader-dark .article-body a { color: #f4e4b8; }
.single-reading.reader-dark .article-footer,
.single-reading.reader-dark .post-navigation-literary { border-color: #35454a; }
.single-reading.reader-dark .article-footer,
.single-reading.reader-dark .comments-shell { color: #edf2ee; }

@media (max-width: 720px) {
  .single-reading .article-heading { padding: 3.5rem 1rem 3rem; }
  .single-reading .article-heading h1 { font-size: clamp(2.6rem, 13vw, 3.8rem); line-height: .94; overflow-wrap: anywhere; }
  .single-reading .article-deck { font-size: 1.2rem; line-height: 1.45; }
  .single-reading .article-body {
    width: calc(100% - 2rem);
    padding: 4.5rem 0 3rem;
    font-size: calc(1.125rem * var(--reader-scale));
    line-height: 1.72;
  }
  .single-reading .article-body h2 { font-size: 2rem; }
  .single-reading .article-body h3 { font-size: 1.55rem; }
  .single-reading .article-body blockquote { margin: 2rem 0; padding: 1rem 1.15rem; font-size: 1.35rem; }
  .reader-tools { top: .5rem; margin: .75rem auto -3.2rem; }
  .reader-tools-panel { max-height: calc(100vh - 6rem); overflow-y: auto; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}

@media (forced-colors: active) {
  .reader-tools summary,
  .reader-control { border: 1px solid ButtonText; }
}
