/* bpm-to-ms.css — /bpm-to-ms/ (learning tools, plan B task B2). Loaded after studio.css (studio_assets()).
   A dub-desk calculator: the BPM is the hero numeral, the delay table a lit pad matrix, the echo strip a row of
   decaying LEDs on a two-bar grid. Tape-echo orange (--st-accent on #bpmms). Hardware stays charcoal in both
   themes (kit rule); the guide text below follows brizm's theme. */

.bpmms-hero { padding: 2rem 0 1rem; }

.bpmms {
    display: grid;
    gap: 14px;
    margin: 0.5rem 0 0;
}

/* ── panel headings ───────────────────────────────────────────────────── */
.bpmms-panel-head {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.25rem 1rem;
    margin: 0 0 0.75rem;
}
.bpmms-h {
    margin: 0;
    font-family: var(--st-font);
    font-size: 1.05rem;
    font-weight: 800;
    font-stretch: 110%;
    letter-spacing: -0.005em;
    color: var(--st-ink);
}
.bpmms-hint {
    margin: 0;
    color: var(--st-muted);
    font-size: 0.84rem;
    font-weight: 550;
    font-stretch: 94%;
}

/* ── deck: hero numeral, field, TAP, genre pads ───────────────────────── */
.bpmms-deck {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas: "tempo tap" "presets presets";
    gap: 18px 22px;
    align-items: center;
}
.bpmms-tempo { grid-area: tempo; min-width: 0; }
.bpmms-display {
    --st-display-size: clamp(4.4rem, 10.5vw, 8.4rem);
    margin: 0 0 0.9rem;
    color: var(--st-panel-ink);
    white-space: nowrap;
}
.bpmms-display .st-unit { color: var(--st-accent); }
.bpmms-display[data-len="5"] { --st-wdth: 100%; }      /* 127.5: Archivo's width axis keeps the line */
.bpmms-display[data-len="6"] { --st-wdth: 84%; }       /* 127.55 */
.bpmms-field {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
}
.bpmms-nudge {
    min-width: 3.1rem;
    padding: 0 0.7rem;
    font-variant-numeric: tabular-nums;
}
.bpmms-input {
    width: calc(6.6ch + 1.4rem);
    min-height: var(--st-target);
    padding: 0 0.6rem;
    border: 1px solid var(--st-line);
    border-radius: 9px;
    background: var(--st-sunk);
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.45);
    color: var(--st-ink);
    font-family: var(--st-font);
    font-size: 1.2rem;
    font-weight: 750;
    font-stretch: 92%;
    font-variant-numeric: tabular-nums;
    text-align: center;
}
.bpmms-input:focus { border-color: var(--st-accent); outline: none; box-shadow: 0 0 0 2px color-mix(in srgb, var(--st-accent) 45%, transparent); }

.bpmms-tap {
    grid-area: tap;
    width: clamp(10rem, 21vw, 13.5rem);
    min-height: 10rem;
    padding: 0.95rem 1rem 1rem;
    border-radius: 12px;
}
.bpmms-tap .st-pad-name {
    font-size: 2.6rem;
    font-weight: 850;
    font-stretch: 125%;
    letter-spacing: -0.02em;
}
.bpmms-tap .st-pad-meta { font-size: 0.86rem; opacity: 0.9; }

.bpmms-presets {
    grid-area: presets;
    display: grid;
    grid-template-columns: repeat(8, minmax(0, 1fr));
    gap: 6px;
}
.bpmms-preset {
    min-height: 4.3rem;
    padding: 0.5rem 0.55rem 0.55rem;
    gap: 0.2rem;
}
.bpmms-preset::before { width: 7px; height: 7px; }
.bpmms-preset .st-pad-name { font-size: 1.25rem; font-variant-numeric: tabular-nums; }
/* a long genre name (ko 드럼앤베이스, ja ヒップホップ) wraps to a second line inside the pad, never cut to an ellipsis */
.bpmms-preset .st-pad-meta { margin-top: 0; font-size: 0.74rem; max-width: 100%; overflow-wrap: anywhere; -webkit-hyphens: auto; hyphens: auto; }
.bpmms-preset.is-on { background: color-mix(in srgb, var(--st-accent) 30%, var(--st-key)); }

/* ── the matrix: seven note values × straight / dotted / triplet ──────── */
.bpmms-table {
    table-layout: fixed;
    border-collapse: separate;
    border-spacing: 6px;
    margin: -6px;
    width: calc(100% + 12px);
}
.bpmms-table th {
    padding: 0 0.15rem;
    color: var(--st-muted);
    font-size: 0.82rem;
    font-weight: 700;
    font-stretch: 94%;
    text-align: start;
    /* a note name longer than its column (pl Sześćdziesięcioczwórka, ru Шестнадцатая) wraps, hyphenated by the
       page's <html lang> where the device has a dictionary, else broken at the column edge; one that fits is untouched */
    overflow-wrap: anywhere;
    -webkit-hyphens: auto;
    hyphens: auto;
}
.bpmms-table thead th { padding-bottom: 0.1rem; }
.bpmms-table thead th:not(.bpmms-th-note)::before {     /* the column's LED */
    content: "";
    display: inline-block;
    width: 6px;
    height: 6px;
    margin-inline-end: 0.4rem;
    border-radius: 50%;
    vertical-align: 0.12em;
    background: var(--st-accent);
    opacity: 0.55;
}
.bpmms-th-note { width: 5.2rem; }
.bpmms-table tbody th { vertical-align: middle; }
.bpmms-frac {
    display: block;
    color: var(--st-ink);
    font-size: 1.3rem;
    font-weight: 800;
    font-stretch: 112%;
    line-height: 1;
    font-variant-numeric: tabular-nums;
}
.bpmms-note-name {
    display: block;
    margin-top: 0.2rem;
    font-size: 0.72rem;
    font-weight: 600;
}
.bpmms-table td { padding: 0; }

.bpmms-cell {
    position: relative;
    display: block;
    width: 100%;
    min-height: 3.75rem;
    padding: 0.55rem 0.7rem 0.5rem 1.35rem;
    border: 0;
    border-radius: 7px;
    background: var(--st-key);
    color: var(--st-key-ink);
    font: inherit;
    font-family: var(--st-font);
    text-align: start;
    cursor: pointer;
    box-shadow: inset 0 -4px 0 rgba(0, 0, 0, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.08);
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    transition: transform 0.06s, background-color 0.08s, filter 0.08s;
}
.bpmms-cell::before {               /* the cell's LED */
    content: "";
    position: absolute;
    top: 0.72rem;
    left: 0.62rem;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.4);
    box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.5);
}
.bpmms-cell:hover { filter: brightness(1.12); }
.bpmms-cell:active { transform: translateY(1px); }
.bpmms-ms {
    font-size: 1.32rem;
    font-weight: 780;
    font-stretch: 84%;
    line-height: 1;
    letter-spacing: -0.01em;
    font-variant-numeric: tabular-nums lining-nums;
}
.bpmms-unit {
    margin-inline-start: 0.2em;
    font-size: 0.72rem;
    font-weight: 650;
    color: var(--st-muted);
}
.bpmms-hz {
    display: block;
    margin-top: 0.28rem;
    color: var(--st-muted);
    font-size: 0.74rem;
    font-weight: 600;
    font-stretch: 92%;
    font-variant-numeric: tabular-nums;
}
.bpmms-cell[aria-pressed="true"] {
    background: var(--st-accent);
    color: var(--st-on-accent);
    box-shadow: inset 0 3px 0 rgba(0, 0, 0, 0.22), 0 0 22px -6px var(--st-accent);
    transform: translateY(1px);
}
.bpmms-cell[aria-pressed="true"]::before { background: var(--st-led); box-shadow: 0 0 8px 2px var(--st-led); }
.bpmms-cell[aria-pressed="true"] .bpmms-unit,
.bpmms-cell[aria-pressed="true"] .bpmms-hz { color: rgba(28, 12, 0, 0.7); }
.bpmms-tag {                         /* a tape-label sticker on the dub delay */
    position: absolute;
    top: 0.42rem;
    right: 0.42rem;
    padding: 0.08rem 0.36rem 0.12rem;
    border-radius: 3px;
    background: var(--st-808-yellow);
    color: #17191B;
    font-size: 0.66rem;
    font-weight: 800;
    font-stretch: 100%;
    line-height: 1.1;
    transform: rotate(-4deg);
    box-shadow: 0 1px 0 rgba(0, 0, 0, 0.35);
}

/* ── Hear it ──────────────────────────────────────────────────────────── */
.bpmms-hear-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 14px 22px;
    margin: 0 0 14px;
}
.bpmms-hear .st-btn--play { flex: none; background: var(--st-accent); }
.bpmms-hear .st-btn--play[aria-pressed="true"] { background: var(--st-808-red); }
.bpmms-hear .st-btn--play:disabled { opacity: 0.35; cursor: not-allowed; }
.bpmms-now { min-width: 11rem; }
.bpmms-now .bpmms-h { color: var(--st-muted); font-size: 0.86rem; font-weight: 700; font-stretch: 100%; }
.bpmms-now-val {
    margin: 0.1rem 0 0;
    font-size: 1.15rem;
    font-weight: 750;
    font-stretch: 100%;
    line-height: 1.1;
    white-space: nowrap;
}
.bpmms-now-ms {
    margin-inline-start: 0.35rem;
    color: var(--st-accent);
    font-size: 1.85rem;
    font-weight: 850;
    font-stretch: 112%;
    letter-spacing: -0.02em;
    font-variant-numeric: tabular-nums;
}
.bpmms-now-unit { margin-inline-start: 0.15rem; color: var(--st-muted); font-size: 0.8rem; font-weight: 700; }
.bpmms-fb { flex: 1 1 11rem; max-width: 17rem; }
.bpmms-toggle {
    gap: 0.5rem;
}
.bpmms-toggle::before {
    content: "";
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #40454C;
    box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.6);
}
.bpmms-toggle[aria-pressed="true"]::before { background: var(--st-accent); box-shadow: 0 0 7px var(--st-accent); }

.bpmms-echo-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(9rem, 13rem);
    gap: 12px;
    align-items: stretch;
}
.bpmms-strip { margin: 0; min-width: 0; }
.bpmms-echo {
    display: block;
    width: 100%;
    height: auto;
    border-radius: 8px;
    background: var(--st-well);
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.6);
}
.bpmms-scope { height: auto; min-height: 5.75rem; }
.bpmms-echo-readout {
    margin: 0.55rem 0 0;
    color: var(--st-muted);
    font-family: var(--st-font);
    font-size: 0.82rem;
    font-weight: 550;
    line-height: 1.45;
}
.bpmms-echo-sum { color: var(--st-ink); font-weight: 750; font-variant-numeric: tabular-nums; }

.bpmms-lane { stroke: rgba(255, 255, 255, 0.08); stroke-width: 1; stroke-dasharray: 2 6; }
.bpmms-barline { stroke: rgba(255, 255, 255, 0.2); stroke-width: 1.5; }
.bpmms-step { fill: var(--st-808-red); opacity: 0.2; }
.bpmms-step[data-group="1"] { fill: var(--st-808-orange); }
.bpmms-step[data-group="2"] { fill: var(--st-808-yellow); }
.bpmms-step[data-group="3"] { fill: var(--st-808-ivory); }
.bpmms-step.is-beat { opacity: 0.4; }
.bpmms-step.is-on { opacity: 1; }
.bpmms-dry { fill: var(--st-808-ivory); opacity: 0.85; }
.bpmms-dry + .bpmms-dry { opacity: 0.4; }
.bpmms-dry.is-hit { fill: #fff; opacity: 1; }
.bpmms-echo-dot {
    fill: var(--st-accent);
    transition: fill 0.12s;
}
.bpmms-echo-dot.is-wrapped { fill: none; stroke: var(--st-accent); stroke-width: 2; }
.bpmms-echo-dot.is-hit { fill: #FFE1CC; stroke: #FFE1CC; opacity: 1 !important; filter: drop-shadow(0 0 5px var(--st-accent)); }

.bpmms-too-long {
    margin: 12px 0 0;
    padding: 0.2rem 0 0.2rem 0.8rem;
    border-inline-start: 3px solid var(--st-led);
    color: var(--st-ink);
    font-size: 0.9rem;
    font-weight: 650;
}

/* ── reverb ───────────────────────────────────────────────────────────── */
.bpmms-rv-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
}
.bpmms-rv {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 0.7rem;
    border-radius: 10px;
    background: var(--st-sunk);
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.45);
}
.bpmms-rv-name {
    margin: 0 0 0.15rem;
    color: var(--st-ink);
    font-size: 1rem;
    font-weight: 800;
    font-stretch: 108%;
    line-height: 1.15;
}
.bpmms-rv-len {
    display: block;
    color: var(--st-muted);
    font-size: 0.74rem;
    font-weight: 600;
    font-stretch: 94%;
}
.bpmms-rv-btn {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0 0.3rem;
    min-height: var(--st-target);
    padding: 0.35rem 0.55rem;
    border: 1px solid transparent;
    border-radius: 7px;
    background: var(--st-key);
    color: var(--st-key-ink);
    font: inherit;
    font-family: var(--st-font);
    text-align: start;
    cursor: pointer;
    box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.28);
}
.bpmms-rv-btn:hover { border-color: var(--st-accent); }
.bpmms-rv-k { flex: 1 0 100%; color: var(--st-muted); font-size: 0.7rem; font-weight: 650; }
.bpmms-rv-v { font-size: 1.1rem; font-weight: 780; font-stretch: 86%; font-variant-numeric: tabular-nums; }

/* ── copy toast ───────────────────────────────────────────────────────── */
.bpmms-toast {
    position: fixed;
    left: 50%;
    bottom: 5.5rem;
    z-index: 40;
    margin: 0;
    padding: 0.6rem 1rem 0.6rem 0.85rem;
    border-inline-start: 4px solid var(--st-accent);
    border-radius: 10px;
    background: var(--st-panel-2);
    color: var(--st-panel-ink);
    font-size: 0.92rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    box-shadow: 0 14px 30px -12px rgba(0, 0, 0, 0.7);
    transform: translateX(-50%);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s;
}
.bpmms-toast:empty { display: none; }
.bpmms-toast.is-shown { opacity: 1; }

/* ── the guide below the tool ─────────────────────────────────────────── */
.bpmms-guide {
    max-width: 68ch;
    margin: 3rem auto 0;
    color: var(--text-dim);
    font-size: 0.95rem;
    line-height: 1.65;
}
.bpmms-guide h2 {
    margin: 2.2rem 0 0.6rem;
    color: var(--text);
    font-family: "Archivo", var(--heading-font, sans-serif);
    font-size: 1.4rem;
    font-weight: 800;
    font-stretch: 108%;
    letter-spacing: -0.01em;
    line-height: 1.2;
}
.bpmms-guide h2:first-child { margin-top: 0; }
.bpmms-guide p { margin: 0 0 0.9rem; }
.bpmms-formula {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}
.bpmms-formula span {
    padding: 0.3rem 0.65rem;
    border: 1px solid var(--border, rgba(124, 116, 214, 0.24));
    border-inline-start: 3px solid #FF6A1F;
    border-radius: 7px;
    color: var(--text);
    font-family: "Archivo", sans-serif;
    font-size: 0.9rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

/* ── narrow screens ───────────────────────────────────────────────────── */
@media (max-width: 760px) {
    .bpmms-deck {
        grid-template-columns: minmax(0, 1fr);
        grid-template-areas: "tempo" "tap" "presets";
    }
    .bpmms-tap { width: 100%; min-height: 6.5rem; }
    .bpmms-tap .st-pad-name { font-size: 2.2rem; }
    .bpmms-presets { grid-template-columns: repeat(4, minmax(0, 1fr)); }
    .bpmms-echo-row { grid-template-columns: minmax(0, 1fr); }
    .bpmms-scope { height: 4.5rem; min-height: 0; }
    .bpmms-rv-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 480px) {
    .bpmms-table { border-spacing: 4px; margin: -4px; width: calc(100% + 8px); }
    .bpmms-th-note { width: 3.4rem; }
    .bpmms-frac { font-size: 1.05rem; }
    .bpmms-note-name { font-size: 0.64rem; }
    .bpmms-cell { min-height: 3.4rem; padding: 0.5rem 0.4rem 0.45rem 0.95rem; }
    .bpmms-cell::before { top: 0.66rem; left: 0.42rem; width: 5px; height: 5px; }
    .bpmms-ms { font-size: 1.04rem; font-stretch: 76%; }
    .bpmms-cell .bpmms-unit { display: none; }
    .bpmms-hz { font-size: 0.66rem; }
    .bpmms-tag { top: auto; bottom: 0.32rem; right: 0.3rem; font-size: 0.58rem; }
    .bpmms-nudge { min-width: 2.75rem; padding: 0 0.45rem; font-size: 0.85rem; }
    .bpmms-hear-head { gap: 12px 16px; }
    .bpmms-fb { max-width: none; flex-basis: 100%; }
}

@media (prefers-reduced-motion: reduce) {
    .bpmms-cell,
    .bpmms-echo-dot,
    .bpmms-toast { transition: none; }
}

@media print {
    .bpmms-hear,
    .bpmms-tap,
    .bpmms-presets,
    .bpmms-field,
    .bpmms-toast { display: none; }
}
