/*
 * Paper editorial mode since 2026-09-24 (navy archive band replaces the red).
 * piccini.app/papers — academic archive surface.
 * Information architecture borrows from arXiv; colors and charts follow
 * docs/BRAND_GUIDE.md. The warm paper surface is a deliberate editorial mode.
 */

@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("/branding/font-1b08e7fc267a5c7e.ttf") format("truetype");
}

@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("/branding/font-e7a1aaf7eda9f2fa.ttf") format("truetype");
}

@font-face {
  font-family: "Source Serif 4";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("/branding/font-8ca4d603b02214e2.ttf") format("truetype");
}

:root {
  --archive: #17345c;
  --archive-dark: #0f2542;
  --band: #17345c;
  --band-edge: #0f2542;
  --feature: #17345c;
  --card: #ffffff;
  --fig-warm: #b24a2c;
  --fig-navy: #17345c;
  --fig-slate: #536171;
  --paper: #f7f5ef;
  --paper-warm: #eeede6;
  --paper-edge: #d8dcd9;
  --ink: #17345c;
  --ink-soft: #3e5068;
  --ink-muted: #536171;
  --navy: #17345c;
  --navy-light: #3d5a9c;
  --navy-ghost: #d6e0f0;
  --amber: #f5a623;
  --positive: #2f766f;
  --negative: #a5414a;
  --sans: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --display: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --serif: "Source Serif 4", Georgia, serif;
}

*, *::before, *::after { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
  color: var(--ink);
  background: var(--paper);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.6;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

body { margin: 0; background: var(--paper); }
a { color: var(--navy); text-decoration-thickness: 1px; text-underline-offset: 0.18em; }
a:hover { color: var(--archive); }
img, svg { max-width: 100%; }

.skip-link {
  position: fixed;
  z-index: 100;
  top: 8px;
  left: 8px;
  transform: translateY(-160%);
  padding: 8px 12px;
  background: var(--card);
  color: var(--archive);
  border: 2px solid var(--archive);
}
.skip-link:focus { transform: translateY(0); }

.archive-header {
  color: white;
  background: var(--band);
  border-bottom: 5px solid var(--band-edge);
}

.archive-header__inner {
  width: min(1220px, calc(100% - 40px));
  min-height: 80px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.archive-brand {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: baseline;
  gap: 11px;
  color: white;
  text-decoration: none;
}
.archive-brand:hover { color: white; }
.archive-brand__name {
  font-family: var(--serif);
  font-size: clamp(27px, 4vw, 38px);
  letter-spacing: -0.045em;
  line-height: 1;
}
.archive-brand__section {
  padding-left: 11px;
  border-left: 1px solid rgba(255,255,255,.45);
  font-family: var(--display);
  font-size: 12px;
  letter-spacing: .14em;
  text-transform: uppercase;
}

.archive-nav { display: flex; align-items: center; gap: 20px; }
.archive-nav a {
  color: rgba(255,255,255,.84);
  font-size: 13px;
  text-decoration: none;
}
.archive-nav a:hover, .archive-nav a[aria-current="page"] { color: white; }

.archive-subbar {
  color: var(--ink-soft);
  background: var(--paper-warm);
  border-bottom: 1px solid var(--paper-edge);
}
.archive-subbar__inner {
  width: min(1220px, calc(100% - 40px));
  margin: 0 auto;
  padding: 9px 0;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  font-size: 12px;
}
.archive-subbar a { color: inherit; }

.archive-main {
  width: min(1080px, calc(100% - 40px));
  margin: 0 auto;
  padding: 64px 0 80px;
}

.archive-kicker,
.paper-kicker {
  margin: 0 0 10px;
  color: var(--archive);
  font-family: var(--display);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: .13em;
  text-transform: uppercase;
}

.archive-intro {
  max-width: 780px;
  margin-bottom: 48px;
}
.archive-intro h1 {
  max-width: 760px;
  margin: 0;
  font-family: var(--serif);
  font-size: clamp(38px, 6vw, 64px);
  font-weight: 400;
  letter-spacing: -.035em;
  line-height: 1.04;
}
.archive-intro__deck {
  max-width: 680px;
  margin: 22px 0 0;
  color: var(--ink-soft);
  font-family: var(--serif);
  font-size: clamp(18px, 2.3vw, 22px);
  line-height: 1.48;
}

.archive-stats {
  margin-top: 28px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.archive-stat {
  padding: 5px 9px;
  border: 1px solid var(--paper-edge);
  border-radius: 3px;
  color: var(--ink-soft);
  background: var(--card);
  font-family: var(--display);
  font-size: 11px;
  letter-spacing: .03em;
}

.listing-heading {
  margin: 0 0 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--ink);
  font-family: var(--display);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: .1em;
  text-transform: uppercase;
}

.paper-entry {
  position: relative;
  display: grid;
  grid-template-columns: 138px minmax(0, 1fr);
  gap: 28px;
  padding: 30px 0 34px;
  border-bottom: 1px solid var(--paper-edge);
}
.paper-entry::before {
  position: absolute;
  top: 30px;
  left: -18px;
  width: 3px;
  height: 43px;
  background: var(--archive);
  content: "";
}
.paper-id {
  color: var(--ink-muted);
  font-family: var(--display);
  font-size: 11px;
  letter-spacing: .04em;
}
.paper-id strong {
  display: block;
  margin-bottom: 7px;
  color: var(--archive);
  font-size: 13px;
  font-weight: 500;
}
.paper-entry h2 {
  margin: -5px 0 8px;
  font-family: var(--serif);
  font-size: clamp(25px, 4vw, 34px);
  font-weight: 400;
  line-height: 1.15;
}
.paper-entry h2 a { color: var(--ink); text-decoration: none; }
.paper-entry h2 a:hover { color: var(--archive); }
.paper-byline { margin: 0 0 13px; color: var(--ink-soft); font-size: 13px; }
.paper-abstract { max-width: 760px; margin: 0; color: var(--ink-soft); font-family: var(--serif); font-size: 16px; line-height: 1.62; }
.paper-tags { margin-top: 17px; display: flex; flex-wrap: wrap; gap: 7px; }
.paper-tag {
  padding: 3px 7px;
  border: 1px solid var(--paper-edge);
  border-radius: 2px;
  color: var(--ink-soft);
  background: var(--paper-warm);
  font-size: 10px;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.archive-note {
  margin-top: 44px;
  padding: 22px 24px;
  border-left: 3px solid var(--navy);
  background: var(--paper-warm);
  color: var(--ink-soft);
  font-size: 14px;
}
.archive-note strong { color: var(--ink); }

.archive-footer {
  padding: 24px 20px;
  color: var(--ink-muted);
  background: var(--paper-warm);
  border-top: 1px solid var(--paper-edge);
  text-align: center;
  font-size: 12px;
}

/* Paper page */
.paper-shell {
  width: min(1220px, calc(100% - 40px));
  margin: 0 auto;
  padding: 46px 0 88px;
  display: grid;
  grid-template-columns: 220px minmax(0, 760px);
  justify-content: center;
  gap: clamp(42px, 6vw, 78px);
}

.paper-sidebar {
  position: sticky;
  top: 24px;
  align-self: start;
  padding-top: 8px;
  color: var(--ink-soft);
  font-size: 12px;
}
.paper-sidebar__section {
  margin-bottom: 30px;
  padding-top: 13px;
  border-top: 1px solid var(--paper-edge);
}
.paper-sidebar h2 {
  margin: 0 0 10px;
  color: var(--ink);
  font-family: var(--display);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: .12em;
  text-transform: uppercase;
}
.paper-sidebar dl { margin: 0; }
.paper-sidebar dt { margin-top: 9px; color: var(--ink-muted); }
.paper-sidebar dd { margin: 0; color: var(--ink); }
.toc { margin: 0; padding: 0; list-style: none; }
.toc li + li { margin-top: 7px; }
.toc a { color: var(--ink-soft); text-decoration: none; }
.toc a:hover { color: var(--archive); }

.paper { min-width: 0; }
.paper-header {
  margin-bottom: 34px;
  padding-bottom: 30px;
  border-bottom: 1px solid var(--paper-edge);
}
.paper-header h1 {
  margin: 0;
  font-family: var(--serif);
  font-size: clamp(38px, 6vw, 59px);
  font-weight: 400;
  letter-spacing: -.036em;
  line-height: 1.03;
}
.paper-deck {
  margin: 20px 0 0;
  color: var(--ink-soft);
  font-family: var(--serif);
  font-size: 20px;
  line-height: 1.45;
}
.paper-authors { margin: 24px 0 0; color: var(--ink); font-size: 14px; }
.paper-authors span { color: var(--ink-muted); }
.status-row { margin-top: 18px; display: flex; flex-wrap: wrap; gap: 7px; }
.status-badge {
  padding: 4px 8px;
  border: 1px solid var(--paper-edge);
  border-radius: 3px;
  color: var(--ink-soft);
  background: var(--paper-warm);
  font-size: 10px;
  letter-spacing: .06em;
  text-transform: uppercase;
}
.status-badge--accent { border-color: #d7b36d; color: #6f4a04; background: #fff7e4; }

.abstract {
  margin: 0 0 38px;
  padding: 24px 27px;
  border: 1px solid var(--paper-edge);
  border-top: 3px solid var(--archive);
  background: var(--card);
}
.abstract h2 {
  margin: 0 0 12px;
  font-family: var(--display);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: .12em;
  text-transform: uppercase;
}
.abstract p { margin: 0; font-family: var(--serif); font-size: 17px; line-height: 1.65; }

.key-result {
  position: relative;
  margin: 38px 0;
  padding: 26px 28px 27px;
  color: white;
  background: var(--feature);
  overflow: hidden;
}
.key-result::after {
  position: absolute;
  right: -26px;
  bottom: -52px;
  width: 145px;
  height: 145px;
  border: 1px solid rgba(255,255,255,.14);
  border-radius: 50%;
  box-shadow: 0 0 0 24px rgba(255,255,255,.035), 0 0 0 48px rgba(255,255,255,.025);
  content: "";
}
.key-result__label {
  display: block;
  margin-bottom: 11px;
  color: #cfd7e1;
  font-family: var(--display);
  font-size: 10px;
  letter-spacing: .13em;
  text-transform: uppercase;
}
.key-result p {
  position: relative;
  z-index: 1;
  max-width: 620px;
  margin: 0;
  font-family: var(--serif);
  font-size: clamp(21px, 3.5vw, 28px);
  line-height: 1.3;
}
.key-result strong { color: #f5a623; font-weight: 400; }

.paper-section { scroll-margin-top: 24px; }
.paper-section > h2 {
  margin: 50px 0 19px;
  padding-top: 15px;
  border-top: 1px solid var(--ink);
  font-family: var(--serif);
  font-size: 30px;
  font-weight: 400;
  letter-spacing: -.02em;
  line-height: 1.2;
}
.paper-section > h3 {
  margin: 31px 0 11px;
  font-family: var(--display);
  font-size: 17px;
  font-weight: 500;
  line-height: 1.35;
}
.paper-section p,
.paper-section li {
  font-family: var(--serif);
  font-size: 17px;
  line-height: 1.72;
}
.paper-section p { margin: 0 0 18px; }
.paper-section ul,
.paper-section ol { margin: 0 0 22px; padding-left: 25px; }
.paper-section li + li { margin-top: 8px; }
.paper-section strong { font-weight: 700; }

.observation-label {
  display: inline-block;
  margin-right: 5px;
  color: var(--archive);
  font-family: var(--display);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: .08em;
  text-transform: uppercase;
  vertical-align: .1em;
}

.figure {
  margin: 34px 0 40px;
  padding: 22px 22px 17px;
  border: 1px solid var(--paper-edge);
  background: var(--card);
}
.figure__title {
  margin: 0;
  font-family: var(--display);
  font-size: 14px;
  font-weight: 500;
}
.figure__subtitle { margin: 4px 0 18px; color: var(--ink-muted); font-size: 12px; }
.figure figcaption {
  margin-top: 13px;
  padding-top: 12px;
  border-top: 1px solid var(--paper-edge);
  color: var(--ink-muted);
  font-size: 11.5px;
  line-height: 1.5;
}

.effect-chart { width: 100%; height: auto; overflow: visible; }
.effect-chart text { font-family: var(--sans); fill: var(--ink-soft); }
.effect-chart .axis { stroke: #c9cdc9; stroke-width: 1; }
.effect-chart .zero { stroke: var(--ink); stroke-width: 1.4; stroke-dasharray: 3 4; }
.effect-chart .row { stroke: #e6e4dc; stroke-width: 1; }
.effect-chart .positive { fill: var(--positive); }
.effect-chart .negative { fill: var(--negative); }
.effect-chart .neutral { fill: var(--ink-muted); }
.effect-chart .value { fill: var(--ink); font-weight: 500; }

.mechanism {
  display: grid;
  grid-template-columns: 1fr 84px 1fr;
  align-items: stretch;
  gap: 12px;
}
.mechanism__side { padding: 18px; border: 1px solid var(--paper-edge); }
.mechanism__side h3 { margin: 0 0 11px; font-family: var(--display); font-size: 14px; font-weight: 500; }
.mechanism__side ul { margin: 0; padding-left: 17px; color: var(--ink-soft); }
.mechanism__side li { font-family: var(--sans); font-size: 12px; line-height: 1.45; }
.mechanism__side--gain { border-top: 3px solid var(--positive); }
.mechanism__side--loss { border-top: 3px solid var(--negative); }
.mechanism__balance {
  display: grid;
  place-items: center;
  color: white;
  background: var(--feature);
  font-family: var(--display);
  font-size: 10px;
  letter-spacing: .09em;
  text-align: center;
  text-transform: uppercase;
}

.confidence-table { width: 100%; border-collapse: collapse; margin: 26px 0 35px; }
.confidence-table th,
.confidence-table td { padding: 12px 10px; border-bottom: 1px solid var(--paper-edge); text-align: left; vertical-align: top; }
.confidence-table th { color: var(--ink-muted); font-family: var(--display); font-size: 10px; font-weight: 500; letter-spacing: .08em; text-transform: uppercase; }
.confidence-table td { font-family: var(--serif); font-size: 15px; line-height: 1.5; }
.confidence-table td:first-child { width: 72px; color: var(--archive); font-family: var(--display); font-size: 19px; }

.references { counter-reset: refs; padding: 0 !important; list-style: none; }
.references li {
  position: relative;
  padding-left: 42px;
  font-size: 14.5px;
  line-height: 1.55;
  overflow-wrap: anywhere;
}
.references li::before {
  position: absolute;
  left: 0;
  top: .1em;
  width: 28px;
  color: var(--archive);
  font-family: var(--display);
  font-size: 11px;
  counter-increment: refs;
  content: "[" counter(refs) "]";
}

.paper-endnote {
  margin-top: 50px;
  padding: 21px 24px;
  border: 1px solid var(--paper-edge);
  color: var(--ink-soft);
  background: var(--paper-warm);
  font-size: 13px;
}

@media (max-width: 840px) {
  .paper-shell { grid-template-columns: 1fr; padding-top: 34px; }
  .paper-sidebar { position: static; display: grid; grid-template-columns: 1fr 1fr; gap: 20px; padding: 0; }
  .paper-sidebar__section { margin: 0; }
}

@media (max-width: 620px) {
  .archive-header__inner { min-height: 68px; }
  .archive-nav { gap: 12px; }
  .archive-nav a:not([aria-current="page"]) { display: none; }
  .archive-subbar__inner span:last-child { display: none; }
  .archive-main { padding-top: 44px; }
  .paper-entry { grid-template-columns: 1fr; gap: 14px; }
  .paper-entry::before { left: -12px; }
  .paper-id strong { display: inline; margin-right: 6px; }
  .paper-shell { width: min(calc(100% - 30px), 760px); }
  .paper-sidebar { display: none; }
  .paper-header h1 { overflow-wrap: anywhere; }
  .mechanism { grid-template-columns: 1fr; }
  .mechanism__balance { min-height: 48px; }
  .figure { margin-left: -7px; margin-right: -7px; padding: 16px 11px 13px; }
  .effect-chart { min-width: 610px; }
  .figure__scroll { overflow-x: auto; }
}

@media print {
  .archive-header, .archive-subbar, .paper-sidebar, .archive-footer { display: none; }
  .paper-shell { display: block; width: 100%; padding: 0; }
  .paper { max-width: none; }
  .paper-section > h2 { break-after: avoid; }
  .figure, .abstract, .key-result { break-inside: avoid; }
  a { color: inherit; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}

/* Dark theme (shared piccini.app key). The header band and feature blocks stay
   deep navy; text accents flip to light slate. */
html.theme-dark {
  --archive: #cfd7e1;
  --archive-dark: #8fa3ba;
  --band: #0f2542;
  --band-edge: #0a1a30;
  --feature: #0f2542;
  --card: #1d406b;
  --paper: #17345c;
  --paper-warm: #1d406b;
  --paper-edge: #58718e;
  --ink: #f7f5ef;
  --ink-soft: #dce2ea;
  --ink-muted: #cfd7e1;
  --navy: #8fb0e8;
  --positive: #6cc0b4;
  --negative: #e88a92;
  --fig-warm: #ef9277;
  --fig-navy: #8fb0e8;
  --fig-slate: #cfd7e1;
  color-scheme: dark;
}
html.theme-dark .status-badge--accent { border-color: #b8913f; color: #f5c46b; background: transparent; }
html.theme-dark .effect-chart .axis { stroke: #58718e; }
html.theme-dark .effect-chart .row { stroke: #2b5080; }

/* Authored figure colors predate the rebrand; map them to brand tokens. */
[fill="#8f1722"] { fill: var(--fig-warm); }
[stroke="#8f1722"] { stroke: var(--fig-warm); }
[fill="#1b3a72"] { fill: var(--fig-navy); }
[stroke="#1b3a72"] { stroke: var(--fig-navy); }
[fill="#576273"] { fill: var(--fig-slate); }
[stroke="#576273"] { stroke: var(--fig-slate); }

.archive-nav .theme-toggle {
  margin-left: 6px; padding: 5px 11px; border: 1px solid rgba(255,255,255,.4); border-radius: 3px;
  background: transparent; color: rgba(255,255,255,.9); font: 600 12px/1.2 var(--sans); cursor: pointer;
}
.archive-nav .theme-toggle:hover { border-color: white; color: white; }
