/* ── Google Fonts ───────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Source+Serif+4:ital,opsz,wght@0,8..60,200..900;1,8..60,200..900&family=Noto+Serif:ital,wght@0,400;0,700;0,900;1,400;1,700&family=Noto+Sans+Mono:wght@400;500;700&display=swap');

/* ── Light ──────────────────────────────── */
:root {
    --bg: #faf9f7;
    --surface: #f0ece6;
    --border: #cfc8bc;
    --accent: #c86820;
    --accent2: #1a1814;
    --text: #2e2a24;
    --text-muted: #7a7068;
    --text-dim: #b0a898;
    --code-bg: #f4f1ed;
    --heading: #1a1814;
}

/* ── Dark ───── */
html.dark {
    --bg: #272729;
    --surface: #313135;
    --border: #606065;
    --accent: #f7923a;
    --accent2: #e8e4d8;
    --text: #a9b1d6;
    --text-muted: #9aa5ce;
    --text-dim: #5c5c5c;
    --code-bg: #353535;
    --heading: #e8e4d8;
}


* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    background: var(--bg);
    color: var(--text);
    font-family: 'Source Serif 4', Georgia, serif;
    font-size: 17px;
    line-height: 1.2;
    min-height: 100vh;
}


.container {
    margin: 0 auto;
    padding: 0 28px 100px;
    position: relative;
    z-index: 1;
}

#theme-toggle {
    position: fixed;
    top: 20px;
    right: 24px;
    background: none;
    border: 1px solid var(--border);
    color: var(--text-muted);
    font-family: 'Noto Sans Mono', monospace;
    font-size: 11px;
    letter-spacing: 0.1em;
    padding: 5px 10px;
    cursor: pointer;
    border-radius: 3px;
    transition: all 0.2s;
    z-index: 100;
}

#theme-toggle:hover {
    color: var(--accent);
    border-color: var(--accent);
}

/* HEADER */
header {
    padding: 64px 0 48px;
    margin-bottom: 56px;
}

.label {
    font-family: 'Noto Sans Mono', monospace;
    font-size: 11px;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--accent);
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
}
.label::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--accent);
    opacity: 0.3;
    max-width: 60px;
}

h1 {
    font-family: 'Noto Serif', serif;
    font-size: clamp(2.4rem, 5vw, 3.6rem);
    font-weight: 900;
    color: var(--heading);
    line-height: 1.1;
    letter-spacing: -0.02em;
    margin-bottom: 20px;
}

h1 span {
    color: var(--accent);
}

.subtitle {
    font-family: 'Source Serif 4', serif;
    font-size: 1.1rem;
    font-style: italic;
    color: var(--text-muted);
    font-weight: 300;
    max-width: 600px;
    line-height: 1.6;
}

.meta {
    margin-top: 28px;
    display: flex;
    gap: 28px;
    font-family: 'Noto Sans Mono', monospace;
    font-size: 11px;
    color: var(--text-dim);
    letter-spacing: 0.08em;
}
.meta span { color: var(--text-muted); }

/* SECTIONS */
section {
    margin-bottom: 64px;
}

h2 {
    font-family: 'Noto Serif', serif;
    font-size: 1.7rem;
    font-weight: 700;
    color: var(--heading);
    margin-bottom: 24px;
    padding-top: 8px;
    display: flex;
    align-items: center;
    gap: 14px;
}

h3 {
    font-family: 'Noto Sans Mono', monospace;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--accent2);
    text-transform: uppercase;
    letter-spacing: 0.12em;
    margin: 36px 0 14px;
}

p {
    margin-bottom: 18px;
    color: var(--text);
}

/* LINKS */
a {
    color: var(--accent);
    text-decoration: none;
    border-bottom: 1px solid rgba(200, 104, 32, 0.2);
    transition: all 0.2s ease;
}

a:hover {
    border-bottom-color: var(--accent);
    background: rgba(200, 104, 32, 0.05);
}

/* BUTTONS */
.btn {
    display: inline-block;
    font-family: 'Noto Sans Mono', monospace;
    font-size: 13px;
    letter-spacing: 0.04em;
    color: var(--bg);
    background: var(--accent);
    border: 1px solid var(--accent);
    border-radius: 4px;
    padding: 10px 18px;
    margin: 4px 0 8px;
    text-decoration: none;
    transition: opacity 0.2s, background 0.2s;
}
.btn:hover {
    background: var(--accent);
    opacity: 0.85;
    border-bottom-color: var(--accent);
}

/* CALLOUT BOXES */
.callout {
    border-left: 3px solid var(--accent);
    background: var(--surface);
    padding: 18px 22px;
    margin: 28px 0;
    border-radius: 0 4px 4px 0;
}
.callout.warn {
    border-left-color: var(--accent2);
}
.callout p { margin: 0; font-size: 0.95rem; }
.callout-label {
    font-family: 'Noto Sans Mono', monospace;
    font-size: 10px;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: var(--accent);
    margin-bottom: 8px;
}
.callout.warn .callout-label { color: var(--accent2); }

/* CODE BLOCKS */
pre {
    background: var(--code-bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 22px 24px;
    overflow-x: auto;
    margin: 24px 0 32px;
    position: relative;
}
pre::before {
    content: attr(data-lang);
    position: absolute;
    top: 10px;
    right: 14px;
    font-family: 'Noto Sans Mono', monospace;
    font-size: 10px;
    color: var(--text-dim);
    letter-spacing: 0.1em;
    text-transform: uppercase;
}
code {
    font-family: 'Noto Sans Mono', monospace;
    font-size: 13.5px;
    line-height: 1.7;
    color: #3a3530;
}
p code, li code {
    background: var(--code-bg);
    border: 1px solid var(--border);
    padding: 1px 7px;
    border-radius: 3px;
    font-size: 13px;
    color: var(--accent);
}

/* Syntax highlight colors */
.kw  { color: #bb6bb2; }
.fn  { color: #8a7030; }
.str { color: #438a59; }
.cm  { color: #969696; font-style: italic; }
.num { color: #d67c3b; }
.ty  { color: #8258b3; }
.op  { color: #3a3530; }

/* DIAGRAM */
.diagram {
    border-top: 2px solid var(--accent2);
    border-bottom: 1px solid var(--border);
    padding: 32px 0 24px;
    margin: 36px 0;
    overflow-x: auto;
    background: transparent;
}

.pipeline {
    display: flex;
    align-items: stretch;
    gap: 0;
    flex-wrap: nowrap;
    min-width: 560px;
    margin-bottom: 16px;
    counter-reset: pipeline-step;
}

.pipe-step {
    flex: 1;
    border-right: 1px solid var(--border);
    padding: 16px 18px 14px;
    font-family: 'Noto Serif', Georgia, serif;
    font-size: 13px;
    color: var(--text-muted);
    position: relative;
    line-height: 1.5;
}

.pipe-step:first-child {
    border-left: 1px solid var(--border);
}



.pipe-step.active {
    background: rgba(247, 146, 58, 0.04);
    color: var(--text);
}

.pipe-step.active::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--accent2);
}

.pipe-step small {
    display: block;
    font-family: 'Noto Sans Mono', monospace;
    font-size: 9px;
    color: var(--text-dim);
    margin-top: 6px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.pipe-arrow { display: none; }

.pipe-step .title {
    font-family: 'Noto Serif', Georgia, serif;
    font-size: 13.5px;
    font-weight: 700;
    font-style: italic;
    color: var(--heading);
    display: block;
    margin-bottom: 5px;
}

.pipe-step .desc {
    font-family: 'Noto Serif', Georgia, serif;
    font-size: 12.5px;
    color: var(--text-muted);
    line-height: 1.5;
}

.pipe-step .num {
    font-family: 'Noto Sans Mono', monospace;
    font-size: 9px;
    letter-spacing: 0.15em;
    color: var(--accent2);
    display: block;
    margin-bottom: 8px;
    text-transform: uppercase;
}

.pipe-step.buffer {
    display: inline-block;
    margin-top: 8px;
    font-family: 'Noto Sans Mono', monospace;
    font-size: 10px;
    color: var(--accent);
    border-bottom: 1px dotted var(--accent);
    padding-bottom: 1px;
}

.diagram-caption {
    font-family: 'Noto Serif', Georgia, serif;
    font-size: 12px;
    font-style: italic;
    color: var(--text-dim);
    text-align: left;
    margin-top: 18px;
    padding-left: 2px;
    letter-spacing: 0;
}

/* FORMULA */
.formula {
    background: var(--code-bg);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 16px 24px;
    margin: 20px 0;
    font-family: 'Noto Sans Mono', monospace;
    font-size: 13px;
    color: #c86820;
    text-align: center;
}

/* TABLE */
table {
    width: 100%;
    border-collapse: collapse;
    margin: 24px 0;
    font-size: 14px;
}
th {
    font-family: 'Noto Sans Mono', monospace;
    font-size: 10px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--accent);
    border-bottom: 1px solid var(--border);
    padding: 10px 14px;
    text-align: left;
}
td {
    border-bottom: 1px solid var(--border);
    padding: 10px 14px;
    color: var(--text);
    vertical-align: top;
}
tr:hover td { background: var(--surface); }
td code { font-size: 12px; }

/* DIVIDER */
.divider {
    border: none;
    border-top: 1px solid var(--border);
    margin: 48px 0;
}

/* FOOTER */
footer {
    font-family: 'Noto Sans Mono', monospace;
    font-size: 11px;
    color: var(--text-dim);
    text-align: center;
    padding-top: 32px;
    border-top: 1px solid var(--border);
    letter-spacing: 0.06em;
}

/* ANIMATIONS */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(16px); }
    to   { opacity: 1; transform: translateY(0); }
}
header { animation: fadeIn 0.6s ease both; }
section { animation: fadeIn 0.5s ease both; }
section:nth-child(2) { animation-delay: 0.08s; }
section:nth-child(3) { animation-delay: 0.14s; }
section:nth-child(4) { animation-delay: 0.20s; }
section:nth-child(5) { animation-delay: 0.26s; }
section:nth-child(6) { animation-delay: 0.32s; }

body { font-family: 'Noto Serif', Georgia, serif; }
h1, h2 { font-family: 'Noto Serif', serif; }
h3, .label, .meta, pre, code, th, .diagram-caption, footer { font-family: 'Noto Sans Mono', monospace; }

ul {
    margin: 0 0 18px 0;
    padding-left: 24px;
}
ul li {
    margin-bottom: 6px;
    color: var(--text);
    line-height: 1.7;
}

.toc {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 24px 28px;
    margin-bottom: 56px;
}
.toc-title {
    font-family: 'Noto Sans Mono', monospace;
    font-size: 10px;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--accent);
    margin-bottom: 16px;
}
.toc ol {
    margin: 0;
    padding-left: 20px;
    counter-reset: none;
}
.toc li {
    font-family: 'Noto Sans Mono', monospace;
    font-size: 12.5px;
    color: var(--text-muted);
    margin-bottom: 6px;
}
.toc a {
    color: var(--text-muted);
    border-bottom: none;
}
.toc a:hover { color: var(--accent); background: none; }

.screenshot {
    display: block;
    max-width: 100%;
    height: auto;
    margin: 0 auto 56px;
    border-radius: 6px;
}

.badge {
    display: inline-block;
    font-family: 'Noto Sans Mono', monospace;
    font-size: 10px;
    padding: 2px 8px;
    border-radius: 3px;
    border: 1px solid;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    margin-right: 6px;
    margin-bottom: 4px;
}
.badge-blue  { color: #2a8b58; border-color: #2a8b58; background: rgba(42, 139, 88, .07); }
.badge-amber { color: #c86820; border-color: #c86820; background: rgba(200, 104, 32, .07); }
.badge-green { color: #1a7a40; border-color: #1a7a40; background: rgba(26, 122, 64, .07); }

.class-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 10px;
    margin: 20px 0 32px;
}
.class-card {
    background: var(--code-bg);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 12px 14px;
}
.class-card .cn {
    font-family: 'Noto Sans Mono', monospace;
    font-size: 12px;
    color: var(--accent);
    display: block;
    margin-bottom: 4px;
}
.class-card .cd {
    font-size: 12px;
    color: var(--text-muted);
    line-height: 1.4;
}

.sample-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 0;
    margin: 28px 0;
    border-top: 1px solid var(--border);
}

.sample-card {
    padding: 20px 0 18px;
    border-bottom: 1px solid var(--border);
    transition: none;
    position: relative;
}

.sample-grid .sample-card:nth-child(even) {
    padding-left: 28px;
    border-left: 1px solid var(--border);
}

.sample-card .sc-title {
    font-family: 'Noto Serif', Georgia, serif;
    font-size: 15px;
    font-weight: 700;
    font-style: italic;
    color: var(--heading);
    display: block;
    margin-bottom: 7px;
}

.sample-card .sc-desc {
    font-family: 'Noto Serif', Georgia, serif;
    font-size: 13.5px;
    color: var(--text-muted);
    line-height: 1.65;
    margin: 0;
}

.sample-card .sc-tags {
    margin-top: 12px;
    display: flex;
    flex-wrap: wrap;
}

.sample-card .badge {
    font-family: 'Noto Sans Mono', monospace;
    font-size: 9.5px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    border: none;
    border-radius: 0;
    background: transparent;
    padding: 0;
    margin-right: 14px;
    margin-bottom: 0;
}

.sample-card .badge::before {
    content: '\00B7';
    margin-right: 5px;
    opacity: 0.4;
}

.sample-card .badge-blue  { color: #2a8b58; }
.sample-card .badge-amber { color: #c86820; }
.sample-card .badge-green { color: #1a7a40; }

.arch-layer {
    display: flex;
    flex-direction: column;
    gap: 0;
    margin: 24px 0 36px;
    border-left: 2px solid var(--border);
    padding-left: 24px;
}

.layer-row {
    display: flex;
    gap: 0;
    align-items: baseline;
    padding: 10px 0;
    border-bottom: 1px dotted var(--border);
}

.layer-row:last-child {
    border-bottom: none;
}

.layer-box {
    flex: 1;
    text-align: left;
    padding: 0;
    font-family: 'Noto Serif', Georgia, serif;
    font-size: 13px;
    line-height: 1.5;
    background: transparent;
    border: none;
}

.layer-box::before {
    content: attr(data-label);
    display: block;
    font-family: 'Noto Sans Mono', monospace;
    font-size: 9px;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    margin-bottom: 3px;
}

.layer-app   { color: var(--text); }
.layer-app::before   { color: #c86820; }

.layer-rhi   { color: var(--text); }
.layer-rhi::before   { color: #2a8b58; }

.layer-back  { color: var(--text); }
.layer-back::before  { color: #1a7a40; }

.layer-hw    { color: var(--text-muted); }
.layer-hw::before    { color: var(--text-dim); }

.layer-arrow {
    flex: none;
    width: 24px;
    text-align: center;
    color: var(--text-dim);
    font-size: 11px;
    align-self: center;
    padding: 0 4px;
}

@media (prefers-color-scheme: dark) {

    code { color: #555555; }
    p code, li code { color: var(--accent); }

    .kw  { color: #774C73FF; }
    .fn  { color: #6C6C0EFF; }
    .str { color: #ce9178; }
    .cm  { color: #6a9955; }
    .num { color: #b5cea8; }
    .ty  { color: #1B4C44A1; }
    .op  { color: #d4d4d4; }

    .formula { color: #f7923a; }

    .badge-blue  { color: #73daca; border-color: #73daca; background: rgba(115, 218, 202, .07); }
    .badge-amber { color: #f7923a; border-color: #f7923a; background: rgba(247, 146, 58, .07); }
    .badge-green { color: #6ec87e; border-color: #6ec87e; background: rgba(110, 200, 126, .07); }

    .sample-card .badge-blue  { color: #73daca; }
    .sample-card .badge-amber { color: #f7923a; }
    .sample-card .badge-green { color: #6ec87e; }

    .layer-app::before  { color: #f7923a; }
    .layer-rhi::before  { color: #73daca; }
    .layer-back::before { color: #6ec87e; }
}

html.dark code { color: #a9b1d6; }
html.dark p code, html.dark li code { color: var(--accent); }
html.dark .kw  { color: #c586c0; }
html.dark .fn  { color: #dcdcaa; }
html.dark .str { color: #ce9178; }
html.dark .cm  { color: #6a9955; }
html.dark .num { color: #b5cea8; }
html.dark .ty  { color: #73daca; }
html.dark .op  { color: #d4d4d4; }
html.dark .formula { color: #f7923a; }
html.dark .badge-blue  { color: #73daca; border-color: #73daca; background: rgba(115, 218, 202, .07); }
html.dark .badge-amber { color: #f7923a; border-color: #f7923a; background: rgba(247, 146, 58, .07); }
html.dark .badge-green { color: #6ec87e; border-color: #6ec87e; background: rgba(110, 200, 126, .07); }
html.dark .sample-card .badge-blue  { color: #73daca; }
html.dark .sample-card .badge-amber { color: #f7923a; }
html.dark .sample-card .badge-green { color: #6ec87e; }
html.dark .layer-app::before  { color: #f7923a; }
html.dark .layer-rhi::before  { color: #73daca; }
html.dark .layer-back::before { color: #6ec87e; }

/* ── Tutorial pages ──────────────────────────── */

/* Breadcrumb navigation */
.crumbs {
  display: flex;
  justify-content: space-between;
  font-family: 'Noto Sans Mono', monospace;
  font-size: 11px;
  letter-spacing: .08em;
  color: var(--text-dim);
  margin-top: 64px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
}
.crumbs a { border-bottom: none; }

/* Figures */
.fig { margin: 28px 0 32px; }
.fig img {
  display: block;
  height: auto;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--code-bg);
}
.fig figcaption {
  font-family: 'Noto Sans Mono', monospace;
  font-size: 12px;
  font-style: normal;
  color: var(--text-dim);
  margin-top: 10px;
  letter-spacing: .02em;
  line-height: 1.5;
}
.fig-missing img { min-height: 120px; display: flex; }

/* Doc links — inline code and pre blocks */
code a.doc-link,
pre a.doc-link {
  color: inherit;
  text-decoration: underline dotted 1px;
  text-underline-offset: 2px;
  border-bottom: none;
  opacity: 0.85;
}
code a.doc-link:hover,
pre a.doc-link:hover {
  opacity: 1;
  text-decoration: underline solid 1px;
}
/* Doc links — prose */
p a.doc-link,
li a.doc-link,
td a.doc-link {
  border-bottom: 1px dotted currentColor;
  text-decoration: none;
}

/* Documentation links block (footer area) */
.doc-links-block {
  margin-top: 64px;
  padding: 28px 0 0;
  border-top: 1px solid var(--border);
}
.doc-links-title {
  font-family: 'Noto Sans Mono', monospace;
  font-size: 11px;
  letter-spacing: .15em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 16px;
}
.doc-links-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 10px;
  margin-bottom: 40px;
}
.doc-links-card {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  text-decoration: none;
  transition: border-color .15s, background .15s;
}
.doc-links-card:hover { border-color: var(--accent); }
.doc-links-name {
  font-family: 'Noto Sans Mono', monospace;
  font-size: 13px;
  font-weight: 500;
  color: var(--accent);
  letter-spacing: .02em;
}
.doc-links-desc {
  font-family: 'Noto Serif', Georgia, serif;
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.4;
}

/* ── Index page ──────────────────────────────── */

/* Article list */
.art-list { list-style: none; margin: 8px 0 24px; padding: 0; border-top: 1px solid var(--border); }
.art-item { padding: 22px 0 20px; border-bottom: 1px solid var(--border); margin: 0; }
.art-link {
  font-family: 'Noto Serif', Georgia, serif;
  font-size: 19px;
  font-weight: 700;
  font-style: italic;
  color: var(--heading);
  text-decoration: none;
  border-bottom: none;
  display: inline-flex;
  align-items: baseline;
  gap: 12px;
}
.art-link:hover { color: var(--accent); background: none; }
.art-num {
  font-family: 'Noto Sans Mono', monospace;
  font-size: 11px;
  font-style: normal;
  letter-spacing: .2em;
  color: var(--accent);
  flex: none;
}
.art-desc {
  font-family: 'Noto Serif', Georgia, serif;
  font-size: 14px;
  color: var(--text-muted);
  line-height: 1.6;
  margin: 8px 0;
}
.art-meta {
  font-family: 'Noto Sans Mono', monospace;
  font-size: 11px;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--text-dim);
}

/* Learning path box */
.path {
  margin-top: 40px;
  padding: 22px 26px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
}
.path .toc-title { margin-bottom: 14px; }
.path ol { margin: 0; padding-left: 20px; }
.path li { font-size: 14px; color: var(--text-muted); margin-bottom: 8px; line-height: 1.5; }
.path li strong { color: var(--text); font-weight: 700; }
