/* AerariumChain docs - an editorial, museum-catalog aesthetic for curators,
   conservators and art historians, carrying AerariumChain's signature traits:
   bold grotesque headings and pill uppercase CTAs as on aerariumchain.com
   (its New Order face is commercially licensed, so headings use Archivo,
   an open SIL-OFL grotesque of the same modernist cut), plus the
   rust-to-copper gradient of the Hub (#C55121 -> #DB8348). Warm ivory
   paper, serif body text, quiet hairlines. Light-first; refined warm dark. */
/* Theme tokens. Light = white paper; night = black paper. The header toggle
   stamps data-theme on <html> (persisted in localStorage); without an explicit
   choice the system preference decides. */
:root, :root[data-theme="light"] {
  --paper: #FFFFFF;
  --card: #FFFFFF;
  --card-hover: #F8F4EE;
  --ink: #1C1813;
  --muted: #6E675C;
  --line: #EAE3D8;
  --line-light: #DFD6C6;
  --brand: #A8471D;
  --brand-2: #C55121;
  --brand-accent: #8F3A15;
  --brand-wash: #F7EDE2;
  --brand-line: rgba(197, 81, 33, 0.35);
  --brand-gradient: linear-gradient(135deg, #A8471D 0%, #C55121 100%);
  --code-bg: #F6F2EA;
  --shadow: 0 1px 3px rgba(60, 48, 35, 0.08);
  --radius: 4px;
  --disp: 'Archivo', 'Inter', -apple-system, sans-serif;
  --body: 'Source Serif 4', 'Iowan Old Style', Georgia, serif;
  --ui: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}
:root[data-theme="dark"] {
  --paper: #000000;
  --card: #14100C;
  --card-hover: #1D1710;
  --ink: #EDE6DA;
  --muted: #A29786;
  --line: #221D15;
  --line-light: #322A1F;
  --brand: #DB8348;
  --brand-2: #DB8348;
  --brand-accent: #E09558;
  --brand-wash: rgba(219, 131, 72, 0.10);
  --brand-line: rgba(219, 131, 72, 0.4);
  --brand-gradient: linear-gradient(135deg, #C55121 0%, #DB8348 100%);
  --code-bg: #120E09;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.55);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #000000;
    --card: #14100C;
    --card-hover: #1D1710;
    --ink: #EDE6DA;
    --muted: #A29786;
    --line: #221D15;
    --line-light: #322A1F;
    --brand: #DB8348;
    --brand-2: #DB8348;
    --brand-accent: #E09558;
    --brand-wash: rgba(219, 131, 72, 0.10);
    --brand-line: rgba(219, 131, 72, 0.4);
    --brand-gradient: linear-gradient(135deg, #C55121 0%, #DB8348 100%);
    --code-bg: #120E09;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.55);
  }
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font: 16.5px/1.75 var(--body);
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
  font-feature-settings: 'liga', 'kern';
}
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1px; }
h1, h2, h3, h4 { font-family: var(--disp); font-weight: 700; line-height: 1.14; letter-spacing: -.01em; }
.material-symbols-outlined {
  font-variation-settings: 'opsz' 24, 'wght' 300;
  font-size: 22px;
  vertical-align: middle;
}

/* ---- top bar ---- */
.top {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 16px;
  padding: 12px 22px;
  background: color-mix(in srgb, var(--paper) 92%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 9px; color: var(--ink); }
.brand:hover { text-decoration: none; }
.menu-btn { display: none; background: none; border: 0; color: var(--ink); cursor: pointer; padding: 4px; }
.search-wrap { position: relative; flex: 1; max-width: 440px; display: flex; align-items: center; }
.search-wrap > .material-symbols-outlined { position: absolute; left: 11px; color: var(--muted); font-size: 18px; }
#search {
  width: 100%; padding: 8px 14px 8px 36px;
  border: 1px solid var(--line-light); border-radius: 2px;
  background: var(--card); color: var(--ink); font-size: 14px; outline: none;
  font-family: var(--ui);
}
#search:focus { border-color: var(--brand-2); }
#search::placeholder { color: var(--muted); }
.search-results {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0;
  max-height: 60vh; overflow: auto;
  background: var(--card); border: 1px solid var(--line-light);
  border-radius: 2px; box-shadow: 0 10px 34px rgba(60, 48, 35, .18); padding: 6px;
}
.search-results a { display: block; padding: 9px 12px; color: var(--ink); }
.search-results a:hover, .search-results a.sel { background: var(--brand-wash); text-decoration: none; }
.search-results a strong { display: block; font-size: 14px; font-family: var(--disp); font-weight: 700; }
.search-results a small { color: var(--muted); font-size: 12.5px; font-family: var(--ui); }
.search-results .none { padding: 10px 12px; color: var(--muted); font-size: 14px; font-family: var(--ui); }
.theme-btn {
  background: none; border: 1px solid var(--line-light); border-radius: 999px;
  color: var(--muted); cursor: pointer; padding: 6px 7px; line-height: 0;
  transition: color .15s ease, border-color .15s ease;
}
.theme-btn:hover { color: var(--brand-2); border-color: var(--brand-2); }
.theme-btn .material-symbols-outlined { font-size: 19px; }
.lang { display: flex; align-items: center; gap: 5px; color: var(--muted); }
.lang select {
  border: 1px solid var(--line-light); border-radius: 2px; padding: 5px 8px;
  background: var(--card); color: var(--ink); font-size: 13px; font-family: var(--ui);
}
.app-link {
  padding: 9px 22px; border-radius: 999px; font-size: 12.5px;
  font-family: var(--disp); font-weight: 700; letter-spacing: .1em; text-transform: uppercase;
  background: var(--brand-gradient); color: #FFF7EF; white-space: nowrap;
  transition: transform .15s ease;
}
.app-link:hover { transform: scale(1.05); text-decoration: none; }

/* ---- layout ---- */
.layout { display: grid; grid-template-columns: 272px minmax(0, 1fr) 220px; gap: 0; max-width: 1400px; margin: 0 auto; }
.sidebar {
  position: sticky; top: 61px; height: calc(100vh - 61px); overflow-y: auto;
  padding: 22px 16px 40px; border-right: 1px solid var(--line);
}
.nav-section h4 {
  margin: 24px 10px 8px; font-size: 11px; text-transform: uppercase;
  letter-spacing: .16em; color: var(--muted); font-family: var(--disp); font-weight: 700;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 10px; font-size: 14px; color: var(--ink); font-family: var(--disp); font-weight: 400;
  border-left: 2px solid transparent;
}
.nav-item .material-symbols-outlined { font-size: 19px; color: var(--muted); }
.nav-item:hover { background: var(--brand-wash); text-decoration: none; }
.nav-item.active { background: var(--brand-wash); border-left-color: var(--brand-2); color: var(--brand-accent); font-weight: 600; }
.nav-item.active .material-symbols-outlined { color: var(--brand-2); }
.ai-download {
  display: flex; align-items: center; gap: 10px;
  margin: 4px 2px 6px; padding: 12px 13px;
  border: 1px solid var(--brand-line); border-radius: 2px;
  background: var(--brand-wash); color: var(--ink); font-size: 13px; font-weight: 600; line-height: 1.4;
  font-family: var(--ui);
}
.ai-download .material-symbols-outlined { color: var(--brand-2); }
.ai-download:hover { text-decoration: none; border-color: var(--brand-2); }

.main { padding: 44px 56px 70px; min-width: 0; }
.aside-col { padding: 44px 18px; }
.toc { position: sticky; top: 84px; font-size: 13px; font-family: var(--ui); }
.toc h4 { margin: 0 0 10px; font-size: 11px; text-transform: uppercase; letter-spacing: .16em; color: var(--muted); font-family: var(--ui); font-weight: 600; }
.toc a { display: block; padding: 4px 0; color: var(--muted); }
.toc a:hover { color: var(--brand); text-decoration: none; }

/* ---- article ---- */
.doc { max-width: 720px; }
.doc h1 {
  font-size: 40px; font-weight: 700; margin: 0 0 14px; letter-spacing: -.015em;
}
.doc h1::after {
  content: ''; display: block; width: 56px; height: 3px;
  margin-top: 18px; background: var(--brand-gradient);
}
.doc h2 { font-size: 25px; margin: 46px 0 12px; padding-top: 8px; }
.doc h3 { font-size: 18px; margin: 30px 0 8px; }
.doc p, .doc li { color: var(--ink); }
.doc .lead { font-size: 20px; line-height: 1.6; color: var(--muted); }
.doc img { max-width: 100%; }
.doc code {
  background: var(--code-bg); border: 1px solid var(--line); border-radius: 2px; padding: 2px 6px;
  font-size: 82%; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.doc pre {
  background: var(--code-bg); border: 1px solid var(--line);
  padding: 14px 16px; overflow-x: auto;
}
.doc pre code { background: none; border: 0; padding: 0; }
.doc table { border-collapse: collapse; width: 100%; display: block; overflow-x: auto; font-size: 14.5px; }
.doc th, .doc td { border: 1px solid var(--line-light); padding: 9px 13px; text-align: left; vertical-align: top; }
.doc th {
  background: var(--brand-wash); font-family: var(--ui); font-weight: 600;
  font-size: 12.5px; letter-spacing: .04em;
}
.doc blockquote {
  margin: 22px 0; padding: 14px 22px;
  border-left: 3px solid var(--brand-2);
  background: var(--brand-wash); color: var(--ink);
  font-style: italic;
}
.doc blockquote p { margin: 6px 0; }
.doc hr { border: 0; border-top: 1px solid var(--line); margin: 40px 0; }
.doc strong { font-weight: 600; }

/* ---- home ---- */
.ai-banner {
  display: flex; align-items: center; gap: 16px;
  margin: 26px 0 8px; padding: 18px 22px;
  border: 1px solid var(--brand-line);
  background: var(--brand-wash);
  color: var(--ink);
}
.ai-banner:hover { text-decoration: none; border-color: var(--brand-2); }
.ai-banner .material-symbols-outlined { font-size: 30px; color: var(--brand-2); }
.card-text { display: flex; flex-direction: column; gap: 2px; }
.card-text small { color: var(--muted); line-height: 1.5; font-family: var(--ui); font-size: 13px; }
.card-text strong { font-family: var(--disp); font-weight: 700; }
.home-section h2 {
  margin: 44px 0 14px; font-size: 14px; font-family: var(--disp); font-weight: 700;
  text-transform: uppercase; letter-spacing: .16em; color: var(--muted);
}
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; }
.card {
  display: flex; align-items: flex-start; gap: 13px;
  padding: 17px 18px; border: 1px solid var(--line-light);
  background: var(--card); color: var(--ink); box-shadow: var(--shadow);
  transition: border-color .15s ease, background .15s ease;
}
.card:hover { border-color: var(--brand-line); background: var(--card-hover); text-decoration: none; }
.card .material-symbols-outlined { color: var(--brand-2); margin-top: 3px; }
.card strong { font-size: 15.5px; font-family: var(--disp); font-weight: 700; }
.card small { font-size: 13px; }

/* ---- pager + footer ---- */
.pager { display: flex; justify-content: space-between; gap: 14px; margin-top: 54px; }
.pager-link {
  display: flex; flex-direction: column; padding: 13px 17px; max-width: 46%;
  border: 1px solid var(--line-light); color: var(--ink);
  background: var(--card);
}
.pager-link:hover { border-color: var(--brand-line); text-decoration: none; }
.pager-link small { color: var(--muted); font-size: 11px; font-family: var(--ui); text-transform: uppercase; letter-spacing: .1em; }
.pager-link span { font-family: var(--disp); font-weight: 700; font-size: 14.5px; }
.pager-link.next { text-align: right; margin-left: auto; }
.foot {
  display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  margin-top: 52px; padding-top: 20px; border-top: 1px solid var(--line);
  color: var(--muted); font-size: 13px; font-family: var(--ui);
}

/* ---- responsive ---- */
@media (max-width: 1080px) {
  .layout { grid-template-columns: 252px minmax(0, 1fr); }
  .aside-col { display: none; }
}
@media (max-width: 820px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .menu-btn { display: block; }
  .sidebar {
    position: fixed; left: 0; top: 61px; bottom: 0; width: 292px; z-index: 25;
    background: var(--card); transform: translateX(-100%); transition: transform .18s ease;
    border-right: 1px solid var(--line); height: auto;
  }
  .sidebar.open { transform: none; box-shadow: 0 10px 40px rgba(0,0,0,.25); }
  .main { padding: 30px 22px 56px; }
  .app-link { display: none; }
  .doc h1 { font-size: 33px; }
}

/* AerariumChain wordmark, masked so it follows the theme ink color. */
.brand-logo {
  display: inline-block; width: 167px; height: 22px; flex: 0 0 auto;
  /* Real multicolor wordmark — dark text on light theme, white on dark. */
  background: url('/logo-aerariumchain-dark.svg') center/contain no-repeat;
}
:root[data-theme="dark"] .brand-logo { background-image: url('/logo-aerariumchain-light.svg'); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .brand-logo { background-image: url('/logo-aerariumchain-light.svg'); }
}
@media (max-width: 720px) { .brand-logo { width: 129px; height: 17px; } }
