/* ═══════════════════════════════════════════════════════════════════════
   SIZE PICKER — выбор размера на витрине (модалка товара + страница товара)
   + попап размерной сетки. Тёмный терминальный стиль, токены STYLE_GUIDE.
   Чипы — по образцу .pd-variation. Работает и в #pmSizePicker, и в #pdSizePicker.
   ══════════════════════════════════════════════════════════════════════ */

.sp { margin: 4px 0 24px; }

/* ── Шапка: кикер «// размер» + ссылка на сетку ── */
.sp-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
}
.sp-kicker {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 10px;
    letter-spacing: 0.28em;
    text-transform: uppercase;
    color: var(--gray);
}
.sp-kicker::before { content: '// '; color: var(--pink); }

.sp-chart-btn {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 10px;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--pink);
    background: none;
    border: none;
    border-bottom: 1px solid rgba(255, 61, 127, 0.3);
    padding: 3px 0;
    cursor: pointer;
    transition: color 0.2s, border-color 0.2s, text-shadow 0.2s;
    white-space: nowrap;
}
.sp-chart-btn::before { content: '// '; opacity: 0.7; }
.sp-chart-btn:hover {
    color: var(--white);
    border-color: var(--pink);
    text-shadow: 0 0 8px var(--pink-glow);
}
.sp-chart-btn:focus-visible { outline: 1px solid var(--pink); outline-offset: 3px; }

/* ── Чипы размеров ── */
.sp-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}
.sp-chip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 38px;
    padding: 8px 16px;
    font-family: 'IBM Plex Mono', monospace;
    font-size: 12px;
    letter-spacing: 0.08em;
    color: var(--gray);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 3px;
    cursor: pointer;
    transition: color 0.15s, border-color 0.15s, background 0.15s, box-shadow 0.2s;
}
.sp-chip:hover { color: var(--white); border-color: var(--gray); }
.sp-chip:focus-visible { outline: 1px solid var(--pink); outline-offset: 2px; }
.sp-chip.active {
    color: var(--white);
    border-color: var(--pink);
    background: rgba(255, 61, 127, 0.10);
    box-shadow: inset 0 0 0 1px var(--pink), 0 0 16px var(--pink-glow);
}
/* Чип «свой размер» — пунктир, чуть иной характер */
.sp-chip-custom {
    border-style: dashed;
    text-transform: uppercase;
    letter-spacing: 0.14em;
}

/* ── Блок кастом-размера ── */
.sp-custom { margin-top: 14px; }
.sp-custom[hidden] { display: none; }
.sp-custom-row { display: flex; align-items: center; gap: 10px; }
.sp-custom-field {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    height: 44px;
    padding: 0 14px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border);
    border-radius: 3px;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.sp-custom-field:focus-within {
    border-color: rgba(255, 61, 127, 0.5);
    box-shadow: 0 0 12px var(--pink-dim);
}
.sp-custom-input {
    width: 88px;
    background: none;
    border: none;
    outline: none;
    font-family: 'IBM Plex Mono', monospace;
    font-size: 15px;
    letter-spacing: 0.05em;
    color: var(--white);
}
.sp-custom-input::placeholder { color: rgba(245, 240, 240, 0.15); }
/* убираем спиннеры number-инпута — чище под терминальный стиль */
.sp-custom-input::-webkit-outer-spin-button,
.sp-custom-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.sp-custom-input { -moz-appearance: textfield; }
.sp-custom-unit {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 11px;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--gray);
}
.sp-custom-hint {
    margin-top: 8px;
    font-family: 'IBM Plex Mono', monospace;
    font-size: 10px;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--gray2);
}
.sp-warn {
    margin-top: 10px;
    font-family: 'IBM Plex Mono', monospace;
    font-size: 11px;
    line-height: 1.65;
    color: var(--pink);
}
.sp-warn[hidden] { display: none; }
.sp-warn a { color: var(--pink); text-decoration: underline; text-underline-offset: 2px; }
.sp-warn a:hover { color: var(--white); }

/* ── Подсветка «выберите размер» при попытке добавить без выбора ── */
@keyframes sp-shake {
    0%, 100% { transform: translateX(0); }
    20%, 60% { transform: translateX(-5px); }
    40%, 80% { transform: translateX(5px); }
}
.sp-shake { animation: sp-shake 0.4s ease; }

/* Кнопка «Добавить в корзину» на странице товара, заблокированная
   size-picker'ом до выбора размера (модалка использует свой .pm-add-disabled) */
.pd-add:disabled { opacity: 0.45; cursor: not-allowed; }

/* ═══════════════════════════════════════════════════════════════════════
   ПОПАП РАЗМЕРНОЙ СЕТКИ
   ══════════════════════════════════════════════════════════════════════ */
.sp-chart-overlay {
    position: fixed;
    inset: 0;
    z-index: 100001;                 /* выше PhotoSwipe (100000) */
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 32px 24px;
    background: rgba(3, 3, 4, 0.85);
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
    opacity: 0;
    transition: opacity 0.24s ease;
}
.sp-chart-overlay.open { opacity: 1; }

.sp-chart {
    position: relative;
    width: 100%;
    max-width: 640px;
    max-height: 86vh;
    overflow-y: auto;
    padding: 36px 34px 32px;
    background: var(--deep);
    border: 1px solid var(--border);
    border-radius: 6px;
    box-shadow: 0 30px 60px rgba(0, 0, 0, 0.8), inset 0 0 20px rgba(255, 61, 127, 0.05);
    transform: translateY(20px) scale(0.98);
    transition: transform 0.24s cubic-bezier(0.16, 1, 0.3, 1);
}
.sp-chart-overlay.open .sp-chart { transform: translateY(0) scale(1); }

.sp-chart-close {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: 1px solid var(--border);
    border-radius: 3px;
    color: var(--gray);
    font-size: 13px;
    cursor: pointer;
    transition: color 0.2s, border-color 0.2s;
}
.sp-chart-close:hover { color: var(--pink); border-color: var(--pink); }
.sp-chart-close:focus-visible { outline: 1px solid var(--pink); outline-offset: 2px; }

.sp-chart-head { margin-bottom: 24px; padding-right: 40px; }
.sp-chart-kicker {
    display: block;
    font-family: 'IBM Plex Mono', monospace;
    font-size: 10px;
    letter-spacing: 0.3em;
    text-transform: uppercase;
    color: var(--pink);
    margin-bottom: 10px;
}
.sp-chart-kicker::before { content: '// '; }
.sp-chart-title {
    font-family: 'Bebas Neue', sans-serif;
    font-size: 34px;
    letter-spacing: 0.04em;
    line-height: 1;
    color: var(--white);
    margin: 0 0 6px;
}
.sp-chart-unit {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 10px;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--gray);
}

/* ── Таблица замеров ── */
.sp-chart-scroll {
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: 4px;
    -webkit-overflow-scrolling: touch;
}
.sp-chart-table {
    width: 100%;
    border-collapse: collapse;
    font-family: 'IBM Plex Mono', monospace;
}
.sp-th {
    padding: 12px 14px;
    font-size: 9px;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--gray);
    text-align: center;
    white-space: nowrap;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}
.sp-th-label, .sp-td-label { text-align: left; }
.sp-td {
    padding: 12px 14px;
    font-size: 12px;
    color: var(--white);
    text-align: center;
    white-space: nowrap;
    border-bottom: 1px solid rgba(30, 30, 40, 0.7);
}
.sp-tr:last-child .sp-td { border-bottom: none; }
.sp-td-label {
    color: var(--pink);
    letter-spacing: 0.06em;
    font-weight: 500;
}
.sp-tr { transition: background 0.15s; }
.sp-tr:hover .sp-td { background: rgba(255, 61, 127, 0.05); }

/* ── Подсказка «как замерить» ── */
.sp-chart-hint {
    margin-top: 22px;
    padding-top: 20px;
    border-top: 1px solid var(--border);
}
.sp-hint-kicker {
    display: block;
    font-family: 'IBM Plex Mono', monospace;
    font-size: 9px;
    letter-spacing: 0.28em;
    text-transform: uppercase;
    color: var(--pink);
    margin-bottom: 10px;
}
.sp-hint-kicker::before { content: '// '; }
.sp-hint-text {
    font-family: 'Libre Baskerville', Georgia, serif;
    font-size: 13px;
    line-height: 1.8;
    color: var(--gray);
    white-space: pre-line;
    margin: 0;
}

/* ═══ Mobile ═══ */
@media (max-width: 768px) {
    .sp-chip { min-height: 44px; padding: 10px 18px; }
    .sp-custom-field { height: 48px; }

    .sp-chart-overlay { padding: 0; }
    .sp-chart {
        max-width: 100%;
        width: 100%;
        max-height: 100dvh;
        height: 100dvh;
        border: none;
        border-radius: 0;
        padding: 28px 20px 24px;
    }
    .sp-chart-title { font-size: 28px; }
}

/* ═══ Reduced motion ═══ */
@media (prefers-reduced-motion: reduce) {
    .sp-chart-overlay,
    .sp-chart { transition: none; }
    .sp-chart { transform: none; }
    .sp-shake { animation: none; }
}
