/* CIPHER paper page: light academic reading layout. Self-contained. */

:root {
  color-scheme: light;
  --page: #ffffff;
  --bg: #f4f3ef;
  --ink: #1d2328;
  --ink-muted: #5a646d;
  --rule: #dcd8ce;
  --accent: #0e6470;
  --accent-strong: #0a4a53;
  --accent-soft: #e2eff0;
  --focus: #0b57d0;
  --bar: #1b2227;
  --bar-ink: #e9edef;
  --font-sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --font-serif: "Source Serif 4", "Source Serif Pro", Georgia, "Times New Roman", serif;
  --font-mono: "JetBrains Mono", "IBM Plex Mono", ui-monospace, Menlo, Consolas, monospace;
  --measure: 70ch;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; scroll-behavior: smooth; scroll-padding-top: 72px; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; }
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-serif);
  font-size: 1.075rem;
  line-height: 1.65;
  overflow-wrap: break-word;
}

a { color: var(--accent); text-underline-offset: 0.16em; text-decoration-thickness: 1px; }
a:hover { color: var(--accent-strong); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 2px; }

.skip-link {
  position: absolute; left: 12px; top: -60px; z-index: 50;
  padding: 10px 14px; background: #fff; color: var(--accent-strong);
  border: 2px solid var(--accent); border-radius: 6px;
  font-family: var(--font-sans); font-weight: 600;
}
.skip-link:focus { top: 12px; }

.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* Top bar */
.paper-bar {
  position: sticky; top: 0; z-index: 20;
  background: var(--bar);
  color: var(--bar-ink);
  font-family: var(--font-sans);
  font-size: 0.92rem;
}
.paper-bar-inner {
  max-width: 1200px; margin: 0 auto;
  padding: 8px clamp(16px, 3vw, 28px);
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 16px;
}
.bar-home { color: #fff; font-weight: 600; letter-spacing: 0.06em; text-decoration: none; }
.bar-home:hover { color: #fff; text-decoration: underline; }
.bar-sub { font-weight: 400; letter-spacing: 0; color: #aab4bb; }
.bar-actions { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.bar-btn {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 36px; padding: 6px 12px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 6px;
  background: transparent;
  color: var(--bar-ink);
  font: inherit; font-weight: 500;
  text-decoration: none;
  cursor: pointer;
}
.bar-btn:hover { background: rgba(255, 255, 255, 0.1); color: #fff; }
.bar-btn.primary { background: #fff; color: var(--bar); border-color: #fff; }
.bar-btn.primary:hover { background: #e7f2f3; color: var(--bar); }
.bar-btn[aria-disabled="true"] { opacity: 0.6; cursor: not-allowed; }
.paper-bar :focus-visible { outline-color: #9cc8ff; }

/* Layout */
.paper-layout {
  max-width: 1200px;
  margin: 0 auto;
  padding: clamp(16px, 3vw, 32px) clamp(0px, 2vw, 28px) 48px;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 24px;
}
@media (min-width: 1100px) {
  .paper-layout.has-toc { grid-template-columns: 240px minmax(0, 1fr); align-items: start; }
}

.paper-main {
  background: var(--page);
  border: 1px solid var(--rule);
  border-radius: 4px;
  padding: clamp(24px, 5vw, 64px) clamp(16px, 5vw, 72px);
  min-width: 0;
  max-width: calc(var(--measure) + 2 * 72px);
  width: 100%;
  margin: 0 auto;
}
@media (max-width: 640px) {
  .paper-main { border-left: 0; border-right: 0; border-radius: 0; }
}

/* Table of contents */
.toc {
  font-family: var(--font-sans);
  font-size: 0.9rem;
  background: var(--page);
  border: 1px solid var(--rule);
  border-radius: 4px;
  padding: 14px 16px;
  margin: 0 16px;
}
@media (min-width: 1100px) {
  .toc { position: sticky; top: 72px; max-height: calc(100vh - 96px); overflow-y: auto; margin: 0; }
}
.toc h2 { font-family: var(--font-sans); font-size: 0.75rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink-muted); margin: 0 0 8px; }
.toc ol { list-style: none; margin: 0; padding: 0; }
.toc ol ol { padding-left: 12px; }
.toc a { display: block; padding: 3px 8px; border-radius: 4px; color: var(--ink); text-decoration: none; line-height: 1.35; }
.toc a:hover { background: var(--accent-soft); color: var(--accent-strong); }
.toc a[aria-current="true"] { background: var(--accent-soft); color: var(--accent-strong); font-weight: 600; }

/* Front matter */
.paper-title {
  font-family: var(--font-serif);
  font-weight: 600;
  font-size: clamp(1.6rem, 1.2rem + 1.6vw, 2.25rem);
  line-height: 1.2;
  text-align: center;
  margin: 0 auto 20px;
  max-width: 30ch;
}
.authors {
  list-style: none; margin: 0 0 8px; padding: 0;
  display: flex; flex-wrap: wrap; justify-content: center; gap: 12px 36px;
  text-align: center;
}
.authors li { min-width: 0; }
.author-name { display: block; font-weight: 600; }
.author-aff { display: block; font-style: italic; color: var(--ink-muted); font-size: 0.95rem; }
.author-email { display: block; font-family: var(--font-mono); font-size: 0.82rem; overflow-wrap: anywhere; }
.doc-meta { text-align: center; color: var(--ink-muted); font-family: var(--font-sans); font-size: 0.85rem; margin: 10px 0 28px; }
.abstract {
  max-width: var(--measure);
  margin: 0 auto 32px;
  padding: 16px 20px;
  background: #faf9f6;
  border-left: 3px solid var(--accent);
}
.abstract h2 { font-family: var(--font-sans); font-size: 0.8rem; letter-spacing: 0.1em; text-transform: uppercase; margin: 0 0 6px; color: var(--ink-muted); }
.abstract p { margin: 0; }

/* Manuscript body (fragment from paper/build/paper.html) */
.paper-body { max-width: var(--measure); margin: 0 auto; }
.paper-body section { scroll-margin-top: 72px; }
.paper-body h1, .paper-body h2, .paper-body h3, .paper-body h4 { font-family: var(--font-serif); font-weight: 600; line-height: 1.3; position: relative; }
.paper-body h2 { font-size: 1.4rem; margin: 2em 0 0.6em; }
.paper-body h3 { font-size: 1.15rem; margin: 1.6em 0 0.5em; }
.paper-body h4 { font-size: 1.02rem; margin: 1.4em 0 0.4em; font-style: italic; }
.paper-body p { margin: 0 0 1em; hyphens: auto; }
.paper-body ul, .paper-body ol { padding-left: 1.4em; }
.paper-body li { margin-bottom: 0.35em; }
.paper-body code { font-family: var(--font-mono); font-size: 0.86em; background: #f3f2ee; padding: 0.05em 0.3em; border-radius: 3px; overflow-wrap: anywhere; }
.paper-body pre { font-family: var(--font-mono); font-size: 0.85rem; background: #151a1e; color: #e3e7ea; padding: 12px 16px; border-radius: 4px; overflow-x: auto; }
.paper-body pre code { background: none; padding: 0; color: inherit; }
.paper-body blockquote { margin: 1em 0; padding-left: 1em; border-left: 3px solid var(--rule); color: var(--ink-muted); }
.paper-body figure { margin: 1.8em 0; text-align: center; }
.paper-body figure img, .paper-body figure svg { max-width: 100%; height: auto; display: block; margin: 0 auto; }
.paper-body figcaption { font-family: var(--font-sans); font-size: 0.88rem; color: var(--ink-muted); text-align: left; margin-top: 8px; }
.paper-body table { border-collapse: collapse; font-family: var(--font-sans); font-size: 0.88rem; font-variant-numeric: tabular-nums; margin: 0 auto; }
.paper-body th, .paper-body td { padding: 5px 10px; border-bottom: 1px solid var(--rule); text-align: left; }
.paper-body thead th { border-bottom: 2px solid var(--ink); }
.paper-body .table-wrap, .paper-body .tablewrap { overflow-x: auto; }
.paper-body figure table { display: block; overflow-x: auto; max-width: 100%; width: max-content; }
.paper-body img { max-width: 100%; height: auto; }
.paper-body sup, .paper-body sub { line-height: 0; }
.paper-body .references, .paper-body #references ol { font-size: 0.93rem; }
.paper-body #references li { margin-bottom: 0.6em; }

.heading-anchor {
  margin-left: 0.4em;
  font-family: var(--font-sans);
  font-size: 0.8em;
  font-weight: 400;
  color: var(--ink-muted);
  text-decoration: none;
  opacity: 0;
}
.paper-body h2:hover .heading-anchor, .paper-body h3:hover .heading-anchor, .heading-anchor:focus-visible { opacity: 1; }
@media (hover: none) { .heading-anchor { opacity: 0.6; } }

/* Cite */
.cite-box { max-width: var(--measure); margin: 2.5em auto 0; font-family: var(--font-sans); }
.cite-box h2 { font-size: 1rem; margin: 0 0 8px; }
.cite-box pre { font-family: var(--font-mono); font-size: 0.8rem; background: #f6f5f1; border: 1px solid var(--rule); border-radius: 4px; padding: 12px 14px; overflow-x: auto; white-space: pre; margin: 0; }
.cite-status { font-family: var(--font-sans); font-size: 0.85rem; color: #9cc8ff; min-height: 1.2em; }

/* Not-built state */
.not-built { font-family: var(--font-sans); max-width: 60ch; margin: 0 auto; }
.not-built h1 { font-family: var(--font-serif); font-size: clamp(1.6rem, 1.3rem + 1.2vw, 2.1rem); margin: 0 0 12px; }
.not-built .lede { font-size: 1.05rem; }
.not-built ul { padding-left: 1.2em; }
.not-built code { font-family: var(--font-mono); font-size: 0.88em; background: #f3f2ee; padding: 0.05em 0.3em; border-radius: 3px; }
.status-pill { display: inline-block; font-size: 0.8rem; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--accent-strong); background: var(--accent-soft); border-radius: 999px; padding: 2px 10px; margin-bottom: 14px; }

.paper-footer {
  font-family: var(--font-sans);
  font-size: 0.85rem;
  color: var(--ink-muted);
  text-align: center;
  padding: 0 16px 40px;
}
.paper-footer p { margin: 0 0 4px; }
.mono { font-family: var(--font-mono); font-size: 0.85em; overflow-wrap: anywhere; }

@media print {
  .paper-bar, .toc, .skip-link, .heading-anchor, .paper-footer { display: none !important; }
  body { background: #fff; }
  .paper-main { border: 0; padding: 0; }
}

@media (max-width: 700px) {
  .paper-bar { position: static; }
  html { scroll-padding-top: 12px; }
  .paper-body section { scroll-margin-top: 12px; }
}
