.saskreels {
    /* SaskSoftware brand palette (matches SaskPWA) */
    --sr-accent: #FF6B35;
    --sr-accent-2: #FF8C5A;
    --sr-btn-text: #ffffff;
    --sr-dark: #1a1a2e;
    --sr-radius: 14px;
}

.saskreels-heading {
    font-size: 22px;
    font-weight: 800;
    margin: 0 0 14px;
    color: var(--sr-dark);
    text-align: center;
}

/* ─── Card layouts (match the store's product grid: 2:3 cards, responsive) ─── */
.saskreels--grid,
.saskreels--feed {
    display: grid;
    grid-template-columns: repeat(2, 1fr); /* mobile */
    gap: 14px;
}
@media (min-width: 600px) {
    /* 3 columns on desktop/tablet to match the store's 3-col product grid. */
    .saskreels--grid, .saskreels--feed { grid-template-columns: repeat(3, 1fr); gap: 18px; }
}
.saskreels--carousel {
    display: flex;
    gap: 14px;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    padding-bottom: 10px;
    -webkit-overflow-scrolling: touch;
}
.saskreels--carousel .saskreels-card {
    flex: 0 0 46%; /* ~2 per view on phones */
    scroll-snap-align: start;
}
@media (min-width: 600px) { .saskreels--carousel .saskreels-card { flex: 0 0 31%; } /* ~3 per view, product-card width */ }

/* ─── Card ─────────────────────────────────────── */
.saskreels-card { cursor: pointer; }
.saskreels-card__media {
    position: relative;
    aspect-ratio: 2 / 3; /* same as the store product image (300x450) */
    border-radius: var(--sr-radius);
    overflow: hidden;
    background: #000;
    box-shadow: 0 4px 16px rgba(0,0,0,0.12);
    transition: transform .15s ease, box-shadow .15s ease;
}
.saskreels-card:hover .saskreels-card__media,
.saskreels-card:focus-visible .saskreels-card__media {
    transform: translateY(-3px);
    box-shadow: 0 10px 26px rgba(0,0,0,0.22);
}
.saskreels-card__poster {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.saskreels-card__play {
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    width: 54px; height: 54px;
    border-radius: 50%;
    background: rgba(0,0,0,0.45);
    backdrop-filter: blur(2px);
}
.saskreels-card__play::after {
    content: '';
    position: absolute;
    top: 50%; left: 54%;
    transform: translate(-50%, -50%);
    border-style: solid;
    border-width: 9px 0 9px 15px;
    border-color: transparent transparent transparent #fff;
}
.saskreels-card__info { padding: 9px 2px 0; }
.saskreels-card__title {
    /* Match the store product-card title exactly (measured: Roboto 16/600 #333). */
    font-family: Roboto, sans-serif;
    font-size: 16px;
    font-weight: 600;
    color: #333;
    line-height: 1.3;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}
.saskreels-card__price { display: block; font-family: Roboto, sans-serif; font-size: 15px; margin-top: 3px; }
.saskreels-card__price del { opacity: 0.6; margin-right: 5px; }

/* ─── Lightbox ─────────────────────────────────── */
.saskreels-modal {
    /* The modal is a sibling of .saskreels, so it needs its own brand vars,
       otherwise the orange Buy Now / View & Buy buttons render with no fill. */
    --sr-accent: #FF6B35;
    --sr-accent-2: #FF8C5A;
    --sr-btn-text: #ffffff;
    position: fixed;
    inset: 0;
    z-index: 2147483000; /* above site install banners / sticky bars */
    display: none;
    align-items: center;
    justify-content: center;
}
/* Hide a site "Add to Home Screen" / install banner while the reel is open. */
body.saskreels-modal-open #saskpwa-a2hs-banner,
body.saskreels-modal-open .saskpwa-a2hs,
body.saskreels-modal-open .pwa-install-banner { display: none !important; }
.saskreels-modal.is-open { display: flex; }
.saskreels-modal__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(10,10,15,0.82);
    backdrop-filter: blur(3px);
}
.saskreels-modal__dialog {
    position: relative;
    width: min(92vw, 380px);
    aspect-ratio: 9 / 16;
    max-height: 88vh;
    max-height: 88dvh; /* exclude mobile browser toolbars */
    border-radius: 18px;
    overflow: hidden;
    background: #000;
    box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}
.saskreels-modal__stage { position: absolute; inset: 0; }
.saskreels-modal__video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    cursor: pointer;
}
.saskreels-modal__sound {
    position: absolute;
    top: 14px; left: 14px;
    background: rgba(0,0,0,0.5);
    color: #fff;
    font-size: 11px;
    padding: 5px 10px;
    border-radius: 20px;
    pointer-events: none;
}

/* Close + nav */
.saskreels-modal__close {
    position: absolute;
    top: 12px; right: 12px;
    z-index: 5;
    width: 38px; height: 38px;
    border: 0;
    border-radius: 50%;
    background: rgba(0,0,0,0.45);
    color: #fff;
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
}
.saskreels-modal__nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 5;
    width: 44px; height: 44px;
    border: 0;
    border-radius: 50%;
    background: rgba(0,0,0,0.4);
    color: #fff;
    font-size: 26px;
    line-height: 1;
    cursor: pointer;
}
.saskreels-modal__prev { left: max(10px, calc(50vw - 250px)); }
.saskreels-modal__next { right: max(10px, calc(50vw - 250px)); }
.saskreels-modal__close:hover,
.saskreels-modal__nav:hover { background: rgba(0,0,0,0.7); }

/* Product overlay at the bottom */
.saskreels-modal__overlay {
    position: absolute;
    left: 0; right: 0; bottom: 0;
    padding: 16px 14px 14px;
    background: linear-gradient(to top, rgba(10,10,15,0.96) 45%, rgba(10,10,15,0.55) 75%, rgba(10,10,15,0));
}
/* Buttons must stay legible over any video colour. */
.saskreels-modal__buy .saskreels-btn,
.saskreels-modal__viewbuy { box-shadow: 0 3px 12px rgba(0,0,0,0.45); }
.saskreels-modal__buy .saskreels-add { border: 1px solid rgba(0,0,0,0.06); }
.saskreels-modal__product {
    display: flex;
    align-items: center;
    gap: 10px;
    background: #fff;
    border-radius: 12px;
    padding: 8px;
    text-decoration: none;
    margin-bottom: 10px;
}
.saskreels-modal__thumb {
    width: 46px; height: 46px;
    object-fit: cover;
    border-radius: 8px;
    flex: 0 0 auto;
}
.saskreels-modal__ptext { display: flex; flex-direction: column; min-width: 0; }
.saskreels-modal__ptitle {
    font-size: 13px; font-weight: 700; color: #1a1a2e; line-height: 1.25;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 230px;
}
.saskreels-modal__pprice { font-size: 13px; color: #1a1a2e; }
.saskreels-modal__pprice del { opacity: 0.55; margin-right: 5px; }

.saskreels-modal__viewbuy {
    display: block;
    text-align: center;
    margin-top: 8px;
    padding: 13px;
    border-radius: 10px;
    font-weight: 800;
    letter-spacing: 0.3px;
    text-decoration: none;
    background: linear-gradient(135deg, var(--sr-accent), var(--sr-accent-2));
    color: var(--sr-btn-text);
}

/* ─── Buy controls (in card buy block + cloned into modal) ─── */
.saskreels-variations { display: flex; gap: 6px; margin-bottom: 8px; flex-wrap: wrap; }
.saskreels-attr { flex: 1 1 auto; min-width: 90px; padding: 8px; border-radius: 8px; border: 0; font-size: 13px; }
.saskreels-actions { display: flex; gap: 8px; }
.saskreels-btn {
    flex: 1;
    padding: 12px 14px;
    min-height: 44px;
    border: 0;
    border-radius: 10px;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    background: #fff;
    color: #111;
    transition: transform .08s ease, opacity .15s ease;
}
.saskreels-btn:active { transform: scale(0.97); }
.saskreels-btn--buy { background: linear-gradient(135deg, var(--sr-accent), var(--sr-accent-2)); color: var(--sr-btn-text); }
.saskreels-btn--disabled, .saskreels-btn[disabled] { opacity: 0.5; cursor: not-allowed; }
.saskreels-btn.is-busy { opacity: 0.7; cursor: progress; }
.saskreels-btn--added { background: #22c55e !important; color: #fff !important; }

/* Never let the feed cause horizontal page scroll (which on mobile expands the
   layout viewport and breaks the responsive breakpoints). */
html, body { overflow-x: hidden; max-width: 100%; }
.saskreels { max-width: 100%; box-sizing: border-box; }
.saskreels * { box-sizing: border-box; }
.saskreels--carousel { width: 100%; max-width: 100%; }
.saskreels-feedback { display: block; margin-top: 8px; font-size: 13px; min-height: 18px; color: #fff; }
.saskreels-feedback.is-ok { color: #34d399; }
.saskreels-feedback.is-error { color: #fca5a5; }

@media (max-width: 600px) {
    .saskreels-modal__prev { left: 8px; }
    .saskreels-modal__next { right: 8px; }
    /* 100dvh excludes the iOS Safari toolbar so the video + buttons are never cut off. */
    .saskreels-modal__dialog { width: 100vw; height: 100vh; height: 100dvh; max-height: 100dvh; border-radius: 0; aspect-ratio: auto; }
    /* Keep the buy controls clear of any site install banner / iOS safe area. */
    .saskreels-modal__overlay { padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px)); }
}
