/* Field, group and branch pages. Tokens mirror the ones inlined in index.html. */
:root {
    --paper: #F4F1E8;
    --paper-raised: #FBF9F4;
    --ink: #1F1D19;
    --ink-2: #4E4940;
    --ink-3: #8A8476;
    --rule: #DCD5C5;

    --serif: "STIX Two Text", "STIX Two Math", "Cambria Math", Georgia, "Times New Roman", serif;
    --sans: "IBM Plex Sans", -apple-system, "Segoe UI", Helvetica, Arial, sans-serif;
    --mono: "IBM Plex Mono", ui-monospace, Menlo, Consolas, monospace;

    --p0: #B04536; --p0-t: #EBCFC5;
    --p1: #9A6A14; --p1-t: #EEDDB9;
    --p2: #864E80; --p2-t: #E4D1E0;
    --p3: #62742B; --p3-t: #DCE0C0;
    --a0: #375B90; --a0-t: #D0DAE9;
    --a1: #1F746B; --a1-t: #C8E0DB;
    --a2: #5A4C9C; --a2-t: #DAD4EE;
    --a3: #477A42; --a3-t: #D2E3CC;

    --c: var(--ink);
    --t: var(--rule);
}

html.dark {
    --paper: #151412;
    --paper-raised: #1D1B18;
    --ink: #ECE6D8;
    --ink-2: #BDB6A6;
    --ink-3: #7F796D;
    --rule: #312D27;

    --p0: #E38472; --p0-t: #3C2621;
    --p1: #D9A74C; --p1-t: #3A2F1A;
    --p2: #C48DBC; --p2-t: #352532;
    --p3: #A9BA68; --p3-t: #2D321C;
    --a0: #84A7DA; --a0-t: #1F2A3B;
    --a1: #63BBB0; --a1-t: #183230;
    --a2: #A194DD; --a2-t: #2A2641;
    --a3: #8BBE82; --a3-t: #203120;
}

.c-p0 { --c: var(--p0); --t: var(--p0-t); }
.c-p1 { --c: var(--p1); --t: var(--p1-t); }
.c-p2 { --c: var(--p2); --t: var(--p2-t); }
.c-p3 { --c: var(--p3); --t: var(--p3-t); }
.c-a0 { --c: var(--a0); --t: var(--a0-t); }
.c-a1 { --c: var(--a1); --t: var(--a1-t); }
.c-a2 { --c: var(--a2); --t: var(--a2-t); }
.c-a3 { --c: var(--a3); --t: var(--a3-t); }

*, *::before, *::after { box-sizing: border-box; }

html { background: var(--paper); }

body {
    margin: 0;
    background: var(--paper);
    color: var(--ink);
    font-family: var(--sans);
    font-size: 17px;
    line-height: 1.65;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

a { color: inherit; }

:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; border-radius: 3px; }

/* ---------- Header ---------- */
.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 14px 24px;
    border-bottom: 1px solid var(--rule);
}

.brand {
    font-family: var(--serif);
    font-size: 27px;
    line-height: 1.1;
    letter-spacing: -0.01em;
    text-decoration: none;
    white-space: nowrap;
}

.header-actions { display: flex; align-items: center; gap: 8px; }

.text-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    height: 36px;
    padding: 0 12px;
    border: 1px solid var(--rule);
    border-radius: 8px;
    font-family: var(--mono);
    font-size: 12px;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    text-decoration: none;
    color: var(--ink-2);
    transition: color 0.15s ease, border-color 0.15s ease;
}

.text-btn:hover { color: var(--ink); border-color: var(--ink-3); }

.icon-btn {
    width: 36px;
    height: 36px;
    display: inline-grid;
    place-items: center;
    padding: 0;
    border: 1px solid var(--rule);
    border-radius: 8px;
    background: transparent;
    color: var(--ink-2);
    cursor: pointer;
    transition: color 0.15s ease, border-color 0.15s ease;
}

.icon-btn:hover { color: var(--ink); border-color: var(--ink-3); }
.icon-btn svg, .text-btn svg { width: 18px; height: 18px; display: block; }

.theme-toggle .icon-sun { display: none; }
html.dark .theme-toggle .icon-sun { display: block; }
html.dark .theme-toggle .icon-moon { display: none; }

/* ---------- Article ---------- */
.page {
    max-width: 760px;
    margin: 0 auto;
    padding: 40px 24px 64px;
}

.crumbs ol {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 0;
    margin: 0 0 22px;
    padding: 0;
    list-style: none;
    font-family: var(--mono);
    font-size: 12px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--ink-3);
}

.crumbs li + li::before { content: "/"; margin: 0 10px; color: var(--rule); }
.crumbs a { color: var(--c); text-decoration: none; }
.crumbs a:hover { text-decoration: underline; text-underline-offset: 3px; }
.crumbs li:first-child a { color: var(--ink-3); }

.title-row {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 24px;
    padding-bottom: 18px;
    margin-bottom: 22px;
    border-bottom: 4px solid var(--c);
}

h1 {
    margin: 0;
    font-family: var(--serif);
    font-weight: 400;
    font-size: 52px;
    line-height: 1.08;
    letter-spacing: -0.015em;
}

.glyph {
    flex: none;
    font-family: var(--serif);
    font-style: italic;
    font-size: 36px;
    line-height: 1;
    color: var(--c);
    white-space: nowrap;
}

.lede {
    margin: 0;
    font-size: 19px;
    line-height: 1.65;
    color: var(--ink-2);
}

.map-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-top: 22px;
    font-family: var(--mono);
    font-size: 12px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--c);
    text-decoration: none;
}

.map-link:hover { text-decoration: underline; text-underline-offset: 3px; }

section { margin-top: 48px; }

.list-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 6px;
}

h2 {
    margin: 0;
    font-family: var(--mono);
    font-size: 12px;
    font-weight: 500;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--ink-3);
}

.note { font-family: var(--mono); font-size: 11.5px; color: var(--ink-3); }

/* ---------- Book and field lists ---------- */
.list {
    margin: 0;
    padding: 0;
    list-style: none;
    counter-reset: item;
}

.list > li {
    display: grid;
    grid-template-columns: 30px 1fr auto;
    align-items: baseline;
    column-gap: 10px;
    padding: 14px 0;
    border-top: 1px solid var(--rule);
}

.list > li:last-child { border-bottom: 1px solid var(--rule); }

.list > li::before {
    counter-increment: item;
    content: counter(item, decimal-leading-zero);
    font-family: var(--mono);
    font-size: 11.5px;
    color: var(--ink-3);
}

.item-title {
    font-family: var(--serif);
    font-size: 21px;
    line-height: 1.3;
    text-decoration: none;
}

.books .item-title { font-style: italic; }

a.item-title:hover { color: var(--c); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px; }

.item-sub {
    display: block;
    margin-top: 3px;
    font-size: 14.5px;
    color: var(--ink-3);
}

.item-text {
    display: block;
    margin-top: 6px;
    font-size: 16px;
    line-height: 1.6;
    color: var(--ink-2);
}

.item-aside {
    font-family: var(--serif);
    font-style: italic;
    font-size: 18px;
    color: var(--c);
    white-space: nowrap;
}

.level {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    margin-left: 10px;
    font-family: var(--mono);
    font-size: 11px;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--ink-3);
    white-space: nowrap;
}

.level i { display: block; width: 3px; height: 10px; border-radius: 1px; background: var(--rule); }
.level i.on { background: var(--c); }
.level i:last-of-type { margin-right: 5px; }

.free-pill,
.buy-link {
    align-self: center;
    font-family: var(--mono);
    font-size: 11px;
    font-weight: 500;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    text-decoration: none;
    white-space: nowrap;
}

.free-pill { padding: 5px 10px; border-radius: 999px; background: var(--c); color: var(--paper-raised); }
.free-pill:hover { filter: brightness(1.1); }
.buy-link { color: var(--ink-3); }
.buy-link:hover { color: var(--ink); }

/* ---------- Mini map of a group ---------- */
.mini-map { display: block; width: 100%; max-width: 330px; height: auto; margin: 22px auto 14px; }
.mini-map a { outline: none; }
.mini-map .hex { fill: var(--t); stroke: var(--paper); stroke-width: 4px; stroke-linejoin: round; transition: fill 0.2s ease; }
.mini-map .hex-glyph { font-family: var(--serif); font-style: italic; font-size: 24px; fill: var(--c); text-anchor: middle; transition: fill 0.2s ease; }
.mini-map .hex-name { font-family: var(--sans); font-weight: 500; font-size: 13.5px; fill: var(--ink); text-anchor: middle; transition: fill 0.2s ease; }
.mini-map a:hover .hex, .mini-map a:focus-visible .hex, .mini-map .current .hex { fill: var(--c); }
.mini-map a:hover text, .mini-map a:focus-visible text, .mini-map .current text { fill: var(--paper); }

/* ---------- Index of all fields ---------- */
.site-index {
    border-top: 1px solid var(--rule);
    padding: 44px 24px 56px;
}

.site-index-inner { max-width: 1040px; margin: 0 auto; }

.atlas {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 32px 48px;
}

.atlas-branch > h3 {
    margin: 0 0 14px;
    font-family: var(--serif);
    font-weight: 400;
    font-size: 26px;
}

.atlas-branch > h3 a { text-decoration: none; }
.atlas-branch > h3 a:hover { text-decoration: underline; text-underline-offset: 4px; text-decoration-thickness: 1px; }

.atlas-groups { display: grid; grid-template-columns: 1fr 1fr; gap: 22px 28px; }

.atlas-group h4 {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0 0 6px;
    font-family: var(--mono);
    font-size: 11.5px;
    font-weight: 500;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

.atlas-group h4 a { color: var(--c); text-decoration: none; }
.atlas-group h4 a:hover { text-decoration: underline; text-underline-offset: 3px; }

.swatch { width: 11px; height: 12px; flex: none; fill: var(--c); }

.atlas-group ul { margin: 0; padding: 0; list-style: none; }
.atlas-group li { padding: 2px 0; font-size: 15.5px; line-height: 1.45; }
.atlas-group li a { text-decoration: none; color: var(--ink-2); }
.atlas-group li a:hover, .atlas-group li a[aria-current] { color: var(--ink); text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--c); }

.site-foot {
    margin-top: 40px;
    font-family: var(--mono);
    font-size: 11.5px;
    color: var(--ink-3);
}

.site-foot a { color: var(--ink-3); }

/* ---------- Small screens ---------- */
@media (max-width: 860px) {
    .atlas { grid-template-columns: 1fr; }
}

@media (max-width: 600px) {
    .header { padding: 10px 16px; }
    .brand { font-size: 21px; }
    .text-btn span { display: none; }
    .text-btn { padding: 0 9px; }
    .page { padding: 28px 16px 48px; }
    h1 { font-size: 38px; }
    .glyph { font-size: 26px; }
    .lede { font-size: 17.5px; }
    .title-row { flex-direction: column; gap: 10px; }
    .list > li { grid-template-columns: 26px 1fr; row-gap: 10px; }
    .list > li > .free-pill, .list > li > .buy-link { grid-column: 2; justify-self: start; }
    .list > li > .item-aside { display: none; }
    .site-index { padding: 36px 16px 44px; }
    .atlas-groups { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { transition: none !important; }
}
