/* CB Public Portal stylesheet. Tokens first, then base, chrome, documents, pages. */

:root {
  --paper: #ffffff;
  --paper-2: #f5f4f0;
  --paper-3: #ebe9e3;
  --ink: #1b1b1b;
  --ink-2: #454545;
  --ink-3: #6b6b6b;
  --line: #d9d7d1;
  --line-2: #bdbab2;
  --accent: #1a4480;
  --accent-ink: #0e2d5c;
  --accent-soft: #e6eef9;
  --mark: #fff1c2;
  --mark-line: #c58a00;
  --focus: #ffbf47;
  --warn: #8a4b00;

  --sans: "Public Sans", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  --serif: "Source Serif 4", "Source Serif Pro", Georgia, "Times New Roman", serif;
  --mono: ui-monospace, "Cascadia Mono", "SF Mono", Menlo, Consolas, monospace;

  --gutter: 1rem;
  --maxw: 76rem;
  --measure: 42rem;
  --radius: 4px;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.06), 0 4px 16px rgba(0, 0, 0, 0.06);

  color-scheme: light;
}

/* Light by default; dark only when the viewer switches it on (data-theme set by js/theme.js). */
:root[data-theme="dark"] {
  color-scheme: dark;
  --paper: #131416; --paper-2: #1b1d20; --paper-3: #24272b;
  --ink: #e9e7e2; --ink-2: #bdbab3; --ink-3: #8f8c85;
  --line: #2f3236; --line-2: #454950;
  --accent: #8fb6f0; --accent-ink: #b9d2f7; --accent-soft: #1b2a42;
  --mark: #3a3110; --mark-line: #d9a21b;
  --warn: #e3a35a;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 4px 16px rgba(0, 0, 0, 0.4);
}

/* ---------- base ---------- */

*, *::before, *::after { box-sizing: border-box; }
html { font-family: var(--sans); font-size: 100%; -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body { margin: 0; background: var(--paper); color: var(--ink); line-height: 1.5; font-size: 1.0625rem; min-height: 100vh; display: flex; flex-direction: column; }
@media (min-width: 48em) { body { font-size: 1.125rem; } }
main { flex: 1; padding-bottom: 4rem; }

a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 0.15em; }
a:hover { color: var(--accent-ink); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
h1, h2, h3, h4 { line-height: 1.2; margin: 0; font-weight: 700; }
h2 { font-size: 1.35rem; margin-top: 2rem; }
button { font: inherit; color: inherit; cursor: pointer; }
img { max-width: 100%; height: auto; display: block; }
table { border-collapse: collapse; }
code { font-family: var(--mono); font-size: 0.9em; }

.container { width: 100%; max-width: var(--maxw); margin-inline: auto; padding-inline: var(--gutter); }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: var(--gutter); top: -3rem; background: var(--accent); color: #fff; padding: 0.5rem 0.75rem; border-radius: 0 0 var(--radius) var(--radius); z-index: 100; }
.skip:focus { top: 0; }
.muted { color: var(--ink-3); font-size: 0.9rem; }
.mono { font-family: var(--mono); font-size: 0.9em; }

/* ---------- chrome ---------- */

.site-header { border-bottom: 1px solid var(--line); background: var(--paper); position: relative; }
.site-header .container { display: flex; align-items: center; gap: 1rem; padding-block: 0.6rem; }
.menu-toggle { display: grid; place-items: center; width: 2.5rem; height: 2.5rem; background: transparent; border: 1px solid transparent; border-radius: var(--radius); color: var(--ink-2); }
.menu-toggle:hover, .menu-toggle[aria-expanded="true"] { color: var(--ink); background: var(--paper-2); border-color: var(--line); }
.site-nav { display: none; }
.site-nav.open { display: block; position: absolute; left: 0; right: 0; top: 100%; background: var(--paper); border-bottom: 1px solid var(--line); box-shadow: var(--shadow); padding: 0.25rem var(--gutter) 0.75rem; z-index: 40; }
.site-nav ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.site-nav li + li { border-top: 1px solid var(--line); }
.site-nav a { display: block; text-decoration: none; font-weight: 600; font-size: 1rem; padding: 0.75rem 0; }
.site-nav a[aria-current="page"] { color: var(--ink); box-shadow: inset 3px 0 0 var(--accent); padding-left: 0.75rem; }
.header-tools { margin-left: auto; display: flex; gap: 0.5rem; align-items: stretch; }
.theme-toggle, .lang-menu summary { background: transparent; border: 1px solid transparent; border-radius: var(--radius); width: 2.5rem; height: 2.5rem; padding: 0; display: grid; place-items: center; color: var(--ink-2); cursor: pointer; }
.theme-toggle:hover, .lang-menu summary:hover, .lang-menu[open] summary { color: var(--ink); background: var(--paper-2); border-color: var(--line); }
.lang-menu { position: relative; }
.lang-menu summary { list-style: none; }
.lang-menu summary::-webkit-details-marker { display: none; }
.lang-menu img { width: 24px; height: 16px; object-fit: cover; border-radius: 2px; }
.lang-menu ul { position: absolute; right: 0; top: calc(100% + 4px); margin: 0; padding: 0.3rem; list-style: none; background: var(--paper); border: 1px solid var(--line-2); border-radius: 6px; box-shadow: var(--shadow); min-width: 10rem; z-index: 50; }
.lang-menu li a { display: flex; align-items: center; gap: 0.6rem; padding: 0.45rem 0.6rem; text-decoration: none; color: var(--ink); border-radius: var(--radius); font-size: 0.95rem; white-space: nowrap; }
.lang-menu li a:hover { background: var(--paper-2); }
.lang-menu li a[aria-current="true"] { font-weight: 600; }
.theme-toggle .sun { display: none; }
:root[data-theme="dark"] .theme-toggle .sun { display: block; }
:root[data-theme="dark"] .theme-toggle .moon { display: none; }
@media (min-width: 48em) {
  .menu-toggle { display: none; }
  .site-nav, .site-nav.open { display: block; position: static; background: transparent; border: 0; box-shadow: none; padding: 0; }
  .site-nav ul { flex-direction: row; gap: 0.25rem 1.25rem; }
  .site-nav li + li { border-top: 0; }
  .site-nav a { font-size: 0.95rem; padding: 0.25rem 0; }
  .site-nav a[aria-current="page"] { box-shadow: none; padding-left: 0; border-bottom: 3px solid var(--accent); }
}

.crumbs { font-size: 0.875rem; color: var(--ink-3); padding-block: 0.9rem 0; }
.crumbs ol { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 0.35rem; }
.crumbs li + li::before { content: "/"; margin-right: 0.35rem; color: var(--line-2); }
.crumbs a { color: var(--ink-2); }

.bottombar { background: var(--paper-2); border-top: 1px solid var(--line); font-size: 0.8125rem; color: var(--ink-2); }
.bottombar .container { padding-block: 0.6rem; max-width: none; text-align: center; }
.bottombar .nowrap { white-space: nowrap; }
.bottombar .ver { font-family: var(--mono); color: var(--ink-3); margin-left: 0.5rem; }

/* ---------- shared heads ---------- */

.eyebrow { font-size: 0.8125rem; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-3); margin: 0 0 0.5rem; }
.part-head, .doc-head { padding-top: 1rem; max-width: 52rem; }
.part-head h1, .doc-head h1 { font-size: clamp(1.75rem, 1.2rem + 2vw, 2.5rem); letter-spacing: -0.01em; }
.doc-head h1 { font-family: var(--mono); font-size: clamp(1.4rem, 1rem + 1.5vw, 2rem); }
.doc-head .roman { display: block; font-family: var(--sans); font-size: 0.8125rem; font-weight: 600; color: var(--ink-2); letter-spacing: 0.04em; text-transform: uppercase; margin-bottom: 0.3rem; }
.lede { font-size: 1.15em; color: var(--ink-2); margin: 0.75rem 0 0; max-width: var(--measure); line-height: 1.5; }
.doc-meta { margin-top: 0.9rem; font-size: 0.9rem; color: var(--ink-2); }
.doc-meta dl { margin: 0; display: grid; grid-template-columns: max-content 1fr; gap: 0.25rem 0.75rem; }
.doc-meta dt { color: var(--ink-3); }
.doc-meta dd { margin: 0; }

.notice { border: 1px solid var(--line-2); border-left: 4px solid var(--accent); background: var(--paper-2); padding: 0.75rem 1rem; border-radius: var(--radius); margin-top: 1rem; font-size: 0.95rem; max-width: var(--measure); }
.notice.superseded { border-left-color: var(--warn); }
.notice.amended { border-left-color: var(--mark-line); }
.status { display: inline-block; font-size: 0.72rem; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; padding: 0.05rem 0.5rem; border-radius: 999px; border: 1px solid var(--line-2); margin-left: 0.5rem; color: var(--ink-2); vertical-align: middle; }
.status-restated, .status-amended { border-color: var(--mark-line); background: var(--mark); color: var(--ink); }
.status-superseded { border-color: var(--warn); color: var(--warn); }

/* ---------- cards and tables ---------- */

.cards { display: grid; gap: 0.9rem; grid-template-columns: 1fr; margin: 1.5rem 0; }
@media (min-width: 40em) { .cards { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 64em) { .cards { grid-template-columns: repeat(3, 1fr); } .home .cards { grid-template-columns: repeat(2, 1fr); } }
.card { display: block; border: 1px solid var(--line); border-radius: 6px; padding: 1rem 1.1rem; text-decoration: none; color: inherit; background: var(--paper); box-shadow: var(--shadow); }
.card:hover { border-color: var(--accent); }
.card strong { display: block; font-size: 1.05rem; color: var(--accent); margin-bottom: 0.25rem; }
.card span { color: var(--ink-2); font-size: 0.95rem; }

.table-wrap { overflow-x: auto; margin: 1rem 0; }
.chain { width: 100%; font-size: 0.95rem; }
.chain th, .chain td { text-align: left; vertical-align: top; padding: 0.6rem 0.75rem; border-bottom: 1px solid var(--line); }
.chain th { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--ink-3); }
.chain td:nth-child(2) { white-space: nowrap; }
@media (max-width: 47.99em) {
  .chain thead { display: none; }
  .chain, .chain tbody { display: block; }
  .chain tr { display: grid; grid-template-columns: 1fr auto auto; gap: 0.15rem 0.75rem; align-items: baseline; padding: 0.6rem 0; border-bottom: 1px solid var(--line); }
  .chain td { display: block; padding: 0; border: 0; }
  .chain td:first-child { font-weight: 600; }
  .chain td:nth-child(4) { grid-column: 1 / -1; color: var(--ink-2); font-size: 0.9rem; }
}

/* ---------- contents ---------- */

.toc { list-style: none; margin: 1.5rem 0 0; padding: 0; max-width: 52rem; }
.toc-item { display: grid; grid-template-columns: 1fr; gap: 0.2rem 1rem; padding: 0.7rem 0; border-top: 1px solid var(--line); align-items: baseline; }
@media (min-width: 48em) { .toc-item { grid-template-columns: 1fr auto; } }
.toc-item a { text-decoration: none; display: flex; gap: 0.75rem; align-items: baseline; }
.toc-item a:hover .toc-title { text-decoration: underline; }
.toc-label { font-family: var(--mono); font-size: 0.85rem; color: var(--ink-3); min-width: 7rem; }
.toc-title { font-weight: 600; }
.toc-meta { font-size: 0.8125rem; color: var(--ink-3); white-space: nowrap; }
.siblings { margin-top: 2.5rem; font-size: 0.95rem; }
.siblings h2 { font-size: 0.8125rem; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-3); margin-top: 0; }
.siblings ul { padding-left: 1.2rem; margin: 0.5rem 0 0; }

.plates { list-style: none; margin: 1.5rem 0 0; padding: 0; display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(10rem, 1fr)); }
.plates a { display: block; text-decoration: none; color: inherit; }
.plates img { width: 100%; border: 1px solid var(--line); background: #fff; aspect-ratio: 311 / 440; object-fit: cover; object-position: top; }
.plates a:hover img { border-color: var(--accent); }
.plate-title { display: block; font-size: 0.85rem; font-weight: 600; margin-top: 0.4rem; line-height: 1.3; }
.plate-cite { display: block; font-family: var(--mono); font-size: 0.75rem; color: var(--ink-3); }

/* ---------- reading page ---------- */

.doc { padding-block: 0 3rem; }
.main-col { max-width: 52rem; }

.text { font-family: var(--serif); margin-top: 1.5rem; }
.text p { margin: 0.75rem 0 0; line-height: 1.65; font-size: 1.05em; }
.text p.sub { padding-left: 1.5rem; }
.text p.caps { font-family: var(--sans); font-weight: 700; letter-spacing: 0.04em; font-size: 0.95em; margin-top: 1rem; }
.text p.sec { scroll-margin-top: 1rem; }
.text p.sec:target { background: linear-gradient(90deg, var(--accent-soft), transparent 70%); margin-inline: -0.5rem; padding-inline: 0.5rem; border-radius: var(--radius); }
.text .num { font-family: var(--mono); font-weight: 600; font-size: 0.9em; }
.text h2.art { font-family: var(--sans); font-size: 1.25rem; margin-top: 1.75rem; }
.text h2.art .roman { display: block; font-size: 0.75rem; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-3); margin-bottom: 0.15rem; }
.text h2.art:first-child { margin-top: 0; }
.ed { font-family: var(--sans); font-size: 0.8em; color: var(--ink-3); font-style: italic; }
.rec-table { font-size: 0.95em; margin-top: 0.75rem; }
.rec-table td { padding: 0.25rem 0.75rem 0.25rem 0; vertical-align: top; border-bottom: 1px solid var(--line); }
.rec-list { padding-left: 1.3rem; margin: 0.6rem 0 0; }
.page-notes { font-family: var(--sans); font-size: 0.8125rem; color: var(--ink-3); margin-top: 1.25rem; }
.page-notes summary { cursor: pointer; }
.page-notes p { margin: 0.4rem 0 0; }

.pager { display: flex; justify-content: space-between; gap: 1rem; margin-top: 2.5rem; padding-top: 1rem; border-top: 1px solid var(--line); font-size: 0.95rem; }
.pager.top { margin-top: 1rem; padding-top: 0; border-top: 0; padding-bottom: 1rem; border-bottom: 1px solid var(--line); }
.pager .side { display: flex; gap: 1.5rem; }
.pager .side.right { margin-left: auto; text-align: right; }
.pager a { text-decoration: none; font-weight: 600; }
.pager a .cap { display: flex; align-items: center; gap: 0.2rem; font-size: 0.75rem; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-3); }
.pager .right .cap { justify-content: flex-end; }
.pager a svg { width: 16px; height: 16px; transition: transform 0.15s ease; }
.pager a.prev:hover svg, .pager a.first:hover svg { transform: translateX(-2px); }
.pager a.next:hover svg, .pager a.last:hover svg { transform: translateX(2px); }

/* scan, above the transcript */
.scan { margin-top: 1.5rem; }
.scan + .text { margin-top: 2.5rem; }
.scan-card { border: 1px solid var(--line); border-radius: 6px; background: var(--paper-2); box-shadow: var(--shadow); overflow: hidden; }
.scan-head { display: flex; justify-content: space-between; align-items: center; gap: 0.5rem; padding: 0.6rem 0.85rem; border-bottom: 1px solid var(--line); font-size: 0.8125rem; }
.scan-head .label { font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-3); font-size: 0.72rem; }
.scan-head .cite { font-family: var(--mono); font-size: 0.8rem; }
.scan-nav { display: flex; gap: 0.25rem; }
.scan-nav a, .scan-nav .off { background: var(--paper); border: 1px solid var(--line-2); border-radius: var(--radius); width: 2rem; height: 2rem; display: grid; place-items: center; color: var(--ink-2); }
.scan-nav a:hover { color: var(--ink); border-color: var(--ink-3); }
.scan-nav .off { opacity: 0.4; }
.scan-nav svg { width: 16px; height: 16px; }
.scan-img { display: block; background: #fff; }
.scan-img img { width: 100%; }
:root[data-theme="dark"] .scan-img img { filter: brightness(0.92); }
.scan-foot { padding: 0.6rem 0.85rem; font-size: 0.8125rem; color: var(--ink-2); display: flex; flex-wrap: wrap; gap: 0.35rem 1rem; align-items: center; justify-content: space-between; }
.scan-note { font-size: 0.8125rem; color: var(--ink-3); margin: 0.6rem 0 0; }

/* ---------- prose pages, home, search ---------- */

.prose { max-width: 48rem; }
.prose h2 { font-size: 1.35rem; margin-top: 2rem; }
.prose h3 { font-size: 1.1rem; margin-top: 1.5rem; }
.prose p, .prose li { line-height: 1.6; }
.prose ul, .prose ol { padding-left: 1.4rem; }
.prose blockquote { margin: 1rem 0; padding: 0.5rem 1rem; border-left: 4px solid var(--line-2); color: var(--ink-2); }
.prose table { width: 100%; font-size: 0.95rem; margin: 1rem 0; }
.prose th, .prose td { text-align: left; vertical-align: top; padding: 0.5rem 0.75rem 0.5rem 0; border-bottom: 1px solid var(--line); }
.prose th { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--ink-3); }
.prose pre { background: var(--paper-2); border: 1px solid var(--line); padding: 0.75rem; overflow-x: auto; border-radius: var(--radius); font-size: 0.85rem; }
.prose hr { border: 0; border-top: 1px solid var(--line); margin: 2rem 0; }

.hero { padding: 2rem 0 0.5rem; max-width: 52rem; }
.home-body { margin-top: 1rem; }
.home-body p { font-size: 1.3rem; line-height: 1.65; }
@media (min-width: 48em) { .home-body p { font-size: 1.5rem; } }
.caret { display: inline-block; width: 2px; height: 1em; background: var(--ink); vertical-align: -0.15em; margin-left: 1px; animation: blink 1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }

.search-form { max-width: 36rem; margin-top: 1.25rem; }
.search-box { position: relative; display: flex; align-items: center; }
.search-box > svg { position: absolute; left: 14px; pointer-events: none; color: var(--ink-3); }
.search-input {
  width: 100%; min-width: 0; font: inherit; font-size: 1.05rem; padding: 0.7rem 2.5rem 0.7rem 2.7rem;
  border: 1px solid var(--line-2); border-radius: 6px; background: var(--paper); color: var(--ink); -webkit-appearance: none; appearance: none;
}
.search-input::placeholder { color: var(--ink-3); opacity: 1; }
.search-input::-webkit-search-cancel-button { -webkit-appearance: none; }
.search-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.search-clear {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%); display: none; align-items: center; justify-content: center;
  width: 26px; height: 26px; padding: 0; border: 0; background: transparent; color: var(--ink-3); border-radius: var(--radius);
}
.search-clear svg { display: block; }
.search-clear:hover { color: var(--ink); background: var(--paper-2); }
.search-input:not(:placeholder-shown) ~ .search-clear { display: flex; }
.results { list-style: none; margin: 1.5rem 0 0; padding: 0; max-width: 52rem; }
.results li { padding: 0.9rem 0; border-top: 1px solid var(--line); }
.results a { font-weight: 600; text-decoration: none; }
.results .doc { display: block; font-size: 0.8rem; color: var(--ink-3); text-transform: uppercase; letter-spacing: 0.05em; margin-top: 0.15rem; }
.results .snip { font-family: var(--serif); margin: 0.35rem 0 0; color: var(--ink-2); font-size: 0.98rem; line-height: 1.55; }
.results mark { background: var(--mark); color: inherit; padding: 0 0.1em; }
