/* Speaker cleaner (speaker_cleaner). Свой вид: «водная» сцена — глубокий синий, бирюзово-голубой акцент;
   большая сетка динамика в центре — она же кнопка, вокруг кольцо прогресса; при звуке из сетки летят
   капли (в такт импульсам через data-pulse). Раскладка — container query по ширине инструмента.
   Префикс .spkcl. */

.spkcl {
    /* --- токены --- */
    --sc-font: "Inter", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
    --sc-bg: #0d3557;
    --sc-bg-2: #082440;
    --sc-panel: rgba(255, 255, 255, .07);
    --sc-border: rgba(255, 255, 255, .16);
    --sc-ink: #eaf6ff;
    --sc-muted: #a7c3da;
    --sc-aqua: #3cc8ff;
    --sc-aqua-2: #1aa6e0;
    --sc-aqua-ink: #04223a;
    --sc-plate: #12324f;
    --sc-plate-2: #0a2238;
    --sc-hole: #04121f;
    --sc-drop: #8fe0ff;
    --sc-track: rgba(255, 255, 255, .16);
    --sc-ok: #4fd18b;
    --sc-radius: 16px;
    --sc-btn-radius: 10px;
    --sc-grille: 300px;

    container: spkcl / inline-size;
    max-width: 760px;
    margin: 0 auto;
    padding: 16px clamp(12px, 3vw, 24px) 20px;
    font-family: var(--sc-font);
    color: var(--sc-ink);
    background: radial-gradient(120% 90% at 50% 10%, var(--sc-bg) 0%, var(--sc-bg-2) 100%);
    border: 1px solid #1b4a73;
    border-radius: var(--sc-radius);
    -webkit-tap-highlight-color: transparent;
}

.spkcl__ic { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.spkcl__ic .spkcl__fill { fill: currentColor; stroke: none; }

/* Подготовка: три коротких пункта */
.spkcl__prep {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 6px 18px;
    margin: 0 0 6px;
    padding: 0;
    list-style: none;
    font-size: 14px;
    color: var(--sc-muted);
}
.spkcl__prep li { display: inline-flex; align-items: center; gap: 6px; }
.spkcl__prep .spkcl__ic { color: var(--sc-aqua); width: 18px; height: 18px; }
/* Датчик наклона: телефон держат динамиком вниз — пункт горит зелёным; во время прогона не так — мигает */
.spkcl__prep li { transition: color .25s; }
.spkcl[data-down="1"] .spkcl__prep-down,
.spkcl[data-down="1"] .spkcl__prep-down .spkcl__ic { color: var(--sc-ok); }
.spkcl[data-stage="run"][data-down="0"] .spkcl__prep-down { color: #ffd166; animation: spkcl-warn 1s ease-in-out infinite; }
@keyframes spkcl-warn { 50% { opacity: .45; } }

/* --- Сетка-кнопка --- */
.spkcl__stage {
    position: relative;
    width: var(--sc-grille);
    max-width: 100%;
    aspect-ratio: 1;
    margin: 6px auto 0;
}
.spkcl__grille { display: block; width: 100%; height: 100%; overflow: visible; }
.spkcl__ring-bg { fill: none; stroke: var(--sc-track); stroke-width: 6; }
.spkcl__ring { fill: none; stroke: var(--sc-aqua); stroke-width: 6; stroke-linecap: round; stroke-dasharray: 0 1000; }
.spkcl__plate { fill: var(--sc-plate); stroke: #24547e; stroke-width: 2; }
.spkcl__holes circle { fill: var(--sc-hole); }
.spkcl[data-stage="run"] .spkcl__plate { stroke: var(--sc-aqua); }
.spkcl[data-stage="run"][data-pulse="1"] .spkcl__plate { filter: drop-shadow(0 0 14px rgba(60, 200, 255, .45)); }

/* Капли: из центра наружу, только когда звучит */
.spkcl__drop { fill: var(--sc-drop); opacity: 0; transform-box: view-box; transform-origin: 100px 100px; }
.spkcl[data-stage="run"][data-pulse="1"] .spkcl__drop {
    animation: spkcl-fly 0.9s ease-out infinite;
    animation-delay: calc(var(--i) * -0.1s);
}
@keyframes spkcl-fly {
    0%   { opacity: 0; transform: rotate(var(--a)) translateY(-30px) scale(.6); }
    20%  { opacity: .95; }
    100% { opacity: 0; transform: rotate(var(--a)) translateY(-112px) scale(1); }
}

.spkcl__go {
    position: absolute;
    left: 50%;
    top: 50%;
    width: 46%;
    aspect-ratio: 1;
    transform: translate(-50%, -50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    padding: 6px;
    border-radius: 50%;
    border: 0;
    background: radial-gradient(circle at 35% 30%, #7fe0ff 0%, var(--sc-aqua) 45%, var(--sc-aqua-2) 100%);
    color: var(--sc-aqua-ink);
    box-shadow: 0 6px 22px rgba(0, 0, 0, .35);
}
.spkcl__go:hover, .spkcl__go:focus-visible { color: var(--sc-aqua-ink); filter: brightness(1.05); }
.spkcl__go:disabled { opacity: .75; color: var(--sc-aqua-ink); }
.spkcl__go-ic svg { width: 26px; height: 26px; fill: currentColor; }
.spkcl__ic-stop { display: none; }
.spkcl[data-stage="run"] .spkcl__ic-play { display: none; }
.spkcl[data-stage="run"] .spkcl__ic-stop { display: block; }
.spkcl__go-txt { font-size: 19px; font-weight: 700; line-height: 1.1; text-align: center; }
.spkcl__go-sub { font-size: 13px; font-weight: 600; opacity: .8; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* --- Панель --- */
.spkcl__panel {
    margin-top: 12px;
    padding: 12px 16px 14px;
    border: 1px solid var(--sc-border);
    border-radius: 12px;
    background: var(--sc-panel);
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.spkcl__msg { margin: 0; min-height: 2.9em; font-size: 15px; line-height: 1.45; text-align: center; }

.spkcl__ask { display: none; justify-content: center; gap: 10px; }
.spkcl[data-stage="ask"] .spkcl__ask { display: flex; }
.spkcl__btn {
    min-height: 44px;
    min-width: 160px;
    padding: 8px 18px;
    border-radius: var(--sc-btn-radius);
    border: 1px solid var(--sc-border);
    background: transparent;
    color: var(--sc-ink);
    font-size: 15.5px;
    font-weight: 600;
}
.spkcl__btn--yes { background: var(--sc-ok); border-color: var(--sc-ok); color: #052814; }
@media (hover: hover) {
    .spkcl__btn:hover { border-color: var(--sc-aqua); color: var(--sc-ink); }
    .spkcl__btn--yes:hover { color: #052814; filter: brightness(1.05); }
}

.spkcl__row { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.spkcl__seg { display: inline-flex; gap: 6px; flex-wrap: wrap; }
.spkcl__seg-btn {
    display: inline-flex;
    flex-direction: column;
    align-items: flex-start;
    padding: 6px 12px;
    border-radius: 9px;
    border: 1px solid var(--sc-border);
    background: transparent;
    color: var(--sc-ink);
    font-size: 14.5px;
    font-weight: 600;
    line-height: 1.25;
    text-align: left;
}
.spkcl__seg-sub { font-size: 12px; font-weight: 500; color: var(--sc-muted); }
.spkcl__seg-btn[aria-pressed="true"] { border-color: var(--sc-aqua); background: rgba(60, 200, 255, .14); }
.spkcl__check {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    border-radius: 9px;
    border: 1px solid var(--sc-border);
    background: transparent;
    color: var(--sc-ink);
    font-size: 14.5px;
}
@media (hover: hover) {
    .spkcl__seg-btn:hover, .spkcl__check:hover { border-color: var(--sc-aqua); color: var(--sc-ink); }
}
.spkcl__seg-btn:disabled, .spkcl__check:disabled { opacity: .5; color: var(--sc-ink); }

.spkcl__vol { display: flex; align-items: center; gap: 10px; color: var(--sc-muted); padding-top: 10px; border-top: 1px solid rgba(255, 255, 255, .1); }
.spkcl__vol-lbl { margin: 0; font-size: 14px; }
.spkcl__vol-track { flex: 1 1 auto; min-width: 80px; max-width: 300px; display: flex; }
.spkcl__runs { margin-left: auto; font-size: 13.5px; white-space: nowrap; font-variant-numeric: tabular-nums; }

.spkcl__range { width: 100%; height: 22px; padding: 0; background: transparent; -webkit-appearance: none; appearance: none; }
.spkcl__range::-webkit-slider-runnable-track {
    height: 6px; border-radius: 3px;
    background: linear-gradient(90deg, var(--sc-aqua) calc(var(--p) * 100%), var(--sc-track) calc(var(--p) * 100%));
}
.spkcl__range::-moz-range-track { height: 6px; border-radius: 3px; background: var(--sc-track); }
.spkcl__range::-moz-range-progress { height: 6px; border-radius: 3px; background: var(--sc-aqua); }
.spkcl__range::-webkit-slider-thumb {
    -webkit-appearance: none; appearance: none;
    width: 18px; height: 18px; margin-top: -6px; border-radius: 50%;
    background: var(--sc-ink); border: 0; box-shadow: 0 0 0 4px rgba(60, 200, 255, .25);
}
.spkcl__range::-moz-range-thumb { width: 18px; height: 18px; border-radius: 50%; background: var(--sc-ink); border: 0; }

/* --- Узко --- */
@container spkcl (max-width: 520px) {
    .spkcl { --sc-grille: 260px; }
    .spkcl__prep { font-size: 13px; gap: 4px 12px; }
    .spkcl__msg { min-height: 4.4em; font-size: 14.5px; }
    .spkcl__ask .spkcl__btn { flex: 1 1 0; min-width: 0; }
    .spkcl__row { flex-direction: column; align-items: stretch; }
    .spkcl__seg { display: grid; grid-template-columns: 1fr 1fr; }
    .spkcl__check { justify-content: center; }
    .spkcl__vol { flex-wrap: wrap; }
    .spkcl__vol-track { max-width: none; }
}

@media (prefers-reduced-motion: reduce) {
    .spkcl[data-stage="run"][data-pulse="1"] .spkcl__drop { animation: none; opacity: .6; transform: rotate(var(--a)) translateY(-90px); }
}
