/*
 * NOHO Konfigurator – Frontend-Styles
 *
 * Alle Regeln sind unter .noho-konfigurator gescoped, damit das Plugin
 * keine globalen CSS-Leaks verursacht.
 *
 * Breakpoints (aus CLAUDE.md):
 *   Mobile Portrait:  bis 767px
 *   Tablet Portrait:  768 – 1024px
 *   Laptop:           1025 – 1480px
 *   Desktop:          ab 1481px
 */

.noho-konfigurator {
    /* Design-Tokens – bewusst nur innerhalb des Scopes gültig. */
    --noho-gap: 24px;
    --noho-swatch-width: 72px;
    --noho-swatch-height: 50px;
    --noho-swatch-radius: 8px;
    --noho-swatch-gap: 15px;
    --noho-border-radius: 10px;
    --noho-color-border: #dcdcdc;
    --noho-color-border-active: #ffffff;
    --noho-color-bg: transparent;
    --noho-shadow-active: 0 0 0 2px rgba(0, 61, 88, 0.99), 0 2px 10px rgba(0, 61, 88, 0.12);
    --noho-transition: 120ms ease-out;

    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--noho-gap);
    width: 100%;
    max-width: 960px;
    margin: 0 auto;
    /* Textfarbe vom Theme erben – keine eigene Vorgabe. */
    color: inherit;
    background: var(--noho-color-bg);
    box-sizing: border-box;
}

.noho-konfigurator *,
.noho-konfigurator *::before,
.noho-konfigurator *::after {
    box-sizing: inherit;
}

/* ---------- Bühne (Kombibild) ---------- */

.noho-konfigurator__stage {
    position: relative;
    width: 100%;
    overflow: hidden;
    border-radius: var(--noho-border-radius);
    /* Theme-Defaults neutralisieren (einige Themes setzen Borders/Shadows auf Bild-Wrapper). */
    border: 0;
    padding: 0;
    margin: 0;
    background: transparent;
    box-shadow: none;
    /* aspect-ratio wird inline gesetzt, damit Tausch des src keinen Layout-Shift verursacht. */
}

/*
 * Double-Buffer: Zwei <img>-Layer liegen absolut positioniert übereinander.
 * Sichtbarkeit wird ausschließlich über z-index gesteuert – keine Opacity,
 * keine Transition. Der inaktive Layer wird per JS befüllt und erst nach
 * img.decode() in den Vordergrund geholt. Effekt: atomarer, unsichtbarer
 * Swap – das Objekt wirkt, als würde es sich nur umfärben.
 */
.noho-konfigurator__bild {
    position: absolute;
    inset: 0;
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    z-index: 1;
    /* Defensive Absicherung gegen Theme-globale Transitionen. */
    transition: none;
}

.noho-konfigurator__bild.is-visible {
    z-index: 2;
}

/* ---------- Swatch-Reihen ---------- */

.noho-konfigurator__reihe {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 20px;
    flex-wrap: wrap;
    width: 100%;
    max-width: 550px;
}

.noho-konfigurator__label {
    flex: 0 0 auto;
    font-size: 20px;
    font-style: normal;
    font-weight: 500;
    letter-spacing: 0.02em;
    /* Farbe vom Theme erben. */
    color: inherit;
    min-width: 110px;
}

.noho-konfigurator__swatches {
    display: flex;
    flex-direction: row;
    align-items: flex-start;
    gap: var(--noho-swatch-gap);
    flex-wrap: wrap;
}

/* ---------- Einzel-Swatch (Button) ---------- */

.noho-konfigurator__swatch {
    /* Reset Browser-Defaults. */
    appearance: none;
    -webkit-appearance: none;
    border: 0;
    margin: 0;
    padding: 0;
    font: inherit;
    color: inherit;
    background: transparent;

    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition:
        transform var(--noho-transition),
        box-shadow var(--noho-transition);
}

.noho-konfigurator__swatch-farbe {
    display: block;
    width: var(--noho-swatch-width);
    height: var(--noho-swatch-height);
    border-radius: var(--noho-swatch-radius);
    border: 1px solid var(--noho-color-border);
    transition:
        border-color var(--noho-transition),
        box-shadow var(--noho-transition),
        transform var(--noho-transition);
}

/* Hover – dezentes, animiertes Grow (keine Border-Änderung). */
@media (hover: hover) {
    .noho-konfigurator__swatch:hover .noho-konfigurator__swatch-farbe {
        transform: scale(1.10);
    }
}

/* Fokus – sichtbar, keyboard-tauglich. */
.noho-konfigurator__swatch:focus {
    outline: none;
}
.noho-konfigurator__swatch:focus-visible .noho-konfigurator__swatch-farbe {
    box-shadow: 0 0 0 3px rgba(17, 17, 17, 0.35);
}

/* Active – drei kombinierte Feedback-Ebenen: Border + Scale + Shadow/Glow. */
.noho-konfigurator__swatch.is-active .noho-konfigurator__swatch-farbe {
    border-color: var(--noho-color-border-active);
    border-width: 2px;
    transform: scale(1.10);
    box-shadow: var(--noho-shadow-active);
}

/* Screen-reader-only Text (für Farbnamen). */
.noho-konfigurator .screen-reader-text {
    position: absolute !important;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ---------- Breakpoints ---------- */

/* Laptop (1025 – 1480px): Swatches etwas kompakter. */
@media (min-width: 1025px) and (max-width: 1480px) {
    .noho-konfigurator {
        --noho-swatch-width: 68px;
        --noho-swatch-height: 46px;
    }
}

/* Tablet Portrait (768 – 1024px). */
@media (min-width: 768px) and (max-width: 1024px) {
    .noho-konfigurator {
        --noho-swatch-width: 64px;
        --noho-swatch-height: 44px;
        --noho-swatch-gap: 12px;
    }
}

/* Mobile Portrait (bis 767px). */
@media (max-width: 767px) {
    .noho-konfigurator {
        --noho-gap: 18px;
        --noho-swatch-width: 56px;
        --noho-swatch-height: 40px;
        --noho-swatch-gap: 10px;
    }

    /* Label darüber statt daneben – Label und Swatches werden zentriert. */
    .noho-konfigurator__reihe {
        gap: 10px;
        justify-content: center;
    }
    .noho-konfigurator__label {
        flex: 1 0 100%;
        min-width: 0;
        font-size: 16px;
        text-align: center;
    }
    .noho-konfigurator__swatches {
        width: 100%;
        justify-content: center;
    }
}

/* Reduced motion respektieren. */
@media (prefers-reduced-motion: reduce) {
    .noho-konfigurator__swatch,
    .noho-konfigurator__swatch-farbe {
        transition: none;
    }
    .noho-konfigurator__swatch.is-active .noho-konfigurator__swatch-farbe {
        transform: none;
    }
}
