/**
 * Rentopian Sync — attribute swatches.
 *
 * Every rule is scoped to the module's own markup and inert without it.
 * Sizes are custom properties so a theme can retune them from its own
 * stylesheet without overriding selectors.
 */

:root {
    --rental-swatch-size: 32px;
    --rental-swatch-radius: 50%;
    --rental-swatch-gap: 8px;
    --rental-swatch-border: rgba(0, 0, 0, 0.15);
    --rental-swatch-border-hover: rgba(0, 0, 0, 0.4);
    --rental-swatch-ring: #222;
    --rental-loop-dot-size: 14px;
    --rental-filter-chip-size: 28px;
    --rental-filter-columns: 6;
}

/* ------------------------------------------------------------------ *
 * Single product: swatches next to WooCommerce's attribute dropdown
 * ------------------------------------------------------------------ */

/* The select keeps working for WooCommerce's script and for assistive
   technology; it is only taken out of the visual flow. */
select.rental-swatches-select {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    min-height: 0 !important;
    margin: -1px !important;
    padding: 0 !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    clip-path: inset(50%) !important;
    white-space: nowrap !important;
    border: 0 !important;
    opacity: 0 !important;
    pointer-events: none !important;
}

/* A theme's fake dropdown built around the select: an element that copied
   the select's classes (OceanWP), or anything a script inserted between the
   select and the swatch group (select2, nice-select). */
.rental-swatches-select:not(select),
select.rental-swatches-select ~ :not(.rental-swatches):has(~ .rental-swatches),
.rental-swatches-hidden {
    display: none !important;
}

.rental-swatches {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--rental-swatch-gap);
    margin: 4px 0;
}

.rental-swatch {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin: 0;
    padding: 0;
    border: 0;
    background: none;
    color: inherit;
    font: inherit;
    line-height: 1;
    cursor: pointer;
    -webkit-appearance: none;
    appearance: none;
    box-shadow: none;
}

.rental-swatch:focus-visible {
    outline: 2px solid var(--rental-swatch-ring);
    outline-offset: 2px;
}

.rental-swatch__chip {
    position: relative;
    display: block;
    box-sizing: border-box;
    width: var(--rental-swatch-size);
    height: var(--rental-swatch-size);
    border-radius: var(--rental-swatch-radius);
    overflow: hidden;
    background-color: #fff;
    box-shadow: inset 0 0 0 1px var(--rental-swatch-border);
    transition: box-shadow 0.15s ease, transform 0.15s ease;
}

.rental-swatch__chip img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    margin: 0;
    border: 0;
}

.rental-swatch--color .rental-swatch__name,
.rental-swatch--image .rental-swatch__name {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.rental-swatch--text .rental-swatch__name {
    display: inline-block;
    box-sizing: border-box;
    min-width: var(--rental-swatch-size);
    height: var(--rental-swatch-size);
    padding: 0 12px;
    border-radius: 4px;
    line-height: var(--rental-swatch-size);
    font-size: 0.875em;
    box-shadow: inset 0 0 0 1px var(--rental-swatch-border);
    transition: box-shadow 0.15s ease;
}

.rental-swatch:hover .rental-swatch__chip,
.rental-swatch:hover .rental-swatch__name {
    box-shadow: inset 0 0 0 1px var(--rental-swatch-border-hover);
}

.rental-swatch.is-selected .rental-swatch__chip {
    box-shadow: inset 0 0 0 2px #fff, 0 0 0 2px var(--rental-swatch-ring);
}

.rental-swatch--text.is-selected .rental-swatch__name {
    box-shadow: inset 0 0 0 2px var(--rental-swatch-ring);
}

.rental-swatch.is-disabled {
    cursor: not-allowed;
    opacity: 0.35;
}

.rental-swatch.is-disabled .rental-swatch__chip::after {
    content: "";
    position: absolute;
    top: 50%;
    left: -10%;
    width: 120%;
    height: 1px;
    background: rgba(0, 0, 0, 0.5);
    transform: rotate(-45deg);
}

/* ------------------------------------------------------------------ *
 * Product listing: colour dots on the card
 * ------------------------------------------------------------------ */

.rental-loop-swatches-wrap {
    list-style: none;
    padding: 0;
}

/* Inline-level so the row follows the card's text alignment; no list
   markup, so a theme's card list-item rules cannot reach the dots. */
.rental-loop-swatches {
    display: inline-flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 6px;
    max-width: 100%;
    margin: 6px 0 0;
    padding: 0;
    vertical-align: middle;
    line-height: 1;
}

.rental-loop-swatch {
    display: inline-flex;
    align-items: center;
    margin: 0;
    padding: 0;
    line-height: 0;
    text-decoration: none;
    border: 0;
    box-shadow: none;
}

.rental-loop-swatch__dot {
    display: block;
    box-sizing: border-box;
    width: var(--rental-loop-dot-size);
    height: var(--rental-loop-dot-size);
    border-radius: 50%;
    box-shadow: inset 0 0 0 1px var(--rental-swatch-border);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

a.rental-loop-swatch:hover .rental-loop-swatch__dot {
    transform: scale(1.2);
    box-shadow: inset 0 0 0 1px var(--rental-swatch-border-hover);
}

.rental-loop-swatch--more {
    font-size: 11px;
    line-height: var(--rental-loop-dot-size);
    opacity: 0.7;
}

/* ------------------------------------------------------------------ *
 * Shop filter: WooCommerce "Filter Products by Attribute" widget
 * ------------------------------------------------------------------ */

.rental-swatch-term {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    vertical-align: middle;
}

.rental-swatch-chip {
    position: relative;
    display: inline-block;
    flex: 0 0 auto;
    box-sizing: border-box;
    width: var(--rental-filter-chip-size);
    height: var(--rental-filter-chip-size);
    border-radius: var(--rental-swatch-radius);
    overflow: hidden;
    vertical-align: middle;
    background-color: #fff;
    box-shadow: inset 0 0 0 1px var(--rental-swatch-border);
    transition: box-shadow 0.15s ease;
}

.rental-swatch-chip img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    margin: 0;
    border: 0;
}

.rental-swatch-chip--none {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    line-height: 1;
    text-transform: uppercase;
    background-color: #f2f2f2;
}

/* Colour attributes with names hidden: the list becomes a grid of chips and
   the term link covers its chip, so the whole chip is the click target. */
.woocommerce-widget-layered-nav-list.rental-swatch-list,
.woocommerce-widget-layered-nav-list:has(> .wc-layered-nav-term > .rental-swatch-term--nolabel) {
    display: grid;
    grid-template-columns: repeat(var(--rental-filter-columns), minmax(0, 1fr));
    gap: 10px 8px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.woocommerce-widget-layered-nav-list.rental-swatch-list > .wc-layered-nav-term,
.woocommerce-widget-layered-nav-list:has(> .wc-layered-nav-term > .rental-swatch-term--nolabel) > .wc-layered-nav-term {
    margin: 0;
    padding: 0;
    display: flex;
    justify-content: center;
}

.rental-swatch-term--nolabel {
    display: block;
    width: 100%;
    max-width: 48px;
}

.rental-swatch-term--nolabel .rental-swatch-chip {
    display: block;
    width: 100%;
    height: auto;
    aspect-ratio: 1 / 1;
}

.rental-swatch-term--nolabel a,
.rental-swatch-term--nolabel > span:not(.rental-swatch-chip) {
    position: absolute;
    inset: 0;
    display: block;
    overflow: hidden;
    font-size: 0;
    line-height: 0;
    color: transparent;
    text-decoration: none;
    border: 0;
}

.rental-swatch-term--nolabel .count {
    display: none;
}

.rental-swatch-term:hover .rental-swatch-chip {
    box-shadow: inset 0 0 0 1px var(--rental-swatch-border-hover);
}

.wc-layered-nav-term.chosen .rental-swatch-chip {
    box-shadow: inset 0 0 0 2px #fff, 0 0 0 2px var(--rental-swatch-ring);
}

.wc-layered-nav-term.chosen .rental-swatch-term--nolabel a::before {
    display: none;
}

/* Note shown in place of an empty attribute filter, to shop managers only. */
.rental-swatches-filter-notice {
    padding: 10px 12px;
    border-left: 3px solid #d6a100;
    background: #fdf6e3;
    color: #4a3c00;
    font-size: 13px;
    line-height: 1.5;
}

.rental-swatches-filter-notice code {
    padding: 1px 4px;
    background: rgba(0, 0, 0, 0.06);
}

/* ------------------------------------------------------------------ *
 * Shop filter: the module's own widget and [rental_swatches_filter]
 *
 * Every term is one element the module built (see
 * Rental_Swatches_Filter_Widget::swatch_term_html()), so these rules only
 * have to undo what a theme puts on a sidebar list and its links. Themes
 * style those with long, often id-carrying selectors, which is why the few
 * properties the swatch cannot do without are forced here. No :has(), no
 * overlay: the chip sits inside the link.
 * ------------------------------------------------------------------ */

.rental-swatches-filter .woocommerce-widget-layered-nav-list {
    display: flex !important;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin: 0 !important;
    padding: 0 !important;
    border: 0;
    list-style: none !important;
}

.rental-swatches-filter .woocommerce-widget-layered-nav-list > li {
    display: block !important;
    width: auto !important;
    margin: 0 !important;
    padding: 0 !important;
    border: 0 !important;
    background: none !important;
    list-style: none !important;
}

.rental-swatches-filter .woocommerce-widget-layered-nav-list > li::before,
.rental-swatches-filter .woocommerce-widget-layered-nav-list > li::after {
    content: none !important;
}

.rental-swatch-filter {
    display: inline-flex !important;
    align-items: center;
    gap: 8px;
    box-sizing: border-box;
    max-width: 100%;
    margin: 0 !important;
    padding: 4px 12px 4px 4px !important;
    border: 1px solid var(--rental-swatch-border) !important;
    border-radius: 999px;
    background: transparent !important;
    color: inherit;
    font-size: 13px;
    line-height: 1.3;
    text-align: left;
    text-decoration: none !important;
    box-shadow: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.rental-swatch-filter--chip-only {
    padding: 3px !important;
    border-radius: 50%;
}

.rental-swatch-filter__chip {
    display: block;
    flex: 0 0 auto;
    box-sizing: border-box;
    width: var(--rental-filter-chip-size);
    height: var(--rental-filter-chip-size);
    overflow: hidden;
    border-radius: 50%;
    background-color: #fff;
    box-shadow: inset 0 0 0 1px var(--rental-swatch-border);
}

.rental-swatch-filter__chip img {
    display: block;
    width: 100%;
    height: 100%;
    margin: 0;
    border: 0;
    object-fit: cover;
}

.rental-swatch-filter__name--hidden {
    position: absolute !important;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    clip-path: inset(50%);
    white-space: nowrap;
    border: 0;
}

.rental-swatch-filter__count {
    flex: 0 0 auto;
    opacity: 0.6;
    font-size: 0.9em;
}

.rental-swatch-filter:hover {
    border-color: var(--rental-swatch-border-hover) !important;
}

.rental-swatch-filter.is-disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.wc-layered-nav-term.chosen .rental-swatch-filter,
.rental-swatch-filter.is-chosen {
    border-color: var(--rental-swatch-ring) !important;
    box-shadow: inset 0 0 0 1px var(--rental-swatch-ring);
}
