/* =============================================================================
   WC Texture Swatches — Frontend v2.1
============================================================================= */

/* ── Swatch wrap ─────────────────────────────────────────────────────────── */
.wcts-swatches-wrap {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: flex-start;
    margin: 6px 0;
}

/* ── Base swatch ─────────────────────────────────────────────────────────── */
.wcts-swatch {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 56px;
    height: 56px;
    border-radius: 8px;
    border: 2px solid #e0e0e0;
    cursor: pointer;
    overflow: visible;
    box-sizing: border-box;
    background: #f5f5f5;
    flex-shrink: 0;
    transition: border-color 0.18s ease, box-shadow 0.18s ease, transform 0.15s ease;
    outline: none;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.wcts-swatch:focus-visible {
    outline: 3px solid #2563eb;
    outline-offset: 2px;
}

.wcts-swatch:hover {
    border-color: #aaa;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.14);
    z-index: 2;
}

/* ── Image swatch ────────────────────────────────────────────────────────── */
.wcts-swatch--image {
    overflow: hidden;
    padding: 0;
}

.wcts-swatch--image img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100% !important;
    object-fit: cover;
    display: block;
    pointer-events: none;
    border-radius: 5px;
    transition: transform 0.2s ease;
}

.wcts-swatch--image:hover img {
    transform: scale(1.08);
}

/* ── Text swatch ─────────────────────────────────────────────────────────── */
.wcts-swatch--text {
    width: auto;
    min-width: 48px;
    padding: 0 14px;
    font-size: 13px;
    font-weight: 600;
    color: #333;
    background: #fff;
    overflow: hidden;
}

/* ── Selected ────────────────────────────────────────────────────────────── */
.wcts-swatch--selected {
    border-color: #111 !important;
    box-shadow: 0 0 0 3px rgba(0,0,0,0.1), 0 2px 8px rgba(0,0,0,0.12) !important;
    transform: translateY(-1px);
}

.wcts-swatch--selected::after {
    content: '';
    position: absolute;
    bottom: -5px;
    right: -5px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #111 url("data:image/svg+xml,%3Csvg viewBox='0 0 10 8' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 4l3 3 5-6' stroke='%23fff' stroke-width='1.6' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / 10px no-repeat;
    border: 2px solid #fff;
    z-index: 3;
    pointer-events: none;
}

/* ── Disabled ────────────────────────────────────────────────────────────── */
.wcts-swatch--disabled {
    opacity: 0.38;
    cursor: not-allowed;
    pointer-events: none;
}

.wcts-swatch--disabled::before {
    content: '';
    position: absolute;
    inset: 0;
    background: repeating-linear-gradient(
        -45deg, transparent, transparent 5px,
        rgba(0,0,0,0.18) 5px, rgba(0,0,0,0.18) 6px
    );
    border-radius: 5px;
    z-index: 2;
    pointer-events: none;
}

/* ── Zoom overlay button ─────────────────────────────────────────────────── */
.wcts-swatch__zoom-btn {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0,0,0,0);
    border-radius: 5px;
    opacity: 0;
    transition: background 0.18s ease, opacity 0.18s ease;
    cursor: pointer;
    z-index: 4;
    border: none;
    padding: 0;
}

.wcts-swatch__zoom-btn svg {
    width: 20px;
    height: 20px;
    stroke: #fff;
    filter: drop-shadow(0 1px 3px rgba(0,0,0,0.6));
    pointer-events: none;
}

.wcts-swatch--image:hover .wcts-swatch__zoom-btn {
    opacity: 1;
    background: rgba(0,0,0,0.35);
}

.wcts-swatch__zoom-btn:focus-visible {
    opacity: 1;
    background: rgba(0,0,0,0.45);
    outline: 3px solid #2563eb;
    outline-offset: -3px;
}

/* ── Tooltip ─────────────────────────────────────────────────────────────── */
.wcts-swatch__tooltip {
    visibility: hidden;
    opacity: 0;
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%) translateY(4px);
    background: rgba(17,17,17,0.9);
    color: #fff;
    font-size: 11px;
    font-weight: 500;
    letter-spacing: 0.02em;
    white-space: nowrap;
    padding: 4px 8px;
    border-radius: 5px;
    pointer-events: none;
    transition: opacity 0.15s ease, transform 0.15s ease;
    z-index: 200;
}

.wcts-swatch__tooltip::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 5px solid transparent;
    border-top-color: rgba(17,17,17,0.9);
}

.wcts-swatch:hover .wcts-swatch__tooltip,
.wcts-swatch:focus-visible .wcts-swatch__tooltip {
    visibility: visible;
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* ── Addon field ─────────────────────────────────────────────────────────── */
.wcts-addon-field { margin: 16px 0; }

.wcts-addon-field__label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: #222;
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.wcts-addon-field__label abbr {
    color: #c0392b;
    text-decoration: none;
    margin-left: 2px;
}

.wcts-addon-field__error {
    color: #c0392b;
    font-size: 12px;
    margin: 6px 0 0;
}

.wcts-addon-field--invalid .wcts-swatch {
    border-color: #c0392b;
    animation: wcts-shake 0.35s ease both;
}

@keyframes wcts-shake {
    0%,100% { transform: translateX(0); }
    25%      { transform: translateX(-4px); }
    75%      { transform: translateX(4px); }
}

/* =============================================================================
   LIGHTBOX
   Uses a visibility/opacity toggle (not display) so transitions work cleanly.
   JS adds/removes .wcts-lightbox--open on the element.
============================================================================= */

/* Hidden by default. JS sets display:flex on open. */
.wcts-lightbox {
    display: none;
    visibility: hidden;
    opacity: 0;
    position: fixed;
    inset: 0;
    z-index: 999999;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.22s ease, visibility 0.22s ease;
    /* Make sure nothing from the theme bleeds in */
    padding: 0;
    margin: 0;
    border: none;
    background: none;
    box-sizing: border-box;
}

.wcts-lightbox--open {
    visibility: visible;
    opacity: 1;
}

/* ── Backdrop ────────────────────────────────────────────────────────────── */
.wcts-lightbox__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(6, 6, 6, 0.88);
    cursor: zoom-out;
    /* No backdrop-filter — it causes compositing bugs in many themes */
}

/* ── Stage (the white card) ──────────────────────────────────────────────── */
.wcts-lightbox__stage {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    width: min(92vw, 700px);
    max-height: 92vh;
    padding: 52px 24px 24px; /* top padding leaves room for the close btn */
    gap: 16px;
    box-sizing: border-box;

    /* Scale-in only on open, not on every navigation */
    transform: scale(0.94) translateY(10px);
    transition: transform 0.22s cubic-bezier(0.34, 1.2, 0.64, 1),
                opacity  0.22s ease;
    opacity: 0;
}

.wcts-lightbox--open .wcts-lightbox__stage {
    transform: scale(1) translateY(0);
    opacity: 1;
}

/* ── Close button — anchored to top-right of the stage ──────────────────── */
.wcts-lightbox__close {
    position: absolute;
	top: 0px;
	right: 20px;
	width: 40px;
	height: 40px;
	border-radius: 50% !important;
	background-color: rgba(255,255,255,0.1) !important;
	border: 1px solid rgba(255,255,255,0.2) !important;
	color: #fff !important;
	display: flex;
	align-items: center;
	justify-content: center;
	flex-shrink: 0;
	transition: background 0.15s ease, transform 0.2s ease;
	padding: 0 !important;
	line-height: 1 !important;
}

.wcts-lightbox__close:hover  { background: rgba(255,255,255,0.25); transform: rotate(90deg); }
.wcts-lightbox__close svg    { width: 18px; height: 18px; display: block; }
.wcts-lightbox__close:focus-visible { outline: 3px solid #60a5fa; outline-offset: 2px; }

/* ── Main image area ─────────────────────────────────────────────────────── */
.wcts-lightbox__figure {
    margin: 0;
    padding: 0;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    flex-shrink: 1;
    min-height: 0; /* allow flex shrink */
}

.wcts-lightbox__img-wrap {
    position: relative;
    width: 100%;
    height: clamp(180px, 52vh, 480px);
    border-radius: 10px;
    overflow: hidden;
    background: rgba(255,255,255);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.wcts-lightbox__img {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
    display: block;
    border-radius: 8px;
    user-select: none;
    transition: opacity 0.18s ease;
    position: relative;
    z-index: 1;
}

.wcts-lightbox__img.wcts-loading { opacity: 0; }

/* ── Spinner ─────────────────────────────────────────────────────────────── */
.wcts-lightbox__spinner {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.15s ease;
    z-index: 0;
}

.wcts-lightbox__spinner::after {
    content: '';
    width: 32px;
    height: 32px;
    border: 3px solid rgba(255,255,255,0.18);
    border-top-color: rgba(255,255,255,0.85);
    border-radius: 50%;
    animation: wcts-spin 0.65s linear infinite;
}

.wcts-lightbox__img-wrap.wcts-is-loading .wcts-lightbox__spinner { opacity: 1; }

@keyframes wcts-spin { to { transform: rotate(360deg); } }

/* ── Caption ─────────────────────────────────────────────────────────────── */
.wcts-lightbox__caption {
    color: rgba(255,255,255,0.85);
	font-size: 14px;
	font-weight: 500;
	letter-spacing: 0.03em;
	text-align: center;
	line-height: 1.4;
	font-style: normal;
	margin: 0;
	padding: 0;
}

/* ── Navigation ──────────────────────────────────────────────────────────── */
.wcts-lightbox__nav {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

.wcts-lightbox__prev,
.wcts-lightbox__next {
	width: 44px;
	height: 44px;
	border-radius: 50% !important;
	background-color: rgba(255,255,255,0.1) !important;
	border: 1px solid rgba(255,255,255,0.2) !important;
	color: #fff !important;
	display: flex;
	align-items: center;
	justify-content: center;
	flex-shrink: 0;
	transition: background 0.15s ease, transform 0.12s ease;
	padding: 0 !important;
}

.wcts-lightbox__prev:hover { background: rgba(255,255,255,0.2); transform: scale(105%); }
.wcts-lightbox__next:hover { background: rgba(255,255,255,0.2); transform: scale(105%); }
.wcts-lightbox__prev svg,
.wcts-lightbox__next svg   { width: 20px; height: 20px; display: block; }

.wcts-lightbox__prev:focus-visible,
.wcts-lightbox__next:focus-visible { outline: 3px solid #60a5fa; outline-offset: 2px; }

.wcts-lightbox__prev:disabled,
.wcts-lightbox__next:disabled { opacity: 0.28; cursor: default; }

.wcts-lightbox__counter {
    color: rgba(255,255,255,0.5);
    font-size: 12px;
    font-weight: 500;
    min-width: 48px;
    text-align: center;
    letter-spacing: 0.04em;
}

/* ── Thumbnail strip ─────────────────────────────────────────────────────── */
.wcts-lightbox__thumbnails {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: center;
    width: 100%;
    flex-shrink: 0;
}

.wcts-lightbox__thumb {
    width: 46px;
    height: 46px;
    border-radius: 6px;
    overflow: hidden;
    cursor: pointer;
    border: 2px solid rgba(255,255,255,0.2);
    padding: 0;
    background: none;
    flex-shrink: 0;
    opacity: 0.5;
    transition: opacity 0.15s ease, border-color 0.15s ease, transform 0.12s ease;
}

.wcts-lightbox__thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    pointer-events: none;
    border-radius: 4px;
}

.wcts-lightbox__thumb:hover           { opacity: 0.82; transform: scale(1.07); }
.wcts-lightbox__thumb--active         { border-color: #fff; opacity: 1; }
.wcts-lightbox__thumb:focus-visible   { outline: 3px solid #60a5fa; opacity: 0.9; }

/* =============================================================================
   Catalog / Archive
============================================================================= */
.wcts-catalog-swatches {
    padding: 6px 0 4px;
    line-height: 1;
}

.wcts-swatches-wrap--catalog .wcts-swatch {
    width: 36px;
    height: 36px;
    border-radius: 5px;
}

.wcts-swatches-wrap--catalog .wcts-swatch--text {
    width: auto;
    min-width: 32px;
    padding: 0 8px;
    font-size: 11px;
    height: 28px;
}

.wcts-swatch--readonly { cursor: default; }

.wcts-swatch--readonly:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(0,0,0,0.10);
}

.wcts-swatch--readonly.wcts-swatch--selected::after { display: none; }

/* =============================================================================
   Responsive
============================================================================= */
@media (max-width: 600px) {
    .wcts-swatch { width: 48px; height: 48px; }

    .wcts-lightbox__stage {
        width: 96vw;
        padding: 48px 14px 18px;
        gap: 12px;
    }

    .wcts-lightbox__img-wrap {
        height: clamp(160px, 46vh, 360px);
        border-radius: 8px;
    }

    .wcts-lightbox__thumb { width: 38px; height: 38px; }
    .wcts-lightbox__thumbnails { gap: 6px; }
}

/* =============================================================================
   Reduced motion
============================================================================= */
@media (prefers-reduced-motion: reduce) {
    .wcts-swatch,
    .wcts-swatch--image img,
    .wcts-swatch__zoom-btn,
    .wcts-swatch__tooltip,
    .wcts-lightbox,
    .wcts-lightbox__stage,
    .wcts-lightbox__close,
    .wcts-lightbox__thumb { transition: none !important; animation: none !important; }
    .wcts-lightbox__spinner::after { animation: none !important; }
}

/* body scroll lock */
body.wcts-lb-open { overflow: hidden; }

/* =============================================================================
   VIEW MORE / VIEW LESS
============================================================================= */

/* Clamp the wrap height — JS sets the exact px value via inline style */
.wcts-swatches-wrap--clamped {
    overflow: hidden;
    /* Smooth expand/collapse */
    transition: max-height 0.3s ease;
}

/* The "View more / View less" button */
.wcts-view-more {
    display: inline-flex !important;
    align-items: center !important;
    gap: 5px !important;
    margin-top: 8px !important;
    padding: 0 !important;
    background: none !important;
    border: none !important;
    cursor: pointer;
    font-size: 12px !important;
    font-weight: 600 !important;
    color: #555 !important;
    letter-spacing: 0.03em !important;
    text-decoration: underline !important;
    text-underline-offset: 3px !important;
    text-decoration-color: #ccc !important;
    transition: color 0.15s ease, text-decoration-color 0.15s ease !important;
    line-height: 1 !important;
}

.wcts-view-more:hover {
    color: #111;
    text-decoration-color: #999;
}

.wcts-view-more svg {
    width: 13px;
    height: 13px;
    stroke: currentColor;
    flex-shrink: 0;
    transition: transform 0.25s ease;
}

@media (prefers-reduced-motion: reduce) {
    .wcts-swatches-wrap--clamped { transition: none !important; }
    .wcts-view-more svg          { transition: none !important; }
}
