/* ==========================================================================
   Kitchen Showroom Module
   Layer-based kitchen designer. Loaded only on template-kitchen-showroom.php.
   ========================================================================== */

.kitchen-showroom {
    --showroom-border: rgba(0, 0, 0, 0.18);
    --showroom-shadow: rgba(0, 0, 0, 0.25);
    --showroom-button-bg: #fff;
    --showroom-button-active-bg: rgba(255, 255, 255, 0.55);
    --showroom-text: #1a1a1a;
}

.kitchen-showroom .visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.kitchen-showroom__heading {
    font-size: clamp(1.75rem, 1.2rem + 1.4vw, 2.5rem);
    margin-bottom: 0.5rem;
}

.kitchen-showroom__lead {
    color: rgba(0, 0, 0, 0.6);
    max-width: 720px;
    margin: 0 auto;
}

/* --- Layered kitchen scene ------------------------------------------------ */

.kitchen-image-wrapper {
    position: relative;
    background-size: contain;
    background-position: center center;
    background-repeat: no-repeat;
    margin-top: 52px;
    min-height: 386px;
}

.kitchen-row {
    position: relative;
    height: 100%;
    align-items: center;
}

/* Overlay base: keep every layer in the DOM (display:block) so the keyframe
   animations have something to animate. Both .visible and .hidden remain
   display:block; only opacity differs. */
.kitchen-showroom .single-kitchen-image,
.single-kitchen-image {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: calc(100% - 30px);
    max-width: 100%;
    display: block !important;
    opacity: 0;
    pointer-events: none;
    will-change: opacity;
}

/* Keyframe animations are more reliable than CSS transitions for
   class-toggle visibility swaps. They fire each time the class is added,
   regardless of any conflicting `transition` rules elsewhere. */
@keyframes showroomFadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

@keyframes showroomFadeOut {
    from { opacity: 1; }
    to   { opacity: 0; }
}

.kitchen-showroom .single-kitchen-image.visible,
.single-kitchen-image.visible {
    opacity: 1 !important;
    pointer-events: auto;
    animation: showroomFadeIn 600ms cubic-bezier(0.4, 0, 0.2, 1) both;
}

.kitchen-showroom .single-kitchen-image.hidden,
.single-kitchen-image.hidden {
    opacity: 0 !important;
    pointer-events: none;
    animation: showroomFadeOut 600ms cubic-bezier(0.4, 0, 0.2, 1) both;
}

.kitchen-showroom .single-kitchen-image.backup-image,
.single-kitchen-image.backup-image {
    opacity: 1 !important;
    animation: none !important;
}

/* Reduced-motion users: keep a brief fade so the swap isn't a hard cut,
   but cut the duration to ~120ms. A gentle opacity change is widely
   considered safe under WCAG SC 2.3.3 (does not trigger vestibular issues
   like parallax, spin, or zoom would). */
@media (prefers-reduced-motion: reduce) {
    .kitchen-showroom .single-kitchen-image.visible,
    .single-kitchen-image.visible {
        animation-duration: 120ms !important;
    }

    .kitchen-showroom .single-kitchen-image.hidden,
    .single-kitchen-image.hidden {
        animation-duration: 120ms !important;
    }
}

.backup-image {
    box-shadow: 0 5px 5px 0 var(--showroom-shadow);
}

/* z-index layer order (must match physical reality):
   1. backplate          ← base photo
   2. floor              ← lowest plane
   3. wall color         ← back wall
   4. cabinets           ← on top of wall
   5. stone/quartz       ← countertop
   6. wall tiles         ← backsplash (overlaps stone edge)
*/
.single-kitchen-image.backup-image           { z-index: 1; }
.single-kitchen-floor                        { z-index: 2; }
.single-kitchen-wall                         { z-index: 3; }
.single-kitchen-cabinets                     { z-index: 4; }
.single-kitchen-stone                        { z-index: 5; }
.single-kitchen-stone-wall-tiles             { z-index: 6; }

/* --- Hotspot buttons on the scene ---------------------------------------- */

.kitchen-button {
    position: absolute;
    padding: 0;
    border-radius: 50%;
    background-color: var(--showroom-button-bg);
    color: var(--showroom-text);
    height: 30px;
    width: 30px;
    border: 1px solid var(--showroom-border);
    z-index: 300;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    transition: background-color 150ms ease, transform 150ms ease;
}

.kitchen-button:hover,
.kitchen-button:focus-visible {
    color: var(--showroom-text);
    transform: scale(1.08);
    outline: none;
}

.kitchen-button.active {
    background-color: var(--showroom-button-active-bg);
    box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.35);
}

.kitchen-button span {
    line-height: 1;
}

#stone-button       { bottom: 20%; left: 40%; }
#wall-tiles-button  { bottom: 38%; left: 25%; }
#floor-tiles-button { bottom: 3%;  right: 10%; left: auto; }
#cabinet-button     { bottom: 55%; left: 20%; }
#color-button       { top: 29%;    left: 43%; }

/* --- Caption bar (5 active filter names) --------------------------------- */

.filter-main-wrapper {
    padding-top: 24px;
}

.filter-main-wrapper > .row {
    margin: 0;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    row-gap: 6px;
    column-gap: 4px;
    border-top: 1px solid var(--showroom-border);
    padding-top: 16px;
}

.filtered-wrapper {
    flex: 1 1 calc(50% - 4px);
    padding: 4px 10px;
    min-width: 0;
}

.filtered-wrapper .stone-filter {
    margin: 0;
    font-size: 13px;
    line-height: 1.35;
    color: rgba(0, 0, 0, 0.55);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.filter-name {
    display: inline;
    font-weight: 600;
    color: var(--showroom-text);
}

.filter-name:empty::before {
    content: "—";
    color: rgba(0, 0, 0, 0.35);
    font-weight: 400;
}

/* xs: 2 per row (5th wraps centered) */
@media (max-width: 575.98px) {
    .filtered-wrapper {
        flex: 1 1 calc(50% - 4px);
        text-align: center;
    }

    .filtered-wrapper .stone-filter {
        font-size: 12px;
    }
}

/* sm: 3 per row */
@media (min-width: 576px) and (max-width: 767.98px) {
    .filtered-wrapper {
        flex: 1 1 calc(33.333% - 4px);
        text-align: center;
    }
}

/* md+: 5 per row, evenly spaced */
@media (min-width: 768px) {
    .filtered-wrapper {
        flex: 1 1 0;
        padding: 0 15px;
        text-align: center;
    }
}

/* --- Picker groups ------------------------------------------------------- */

.single-filter-group {
    border: 1px solid var(--showroom-border);
    overflow-x: hidden;
    flex-basis: 100%;
    margin-top: 30px;
    margin-bottom: 100px;
}

/* Stone picker holds 4 sub-categories (Granite, Marble, Quartz, Quartzite)
   and can scroll past 1 screen. Cap height so the kitchen scene above stays
   visible while the user scrolls through swatches. */
#stone-filter {
    max-height: 460px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(0, 0, 0, 0.25) transparent;
}

#stone-filter::-webkit-scrollbar {
    width: 8px;
}

#stone-filter::-webkit-scrollbar-track {
    background: transparent;
}

#stone-filter::-webkit-scrollbar-thumb {
    background-color: rgba(0, 0, 0, 0.22);
    border-radius: 4px;
}

#stone-filter::-webkit-scrollbar-thumb:hover {
    background-color: rgba(0, 0, 0, 0.4);
}

.single-filter-group.hidden {
    display: none;
}

.single-filter-group.visible {
    display: block;
}

.single-filter-group .row {
    display: flex;
    padding-top: 20px;
    vertical-align: top;
}

.single-filter-group p {
    padding: 0 10px;
    margin-bottom: 10px;
}

.single-filter-group p.stone-name {
    font-weight: 600;
    font-size: 1.05rem;
    width: 100%;
    text-align: center;
    border-bottom: 1px solid var(--showroom-border);
    padding-bottom: 8px;
    margin-bottom: 16px;
}

/* --- Single swatch tile -------------------------------------------------- */

.single-filter-wrapper {
    margin-bottom: 10px;
}

.single-filter-wrapper a {
    display: block;
    width: 100%;
    text-align: center;
    color: var(--showroom-text);
    font-size: 11px;
    line-height: 1.2;
    text-decoration: none;
}

.single-filter-wrapper a:hover,
.single-filter-wrapper a:focus-visible {
    text-decoration: none;
    outline: none;
}

.single-filter-wrapper a:hover .single-filter-inner,
.single-filter-wrapper a:focus-visible .single-filter-inner,
.single-filter-wrapper a.active .single-filter-inner {
    box-shadow: 0 0 0 2px #1a1a1a, 0 4px 6px var(--showroom-shadow);
    transform: translateY(-2px);
}

.single-filter-inner {
    display: block;
    position: relative;
    width: 90%;
    margin: 0 auto;
    aspect-ratio: 1 / 1;
    background-size: cover;
    background-position: center center;
    background-repeat: no-repeat;
    box-shadow: 2px 2px 3px 2px var(--showroom-shadow);
    transition: box-shadow 150ms ease, transform 150ms ease;
}

.single-filter-label {
    display: block;
    margin-top: 6px;
    font-size: 11px;
    color: var(--showroom-text);
}

/* --- Responsive ---------------------------------------------------------- */

@media (min-width: 992px) {
    .kitchen-image-wrapper {
        min-height: 521px;
    }
}

@media (min-width: 1200px) {
    .kitchen-image-wrapper {
        min-height: 622px;
    }
}

/* Tablet — slightly tighten hotspot positions and shrink buttons */
@media (max-width: 991.98px) {
    .kitchen-button {
        height: 26px;
        width: 26px;
        font-size: 14px;
    }
}

/* Mobile (≤768px) — re-position all 5 hotspots so they map to the
   correctly scaled-down kitchen scene. Original (desktop) values clustered
   too closely once the image shrank. */
@media (max-width: 767.98px) {
    .kitchen-image-wrapper {
        margin-top: 32px;
        min-height: 260px;
    }

    .kitchen-button {
        height: 22px;
        width: 22px;
    }

    .kitchen-button span {
        font-size: 13px;
        line-height: 1;
    }

    #stone-button       { bottom: 28%; left: 45%; }
    #wall-tiles-button  { top: 30%;    left: 22%; bottom: auto; }
    #floor-tiles-button { bottom: 8%;  right: 12%; left: auto; }
    #cabinet-button     { top: 10%;    left: 18%; bottom: auto; }
    #color-button       { top: 18%;    right: 18%; left: auto; }

    .single-filter-group .row {
        min-height: 200px;
    }
}

/* Small phones — even tighter, hotspots can't crowd at all */
@media (max-width: 480px) {
    .kitchen-button {
        height: 20px;
        width: 20px;
    }

    .kitchen-button span {
        font-size: 12px;
    }
.filter-main-wrapper {
    padding-top: 0;
}
    #stone-button       { bottom: 26%; left: 33%; }
    #wall-tiles-button  { top: 51%;    left: 22%; bottom: auto; }
    #floor-tiles-button { bottom: 14%;  right: 10%; left: auto; }
    #cabinet-button     { top: 33%;     left: 7%; bottom: auto; }
    #color-button       { top: 25%;    right: 14%; left: auto; }

    .single-filter-inner {
        width: 85%;
    }

    .single-filter-label {
        font-size: 10px;
    }
}

/* Bootstrap 5 tooltip support — ensures custom data attr inherits font */
.kitchen-showroom .tooltip {
    font-family: inherit;
}
