/* NagiSeries documentation site. Pages are generated by site/build.py. */

:root {
    --bg: #fbfcfc;
    --surface: #ffffff;
    --side: #f2f6f7;
    --text: #1b2327;
    --muted: #5a6870;
    --line: #dde5e8;
    --line-strong: #c6d2d7;
    --accent: #1d6a89;
    --accent-hover: #134f68;
    --accent-soft: #e1f0f5;
    --on-accent: #ffffff;
    --code-bg: #eff3f4;
    --code-text: #24323a;
    --pre-bg: #15212a;
    --pre-text: #e3ebef;
    --mark: #ffe2a8;
    --brand-bg: #15252e;
    --brand-wave: #7dbad6;
    --shadow: 0 1px 2px rgba(16, 32, 40, .06), 0 8px 24px rgba(16, 32, 40, .06);
    --side-w: 300px;
    --topbar-h: 56px;
    --font: "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", "Yu Gothic UI", "Meiryo", system-ui, sans-serif;
    --mono: ui-monospace, "SFMono-Regular", "Cascadia Mono", Consolas, "BIZ UDGothic", "Osaka-Mono", monospace;
    color-scheme: light;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --bg: #0e1316;
        --surface: #121a1f;
        --side: #0b1013;
        --text: #e4ebee;
        --muted: #92a3ab;
        --line: #22313a;
        --line-strong: #31444f;
        --accent: #7dbad6;
        --accent-hover: #a5d3e8;
        --accent-soft: #15283271;
        --on-accent: #0b1216;
        --code-bg: #1a252c;
        --code-text: #d7e2e7;
        --pre-bg: #0a1014;
        --pre-text: #dce6ea;
        --mark: #6b5420;
        --brand-bg: #1c3340;
        --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
        color-scheme: dark;
    }
}
:root[data-theme="dark"] {
    --bg: #0e1316; --surface: #121a1f; --side: #0b1013; --text: #e4ebee; --muted: #92a3ab;
    --line: #22313a; --line-strong: #31444f; --accent: #7dbad6; --accent-hover: #a5d3e8;
    --accent-soft: #15283271; --on-accent: #0b1216; --code-bg: #1a252c; --code-text: #d7e2e7; --pre-bg: #0a1014;
    --pre-text: #dce6ea; --mark: #6b5420; --brand-bg: #1c3340;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
    color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; scroll-padding-top: 16px; }
body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
    font-size: 16px;
    line-height: 1.85;
    overflow-wrap: anywhere;
    -webkit-font-smoothing: antialiased;
}
html.menu-open { overflow: hidden; }
a { color: var(--accent); text-underline-offset: .2em; text-decoration-thickness: 1px; }
a:hover { color: var(--accent-hover); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
svg { display: block; }

.skip {
    position: absolute; left: 12px; top: -48px; z-index: 50; padding: 8px 14px;
    background: var(--surface); border: 1px solid var(--line); border-radius: 8px;
}
.skip:focus { top: 12px; }

/* ---- brand ---- */
.brand {
    display: inline-flex; align-items: center; gap: 10px;
    color: var(--text); text-decoration: none; font-weight: 700; letter-spacing: .02em;
}
.brand:hover { color: var(--text); }
.brand-mark { width: 30px; height: 30px; flex: none; }
.brand-name { font-size: 18px; }

/* ---- layout: a fixed left column on wide screens ---- */
.topbar { display: none; }
.layout { display: grid; grid-template-columns: var(--side-w) minmax(0, 1fr); min-height: 100vh; }

.sidebar {
    position: sticky; top: 0; height: 100vh; height: 100dvh;
    display: flex; flex-direction: column; gap: 14px;
    padding: 20px 14px 16px 20px;
    background: var(--side);
    border-right: 1px solid var(--line);
    overflow-y: auto; overscroll-behavior: contain;
    scrollbar-width: thin;
}
.sidebar > .brand { padding: 2px 6px; }

.main { min-width: 0; padding: 40px clamp(20px, 5vw, 64px) 40px; }
.doc, .pager, .foot { max-width: 820px; margin-left: auto; margin-right: auto; }

/* ---- navigation ---- */
.nav-list, .nav-toc, .nav-toc ol { list-style: none; margin: 0; padding: 0; }
.nav-list { display: grid; gap: 2px; }
.nav-link {
    display: flex; align-items: baseline; justify-content: space-between; gap: 8px;
    padding: 7px 10px; border-radius: 8px;
    color: var(--text); text-decoration: none; line-height: 1.4;
}
.nav-link:hover { background: var(--accent-soft); color: var(--text); }
.nav-name { font-weight: 650; }
.nav-sub { font-size: 12px; color: var(--muted); }
.nav-item.is-current > .nav-link { background: var(--accent-soft); }
.nav-item.is-current > .nav-link .nav-name { color: var(--accent); }

.nav-toc { margin: 4px 0 10px 10px; padding-left: 10px; border-left: 1px solid var(--line-strong); }
.nav-toc a {
    display: block; padding: 4px 8px; border-radius: 6px;
    color: var(--muted); text-decoration: none; font-size: 13.5px; line-height: 1.5;
}
.nav-toc ol a { padding-left: 20px; font-size: 13px; }
.nav-toc a:hover { color: var(--text); background: var(--accent-soft); }
.nav-toc a.is-active { color: var(--accent); font-weight: 650; background: var(--accent-soft); }
.nav-toc code { font-size: .92em; background: none; padding: 0; }

.side-foot {
    margin: auto 0 0; padding: 12px 10px 0; border-top: 1px solid var(--line);
    display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 13px;
}
.side-foot a { color: var(--muted); text-decoration: none; }
.side-foot a:hover { color: var(--accent); }

/* ---- search ---- */
.search { position: relative; }
.search-field {
    display: flex; align-items: center; gap: 8px;
    padding: 0 10px; height: 40px;
    background: var(--surface); border: 1px solid var(--line-strong); border-radius: 10px;
    color: var(--muted);
}
.search-field:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.search-field svg { width: 18px; height: 18px; flex: none; }
.search-field input {
    flex: 1; min-width: 0; height: 100%; border: 0; outline: 0; background: none;
    color: var(--text); font: inherit; font-size: 15px;
}
.search-field input::-webkit-search-cancel-button { cursor: pointer; }
.search-key {
    font-family: var(--mono); font-size: 12px; line-height: 1; padding: 3px 6px;
    border: 1px solid var(--line-strong); border-radius: 5px; color: var(--muted);
}
.search-field:focus-within .search-key { display: none; }
.menu .search-key { display: none; }
.search-results {
    margin-top: 8px; padding: 4px; max-height: min(60vh, 520px); overflow-y: auto; overscroll-behavior: contain;
    background: var(--surface); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow);
}
.search-results a {
    display: block; padding: 8px 10px; border-radius: 8px; color: var(--text); text-decoration: none; line-height: 1.5;
}
.search-results a:hover, .search-results a.is-selected { background: var(--accent-soft); }
.search-results .r-page { display: block; font-size: 11.5px; color: var(--muted); letter-spacing: .02em; }
.search-results .r-title { display: block; font-weight: 650; font-size: 14.5px; }
.search-results .r-text { display: block; font-size: 13px; color: var(--muted); margin-top: 2px; }
.search-results mark { background: var(--mark); color: inherit; border-radius: 2px; padding: 0 1px; }
.search-empty { padding: 10px; font-size: 13.5px; color: var(--muted); }

/* ---- document ---- */
.crumbs { margin: 0 0 6px; font-size: 13px; color: var(--muted); display: flex; gap: 8px; }
.crumbs a { color: var(--muted); text-decoration: none; }
.crumbs a:hover { color: var(--accent); }
.doc-title { margin: 0 0 18px; font-size: clamp(26px, 4vw, 34px); line-height: 1.35; letter-spacing: .01em; }
.lead { font-size: 16.5px; color: var(--text); }
.lead > p:first-child { margin-top: 0; }

.toc-inline { display: none; }

.doc-body h2, .doc-body h3, .doc-body h4 {
    position: relative; line-height: 1.45; scroll-margin-top: 16px;
}
.doc-body h2 {
    margin: 56px 0 16px; padding-top: 24px; font-size: 24px;
    border-top: 1px solid var(--line);
}
.doc-body > h2:first-child { margin-top: 32px; }
.doc-body h3 { margin: 36px 0 12px; font-size: 19px; }
.doc-body h4 { margin: 28px 0 8px; font-size: 16.5px; }
.doc-body hr { display: none; }
.anchor {
    margin-left: 8px; color: var(--line-strong); text-decoration: none; font-weight: 400;
    opacity: 0; transition: opacity .15s;
}
h2:hover .anchor, h3:hover .anchor, h4:hover .anchor, .anchor:focus-visible { opacity: 1; }
.anchor:hover { color: var(--accent); }

.doc p { margin: 14px 0; }
.doc ul, .doc ol { margin: 12px 0; padding-left: 1.5em; }
.doc li { margin: 4px 0; }
.doc li > ul, .doc li > ol { margin: 4px 0; }
.doc li::marker { color: var(--muted); }
.doc strong { font-weight: 700; }
.doc blockquote {
    margin: 16px 0; padding: 4px 16px; border-left: 3px solid var(--accent);
    background: var(--accent-soft); border-radius: 0 8px 8px 0;
}

.doc code {
    font-family: var(--mono); font-size: .88em;
    background: var(--code-bg); color: var(--code-text);
    padding: .12em .4em; border-radius: 5px; overflow-wrap: anywhere;
}
.doc pre {
    position: relative; margin: 16px 0; padding: 16px 18px;
    background: var(--pre-bg); color: var(--pre-text);
    border-radius: 10px; overflow-x: auto; line-height: 1.6;
    -webkit-overflow-scrolling: touch;
}
.doc pre code {
    background: none; color: inherit; padding: 0; font-size: 13.5px;
    white-space: pre; overflow-wrap: normal;
}
.copy {
    position: absolute; top: 8px; right: 8px;
    padding: 4px 10px; font: inherit; font-size: 12px; line-height: 1.5;
    color: var(--pre-text); background: rgba(255, 255, 255, .08);
    border: 1px solid rgba(255, 255, 255, .16); border-radius: 6px; cursor: pointer;
    opacity: 0; transition: opacity .15s;
}
.doc pre:hover .copy, .copy:focus-visible, .copy.is-done { opacity: 1; }
@media (hover: none) { .copy { opacity: 1; } }

.table-wrap {
    margin: 16px 0; overflow-x: auto; -webkit-overflow-scrolling: touch;
    border: 1px solid var(--line); border-radius: 10px;
}
.table-wrap table { width: 100%; border-collapse: collapse; font-size: 14.5px; line-height: 1.7; }
.table-wrap th, .table-wrap td { padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: top; text-align: left; }
.table-wrap th { background: var(--side); font-weight: 650; white-space: nowrap; }
.table-wrap tr:last-child td { border-bottom: 0; }
.table-wrap td:first-child { font-weight: 600; min-width: 7em; }

.figure { margin: 20px 0; }
.doc img { max-width: 100%; height: auto; border-radius: 8px; }
.zoom { display: inline-block; cursor: zoom-in; border-radius: 10px; line-height: 0; }
.figure .zoom img, .shots img { border: 1px solid var(--line); box-shadow: var(--shadow); }
.shots { display: block; margin: 20px 0; }
.shots tbody { display: block; }
.shots tr { display: flex; flex-wrap: wrap; gap: 16px; }
.shots td { flex: 1 1 200px; padding: 0; font-size: 13.5px; color: var(--muted); line-height: 1.6; }
.shots td[align="center"] { text-align: center; }
.shots br { display: block; content: ""; margin-top: 6px; }
.shots .zoom { margin-bottom: 4px; }

/* ---- top page ---- */
.hero-links { display: flex; flex-wrap: wrap; gap: 10px; margin: 20px 0 8px; }
.btn {
    display: inline-flex; align-items: center; gap: 8px; padding: 9px 16px;
    border-radius: 999px; border: 1px solid var(--line-strong);
    color: var(--text); text-decoration: none; font-weight: 600; font-size: 14.5px; line-height: 1.4;
    background: var(--surface);
}
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: var(--on-accent); }

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 16px; margin: 20px 0; }
.card {
    display: flex; flex-direction: column;
    background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
    overflow: hidden; box-shadow: var(--shadow);
}
.card-img { display: block; aspect-ratio: 1200 / 630; overflow: hidden; background: var(--brand-bg); line-height: 0; }
.card-img img { width: 100%; height: 100%; object-fit: cover; border-radius: 0; }
.card-body { display: flex; flex-direction: column; flex: 1; padding: 14px 16px 16px; }
.card h3 { margin: 0 !important; font-size: 19px !important; }
.card .card-kind { margin: 2px 0 8px; font-size: 13px; color: var(--muted); }
.card ul { margin: 0 0 14px; padding-left: 1.2em; font-size: 14.5px; line-height: 1.7; }
.card-links { margin-top: auto; display: flex; flex-wrap: wrap; gap: 8px; }
.card-links .btn { padding: 6px 12px; font-size: 13.5px; }

.flow { display: grid; gap: 10px; margin: 16px 0; padding: 0; list-style: none; counter-reset: flow; }
.flow li {
    counter-increment: flow; position: relative; margin: 0;
    padding: 12px 14px 12px 52px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface);
}
.flow li::before {
    content: counter(flow); position: absolute; left: 14px; top: 13px;
    width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center;
    background: var(--accent-soft); color: var(--accent); font-weight: 700; font-size: 14px; line-height: 1;
}

/* ---- pager / footer ---- */
.pager { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 56px; }
.pager a {
    display: block; padding: 12px 16px; border: 1px solid var(--line); border-radius: 12px;
    text-decoration: none; color: var(--accent); font-weight: 650; background: var(--surface);
}
.pager a:hover { border-color: var(--accent); }
.pager span { display: block; font-size: 12px; color: var(--muted); font-weight: 400; }
.pager-next { text-align: right; grid-column: 2; }
.foot {
    margin-top: 32px; padding-top: 16px; border-top: 1px solid var(--line);
    display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 16px;
    font-size: 13px; color: var(--muted);
}
.foot p { margin: 0; }
.foot a { color: var(--muted); }

/* ---- menu (dialog on narrow screens) ---- */
.menu {
    width: min(440px, calc(100vw - 24px));
    max-width: none;
    max-height: calc(100vh - 24px);
    max-height: calc(100dvh - 24px);
    margin: 12px 12px auto auto;
    padding: 0;
    border: 1px solid var(--line); border-radius: 16px;
    background: var(--side); color: var(--text);
    box-shadow: 0 20px 60px rgba(0, 0, 0, .3);
    overflow: hidden;
}
.menu[open] { display: flex; flex-direction: column; }
.menu::backdrop { background: rgba(8, 14, 18, .5); }
.menu-head {
    display: flex; align-items: center; justify-content: space-between;
    padding: 10px 10px 10px 18px; border-bottom: 1px solid var(--line); flex: none;
}
.menu-title { margin: 0; font-weight: 700; }
.menu-close, .topbar-btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    min-width: 40px; height: 40px; padding: 0 10px;
    background: none; border: 1px solid transparent; border-radius: 10px;
    color: var(--text); font: inherit; font-size: 14px; cursor: pointer;
}
.menu-close:hover, .topbar-btn:hover { background: var(--accent-soft); }
.menu-close svg, .topbar-btn svg { width: 22px; height: 22px; }
/* The menu itself scrolls when it is taller than the screen. */
.menu-body {
    flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    padding: 14px 14px 18px; display: flex; flex-direction: column; gap: 14px;
}
.menu .side-foot { margin-top: 4px; }

/* ---- narrow screens: headings become a table of contents in the page ---- */
@media (max-width: 960px) {
    .layout { display: block; }
    .sidebar { display: none; }
    .topbar {
        position: sticky; top: 0; z-index: 20;
        display: flex; align-items: center; justify-content: space-between;
        height: var(--topbar-h); padding: 0 8px 0 16px;
        background: color-mix(in srgb, var(--bg) 88%, transparent);
        -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
        border-bottom: 1px solid var(--line);
    }
    .topbar .brand-mark { width: 26px; height: 26px; }
    .topbar .brand-name { font-size: 16.5px; }
    .topbar-btn { border-color: var(--line-strong); }
    html { scroll-padding-top: calc(var(--topbar-h) + 12px); }
    .doc-body h2, .doc-body h3, .doc-body h4 { scroll-margin-top: calc(var(--topbar-h) + 12px); }
    .main { padding: 24px 16px 32px; }

    .toc-inline {
        display: block; margin: 24px 0 8px; padding: 14px 16px 12px;
        background: var(--side); border: 1px solid var(--line); border-radius: 14px;
    }
    .toc-title { margin: 0 0 6px; font-weight: 700; font-size: 15px; }
    .toc-list, .toc-list ol { list-style: none; margin: 0; padding: 0; }
    .toc-list { counter-reset: toc; }
    .toc-list > li { counter-increment: toc; border-top: 1px solid var(--line); margin: 0; }
    .toc-list > li:first-child { border-top: 0; }
    .toc-list a {
        display: block; padding: 9px 2px; color: var(--text); text-decoration: none;
        line-height: 1.5; font-size: 15px;
    }
    .toc-list > li > a::before {
        content: counter(toc) "."; display: inline-block; min-width: 2em;
        color: var(--muted); font-variant-numeric: tabular-nums;
    }
    .toc-list ol { margin: -4px 0 6px 2em; }
    .toc-list ol a { padding: 5px 0 5px 12px; font-size: 14px; color: var(--muted); border-left: 1px solid var(--line-strong); }
    .toc-list code { font-family: var(--mono); font-size: .9em; }

    .doc-body h2 { margin-top: 44px; font-size: 21px; }
    .doc-body h3 { font-size: 17.5px; }
    .anchor { display: none; }
    .doc pre { margin-left: -16px; margin-right: -16px; border-radius: 0; padding: 14px 16px; }
    .pager { grid-template-columns: 1fr; }
    .pager-next { grid-column: auto; }
}

@media (prefers-reduced-motion: reduce) {
    * { transition: none !important; scroll-behavior: auto !important; }
}

@media print {
    .sidebar, .topbar, .menu, .pager, .copy, .anchor { display: none !important; }
    .layout { display: block; }
}
