/**
 * J2Commerce - Lookbook — site styles (bootstrap5 framework)
 *
 * @package     J2Commerce
 * @subpackage  mod_j2commerce_lookbook
 * @copyright   (C)2024-2026 J2Commerce, LLC <https://www.j2commerce.com>
 * @license     GNU General Public License version 2 or later; see LICENSE.txt
 */

.j2c-lookbook {
    container-type: inline-size;
    position: relative;
}

/* ---------------------------------------------------------------------
   Frame — locked to the image's own intrinsic ratio (PRD §7). No
   cropping, so hotspot percentages are always exact.
   ------------------------------------------------------------------ */
.j2c-lookbook__frame {
    position: relative;
    width: 100%;
    aspect-ratio: var(--lb-w) / var(--lb-h);
    /* No overflow:hidden here (M-6) — it clipped the focus ring/pulse halo of any
       marker near the frame edge. The image alone is clipped to the rounded corners. */
    border-radius: var(--j2c-lookbook-radius, 0.25rem);
    /* Numbers list-only markers via CSS alone, in DOM/visual order (M-8). */
    counter-reset: j2c-lookbook-spot;
}

.j2c-lookbook--bootstrap5 .j2c-lookbook__frame {
    background-color: var(--bs-tertiary-bg, #f3f3f3);
}

.j2c-lookbook__frame > img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
    border-radius: inherit;
    overflow: clip;
}

/* ---------------------------------------------------------------------
   Markers — position is a CSS percentage on the frame (no JS in the
   positioning path); size is fixed px with a container-query step-down
   so position and size never share a unit (PRD §7.4).
   ------------------------------------------------------------------ */
.j2c-lookbook__spot {
    position: absolute;
    left: calc(var(--lb-x) * 1%);
    top: calc(var(--lb-y) * 1%);
    transform: translate(-50%, -50%);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    padding: 2px;
    margin: 0;
    border: 0;
    background: transparent;
    cursor: pointer;
    color: inherit;
    -webkit-tap-highlight-color: transparent;
    counter-increment: j2c-lookbook-spot;
}

@container (max-width: 480px) {
    .j2c-lookbook__spot {
        width: 24px;
        height: 24px;
    }
}

.j2c-lookbook__spot:focus-visible {
    outline: 3px solid #ffffff;
    outline-offset: 2px;
    box-shadow: 0 0 0 5px #16191d;
    border-radius: 50%;
}

/* Tag is a pill, not a circle — its focus ring follows the same shape (L-19). */
.j2c-lookbook__spot--tag:focus-visible {
    border-radius: 999px;
}

.j2c-lookbook__ring {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    font-size: 0.7rem;
    font-weight: 700;
    line-height: 1;
    pointer-events: none;
}

/* Ring (default) — dual-tone: guaranteed 3:1 against any photograph (§8.4) */
.j2c-lookbook__spot--ring .j2c-lookbook__ring {
    border: 2px solid #ffffff;
    box-shadow: 0 0 0 2px #16191d, 0 1px 3px rgba(0, 0, 0, 0.35);
    background: transparent;
}

/* Pulse — ring + animated halo */
.j2c-lookbook__spot--pulse .j2c-lookbook__ring {
    border: 2px solid #ffffff;
    box-shadow: 0 0 0 2px #16191d, 0 1px 3px rgba(0, 0, 0, 0.35);
}

.j2c-lookbook__spot--pulse .j2c-lookbook__ring::after {
    content: '';
    position: absolute;
    inset: -6px;
    border-radius: 50%;
    border: 2px solid #ffffff;
    animation: j2c-lookbook-pulse 1.8s ease-out infinite;
}

@keyframes j2c-lookbook-pulse {
    0% { transform: scale(0.7); opacity: 0.9; }
    100% { transform: scale(1.4); opacity: 0; }
}

/* Solid — filled dot, dual-tone hairline retained */
.j2c-lookbook__spot--solid .j2c-lookbook__ring {
    background: #16191d;
    border: 2px solid #ffffff;
}

/* Number — solid, carries the pin's ordinal */
.j2c-lookbook__spot--number .j2c-lookbook__ring {
    background: #16191d;
    border: 2px solid #ffffff;
    color: #ffffff;
}

/* Plus — solid with a rotating glyph (non-colour open-state signal) */
.j2c-lookbook__spot--plus .j2c-lookbook__ring {
    background: #16191d;
    border: 2px solid #ffffff;
}

.j2c-lookbook__spot--plus .j2c-lookbook__ring::before {
    content: '+';
    position: absolute;
    color: #ffffff;
    font-size: 1rem;
    line-height: 1;
    transition: transform 0.15s ease;
}

.j2c-lookbook__spot--plus[aria-expanded="true"] .j2c-lookbook__ring::before {
    transform: rotate(45deg);
}

/* Tag — a small pill carrying the pin's title inline (opaque by default: 4.5:1 body text) */
.j2c-lookbook__spot--tag {
    width: auto;
    height: auto;
    min-width: 24px;
    min-height: 24px;
}

.j2c-lookbook__spot--tag .j2c-lookbook__ring {
    border-radius: 999px;
    background: #16191d;
    color: #ffffff;
    padding: 0.25rem 0.6rem;
    font-size: 0.75rem;
    white-space: nowrap;
}

/* Crosshair — two thin strokes, minimal ink, subject stays visible */
.j2c-lookbook__spot--crosshair .j2c-lookbook__ring {
    background: transparent;
}

.j2c-lookbook__spot--crosshair .j2c-lookbook__ring::before,
.j2c-lookbook__spot--crosshair .j2c-lookbook__ring::after {
    content: '';
    position: absolute;
    background: #ffffff;
    box-shadow: 0 0 0 1px #16191d;
}

.j2c-lookbook__spot--crosshair .j2c-lookbook__ring::before {
    width: 14px;
    height: 2px;
}

.j2c-lookbook__spot--crosshair .j2c-lookbook__ring::after {
    width: 2px;
    height: 14px;
}

@media (prefers-reduced-motion: reduce) {
    .j2c-lookbook__spot--pulse .j2c-lookbook__ring::after {
        animation: none;
        display: none;
    }

    .j2c-lookbook__spot--plus .j2c-lookbook__ring::before {
        transition: none;
    }
}

/* ---------------------------------------------------------------------
   Popover card (enhanced, JS-driven — see lookbook.js). Not present
   until JS sets [popover]; without JS the same node stays in-flow in
   the list below and is fully reachable (PRD §12.1, WCAG A7).
   ------------------------------------------------------------------ */
.j2c-lookbook__card[popover] {
    position: fixed;
    inset: unset;
    margin: 0;
    padding: 0;
    border: 0;
    max-width: min(20rem, calc(100vw - 2rem));
    background: transparent;
    overflow: visible;
}

.j2c-lookbook__card[popover]:popover-open {
    display: block;
}

.j2c-lookbook__card-body {
    display: flex;
    gap: 0.75rem;
    align-items: flex-start;
    padding: 0.85rem;
    border-radius: 0.375rem;
    box-shadow: 0 0.5rem 1.5rem rgba(0, 0, 0, 0.15);
}

/* Scoped so a page mixing a bootstrap5 lookbook and a uikit lookbook never has one
   family's theme tokens win over the other's for the shared selector (M-18). */
.j2c-lookbook--bootstrap5 .j2c-lookbook__card-body {
    border: 1px solid var(--lb-tooltip-border, var(--bs-border-color, #dee2e6));
    background: var(--lb-tooltip-bg, var(--bs-body-bg, #ffffff));
    color: var(--lb-tooltip-fg, var(--bs-body-color, #16191d));
}

.j2c-lookbook__card[popover] .j2c-lookbook__card-body {
    min-width: 14rem;
}

/* Tooltip themes */
.j2c-lookbook__spot--theme-auto {
    color-scheme: light dark;
}

.j2c-lookbook__spot--theme-dark .j2c-lookbook__card-body {
    --lb-tooltip-bg: #16191d;
    --lb-tooltip-fg: #f5f6f8;
    --lb-tooltip-border: #454c55;
}

.j2c-lookbook__spot--theme-light .j2c-lookbook__card-body {
    --lb-tooltip-bg: #ffffff;
    --lb-tooltip-fg: #16191d;
    --lb-tooltip-border: #dee2e6;
}

.j2c-lookbook__spot--theme-custom .j2c-lookbook__card-body {
    --lb-tooltip-bg: var(--lb-custom-bg);
    --lb-tooltip-fg: var(--lb-custom-fg);
    --lb-tooltip-border: var(--lb-custom-fg);
}

.j2c-lookbook__card-thumb img {
    display: block;
    width: 4rem;
    height: 4rem;
    object-fit: cover;
    border-radius: 0.25rem;
}

.j2c-lookbook__card-info {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    min-width: 0;
}

.j2c-lookbook__card-title {
    font-weight: 600;
    text-decoration: none;
    color: inherit;
}

.j2c-lookbook__card-title:hover,
.j2c-lookbook__card-title:focus-visible {
    text-decoration: underline;
}

.j2c-lookbook__card-text {
    margin: 0;
    font-size: 0.9rem;
}

.j2c-lookbook__card-price {
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.j2c-lookbook__card-price-sale {
    font-weight: 700;
}

.j2c-lookbook__card-button {
    align-self: flex-start;
}

/* ---------------------------------------------------------------------
   The always-visible list beneath the image. Base state: flowing,
   reachable content — works with JS off. Enhanced state: a
   snap-scrolling strip below the mobile breakpoint, or hidden (its
   items promoted to popovers) above it.
   ------------------------------------------------------------------ */
.j2c-lookbook__list {
    list-style: none;
    margin: 1rem 0 0;
    padding: 0;
    display: grid;
    gap: 0.75rem;
}

.j2c-lookbook__card {
    scroll-snap-align: start;
}

/* Closed popovers are hidden by the UA; display:none here would also stop the open one rendering in the top layer. */
.j2c-lookbook.j2c-lookbook--enhanced .j2c-lookbook__list-wrap:has(.j2c-lookbook__card[popover]) .j2c-lookbook__list {
    margin: 0;
    gap: 0;
}

/* The mode class is only set by lookbook.js below the configured breakpoint. */
.j2c-lookbook.j2c-lookbook--mode-strip .j2c-lookbook__list {
    display: flex;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    gap: 0.75rem;
    padding-bottom: 0.5rem;
}

.j2c-lookbook.j2c-lookbook--mode-strip .j2c-lookbook__card {
    flex: 0 0 auto;
    width: min(16rem, 85%);
}

.j2c-lookbook.j2c-lookbook--mode-strip .j2c-lookbook__card.is-active .j2c-lookbook__card-body {
    outline: 2px solid currentColor;
    outline-offset: -2px;
}

/* Drawer mode: the whole list surfaces in a bottom sheet on demand. */
.j2c-lookbook__list-wrap[popover] {
    position: fixed;
    inset: auto 0 0 0;
    margin: 0;
    width: 100%;
    max-height: 80vh;
    overflow-y: auto;
    border: 0;
    border-radius: 0.75rem 0.75rem 0 0;
    padding: 1rem;
}

.j2c-lookbook--bootstrap5 .j2c-lookbook__list-wrap[popover] {
    background: var(--bs-body-bg, #ffffff);
    color: var(--bs-body-color, #16191d);
}

.j2c-lookbook__list-wrap[popover]:popover-open {
    display: block;
}

.j2c-lookbook__list-wrap[popover] .j2c-lookbook__list {
    display: grid;
}

@media (prefers-reduced-motion: no-preference) {
    .j2c-lookbook__list-wrap[popover] {
        transition: transform 0.2s ease;
    }
}

/* List-only mode: the marker/card pairing (PRD §12.3) is conveyed visually by number —
   every pin style becomes a plain numbered dot here (pin_style=number already shows its
   own server-rendered ordinal; every other style would otherwise be an anonymous mark,
   or in crosshair/plus's case keep a ::before/::after meant for a different purpose) (M-8). */
.j2c-lookbook--mode-list_only .j2c-lookbook__spot:not(.j2c-lookbook__spot--number) .j2c-lookbook__ring {
    background: #16191d;
    border: 2px solid #ffffff;
}

.j2c-lookbook--mode-list_only .j2c-lookbook__spot:not(.j2c-lookbook__spot--number) .j2c-lookbook__ring::after {
    content: none;
}

.j2c-lookbook--mode-list_only .j2c-lookbook__spot:not(.j2c-lookbook__spot--number) .j2c-lookbook__ring::before {
    content: counter(j2c-lookbook-spot);
    position: static;
    color: #ffffff;
    width: auto;
    height: auto;
    box-shadow: none;
    border: 0;
    background: transparent;
}

.j2c-lookbook--mode-list_only .j2c-lookbook__list {
    list-style: decimal;
    padding-left: 1.5rem;
}

/* Open/active state is signalled by size, never colour alone (WCAG 1.4.1, PRD §12.5). */
.j2c-lookbook__spot[aria-expanded="true"] .j2c-lookbook__ring,
.j2c-lookbook__spot.is-active .j2c-lookbook__ring {
    transform: scale(1.3);
}
