/* PIM Atlas. Layout concept: a nautical-chart "plate" system. Pale chart paper, deep survey ink,
   chart magenta reserved for the one thing that matters on each view, graticule ticks as structure. */
:root {
  --paper: #f4f7f8;
  --paper-2: #e6eef1;
  --sound: #d3e3ea;
  --ink: #12293a;
  --ink-2: #44596a;
  --rule: #b9cbd4;
  --accent: #a3195b;
  --accent-ink: #ffffff;
  --shoal: #2f6f8f;
  --ok: #2e7d4f;
  --warn: #9a5b00;
  --f-display: "Literata", "Iowan Old Style", Georgia, serif;
  --f-body: "Public Sans", "Segoe UI", system-ui, sans-serif;
  --f-label: "Alegreya Sans SC", "Public Sans", system-ui, sans-serif;
  --measure: 68ch;
  --wrap: 1180px;
  --r: 3px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #0c1a24; --paper-2: #13242f; --sound: #1a3140; --ink: #e3ecf0; --ink-2: #9db1bd;
    --rule: #2c4554; --accent: #f06aa7; --accent-ink: #1a0610; --shoal: #7fb8d4; --ok: #6cc796; --warn: #e3a64a;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #0c1a24; --paper-2: #13242f; --sound: #1a3140; --ink: #e3ecf0; --ink-2: #9db1bd;
  --rule: #2c4554; --accent: #f06aa7; --accent-ink: #1a0610; --shoal: #7fb8d4; --ok: #6cc796; --warn: #e3a64a;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 16px/1.62 var(--f-body); }
body::before { content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); z-index: 10; background: var(--paper); }
a { color: var(--shoal); text-underline-offset: 3px; text-decoration-thickness: 1px; }
a:hover { color: var(--accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
img, svg { max-width: 100%; }
h1, h2, h3 { font-family: var(--f-display); font-weight: 600; line-height: 1.18; text-wrap: balance; letter-spacing: -0.01em; margin: 0; }
h1 { font-size: clamp(2rem, 1.4rem + 2.6vw, 3.25rem); }
h2 { font-size: clamp(1.4rem, 1.15rem + 1vw, 1.85rem); }
h3 { font-size: 1.15rem; }
p { margin: 0; }
.label { font-family: var(--f-label); font-size: 0.86rem; letter-spacing: 0.09em; text-transform: lowercase; color: var(--ink-2); font-weight: 500; }
.num { font-variant-numeric: tabular-nums; }

.wrap { max-width: var(--wrap); margin: 0 auto; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
.skip { position: absolute; left: -9999px; }
.skip:focus { left: 16px; top: 16px; background: var(--paper); padding: 8px 12px; z-index: 20; }

/* Header: wordmark plus graticule tick strip */
.site-head { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 9; background: color-mix(in srgb, var(--paper) 94%, transparent); backdrop-filter: blur(6px); border-bottom: 1px solid var(--rule); }
.site-head .wrap { display: flex; align-items: center; gap: 24px; padding-block: 12px; flex-wrap: wrap; }
.brand { display: flex; align-items: baseline; gap: 10px; text-decoration: none; color: var(--ink); }
.brand-mark { font-family: var(--f-label); font-weight: 700; font-size: 1.32rem; letter-spacing: 0.2em; text-transform: lowercase; }
.brand-mark b { color: var(--accent); font-weight: 700; }
.brand-ed { font-family: var(--f-label); font-size: 0.78rem; letter-spacing: 0.08em; color: var(--ink-2); }
.nav { display: flex; gap: 4px 20px; flex-wrap: wrap; margin-left: auto; }
.nav a { color: var(--ink); text-decoration: none; font-size: 0.95rem; padding: 4px 0; border-bottom: 2px solid transparent; }
.nav a:hover, .nav a[aria-current="page"] { border-bottom-color: var(--accent); color: var(--ink); }
.ticks { height: 7px; background-image: repeating-linear-gradient(90deg, var(--rule) 0 1px, transparent 1px 24px), repeating-linear-gradient(90deg, var(--ink-2) 0 1px, transparent 1px 120px); background-size: auto 4px, auto 7px; background-repeat: repeat-x; background-position: 0 0; opacity: 0.7; }

main { display: block; }
.section { padding-block: clamp(40px, 6vw, 72px); }
.section + .section { border-top: 1px solid var(--rule); }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px 24px; flex-wrap: wrap; margin-bottom: 24px; }
.section-head p { color: var(--ink-2); max-width: 60ch; }

/* Breadcrumbs */
.crumbs { font-size: 0.86rem; color: var(--ink-2); padding-top: 20px; }
.crumbs ol { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.crumbs li + li::before { content: "/"; margin-right: 6px; color: var(--rule); }
.crumbs a { color: var(--ink-2); }

/* Hero */
.hero { padding-block: clamp(32px, 5vw, 64px) clamp(28px, 4vw, 48px); }
.hero-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr); gap: clamp(24px, 4vw, 56px); align-items: center; }
.hero h1 { margin: 10px 0 16px; }
.hero h1 em { font-style: italic; color: var(--accent); font-weight: 500; }
.lede { font-size: 1.14rem; color: var(--ink-2); max-width: 54ch; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 24px; }
.btn { display: inline-flex; align-items: center; gap: 8px; padding: 11px 18px; border-radius: var(--r); border: 1px solid var(--ink); color: var(--ink); background: transparent; text-decoration: none; font: 600 0.95rem var(--f-body); cursor: pointer; }
.btn:hover { background: var(--paper-2); color: var(--ink); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: var(--accent); color: var(--accent-ink); filter: brightness(1.08); }
.stats { display: flex; flex-wrap: wrap; gap: 8px 32px; margin-top: 28px; padding-top: 16px; border-top: 1px solid var(--rule); }
.stats div { display: flex; flex-direction: column; }
.stats strong { font-family: var(--f-display); font-size: 1.7rem; font-weight: 600; font-variant-numeric: tabular-nums; line-height: 1.1; }

/* Chart plate */
.plate { border: 1px solid var(--rule); background: var(--sound); border-radius: var(--r); position: relative; }
.plate svg { display: block; width: 100%; height: auto; }
.plate .grat { stroke: var(--rule); stroke-width: 0.6; fill: none; }
.plate .grat-lbl { fill: var(--ink-2); font: 500 9px var(--f-label); letter-spacing: 0.06em; }
.plate .dot { fill: var(--ink); stroke: var(--sound); stroke-width: 1.2; }
.plate .dot-major { fill: var(--accent); }
.plate .dot-lbl { fill: var(--ink); font: 600 9.5px var(--f-body); paint-order: stroke; stroke: var(--sound); stroke-width: 3px; }
.plate a:hover .dot { fill: var(--accent); }
.plate-cap { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 4px 16px; padding: 8px 12px; border-top: 1px solid var(--rule); background: var(--paper); font-size: 0.8rem; color: var(--ink-2); }
.plate-cap span b { color: var(--ink); font-weight: 600; }

/* Index lists */
.index-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 0 32px; }
.index-row { display: grid; grid-template-columns: 2.4rem minmax(0, 1fr) auto; gap: 12px; align-items: baseline; padding: 14px 0; border-bottom: 1px solid var(--rule); text-decoration: none; color: var(--ink); }
.index-row:hover h3 { color: var(--accent); }
.index-row .ref { font-family: var(--f-label); color: var(--ink-2); font-size: 0.9rem; }
.index-row p { color: var(--ink-2); font-size: 0.9rem; margin-top: 2px; }
.index-row .count { font-variant-numeric: tabular-nums; font-weight: 600; }

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 20px; }
.card { display: flex; flex-direction: column; gap: 8px; padding: 18px 20px; border: 1px solid var(--rule); border-radius: var(--r); background: var(--paper); text-decoration: none; color: var(--ink); min-width: 0; }
.card:hover { border-color: var(--ink-2); }
.card:hover h3 { color: var(--accent); }
.card p { color: var(--ink-2); font-size: 0.94rem; }
.card .meta { margin-top: auto; padding-top: 8px; display: flex; flex-wrap: wrap; gap: 6px; }

.chip { display: inline-block; padding: 2px 8px; border: 1px solid var(--rule); border-radius: 999px; font-size: 0.78rem; color: var(--ink-2); white-space: nowrap; background: var(--paper); }
.chip-strong { border-color: var(--ink-2); color: var(--ink); }
a.chip { text-decoration: none; }
a.chip:hover { border-color: var(--accent); color: var(--ink); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }

/* Directory */
.filters { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; padding: 16px; border: 1px solid var(--rule); border-radius: var(--r); background: var(--paper-2); margin-bottom: 16px; }
.filters label { display: flex; flex-direction: column; gap: 4px; font-size: 0.82rem; color: var(--ink-2); }
.filters input, .filters select { font: 0.95rem var(--f-body); padding: 8px 10px; border: 1px solid var(--rule); border-radius: var(--r); background: var(--paper); color: var(--ink); min-width: 0; }
.filters .check { flex-direction: row; align-items: center; gap: 8px; align-self: end; padding-bottom: 8px; }
.result-line { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; font-size: 0.9rem; color: var(--ink-2); }
.table-scroll { overflow-x: auto; border: 1px solid var(--rule); border-radius: var(--r); }
table { border-collapse: collapse; width: 100%; font-size: 0.92rem; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--rule); vertical-align: top; }
th { font-family: var(--f-label); font-weight: 500; letter-spacing: 0.06em; color: var(--ink-2); background: var(--paper-2); white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
td.name a { font-weight: 600; color: var(--ink); text-decoration: none; }
td.name a:hover { color: var(--accent); }
td.name small { display: block; color: var(--ink-2); font-weight: 400; }
.dir-table td { white-space: nowrap; }
.dir-table td.name, .dir-table td.wrapcell { white-space: normal; min-width: 220px; }

/* Profile + article layout */
.page-head { padding-block: 16px 28px; border-bottom: 1px solid var(--rule); }
.page-head h1 { margin: 8px 0 12px; }
.page-head .lede { max-width: 70ch; }
.layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: clamp(24px, 4vw, 56px); padding-block: 32px 64px; align-items: start; }
.layout-rev { grid-template-columns: 240px minmax(0, 1fr); }
.prose { max-width: var(--measure); min-width: 0; }
.prose > * + * { margin-top: 1.05em; }
.prose h2 { margin-top: 2em; scroll-margin-top: 90px; }
.prose h3 { margin-top: 1.5em; scroll-margin-top: 90px; }
.prose ul, .prose ol { padding-left: 1.3em; }
.prose li + li { margin-top: 0.35em; }
.prose table { margin-block: 1.2em; }
.prose .table-scroll { margin-top: 1.2em; }
.prose blockquote { margin-left: 0; padding-left: 16px; border-left: 3px solid var(--rule); color: var(--ink-2); }
.prose code { font-size: 0.9em; background: var(--paper-2); padding: 1px 5px; border-radius: 3px; }

.answer { border: 1px solid var(--rule); border-left: 4px solid var(--accent); border-radius: var(--r); padding: 16px 20px; background: var(--paper-2); }
.answer .label { display: block; margin-bottom: 4px; }
.answer p { font-size: 1.06rem; }

.datasheet { border: 1px solid var(--rule); border-radius: var(--r); background: var(--paper); position: sticky; top: calc(env(safe-area-inset-top, 0px) + 84px); }
.datasheet h2 { font-family: var(--f-label); font-size: 1rem; font-weight: 700; letter-spacing: 0.12em; padding: 12px 16px; border-bottom: 1px solid var(--rule); background: var(--paper-2); }
.datasheet dl { margin: 0; padding: 4px 16px 12px; display: grid; grid-template-columns: 7.5rem minmax(0, 1fr); gap: 0 12px; font-size: 0.88rem; }
.datasheet dt { color: var(--ink-2); padding: 7px 0; border-bottom: 1px dashed var(--rule); }
.datasheet dd { margin: 0; padding: 7px 0; border-bottom: 1px dashed var(--rule); min-width: 0; overflow-wrap: anywhere; }
.datasheet .ds-foot { padding: 12px 16px; border-top: 1px solid var(--rule); display: flex; flex-direction: column; gap: 8px; }

.split { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.ledger { border-top: 2px solid var(--ink); padding-top: 10px; }
.ledger h3 { font-family: var(--f-label); font-size: 1rem; letter-spacing: 0.1em; font-weight: 700; margin-bottom: 8px; }
.ledger ul { list-style: none; padding: 0; margin: 0; }
.ledger li { padding: 8px 0 8px 22px; border-bottom: 1px solid var(--rule); position: relative; font-size: 0.95rem; }
.ledger li::before { position: absolute; left: 0; top: 8px; font-weight: 700; }
.ledger.plus li::before { content: "+"; color: var(--ok); }
.ledger.minus li::before { content: "\2212"; color: var(--warn); }

.faq { border-top: 1px solid var(--rule); }
.faq details { border-bottom: 1px solid var(--rule); padding: 14px 0; }
.faq summary { cursor: pointer; font-weight: 600; font-family: var(--f-display); font-size: 1.05rem; list-style: none; display: flex; justify-content: space-between; gap: 16px; }
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: "+"; color: var(--accent); font-family: var(--f-body); }
.faq details[open] summary::after { content: "\2212"; }
.faq details p { margin-top: 8px; color: var(--ink-2); }

.sources { font-size: 0.86rem; color: var(--ink-2); }
.sources ol { padding-left: 1.2em; margin: 8px 0 0; }
.sources li { overflow-wrap: anywhere; }

.toc { position: sticky; top: calc(env(safe-area-inset-top, 0px) + 84px); font-size: 0.9rem; }
.toc ol { list-style: none; margin: 8px 0 0; padding: 0; border-left: 1px solid var(--rule); }
.toc li a { display: block; padding: 5px 0 5px 14px; color: var(--ink-2); text-decoration: none; margin-left: -1px; border-left: 2px solid transparent; }
.toc li a:hover { color: var(--ink); border-left-color: var(--accent); }
.meta-line { display: flex; flex-wrap: wrap; gap: 4px 18px; font-size: 0.86rem; color: var(--ink-2); }

.aside-box { border: 1px solid var(--rule); border-radius: var(--r); padding: 16px; display: flex; flex-direction: column; gap: 10px; background: var(--paper); }
.aside-box + .aside-box { margin-top: 16px; }
.aside-box ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; font-size: 0.92rem; }
.resource { border: 1px dashed var(--rule); border-radius: var(--r); padding: 14px 16px; font-size: 0.92rem; color: var(--ink-2); }

/* Compare tool */
.compare-pick { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-bottom: 20px; }
.compare-pick select { width: 100%; font: 0.95rem var(--f-body); padding: 10px; border: 1px solid var(--rule); border-radius: var(--r); background: var(--paper); color: var(--ink); }
.cmp-table th[scope="row"] { width: 170px; background: var(--paper-2); }
.cmp-table td { min-width: 200px; }
.cmp-table thead th { font-family: var(--f-display); font-size: 1.05rem; letter-spacing: 0; color: var(--ink); text-transform: none; }

/* Glossary */
.alpha { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 20px; }
.alpha a { font-family: var(--f-label); padding: 2px 8px; border: 1px solid var(--rule); border-radius: var(--r); text-decoration: none; color: var(--ink); }
.term { padding: 16px 0; border-bottom: 1px solid var(--rule); display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 8px 24px; scroll-margin-top: 90px; }
.term dt h3 { font-size: 1.1rem; }
.term dt small { color: var(--ink-2); display: block; font-size: 0.85rem; }
.term dd { margin: 0; color: var(--ink-2); max-width: 70ch; }

/* Search */
.search-box { width: 100%; font: 1.05rem var(--f-body); padding: 12px 14px; border: 1px solid var(--ink-2); border-radius: var(--r); background: var(--paper); color: var(--ink); }
.search-results { list-style: none; padding: 0; margin: 16px 0 0; }
.search-results li { padding: 12px 0; border-bottom: 1px solid var(--rule); }
.search-results small { color: var(--ink-2); display: block; }

/* Footer */
.site-foot { border-top: 1px solid var(--rule); background: var(--paper-2); padding-block: 40px 28px; font-size: 0.9rem; color: var(--ink-2); }
.foot-grid { display: grid; grid-template-columns: 1.4fr repeat(3, minmax(0, 1fr)); gap: 28px; }
.foot-grid h2 { font-family: var(--f-label); font-size: 0.95rem; letter-spacing: 0.1em; font-weight: 700; color: var(--ink); margin-bottom: 10px; }
.foot-grid ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.foot-grid a { color: var(--ink-2); text-decoration: none; }
.foot-grid a:hover { color: var(--accent); }
.foot-base { margin-top: 28px; padding-top: 16px; border-top: 1px solid var(--rule); display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px 24px; font-size: 0.82rem; }

@media (max-width: 960px) {
  .hero-grid, .layout, .layout-rev { grid-template-columns: minmax(0, 1fr); }
  .datasheet, .toc { position: static; }
  .layout-rev .toc { display: none; }
  .foot-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 620px) {
  .split, .compare-pick { grid-template-columns: minmax(0, 1fr); }
  .term { grid-template-columns: minmax(0, 1fr); }
  .foot-grid { grid-template-columns: minmax(0, 1fr); }
  .site-head { position: static; }
  .nav { margin-left: 0; width: 100%; flex-wrap: nowrap; overflow-x: auto; gap: 18px; scrollbar-width: none; }
  .nav a { white-space: nowrap; }
  .brand-ed { display: none; }
  .datasheet dl { grid-template-columns: 6.5rem minmax(0, 1fr); }
}
@media (prefers-reduced-motion: no-preference) {
  .plate .dot { transition: fill 0.15s; }
}
