/* ============================================================
   RDS CAL Homepage Product Grid  —  rdscal-hpg-style.css  v1.3
   Changes from v1.2:
   - Radio buttons visible on variation rows (custom styled)
   - Qty stepper fixed compact width on desktop (96px)
   - Mobile: variation name on top, price below, both centered
   - Stars: "Rated X out of 5" text hidden, only ★ glyphs shown
   - Mobile: product images fill card width, gap between cards
   ============================================================ */

/* ── CSS Variables ─────────────────────────────────────────── */
.rdscal-hpg-grid {
    --hpg-border:     #e5e7eb;
    --hpg-accent:     #0067b8;
    --hpg-accent-h:   #005a9e;
    --hpg-accent-bg:  #e8f2fb;
    --hpg-muted:      #6b7280;
    --hpg-green:      #15803d;
    --hpg-price:      #0067b8;
    --hpg-shadow-h:   0 6px 20px rgba(0,0,0,.10), 0 2px 6px rgba(0,0,0,.05);
    --hpg-tr:         .15s ease;
}

/* ── Grid ──────────────────────────────────────────────────── */
.rdscal-hpg-grid {
    display: grid;
    gap: 20px;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    align-items: stretch;
}

.rdscal-hpg-cols-1 { grid-template-columns: 1fr; }
.rdscal-hpg-cols-2 { grid-template-columns: repeat(2, 1fr); }
.rdscal-hpg-cols-3 { grid-template-columns: repeat(3, 1fr); }
.rdscal-hpg-cols-4 { grid-template-columns: repeat(4, 1fr); }

/* Ensure grid fills Beaver Builder / theme containers */
.fl-module-content .rdscal-hpg-grid,
.fl-col-content .rdscal-hpg-grid,
.entry-content .rdscal-hpg-grid,
.page-content .rdscal-hpg-grid {
    width: 100%;
    max-width: 100%;
}

/* ── Card ──────────────────────────────────────────────────── */
.rdscal-hpg-card {
    background: #fff;
    border: 1px solid var(--hpg-border);
    border-radius: 10px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
    box-shadow: 0 2px 8px rgba(0,0,0,.08), 0 1px 3px rgba(0,0,0,.06);
    transition: box-shadow var(--hpg-tr), transform var(--hpg-tr);
    position: relative;
    z-index: 0;
}
.rdscal-hpg-card:hover {
    box-shadow: var(--hpg-shadow-h);
    transform: translateY(-2px);
    z-index: 2;
}

/* ── Product Image ─────────────────────────────────────────── */
.rdscal-hpg-img-wrap {
    background: #ffffff;
    border-bottom: 1px solid var(--hpg-border);
    width: 100%;
    overflow: hidden;
    aspect-ratio: 1 / 1;
    display: flex;
    align-items: center;
    justify-content: center;
}
.rdscal-hpg-img-wrap a { display: flex; width: 100%; height: 100%; align-items: center; justify-content: center; }
.rdscal-hpg-img {
    width: 100%; height: 100%;
    max-width: 100%;
    object-fit: contain;
    display: block;
    padding: 16px;
    box-sizing: border-box;
}

/* ── Body ──────────────────────────────────────────────────── */
.rdscal-hpg-body {
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    flex: 1;
    box-sizing: border-box;
}

/* ── Title ─────────────────────────────────────────────────── */
.rdscal-hpg-title {
    font-size: 1em; font-weight: 700; line-height: 1.35; margin: 0; color: inherit;
}
.rdscal-hpg-title a { color: inherit; text-decoration: none; }
.rdscal-hpg-title a:hover { color: var(--hpg-accent); }

/* ── Price ─────────────────────────────────────────────────── */
.rdscal-hpg-price {
    font-size: 1.25em; font-weight: 700; color: var(--hpg-price); line-height: 1.2;
}
.rdscal-hpg-price .woocommerce-Price-amount { color: var(--hpg-price); }
.rdscal-hpg-price del { font-size: .8em; color: var(--hpg-muted); font-weight: 400; margin-right: 4px; }
.rdscal-hpg-price ins { text-decoration: none; }

/* ── Variation Selector ─────────────────────────────────────── */
.rdscal-hpg-selector { display: flex; flex-direction: column; gap: 6px; }

.rdscal-hpg-sel-label {
    font-size: .75em; font-weight: 600;
    text-transform: uppercase; letter-spacing: .05em;
    color: var(--hpg-muted); margin-bottom: 2px;
}

/* ── Dropdown Variation Selector ──────────────────────────── */
.rdscal-hpg-sel-dropdown {
    width: 100%;
    padding: 9px 12px;
    font-size: .9em;
    font-weight: 500;
    font-family: inherit;
    color: inherit;
    background: #fff;
    border: 2px solid var(--hpg-border);
    border-radius: 7px;
    cursor: pointer;
    transition: border-color var(--hpg-tr);
    box-sizing: border-box;
    line-height: 1.4;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%236b7280' d='M1.41 0L6 4.58 10.59 0 12 1.41l-6 6-6-6z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 12px;
    padding-right: 32px;
}
.rdscal-hpg-sel-dropdown:hover {
    border-color: var(--hpg-accent);
}
.rdscal-hpg-sel-dropdown:focus {
    border-color: var(--hpg-accent);
    outline: none;
    box-shadow: 0 0 0 3px rgba(0,103,184,.15);
}
.rdscal-hpg-sel-dropdown option:disabled {
    color: #aaa;
}

/* ── User CAL Note ────────────────────────────────────────── */
.rdscal-hpg-user-cal-note {
    font-size: .8em;
    line-height: 1.4;
    color: #1e3a5f;
    background: #e8f0fe;
    border: 1px solid #b8d4f0;
    border-radius: 6px;
    padding: 8px 10px;
    margin-top: 6px;
}

/* ── Quantity + Add to Cart ────────────────────────────────── */
.rdscal-hpg-purchase-row {
    display: flex;
    align-items: stretch;
    gap: 8px;
    margin-top: auto;
}

/* Quantity stepper — fixed 96px on desktop */
.rdscal-hpg-qty-wrap {
    display: flex;
    align-items: stretch;
    border: 2px solid var(--hpg-border);
    border-radius: 7px;
    overflow: hidden;
    flex-shrink: 0;
    width: 120px;
    background: #fff;
}
.rdscal-hpg-qty-wrap button {
    background: none;
    border: none;
    width: 28px;
    font-size: 1.1em;
    font-weight: 600;
    color: inherit;
    cursor: pointer;
    transition: background var(--hpg-tr);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    font-family: inherit;
    flex-shrink: 0;
}
.rdscal-hpg-qty-wrap button:hover { background: #f3f4f6; color: #000; }

.rdscal-hpg-qty-input {
    flex: 1;
    min-width: 0;
    border: none;
    border-left: 1px solid var(--hpg-border);
    border-right: 1px solid var(--hpg-border);
    text-align: center;
    font-size: .9em;
    font-weight: 600;
    color: inherit;
    font-family: inherit;
    background: #fff;
    -moz-appearance: textfield;
    padding: 0;
}
.rdscal-hpg-qty-input::-webkit-inner-spin-button,
.rdscal-hpg-qty-input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }

/* Add to Cart button */
.rdscal-hpg-atc-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 10px 14px;
    background: var(--hpg-accent);
    color: #fff;
    border: none;
    border-radius: 7px;
    font-size: .9em;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    transition: background var(--hpg-tr), box-shadow var(--hpg-tr), transform var(--hpg-tr);
    white-space: nowrap;
    min-width: 0;
}
.rdscal-hpg-atc-btn:hover:not(:disabled) {
    background: var(--hpg-accent-h);
    box-shadow: 0 3px 10px rgba(0,103,184,.30);
    transform: translateY(-1px);
}
.rdscal-hpg-atc-btn:active:not(:disabled) { transform: translateY(0); }
.rdscal-hpg-atc-btn:disabled  { opacity: .6; cursor: not-allowed; }
.rdscal-hpg-atc-btn.is-loading { pointer-events: none; opacity: .8; }
.rdscal-hpg-atc-btn.is-success { background: #15803d; }

.rdscal-hpg-cart-icon { width: 15px; height: 15px; flex-shrink: 0; }
@keyframes rdscalHpgSpin { to { transform: rotate(360deg); } }
.rdscal-hpg-spin { width: 15px; height: 15px; animation: rdscalHpgSpin .7s linear infinite; }

/* ── Feature bullets ───────────────────────────────────────── */
.rdscal-hpg-features { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.rdscal-hpg-features li {
    font-size: .82em; color: var(--hpg-muted);
    display: flex; align-items: flex-start; gap: 5px; line-height: 1.4;
}
.rdscal-hpg-features li::before {
    content: '✓'; color: var(--hpg-green); font-weight: 700; flex-shrink: 0; margin-top: 1px;
}

/* ── View More Details link ───────────────────────────────── */
.rdscal-hpg-details-link {
    font-size: .82em;
    font-weight: 600;
    color: var(--hpg-accent);
    text-decoration: none;
    display: inline-block;
    transition: color var(--hpg-tr);
}
.rdscal-hpg-details-link:hover {
    color: var(--hpg-accent-h);
    text-decoration: underline;
}

/* ── Notice ────────────────────────────────────────────────── */
.rdscal-hpg-notice { font-size: .82em; font-weight: 500; padding: 7px 10px; border-radius: 6px; line-height: 1.4; }
.rdscal-hpg-notice.is-success { background: #f0fdf4; color: #15803d; border: 1px solid #bbf7d0; }
.rdscal-hpg-notice.is-error   { background: #fef2f2; color: #b91c1c; border: 1px solid #fecaca; }
.rdscal-hpg-error { color: #b91c1c; font-style: italic; font-size: .9em; }

/* ── Responsive ────────────────────────────────────────────── */

/* Tablet ≤900px: 3 or 4 cols → 2 cols */
@media (max-width: 900px) {
    .rdscal-hpg-cols-3,
    .rdscal-hpg-cols-4 { grid-template-columns: repeat(2, 1fr); }
}

/* Mobile ≤600px */
@media (max-width: 600px) {
    /* Grid: 2 cols with visible gap between cards */
    .rdscal-hpg-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 12px !important;
        padding: 0;
    }

    /* Cards: no extra overrides needed, shadow/radius from base */
    .rdscal-hpg-card {
        margin: 0 !important;
    }

    /* Product image: fill card width, square aspect ratio */
    .rdscal-hpg-img-wrap {
        aspect-ratio: 1 / 1;
    }
    .rdscal-hpg-img {
        padding: 6px;
        width: 100%;
        height: 100%;
        object-fit: contain;
    }

    .rdscal-hpg-body  { padding: 10px; gap: 7px; }
    .rdscal-hpg-price { font-size: 1em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
    .rdscal-hpg-title { font-size: .9em; }

    /* Dropdown: smaller on mobile */
    .rdscal-hpg-sel-dropdown {
        font-size: .75em;
        padding: 7px 9px;
        padding-right: 26px;
    }

    /* Qty + ATC stack vertically */
    .rdscal-hpg-purchase-row { flex-direction: column; gap: 6px; }
    .rdscal-hpg-qty-wrap { width: 100%; }
    .rdscal-hpg-atc-btn  { width: 100%; }

    /* Feature bullets: smaller on mobile */
    .rdscal-hpg-features li {
        font-size: .7em;
        gap: 3px;
        line-height: 1.3;
    }
    .rdscal-hpg-details-link {
        font-size: .7em;
    }
    .rdscal-hpg-user-cal-note {
        font-size: .68em;
        padding: 6px 8px;
    }
}
