/* Score builder (page module [site:score-builder]). Loaded only on pages that render it.
   Colours come from the per-site brand tokens. One container per level: the module root is flat,
   only the result card and the tables are boxed. */
.scb {
    --scb-ink: var(--gym-dark, #24211e);
    --scb-muted: color-mix(in srgb, var(--scb-ink) 62%, transparent);
    --scb-line: color-mix(in srgb, var(--scb-ink) 14%, transparent);
    --scb-accent: var(--gym-accent, #db5a32);
    --scb-strong: var(--gym-button, var(--scb-accent));
    --scb-paper: var(--gym-paper, #f6f1ea);
    margin-block: 32px;
    color: var(--scb-ink);
    font-family: var(--gym-font-body, 'Montserrat', ui-sans-serif, system-ui, sans-serif);
    font-size: .9375rem;
    line-height: 1.5;
}

.scb *, .scb *::before, .scb *::after { box-sizing: border-box; }
.scb [hidden] { display: none !important; }

.scb__head { display: grid; gap: 6px; margin-bottom: clamp(18px, 2.4vw, 26px); }
.scb__eyebrow { color: var(--scb-accent); font-size: .7rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; }
.scb__title { font-size: clamp(1.25rem, 2.6vw, 1.6rem); font-weight: 600; line-height: 1.2; letter-spacing: -.02em; }
.scb__lead { max-width: 62ch; color: var(--scb-muted); }

.scb__bar-top { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px; padding-bottom: 12px; }
.scb__badge { padding: 4px 12px; border-radius: 999px; background: color-mix(in srgb, var(--scb-accent) 12%, transparent); font-size: .78rem; font-weight: 700; }
.scb__actions { display: flex; gap: 16px; }
.scb__link { padding: 0; border: 0; background: none; color: var(--scb-accent); font: inherit; font-size: .85rem; font-weight: 650; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.scb__link:hover { color: var(--scb-strong); }
.scb__link:focus-visible, .scb__btn:focus-visible, .scb__number:focus-visible, .scb__group summary:focus-visible { outline: 2px solid var(--scb-accent); outline-offset: 2px; }

/* ---------- Layout ---------- */
.scb__layout { display: grid; gap: 24px; align-items: start; }
@media (min-width: 980px) {
    .scb__layout { grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); gap: 36px; }
    .scb__result { position: sticky; top: 24px; }
}

/* ---------- Parts ---------- */
.scb__part { padding: 16px 0; border-top: 1px solid var(--scb-line); }
.scb__part-head { display: grid; grid-template-columns: 40px minmax(0, 1fr) auto; gap: 14px; align-items: start; }
.scb__part-title { font-size: 1rem; font-weight: 650; }
.scb__part-hint { margin-top: 2px; color: var(--scb-muted); font-size: .85rem; line-height: 1.45; }
.scb__part-value { color: var(--scb-accent); font-size: 1.25rem; font-weight: 650; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.scb__rows { display: grid; gap: 4px; margin-top: 10px; padding-left: 54px; }
.scb__row { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 4px 12px; align-items: center; padding: 6px 0; }
.scb__row-name { font-size: .92rem; font-weight: 600; line-height: 1.35; }
.scb__row-name small { display: block; color: var(--scb-muted); font-size: .8rem; font-weight: 500; }
.scb__row-value { color: var(--scb-muted); font-size: .85rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
.scb__row > .scb__stepper:last-child:nth-child(2) { grid-column: 2 / -1; }

.scb__stepper { display: inline-flex; align-items: center; gap: 4px; }
.scb__btn {
    display: grid; flex: none; place-items: center; width: 36px; height: 36px; padding: 0; border: 1px solid var(--scb-line); border-radius: 11px;
    background: transparent; color: var(--scb-ink); font: inherit; font-size: 1.1rem; line-height: 1; cursor: pointer; transition: border-color .15s ease, color .15s ease;
}
.scb__btn:hover { border-color: var(--scb-accent); color: var(--scb-accent); }
.scb__number {
    width: 5.2ch; min-width: 0; padding: 6px 4px; border: 1px solid transparent; border-radius: 9px; background: transparent; color: var(--scb-ink);
    font: inherit; font-weight: 650; text-align: center; font-variant-numeric: tabular-nums; -moz-appearance: textfield; appearance: textfield;
}
.scb__number:hover { border-color: var(--scb-line); }
.scb__number::-webkit-outer-spin-button, .scb__number::-webkit-inner-spin-button { margin: 0; -webkit-appearance: none; }

.scb__groups { display: grid; gap: 6px; margin-top: 10px; padding-left: 54px; }
.scb__group { border: 1px solid var(--scb-line); border-radius: 14px; }
.scb__group summary { padding: 10px 14px; font-size: .9rem; font-weight: 650; cursor: pointer; list-style: none; display: flex; align-items: center; justify-content: space-between; }
.scb__group summary::-webkit-details-marker { display: none; }
.scb__group summary::after { content: '+'; color: var(--scb-muted); font-size: 1.1rem; line-height: 1; }
.scb__group[open] summary::after { content: '\2212'; }
.scb__group .scb__rows { margin: 0; padding: 0 14px 10px; }

/* ---------- Result card ---------- */
.scb__result { padding: clamp(16px, 2.6vw, 26px); border: 1px solid var(--scb-line); border-radius: 20px; background: #fff; }
.scb__result-label { color: var(--scb-muted); font-size: .72rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.scb__total { margin-top: 4px; color: var(--scb-accent); font-size: clamp(2.4rem, 5vw, 3.4rem); font-weight: 650; letter-spacing: -.03em; line-height: 1.05; font-variant-numeric: tabular-nums; }
.scb__formula { margin-top: 2px; color: var(--scb-muted); font-size: .85rem; }
.scb__meter { display: flex; gap: 2px; height: 14px; margin-top: 16px; overflow: hidden; border-radius: 999px; background: color-mix(in srgb, var(--scb-ink) 6%, transparent); }
.scb__seg { flex: 1 1 0; min-width: 4px; transition: flex-grow .3s ease; }
.scb__seg--d, .scb__item--d .scb__dot { background: var(--scb-accent); }
.scb__seg--a, .scb__item--a .scb__dot { background: color-mix(in srgb, var(--scb-accent) 62%, var(--scb-paper)); }
.scb__seg--e, .scb__item--e .scb__dot { background: color-mix(in srgb, var(--scb-accent) 34%, var(--scb-paper)); }
.scb .scb__list { display: grid; gap: 2px; margin: 14px 0 0; padding: 0; list-style: none; }
.scb .scb__item { display: grid; grid-template-columns: 10px minmax(0, 1fr) auto; gap: 10px; align-items: center; margin: 0; padding: 6px 0; font-size: .92rem; }
.scb .scb__item::before { content: none; }
.scb__dot { width: 10px; height: 10px; border-radius: 50%; }
.scb__item--p .scb__dot { background: var(--scb-ink); opacity: .45; }
.scb__item-sum { font-weight: 650; font-variant-numeric: tabular-nums; }
.scb__insight { margin-top: 12px; padding: 10px 14px; border-radius: 14px; background: color-mix(in srgb, var(--scb-accent) 8%, transparent); font-size: .88rem; font-weight: 600; }
.scb__note { margin-top: 14px; color: var(--scb-muted); font-size: .85rem; line-height: 1.5; }

/* ---------- Icons ---------- */
.scb__icon { display: block; flex: none; width: 40px; height: 40px; border-radius: 12px; background: color-mix(in srgb, var(--scb-accent) 12%, transparent); position: relative; }
.scb__icon::after { position: absolute; inset: 8px; background: var(--scb-accent); -webkit-mask: var(--scb-icon) center / contain no-repeat; mask: var(--scb-icon) center / contain no-repeat; content: ''; }
.scb__icon--d { --scb-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 48 48' fill='none' stroke='%23000' stroke-width='3.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 40h10V30h10V19h10V8h6'/%3E%3C/svg%3E"); }
.scb__icon--a { --scb-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 48 48' fill='none' stroke='%23000' stroke-width='3.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M18 36V10l20-4v26'/%3E%3Ccircle cx='13' cy='37' r='5'/%3E%3Ccircle cx='33' cy='33' r='5'/%3E%3C/svg%3E"); }
.scb__icon--e { --scb-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 48 48' fill='none' stroke='%23000' stroke-width='5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M9 25l10 10 20-22'/%3E%3C/svg%3E"); }
.scb__icon--p { --scb-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 48 48' fill='none' stroke='%23000' stroke-width='3.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='24' cy='26' r='15'/%3E%3Cpath d='M24 18v9l6 4M19 5h10'/%3E%3C/svg%3E"); }

/* ---------- Tables ---------- */
.scb__sheet { margin-top: clamp(26px, 3.6vw, 40px); }
.scb__sheet-title { margin-bottom: 12px; font-size: 1.05rem; font-weight: 600; letter-spacing: -.01em; }
.scb__sheet-title--second { margin-top: 28px; }
.scb__table-wrap { overflow-x: auto; border: 1px solid var(--scb-line); border-radius: 18px; -webkit-overflow-scrolling: touch; }
.scb .scb__table { display: table; width: 100%; min-width: 560px; max-width: none; margin: 0; border: 0; border-radius: 0; border-collapse: collapse; background: transparent; color: inherit; font-size: .875rem; font-variant-numeric: tabular-nums; }
.scb .scb__table :is(th, td) { min-width: 0; padding: 10px 12px; border: 0; border-bottom: 1px solid var(--scb-line); background: transparent; font-size: .875rem; line-height: 1.4; text-align: left; vertical-align: top; text-transform: none; letter-spacing: normal; }
.scb .scb__table thead th { color: var(--scb-muted); font-size: .7rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; white-space: nowrap; }
.scb .scb__table tbody th { font-weight: 600; }
.scb .scb__table td.scb__wrap { white-space: normal; }
.scb .scb__table tbody tr:last-child :is(th, td) { border-bottom: 0; }
.scb .scb__table tbody tr, .scb .scb__table tbody tr:nth-child(even) { background: transparent; }

@media (max-width: 520px) {
    .scb__rows, .scb__groups { padding-left: 0; }
    .scb__part-head { grid-template-columns: 40px minmax(0, 1fr); }
    .scb__part-value { grid-column: 2; }
}
@media (prefers-reduced-motion: reduce) { .scb * { transition: none !important; } }
