/**
 * @package     mod_alfa_items_pro
 * @copyright   (C) 2024-2026 Easylogic CO LP / Agamemnon Fakas. All rights reserved.
 * @license     GNU General Public License version 3 or later; see LICENSE
 * @author      Agamemnon Fakas <info@easylogic.gr>
 */

.mod-alfa-items-pro {
    --mod-alfa-items-accent: var(--alfa-action-primary-bg, #333);
    --mod-alfa-items-gap: 16px;

    /* Palette aliases: declared once here, used by name below. The accent is the
       storefront's primary action unless the module was given its own colour, so
       a merchant who themes the shop themes the card too. Each fallback is what
       the module looked like before the palette existed. */
    --alfa-items-surface: var(--alfa-surface, #fff);
    /* Writing on that surface. `inherit` by default, so the module keeps taking
       the page's own text colour until a merchant or the palette says otherwise. */
    --alfa-items-surface-color: var(--alfa-surface-color, inherit);
    /* Text that should recede: the empty-state message. */
    --alfa-items-muted: var(--alfa-muted-color, #6b7280);
    --alfa-items-hairline: var(--alfa-hairline, #e2e2e2);
    --alfa-items-radius: var(--alfa-radius, 4px);
    /* A card's own background, inside its border and corners: none unless the module or a
       block sets one (Palette, slotColourCss); a block's own background stays around it. */
    --alfa-items-card-bg: transparent;
    /* Its border's colour, the same in both modes unless the module or a block sets one. */
    --alfa-items-card-border-color: #000000;
    /* An overlay card sets its name and buy form on the photo, so it is dark in both
       modes: its ground where an item has no image, and the colour of the writing on it. */
    --alfa-items-overlay: #111827;
    --alfa-items-overlay-color: #fff;
    /* What an overlay card's name and buy form sit on: a gradient toward the image at the
       bottom and at the top, a band in the middle. A card's Overlay background replaces it. */
    --alfa-items-overlay-bottom: linear-gradient(to top, rgb(0 0 0 / 0.85), rgb(0 0 0 / 0.55) 60%, transparent);
    --alfa-items-overlay-middle: rgb(0 0 0 / 0.6);
    --alfa-items-overlay-top: linear-gradient(to bottom, rgb(0 0 0 / 0.85), rgb(0 0 0 / 0.55) 60%, transparent);
    /* How long a hover or focus change takes, for everything in the module that eases
       (never the slider track: Keen moves the slides itself). */
    --alfa-items-transition: 0.2s ease;

    color: var(--alfa-items-surface-color);
}

/* TABS */

.mod-alfa-items-pro .tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
    margin: 0 0 1rem;
    border-bottom: 1px solid var(--alfa-items-hairline);
}

.mod-alfa-items-pro .tab {
    appearance: none;
    background: none;
    border: 0;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    padding: 0.6rem 1rem;
    font: inherit;
    color: inherit;
    cursor: pointer;
    opacity: 0.7;
    transition: opacity var(--alfa-items-transition), border-color var(--alfa-items-transition);
}

.mod-alfa-items-pro .tab:hover,
.mod-alfa-items-pro .tab:focus-visible {
    opacity: 1;
}

.mod-alfa-items-pro .tab[data-state="active"] {
    opacity: 1;
    font-weight: 600;
    border-bottom-color: var(--mod-alfa-items-accent);
}

.mod-alfa-items-pro .panel[hidden] {
    display: none;
}

/* A panel being fetched keeps its skeleton (default_placeholder.php) on
   screen; the shapes shimmer until the cards arrive. Rules an edition sharing
   the page must not inherit are scoped by the root marker. */
.mod-alfa-items-pro[data-mod-alfa-items-pro] .panel[data-state="loading"] {
    min-height: 6rem;
}

.mod-alfa-items-pro .slot-placeholder {
    display: flex;
}

.mod-alfa-items-pro .placeholder-row {
    display: grid;
    grid-template-columns: repeat(var(--placeholder-count, 1), minmax(0, 1fr));
    gap: var(--mod-alfa-items-gap);
    width: 100%;
}

.mod-alfa-items-pro .placeholder-card,
.mod-alfa-items-pro .placeholder-block {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    width: 100%;
    min-width: 0;
}

.mod-alfa-items-pro .placeholder-image,
.mod-alfa-items-pro .placeholder-line,
.mod-alfa-items-pro .placeholder-block {
    display: block;
    border-radius: var(--alfa-items-radius);
    background: linear-gradient(90deg, rgba(0, 0, 0, 0.08) 25%, rgba(0, 0, 0, 0.16) 37%, rgba(0, 0, 0, 0.08) 63%);
    background-size: 400% 100%;
    animation: mod-alfa-items-pro-shimmer 1.4s ease infinite;
}

.mod-alfa-items-pro .placeholder-image {
    aspect-ratio: 1 / 1;
}

.mod-alfa-items-pro .placeholder-line {
    height: 0.9rem;
}

.mod-alfa-items-pro .placeholder-line-short {
    width: 55%;
}

.mod-alfa-items-pro .placeholder-block {
    min-height: 6rem;
}

/* A placeholder takes its card's frame when the card has one. */
.mod-alfa-items-pro .placeholder-card[data-ratio="16-9"] .placeholder-image {
    aspect-ratio: 16 / 9;
}

.mod-alfa-items-pro .placeholder-card[data-ratio="16-10"] .placeholder-image {
    aspect-ratio: 16 / 10;
}

.mod-alfa-items-pro .placeholder-card[data-ratio="4-3"] .placeholder-image {
    aspect-ratio: 4 / 3;
}

.mod-alfa-items-pro .placeholder-card[data-ratio="3-4"] .placeholder-image {
    aspect-ratio: 3 / 4;
}

@keyframes mod-alfa-items-pro-shimmer {
    from { background-position: 100% 0; }
    to   { background-position: 0 0; }
}

.mod-alfa-items-pro .empty {
    margin: 0;
    color: var(--alfa-items-muted);
}

/* TEXTS AROUND A TAB + VIEW ALL */

.mod-alfa-items-pro .tab-text-before {
    margin: 0 0 1rem;
}

.mod-alfa-items-pro .tab-text-after {
    margin: 1rem 0 0;
}

.mod-alfa-items-pro .view-all {
    margin: 1rem 0 0;
    text-align: right;
}

.mod-alfa-items-pro .view-all a {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    color: var(--mod-alfa-items-accent);
    font-weight: 600;
    text-decoration: none;
}

.mod-alfa-items-pro .view-all a:hover,
.mod-alfa-items-pro .view-all a:focus-visible {
    text-decoration: underline;
}

.mod-alfa-items-pro .view-all svg {
    width: 1rem;
    height: 1rem;
}

/* CUSTOM LAYOUT — the tab's own grid of slots; the areas and column count come
   from the layout's descriptor (inline custom properties on the block). */

.mod-alfa-items-pro .pattern {
    display: grid;
    grid-template-columns: repeat(var(--mod-alfa-items-columns, 4), minmax(0, 1fr));
    grid-template-areas: var(--mod-alfa-items-areas);
    gap: var(--mod-alfa-items-pattern-gap, var(--mod-alfa-items-gap));
}

.mod-alfa-items-pro .pattern + .pattern {
    margin-top: var(--mod-alfa-items-gap);
}

.mod-alfa-items-pro .slot {
    min-width: 0;
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
}

/* A styled slot (background, padding…) wraps its card like a tile. */
.mod-alfa-items-pro .slot-card > .item-card {
    flex: 1 1 auto;
}

/* The block's own texts, above and below its content. */
.mod-alfa-items-pro .slot-text {
    width: 100%;
    min-width: 0;
}

.mod-alfa-items-pro .slot-text-before {
    margin-bottom: 0.5rem;
}

.mod-alfa-items-pro .slot-text-after {
    margin-top: 0.5rem;
}

.mod-alfa-items-pro .slot-text > :last-child {
    margin-bottom: 0;
}

.mod-alfa-items-pro .slot > .item-card,
.mod-alfa-items-pro .slot > .slider {
    width: 100%;
}

.mod-alfa-items-pro .slot-content {
    width: 100%;
    min-width: 0;
}

/* A slider inside a slot keeps its arrows within the slot. */
.mod-alfa-items-pro .slot .arrow-prev {
    left: 0.25rem;
}

.mod-alfa-items-pro .slot .arrow-next {
    right: 0.25rem;
}

/* CARD — one product card (default_card.php). Its classes are the module's own, so
   neither the shop's listing styles nor a template's card rules reach it. What sits in
   its buy form — the price, the stock line, add to cart, variant and option choices —
   Alfa draws and styles.

   This is the default card. What a module, a tab or a layout block sets instead — on every screen,
   or for one breakpoint — is written as rules for the card's place (`data-look`) by
   CardLook::css, from the same list of declarations, so every property a setting can
   change is declared here. */

.mod-alfa-items-pro .item-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0;
    height: 100%;
    padding: var(--alfa-items-card-padding, 10px);
    overflow: visible;
    border: 1px solid var(--alfa-items-card-border-color);
    /* Its width on each side; 0 removes it there. */
    border-width: var(--alfa-items-card-border, 1px);
    border-radius: var(--alfa-items-card-radius, 0);
    color: inherit;
    background: var(--alfa-items-card-bg);
    box-shadow: var(--alfa-items-card-shadow, none);
    text-align: center;
    transition: opacity var(--alfa-items-transition), box-shadow var(--alfa-items-transition);
}

/* The hover shadow also shows while the card holds focus, eased in by the card's transition. */
.mod-alfa-items-pro .item-card:is(:hover, :focus-within) {
    box-shadow: var(--alfa-items-card-shadow-hover, var(--alfa-items-card-shadow, none));
}

/* An overlay card stacks its image and its name and buy form in one grid cell. */
.mod-alfa-items-pro .item-card > * {
    grid-area: auto;
}

/* A field plugin's badge overlays the image's corner. */
.mod-alfa-items-pro .item-card-image {
    position: relative;
    flex: 0 1 auto;
    align-self: auto;
    width: auto;
    aspect-ratio: auto;
    max-height: none;
    overflow: visible;
}

.mod-alfa-items-pro .item-card-image > a {
    display: inline;
    height: auto;
}

/* The image itself is rounded, so a frame and an image in its own shape round alike. */
.mod-alfa-items-pro .item-card-image img {
    width: 100%;
    height: auto;
    max-height: none;
    border-radius: var(--alfa-items-card-image-radius, 0);
    object-fit: contain;
    object-position: center;
}

/* The name and the buy form, under the image; the look moves the image around them. */
.mod-alfa-items-pro .item-card-body {
    z-index: auto;
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    align-items: center;
    align-self: auto;
    width: 100%;
    min-width: 0;
    padding: 0;
    background: none;
}

/* The name and the buy form keep to the bottom, so the buy forms of a row line up. */
.mod-alfa-items-pro .item-card-title {
    display: block;
    overflow: visible;
    margin-top: auto;
    -webkit-line-clamp: none;
}

/* The read-only specifications, inside the buy form after the selectors: one line per
   field, its name then its values. Spaced only while a row is visible, since ShowOn can
   hide every spec. */
.mod-alfa-items-pro .item-card-specs:has(> .item-field-surface:not([hidden])) {
    margin: 0.35rem 0;
}

.mod-alfa-items-pro .item-card-specs .spec-field {
    display: block;
}

.mod-alfa-items-pro .item-card-specs .spec-field-label {
    margin-inline-end: 0.25rem;
}

/* The add-to-cart controls sit in a centred column, so their own row is centred too. */
.mod-alfa-items-pro .item-card .item-cart-add {
    justify-content: center;
}

/* While a variant or option change re-draws the card, it dims and ignores the pointer. */
.mod-alfa-items-pro .item-card.is-loading {
    opacity: 0.55;
    pointer-events: none;
}

/* SLIDER */

.mod-alfa-items-pro .slider {
    position: relative;
}

.mod-alfa-items-pro .slide {
    display: flex;
}

/* keen-slider clips each slide, and a card fills its slide: left clipped, the room the
   track makes above and below a card with a shadow would still cut the shadow off. */
.mod-alfa-items-pro .slider .slide.keen-slider__slide {
    overflow: visible;
}

.mod-alfa-items-pro .slide > .item-card {
    width: 100%;
}

.mod-alfa-items-pro .arrow {
    position: absolute;
    top: 50%;
    z-index: 2;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.5rem;
    height: 2.5rem;
    padding: 0;
    border: 1px solid var(--alfa-items-hairline);
    border-radius: 50%;
    background: var(--alfa-items-surface);
    color: var(--mod-alfa-items-accent);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.12);
    cursor: pointer;
    transform: translateY(-50%);
    transition: opacity var(--alfa-items-transition);
}

.mod-alfa-items-pro .arrow-prev {
    left: -1.25rem;
}

.mod-alfa-items-pro .arrow-next {
    right: -1.25rem;
}

.mod-alfa-items-pro .arrow:disabled {
    opacity: 0.35;
    cursor: default;
}

.mod-alfa-items-pro .arrow svg {
    width: 1.25rem;
    height: 1.25rem;
}

.mod-alfa-items-pro .dots {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    margin-top: 1rem;
}

.mod-alfa-items-pro .dot {
    width: 0.6rem;
    height: 0.6rem;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.2);
    cursor: pointer;
    transition: background-color var(--alfa-items-transition);
}

@media (prefers-reduced-motion: reduce) {
    .mod-alfa-items-pro :is(.tab, .arrow, .dot, .item-card) {
        transition: none;
    }
}

/* A slider's track clips what sticks out of it: a place whose cards have a shadow
   gives it room (12px) in its rules. */
.mod-alfa-items-pro .slider .track {
    padding-block: 0;
}

.mod-alfa-items-pro .dot[data-state="active"] {
    background: var(--mod-alfa-items-accent);
}

@media (max-width: 767px) {
    .mod-alfa-items-pro .arrow-prev {
        left: 0.25rem;
    }

    .mod-alfa-items-pro .arrow-next {
        right: 0.25rem;
    }

}

/* The layout's tablet / mobile behaviour (designed arrangements, automatic collapse,
   hidden slots) is emitted per module instance at the merchant's own breakpoint
   widths — see AlfaItemsProHelper::responsiveCss(). */

@media (prefers-reduced-motion: reduce) {
    .mod-alfa-items-pro .placeholder-image,
    .mod-alfa-items-pro .placeholder-line,
    .mod-alfa-items-pro .placeholder-block {
        animation: none;
    }
}

/* ---------------------------------------------------------------------------
   DARK
   The module's own dark values, so it is correct in both modes on its own — a page
   that never loads com_alfa's palette still gets a readable panel instead of dark
   text on a dark ground. Where the palette IS loaded it wins, so a merchant who
   themes the shop still themes this module; these are the floor, not the ceiling.

   Keyed on what the PAGE declares, never on the device alone: a visitor who picks
   light on a dark laptop must get light. The third selector is the case where no
   Alfa template is installed — neither attribute exists, so the device decides.
   --------------------------------------------------------------------------- */
:is(:root[data-theme="dark"], :root[data-theme-default="dark"]:not([data-theme]))
.mod-alfa-items-pro {
    --mod-alfa-items-accent: var(--alfa-action-primary-bg, #e5e7eb);
    --alfa-items-surface: var(--alfa-surface, #1f2937);
    --alfa-items-surface-color: var(--alfa-surface-color, #e5e7eb);
    --alfa-items-muted: var(--alfa-muted-color, #9ca3af);
    --alfa-items-hairline: var(--alfa-hairline, #374151);
    --alfa-items-card-bg: transparent;
    --alfa-items-card-border-color: #000000;
}

@media (prefers-color-scheme: dark) {
    :is(:root[data-theme="auto"],
        :root[data-theme-default="auto"]:not([data-theme]),
        :root:not([data-theme]):not([data-theme-default]))
    .mod-alfa-items-pro {
        --mod-alfa-items-accent: var(--alfa-action-primary-bg, #e5e7eb);
        --alfa-items-surface: var(--alfa-surface, #1f2937);
        --alfa-items-surface-color: var(--alfa-surface-color, #e5e7eb);
        --alfa-items-muted: var(--alfa-muted-color, #9ca3af);
        --alfa-items-hairline: var(--alfa-hairline, #374151);
        --alfa-items-card-bg: transparent;
        --alfa-items-card-border-color: #000000;
    }
}
