/* Paper, ink and press rules */
:root {
  color-scheme: light;
  --paper: #faf7f0;
  --panel: #f1ebe1;
  --ink: #211f1d;
  --muted: #615c56;
  --rule: #c9c1b6;
  --control: #978d80;
  --wine: #75263b;
  --tint: #f1e7e4;
  --bar: #152032;
  --bar-ink: #faf7f0;
  --serif: Georgia, 'Times New Roman', serif;
  --sans: 'Segoe UI', Arial, sans-serif;
}
html.dark {
  color-scheme: dark;
  --paper: #1b1c1f;
  --panel: #26262a;
  --ink: #f3ede2;
  --muted: #c2bcb4;
  --rule: #53504f;
  --control: #898480;
  --wine: #f1a4b3;
  --tint: #34272d;
  --bar: #101722;
}
* { box-sizing: border-box; }
body {
  background: var(--paper);
  color: var(--ink);
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font: 1rem/1.5 var(--sans);
  transition: background-color .22s ease, color .22s ease;
}
h1, h2, h3, p { margin: 0; }
button, input, textarea, select { font: inherit; color: inherit; }
button { background: transparent; border: 0; padding: 0; cursor: pointer; }
button, a, input { transition: color .16s, background-color .16s, border-color .16s; }
button, a { touch-action: manipulation; }
button:focus-visible, a:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible, section:focus-visible {
  outline: 2px solid var(--wine);
  outline-offset: 3px;
}
::selection { background: var(--wine); color: var(--paper); }
.container { width: min(88%, 81rem); margin-inline: auto; }
main { flex: 1; }
.hidden, .symbols { display: none !important; }
.icon { width: 1.1em; height: 1.1em; fill: none; stroke: currentColor; stroke-width: 1.65; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.sr-only, .skip-link:not(:focus) { position: absolute; width: 1px; height: 1px; clip-path: inset(50%); overflow: hidden; white-space: nowrap; }
.skip-link:focus { position: absolute; z-index: 3; inset: .5rem auto auto .5rem; background: var(--paper); color: var(--ink); padding: .65rem 1rem; }

/* Utility strip, masthead and folio navigation */
.utility { background: var(--bar); color: var(--bar-ink); }
.utility-inner, .dateline, .utility-actions, .utility-actions button { display: flex; align-items: center; }
.utility-inner { justify-content: space-between; min-height: 3.1rem; gap: .75rem; }
.dateline { gap: .65rem; font-size: .875rem; font-variant-numeric: tabular-nums; }
.dateline .icon { opacity: .85; }
.utility-actions { gap: .8rem; }
.utility-actions button { justify-content: center; gap: .45rem; min-height: 44px; font-size: .875rem; }
.utility-actions button:hover { text-decoration: underline; text-underline-offset: .22em; }
.utility-actions .import-btn { color: #24252a; background: #f1eade; border-radius: 2px; min-height: 36px; padding-inline: .9rem; font-weight: 600; }
.utility-actions .theme-btn { width: 44px; border-left: 1px solid #586171; }
.theme-btn .icon { width: 1.15rem; height: 1.15rem; }
.theme-btn .icon:last-child, .dark .theme-btn .icon:first-child { display: none; }
.dark .theme-btn .icon:last-child { display: block; }
.utility :focus-visible { outline-color: #f5deb9; }
.masthead { display: flex; align-items: center; justify-content: center; position: relative; padding: clamp(1.8rem, 3.5vw, 3.7rem) 5rem clamp(1.5rem, 2.7vw, 2.9rem); }
.masthead h1 { font: bold clamp(2.4rem, 6.5vw, 6.45rem)/.98 'Times New Roman', Georgia, serif; letter-spacing: -.055em; text-align: center; text-transform: uppercase; }
.masthead img { position: absolute; right: .2rem; width: clamp(2.6rem, 4.4vw, 4.2rem); height: auto; border-radius: 16%; }
.category-nav { display: flex; align-items: stretch; justify-content: space-between; gap: .35rem; border-block: 3px double var(--ink); }
.category-nav button { padding: .7rem clamp(.35rem, 1vw, 1.25rem); white-space: nowrap; position: relative; font: 1.08rem/1.35 var(--serif); min-height: 44px; }
.category-nav button[aria-pressed=true] { color: var(--wine); font-weight: bold; }
.category-nav button[aria-pressed=true]::after { content: ''; position: absolute; inset: auto .3rem 0; height: 3px; background: currentColor; }
.category-nav button:hover, .rubric:hover { color: var(--wine); background: var(--panel); }
.category-nav button:focus-visible { outline-offset: -3px; }

/* Edition status and search */
.toolbar { border-bottom: 1px solid var(--rule); display: flex; align-items: center; justify-content: space-between; gap: 1.25rem; padding: 1.15rem 0; }
.status-row, .toolbar-controls, .badge, .btn, .search-box { display: flex; align-items: center; }
.status-row { gap: .8rem; flex-wrap: wrap; }
.badge { gap: .5rem; background: var(--panel); font-size: .83rem; font-weight: 600; padding: .18rem .65rem; border-radius: 2px; }
.badge-dot { width: .48rem; height: .48rem; border-radius: 100%; background: #af7021; }
.ready .badge-dot { background: #45835c; }
#articleCountLabel, .edition-info p { font-size: .82rem; color: var(--muted); }
.edition-info p { margin-top: .4rem; }
.toolbar-controls { gap: .5rem; flex-shrink: 0; }
.search-box { position: relative; }
.search-box .icon { position: absolute; left: .75rem; color: var(--muted); pointer-events: none; }
.search-box input, .input-field, .textarea-code { background: var(--paper); border: 1px solid var(--control); border-radius: 2px; min-height: 44px; }
.search-box input { width: clamp(11.5rem, 17vw, 16rem); padding: .55rem .55rem .55rem 2.25rem; font-size: .9rem; }
::placeholder { color: var(--muted); opacity: 1; }
.btn { justify-content: center; gap: .5rem; border: 1px solid var(--control); min-height: 44px; padding: .5rem .85rem; border-radius: 2px; font-size: .9rem; font-weight: 600; background: var(--panel); }
.btn:hover { border-color: var(--ink); }
.btn-primary { background: var(--wine); border-color: var(--wine); color: var(--paper); }

/* The front page */
.edition-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(12.5rem, 22%); gap: clamp(1.5rem, 3.3vw, 3.6rem); align-items: start; padding-block: clamp(1.8rem, 3.2vw, 3.4rem) 3.5rem; }
.story { overflow-wrap: anywhere; }
.story + .story { border-top: 1px solid var(--ink); margin-top: 2.75rem; padding-top: 1.8rem; }
.story-meta { display: flex; align-items: center; flex-wrap: wrap; gap: .5rem .75rem; }
.section-label, .lead-label { font: 700 .75rem/1.4 var(--sans); text-transform: uppercase; letter-spacing: .095em; }
.section-label { color: var(--wine); }
.lead-label { color: #fff9f0; background: #75263b; padding: .32rem .62rem; }
.story-date { font-size: .83rem; color: var(--muted); border-left: 1px solid var(--control); padding-left: .75rem; }
.story h2, .empty-state h2 { font: bold clamp(1.85rem, 3vw, 3rem)/1.08 var(--serif); letter-spacing: -.045em; margin: .9rem 0 1.15rem; text-wrap: pretty; }
.lead h2 { font-size: clamp(2.45rem, 4.25vw, 4.5rem); }
.story-copy { display: flow-root; }
.story-photo { max-width: 100%; height: auto; max-height: 32rem; object-fit: contain; display: block; margin-bottom: 1.2rem; }
.story-copy:has(.story-photo) { display: grid; grid-template-columns: 1.15fr 1fr; align-items: start; gap: 1.4rem; }
.story-copy:has(.story-photo) .story-photo { width: 100%; }
.summary { font: 1.16rem/1.65 var(--serif); max-width: 70ch; }
.lead .summary { font-size: clamp(1.18rem, 1.45vw, 1.42rem); line-height: 1.56; }
.lead .story-copy:not(:has(.story-photo)) .summary::first-letter { float: left; font: normal 3.6em/.82 var(--serif); color: var(--wine); padding: .08em .09em 0 0; }
.impact { margin: 1.55rem 0 .2rem; border-left: 3px solid var(--wine); padding: 1rem 1.35rem 1.1rem; background: var(--panel); }
.impact h3 { font: italic bold 1.35rem/1.3 var(--serif); color: var(--wine); margin-bottom: .35rem; }
.impact p { font: 1.07rem/1.6 var(--serif); max-width: 78ch; }
.story-footer { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-top: 1.45rem; border-top: 1px solid var(--rule); padding-top: 1rem; }
.sources h3 { font-size: .75rem; color: var(--muted); }
.source-links { display: flex; flex-wrap: wrap; gap: 0 1.2rem; }
.source-links a, .read-toggle, .link-btn { color: var(--wine); font-weight: 600; font-size: .9rem; }
.source-links a, .read-toggle { display: inline-flex; align-items: center; gap: .4rem; min-height: 44px; }
.source-links a { text-decoration-thickness: 1px; text-underline-offset: .2em; }
.source-links a:hover, .link-btn:hover { color: var(--ink); }
.source-links .icon { width: .82em; }
.read-toggle { margin-left: auto; color: var(--muted); }
.read-toggle:hover, .read-toggle[aria-pressed=true] { color: var(--wine); }
.read-toggle[aria-pressed=true] .icon { fill: currentColor; }
aside { border-left: 1px solid var(--rule); padding-left: clamp(1.2rem, 2vw, 2.1rem); }
aside h2 { display: flex; align-items: center; gap: .6rem; padding: .3rem 0 .8rem; border-bottom: 2px solid var(--wine); }
aside h2 .icon { width: 1rem; height: 1rem; }
.rubric { width: 100%; display: flex; align-items: baseline; justify-content: space-between; text-align: left; gap: .6rem; padding: 1rem .1rem; min-height: 44px; border-bottom: 1px solid var(--rule); font: 1.22rem/1.25 var(--serif); }
.rubric.has-news { color: var(--wine); }
.rubric[aria-pressed=true] { font-weight: bold; background: var(--panel); }
.rubric-count { color: var(--muted); font: .9rem/1.4 var(--sans); font-variant-numeric: tabular-nums; }
.has-news .rubric-count { color: var(--wine); }
.empty-state { padding: clamp(1rem, 4vw, 4rem) 0; }
.empty-state p { color: var(--muted); margin-bottom: 1.2rem; }
.site-footer { border-top: 3px double var(--ink); padding: 1.2rem 0 1.8rem; display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: .4rem 1rem; }
.footer-brand { font: bold 1.4rem/1.5 var(--serif); letter-spacing: -.045em; }
#editionSource { display: block; color: var(--muted); font-size: .8rem; }
.link-btn { min-height: 44px; text-decoration: underline; text-underline-offset: .22em; }

/* Edition dialogs */
dialog { background: var(--paper); color: var(--ink); width: min(39rem, calc(100% - 1.5rem)); max-height: min(90dvh, 52rem); padding: 0; border: 1px solid var(--control); border-top: 4px solid var(--wine); }
dialog::backdrop { background: rgb(14 18 25 / .66); }
body:has(dialog[open]) { overflow-y: hidden; }
.modal-card { padding: clamp(1rem, 3vw, 2.1rem); }
.modal-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; border-bottom: 1px solid var(--rule); padding-bottom: 1rem; margin-bottom: 1rem; }
.modal-header h2 { font: bold 2rem/1.1 var(--serif); letter-spacing: -.035em; }
.modal-header p { margin-top: .45rem; }
.muted-text, .rules-list { color: var(--muted); }
.btn-icon { min-width: 44px; padding: 0; font-size: 1.5rem; background: transparent; }
.tab-bar { display: flex; gap: 1.2rem; border-bottom: 1px solid var(--rule); margin-bottom: 1rem; }
.tab-btn { min-height: 44px; font-weight: 600; border-bottom: 2px solid transparent; }
.tab-btn[aria-pressed=true] { border-color: var(--wine); color: var(--wine); }
.tab-panel, .form-group { display: grid; gap: .9rem; }
.form-group { gap: .3rem; }
.form-grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
.field-header, .modal-footer-actions { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: .4rem; }
.modal-footer-actions { justify-content: flex-end; }
.field-header label, .form-group label { font-size: .9rem; font-weight: 600; }
.input-field, .textarea-code { width: 100%; min-width: 0; padding: .6rem .7rem; }
textarea { resize: vertical; }
.textarea-code { font: .95rem/1.5 Consolas, monospace; }
.error-box { background: var(--tint); color: var(--wine); padding: .7rem 1rem; }
.rules-list { padding-left: 1.2rem; }
.rules-list li { margin-block: .65rem; }
.rules-list strong { color: var(--ink); }
.toast { position: fixed; bottom: 1rem; left: 50%; transform: translateX(-50%); background: var(--ink); color: var(--paper); padding: .7rem 1rem; font-size: .9rem; width: max-content; max-width: 90%; }

/* Reflow for narrow editions */
@media (max-width: 65rem) {
  .container { width: 92%; }
  .category-nav { overflow-x: auto; scrollbar-width: thin; }
  .category-nav button { font-size: 1rem; }
  .toolbar { flex-wrap: wrap; }
  .edition-layout { grid-template-columns: minmax(0,1fr) minmax(11rem,23%); gap: 1.6rem; }
  .story-copy:has(.story-photo) { display: block; }
}
@media (max-width: 44rem) {
  .container { width: calc(100% - 2rem); }
  .utility-inner { flex-wrap: wrap; gap: 0 .7rem; }
  .utility-actions { margin-left: auto; gap: .65rem; }
  .dateline { font-size: .8rem; }
  .masthead { padding: 1.65rem 0 1.35rem; justify-content: space-between; gap: .5rem; }
  .masthead h1 { font-size: clamp(1.4rem, 7.1vw, 3rem); }
  .masthead img { position: static; width: clamp(1.9rem, 6vw, 2.8rem); }
  .category-nav { gap: .5rem; }
  .toolbar { gap: .9rem; padding-block: 1rem; }
  .toolbar-controls { width: 100%; }
  .search-box { flex: 1; min-width: 0; }
  .search-box input { width: 100%; min-width: 0; font-size: 1rem; }
  .edition-layout { grid-template-columns: minmax(0,1fr); padding-block: 1.5rem 2rem; gap: 2rem; }
  .lead h2 { font-size: clamp(2.2rem, 7.8vw, 3.25rem); }
  .story-meta { gap: .4rem .55rem; }
  .section-label, .lead-label { letter-spacing: .065em; }
  .story-footer { gap: .25rem; }
  .impact { padding: .9rem 1rem; }
  aside { border-left: 0; padding: 0; }
  .rubric { padding-block: .75rem; }
  .form-grid-2 { grid-template-columns: minmax(0,1fr); }
}
@media (max-width: 31rem) {
  .utility-inner { justify-content: space-between; }
  .dateline { width: 100%; padding-top: .45rem; }
  .utility-actions { width: 100%; justify-content: flex-end; }
  .utility-actions button:first-child { margin-right: auto; }
}
@media (prefers-reduced-motion: no-preference) {
  .edition-layout, dialog[open] { animation: arrive .25s ease-out both; }
  @keyframes arrive { from { opacity: .35; transform: translateY(3px); } to { opacity: 1; transform: none; } }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
