/* Rank guide (page module [site:rank-guide]). 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 detail card and the norms table are boxed. */
.rkg {
    --rkg-ink: var(--gym-dark, #24211e);
    --rkg-muted: color-mix(in srgb, var(--rkg-ink) 62%, transparent);
    --rkg-line: color-mix(in srgb, var(--rkg-ink) 14%, transparent);
    --rkg-accent: var(--gym-accent, #db5a32);
    --rkg-strong: var(--gym-button, var(--rkg-accent));
    --rkg-paper: var(--gym-paper, #f6f1ea);
    margin-block: 32px;
    color: var(--rkg-ink);
    font-family: var(--gym-font-body, 'Montserrat', ui-sans-serif, system-ui, sans-serif);
    font-size: .9375rem;
    line-height: 1.5;
}

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

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

/* ---------- Ladder ---------- */
.rkg__ladder { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(46px, 1fr); gap: clamp(4px, 1vw, 12px); align-items: end; overflow-x: auto; padding-bottom: 4px; }
.rkg__step {
    display: grid; grid-template-rows: auto 150px auto; justify-items: center; gap: 6px; min-width: 0; padding: 8px 2px 6px;
    border: 1px solid transparent; border-radius: 14px; background: transparent; color: inherit; font: inherit; cursor: pointer;
    transition: background-color .15s ease, border-color .15s ease, opacity .15s ease;
}
.rkg__step:hover { background: color-mix(in srgb, var(--rkg-accent) 6%, transparent); }
.rkg__step:focus-visible, .rkg__btn:focus-visible, .rkg__number:focus-visible, .rkg__switch-input:focus-visible + .rkg__switch-track { outline: 2px solid var(--rkg-accent); outline-offset: 2px; }
.rkg__points { font-size: .8rem; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--rkg-muted); }
.rkg__bar {
    align-self: end; width: min(100%, 38px); height: var(--rkg-h, 50%); min-height: 10px; border-radius: 10px 10px 4px 4px;
    background: color-mix(in srgb, var(--rkg-accent) 22%, transparent); transition: height .35s cubic-bezier(.22, 1, .36, 1), background-color .2s ease;
}
.rkg__step--sport .rkg__bar { background: color-mix(in srgb, var(--rkg-accent) 48%, transparent); }
.rkg__step--top .rkg__bar { background: color-mix(in srgb, var(--rkg-strong) 78%, transparent); }
.rkg__label { font-size: .72rem; font-weight: 700; letter-spacing: .02em; text-align: center; }
.rkg__step[aria-checked="true"] { border-color: var(--rkg-line); background: color-mix(in srgb, var(--rkg-paper) 45%, #fff); }
.rkg__step[aria-checked="true"] .rkg__bar { background: var(--rkg-accent); }
.rkg__step[aria-checked="true"] .rkg__points, .rkg__step[aria-checked="true"] .rkg__label { color: var(--rkg-ink); }
.rkg__step.is-locked { opacity: .42; }

/* ---------- Controls ---------- */
.rkg__controls { display: grid; gap: 16px 28px; margin-top: 18px; padding-top: 18px; border-top: 1px solid var(--rkg-line); }
@media (min-width: 720px) { .rkg__controls { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: start; } }
.rkg__field { display: grid; gap: 6px; }
.rkg__field-label { color: var(--rkg-muted); font-size: .72rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.rkg__stepper { display: flex; align-items: center; gap: 4px; }
.rkg__btn {
    display: grid; flex: none; place-items: center; width: 40px; height: 40px; padding: 0; border: 1px solid var(--rkg-line); border-radius: 12px;
    background: transparent; color: var(--rkg-ink); font: inherit; font-size: 1.15rem; line-height: 1; cursor: pointer; transition: border-color .15s ease, color .15s ease;
}
.rkg__btn:hover { border-color: var(--rkg-accent); color: var(--rkg-accent); }
.rkg__number {
    width: 3.6ch; min-width: 0; padding: 0; border: 0; background: transparent; color: var(--rkg-ink); font: inherit; font-size: 1.75rem; font-weight: 600;
    text-align: right; letter-spacing: -.02em; font-variant-numeric: tabular-nums; -moz-appearance: textfield; appearance: textfield;
}
.rkg__number::-webkit-outer-spin-button, .rkg__number::-webkit-inner-spin-button { margin: 0; -webkit-appearance: none; }
.rkg__unit { margin-right: 4px; color: var(--rkg-muted); font-size: .85rem; }
.rkg__hint { color: var(--rkg-muted); font-size: .85rem; }

.rkg__switch { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: 12px; cursor: pointer; }
.rkg__switch-input { position: absolute; opacity: 0; pointer-events: none; }
.rkg__switch-track { position: relative; width: 44px; height: 26px; border-radius: 999px; background: var(--rkg-line); transition: background-color .2s ease; }
.rkg__switch-track::after { position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgb(0 0 0 / 25%); content: ''; transition: transform .2s ease; }
.rkg__switch-input:checked + .rkg__switch-track { background: var(--rkg-accent); }
.rkg__switch-input:checked + .rkg__switch-track::after { transform: translateX(18px); }
.rkg__switch-text { display: grid; gap: 1px; }
.rkg__switch-text strong { font-size: .95rem; font-weight: 600; }
.rkg__switch-text small { color: var(--rkg-muted); font-size: .85rem; }

/* ---------- Detail card ---------- */
.rkg__detail { margin-top: 22px; padding: clamp(16px, 2.6vw, 26px); border: 1px solid var(--rkg-line); border-radius: 20px; background: #fff; }
.rkg__detail-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 6px 16px; margin-bottom: 14px; padding-bottom: 14px; border-bottom: 1px solid var(--rkg-line); }
.rkg__detail-title { font-size: clamp(1.2rem, 2.4vw, 1.5rem); font-weight: 650; letter-spacing: -.02em; }
.rkg__score { display: flex; align-items: baseline; gap: 8px; }
.rkg__score strong { font-size: clamp(2rem, 4vw, 2.75rem); font-weight: 650; letter-spacing: -.03em; line-height: 1; font-variant-numeric: tabular-nums; color: var(--rkg-accent); }
.rkg__score span { color: var(--rkg-muted); font-size: .9rem; }
.rkg__rows { display: grid; gap: 14px; }
.rkg__row { display: grid; grid-template-columns: 40px minmax(0, 1fr); gap: 14px; align-items: start; }
.rkg__icon { display: block; width: 40px; height: 40px; border-radius: 12px; background: color-mix(in srgb, var(--rkg-accent) 12%, transparent); position: relative; }
.rkg__icon::after { position: absolute; inset: 8px; background: var(--rkg-accent); -webkit-mask: var(--rkg-icon) center / contain no-repeat; mask: var(--rkg-icon) center / contain no-repeat; content: ''; }
.rkg__row-label { color: var(--rkg-muted); font-size: .72rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.rkg__row-value { font-size: 1rem; font-weight: 600; line-height: 1.4; }
.rkg__row-extra { margin-top: 2px; color: var(--rkg-muted); font-size: .9rem; }
.rkg__next { display: flex; align-items: center; gap: 10px; margin-top: 16px; padding: 12px 14px; border-radius: 14px; background: color-mix(in srgb, var(--rkg-accent) 8%, transparent); font-size: .9rem; font-weight: 600; }
.rkg__next .rkg__icon { width: 28px; height: 28px; border-radius: 9px; flex: none; }
.rkg__next .rkg__icon::after { inset: 5px; }
.rkg__note { margin-top: 12px; color: var(--rkg-muted); font-size: .85rem; line-height: 1.5; }

.rkg__icon--age { --rkg-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%3Crect x='7' y='10' width='34' height='31' rx='5'/%3E%3Cpath d='M7 20h34M16 6v8M32 6v8'/%3E%3C/svg%3E"); }
.rkg__icon--program { --rkg-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='M15 14h26M15 24h26M15 34h26'/%3E%3Cpath d='M7 14h.01M7 24h.01M7 34h.01' stroke-width='5'/%3E%3C/svg%3E"); }
.rkg__icon--points { --rkg-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='24' r='16'/%3E%3Ccircle cx='24' cy='24' r='7'/%3E%3C/svg%3E"); }
.rkg__icon--where { --rkg-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='M10 42V6'/%3E%3Cpath d='M10 8h26l-6 9 6 9H10'/%3E%3C/svg%3E"); }
.rkg__icon--next { --rkg-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='4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M9 24h30M26 10l14 14-14 14'/%3E%3C/svg%3E"); }

/* ---------- Norms table ---------- */
.rkg__sheet { margin-top: clamp(26px, 3.6vw, 40px); }
.rkg__sheet-title { margin-bottom: 12px; font-size: 1.05rem; font-weight: 600; letter-spacing: -.01em; }
.rkg__table-wrap { overflow-x: auto; border: 1px solid var(--rkg-line); border-radius: 18px; -webkit-overflow-scrolling: touch; }
.rkg .rkg__table { display: table; width: 100%; min-width: 600px; 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; }
.rkg .rkg__table :is(th, td) { min-width: 0; padding: 10px 12px; border: 0; border-bottom: 1px solid var(--rkg-line); background: transparent; font-size: .875rem; line-height: 1.4; text-align: left; vertical-align: middle; text-transform: none; letter-spacing: normal; }
.rkg .rkg__table thead th { color: var(--rkg-muted); font-size: .7rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; white-space: nowrap; }
.rkg .rkg__table tbody th { font-weight: 600; white-space: nowrap; }
.rkg .rkg__table td { white-space: nowrap; }
.rkg .rkg__table tbody tr:last-child :is(th, td) { border-bottom: 0; }
.rkg .rkg__table tbody tr, .rkg .rkg__table tbody tr:nth-child(even) { background: transparent; }
.rkg .rkg__table tr.is-current :is(th, td) { background: color-mix(in srgb, var(--rkg-accent) 10%, transparent); }

@media (max-width: 520px) {
    .rkg__step { grid-template-rows: auto 110px auto; padding-inline: 0; }
    .rkg__label { font-size: .66rem; }
}
@media (prefers-reduced-motion: reduce) { .rkg * { transition: none !important; } }
