/**
 * Product Rescue – Front office styles.
 *
 * Layout & components. Colours, radius, fonts and shadows come from the
 * active theme via CSS custom properties (printed inline in a <style> tag
 * from the Custom CSS field). Layout settings (card width, gap) arrive as
 * inline variables on #epr-rescue-box.
 *
 * @author    Rekire <info@rekire.com>
 * @copyright Since 2026 Rekire
 * @license   https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0
 */

/* ------------------------------------------------------------------ */
/* Fallback variables (used when no theme CSS is loaded)               */
/* ------------------------------------------------------------------ */
.epr-rescue-box,
.epr-popup-dialog {
    --epr-bg: #ffffff;
    --epr-bg-image: none;
    --epr-card-bg: #ffffff;
    --epr-text: #111111;
    --epr-text-muted: #666666;
    --epr-accent: #2563eb;
    --epr-accent-hover: #1d4ed8;
    --epr-accent-text: #ffffff;
    --epr-border: #e3e3e3;
    --epr-radius: 12px;
    --epr-card-radius: 10px;
    --epr-shadow: 0 4px 16px rgba(0, 0, 0, .08);
    --epr-card-shadow: 0 2px 8px rgba(0, 0, 0, .06);
    --epr-font: inherit;
    --epr-heading-weight: 700;
    --epr-gap: 16px;
    --epr-card-width: 220px;
}

/* ------------------------------------------------------------------ */
/* Rescue box                                                          */
/* ------------------------------------------------------------------ */
.epr-hidden-original { display: none !important; }

.epr-rescue-box {
    max-width: 1280px;
    margin: 20px auto 40px;
    padding: 24px;
    background-color: var(--epr-bg);
    background-image: var(--epr-bg-image);
    color: var(--epr-text);
    font-family: var(--epr-font);
    border: 1px solid var(--epr-border);
    border-radius: var(--epr-radius);
    box-shadow: var(--epr-shadow);
}

.epr-rescue-box.epr-visible { display: block; }

.epr-message { margin-bottom: 24px; }
.epr-message h2 {
    font-size: 1.75rem;
    font-weight: var(--epr-heading-weight);
    margin: 0 0 10px;
    color: var(--epr-text);
}
.epr-message .epr-intro,
.epr-message p {
    font-size: 1.05rem;
    margin: 0;
    color: var(--epr-text-muted);
}

.epr-align-center .epr-message { text-align: center; }
.epr-align-left .epr-message { text-align: left; }

.epr-section { margin-top: 28px; }
.epr-section h3 {
    margin-bottom: 14px;
    color: var(--epr-text);
    font-weight: var(--epr-heading-weight);
}

/* ------------------------------------------------------------------ */
/* Slider                                                              */
/* ------------------------------------------------------------------ */
.epr-slider-wrap {
    display: grid;
    grid-template-columns: 42px 1fr 42px;
    gap: 8px;
    align-items: center;
}

.epr-slider {
    display: flex;
    gap: var(--epr-gap);
    overflow: auto;
    scroll-snap-type: x mandatory;
    scrollbar-width: thin;
    padding: 6px 2px 14px;
}

.epr-card {
    min-width: var(--epr-card-width);
    max-width: var(--epr-card-width);
    scroll-snap-align: start;
    border: 1px solid var(--epr-border);
    border-radius: var(--epr-card-radius);
    background: var(--epr-card-bg);
    box-shadow: var(--epr-card-shadow);
    overflow: hidden;
    transition: transform .18s ease, box-shadow .18s ease;
}

.epr-card:hover { transform: translateY(-3px); }

.epr-card-link {
    display: flex;
    flex-direction: column;
    gap: 6px;
    text-decoration: none !important;
    color: inherit;
    padding: 12px;
    height: 100%;
}

.epr-card img {
    width: 100%;
    aspect-ratio: 1 / 1;
    object-fit: contain;
    background: rgba(127, 127, 127, .06);
    border-radius: calc(var(--epr-card-radius) / 2);
}

.epr-fit-cover .epr-card img,
.epr-fit-cover .epr-list-item img { object-fit: cover; }

.epr-card strong { color: var(--epr-text); line-height: 1.3; }
.epr-card small { opacity: .7; color: var(--epr-text-muted); }

.epr-price {
    font-weight: 700;
    margin-top: auto;
    color: var(--epr-accent);
}

.epr-arrow {
    border: 0;
    background: var(--epr-accent);
    color: var(--epr-accent-text);
    width: 38px;
    height: 46px;
    border-radius: calc(var(--epr-card-radius));
    cursor: pointer;
    transition: background .15s ease;
}

.epr-arrow:hover { background: var(--epr-accent-hover); }

/* ------------------------------------------------------------------ */
/* Secondary sections (grid lists)                                     */
/* ------------------------------------------------------------------ */
.epr-product-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: var(--epr-gap);
}

.epr-list-item {
    display: flex;
    gap: 12px;
    align-items: center;
    border: 1px solid var(--epr-border);
    border-radius: var(--epr-card-radius);
    background: var(--epr-card-bg);
    box-shadow: var(--epr-card-shadow);
    padding: 10px;
    text-decoration: none !important;
    color: inherit;
    transition: transform .18s ease, box-shadow .18s ease;
}

.epr-list-item:hover { transform: translateY(-3px); }
.epr-list-item img {
    width: 68px;
    height: 68px;
    object-fit: contain;
    flex: 0 0 auto;
}
.epr-list-item span { display: flex; flex-direction: column; }
.epr-list-item strong { color: var(--epr-text); }
.epr-list-item small { opacity: .65; color: var(--epr-text-muted); }
.epr-list-item em {
    font-style: normal;
    font-weight: 700;
    color: var(--epr-accent);
}

/* ------------------------------------------------------------------ */
/* CTA                                                                 */
/* ------------------------------------------------------------------ */
.epr-cta { margin-top: 26px; text-align: center; }

.epr-btn {
    display: inline-block;
    padding: 10px 26px;
    background: var(--epr-accent);
    color: var(--epr-accent-text) !important;
    border-radius: var(--epr-card-radius);
    text-decoration: none !important;
    font-weight: 600;
    border: 0;
    cursor: pointer;
    transition: background .15s ease, transform .15s ease;
}

.epr-btn:hover { background: var(--epr-accent-hover); transform: translateY(-1px); }

/* ------------------------------------------------------------------ */
/* Out-of-stock notice (in-page mode)                                  */
/* ------------------------------------------------------------------ */
.epr-oos-notice {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    margin: 12px 0;
    padding: 10px 14px;
    border: 1px solid #f1c9c9;
    border-left: 4px solid #d9534f;
    border-radius: 6px;
    background: #fdf3f3;
    color: #842029;
    font-size: .95rem;
}

.epr-oos-notice-title { font-weight: 700; }

.epr-oos-notice-link {
    border: 0;
    background: transparent;
    color: #b02a37;
    text-decoration: underline;
    cursor: pointer;
    font-weight: 600;
    padding: 0;
}

body.epr-oos-inpage .product-actions button[name="add-to-cart"],
body.epr-oos-inpage .add-to-cart,
body.epr-oos-inpage #add-to-cart-or-refresh .btn-primary {
    opacity: .55;
    cursor: not-allowed;
    pointer-events: none;
}

/* ------------------------------------------------------------------ */
/* Popup                                                               */
/* ------------------------------------------------------------------ */
.epr-popup {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 999999;
}

.epr-popup-open { display: block; }

.epr-popup-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, .62);
}

.epr-popup-dialog {
    position: relative;
    z-index: 2;
    width: min(920px, calc(100% - 32px));
    max-height: 86vh;
    overflow: auto;
    margin: 7vh auto;
    background-color: var(--epr-bg);
    background-image: var(--epr-bg-image);
    color: var(--epr-text);
    font-family: var(--epr-font);
    border: 1px solid var(--epr-border);
    border-radius: var(--epr-radius);
    padding: 28px;
    box-shadow: var(--epr-shadow);
}

.epr-popup-dialog h2 { font-weight: var(--epr-heading-weight); }
.epr-popup-dialog .epr-intro { color: var(--epr-text-muted); }

.epr-popup-close {
    position: absolute;
    right: 12px;
    top: 8px;
    border: 0;
    background: transparent;
    font-size: 34px;
    line-height: 1;
    cursor: pointer;
    color: var(--epr-text);
}

.epr-popup-products {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 14px;
    margin-top: 20px;
}

.epr-popup-products a { text-decoration: none !important; color: inherit; }
.epr-popup-products img {
    width: 100%;
    aspect-ratio: 1 / 1;
    object-fit: contain;
    background: var(--epr-card-bg);
    border: 1px solid var(--epr-border);
    border-radius: var(--epr-card-radius);
}
.epr-popup-products span {
    display: block;
    margin-top: 6px;
    font-size: .9rem;
    color: var(--epr-text);
}

.epr-popup-lock { overflow: hidden; }

/* ------------------------------------------------------------------ */
/* Layout styles (cards / clean / compact)                             */
/* ------------------------------------------------------------------ */
.epr-style-clean .epr-rescue-box,
.epr-rescue-box.epr-style-clean {
    border: 0 !important;
    box-shadow: none !important;
    padding-left: 0 !important;
    padding-right: 0 !important;
    background-image: none !important;
}
.epr-style-clean .epr-card,
.epr-style-clean .epr-list-item {
    border-color: transparent;
    box-shadow: none;
}

.epr-style-compact { padding: 16px; }
.epr-style-compact .epr-message { margin-bottom: 14px; }
.epr-style-compact .epr-section { margin-top: 16px; }

.epr-shadow-none.epr-rescue-box { box-shadow: none; }
.epr-shadow-strong.epr-rescue-box { box-shadow: 0 14px 44px rgba(0, 0, 0, .22); }

/* ------------------------------------------------------------------ */
/* Effects                                                             */
/* ------------------------------------------------------------------ */
@keyframes eprFadeIn   { from { opacity: 0; } to { opacity: 1; } }
@keyframes eprZoomIn   { from { opacity: 0; transform: scale(.92); } to { opacity: 1; transform: scale(1); } }
@keyframes eprSlideUp  { from { opacity: 0; transform: translateY(26px); } to { opacity: 1; transform: none; } }
@keyframes eprPulse    { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.012); } }
@keyframes eprGlow     { 0%, 100% { box-shadow: 0 0 0 rgba(37, 99, 235, 0); } 50% { box-shadow: 0 0 26px rgba(37, 99, 235, .45); } }
@keyframes eprShake    { 0%, 100% { transform: translateX(0); } 15% { transform: translateX(-7px); } 30% { transform: translateX(6px); } 45% { transform: translateX(-5px); } 60% { transform: translateX(4px); } 75% { transform: translateX(-2px); } }
@keyframes eprBounce   { 0% { opacity: 0; transform: translateY(40px); } 55% { opacity: 1; transform: translateY(-8px); } 75% { transform: translateY(4px); } 100% { transform: none; } }
@keyframes eprCardIn   { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

.epr-fx-fade     { animation: eprFadeIn .55s ease both; }
.epr-fx-zoom     { animation: eprZoomIn .5s cubic-bezier(.2, .8, .3, 1) both; }
.epr-fx-slide_up { animation: eprSlideUp .55s cubic-bezier(.2, .8, .3, 1) both; }
.epr-fx-pulse    { animation: eprFadeIn .45s ease both, eprPulse 2.4s ease-in-out .5s infinite; }
.epr-fx-glow     { animation: eprFadeIn .45s ease both, eprGlow 2.6s ease-in-out .4s infinite; }
.epr-fx-shake    { animation: eprFadeIn .35s ease both, eprShake .7s ease-in-out .45s 2; }
.epr-fx-bounce   { animation: eprBounce .8s cubic-bezier(.28, .84, .42, 1) both; }

.epr-fx-slow { animation-duration: 1.1s, 3.6s; }
.epr-fx-fast { animation-duration: .28s, 1.4s; }
.epr-fx-slow.epr-fx-zoom, .epr-fx-slow.epr-fx-slide_up,
.epr-fx-slow.epr-fx-bounce, .epr-fx-slow.epr-fx-shake { animation-duration: 1.1s; }
.epr-fx-fast.epr-fx-zoom, .epr-fx-fast.epr-fx-slide_up,
.epr-fx-fast.epr-fx-bounce, .epr-fx-fast.epr-fx-shake { animation-duration: .28s; }

/* Staggered card entrance whenever an effect is active */
[class*="epr-fx-"]:not(.epr-fx-none) .epr-card,
[class*="epr-fx-"]:not(.epr-fx-none) .epr-list-item {
    animation: eprCardIn .5s ease both;
}
[class*="epr-fx-"]:not(.epr-fx-none) .epr-card:nth-child(2),
[class*="epr-fx-"]:not(.epr-fx-none) .epr-list-item:nth-child(2) { animation-delay: .07s; }
[class*="epr-fx-"]:not(.epr-fx-none) .epr-card:nth-child(3),
[class*="epr-fx-"]:not(.epr-fx-none) .epr-list-item:nth-child(3) { animation-delay: .14s; }
[class*="epr-fx-"]:not(.epr-fx-none) .epr-card:nth-child(4),
[class*="epr-fx-"]:not(.epr-fx-none) .epr-list-item:nth-child(4) { animation-delay: .21s; }
[class*="epr-fx-"]:not(.epr-fx-none) .epr-card:nth-child(5),
[class*="epr-fx-"]:not(.epr-fx-none) .epr-list-item:nth-child(5) { animation-delay: .28s; }
[class*="epr-fx-"]:not(.epr-fx-none) .epr-card:nth-child(n+6),
[class*="epr-fx-"]:not(.epr-fx-none) .epr-list-item:nth-child(n+6) { animation-delay: .35s; }

@media (prefers-reduced-motion: reduce) {
    .epr-rescue-box,
    .epr-card,
    .epr-list-item,
    .epr-popup-dialog {
        animation: none !important;
        transition: none !important;
    }
}

/* ------------------------------------------------------------------ */
/* Responsive                                                          */
/* ------------------------------------------------------------------ */
@media (max-width: 767px) {
    .epr-rescue-box { padding: 16px; border-radius: 0; }
    .epr-slider-wrap { grid-template-columns: 1fr; }
    .epr-arrow { display: none; }
    .epr-card { min-width: 72vw; max-width: 72vw; }
    .epr-product-list { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
}
