/* ====================================================================
   Product card polish — category index pages
   --------------------------------------------------------------------
   Loaded AFTER the inline page CSS, so it cleanly layers on top of the
   existing classic-theme rules without disturbing the dark-theme
   overrides scoped under html.palette-midnight / html.palette-royal.
   No markup changes — works with the existing card structure.
   ==================================================================== */

.card-with-compare {
    --card-bg:      #fff;
    --card-bd:      color-mix(in srgb, var(--orient-gray-200) 80%, transparent);
    --card-bd-hi:   color-mix(in srgb, var(--orient-blue) 28%, var(--orient-gray-200));
    --card-bd-sel:  color-mix(in srgb, var(--orient-blue) 55%, var(--orient-gray-200));
    --card-shadow:  0 1px 1px rgba(16,24,40,.05), 0 8px 22px rgba(16,24,40,.06);
    --card-shadow-h:0 2px 4px rgba(16,24,40,.06), 0 18px 40px rgba(3,78,162,.10);
    position: relative;
    border-radius: 18px;
    padding-bottom: 0;
}

/* The clickable card surface */
.card-with-compare .featured__card {
    display: block;
    overflow: hidden;
    border-radius: 18px;
    background: var(--card-bg);
    border: 1px solid var(--card-bd);
    box-shadow: var(--card-shadow);
    transition: transform .25s cubic-bezier(0.22, 1, 0.36, 1),
                box-shadow .25s cubic-bezier(0.22, 1, 0.36, 1),
                border-color .25s ease;
    text-decoration: none;
    color: inherit;
}
.card-with-compare:hover .featured__card {
    transform: translateY(-3px);
    border-color: var(--card-bd-hi);
    box-shadow: var(--card-shadow-h);
}
.card-with-compare .featured__card:focus-visible {
    outline: 2px solid color-mix(in srgb, var(--orient-blue) 70%, #fff);
    outline-offset: 3px;
}

/* Image well: gradient + subtle brand halo on hover */
.card-with-compare .featured__card-img {
    height: 240px;
    display: grid;
    place-items: center;
    padding: 18px;
    position: relative;
    background:
        radial-gradient(120% 80% at 50% 12%,
            color-mix(in srgb, var(--orient-blue) 9%, #fff), transparent 60%),
        linear-gradient(180deg,
            color-mix(in srgb, var(--orient-gray-200) 50%, #fff), #fff);
}
.card-with-compare .featured__card-img::after {
    content: '';
    position: absolute; inset: 0;
    background: radial-gradient(120% 80% at 50% 65%,
        color-mix(in srgb, var(--orient-blue) 14%, transparent), transparent 60%);
    opacity: 0;
    transition: opacity .35s ease;
    pointer-events: none;
}
.card-with-compare:hover .featured__card-img::after { opacity: 1; }

.card-with-compare .featured__card-img img {
    max-width: 100%;
    max-height: 192px;
    object-fit: contain;
    transform: translateZ(0);
    transition: transform .35s cubic-bezier(0.22, 1, 0.36, 1);
    filter: drop-shadow(0 10px 18px rgba(16,24,40,.10));
}
.card-with-compare:hover .featured__card-img img {
    transform: scale(1.04);
}

/* Body — divider above content, refined typography */
.card-with-compare .featured__card-body {
    padding: 18px 18px 20px;
    border-top: 1px solid color-mix(in srgb, var(--orient-gray-200) 65%, transparent);
}
.card-with-compare .featured__card-series {
    font-family: var(--font-heading), Montserrat, sans-serif;
    font-size: 11px;
    letter-spacing: 0.10em;
    text-transform: uppercase;
    color: color-mix(in srgb, var(--orient-blue) 90%, #fff);
    margin: 0 0 6px;
    line-height: 1.2;
    font-weight: 700;
}
.card-with-compare .featured__card-name {
    font-family: var(--font-body), Inter, sans-serif;
    font-size: 15px;
    line-height: 1.4;
    font-weight: 500;
    color: var(--orient-gray-800);
    margin: 0 0 10px;
    /* clamp to 2 lines to keep cards uniform */
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    min-height: 42px;
}
.card-with-compare .featured__card-price {
    font-family: var(--font-heading), Montserrat, sans-serif;
    font-size: 15px;
    font-weight: 700;
    letter-spacing: 0.01em;
    color: color-mix(in srgb, var(--orient-blue) 85%, #000);
    margin: 0;
}

/* Compare chip — bottom-right of the card body (below the image, on the
   white card surface, never over the product photo) */
.card-with-compare .compare-check {
    position: absolute;
    top: auto;
    left: auto;
    bottom: 14px;
    right: 14px;
    z-index: 3;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 10px 5px 8px;
    border-radius: 999px;
    background: var(--card-bg);
    border: 1px solid color-mix(in srgb, var(--orient-gray-200) 70%, transparent);
    font: 600 11px/1 var(--font-body), Inter, sans-serif;
    color: color-mix(in srgb, var(--orient-gray-800) 80%, #fff);
    cursor: pointer;
    transition: border-color .2s ease, color .2s ease, background .2s ease;
}
.card-with-compare .compare-check:hover {
    border-color: color-mix(in srgb, var(--orient-blue) 40%, transparent);
    color: color-mix(in srgb, var(--orient-blue) 90%, #000);
}
.card-with-compare .compare-check input[type="checkbox"] {
    width: 13px; height: 13px;
    margin: 0;
    accent-color: var(--orient-blue);
    cursor: pointer;
}

/* Reserve a row at the bottom of the body for the chip so it never
   overlaps the title, series, or price */
.card-with-compare .featured__card-body {
    padding-bottom: 52px;
}

/* Selected state — when the compare checkbox is ticked, highlight the card */
.card-with-compare:has(.compare-check input:checked) .featured__card {
    border-color: var(--card-bd-sel);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--orient-blue) 15%, transparent),
                var(--card-shadow-h);
}
.card-with-compare:has(.compare-check input:checked) .compare-check {
    background: color-mix(in srgb, var(--orient-blue) 10%, var(--card-bg));
    color: color-mix(in srgb, var(--orient-blue) 85%, #000);
    border-color: color-mix(in srgb, var(--orient-blue) 40%, transparent);
}

/* ====================================================================
   Cards-per-row layout — flex-wrap with justify-content:center so the
   last (partial) row centers automatically.
   Driven by body[data-cards-per-row="3|4|5"] (set by price-visibility.js).
   ==================================================================== */
body[data-cards-per-row] .featured__scroll {
    display: flex !important;
    flex-wrap: wrap;
    justify-content: center;
    gap: 24px;
    overflow-x: visible;
    scroll-snap-type: none;
    padding: 20px 0;
}
body[data-cards-per-row] .featured__scroll > .card-with-compare {
    flex-grow: 0;
    flex-shrink: 0;
    scroll-snap-align: none;
}
body[data-cards-per-row] .featured__scroll > .card-with-compare > .featured__card {
    flex: 0 0 100%;
    width: 100%;
    scroll-snap-align: none;
}

/* Per-N widths — 24px gap × (N-1) is removed from full width */
body[data-cards-per-row="3"] .featured__scroll > .card-with-compare {
    width: calc((100% - 48px) / 3);
    max-width: 360px;
}
body[data-cards-per-row="4"] .featured__scroll > .card-with-compare {
    width: calc((100% - 72px) / 4);
    max-width: 320px;
}
body[data-cards-per-row="5"] .featured__scroll > .card-with-compare {
    width: calc((100% - 96px) / 5);
    max-width: 280px;
}

/* Image well scales with card width via aspect-ratio. The aspect itself
   is driven by body[data-box-shape-effective] so portrait products
   (refrigerators / washing machines / water dispensers) get a tall box
   instead of being cropped by a wide one. Capped vertically so very
   wide viewports don't produce huge image areas. */
body[data-cards-per-row] .featured__card-img {
    height: auto;
    max-height: 380px;
    min-height: 180px;
}
body[data-box-shape-effective="wide"]   .featured__card-img { aspect-ratio: 4 / 3; }
body[data-box-shape-effective="square"] .featured__card-img { aspect-ratio: 1 / 1; }
body[data-box-shape-effective="tall"]   .featured__card-img { aspect-ratio: 3 / 4; }

/* Image fills the padded content area; object-fit:contain preserves aspect.
   Padding on .featured__card-img already provides breathing room. */
body[data-cards-per-row] .featured__card-img img {
    width: 100%;
    height: 100%;
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;        /* never crop in padded mode */
}

/* === Image fit: 'fill' — photo covers the entire box, edge to edge. === */
body[data-image-fit="fill"] .featured__card-img {
    padding: 0;
    overflow: hidden;
}
body[data-image-fit="fill"] .featured__card-img img {
    width: 100%;
    height: 100%;
    max-width: none;
    max-height: none;
    object-fit: cover;
    object-position: center;
    filter: none;            /* drop the float shadow when filling */
}
/* Keep the soft halo on hover but clip it inside the box */
body[data-image-fit="fill"] .featured__card-img::after {
    border-radius: inherit;
}

/* Fill-mode top spacing — pushes the image down from the box's top edge */
body[data-image-fit="fill"][data-fill-top="small"]  .featured__card-img { padding-top: 12px; }
body[data-image-fit="fill"][data-fill-top="medium"] .featured__card-img { padding-top: 24px; }
body[data-image-fit="fill"][data-fill-top="small"]  .featured__card-img img,
body[data-image-fit="fill"][data-fill-top="medium"] .featured__card-img img {
    height: calc(100% - var(--fill-top, 0px));
}
body[data-image-fit="fill"][data-fill-top="small"]  { --fill-top: 12px; }
body[data-image-fit="fill"][data-fill-top="medium"] { --fill-top: 24px; }

/* Padded-mode size variants — overrides the default 18px image-well padding */
body[data-image-fit="padded"][data-padding-size="compact"] .featured__card-img { padding: 8px; }
body[data-image-fit="padded"][data-padding-size="normal"]  .featured__card-img { padding: 18px; }
body[data-image-fit="padded"][data-padding-size="roomy"]   .featured__card-img { padding: 32px; }
/* Image always fills the inner (after-padding) area; padding alone
   controls visual breathing room. The earlier 78–92% caps are removed
   so the photo doesn't shrink further inside the already-padded box. */

/* Hide the irrelevant section in the settings panel based on current fit */
body[data-image-fit="fill"]   .price-vis-only-padded { display: none !important; }
body[data-image-fit="padded"] .price-vis-only-fill   { display: none !important; }

/* Image-review pin/notice rules live in assets/css/price-visibility.css
   so detail pages (which only load price-visibility.css) pick them up too. */

/* Responsive fallbacks — keep readable on narrow viewports */
@media (max-width: 1024px) {
    body[data-cards-per-row="4"] .featured__scroll > .card-with-compare,
    body[data-cards-per-row="5"] .featured__scroll > .card-with-compare {
        width: calc((100% - 48px) / 3);
        max-width: 320px;
    }
}
@media (max-width: 760px) {
    body[data-cards-per-row] .featured__scroll > .card-with-compare {
        width: calc((100% - 24px) / 2);
        max-width: none;
    }
}
@media (max-width: 480px) {
    body[data-cards-per-row] .featured__scroll > .card-with-compare {
        width: 100%;
    }
}

/* Dark themes: keep original glassy treatment, only soften corners + lift */
html.palette-midnight .card-with-compare .featured__card,
html.palette-royal    .card-with-compare .featured__card {
    border-radius: 18px;
}
html.palette-midnight .card-with-compare:hover .featured__card,
html.palette-royal    .card-with-compare:hover .featured__card {
    transform: translateY(-3px);
    box-shadow: 0 24px 48px rgba(0,0,0,0.35);
}
