/* Reading-room additions. Shared navigation and study primitives stay in upsc.css. */
@font-face {
  font-family: "Newsreader";
  font-style: normal;
  font-weight: 200 800;
  font-display: swap;
  src: url("../fonts/newsreader-latin.woff2") format("woff2");
}

@font-face {
  font-family: "Public Sans";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("../fonts/public-sans-latin.woff2") format("woff2");
}

:root {
  color-scheme: light;
  --bg: #faf9f6;
  --paper: #fffefa;
  --white: #fffefa;
  --text: #262c29;
  --gray: #626761;
  --blue: #315d4d;
  --editorial-accent: #315d4d;
  --editorial-wash: #efefe7;
  --rule: #dfdfd6;
  --rule-strong: #a8aea5;
  --input-bg: #fffefa;
  --panel-muted: #efefe7;
  --editorial-max: 1100px;
  --reading-measure: 660px;
  --upsc-scroll-offset: 48px;
  --upsc-reader-offset: 48px;
  --sans: "Public Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --serif: "Newsreader", "Iowan Old Style", Georgia, serif;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #181d1a;
  --paper: #202722;
  --white: #202722;
  --text: #eeeee5;
  --gray: #b2b9b0;
  --blue: #a1c8b4;
  --editorial-accent: #a1c8b4;
  --editorial-wash: #272f29;
  --rule: #3b453d;
  --rule-strong: #737e73;
  --input-bg: #202722;
  --panel-muted: #272f29;
}

:root, :root[data-theme="dark"] {
  --an-ink: var(--text);
  --an-navy: var(--blue);
  --an-maroon: var(--blue);
}

/* Published archive pages remain JavaScript-free and follow the device theme. */
@media (prefers-color-scheme: dark) {
  :root.upsc-static {
    color-scheme: dark;
    --bg: #181d1a;
    --text: #eeeee5;
    --gray: #b2b9b0;
    --blue: #a1c8b4;
    --rule: #3b453d;
    --editorial-wash: #272f29;
  }
}

.an-editorial-masthead { padding: 104px 24px 28px; }
.an-editorial-masthead h1 { font-size: clamp(50px, 8vw, 84px); }
.an-edition-line { flex-wrap: wrap; align-items: center; gap: 4px 20px; letter-spacing: 0; text-transform: none; }
.an-edition-line a { display: inline-flex; align-items: center; min-height: 44px; }
.an-main { padding-top: 40px; }
.an-label { font-size: 12px; }
.an-search { flex-basis: 290px; min-width: 0; }
.an-search input { flex: 1; min-width: 0; font-size: 16px; }
.an-main, .an-primary, .an-entry__body, .an-subject, .an-field { min-width: 0; }
.an-main { overflow-wrap: anywhere; }
.an-viewhead, .an-edition-head, .an-daily__head { flex-wrap: wrap; gap: 16px; }
.an-viewhead > *, .an-edition-head > *, .an-daily__head > * { min-width: 0; }
.an-toolbar, .an-toolbar__right, .an-chips, .an-segmented { flex-wrap: wrap; min-width: 0; }
.an-toolbar__right > select { flex: 1 1 150px; min-width: 0; }
.an-main input, .an-main select, .an-main textarea { max-width: 100%; font-size: 16px; }
.an-main button, .atlas-actions a, .atlas-linkbtn, .atlas-weaklist button { min-height: 44px; }
.an-main summary { min-height: 44px; }
.an-views button { min-height: 44px; }
.atlas-actions a { display: inline-flex; align-items: center; }
.atlas-detail, .atlas-group, .atlas-drill, .atlas-row__head > * { min-width: 0; }
.atlas-row__head h3 { overflow-wrap: anywhere; }
.atlas-prelims, .atlas-drill__ask, .atlas-trigger p { font-size: 17px; line-height: 1.65; }
.ug { max-width: var(--reading-measure); margin-inline: auto; }
.util-head .an-textbtn { min-height: 44px; }
.util-head__meta a { display: inline-flex; align-items: center; min-height: 44px; max-width: 100%; }
.an-source__body, .an-source__stamp { min-width: 0; }
.an-source__summary, .an-source__body h3 { overflow-wrap: anywhere; }
.an-source__summary { font-size: 16px; }
.an-source__stamp, .an-source__stamp strong { font-size: 12px; }
.an-source__stamp { border-right: 1px solid var(--rule); }
.an-viewhead__meta, .an-daily-item__meta { font-size: 12px; }
.an-footer-links { flex-wrap: wrap; }
.an-footer-links a { display: inline-flex; align-items: center; min-height: 44px; }
.an-view { scroll-margin-top: calc(var(--upsc-scroll-offset) + 24px); }
.an-subject-jump { display: flex; flex-wrap: wrap; gap: 8px 20px; overflow: visible; white-space: normal; }
.an-subject-jump a { white-space: normal; }
.sv-coach-panel { max-height: min(72dvh, 640px); }
.sv-coach-panel button { min-height: 44px; }
.sv-coach-panel input, .sv-coach-panel textarea { min-width: 0; font-size: 16px; }
.sv-coach-msg, .sv-coach-sources { overflow-wrap: anywhere; }

.pr-section-head { display: flex; align-items: end; justify-content: space-between; gap: 24px; margin-bottom: 28px; }
.pr-section-head h2 { margin-top: 8px; font-size: clamp(28px, 4vw, 36px); font-weight: 500; text-wrap: balance; }
.pr-shelf + .pr-shelf { margin-top: 48px; }
.pr-shelf__title { margin-bottom: 16px; font: 600 14px/1.5 var(--sans); color: var(--gray); }
.pr-browse { max-width: var(--editorial-max); margin-inline: auto; }
.pr-browse__toggle { display: none; }
.upsc-reading .an-editorial-masthead { display: none; }
.upsc-reading .an-command { margin-top: var(--upsc-nav-height, 48px); }
.upsc-reading .an-main { padding-top: 20px; }
.upsc-reading .pr-browse__toggle { display: list-item; width: fit-content; cursor: pointer; min-height: 44px; padding: 12px 24px; color: var(--blue); font: 14px/1.5 var(--sans); }
.upsc-reading .pr-browse[open] .an-command__inner { padding-top: 0; }
.pr-list { list-style: none; }
.pr-story { border-top: 1px solid var(--rule); }
.pr-story__link { display: grid; grid-template-columns: 120px minmax(0, 1fr) 44px; gap: 28px; padding: 28px 0; color: var(--text); text-decoration: none; }
.pr-story__content { min-width: 0; }
.pr-story__index { font-family: var(--sans); font-size: 12px; color: var(--gray); padding-top: 5px; }
.pr-story__meta, .pr-reader__meta { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; font-family: var(--sans); font-size: 12px; color: var(--gray); }
.pr-story__meta span:first-child { color: var(--blue); font-weight: 600; }
.pr-story :is(h3, h4) { margin: 8px 0 10px; font-size: clamp(25px, 3vw, 32px); font-weight: 500; text-wrap: balance; transition: color 180ms ease; }
.pr-story__link:hover :is(h3, h4) { color: var(--blue); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 5px; }
.pr-story__link:visited :is(h3, h4) { color: var(--gray); }
.pr-story p { max-width: 58ch; font-size: 18px; line-height: 1.6; color: var(--gray); }
.pr-story__arrow { display: flex; align-items: center; justify-content: center; align-self: center; width: 44px; min-height: 44px; font-family: var(--sans); font-size: 24px; color: var(--blue); }
.pr-shelf:first-child .pr-story:first-child { background: var(--editorial-wash); border: 0; border-radius: 4px; margin-bottom: 12px; }
.pr-shelf:first-child .pr-story:first-child .pr-story__link { padding: 28px; grid-template-columns: 100px minmax(0, 1fr) 44px; }
.pr-shelf:first-child .pr-story:first-child :is(h3, h4) { font-size: clamp(28px, 3.5vw, 38px); }
.pr-message { padding: 28px 0; color: var(--gray); font-family: var(--sans); font-size: 16px; }
.pr-message button { margin-top: 12px; }

.pr-reader, .pk-packet { max-width: var(--reading-measure); margin: 0 auto 48px; min-width: 0; overflow-wrap: anywhere; }
.pr-reader { scroll-margin-top: calc(var(--upsc-reader-offset) + 16px); }
.pr-reader__back { display: inline-flex; align-items: center; min-height: 44px; margin-bottom: 8px; font-family: var(--sans); font-size: 14px; color: var(--blue); text-underline-offset: 4px; }
.pr-reader h2, .pk-packet h2 { margin: 16px 0; font-size: clamp(36px, 5.5vw, 54px); font-weight: 500; line-height: 1.1; text-wrap: balance; letter-spacing: -0.025em; }
.pr-reader h2, .pk-packet h2, #pocketLibraryTitle, #packetDesk { scroll-margin-top: calc(var(--upsc-scroll-offset) + 48px); }
.pr-reader h2:focus, .pk-packet h2:focus, #pocketLibraryTitle:focus { outline: none; }
.pr-reader h2 { font-size: clamp(32px, 4.5vw, 44px); margin: 12px 0; }
.pr-reader__dek { font-size: 21px; line-height: 1.5; color: var(--gray); }
.pr-reader__body { font-size: 20px; line-height: 1.8; }
.pr-reader__body section { margin-top: 32px; }
.pr-reader__body section:first-child { margin-top: 24px; }
.pr-reader__body h3 { margin-bottom: 14px; font-size: 26px; font-weight: 600; line-height: 1.25; text-wrap: balance; }
.pr-reader__body p + p { margin-top: 18px; }
.pr-reader__tools { display: flex; flex-wrap: wrap; gap: 8px 12px; margin: 16px 0 24px; }
.pr-feed-controls { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px 16px; margin: 12px 0 24px; }
.pr-feed-controls p { color: var(--gray); font: 12px/1.5 var(--sans); }
.pr-feed-controls [role="alert"] { color: var(--text); font-size: 14px; }
.pr-feed-controls .btn { font: 13px/1.4 var(--sans); border-radius: 4px; }
#pocketFeedRefresh { scroll-margin-top: calc(var(--upsc-scroll-offset) + 16px); }
.an-main[data-reading] .pr-feed-controls { margin: 0 0 16px; }
.an-main[data-reading] .pr-feed-controls[data-correction] { position: sticky; top: var(--upsc-scroll-offset); z-index: 20; background: var(--bg); border-bottom: 1px solid var(--rule); padding: 8px 0; }
.pr-section-source { margin-top: 14px; color: var(--gray); font: 12px/1.6 var(--sans); }
.pr-section-source a { display: inline-flex; align-items: center; min-height: 44px; color: var(--blue); text-underline-offset: 3px; }
.pr-reader__tools .btn { border-radius: 4px; font-family: var(--sans); font-size: 14px; }
.pr-example, .pr-comparison { margin: 36px 0; }
.pr-example { padding-left: 20px; border-left: 3px solid var(--blue); }
.pr-example h3, .pr-comparison h3 { margin: 10px 0 16px; font-size: 26px; font-weight: 600; }
.pr-example > p:not(.an-label) { font-size: 20px; line-height: 1.75; }
.pr-comparison table { width: 100%; table-layout: fixed; border-collapse: collapse; font-size: 18px; line-height: 1.6; }
.pr-comparison th, .pr-comparison td { padding: 14px 8px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--rule); overflow-wrap: anywhere; }
.pr-comparison th:first-child { width: 35%; padding-left: 0; }
.pr-comparison thead th { font-family: var(--sans); font-size: 12px; color: var(--gray); font-weight: 600; }
.pr-comparison tbody th { font-weight: 600; }
.pr-question details { margin-top: 12px; }
.pr-question summary { cursor: pointer; padding: 12px 0; font-family: var(--sans); font-size: 14px; color: var(--blue); }
.pr-large-text .pr-reader__body, .pr-large-text .pr-example > p:not(.an-label), .pr-large-text .pr-question p { font-size: 22px; }
.pr-large-text .pr-comparison table { font-size: 20px; }
.pr-reader__sources li > p { font-size: 17px; line-height: 1.6; color: var(--gray); margin: 0 0 20px; }
.sv-coach-toggle[hidden] { display: none; }
.sv-coach-panel--article { z-index: 11000; width: min(480px, calc(100vw - 32px)); max-height: min(760px, calc(var(--sv-visible-height, 100dvh) - 32px)); bottom: calc(16px + var(--sv-keyboard-gap, 0px)); right: 16px; border-radius: 8px; overflow: hidden; }
.sv-coach-panel--article .sv-coach-head { flex-wrap: wrap; }
.sv-coach-panel--article .sv-coach-head h2 { font-size: 22px; }
.sv-coach-panel--article #svCoachMode, .sv-coach-panel--article #svCoachMute { display: none; }
.sv-coach-panel--article .sv-coach-log { min-height: 0; }
.sv-coach-panel--compact .sv-coach-intro, .sv-coach-panel--compact .sv-coach-chips { display: none; }
.sv-coach-panel--article .sv-coach-msg { max-width: 100%; font-size: 17px; line-height: 1.65; padding: 12px 0; border: 0; border-radius: 0; background: transparent; }
.sv-coach-panel--article .sv-coach-msg--user { padding: 12px; background: var(--editorial-wash); color: var(--text); }
.sv-coach-source-state { font-family: var(--sans); font-size: 12px; color: var(--gray); margin-top: 12px; }
.pr-takeaway { margin: 36px 0; padding: 24px; border: 1px solid var(--rule); background: var(--editorial-wash); border-radius: 4px; }
.pr-takeaway h3, .pr-reader__sources h3, .pr-question h3 { margin-bottom: 10px; font-family: var(--sans); font-size: 13px; font-weight: 600; }
.pr-takeaway p, .pr-question p { font-size: 20px; line-height: 1.6; }
.pr-question { margin: 32px 0; }
.pr-reader__sources { margin-top: 32px; padding-top: 24px; border-top: 1px solid var(--rule); }
.pr-reader__sources ul { list-style: none; }
.pr-reader__sources a { display: inline-flex; align-items: center; min-height: 44px; font-family: var(--sans); font-size: 14px; color: var(--blue); text-underline-offset: 4px; overflow-wrap: anywhere; }
.pr-reader__sources a:visited { color: var(--gray); }
.pr-reader__actions { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-top: 24px; }
.pr-reader__actions .btn { border-radius: 4px; font: 14px/1.5 var(--sans); }
.pr-reader__actions .btn-primary { background: var(--blue); color: var(--bg); }
.pr-save-status { font-family: var(--sans); font-size: 14px; color: var(--blue); }
.pr-reader__next { display: block; margin-top: 32px; padding: 24px 0; border-top: 1px solid var(--rule); color: var(--text); text-decoration: none; }
.pr-reader__next span { display: block; margin-bottom: 8px; font-family: var(--sans); font-size: 12px; color: var(--gray); }
.pr-reader__next strong { font-size: 24px; font-weight: 500; }
.pr-reader__next:hover strong { color: var(--blue); }

.pr-study-tools { border-block: 1px solid var(--rule); margin: 32px 0; }
.pr-study-tools > summary { cursor: pointer; padding: 20px 0; font-family: var(--sans); font-size: 16px; font-weight: 600; }
.pr-study-tools[open] > summary { margin-bottom: 24px; }
.an-main[data-reading] .pr-study-tools,
.an-main[data-reading] .an-source-stream,
.an-main[data-reading] .an-subject-jump,
.an-main[data-reading] .an-reading-tools { display: none; }
.pr-study-tools .an-edition-head { display: none; }
.pk-hero h2 { font-size: 32px; }
.pk-stack h3 { margin-bottom: 16px; }
.pk-card { min-width: 0; padding: 28px 0; overflow-wrap: anywhere; }
.pk-card h3 { font-size: clamp(25px, 3vw, 32px); font-weight: 500; line-height: 1.2; text-wrap: balance; }
.pk-card__actions { margin-top: 16px; }
.pk-card__meta { gap: 8px 16px; }
.pk-card__meta .pk-badge, .pk-paper, .pk-subject, .pk-read { font-size: 12px; letter-spacing: 0; text-transform: none; }
.pk-card__changed { font-size: 18px; line-height: 1.65; }
.pk-packet { padding: 0 0 32px; font-size: 20px; line-height: 1.8; }
.pk-packet__head { padding-bottom: 24px; border-bottom: 1px solid var(--rule); }
.pk-packet__status { margin-top: 16px; font-size: 12px; }
.pk-packet .pk-block, .pk-packet .pk-bridge, .pk-packet .pk-changed,
.pk-packet .pk-vault, .pk-packet .pk-kit, .pk-packet .pk-pyq, .pk-packet .pk-sources { margin: 36px 0; }
.pk-packet .pk-block h3, .pk-packet .pk-bridge h3, .pk-packet .pk-changed h3,
.pk-packet .pk-vault h3, .pk-packet .pk-kit h3, .pk-packet .pk-pyq h3 {
  margin-bottom: 14px; font-family: var(--serif); font-size: 26px; font-weight: 600;
  line-height: 1.25; letter-spacing: 0; text-transform: none; color: var(--text);
}
.pk-packet .pk-block p, .pk-packet .pk-block li, .pk-packet .pk-empty,
.pk-packet .pk-bridge p, .pk-packet .pk-changed dd { font-size: inherit; line-height: inherit; }
.pk-packet li + li { margin-top: 12px; }
.pk-packet .pk-sources { padding-top: 24px; border-top: 1px solid var(--rule); }
.pk-packet .pk-sources h3 { letter-spacing: 0; text-transform: none; }
.pk-packet .pk-sources a { display: inline-block; min-height: 44px; overflow-wrap: anywhere; }
.pk-packet .pk-sticky { position: static; margin-top: 24px; background: transparent; }
.pk-packet .pk-sticky .btn { flex: 1 1 160px; border-radius: 4px; }
.pk-packet .pk-sticky .btn-primary { background: var(--blue); color: var(--bg); }
.pk-packet > p > .btn { max-width: 100%; min-height: 44px; padding: 12px 16px; border-radius: 4px; font-family: var(--sans); font-size: 14px; text-decoration: none; }
.pk-low { margin-bottom: 24px; }
.pk-low summary { min-height: 44px; cursor: pointer; }
.pk-empty, .pk-sources__meta { font-size: 16px; }
.pk-layers { scroll-margin-top: 140px; }
.pk-layers button[aria-pressed="true"] { background: var(--blue); color: var(--bg); border-color: var(--blue); }
.pk-block p, .pk-block li { font-size: 18px; line-height: 1.7; }

.an-source-stream { margin-top: 32px; }
.an-daily__head h2 { font-size: 32px; }
.an-daily-group { padding-top: 28px; margin-top: 28px; }
.an-daily-item__summary { font-size: 18px; line-height: 1.65; }
.an-subject-jump { margin-top: 28px; }
.an-subject-jump a { display: inline-flex; align-items: center; min-height: 44px; }
.an-daily-item h4 a:visited { color: var(--gray); }
.an-reading-tools { margin-top: 28px; }

/* Long sections stay visible; scroll reveal must never hide an article. */
html.sb-motion .sb-reveal { opacity: 1; transform: none; }
html.sb-motion .an-editorial-masthead { transform: none; }
html.sb-motion .an-editorial-masthead::after { display: none; }
html.sb-motion .an-editorial-masthead h1,
html.sb-motion .an-publication-mark,
html.sb-motion .an-edition-line,
html.sb-motion .an-command { animation-duration: 300ms; animation-delay: 0ms; }

@media (max-width: 900px) {
  .an-command__inner { gap: 0; }
  .an-search { flex-basis: auto; }
  .pr-section-head { align-items: start; flex-direction: column; gap: 12px; }
  .an-toolbar__right { width: 100%; margin-left: 0; }
  .an-views { flex-wrap: wrap; overflow: visible; row-gap: 4px; }
  .pr-story__link, .pr-shelf:first-child .pr-story:first-child .pr-story__link { grid-template-columns: 80px minmax(0, 1fr) 44px; gap: 20px; }
}

@media (max-width: 680px) {
  .an-editorial-masthead { padding: 84px 20px 20px; }
  .an-editorial-masthead h1 { font-size: clamp(38px, 10vw, 58px); margin-bottom: 12px; overflow-wrap: anywhere; }
  .util-head h1 { font-size: clamp(36px, 10vw, 52px); }
  .an-edition-line { gap: 4px 14px; }
  .an-main { padding: 28px 20px 64px; }
  .an-views { justify-content: flex-start; gap: 4px; }
  .an-views a, .an-views button { min-width: 44px; min-height: 44px; font-size: 12px; padding-inline: 4px; }
  .an-views .an-count, .an-views .sr-only { display: none; }
  .pr-story__link, .pr-shelf:first-child .pr-story:first-child .pr-story__link { grid-template-columns: minmax(0, 1fr) 44px; gap: 12px; padding: 24px 0; }
  .pr-shelf:first-child .pr-story:first-child .pr-story__link { padding: 24px; }
  .pr-story__content { grid-column: 1 / -1; grid-row: 2; }
  .pr-story__index { display: flex; gap: 12px; padding: 0; }
  .pr-story__arrow { grid-column: 2; grid-row: 1; }
  .pr-story__meta { gap: 8px 12px; }
  .pr-story :is(h3, h4) { font-size: 27px; }
  .pr-shelf:first-child .pr-story:first-child :is(h3, h4) { font-size: 30px; }
  .pr-reader h2, .pk-packet h2 { font-size: clamp(32px, 9.5vw, 38px); }
  .pr-reader h2 { font-size: clamp(30px, 8.3vw, 36px); }
  .pr-reader__dek { font-size: 19px; }
  .upsc-reading .pr-browse__toggle { padding-inline: 20px; }
  .pr-reader__body, .pk-packet { font-size: 19px; line-height: 1.75; }
  .pr-takeaway { padding: 20px; }
  .pr-reader__actions .btn { flex: 1; }
  .an-subject-grid, .an-revision-settings__grid { grid-template-columns: minmax(0, 1fr); }
  .an-entry, .an-daily-item { min-width: 0; }
  .an-entry__tags { flex-wrap: wrap; }
  .an-code, .atlas-recurrence { overflow-wrap: anywhere; }
  .an-state { padding-inline: 0; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .pr-story h3 { transition: none; }
}

@media print {
  body > nav, .an-command, footer, .pr-study-tools, .an-source-stream,
  .an-subject-jump, .an-reading-tools, .pr-reader__actions, .pr-reader__back,
  .pr-reader__next { display: none; }
  .an-editorial-masthead { padding: 0 0 24px; }
  .an-main { padding: 0; }
  .pr-reader { max-width: none; }
  .pr-reader__sources a::after { content: " (" attr(href) ")"; }
}
