/* =============================================================================
   PageFound Product Pop Up — Frontend Styles  v1.2
   =============================================================================
   Accent colour → set in WooCommerce › Product Pop Up settings (admin).
   It is injected as --pgwp-accent on #pgwp-overlay by PHP automatically.
   All other STYLE values are marked with "/* STYLE:" comments.
   ============================================================================= */

#pgwp-overlay {
    --pgwp-accent:       #2b9e4c;  /* fallback; overridden by PHP */
    --pgwp-accent-dark:  color-mix(in srgb, var(--pgwp-accent) 75%, black);
    --pgwp-accent-light: color-mix(in srgb, var(--pgwp-accent) 55%, white);
}
@supports not (color: color-mix(in srgb, red 50%, blue)) {
    #pgwp-overlay {
        --pgwp-accent-dark:  var(--pgwp-accent);
        --pgwp-accent-light: var(--pgwp-accent);
    }
}


/* =============================================================================
   1. OVERLAY
   ============================================================================= */

.pgwp-overlay {
    position: fixed;
    inset: 0;
    z-index: 999999;
    background: rgba(0, 0, 0, 0.62);  /* STYLE: overlay darkness */
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    box-sizing: border-box;
    animation: pgwpFadeIn 0.22s ease-out;
}

@keyframes pgwpFadeIn  { from { opacity: 0; } to { opacity: 1; } }

.pgwp-overlay.pgwp-is-closing {
    animation: pgwpFadeOut 0.32s ease-in forwards;
    pointer-events: none;
}
@keyframes pgwpFadeOut { from { opacity: 1; } to { opacity: 0; } }


/* =============================================================================
   2. MODAL
   ============================================================================= */

.pgwp-modal {
    position: relative;
    width: 100%;
    max-width: 880px;            /* STYLE: maximum popup width */
    background: #ffffff;         /* STYLE: modal background */
    border-radius: 16px;         /* STYLE: corner roundness */
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.28);
    padding: 40px 36px 32px;     /* STYLE: inner padding */
    max-height: 90vh;
    overflow-y: auto;
    box-sizing: border-box;
    animation: pgwpSlideUp 0.26s ease-out;
    transform-origin: center bottom;
}

.pgwp-is-closing .pgwp-modal {
    animation: pgwpSlideDown 0.32s ease-in forwards;
}

@keyframes pgwpSlideUp   { from { transform: translateY(28px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
@keyframes pgwpSlideDown { from { transform: translateY(0); opacity: 1; }    to { transform: translateY(48px); opacity: 0; } }

.pgwp-modal::-webkit-scrollbar       { width: 5px; }
.pgwp-modal::-webkit-scrollbar-thumb { background: #ddd; border-radius: 3px; }


/* =============================================================================
   3. HEADER
   ============================================================================= */

.pgwp-modal-header {
    text-align: center;
    margin-bottom: 28px;  /* STYLE: space below header */
}
.pgwp-modal-header h2 {
    margin: 0 0 8px;
    font-size: 1.6rem;    /* STYLE: heading size */
    font-weight: 700;
    color: #1a1a1a;       /* STYLE: heading colour */
    line-height: 1.3;
}
.pgwp-subtitle {
    margin: 0;
    font-size: 1rem;      /* STYLE: subheading size */
    color: #666;          /* STYLE: subheading colour */
}


/* =============================================================================
   4. PRODUCT GRID
   ============================================================================= */

.pgwp-products-grid {
    display: grid;
    /*
     * STYLE: column layout.
     * auto-fit: 1 card = full-width, 2 = 2 cols, etc.
     * To force a fixed count: repeat(2, 1fr)
     */
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;             /* STYLE: gap between cards */
    margin-bottom: 24px;
}


/* =============================================================================
   5. PRODUCT CARD
   ============================================================================= */

.pgwp-product-card {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: #f9f9f9;      /* STYLE: card background */
    border: 1px solid #e4e4e4; /* STYLE: card border */
    border-radius: 12px;       /* STYLE: card corner roundness */
    transition: box-shadow 0.2s, transform 0.2s;
}
.pgwp-product-card:hover {
    box-shadow: 0 6px 22px rgba(0, 0, 0, 0.10);
    transform: translateY(-2px);
}


/* =============================================================================
   6. SLIDESHOW  —  three display modes: cover | contain | natural
   ============================================================================= */

/* ── Shared base ─────────────────────────────────────────────────────── */
.pgwp-slideshow {
    position: relative;
    overflow: hidden;
    background: #ececec;
    height: 200px;    /* STYLE: fixed image area height (cover / contain modes) */
}

.pgwp-slides-track {
    position: relative;
    width: 100%;
    height: 100%;
}

.pgwp-slide {
    position: absolute;
    inset: 0;
    opacity: 0;
    transition: opacity 0.4s ease;
    pointer-events: none;
}
.pgwp-slide.active {
    opacity: 1;
    pointer-events: auto;
}

.pgwp-slide img {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: cover;  /* default — overridden per mode below */
}

/* ── Mode: contain ───────────────────────────────────────────────────── */
/* Shows the full image inside the fixed box; neutral background fills gaps. */
.pgwp-slideshow[data-fit="contain"] {
    background: #f5f5f5;  /* STYLE: letterbox background in contain mode */
}
.pgwp-slideshow[data-fit="contain"] .pgwp-slide img {
    object-fit: contain;
}

/* ── Mode: natural ───────────────────────────────────────────────────── */
/* No fixed height — the card and popup grow to fit the image. */
.pgwp-slideshow[data-fit="natural"] {
    height: auto;
    background: none;
    overflow: visible;
}
.pgwp-slideshow[data-fit="natural"] .pgwp-slides-track {
    height: auto;
}
.pgwp-slideshow[data-fit="natural"] .pgwp-slide {
    position: static;
    opacity: 1;
    display: none;
    transition: none;
    pointer-events: auto;
}
.pgwp-slideshow[data-fit="natural"] .pgwp-slide.active {
    display: block;
}
.pgwp-slideshow[data-fit="natural"] .pgwp-slide img {
    width: 100%;
    height: auto;
    object-fit: unset;
}
/* In natural mode use dots below the image; hide side arrows */
.pgwp-slideshow[data-fit="natural"] .pgwp-slide-prev,
.pgwp-slideshow[data-fit="natural"] .pgwp-slide-next {
    display: none;
}
.pgwp-slideshow[data-fit="natural"] .pgwp-dots {
    position: static;
    transform: none;
    justify-content: center;
    padding: 8px 0 4px;
}
.pgwp-slideshow[data-fit="natural"] .pgwp-dot {
    background: rgba(0, 0, 0, 0.22);
}
.pgwp-slideshow[data-fit="natural"] .pgwp-dot.active {
    background: rgba(0, 0, 0, 0.6);
}

/* ── Prev / next arrows ──────────────────────────────────────────────── */
.pgwp-slide-prev,
.pgwp-slide-next {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 2;
    background: rgba(0, 0, 0, 0.36);  /* STYLE: arrow button background */
    color: #fff;
    border: none;
    width: 30px;
    height: 36px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 20px;
    line-height: 36px;
    text-align: center;
    padding: 0;
    transition: background 0.15s;
    user-select: none;
}
.pgwp-slide-prev { left: 6px; }
.pgwp-slide-next { right: 6px; }
.pgwp-slide-prev:hover,
.pgwp-slide-next:hover { background: rgba(0, 0, 0, 0.6); }

/* ── Dot indicators ──────────────────────────────────────────────────── */
.pgwp-dots {
    position: absolute;
    bottom: 8px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 5px;
    z-index: 2;
}
.pgwp-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.55);
    cursor: pointer;
    transition: background 0.2s, transform 0.2s;
}
.pgwp-dot.active {
    background: #fff;
    transform: scale(1.25);
}


/* =============================================================================
   7. CARD BODY
   ============================================================================= */

.pgwp-card-body {
    display: flex;
    flex-direction: column;
    flex: 1;
    padding: 16px;    /* STYLE: card body padding */
}

.pgwp-card-title {
    margin: 0 0 6px;
    font-size: 1rem;  /* STYLE: card title size */
    font-weight: 600;
    color: #1a1a1a;   /* STYLE: card title colour */
    line-height: 1.35;
}

.pgwp-card-description {
    margin: 0 0 10px;
    flex: 1;
    font-size: 0.875rem;  /* STYLE: description size */
    color: #666;          /* STYLE: description colour */
    line-height: 1.55;
}

.pgwp-card-price {
    display: block;
    margin-bottom: 10px;
    font-weight: 700;
    font-size: 1.15rem;   /* STYLE: price size */
    line-height: 1;
    color: var(--pgwp-accent);
}


/* =============================================================================
   8. VARIATION SWATCHES
   ============================================================================= */

.pgwp-variation-container {
    margin-bottom: 14px;
}

/* One row per item when qty > 1 */
.pgwp-var-item-row {
    display: flex;
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 10px;
}
.pgwp-var-item-row:last-child { margin-bottom: 0; }

/* "Item 1:" label */
.pgwp-var-item-label {
    font-size: 0.8125rem;
    font-weight: 700;
    color: #444;
    white-space: nowrap;
    min-width: 52px;
    padding-top: 9px; /* align with swatch height */
}

/* Swatch group */
.pgwp-swatches {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

/* ── Individual swatch ──────────────────────────────────────────── */
/*
 * Each swatch uses its variation colour as the border.
 * Border colour is set inline by JS via --pgwp-swatch-color.
 * STYLE: change border-radius to adjust swatch shape.
 * 8px = rounded rectangle (default), 50px = fully rounded pill.
 */
.pgwp-swatch {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 6px 16px;
    border: 2.5px solid var(--pgwp-swatch-color, #e0e0e0);
    border-radius: 8px;             /* STYLE: swatch corner roundness */
    background: #ffffff;
    color: #222;
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 500;
    line-height: 1;
    white-space: nowrap;
    min-height: 36px;
    transition: border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
    user-select: none;
}

.pgwp-swatch:hover {
    box-shadow: 0 1px 6px rgba(0, 0, 0, 0.14);
}

/* Selected state — thicker border + very subtle background tint */
.pgwp-swatch.selected {
    border-width: 3px;
    background: color-mix(in srgb, var(--pgwp-swatch-color, var(--pgwp-accent)) 12%, white);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.10);
}
@supports not (color: color-mix(in srgb, red 50%, blue)) {
    .pgwp-swatch.selected { background: #f5f5f5; }
}

/* Label text inside swatch */
.pgwp-swatch-text {
    display: inline-block;
    line-height: 1;
}

/* =============================================================================
   9. QUANTITY SELECTOR
   ============================================================================= */

.pgwp-qty-row {
    margin-bottom: 12px;
    padding: 10px 12px;
    background: #f3f3f3;  /* STYLE: qty selector background */
    border-radius: 8px;
}

.pgwp-qty-label {
    margin: 0 0 8px;
    font-size: 0.8125rem;
    color: #555;
    font-weight: 500;
}

.pgwp-qty-controls {
    display: flex;
    align-items: center;
    gap: 0;
}

.pgwp-qty-btn {
    width: 32px;
    height: 32px;
    background: #fff;
    border: 1px solid #ccc;
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
    user-select: none;
}
.pgwp-qty-btn:hover { background: #f0f0f0; }
.pgwp-qty-minus { border-radius: 6px 0 0 6px; }
.pgwp-qty-plus  { border-radius: 0 6px 6px 0; }

.pgwp-qty-value {
    min-width: 36px;
    height: 32px;
    border-top: 1px solid #ccc;
    border-bottom: 1px solid #ccc;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9375rem;
    font-weight: 600;
    background: #fff;
    color: #1a1a1a;
}


/* =============================================================================
   10. ADD-TO-CART BUTTON
   ============================================================================= */

.pgwp-add-btn {
    display: block;
    width: 100%;
    text-align: center;
    border: none;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.9375rem;  /* STYLE: button font size */
    padding: 11px 16px;    /* STYLE: button padding */
    border-radius: 8px;    /* STYLE: button corner roundness */
    line-height: 1;
    background: var(--pgwp-accent);
    color: #ffffff;
    transition: background 0.18s, opacity 0.18s;
}
.pgwp-add-btn:hover:not(:disabled) { background: var(--pgwp-accent-dark); }
.pgwp-add-btn:focus                { outline: 2px solid var(--pgwp-accent); outline-offset: 2px; }
.pgwp-add-btn.pgwp-loading         { opacity: 0.65; cursor: wait; }
.pgwp-add-btn.pgwp-added,
.pgwp-add-btn.pgwp-added:disabled  { background: var(--pgwp-accent-light); cursor: default; }
.pgwp-add-btn.pgwp-error           { background: #c0392b; }  /* STYLE: error colour */


/* =============================================================================
   10. FOOTER ("No thanks")
   ============================================================================= */

.pgwp-modal-footer { text-align: center; padding-top: 6px; }
.pgwp-no-thanks-btn {
    background: none;
    border: none;
    cursor: pointer;
    text-decoration: underline;
    padding: 6px 8px;
    font-size: 0.875rem;  /* STYLE: "No thanks" size */
    color: #999;          /* STYLE: "No thanks" colour */
    transition: color 0.15s;
}
.pgwp-no-thanks-btn:hover { color: #444; }


/* =============================================================================
   11. SCROLL LOCK
   ============================================================================= */

body.pgwp-no-scroll { overflow: hidden; }


/* =============================================================================
   12. RESPONSIVE
   ============================================================================= */

@media (max-width: 768px) {
    .pgwp-modal { padding: 32px 24px 26px; }
    .pgwp-modal-header h2 { font-size: 1.35rem; }
}

@media (max-width: 600px) {
    .pgwp-modal {
        border-radius: 14px;
        padding: 28px 16px 22px;
    }
    .pgwp-modal-header h2 { font-size: 1.2rem; }
    .pgwp-modal-header    { margin-bottom: 20px; }
    .pgwp-products-grid   { grid-template-columns: 1fr; gap: 14px; }
    .pgwp-slideshow       { height: 220px; }  /* STYLE: mobile slideshow height */
    .pgwp-slideshow[data-fit="natural"] { height: auto; }
    .pgwp-slide-prev, .pgwp-slide-next {
        width: 26px; height: 32px;
        font-size: 17px; line-height: 32px;
    }
}
