/* ==========================================================================
   /best-way-to-memorize/: the technique chooser, the chunking + memory
   palace illustration and the worked-example boxes. Built on the tokens in
   site.css and the .tool shell in tools.css.
   ========================================================================== */

/* ---------- Technique chooser ---------- */

.bwm-pick { border: 0; padding: 0; margin: 0 0 20px; min-width: 0; }
.bwm-legend { font-size: 14px; font-weight: 600; color: var(--text-2); margin-bottom: 10px; padding: 0; }
.bwm-opts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.bwm-opt { position: relative; cursor: pointer; }
.bwm-opt input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.bwm-opt span {
    display: flex; align-items: center; justify-content: center; min-height: 48px; height: 100%; padding: 8px 12px;
    border-radius: 14px; border: 1px solid var(--line-strong); background: var(--surface-2);
    font-size: 15px; font-weight: 600; line-height: 1.25; color: var(--text-2); text-align: center;
    transition: background-color 0.25s ease, color 0.25s ease, border-color 0.25s ease;
}
.bwm-opt:hover span { color: var(--text); border-color: rgba(255, 255, 255, 0.24); }
.bwm-opt input:checked + span { background: var(--text); color: #000; border-color: transparent; }
.bwm-opt input:focus-visible + span { outline: 2px solid var(--blue); outline-offset: 2px; }

.bwm-static .bwm-card + .bwm-card { margin-top: 28px; padding-top: 28px; border-top: 1px solid var(--line); }
.bwm-out .bwm-card { animation: bwm-in 0.45s var(--ease); }
@keyframes bwm-in { from { opacity: 0; transform: translateY(6px); } }

.prose .bwm-for { margin: 0 0 14px; font-size: 21px; }
.bwm-for small { display: block; font-size: 14px; font-weight: 400; letter-spacing: 0; color: var(--text-3); margin-top: 4px; }
.bwm-picks { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.bwm-picks li {
    position: relative; display: flex; flex-direction: column; gap: 4px;
    padding: 14px 16px; border-radius: 14px;
    background: var(--surface-2); border: 1px solid var(--line);
}
.bwm-picks a::before { content: ''; display: inline-block; width: 8px; height: 8px; margin-right: 9px; border-radius: 50%; vertical-align: 2px; background: var(--c, var(--violet)); }
.prose .bwm-picks a:not(.btn):not(.related-card) { color: var(--text); font-weight: 700; font-size: 17px; letter-spacing: -0.015em; text-decoration: underline; text-decoration-color: var(--line-strong); text-underline-offset: 3px; }
.prose .bwm-picks a:not(.btn):not(.related-card):hover { text-decoration-color: var(--text-2); }
.bwm-picks span { font-size: 15px; line-height: 1.45; color: var(--text-2); }

.bwm-steps { counter-reset: bwm; display: flex; flex-direction: column; gap: 10px; margin-top: 18px !important; }
.bwm-steps li { counter-increment: bwm; display: grid; grid-template-columns: 28px 1fr; gap: 12px; font-size: 16px; line-height: 1.5; color: #d2d2d7; }
.bwm-steps li::before {
    content: counter(bwm); width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center;
    background: rgba(255, 255, 255, 0.07); color: var(--text); font-weight: 700; font-size: 14px; margin-top: -1px;
}
.bwm-keep { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line); font-size: 15px; color: var(--text-2); }
.bwm-keep b { color: var(--text); }
.prose .bwm-keep a { color: var(--blue); }

/* ---------- Illustration: chunking first, then a memory palace walk ---------- */
/* The script drives every moving value from one pausable clock (see the page JS).
   Without JS, or with reduced motion, the markup shows the final state. */

.bwm-chunks, .bwm-plan { display: block; width: 100%; max-width: 640px; margin: 0 auto; height: auto; overflow: visible; font-family: var(--font); }
.bwm-stage { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 10px; margin-bottom: 14px; font-size: 14px; color: var(--text-3); }
.bwm-stage b { font-size: 13px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-2); }
.bwm-palace { margin-top: 32px; padding-top: 24px; border-top: 1px solid var(--line); }

.bwm-l { font-size: 40px; font-weight: 650; fill: var(--c); text-anchor: middle; transition: fill 0.8s ease; }
.bwm-u { stroke: var(--c); stroke-width: 3; stroke-linecap: round; stroke-dasharray: 98; stroke-dashoffset: 0; }
.bwm-lab { font-size: 18px; fill: var(--text-2); text-anchor: middle; }
.bwm-count { font-size: 15px; font-weight: 600; fill: var(--text-3); }
.bwm-count-a { opacity: 0; }
.bwm-count-b { fill: var(--text); }

.bwm-walls { fill: none; stroke: rgba(255, 255, 255, 0.3); stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.bwm-room { font-size: 15px; fill: var(--text-3); }
.bwm-path { fill: none; stroke: url(#bwm-path-grad); stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.bwm-stop circle { fill: var(--c); stroke: var(--surface); stroke-width: 4; }
.bwm-item { font-size: 20px; font-weight: 600; fill: var(--text); text-anchor: middle; }
.bwm-stop { transform-box: fill-box; transform-origin: center; transition: opacity 0.4s ease, transform 0.5s var(--ease); }
.bwm-walker { fill: #fff; opacity: 0; }

.bwm-scenes { display: grid; gap: 6px; margin-top: 18px !important; }
.bwm-scenes li { position: relative; padding-left: 20px; font-size: 15px; line-height: 1.45; color: var(--text-2); transition: opacity 0.4s ease; }
.bwm-scenes li::before { content: ''; position: absolute; left: 2px; top: 0.5em; width: 8px; height: 8px; border-radius: 50%; background: var(--c); }
.bwm-scenes b { color: var(--text); font-weight: 600; }

.bwm-demo .anim-foot { margin-top: 20px; }

/* Armed: set by the script while it plays (never without JS) */
.bwm-demo.is-armed [data-g]:not(.on) .bwm-l { fill: var(--text-2); }
.bwm-demo.is-armed .bwm-stop:not(.on) { opacity: 0; transform: scale(0.6); }
.bwm-demo.is-armed .bwm-scenes li:not(.on) { opacity: 0.3; }
.bwm-demo.is-walking .bwm-walker { opacity: 1; }
.bwm-demo.no-tr * { transition: none !important; }

/* ---------- Worked examples ---------- */

.bwm-ex { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px 24px; font-size: 17px; line-height: 1.6; }
.bwm-ex > * + * { margin-top: 0.7em; }
.bwm-ex-label { display: block; font-size: 12px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--pink); }
.bwm-ex p { color: #d2d2d7; }
.bwm-ex b { color: var(--text); font-weight: 600; }


@media (max-width: 720px) {
    .bwm-opts { grid-template-columns: 1fr 1fr; }
    .bwm-picks { grid-template-columns: 1fr; }
    .bwm-ex { padding: 18px 18px; font-size: 16px; }
}
@media (max-width: 520px) {
    .bwm-lab, .bwm-count { font-size: 24px; }
    .bwm-room { font-size: 21px; }
    .bwm-item { font-size: 27px; }
}
@media (prefers-reduced-motion: reduce) {
    .bwm-out .bwm-card { animation: none; }
}
