/* Copyright © 2026 Christopher Snow. */
/* Shared visual roles for the opening book chapters. */
.book-chapter .intro { padding-bottom:20px; margin-bottom:24px; }
.chapter-opening-code { margin:16px 0 24px; padding:20px; background:var(--accent-soft); color:var(--accent); border:0; border-left:4px solid var(--accent); border-radius:0 6px 6px 0; white-space:pre; overflow-wrap:normal; font:600 18px/1.8 ui-monospace,SFMono-Regular,Consolas,monospace; }
.chapter-opening-code code { font:inherit; }
.chapter-browser-note { color:var(--muted); font-size:14px; line-height:1.65; margin:24px 0; }
.book-chapter .hello-section,.book-chapter .book-section { border-top:1px solid var(--line); margin:40px 0; padding-top:28px; scroll-margin-top:90px; }
.book-chapter .hello-section h2,.book-chapter .book-section h2 { font-size:clamp(25px,3vw,32px); }
.book-chapter .hello-concept { font-size:inherit; }
.book-chapter .hello-note,.book-chapter .book-note { font-size:14px; }

.book-chapter { --cuda-ink:#245b91; --cuda-soft:#e9f0f8; }
:root[data-theme="dark"] .book-chapter { --cuda-ink:#b2d3ff; --cuda-soft:#20354c; }
.chapter-code-label { margin:16px 0 0; padding:8px 16px; font-size:14px; font-weight:650; }
.chapter-code-panel[data-language="pytorch"]>.chapter-code-label { color:var(--accent); background:var(--accent-soft); border-left:4px solid var(--accent); }
.chapter-code-panel[data-language="cuda"]>.chapter-code-label { color:var(--cuda-ink); background:var(--cuda-soft); border-left:4px solid var(--cuda-ink); }
.book-chapter .chapter-code-panel>pre { margin-top:0; border-radius:0 0 6px 0; }
.book-chapter .chapter-code-panel[data-language="cuda"]>pre { border:0; border-left:4px solid var(--cuda-ink); background:var(--cuda-soft); color:var(--cuda-ink); padding:16px; font:16px/1.7 ui-monospace,monospace; white-space:pre; overflow-wrap:normal; }
.chapter-code-panel>pre code { font:inherit; }

.chapter-code-panel.is-selected-thread { outline:2px solid var(--accent); outline-offset:2px; border-radius:6px; }

.chapter-definition { margin:20px 0; padding:16px 20px; border-left:4px solid var(--muted); border-radius:0 6px 6px 0; background:var(--soft); color:var(--ink); }
.chapter-definition-label { margin:0 0 10px; color:var(--muted); font-size:14px; font-weight:650; }
.chapter-definition dl { margin:0; }
.chapter-definition dt { margin:14px 0 2px; font-weight:700; }
.chapter-definition dt:first-child { margin-top:0; }
.chapter-definition dfn { font-style:normal; }
.chapter-definition dd { margin:0; line-height:1.65; }

.chapter-task { margin:20px 0; padding:16px 20px; border:1px solid var(--accent); border-radius:6px; background:var(--accent-soft); }
.chapter-task-label { display:flex; gap:10px; color:var(--accent); font-weight:700; }
.chapter-task p { margin:0; }
.chapter-task .chapter-task-label { margin-bottom:8px; }

/* The page reads as a chapter; visual emphasis belongs to examples and actions. */
.book-chapter .intro { padding-bottom:30px; margin-bottom:30px; border-bottom:0; }
.book-chapter .intro>p:last-child { font-size:19px; line-height:1.65; color:var(--muted); }
.book-chapter .hello-section,.book-chapter .book-section { margin-block:48px; padding-top:32px; }
.book-chapter .hello-section h2,.book-chapter .book-section h2 { font-size:clamp(27px,3vw,34px); line-height:1.2; margin-bottom:24px; }
.chapter-definition { border-left:2px solid var(--line); background:transparent; border-radius:0; padding:4px 0 4px 20px; margin-block:26px; }
.chapter-definition-label { color:var(--muted); font-size:13px; margin-bottom:8px; }
.chapter-definition dt { font-size:18px; }
.chapter-task { padding:16px 20px; border:0; border-left:3px solid var(--accent); border-radius:0 8px 8px 0; }
.chapter-task-label { font-size:15px; }
.chapter-code-panel { margin-block:24px; }
.chapter-code-label { margin:0; padding:12px 20px 4px; font-size:13px; letter-spacing:.01em; }
.chapter-code-panel[data-language]>.chapter-code-label { border-radius:8px 8px 0 0; }
.chapter-opening-code { padding:18px 20px; font-family:"IBM Plex Mono",monospace; font-weight:400; line-height:1.6; }
.book-chapter .chapter-code-panel[data-language="cuda"]>pre { font-family:"IBM Plex Mono",monospace; line-height:1.6; padding:18px 20px; }
.book-chapter .chapter-code-panel>pre { border-radius:0 0 8px 0; }
.book-chapter .hello-operation { font-family:"IBM Plex Mono",monospace; font-weight:400; margin-bottom:0; }
.book-chapter pre,.book-chapter pre code,.book-chapter code { font-family:"IBM Plex Mono",monospace; }
.chapter-browser-note { border-top:1px solid var(--line); padding-top:18px; max-width:72ch; }
@media(max-width:760px) {
 .book-chapter .intro { padding-bottom:12px; margin-bottom:28px; }
 .book-chapter .hello-section,.book-chapter .book-section { margin-block:36px; padding-top:26px; }
 .chapter-code-label { padding-inline:16px; }
 .chapter-opening-code,.book-chapter .chapter-code-panel[data-language="cuda"]>pre { padding-inline:16px; }
}

/* Optional resources form a quiet index after the chapter's application. */
.book-chapter .chapter-resource { max-width:960px; border:0; border-bottom:1px solid var(--line); border-radius:0; background:transparent; padding:0; margin:0; scroll-margin-top:100px; }
.book-chapter .chapter-resource[data-section-kind="recap"] { border-top:1px solid var(--line); margin-top:40px; }
.book-chapter .chapter-resource .section-cue-heading { display:flex; align-items:center; gap:12px; min-width:0; margin:0; font-size:18px; font-weight:600; line-height:1.45; letter-spacing:0; }
.section-cue-icon { display:inline-flex; align-items:center; justify-content:center; flex:0 0 24px; width:24px; height:24px; color:var(--muted); }
.section-cue-icon svg { display:block; width:20px; height:20px; }
.book-chapter .chapter-resource>summary { display:flex; align-items:center; gap:16px; min-height:64px; padding:18px 4px; cursor:pointer; list-style:none; }
.chapter-resource>summary::-webkit-details-marker { display:none; }
.chapter-resource>summary::marker { content:""; }
.chapter-resource>summary .section-cue-heading { flex:1; }
.chapter-resource>summary::after { content:""; flex:0 0 8px; width:8px; height:8px; border-right:1.5px solid var(--muted); border-bottom:1.5px solid var(--muted); transform:rotate(-45deg); margin-right:5px; }
.chapter-resource[open]>summary::after { transform:rotate(45deg); }
.resource-summary-note,.recap-duration { color:var(--muted); font-size:14px; font-weight:400; white-space:nowrap; }
.recap-duration { margin-left:auto; font-variant-numeric:tabular-nums; }
.book-chapter .recap-watch { display:flex; align-items:center; gap:12px; width:100%; min-height:68px; padding:18px 4px; color:var(--accent); text-decoration:none; }
.recap-watch .section-cue-icon { color:var(--accent); }
.resource-arrow { flex:0 0 16px; margin-left:4px; text-align:center; }
.resource-body { padding:0 4px 24px 40px; }
.resource-body>p:first-child { margin-top:0; }
.resource-body>p:last-child { margin-bottom:0; }
.resource-body>p { max-width:68ch; }
.chapter-resource .chapter-reference-list { padding-left:22px; }
.book-chapter .chapter-resource>summary:focus-visible,.book-chapter .recap-watch:focus-visible { outline:2px solid var(--accent); outline-offset:-2px; border-radius:4px; }
@media(hover:hover) {
 .book-chapter .chapter-resource>summary:hover,.book-chapter .recap-watch:hover { background:var(--soft); }
 .recap-watch:hover>span:nth-child(2) { text-decoration:underline; text-underline-offset:4px; }
}
/* Progression is the primary action; resources remain available without dominating. */
.book-chapter :is(.book-pager,.lesson-pagination) { display:grid; grid-template-columns:minmax(0,.8fr) minmax(0,1.2fr); align-items:end; gap:24px; border-top:0; margin-top:32px; padding-block:0 24px; }
.book-chapter :is(.book-pager,.lesson-pagination)>a { border:0; border-radius:0; background:transparent; padding:12px 0; min-height:44px; font-size:16px; }
.book-chapter .lesson-forward { align-items:stretch; gap:16px; }
.book-chapter .lesson-completion label { border:0; border-radius:0; background:transparent; padding:0; font-size:15px; }
.book-chapter .lesson-completion p { margin-top:0; text-align:left; }
.book-chapter :is(.book-pager,.lesson-pagination)>.lesson-forward>a { display:flex; align-items:center; justify-content:space-between; width:100%; min-height:64px; border:1px solid var(--accent); border-radius:8px; padding:16px 20px; background:var(--accent); color:var(--panel); font-size:17px; font-weight:600; line-height:1.5; text-align:left; text-decoration:none; }
@media(max-width:600px) {
 .book-chapter .chapter-resource .section-cue-heading { font-size:17px; }
 .book-chapter .chapter-resource[data-section-kind="recap"] { margin-top:32px; }
 .book-chapter .chapter-resource[data-section-kind="documentation"]>summary { display:grid; grid-template-columns:minmax(0,1fr) 12px; gap:2px 12px; }
 .chapter-resource[data-section-kind="documentation"]>summary::after { grid-column:2; grid-row:1 / 3; }
 .resource-summary-note { grid-column:1; padding-left:36px; font-size:13px; }
 .resource-body { padding:4px 4px 20px; }
 .book-chapter :is(.book-pager,.lesson-pagination) { grid-template-columns:minmax(0,1fr); gap:12px; margin-top:24px; }
 .book-chapter .lesson-forward { gap:12px; }
}
@media(forced-colors:active) { .section-cue-icon { color:CanvasText; } .book-chapter :is(.book-pager,.lesson-pagination)>.lesson-forward>a { border-color:LinkText; color:LinkText; } }

/* Visible relationship diagrams share text sizes, surfaces and responsive flow. */
.concept-figure { container:concept / inline-size; margin:28px 0; padding:20px; border:1px solid var(--line); border-radius:8px; background:var(--soft); font-size:16px; line-height:1.65; }
.concept-figure>figcaption { margin-bottom:20px; color:var(--ink); font-size:18px; font-weight:650; }
.concept-node { min-width:0; padding:14px; border:1px solid var(--line); border-radius:6px; background:var(--panel); }
.concept-node-title { display:block; color:var(--ink); font-size:18px; line-height:1.45; }
.concept-node p { margin:10px 0 0; }
.concept-pair { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:20px; }
.concept-pair>div { min-width:0; }
.concept-pair.concept-alternatives { grid-template-columns:repeat(2,minmax(0,1fr)); gap:12px; }
.concept-connector { margin:12px 0; color:var(--accent); text-align:center; }
.concept-flow-label { margin:24px 0 14px; font-weight:650; }
.concept-flow { display:flex; align-items:stretch; gap:30px; list-style:none; padding:0; margin:0; }
.concept-flow>li { position:relative; flex:1; min-width:0; margin:0; }
.concept-flow .concept-node { height:100%; }
.concept-flow>li:not(:last-child)::after { content:'→'; position:absolute; right:-24px; top:30px; color:var(--accent); font-size:24px; line-height:1; }
.concept-figure>.concept-scope { margin:18px 0 0; color:var(--muted); }
@container concept (max-width:740px) {
 .concept-pair { grid-template-columns:minmax(0,1fr); gap:4px; }
 .concept-flow { flex-direction:column; }
 .concept-flow>li:not(:last-child)::after { content:'↓'; top:auto; right:50%; bottom:-27px; transform:translateX(50%); }
}
