/* =====================================================================
   Learn pane (knowledge hub) and the interactive diagrams in diagram.js.
   Uses the shared tokens in variables.css, so both themes work.
   ===================================================================== */
.hero-learn .hh-title { max-width: 22ch; }
.hero-sf .o1 { background: #0891b2; } .hero-sf .o2 { background: #38bdf8; } .hero-sf .o3 { background: #2563eb; }
.hero-learn .o1 { background: #2563eb; } .hero-learn .o2 { background: #0891b2; } .hero-learn .o3 { background: #4f46e5; }
.hub-hero[hidden], .hub[hidden] { display: none; }
.hh-back { display: inline-block; margin-bottom: 14px; font-size: 13.5px; font-weight: 700; color: #ffd700; }
.hh-back:hover { color: #fff; text-decoration: underline; }
.digest-tile { background: linear-gradient(160deg, color-mix(in srgb, var(--c) 8%, var(--surface)), var(--surface)); }
.hub-hero[hidden] + .hub-body { padding-top: calc(var(--nav-h) + 28px); }

/* --- tiles: every tile is one link --- */
.concept-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 18px; }
.concept-tile, .cat-tile {
  position: relative; display: flex; flex-direction: column; gap: 10px; overflow: hidden;
  padding: 22px 22px 18px; border-radius: var(--radius-lg); color: var(--text);
  background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-sm);
  transition: transform var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease);
}
.concept-tile::before, .cat-tile::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 4px; background: linear-gradient(90deg, var(--c), color-mix(in srgb, var(--c) 35%, transparent)); }
.concept-tile:hover, .cat-tile:hover, .concept-tile:focus-visible, .cat-tile:focus-visible {
  transform: translateY(-4px); border-color: color-mix(in srgb, var(--c) 50%, var(--border));
  box-shadow: 0 18px 38px color-mix(in srgb, var(--c) 22%, transparent);
}
.concept-tile:focus-visible, .cat-tile:focus-visible, .tool-card:focus-visible, .spot-card:focus-visible, .pick-card:focus-visible { outline: 3px solid color-mix(in srgb, var(--c, #2563eb) 60%, transparent); outline-offset: 2px; }
.concept-tile h4 { font-size: 1.08rem; font-weight: 700; letter-spacing: -0.01em; line-height: 1.3; }
.concept-tile p { font-size: 14px; line-height: 1.55; color: var(--text-muted); }
.ct-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.ct-cat { display: inline-flex; align-items: center; gap: 6px; font-size: 11.5px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; color: color-mix(in srgb, var(--c) 80%, var(--text)); }
.ct-cat svg { width: 15px; height: 15px; }
.lv { padding: 3px 9px; border-radius: 999px; font-size: 11px; font-weight: 700; background: var(--surface-2); color: var(--text-muted); }
.lv-foundation { background: color-mix(in srgb, #16a34a 14%, transparent); color: color-mix(in srgb, #16a34a 75%, var(--text)); }
.lv-intermediate { background: color-mix(in srgb, #2563eb 14%, transparent); color: color-mix(in srgb, #2563eb 75%, var(--text)); }
.lv-advanced { background: color-mix(in srgb, #7c3aed 14%, transparent); color: color-mix(in srgb, #7c3aed 75%, var(--text)); }
.ct-foot { margin-top: auto; padding-top: 6px; display: flex; justify-content: space-between; align-items: center; font-size: 12.5px; font-weight: 600; color: var(--text-faint); }
.ct-foot i, .cat-n i { font-style: normal; font-size: 18px; color: var(--c); transition: transform var(--dur-fast) var(--ease); }
.concept-tile:hover .ct-foot i, .cat-tile:hover .cat-n i { transform: translateX(4px); }

.cat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 18px; }
.cat-ico { display: inline-grid; place-items: center; width: 46px; height: 46px; border-radius: 14px; color: #fff; background: linear-gradient(145deg, var(--c), color-mix(in srgb, var(--c) 55%, #022a5c)); box-shadow: 0 8px 18px color-mix(in srgb, var(--c) 30%, transparent); }
.cat-ico svg { width: 24px; height: 24px; }
.cat-ico.lg { width: 60px; height: 60px; border-radius: 18px; flex-shrink: 0; }
.cat-ico.lg svg { width: 30px; height: 30px; }
.cat-tile h3 { font-size: 1.15rem; font-weight: 700; letter-spacing: -0.01em; }
.cat-tile p { font-size: 14px; line-height: 1.55; color: var(--text-muted); }
.cat-tile ul { display: flex; flex-wrap: wrap; gap: 6px; }
.cat-tile li { padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; background: color-mix(in srgb, var(--c) 10%, transparent); color: color-mix(in srgb, var(--c) 75%, var(--text)); }
.cat-tile li.more { background: var(--surface-2); color: var(--text-faint); }
.cat-n { margin-top: auto; display: flex; align-items: center; gap: 6px; font-size: 13.5px; color: var(--text-muted); }
.cat-n b { font-family: var(--font-display); font-size: 1.5rem; color: var(--c); }
.cat-n i { margin-left: auto; }

.learn-how { padding: 28px 30px; }
.learn-how h3 { font-size: 1.15rem; font-weight: 700; }
.learn-how ol { margin-top: 14px; display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 10px 28px; counter-reset: lh; }
.learn-how li { position: relative; padding-left: 34px; font-size: 14px; line-height: 1.55; color: var(--text-muted); counter-increment: lh; }
.learn-how li::before { content: counter(lh); position: absolute; left: 0; top: 0; width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; font-size: 12px; font-weight: 700; color: #fff; background: var(--accent-2); }
.learn-how b { color: var(--text); }

/* --- breadcrumbs, category header --- */
.crumbs { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 22px; font-size: 13.5px; color: var(--text-faint); }
.crumbs a { font-weight: 600; color: var(--accent-2); }
.crumbs a:hover { text-decoration: underline; }
.crumbs [aria-current] { color: var(--text-muted); }
.cat-head { display: flex; gap: 18px; align-items: center; margin-bottom: 28px; }
.cat-head h2 { font-size: clamp(1.6rem, 3vw, 2.2rem); font-weight: 700; letter-spacing: -0.02em; }
.cat-head p { margin-top: 6px; max-width: 70ch; color: var(--text-muted); line-height: 1.55; }
.other-cats { margin-top: 48px; }
.cat-chips { display: flex; flex-wrap: wrap; gap: 10px; }
.cat-chips a { display: inline-flex; align-items: center; gap: 8px; padding: 9px 15px; border-radius: 999px; font-size: 13.5px; font-weight: 600; color: var(--text); background: var(--surface); border: 1px solid var(--border); transition: all var(--dur-fast) var(--ease); }
.cat-chips a svg { width: 16px; height: 16px; color: var(--c); }
.cat-chips a:hover { border-color: var(--c); background: color-mix(in srgb, var(--c) 10%, var(--surface)); transform: translateY(-2px); }

/* --- concept page --- */
.concept { max-width: 980px; }
.concept-head { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.concept-head h2 { flex-basis: 100%; margin-top: 4px; font-size: clamp(1.8rem, 4vw, 2.7rem); font-weight: 700; letter-spacing: -0.025em; line-height: 1.12; }
.concept-head .lede { flex-basis: 100%; max-width: 68ch; font-size: 1.12rem; line-height: 1.6; color: var(--text-muted); }
.c-sec { margin-top: 36px; }
.c-sec > h3 { font-size: 1.25rem; font-weight: 700; letter-spacing: -0.01em; margin-bottom: 14px; }
.scenario { padding: 24px 26px; border-radius: var(--radius-lg); background: color-mix(in srgb, var(--c) 7%, var(--surface)); border: 1px solid color-mix(in srgb, var(--c) 25%, var(--border)); border-left: 5px solid var(--c); }
.scenario h3 { margin-bottom: 10px; }
.scenario .tag { display: inline-block; padding: 4px 12px; border-radius: 999px; font-size: 12px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; background: var(--c); color: #fff; }
.scenario p { font-size: 15.5px; line-height: 1.65; }
.needs-h { margin-top: 14px; font-weight: 700; }
.needs { margin-top: 8px; display: grid; gap: 8px; }
.needs li { position: relative; padding-left: 30px; font-size: 15px; line-height: 1.5; }
.needs li::before { content: "✓"; position: absolute; left: 0; top: 0; width: 21px; height: 21px; border-radius: 6px; display: grid; place-items: center; font-size: 12px; font-weight: 700; color: #fff; background: #16a34a; }
.scenario .q { margin-top: 14px; font-weight: 700; color: color-mix(in srgb, var(--c) 80%, var(--text)); }

.steps { display: grid; gap: 12px; counter-reset: st; }
.steps li { position: relative; padding: 16px 18px 16px 62px; border-radius: var(--radius-md); background: var(--surface); border: 1px solid var(--border); counter-increment: st; }
.steps li::before { content: counter(st); position: absolute; left: 16px; top: 15px; width: 32px; height: 32px; border-radius: 10px; display: grid; place-items: center; font: 700 15px var(--font-display); color: #fff; background: linear-gradient(145deg, var(--c), color-mix(in srgb, var(--c) 60%, #022a5c)); }
.steps b { font-size: 15.5px; }
.steps p { margin-top: 4px; font-size: 14.5px; line-height: 1.6; color: var(--text-muted); }

.trade { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
.tcard { padding: 18px 20px; border-radius: var(--radius-md); background: var(--surface); border: 1px solid var(--border); border-top: 4px solid var(--k); }
.tcard.good { --k: #16a34a; } .tcard.bad { --k: #dc2626; } .tcard.use { --k: #2563eb; } .tcard.avoid { --k: #64748b; }
.tcard h4 { font-size: 14px; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; color: color-mix(in srgb, var(--k) 80%, var(--text)); }
.tcard ul { margin-top: 10px; display: grid; gap: 7px; }
.tcard li { position: relative; padding-left: 18px; font-size: 14.5px; line-height: 1.5; }
.tcard li::before { content: ""; position: absolute; left: 2px; top: 8px; width: 7px; height: 7px; border-radius: 50%; background: var(--k); }

.code-card { border-radius: var(--radius-md); overflow: hidden; border: 1px solid #1e2d44; background: #0b1424; }
.code-bar { display: flex; justify-content: space-between; gap: 12px; padding: 10px 16px; font-size: 13px; font-weight: 600; color: #c7d4e3; background: #12203a; }
.code-bar em { font-style: normal; font-size: 11.5px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: #7dd3fc; }
.code-card pre { margin: 0; padding: 16px 18px; overflow-x: auto; font: 13px/1.6 ui-monospace, "Cascadia Code", "SFMono-Regular", Consolas, monospace; color: #e2e8f0; }
.code-note { margin-top: 8px; font-size: 13.5px; color: var(--text-faint); }
.stack { display: flex; flex-wrap: wrap; gap: 8px; }
.stack span { padding: 6px 13px; border-radius: 999px; font-size: 13px; font-weight: 600; background: var(--surface); border: 1px solid var(--border); }

.takeaway { margin-top: 36px; padding: 22px 26px; border-radius: var(--radius-lg); color: #fff; background: linear-gradient(135deg, #022a5c, color-mix(in srgb, var(--c) 70%, #022a5c)); box-shadow: var(--shadow-md); }
.takeaway span { font-size: 12.5px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: #bfdbfe; }
.takeaway p { margin-top: 8px; font: 700 clamp(1.05rem, 2vw, 1.3rem)/1.45 var(--font-display); }
.refs ul { display: grid; gap: 8px; }
.refs a { font-weight: 600; color: var(--accent-2); }
.refs a:hover { text-decoration: underline; }

.tool-bridge { margin-top: 28px; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 14px; padding: 18px 22px; border-radius: var(--radius-lg); color: var(--text); background: color-mix(in srgb, #4f46e5 8%, var(--surface)); border: 1px solid color-mix(in srgb, #4f46e5 30%, var(--border)); transition: transform var(--dur-fast) var(--ease); }
.tool-bridge span { flex-basis: 100%; font-size: 12px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: #4f46e5; }
.tool-bridge i { margin-left: auto; font-style: normal; font-size: 20px; color: #4f46e5; }
.tool-bridge:hover { transform: translateY(-3px); }
.ai-concepts { margin-top: 56px; }
.pager { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 40px; }
.pager a { display: flex; flex-direction: column; gap: 4px; padding: 16px 18px; border-radius: var(--radius-md); font-weight: 700; color: var(--text); background: var(--surface); border: 1px solid var(--border); transition: all var(--dur-fast) var(--ease); }
.pager a small { font-size: 12px; font-weight: 600; color: var(--text-faint); }
.pager a:hover { border-color: var(--accent-2); transform: translateY(-2px); }
.pager .next { text-align: right; }

/* --- diagrams --- */
.dg { margin-top: 36px; padding: 22px; border-radius: var(--radius-lg); background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-sm); }
.dg-title { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 6px 14px; margin-bottom: 18px; }
.dg-title b { font: 700 1.15rem var(--font-display); letter-spacing: -0.01em; }
.dg-title span { font-size: 12.5px; font-weight: 600; color: var(--text-faint); }
.dg-canvas { display: grid; gap: 16px; }
.dg-node, .dg-layer, .dg-side, .dg-spoke, .dg-center {
  --tint: color-mix(in srgb, var(--tc) 9%, var(--surface));
  display: flex; flex-direction: column; gap: 5px; text-align: left; min-width: 0;
  padding: 13px 14px; border-radius: 12px; color: var(--text);
  background: var(--tint); border: 1.5px solid color-mix(in srgb, var(--tc) 35%, var(--border)); border-top: 4px solid var(--tc);
  transition: transform var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease), background var(--dur-fast) var(--ease);
}
.dg b { font-size: 14px; font-weight: 700; line-height: 1.3; overflow-wrap: anywhere; color: color-mix(in srgb, var(--tc, var(--text)) 55%, var(--text)); }
.dg small, .dg-canvas li { overflow-wrap: anywhere; }
.dg small { font-size: 12px; line-height: 1.4; color: var(--text-muted); }
.dg-canvas ul { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 2px; }
.dg-canvas li { padding: 2px 8px; border-radius: 6px; font-size: 11.5px; font-weight: 600; background: color-mix(in srgb, var(--tc) 13%, transparent); color: color-mix(in srgb, var(--tc) 70%, var(--text)); }
.dg-hit { cursor: pointer; }
.dg-hit:hover, .dg-hit:focus-visible { transform: translateY(-3px); box-shadow: 0 10px 22px color-mix(in srgb, var(--tc) 28%, transparent); }
.dg-hit:focus-visible { outline: 3px solid color-mix(in srgb, var(--tc) 55%, transparent); outline-offset: 2px; }
.dg-hit.on { background: color-mix(in srgb, var(--tc) 18%, var(--surface)); box-shadow: 0 0 0 2px var(--tc); }
.dg-detail { margin-top: 16px; padding: 13px 16px; border-radius: 12px; font-size: 14px; line-height: 1.55; color: var(--text-muted); background: var(--surface-2); border-left: 4px solid var(--border-strong); }
.dg-detail.filled { color: var(--text); border-left-color: var(--tc); background: color-mix(in srgb, var(--tc) 8%, var(--surface)); }
.dg-caption { margin-top: 10px; font-size: 13px; color: var(--text-faint); }

/* flow */
.dg-row { display: grid; gap: 8px; }
.dg-rowlabel { justify-self: start; padding: 3px 11px; border-radius: 999px; font-size: 11.5px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: #fff; background: var(--tc); }
.dg-flow { display: flex; align-items: stretch; gap: 0; }
.dg-flow > .dg-node { flex: 1 1 0; }
.dg-arrow { flex: 0 0 auto; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; width: 44px; padding: 0 2px; color: var(--text-faint); }
.dg-arrow svg { width: 22px; height: 22px; }
.dg-arrow em { font-style: normal; font-size: 10px; font-weight: 700; line-height: 1.15; text-align: center; color: var(--text-faint); }

/* layers */
.dg-layers { display: grid; gap: 10px; }
.dg-layers.has-side { grid-template-columns: 1fr 170px; }
.dg-stack { display: grid; gap: 10px; }
.dg-layer { flex-direction: row; flex-wrap: wrap; align-items: center; gap: 8px 14px; border-top-width: 1.5px; border-left: 5px solid var(--tc); }
.dg-layer > b { min-width: 170px; }
.dg-layer ul { flex: 1; margin: 0; }
.dg-side { justify-content: center; text-align: center; align-items: center; border-top-width: 1.5px; border-left: 5px solid var(--tc); background: repeating-linear-gradient(135deg, var(--tint), var(--tint) 10px, color-mix(in srgb, var(--tc) 14%, var(--surface)) 10px, color-mix(in srgb, var(--tc) 14%, var(--surface)) 20px); }
.dg-side ul { justify-content: center; }

/* hub */
.dg-hub { display: grid; gap: 14px; }
.dg-center { align-items: center; text-align: center; padding: 18px; color: #fff; background: linear-gradient(135deg, var(--tc), color-mix(in srgb, var(--tc) 60%, #000)); border: 0; }
.dg-center b { font-size: 16px; color: #fff; }
.dg-center small { color: rgba(255, 255, 255, 0.82); }
.dg-center.dg-hit.on { box-shadow: 0 0 0 3px color-mix(in srgb, var(--tc) 40%, #fff); }
.dg-spokes { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; position: relative; }
.dg-spokes::before { content: ""; position: absolute; left: 50%; top: -14px; width: 2px; height: 14px; background: var(--border-strong); }

/* compare */
.dg-table-wrap { overflow-x: auto; border-radius: 12px; border: 1px solid var(--border); }
.dg-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.dg-table th, .dg-table td { padding: 11px 14px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--border); }
.dg-table thead th { font: 700 13.5px var(--font-display); color: #fff; background: #1e3a8a; }
.dg-table thead th:first-child { background: #022a5c; }
.dg-table tbody th { width: 24%; font-weight: 700; color: var(--text); background: var(--surface-2); }
.dg-table tbody tr:last-child th, .dg-table tbody tr:last-child td { border-bottom: 0; }
.dg-table td { color: var(--text-muted); }
.dg-table td.best { color: var(--text); font-weight: 700; background: color-mix(in srgb, #16a34a 10%, transparent); }
.dg-table td.best::after { content: " ✓"; color: #16a34a; }

/* --- responsive --- */
@media (max-width: 860px) {
  .trade { grid-template-columns: 1fr; }
  .dg-layers.has-side { grid-template-columns: 1fr; }
  .dg-layer > b { min-width: 0; flex-basis: 100%; }
}
@media (max-width: 760px) {
  .dg { padding: 16px 14px; }
  .dg-flow { flex-direction: column; }
  .dg-arrow { width: auto; flex-direction: row; padding: 4px 0; }
  .dg-arrow svg { transform: rotate(90deg); }
  .dg-arrow em { font-size: 11px; }
  .cat-head { align-items: flex-start; }
  .pager { grid-template-columns: 1fr; }
  .pager .next { text-align: left; }
  .scenario { padding: 20px 18px; }
  .steps li { padding-left: 56px; }
}
