/* Chapter 04 — 조립·피팅 page styles */

/* ---------- Bike drawing palette (same tokens as the anatomy page) ---------- */
.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);
}
/* Dark theme: rubber, carbon and anodised parts stay dark (as on a real bike), lifted just enough to read. */
@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(--bk-bg, 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 .ground { stroke: var(--line-2); }

/* Hero art: size-56 road bike on a repair stand */
.asm-hero-art { width: min(38vw, 470px); right: 0; bottom: 6px; opacity: 1; --bk-bg: var(--bg); }
.asm-hero-shadow { fill: var(--ink); opacity: .07; }
.asm-hero-spin { animation: asm-spin 7s linear infinite; }
@keyframes asm-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .asm-hero-spin { animation: none; } }
@media (min-width: 861px) and (max-width: 1240px) { .asm-hero-art { display: none; } }
@media (max-width: 860px) { .asm-hero-art { width: 100%; max-width: 440px; display: block; margin-left: auto; margin-right: auto; } }

.asm-stats { margin-bottom: 8px; }
.asm-stats .stat-value { font-size: clamp(2rem, 4vw, 2.8rem); }

/* ---------- Tool checklist ---------- */
.tool-meter { margin-bottom: 18px; }
.tool-meter-row { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; font-size: .92rem; margin-bottom: 8px; }
.tool-meter-track { height: 12px; background: var(--bg-2); border-radius: 999px; overflow: hidden; }
.tool-meter-fill { height: 100%; width: 0; background: linear-gradient(90deg, var(--accent), var(--gold)); border-radius: 999px; transition: width .5s cubic-bezier(.2,.8,.2,1); }
.tool-meter-fill.full { background: var(--green); }
.tool-meter-msg { margin: 8px 0 0; font-size: .88rem; color: var(--muted); }
.tool-filter { margin-bottom: 16px; }
.tool-grid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 190px), 1fr)); gap: 12px; }
.tool-grid li[hidden] { display: none; }
.tool-card {
  width: 100%; height: 100%; text-align: left; display: grid; grid-template-columns: 44px 1fr; grid-template-rows: auto auto auto; column-gap: 12px; row-gap: 2px;
  padding: 14px 14px 14px 12px; border-radius: var(--radius-sm); border: 1px solid var(--line); background: var(--surface-2); position: relative;
  transition: border-color .2s, background .2s, transform .15s;
}
.tool-card:hover { border-color: var(--line-2); transform: translateY(-2px); }
.tool-card svg { grid-row: 1 / 4; width: 44px; height: 44px; color: var(--ink-2); fill: none; stroke: currentColor; stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; padding: 5px; border-radius: 10px; background: var(--bg-2); transition: color .2s, background .2s; }
.tool-card svg .tn { stroke-width: 1.6; }
.tool-card svg .fi { fill: currentColor; stroke: none; }
.tool-card:hover svg { color: var(--ink); }
.tool-name { font-weight: 700; font-size: .95rem; line-height: 1.3; padding-right: 26px; }
.tool-desc { font-size: .8rem; color: var(--muted); line-height: 1.45; }
.tool-card .tag { justify-self: start; margin-top: 4px; }
.tool-check { position: absolute; top: 12px; right: 12px; width: 22px; height: 22px; border-radius: 6px; border: 2px solid var(--line-2); background: var(--surface); display: grid; place-items: center; }
.tool-card[aria-pressed="true"] { border-color: var(--green); background: var(--green-soft); }
.tool-card[aria-pressed="true"] svg { color: var(--green); background: var(--surface); }
.tool-card[aria-pressed="true"] .tool-check { background: var(--green); border-color: var(--green); }
.tool-card[aria-pressed="true"] .tool-check::after { content: ""; width: 10px; height: 6px; border-left: 2.5px solid #fff; border-bottom: 2.5px solid #fff; transform: translateY(-1px) rotate(-45deg); }

/* ---------- Wizard ---------- */
.wz:focus { outline: none; }
.wz-count { font-size: .85rem; color: var(--muted); padding-top: 6px; }
.wz-progress { height: 6px; background: var(--bg-2); border-radius: 999px; overflow: hidden; margin-bottom: 14px; }
.wz-progress-fill { height: 100%; width: 0; background: var(--accent); transition: width .4s ease; }
.wz-dots { list-style: none; padding: 0; margin: 0 0 20px; display: flex; flex-wrap: wrap; gap: 6px; }
.wz-dot { width: 34px; height: 34px; border-radius: 50%; border: 1.5px solid var(--line-2); background: var(--surface); font-family: var(--mono); font-size: .78rem; font-weight: 600; color: var(--muted); display: grid; place-items: center; padding: 0; transition: background .2s, border-color .2s, color .2s; }
.wz-dot:hover { border-color: var(--ink); color: var(--ink); }
.wz-dot.done { background: var(--green-soft); border-color: var(--green); color: var(--green); }
.wz-dot[aria-current="step"] { background: var(--ink); border-color: var(--ink); color: var(--bg); }
.wz-dot.done[aria-current="step"] { background: var(--green); border-color: var(--green); color: #fff; }

.wz-body { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr); gap: 28px; align-items: start; }
@media (max-width: 1180px) { .wz-body { grid-template-columns: 1fr; } }
.wz-figure { margin: 0; position: sticky; top: calc(var(--header-h) + 16px); background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 12px; }
@media (max-width: 1180px) { .wz-figure { position: static; } }
.wz-figure figcaption { text-align: center; margin-top: 4px; }
.wz-figure { --bk-bg: var(--surface-2); }
.wz-bike { width: 100%; height: auto; overflow: visible; display: block; }
.wz-ground { stroke: var(--line-2); stroke-width: 3; stroke-dasharray: 12 12; }
.wz-parts [data-part] { transition: opacity .45s ease, filter .45s ease; }
/* focus: everything else recedes, the target keeps its real colours and gets an accent halo */
.wz-bike.dim [data-part]:not(.is-hl) { opacity: .2; filter: grayscale(1); }
.wz-bike.dim [data-part].is-hl {
  filter: drop-shadow(0 0 4px var(--accent)) drop-shadow(0 0 4px var(--accent)) drop-shadow(0 0 22px color-mix(in srgb, var(--accent) 55%, transparent));
}
.wz-bike.show-bolts [data-part] { opacity: .3; }

.wz-bolts circle { fill: var(--gold); stroke: var(--surface); stroke-width: 6; opacity: 0; transform-box: fill-box; transform-origin: center; transition: opacity .35s; }
.wz-bike.show-bolts .wz-bolts circle { opacity: 1; animation: wz-blink 1.6s ease-in-out infinite; }
@keyframes wz-blink { 50% { transform: scale(1.45); } }
.wz-motion path { stroke: var(--accent); stroke-width: 12; stroke-linecap: round; fill: none; opacity: 0; transition: opacity .35s; }
.wz-bike.show-motion .wz-motion path { opacity: .75; animation: wz-dash 1s linear infinite; stroke-dasharray: 60 40; }
@keyframes wz-dash { to { stroke-dashoffset: -100; } }
.wz-spin { transition: none; }
.wz-bike.show-motion .wz-spin { animation: wz-spin 1.1s linear infinite; }
@keyframes wz-spin { to { transform: rotate(360deg); } }
.wz-box path { fill: none; stroke: var(--gold); stroke-width: 5; stroke-dasharray: 22 14; opacity: 0; transition: opacity .4s; }
.wz-box .wz-box-face { fill: color-mix(in srgb, var(--gold) 7%, transparent); }
.wz-bike.show-box .wz-box path { opacity: .9; }

.wz-focus { transition: transform .6s cubic-bezier(.2,.8,.2,1), opacity .3s; pointer-events: none; }
.wz-focus.off { opacity: 0; }
.wz-focus-ring { fill: none; stroke: var(--accent); stroke-width: 2; vector-effect: non-scaling-stroke; transition: r .6s cubic-bezier(.2,.8,.2,1); }
.wz-focus-pulse { fill: color-mix(in srgb, var(--accent) 7%, transparent); stroke: var(--accent); stroke-width: 1; vector-effect: non-scaling-stroke; transform-box: fill-box; transform-origin: center; animation: wz-pulse 2.2s ease-out infinite; transition: r .6s cubic-bezier(.2,.8,.2,1); }
@keyframes wz-pulse { 0% { opacity: .8; transform: scale(1); } 100% { opacity: 0; transform: scale(1.18); } }
.wz-callout { pointer-events: none; opacity: 0; }
.wz-callout.in { animation: wz-callout-in .45s ease .45s both; }
@keyframes wz-callout-in { from { opacity: 0; } to { opacity: 1; } }
.wz-leader { fill: none; stroke: var(--accent); stroke-width: 1.5; vector-effect: non-scaling-stroke; }
.wz-tag { fill: var(--accent); }
.wz-tag-t { fill: #fff; font: 700 40px var(--font); letter-spacing: -.01em; text-anchor: middle; }
@media (max-width: 640px) { .wz-tag-t { font-size: 54px; } }
@media (prefers-reduced-motion: reduce) {
  .wz-focus, .wz-focus-ring, .wz-focus-pulse { transition: none; animation: none; }
  .wz-bike.show-motion .wz-spin, .wz-bike.show-motion .wz-motion path, .wz-bike.show-bolts .wz-bolts circle { animation: none; }
}

.wz-steps { min-width: 0; }
.wz-step { animation: wz-in .35s ease; }
.wz-step[hidden] { display: none; }
@keyframes wz-in { from { opacity: 0; transform: translateX(12px); } to { opacity: 1; transform: none; } }
.wz-step-num { font-family: var(--mono); font-size: .75rem; letter-spacing: .12em; color: var(--accent); font-weight: 600; }
.wz-step h4 { font-size: 1.3rem; margin: 4px 0 12px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.wz-step h4 .tag { font-size: .72rem; }
.wz-step p { color: var(--ink-2); font-size: .97rem; }
.wz-meta { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin: 16px 0 0; }
.wz-meta div { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 10px 12px; }
.wz-meta dt { font-family: var(--mono); font-size: .68rem; letter-spacing: .1em; color: var(--muted); text-transform: uppercase; }
.wz-meta dd { margin: 2px 0 0; font-size: .86rem; font-weight: 600; line-height: 1.45; }
@media (max-width: 640px) { .wz-meta { grid-template-columns: 1fr; } }
.wz-step .callout { font-size: .92rem; margin: 16px 0 0; }
.wz-controls { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-top: 24px; padding-top: 18px; border-top: 1px solid var(--line); }
.wz-controls .btn:disabled { opacity: .4; cursor: not-allowed; transform: none; }
.wz-done-btn { background: var(--surface); color: var(--ink); border-color: var(--line-2); }
.wz-done-btn:hover { color: var(--ink); }
.wz-done-btn[aria-pressed="true"] { background: var(--green); border-color: var(--green); color: #fff; }
.wz-done-btn[aria-pressed="true"]:hover { color: #fff; }
.wz-hint { font-size: .8rem; margin: 12px 0 0; }
@media (max-width: 640px) { .wz-hint { display: none; } .wz-controls .btn { flex: 1 1 auto; justify-content: center; } }

/* ---------- Pedal demo ---------- */
.pedal-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
@media (max-width: 640px) { .pedal-grid { grid-template-columns: 1fr; } }
.pedal-panel { margin: 0; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 12px; }
.pedal-panel svg { width: 100%; height: auto; display: block; --bk-bg: var(--surface-2); }
.pedal-panel figcaption { font-size: .84rem; color: var(--muted); line-height: 1.55; margin-top: 4px; }
.pd-title { font-weight: 800; font-size: 15px; fill: var(--ink); font-family: var(--font); }
.pd-sub { font-size: 11px; fill: var(--muted); font-family: var(--font); letter-spacing: .02em; }
.pd-dir { font-weight: 800; font-size: 16px; fill: var(--accent-ink); font-family: var(--font); }
.pd-front { font-size: 12px; font-weight: 700; fill: var(--muted); font-family: var(--font); }
.pd-lbl { font-size: 10.5px; font-weight: 600; fill: var(--ink-2); font-family: var(--font); }
.pd-lbl-inv { fill: #fff; opacity: .85; font-size: 9.5px; }
.pd-lbl-mono { font-family: var(--mono); font-size: 10px; fill: var(--muted); }
.pd-arrow { fill: none; stroke: var(--accent); stroke-width: 3.5; stroke-linecap: round; }
.pd-wrench { fill: color-mix(in srgb, var(--bk-alloy) 70%, var(--surface)); stroke: var(--bk-comp); stroke-width: 1.5; stroke-linejoin: round; }
.pd-wrench-grip { fill: var(--accent); opacity: .92; }
.pd-axis { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 14 4 2 4; opacity: .7; }
.pd-sec { fill: url(#pd-hatch); }
.pd-sec-edge { fill: none; stroke: var(--ink-2); stroke-width: 1.6; }
.pd-tooth { fill: url(#pd-hatch); stroke: var(--ink-2); stroke-width: 1.2; stroke-linejoin: round; }
.pd-spindle { fill: color-mix(in srgb, var(--bk-alloy) 80%, var(--surface)); stroke: var(--bk-dark); stroke-width: 1.5; }
.pd-hidden { fill: none; stroke: var(--bk-dark); stroke-width: 1.1; stroke-dasharray: 4 3; opacity: .7; }
.pd-crest { fill: none; stroke: var(--bk-dark); stroke-width: 1.7; stroke-linecap: round; }
.pd-crest-back { fill: none; stroke: var(--bk-dark); stroke-width: .9; stroke-dasharray: 2.5 2.5; opacity: .35; }
.pedal-rule { margin: 16px 0 0; padding: 12px 16px; border-radius: var(--radius-sm); background: var(--accent-soft); color: var(--ink); font-size: .95rem; }
#pedal-play .lbl { min-width: 2.6em; display: inline-block; }

/* ---------- Torque bars ---------- */
.tq .bar-row { grid-template-columns: 180px 1fr 64px; }
.tq .bar-track { position: relative; height: 16px; }
.tq-lo { position: absolute; left: 0; top: 0; bottom: 0; background: repeating-linear-gradient(135deg, var(--accent-soft) 0 4px, color-mix(in srgb, var(--accent) 35%, var(--surface)) 4px 6px); opacity: 0; transition: opacity .6s ease .9s; border-radius: 999px 0 0 999px; }
.tq.in .tq-lo { opacity: 1; }
@media (max-width: 640px) { .tq .bar-row { grid-template-columns: 1fr 56px; row-gap: 4px; } .tq .bar-row > span:first-child { grid-column: 1 / -1; font-weight: 600; } }
.tq-legend { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: .8rem; color: var(--muted); }
.tq-key { width: 18px; height: 10px; border-radius: 3px; display: inline-block; margin-left: 6px; }
.tq-key-lo { background: repeating-linear-gradient(135deg, var(--accent-soft) 0 4px, color-mix(in srgb, var(--accent) 35%, var(--surface)) 4px 6px); }
.tq-key-hi { background: var(--accent); }
.tq-note { font-size: .82rem; margin: 18px 0 0; }
.tq-scale { font-family: var(--mono); font-size: .75rem; color: var(--muted); margin: -12px 0 14px; }

/* ---------- Fit calculator ---------- */
.fit-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr); gap: 24px; align-items: start; }
@media (max-width: 760px) { .fit-grid { grid-template-columns: 1fr; } }
.fit-form output { font-family: var(--mono); color: var(--accent-ink); }
.fit-error { color: var(--red); font-size: .86rem; min-height: 1.2em; margin: 0; }
.fit-unit { font-size: .45em; font-family: var(--font); }
.fit-sub { font-size: .85rem; margin-top: 4px; }
.fit-results { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 16px; margin-top: 20px; padding-top: 18px; border-top: 1px solid color-mix(in srgb, var(--bg) 20%, transparent); }
.fit-results div { display: grid; gap: 2px; }
.fit-results span { font-size: .78rem; line-height: 1.35; }
.fit-results strong { font-size: 1.2rem; font-family: var(--mono); }
.fit-figure { margin: 24px 0 0; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 12px; }
.fit-figure svg { width: 100%; height: auto; }
.fit-explain { font-size: .88rem; margin: 16px 0 0; }
.fit-ok { color: var(--green); font-weight: 700; }
.fit-bad { color: var(--red); font-weight: 700; }

/* SVG drawing classes for the fit diagram (1 unit = 1 mm) */
.fit-figure { --bk-bg: var(--surface-2); }
.fit-svg { --rider: color-mix(in srgb, var(--ink-2) 78%, var(--teal)); }
.fd-ground { stroke: var(--line-2); stroke-width: 3; stroke-dasharray: 14 14; }
.fd-body { opacity: .9; }
.fd-body.fd-far { opacity: .34; }
.fd-rider { fill: var(--rider); }
.fd-shoe { fill: color-mix(in srgb, var(--rider) 55%, #000); }
.fd-helmet { fill: var(--accent); }
.fd-vent { stroke: color-mix(in srgb, var(--accent) 40%, #000); stroke-width: 6; fill: none; }
.fd-bone { fill: none; stroke: var(--gold); stroke-width: 2; vector-effect: non-scaling-stroke; stroke-dasharray: 5 4; }
.fd-ext { fill: none; stroke: var(--muted); stroke-width: 1.2; vector-effect: non-scaling-stroke; stroke-dasharray: 4 4; }
.fd-joint { fill: var(--surface); stroke: var(--gold); stroke-width: 2; vector-effect: non-scaling-stroke; }
.fd-knee-arc { fill: color-mix(in srgb, var(--gold) 34%, transparent); stroke: var(--gold); stroke-width: 1.6; vector-effect: non-scaling-stroke; }
.fd-knee-txt { font-family: var(--mono); font-size: 46px; font-weight: 700; fill: var(--ink); paint-order: stroke; stroke: var(--surface-2); stroke-width: 10px; stroke-linejoin: round; }
.fd-dim { fill: none; stroke: var(--accent); stroke-width: 1.6; vector-effect: non-scaling-stroke; }
.fd-label { font-family: var(--mono); font-size: 44px; font-weight: 700; fill: var(--accent-ink); }
.fd-label-bg { fill: var(--surface); stroke: var(--accent); stroke-width: 1.4; vector-effect: non-scaling-stroke; }
.fd-small { font-family: var(--font); font-size: 38px; font-weight: 700; fill: var(--muted); }
@media (max-width: 640px) { .fd-knee-txt { font-size: 62px; } .fd-small { font-size: 52px; } .fd-label { font-size: 62px; } }

/* ---------- Size chart ---------- */
.size-table tbody tr { transition: background .3s; }
.size-table tbody tr.is-match { background: var(--accent-soft); }
.size-table tbody tr.is-match td:first-child { box-shadow: inset 4px 0 0 var(--accent); font-weight: 700; }
.size-table td.is-col { font-weight: 800; color: var(--accent-ink); }
.size-note { font-size: .85rem; margin-top: -8px; }
