/* How-to tutorials (how-to/*.html): course layout, code blocks, diagrams, animations, quizzes.
   Uses the site's design tokens from style.css only, so light/dark mode and colour themes just work.
   Linked as ?v=N on the how-to pages only (bump it there, not site-wide). Engine: assets/js/howto.js */

/* ---------- Reading progress (thin bar under the sticky header) ---------- */
.hx-progress { position: fixed; top: 56px; left: 0; right: 0; height: 3px; z-index: 9; pointer-events: none; }
.hx-progress span { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--accent), var(--accent-2)); transition: width .1s linear; }

/* ---------- Page head ---------- */
.hx-head { padding: 28px 0 8px; max-width: 860px; }
.hx-eyebrow { display: inline-flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; font-size: .82rem; font-weight: 600; color: var(--accent); text-transform: uppercase; letter-spacing: .04em; margin-bottom: 8px; }
.hx-head h1 { font-size: clamp(1.6rem, 3.2vw, 2.3rem); letter-spacing: -.02em; margin-bottom: 10px; }
.hx-sub { font-size: 1.08rem; color: var(--muted); max-width: 760px; }
.hx-meta { display: flex; flex-wrap: wrap; gap: 8px 16px; margin: 14px 0 0; padding: 0; list-style: none; font-size: .87rem; color: var(--muted); }
.hx-meta li { display: inline-flex; align-items: center; gap: 6px; }
.hx-meta b { color: var(--text); font-weight: 600; }

/* ---------- Two columns: sticky contents + article ---------- */
.hx-layout { display: grid; grid-template-columns: 250px minmax(0, 1fr); gap: 36px; align-items: start; margin-top: 18px; }
.hx-side { position: sticky; top: 76px; max-height: calc(100vh - 92px); overflow: auto; padding-bottom: 12px; scrollbar-width: thin; }
.hx-side summary { display: none; }
.hx-side-title { font-size: .75rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 0 0 8px; }
.hx-chapters { list-style: none; padding: 0; margin: 0 0 20px; counter-reset: ch; }
.hx-chapters li { counter-increment: ch; }
.hx-chapters a { display: grid; grid-template-columns: 22px 1fr; gap: 8px; align-items: start; padding: 6px 8px; border-radius: 8px; color: var(--text); font-size: .88rem; line-height: 1.35; }
.hx-chapters a::before { content: counter(ch); display: grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; background: var(--surface-2); border: 1px solid var(--border); font-size: .72rem; font-weight: 700; color: var(--muted); }
.hx-chapters a:hover { background: var(--surface-2); text-decoration: none; }
.hx-chapters a[aria-current="page"] { background: var(--accent-soft); font-weight: 600; }
.hx-chapters a[aria-current="page"]::before { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.hx-chapters li.done a::before { content: "✓"; background: var(--ok-soft); border-color: var(--ok); color: var(--ok); }
.hx-onpage { list-style: none; margin: 0; padding: 0 0 0 10px; border-left: 2px solid var(--border); }
.hx-onpage a { display: block; padding: 4px 10px; margin-left: -12px; border-left: 2px solid transparent; color: var(--muted); font-size: .84rem; line-height: 1.35; }
.hx-onpage a:hover { color: var(--text); text-decoration: none; }
.hx-onpage a.active { color: var(--accent); border-left-color: var(--accent); font-weight: 600; }
.hx-course-progress { font-size: .8rem; color: var(--muted); margin: -8px 0 16px; }
.hx-course-progress i { display: block; height: 5px; border-radius: 99px; background: var(--surface-2); overflow: hidden; margin-top: 5px; }
.hx-course-progress i span { display: block; height: 100%; background: var(--ok); width: 0; transition: width .3s; }

@media (max-width: 960px) {
  .hx-layout { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .hx-side { position: static; max-height: none; overflow: visible; padding-bottom: 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 18px; }
  .hx-side summary { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 12px 14px; cursor: pointer; font-weight: 600; list-style: none; }
  .hx-side summary::-webkit-details-marker { display: none; }
  .hx-side summary::after { content: "▾"; color: var(--muted); transition: transform .2s; }
  .hx-side[open] summary::after { transform: rotate(180deg); }
  .hx-side-body { padding: 0 14px 14px; }
}

/* ---------- Article typography ---------- */
.hx-article { min-width: 0; max-width: 800px; font-size: 16px; line-height: 1.72; }
.hx-article > section { scroll-margin-top: 76px; }
.hx-article h2 { font-size: 1.5rem; letter-spacing: -.01em; margin: 2.4em 0 .6em; padding-top: .4em; scroll-margin-top: 76px; }
.hx-article h2:first-child { margin-top: .4em; }
.hx-article h3 { font-size: 1.15rem; margin: 1.8em 0 .5em; scroll-margin-top: 76px; }
.hx-article h4 { font-size: 1rem; margin: 1.4em 0 .4em; }
.hx-article p, .hx-article li { color: var(--text); }
.hx-article ul, .hx-article ol { padding-left: 1.3em; margin: 0 0 1em; }
.hx-article li + li { margin-top: .3em; }
.hx-article :not(pre) > code { font-size: .88em; background: var(--surface-2); border: 1px solid var(--border); border-radius: 5px; padding: .08em .35em; overflow-wrap: anywhere; }
.hx-article kbd { font: 600 .82em var(--mono); background: var(--surface); border: 1px solid var(--border); border-bottom-width: 2px; border-radius: 5px; padding: .05em .4em; }
.hx-article hr { border: 0; border-top: 1px solid var(--border); margin: 2.4em 0; }
.hx-anchor { margin-left: .35em; color: var(--muted); opacity: 0; font-weight: 400; text-decoration: none; }
h2:hover > .hx-anchor, h3:hover > .hx-anchor, .hx-anchor:focus { opacity: 1; text-decoration: none; }
.hx-lead { font-size: 1.1rem; color: var(--muted); }

/* ---------- Boxes: learn / why / callouts / takeaways ---------- */
.hx-learn { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin: 8px 0 24px; }
.hx-learn > div { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.hx-learn h2, .hx-learn h3 { font-size: .8rem !important; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 0 0 8px !important; padding: 0 !important; }
.hx-learn ul { margin: 0; padding-left: 1.1em; }
.hx-learn p { margin: 0; }
@media (max-width: 700px) { .hx-learn { grid-template-columns: 1fr; } }

.hx-callout { --c: var(--accent); --cs: var(--accent-soft); position: relative; margin: 1.3em 0; padding: 12px 16px 12px 16px; border: 1px solid var(--border); border-left: 4px solid var(--c); border-radius: 10px; background: var(--surface); }
.hx-callout > :last-child { margin-bottom: 0; }
.hx-callout-title { display: flex; align-items: center; gap: 8px; font-weight: 700; margin: 0 0 6px; color: var(--c); font-size: .92rem; }
.hx-callout-title::before { content: attr(data-icon); display: grid; place-items: center; width: 22px; height: 22px; border-radius: 6px; background: var(--cs); font-size: .8rem; }
.hx-callout.tip { --c: var(--ok); --cs: var(--ok-soft); }
.hx-callout.warn, .hx-callout.mistake { --c: var(--err); --cs: var(--err-soft); }
.hx-callout.why { --c: var(--t3); --cs: var(--t3-soft); }
.hx-callout.simple { --c: var(--t5); --cs: var(--t5-soft); }
.hx-callout.prod { --c: var(--t2); --cs: var(--t2-soft); }
.hx-callout.analogy { --c: var(--t4); --cs: var(--t4-soft); }

.hx-mistakes { display: grid; gap: 10px; margin: 1em 0; }
.hx-mistakes details { border: 1px solid var(--border); border-radius: 10px; background: var(--surface); }
.hx-mistakes summary { padding: 10px 14px; cursor: pointer; font-weight: 600; display: flex; gap: 10px; align-items: baseline; }
.hx-mistakes summary::before { content: "✗"; color: var(--err); font-weight: 800; }
.hx-mistakes details[open] summary { border-bottom: 1px solid var(--border); }
.hx-mistakes details > :not(summary) { margin: 10px 14px; }
.hx-mistakes .fix { color: var(--ok); font-weight: 700; }

.hx-takeaways { background: linear-gradient(135deg, var(--accent-soft), var(--surface)); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; margin: 1.5em 0; }
.hx-takeaways h2, .hx-takeaways h3 { margin: 0 0 8px !important; padding: 0 !important; font-size: 1.05rem; }
.hx-takeaways ul { margin: 0; list-style: none; padding: 0; }
.hx-takeaways li { padding-left: 1.6em; position: relative; }
.hx-takeaways li::before { content: "✓"; position: absolute; left: 0; color: var(--ok); font-weight: 800; }

details.hx-more { border: 1px dashed var(--border); border-radius: 10px; margin: 1em 0; background: var(--surface); }
details.hx-more > summary { padding: 9px 14px; cursor: pointer; font-weight: 600; color: var(--accent); }
details.hx-more[open] > summary { border-bottom: 1px dashed var(--border); }
details.hx-more > :not(summary) { margin-left: 14px; margin-right: 14px; }
details.hx-more > :nth-child(2) { margin-top: 10px; }

/* Numbered walkthrough steps */
ol.hx-walk { list-style: none; counter-reset: w; padding: 0; margin: 1em 0; }
ol.hx-walk > li { counter-increment: w; position: relative; padding-left: 44px; margin: 0 0 14px; }
ol.hx-walk > li::before { content: counter(w); position: absolute; left: 0; top: 0; width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; background: var(--accent); color: var(--on-accent); font-weight: 700; font-size: .85rem; }
ol.hx-walk > li::after { content: ""; position: absolute; left: 14px; top: 34px; bottom: -12px; width: 2px; background: var(--border); }
ol.hx-walk > li:last-child::after { display: none; }

/* Tables */
.hx-table-wrap { overflow-x: auto; margin: 1em 0; border: 1px solid var(--border); border-radius: 10px; }
table.hx-table { width: 100%; border-collapse: collapse; font-size: .9rem; line-height: 1.5; }
.hx-table th, .hx-table td { text-align: left; padding: 8px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
.hx-table th { background: var(--surface-2); font-weight: 600; white-space: nowrap; }
.hx-table tr:last-child td { border-bottom: 0; }
.hx-table td code { white-space: nowrap; }

.hx-tag { display: inline-block; font-size: .72rem; font-weight: 700; padding: .1em .5em; border-radius: 99px; background: var(--surface-2); border: 1px solid var(--border); color: var(--muted); vertical-align: middle; white-space: nowrap; }
.hx-tag.mvp { background: var(--ok-soft); border-color: var(--ok); color: var(--ok); }
.hx-tag.adv { background: var(--t3-soft); border-color: var(--t3); color: var(--t3); }
.hx-tag.get { background: var(--t2-soft); color: var(--t2); border-color: var(--t2); }
.hx-tag.post { background: var(--ok-soft); color: var(--ok); border-color: var(--ok); }
.hx-tag.delete { background: var(--err-soft); color: var(--err); border-color: var(--err); }
.hx-tag.put { background: var(--t5-soft); color: var(--t5); border-color: var(--t5); }

/* ---------- Code blocks ---------- */
figure.code { margin: 1.1em 0 1.3em; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2); overflow: hidden; position: relative; }
.code-head { display: flex; align-items: center; gap: 8px; padding: 6px 8px 6px 12px; border-bottom: 1px solid var(--border); background: var(--surface); font-size: .78rem; color: var(--muted); min-height: 36px; }
.code-head .code-file { font: 600 .8rem var(--mono); color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; direction: rtl; text-align: left; }
.code-head .code-file bdi { direction: ltr; unicode-bidi: isolate; }
.code-head .code-lang { flex: none; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; font-size: .68rem; padding: .15em .55em; border-radius: 5px; background: var(--surface-2); border: 1px solid var(--border); }
.code-head .code-kind { flex: none; font-weight: 700; font-size: .72rem; }
.code-head .code-note { font-size: .74rem; font-style: italic; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.code-head .spacer { flex: 1; }
.code-head .btn { height: 26px; padding: 0 9px; font-size: .75rem; border-radius: 7px; }
figure.code pre { margin: 0; padding: 12px 14px; overflow-x: auto; font: 13px/1.6 var(--mono); tab-size: 4; white-space: pre; color: var(--text); }
figure.code pre code { font: inherit; background: none; border: 0; padding: 0; }
figure.code.cmd pre code .p { color: var(--muted); user-select: none; }
figure.code.out { background: var(--surface); border-style: dashed; }
figure.code.out .code-head { background: var(--surface-2); }
figure.code.out pre { color: var(--muted); }
figure.code.collapsed pre { max-height: 360px; overflow: hidden; }
figure.code.collapsed::after { content: ""; position: absolute; left: 0; right: 0; bottom: 42px; height: 70px; background: linear-gradient(transparent, var(--surface-2)); pointer-events: none; }
.code-more { display: block; width: 100%; border: 0; border-top: 1px solid var(--border); background: var(--surface); color: var(--accent); font: 600 .82rem var(--sans); padding: 10px; cursor: pointer; }
.code-more:hover { background: var(--surface-2); }
figure.code > figcaption { padding: 8px 12px; border-top: 1px solid var(--border); font-size: .85rem; color: var(--muted); background: var(--surface); }
/* Token colours (highlighter in howto.js) */
.tk-com { color: var(--muted); font-style: italic; }
.tk-str { color: var(--ok); }
.tk-kw { color: var(--t3); font-weight: 600; }
.tk-num { color: var(--t5); }
.tk-ann { color: var(--t4); }
.tk-type { color: var(--t2); }
.tk-tag { color: var(--t2); font-weight: 600; }
.tk-attr { color: var(--t5); }
.tk-key { color: var(--t3); }
.tk-var { color: var(--t4); }
.tk-fn { color: var(--t1); }
.tk-add { background: var(--ok-soft); display: inline-block; width: 100%; }

/* ---------- Tabs ---------- */
.hx-tabs { margin: 1.1em 0 1.3em; }
.hx-tablist { display: flex; gap: 4px; overflow-x: auto; border-bottom: 1px solid var(--border); scrollbar-width: thin; }
.hx-tablist button { flex: none; border: 1px solid transparent; border-bottom: 0; background: none; padding: 8px 14px; font: 600 .86rem var(--sans); color: var(--muted); cursor: pointer; border-radius: 8px 8px 0 0; margin-bottom: -1px; }
.hx-tablist button[aria-selected="true"] { color: var(--accent); background: var(--surface); border-color: var(--border); border-bottom: 1px solid var(--surface); }
.hx-tabpanel { padding-top: 4px; }
.hx-tabpanel > figure.code:first-child { margin-top: .6em; }
.js .hx-tabs > .hx-tabpanel[data-label] > .hx-tablabel { display: none; }
.hx-tablabel { font-weight: 700; margin: 1em 0 .3em; }

/* Before / after */
.hx-compare { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 14px; margin: 1.2em 0; }
.hx-compare > div { border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px 4px; background: var(--surface); min-width: 0; }
.hx-compare > div > h4 { margin: 0 0 6px; display: flex; gap: 8px; align-items: center; font-size: .95rem; }
.hx-compare .bad { border-top: 4px solid var(--err); }
.hx-compare .good { border-top: 4px solid var(--ok); }
.hx-compare .bad > h4::before { content: "✗"; color: var(--err); }
.hx-compare .good > h4::before { content: "✓"; color: var(--ok); }
.hx-compare figure.code { margin: .6em 0 .9em; }
@media (max-width: 760px) { .hx-compare { grid-template-columns: minmax(0, 1fr); } }

/* ---------- Diagrams ---------- */
.hx-figure { margin: 1.4em 0; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); overflow: hidden; }
.hx-figure > figcaption { padding: 10px 14px; font-size: .86rem; color: var(--muted); border-top: 1px solid var(--border); }
.hx-figure > figcaption b { color: var(--text); }
.hx-canvas { padding: 10px; overflow-x: auto; }
.hx-canvas svg { display: block; width: 100%; height: auto; min-width: 520px; max-height: 70vh; font-family: var(--sans); }
.hx-figure.narrow .hx-canvas svg { min-width: 0; }
.hx-scroll-hint { display: none; font-size: .75rem; color: var(--muted); padding: 0 12px 6px; }
@media (max-width: 600px) { .hx-scroll-hint { display: block; } }

svg .dg-group rect { fill: var(--surface-2); stroke: var(--border); stroke-dasharray: 6 5; }
svg .dg-group text { fill: var(--muted); font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }
svg .dg-edge { stroke: var(--border); stroke-width: 2.2; fill: none; transition: stroke .3s, opacity .3s; }
svg .dg-edge.dashed { stroke-dasharray: 6 5; }
svg .dg-edge.hot { stroke: var(--accent); stroke-width: 3; }
svg .dg-arrow { fill: var(--border); transition: fill .3s; }
svg .dg-edge-label { fill: var(--muted); font-size: 11.5px; font-weight: 600; paint-order: stroke; stroke: var(--surface); stroke-width: 4px; stroke-linejoin: round; }
svg .dg-node { cursor: default; transition: opacity .35s; }
svg .dg-node rect.box { fill: var(--surface); stroke: var(--tint, var(--border)); stroke-width: 2; transition: stroke-width .25s, filter .25s; }
svg .dg-node rect.band { fill: var(--tint-soft, var(--surface-2)); }
svg .dg-node .t { fill: var(--text); font-weight: 700; font-size: 14px; }
svg .dg-node .s { fill: var(--muted); font-size: 11.5px; }
svg .dg-node .i { font-size: 18px; }
svg .dg-node .row { fill: var(--text); font: 11.5px var(--mono); white-space: pre; }
svg .dg-node .row.pk { font-weight: 700; }
svg .dg-node .row.fk { fill: var(--tint); }
svg .dg-node line.sep { stroke: var(--border); }
svg .dg-node.k-client { --tint: var(--t2); --tint-soft: var(--t2-soft); }
svg .dg-node.k-app { --tint: var(--t1); --tint-soft: var(--t1-soft); }
svg .dg-node.k-data { --tint: var(--t3); --tint-soft: var(--t3-soft); }
svg .dg-node.k-cache { --tint: var(--t4); --tint-soft: var(--t4-soft); }
svg .dg-node.k-ext { --tint: var(--t5); --tint-soft: var(--t5-soft); }
svg .dg-node.k-queue { --tint: var(--t6); --tint-soft: var(--t6-soft); }
svg .dg-node.k-muted { --tint: var(--border); --tint-soft: var(--surface-2); }
svg .dg-node.on rect.box { stroke-width: 3.5; filter: drop-shadow(0 0 6px var(--tint)); }
svg .dg-node.dim, svg .dg-edge.dim, svg .dg-edge-label.dim { opacity: .28; }
svg .dg-node.gone, svg .dg-edge.gone, svg .dg-edge-label.gone, svg .dg-arrow.gone { opacity: 0; pointer-events: none; }
svg .dg-node.clickable { cursor: pointer; }
svg .dg-node.clickable:hover rect.box, svg .dg-node.clickable:focus rect.box { stroke-width: 3.5; }
svg .dg-node:focus { outline: none; }
svg .dg-node.picked rect.box { stroke-width: 3.5; stroke: var(--accent); }
svg .dg-badge rect { fill: var(--accent); }
svg .dg-badge text { fill: var(--on-accent); font-size: 11px; font-weight: 700; }
svg .dg-packet circle { fill: var(--accent); stroke: var(--surface); stroke-width: 2.5; }
svg .dg-packet rect { fill: var(--text); }
svg .dg-packet text { fill: var(--bg); font: 600 11px var(--mono); }
svg .dg-packet.k-ok circle { fill: var(--ok); }
svg .dg-packet.k-err circle { fill: var(--err); }
svg .dg-packet.k-alt circle { fill: var(--accent-2); }
svg .dg-note { fill: var(--muted); font-size: 12px; }

/* Step player */
.hx-player { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 10px 12px; border-top: 1px solid var(--border); background: var(--surface-2); }
.hx-player .btn { height: 32px; }
.hx-player .btn.icon { width: 34px; }
.hx-player .count { font-size: .8rem; color: var(--muted); font-variant-numeric: tabular-nums; margin-left: auto; }
.hx-caption { padding: 12px 14px; min-height: 4.4em; font-size: .93rem; line-height: 1.6; border-top: 1px solid var(--border); }
.hx-caption b:first-child { color: var(--accent); }
.hx-caption code { font-size: .86em; background: var(--surface-2); border: 1px solid var(--border); border-radius: 4px; padding: 0 .3em; }
.js .hx-figure ol.hx-steps { display: none; }
ol.hx-steps { margin: 0; padding: 12px 14px 12px 34px; font-size: .92rem; border-top: 1px solid var(--border); }
.hx-dots { display: flex; gap: 5px; flex-wrap: wrap; }
.hx-dots button { width: 9px; height: 9px; border-radius: 50%; border: 0; padding: 0; background: var(--border); cursor: pointer; }
.hx-dots button.on { background: var(--accent); }

/* Click-to-explain panels */
.hx-info { border-top: 1px solid var(--border); padding: 12px 14px; font-size: .93rem; min-height: 5em; }
.hx-info h4 { margin: 0 0 4px; font-size: 1rem; }
.hx-info p { margin: 0 0 .6em; }
.hx-info .hint { color: var(--muted); }
.js .hx-figure dl.hx-defs { display: none; }
dl.hx-defs { margin: 0; padding: 12px 14px; border-top: 1px solid var(--border); font-size: .92rem; }
dl.hx-defs dt { font-weight: 700; margin-top: .6em; }
dl.hx-defs dd { margin: 0; }

/* ---------- Demos (shared bits) ---------- */
.hx-demo { margin: 1.4em 0; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); overflow: hidden; }
.hx-demo-head { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--border); background: var(--surface-2); }
.hx-demo-head b { font-size: .95rem; }
.hx-demo-head .hx-tag { margin-left: auto; }
.hx-demo-body { padding: 14px; }
.hx-demo-body > :last-child { margin-bottom: 0; }
.hx-demo label { font-size: .82rem; }
.hx-demo .row { gap: 10px; }
.hx-demo .out { font: 12.5px/1.55 var(--mono); background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; white-space: pre-wrap; overflow-wrap: anywhere; margin: 10px 0 0; max-height: 360px; overflow: auto; }
.hx-demo .ok { color: var(--ok); font-weight: 700; }
.hx-demo .bad { color: var(--err); font-weight: 700; }
.hx-status { display: inline-block; font: 700 .8rem var(--mono); padding: .15em .55em; border-radius: 6px; background: var(--surface-2); border: 1px solid var(--border); }
.hx-status.s2 { color: var(--ok); border-color: var(--ok); background: var(--ok-soft); }
.hx-status.s4, .hx-status.s5 { color: var(--err); border-color: var(--err); background: var(--err-soft); }

/* ---------- Knowledge check ---------- */
.hx-quiz { margin: 1.2em 0; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); padding: 14px 16px; }
.hx-quiz > p:first-child, .hx-quiz-q { font-weight: 600; margin-bottom: 10px; }
.hx-quiz ol { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.hx-quiz li { margin: 0 !important; }
.hx-quiz button.opt { width: 100%; text-align: left; border: 1px solid var(--border); background: var(--bg); color: var(--text); border-radius: 9px; padding: 9px 12px; font: 14.5px/1.45 var(--sans); cursor: pointer; display: flex; gap: 10px; }
.hx-quiz button.opt::before { content: attr(data-letter); flex: none; width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-2); border: 1px solid var(--border); font-size: .75rem; font-weight: 700; }
.hx-quiz button.opt:hover:not(:disabled) { border-color: var(--accent); }
.hx-quiz button.opt.right { border-color: var(--ok); background: var(--ok-soft); }
.hx-quiz button.opt.right::before { content: "✓"; background: var(--ok); color: var(--on-accent); border-color: var(--ok); }
.hx-quiz button.opt.wrong { border-color: var(--err); background: var(--err-soft); }
.hx-quiz button.opt.wrong::before { content: "✗"; background: var(--err); color: #fff; border-color: var(--err); }
.hx-quiz button.opt:disabled { cursor: default; }
.hx-quiz .why { margin: 10px 0 0; padding: 10px 12px; border-radius: 8px; background: var(--surface-2); font-size: .92rem; }
.js .hx-quiz .why:not(.shown) { display: none; }
.hx-quiz .again { margin-top: 8px; }
.hx-score { font-weight: 600; color: var(--muted); font-size: .9rem; }

/* Exercise */
.hx-exercise { border: 2px dashed var(--accent); border-radius: var(--radius); padding: 14px 16px; margin: 1.4em 0; background: var(--accent-soft); }
.hx-exercise > h3:first-child, .hx-exercise > h4:first-child { margin-top: 0; }

/* ---------- Chapter end ---------- */
.hx-done { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; margin: 2.4em 0 1em; padding: 16px 18px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.hx-done p { margin: 0; color: var(--muted); }
.hx-done .btn.is-done { background: var(--ok-soft); border-color: var(--ok); color: var(--ok); }
.hx-pager { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 1.4em 0 0; }
.hx-pager a { display: block; border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 16px; background: var(--surface); color: var(--text); box-shadow: var(--shadow); transition: border-color .15s, transform .15s; }
.hx-pager a:hover { border-color: var(--accent); text-decoration: none; transform: translateY(-1px); }
.hx-pager small { display: block; color: var(--muted); font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; font-weight: 700; }
.hx-pager b { display: block; margin-top: 2px; }
.hx-pager .next { text-align: right; grid-column: 2; }
@media (max-width: 600px) { .hx-pager { grid-template-columns: 1fr; } .hx-pager .next { grid-column: 1; } }

.hx-top { position: fixed; right: 18px; bottom: 18px; z-index: 8; width: 42px; height: 42px; border-radius: 50%; border: 1px solid var(--border); background: var(--surface); color: var(--text); box-shadow: var(--shadow-hover); font-size: 18px; cursor: pointer; opacity: 0; transform: translateY(10px); transition: opacity .2s, transform .2s; pointer-events: none; }
.hx-top.show { opacity: 1; transform: none; pointer-events: auto; }

/* ---------- Landing page ---------- */
.hx-hero { padding: 36px 0 10px; max-width: 820px; }
.hx-hero h1 { font-size: clamp(1.8rem, 4vw, 2.5rem); letter-spacing: -.02em; }
.hx-hero p { color: var(--muted); font-size: 1.06rem; }
.hx-filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin: 18px 0 8px; }
.hx-filters input { max-width: 340px; }
.hx-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.hx-chip { border: 1px solid var(--border); background: var(--surface); color: var(--text); border-radius: 99px; padding: 6px 13px; font: 500 .85rem var(--sans); cursor: pointer; }
.hx-chip[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.hx-chip .n { color: inherit; opacity: .7; margin-left: 4px; font-size: .78rem; }
.hx-featured { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 0; margin: 20px 0 8px; border: 1px solid var(--border); border-radius: 16px; overflow: hidden; background: var(--surface); box-shadow: var(--shadow); }
.hx-featured-text { padding: 24px 26px; }
.hx-featured-text h2 { font-size: 1.5rem; margin: 6px 0 8px; }
.hx-featured-text h2 a { color: var(--text); }
.hx-featured-text p { color: var(--muted); }
.hx-featured-art { background: linear-gradient(135deg, var(--accent-soft), var(--t3-soft)); display: grid; place-items: center; padding: 18px; border-left: 1px solid var(--border); }
.hx-featured-art svg { width: 100%; max-width: 380px; height: auto; }
.hx-chapter-list { columns: 2; column-gap: 24px; padding-left: 1.2em; margin: 12px 0 16px; font-size: .9rem; }
.hx-chapter-list li { break-inside: avoid; }
@media (max-width: 800px) { .hx-featured { grid-template-columns: minmax(0, 1fr); } .hx-featured-art { border-left: 0; border-top: 1px solid var(--border); } .hx-chapter-list { columns: 1; } }
.hx-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; margin-top: 14px; }
.hx-card { display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); padding: 16px; color: var(--text); box-shadow: var(--shadow); transition: border-color .15s, transform .15s, box-shadow .15s; }
.hx-card:hover { border-color: var(--accent); transform: translateY(-2px); box-shadow: var(--shadow-hover); text-decoration: none; }
.hx-card h3 { font-size: 1.05rem; margin: 8px 0 6px; }
.hx-card p { color: var(--muted); font-size: .9rem; margin: 0 0 12px; flex: 1; }
.hx-card-meta { display: flex; flex-wrap: wrap; gap: 6px 12px; font-size: .8rem; color: var(--muted); }
.hx-card-meta b { color: var(--text); font-weight: 600; }
.hx-card .hx-tags { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 10px; }
.hx-card.soon { border-style: dashed; box-shadow: none; }
.hx-card.soon:hover { transform: none; border-color: var(--border); }
.hx-level { font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--accent); }
.hx-empty { color: var(--muted); padding: 20px 0; }
.hx-card-progress { height: 5px; border-radius: 99px; background: var(--surface-2); overflow: hidden; margin-top: 10px; }
.hx-card-progress span { display: block; height: 100%; background: var(--ok); }

@media (prefers-reduced-motion: reduce) {
  .hx-progress span, .hx-top, svg .dg-node, svg .dg-edge, .hx-card, .hx-pager a { transition: none; }
}
@media print {
  .hx-side, .hx-progress, .hx-top, .hx-player, .promo, .site-header, .site-footer { display: none !important; }
  .hx-layout { display: block; }
  .js .hx-figure ol.hx-steps, .js .hx-figure dl.hx-defs, .js .hx-quiz .why:not(.shown) { display: block; }
  figure.code.collapsed pre { max-height: none; }
}

/* ---------- Chapter 1: interactive "anatomy of the app" mock ---------- */
.c1-anatomy { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); }
.c1-mock { padding: 14px; background: var(--bg); border-right: 1px solid var(--border); font-size: 13px; line-height: 1.4; min-width: 0; }
.c1-bar { display: flex; align-items: center; gap: 10px; padding-bottom: 10px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.c1-logo { font-weight: 800; color: var(--accent); font-size: 16px; }
.c1-search { flex: 1; min-width: 90px; border: 1px solid var(--border); border-radius: 99px; padding: 4px 10px; color: var(--muted); background: var(--surface); }
.c1-nav { display: flex; gap: 10px; color: var(--text); }
.c1-badge { background: var(--accent); color: var(--on-accent); border-radius: 99px; padding: 0 6px; font-size: 11px; margin-left: 3px; }
.c1-cols { display: grid; grid-template-columns: minmax(0, 1fr) 130px; gap: 10px; margin-top: 10px; }
.c1-card { position: relative; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 9px 10px; margin-bottom: 8px; }
.c1-compose { color: var(--muted); }
.c1-compose .c1-row { display: flex; justify-content: space-between; align-items: center; margin-top: 18px; }
.c1-pill { background: var(--accent); color: var(--on-accent); border-radius: 99px; padding: 2px 10px; font-weight: 700; font-size: 12px; }
.c1-who b { display: block; margin-bottom: 4px; }
.c1-person { display: flex; justify-content: space-between; align-items: center; gap: 4px; margin-top: 6px; font-size: 12px; }
.c1-person span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.c1-actions { display: flex; gap: 14px; color: var(--muted); margin-top: 6px; }
.c1-like { color: var(--t4); }
.c1-hot { position: absolute; z-index: 2; width: 24px; height: 24px; border-radius: 50%; border: 2px solid var(--surface); background: var(--accent-2); color: #fff; font: 700 12px var(--sans); cursor: pointer; display: grid; place-items: center; padding: 0; box-shadow: 0 0 0 0 var(--accent-2); animation: c1-pulse 2.4s infinite; }
.c1-hot:hover, .c1-hot[aria-pressed="true"] { background: var(--accent); animation: none; transform: scale(1.12); }
@keyframes c1-pulse { 0% { box-shadow: 0 0 0 0 rgba(124, 108, 240, .5); } 70% { box-shadow: 0 0 0 8px rgba(124, 108, 240, 0); } 100% { box-shadow: 0 0 0 0 rgba(124, 108, 240, 0); } }
@media (prefers-reduced-motion: reduce) { .c1-hot { animation: none; } }
.c1-panel { padding: 16px; font-size: .93rem; min-width: 0; }
.c1-panel h4 { margin: 4px 0 6px; font-size: 1.05rem; }
.c1-panel p { margin: 0 0 .7em; }
.c1-panel dl { margin: 0; font-size: .86rem; }
.c1-panel dt { font-weight: 700; color: var(--muted); text-transform: uppercase; font-size: .7rem; letter-spacing: .05em; margin-top: 8px; }
.c1-panel dd { margin: 2px 0 0; overflow-wrap: anywhere; }
@media (max-width: 760px) { .c1-anatomy { grid-template-columns: minmax(0, 1fr); } .c1-mock { border-right: 0; border-bottom: 1px solid var(--border); } .c1-cols { grid-template-columns: minmax(0, 1fr); } }

.c1-board { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin: 1.2em 0; }
.c1-board > div { border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; background: var(--surface); }
.c1-board h3 { margin: 0 0 8px !important; font-size: 1rem; display: flex; gap: 8px; align-items: center; }
.c1-board ul { margin: 0; padding-left: 1.1em; font-size: .93rem; }
@media (max-width: 640px) { .c1-board { grid-template-columns: 1fr; } }
.hx-shot { margin: 1.4em 0; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: var(--surface); box-shadow: var(--shadow); }
.hx-shot img { display: block; width: 100%; height: auto; }
.hx-shot figcaption { padding: 10px 14px; font-size: .86rem; color: var(--muted); border-top: 1px solid var(--border); }
.hx-course-map { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; margin: 1em 0; padding: 0; list-style: none; counter-reset: cm; }
.hx-course-map li { counter-increment: cm; margin: 0 !important; }
.hx-course-map a { display: block; height: 100%; border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; background: var(--surface); color: var(--text); font-size: .9rem; line-height: 1.45; }
.hx-course-map a:hover { border-color: var(--accent); text-decoration: none; }
.hx-course-map a::before { content: "Chapter " counter(cm); display: block; font-size: .72rem; font-weight: 700; color: var(--accent); text-transform: uppercase; letter-spacing: .05em; }
.hx-course-map b { display: block; margin: 2px 0 4px; }
.hx-course-map span { color: var(--muted); font-size: .84rem; }

/* style.css styles text inputs but not type="search" */
.hx-filters input[type="search"] { flex: 1 1 240px; min-width: 0; border: 1px solid var(--border); border-radius: 99px; background: var(--surface); color: var(--text); padding: 9px 16px; font: 14px var(--sans); }
.hx-filters input[type="search"]:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
