/* =========================================================
   Chapter 03 — Anatomy (page-specific)
   ========================================================= */

/* ---------- Bike drawing palette ---------- */
.bike {
  --bk-frame: var(--teal);
  --bk-comp: var(--ink-2);
  --bk-dark: var(--ink);
  --bk-metal: var(--muted);
  --bk-tire: var(--ink);
  --bk-soft: var(--line-2);
  --bk-alloy: color-mix(in srgb, var(--ink) 30%, var(--surface));
  --bk-rim: color-mix(in srgb, var(--ink) 74%, var(--surface));
  --bk-hi: color-mix(in srgb, var(--surface) 62%, transparent);
  width: 100%; height: auto; overflow: visible;
}
/* Dark theme: keep rubber, carbon and anodised parts dark (as on a real bike) instead of
   inverting them; lift them just enough above the background to stay legible. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .bike {
    --bk-tire: #4a463f; --bk-dark: #3e3b35; --bk-comp: #6f6a60; --bk-rim: #5c5850;
    --bk-alloy: #9a948a; --bk-metal: #aaa398; --bk-soft: #5e5a52;
  }
}
:root[data-theme="dark"] .bike {
  --bk-tire: #4a463f; --bk-dark: #3e3b35; --bk-comp: #6f6a60; --bk-rim: #5c5850;
  --bk-alloy: #9a948a; --bk-metal: #aaa398; --bk-soft: #5e5a52;
}
.bike .s { stroke: var(--c); }
.bike .f { fill: var(--c); }
.bike .k-fr { --c: var(--bk-frame); }
.bike .k-cp { --c: var(--bk-comp); }
.bike .k-dk { --c: var(--bk-dark); }
.bike .k-mt { --c: var(--bk-metal); }
.bike .k-tr { --c: var(--bk-tire); }
.bike .k-sf { --c: var(--bk-soft); }
.bike .k-bg { --c: var(--surface); }
.bike .k-al { --c: var(--bk-alloy); }
.bike .k-rm { --c: var(--bk-rim); }
.bike .sheen { stroke: var(--bk-hi); fill: none; }
.bike .shade { stroke: #000; opacity: .14; fill: none; }
.bike .far { opacity: .42; }
.bike .hit { fill: none; stroke: transparent; }
.bike .ground { stroke: var(--line-2); }

/* interactive parts */
.ax-svg .part { cursor: pointer; transition: opacity .25s ease; outline: none; }
.ax-svg .part * { transition: stroke .2s ease, fill .2s ease; }
.ax-svg.dim .part:not(.hl) { opacity: .26; }
.ax-svg .part.hl * { --c: var(--accent); }
.ax-svg .part.sel { filter: drop-shadow(0 0 6px color-mix(in srgb, var(--accent) 55%, transparent)); }

/* ---------- Explorer layout ---------- */
.ax-wrap { display: grid; grid-template-columns: minmax(0, 1.75fr) minmax(0, 1fr); gap: 24px; align-items: start; }
.ax-stage { position: relative; background:
  radial-gradient(circle at 1px 1px, var(--line) 1px, transparent 0) 0 0 / 22px 22px, var(--surface-2);
  border: 1px solid var(--line); border-radius: var(--radius); padding: 10px; }
.ax-stage-bar { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; padding: 4px 6px 8px; font-size: .82rem; color: var(--muted); }
.ax-stage-bar .mono { font-size: .75rem; letter-spacing: .06em; }
.ax-hover { font-weight: 700; color: var(--ink); min-height: 1.4em; }
.ax-canvas { position: relative; }
.ax-pin {
  position: absolute; transform: translate(-50%, calc(-100% - 10px)); pointer-events: none;
  background: var(--ink); color: var(--bg); font-size: .78rem; font-weight: 700; line-height: 1.3;
  padding: 5px 10px; border-radius: 8px; white-space: nowrap; box-shadow: var(--shadow);
  opacity: 0; transition: opacity .15s ease;
}
.ax-pin::after { content: ""; position: absolute; left: 50%; bottom: -5px; margin-left: -5px; border: 5px solid transparent; border-bottom: 0; border-top-color: var(--ink); }
.ax-pin.show { opacity: 1; }
.ax-pin small { font-weight: 500; opacity: .7; margin-left: 4px; font-family: var(--mono); font-size: .68rem; }

.ax-panel { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; min-height: 100%; }
.ax-panel h3 { margin: 10px 0 0; font-size: 1.5rem; }
.ax-en { font-family: var(--mono); font-size: .8rem; color: var(--muted); letter-spacing: .04em; margin-bottom: 12px; }
.ax-role { font-size: .95rem; color: var(--ink-2); line-height: 1.65; }
.ax-specs { display: grid; gap: 0; margin: 14px 0; border-top: 1px solid var(--line); }
.ax-specs > div { display: grid; grid-template-columns: 72px 1fr; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line); font-size: .87rem; }
.ax-specs dt { font-weight: 700; color: var(--muted); font-size: .78rem; padding-top: 2px; }
.ax-specs dd { margin: 0; color: var(--ink); line-height: 1.5; }
.ax-warn { background: var(--gold-soft); border-radius: var(--radius-sm); padding: 12px 14px; font-size: .86rem; line-height: 1.55; color: var(--ink-2); }
.ax-warn b { display: block; color: var(--ink); margin-bottom: 2px; }
.ax-links { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 14px; }
.ax-links a { font-size: .8rem; font-weight: 700; padding: 5px 11px; border-radius: 999px; background: var(--accent-soft); color: var(--accent-ink); text-decoration: none; }
.ax-links a:hover { background: var(--accent); color: #fff; }
.ax-step { display: flex; gap: 8px; margin-top: 16px; }
.ax-step button { flex: 1; }
.ax-empty { color: var(--muted); font-size: .92rem; }

.ax-finder { margin-top: 20px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; }
.ax-finder-top { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.ax-finder-top .input { flex: 1 1 220px; }
.ax-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 6px; max-height: 260px; overflow: auto; padding-right: 4px; }
.ax-list button {
  width: 100%; text-align: left; border: 1px solid var(--line); background: var(--surface); border-radius: 10px;
  padding: 8px 10px; font-size: .86rem; font-weight: 600; line-height: 1.3; display: flex; align-items: center; gap: 8px;
}
.ax-list button small { display: block; font-family: var(--mono); font-size: .66rem; color: var(--muted); font-weight: 400; }
.ax-list button:hover, .ax-list button.hl { border-color: var(--accent); }
.ax-list button[aria-pressed="true"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.ax-list button[aria-pressed="true"] small { color: inherit; opacity: .7; }
.ax-dot { width: 8px; height: 8px; border-radius: 50%; flex: none; background: var(--muted); }
.ax-count { font-size: .8rem; color: var(--muted); font-family: var(--mono); }
.ax-chips .chip { padding: 5px 11px; font-size: .8rem; }

@media (max-width: 900px) { .ax-wrap { grid-template-columns: minmax(0, 1fr); } }

/* full-width flagship section */
.ax-section { padding-top: clamp(40px, 6vw, 72px); padding-bottom: 0; }
.ax-section .widget { margin-top: 0; }

/* ---------- Exploded view ---------- */
.ex-stage { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 8px; }
.ex-controls { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 16px; align-items: center; margin-top: 16px; }
.ex-controls output { font-family: var(--mono); font-weight: 600; min-width: 4ch; text-align: right; }
.ex-label rect { fill: var(--ink); }
.ex-label text { fill: var(--bg); font: 700 45px var(--font); }
.ex-label .sub { font: 400 27px var(--font); opacity: .75; }
.ex-leader { stroke: var(--accent); stroke-width: 4.5; fill: none; stroke-dasharray: 7 5; }
.ex-dot { fill: var(--accent); }
@media (max-width: 520px) { .ex-controls { grid-template-columns: minmax(0, 1fr) auto; } .ex-controls .btn { grid-column: 1 / -1; justify-content: center; } }

/* ---------- Drivetrain simulator ---------- */
.dt-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 20px; align-items: start; }
.dt-ctl { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 0 28px; align-items: start; }
@media (max-width: 760px) { .dt-ctl { grid-template-columns: minmax(0, 1fr); } }
.dt-svg { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius); width: 100%; height: auto; }
.dt-svg text { font-family: var(--font); fill: var(--muted); font-size: 14px; }
.dt-svg .t-big { font-family: var(--serif); font-weight: 800; font-size: 24px; fill: var(--ink); }
.dt-group-label { font-size: .78rem; font-weight: 700; color: var(--muted); margin: 14px 0 8px; display: block; }
.dt-cogs { display: grid; grid-template-columns: repeat(auto-fill, minmax(44px, 1fr)); gap: 6px; }
.dt-cogs .chip { justify-content: center; padding: 7px 0; font-family: var(--mono); }
.dt-out { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; background: color-mix(in srgb, var(--bg) 20%, transparent); border-radius: var(--radius); overflow: hidden; margin-top: 16px; }
.dt-out > div { background: var(--ink); color: var(--bg); padding: 14px 16px; }
.dt-out .big { font-family: var(--serif); font-weight: 800; font-size: 1.7rem; line-height: 1.1; }
.dt-out .lab { font-size: .74rem; opacity: .65; font-family: var(--mono); letter-spacing: .04em; }
.dt-alert { margin-top: 14px; border-radius: var(--radius-sm); padding: 12px 14px; font-size: .88rem; line-height: 1.55; }
.dt-alert.ok { background: var(--green-soft); color: var(--ink-2); }
.dt-alert.bad { background: var(--red-soft); color: var(--ink-2); }
.dt-alert.mid { background: var(--gold-soft); color: var(--ink-2); }
.dt-alert b { color: var(--ink); }
.dt-table td, .dt-table th { padding: 7px 8px; text-align: center; font-family: var(--mono); font-size: .78rem; white-space: nowrap; }
.dt-table td.cur { background: var(--accent); color: #fff; font-weight: 700; }
.dt-table td.x { color: var(--red); text-decoration: line-through; text-decoration-color: color-mix(in srgb, var(--red) 50%, transparent); }
.dt-table th[scope="row"] { background: var(--surface-2); }

/* ---------- Generic figure / diagram ---------- */
.fig { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: clamp(14px, 3vw, 24px); margin: 2em 0; }
.fig svg { width: 100%; height: auto; }
.fig svg text { font-family: var(--font); fill: var(--ink-2); font-size: 13px; }
.fig svg .lbl-strong { font-weight: 800; fill: var(--ink); }
.fig svg .lbl-acc { fill: var(--accent-ink); font-weight: 700; }
.fig svg .lbl-teal { fill: var(--teal); font-weight: 700; }
.dim-line { stroke: var(--accent); stroke-width: 1.6; fill: none; }
.dim-ext { stroke: var(--line-2); stroke-width: 1; stroke-dasharray: 4 4; fill: none; }
.geo-frame { stroke: var(--ink-2); stroke-width: 6; stroke-linecap: round; fill: none; }
.geo-wheel { stroke: var(--line-2); stroke-width: 6; fill: none; }

.term { border-bottom: 1px dotted var(--accent); cursor: help; }

/* material cards */
.mat-card h4 { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin-bottom: 14px; }
.mat-card h4 small { font-family: var(--mono); font-size: .72rem; color: var(--muted); font-weight: 400; }
.mat-card .bars { gap: 10px; }
.mat-card .bar-row { grid-template-columns: 64px 1fr 36px; gap: 10px; font-size: .82rem; }
.mat-card .bar-track { height: 10px; }
.mat-card p { font-size: .88rem; color: var(--ink-2); margin: 14px 0 0; line-height: 1.6; }

/* groupset ladder */
.ladder { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 8px; align-items: end; min-height: 300px; }
.rung { display: flex; flex-direction: column; justify-content: flex-end; }
.rung-bar { height: var(--h); border-radius: 12px 12px 4px 4px; padding: 12px 10px; color: #fff; display: flex; flex-direction: column; justify-content: flex-start; gap: 4px;
  background: linear-gradient(180deg, color-mix(in srgb, var(--rc) 100%, transparent), color-mix(in srgb, var(--rc) 70%, var(--ink))); }
.rung-bar strong { font-size: 1rem; line-height: 1.2; }
.rung-bar span { font-family: var(--mono); font-size: .72rem; opacity: .92; }
.rung-note { font-size: .78rem; color: var(--muted); margin-top: 8px; line-height: 1.45; min-height: 3.2em; }
@media (max-width: 680px) {
  .ladder { grid-template-columns: minmax(0, 1fr); min-height: 0; gap: 6px; }
  .rung { display: grid; grid-template-columns: minmax(0, 1fr); }
  .rung-bar { height: auto; width: var(--w); min-width: 150px; max-width: 100%; border-radius: 4px 12px 12px 4px; flex-direction: row; justify-content: space-between; align-items: center; padding: 10px 12px; }
  .rung-note { min-height: 0; margin: 2px 0 6px; }
}
.brand-row { display: grid; gap: 10px; }
.brand-item { display: grid; grid-template-columns: 130px minmax(0, 1fr); gap: 14px; padding: 12px 0; border-bottom: 1px solid var(--line); font-size: .92rem; }
.brand-item:last-child { border-bottom: 0; }
.brand-item strong { color: var(--ink); }
.brand-item p { margin: 0; color: var(--ink-2); }
@media (max-width: 520px) { .brand-item { grid-template-columns: minmax(0, 1fr); gap: 2px; } }

/* donut */
.donut-wrap { display: grid; grid-template-columns: minmax(0, 300px) minmax(0, 1fr); gap: 32px; align-items: center; }
@media (max-width: 700px) { .donut-wrap { grid-template-columns: minmax(0, 1fr); } .donut-box { max-width: 300px; margin: 0 auto; } }
.donut-box { position: relative; }
.donut-box svg { width: 100%; height: auto; transform: rotate(-90deg); }
.donut-seg { fill: none; stroke-width: 34; transition: stroke-width .2s ease, opacity .2s ease; cursor: pointer; }
.donut-box.focus .donut-seg { opacity: .3; }
.donut-box.focus .donut-seg.on { opacity: 1; stroke-width: 42; }
.donut-center { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; pointer-events: none; padding: 25%; }
.donut-center .big { font-family: var(--serif); font-size: clamp(1.8rem, 5vw, 2.4rem); font-weight: 800; line-height: 1; }
.donut-center .lab { font-size: .8rem; color: var(--muted); margin-top: 6px; line-height: 1.35; }
.donut-legend { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.donut-legend button { width: 100%; display: grid; grid-template-columns: 14px minmax(0, 1fr) auto auto; gap: 10px; align-items: center; text-align: left;
  border: 0; background: transparent; padding: 7px 8px; border-radius: 8px; font-size: .9rem; }
.donut-legend button:hover, .donut-legend button.on { background: var(--bg-2); }
.donut-legend i { width: 14px; height: 14px; border-radius: 4px; background: var(--sw); }
.donut-legend .kg { font-family: var(--mono); font-size: .82rem; }
.donut-legend .pc { font-family: var(--mono); font-size: .78rem; color: var(--muted); min-width: 4.2ch; text-align: right; }

/* hero art */
.ax-hero-stats { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 22px; }
.ax-hero-stats .chip { font-family: var(--mono); font-size: .78rem; }
.dt-table td.cur.x { color: #fff; text-decoration-color: rgba(255,255,255,.7); }
