/* ============================================================
   Shoppable Reel Carousel  —  Frontend v2.1
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; }

/* ── Full-width breakout ─────────────────────────────────── */
.irc-wrap {
    width: 100vw;
    position: relative;
    left: 50%;
    margin-left: -50vw;
    background: #fff;
    overflow: hidden;
}
.irc-outer {
    position: relative;
    padding: 20px 56px 28px;
    overflow: hidden;
}

/* ── Track ───────────────────────────────────────────────── */
.irc-track {
    display: flex;
    gap: 14px;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    /* Disable pointer events on track itself so only slides are clickable */
    scroll-behavior: auto; /* JS handles smooth scroll */
}
.irc-track::-webkit-scrollbar { display: none; }

/* ── Slides ─────────────────────────────────────────────── */
.irc-slide {
    flex: 0 0 calc((100% - 56px) / 5);
    scroll-snap-align: start;
    border-radius: 16px;
    overflow: hidden;
    background: #fff;
    box-shadow: 0 2px 14px rgba(0,0,0,.10);
    cursor: pointer;
    display: flex;
    flex-direction: column;
    transition: transform .22s ease, box-shadow .22s ease;
    user-select: none; /* prevent text-select while clicking */
}
.irc-slide:hover { transform: translateY(-4px); box-shadow: 0 10px 30px rgba(0,0,0,.15); }

/* ── Card media (9:16) ───────────────────────────────────── */
.irc-card-media {
    position: relative;
    width: 100%;
    aspect-ratio: 9 / 16;
    overflow: hidden;
    background: #111;
    flex-shrink: 0;
}

/*
 * Thumbnail image — ALWAYS VISIBLE as a permanent backdrop.
 * This means the video plays on top and when it loops back to
 * frame 0 there is never a grey/black flash — the image shows through.
 */
.irc-thumb-img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    z-index: 1;
}
.irc-thumb-placeholder {
    position: absolute;
    inset: 0;
    background: linear-gradient(160deg,#1a1a2e 0%,#16213e 60%,#0f3460 100%);
    z-index: 1;
}

/*
 * Preview video — sits on top of the thumbnail (z-index 2).
 * opacity is set to 1 by JS only after `canplay` fires,
 * ensuring the user never sees the loading grey frame.
 * We also manually seek to 0 just before the last frame so
 * the loop is seamless (no browser-gap flash).
 */
.irc-preview-video {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    z-index: 2;
    opacity: 0;          /* revealed by JS once ready */
    pointer-events: none;
}

/* Play button overlay — transparent background, just the button */
.irc-play-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 3;
    background: transparent;
    pointer-events: none;
}

/*
 * YouTube-style: red rounded-rectangle pill, 0.5 opacity at rest,
 * fuller opacity on hover.
 */
.irc-play-btn {
    pointer-events: auto;
    width: 68px; height: 46px;
    border-radius: 12px;
    background: rgba(255, 0, 0, 0.50);
    border: none;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer;
    transition: background .2s, transform .18s;
    padding: 0;
    box-shadow: 0 2px 12px rgba(0,0,0,.25);
}
.irc-slide:hover .irc-play-btn {
    background: rgba(255, 0, 0, 0.92);
    transform: scale(1.08);
}
.irc-play-btn svg {
    width: 22px; height: 22px;
    margin-left: 4px;
    filter: drop-shadow(0 1px 2px rgba(0,0,0,.3));
}

/* ── Mini product (below card) ───────────────────────────── */
.irc-mini-product {
    padding: 12px 14px 14px;
    display: flex; flex-direction: column; gap: 7px;
    flex: 1; background: #fff;
}
.irc-mini-name {
    font-size: 13px; font-weight: 600; color: #111;
    margin: 0; line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont,'Segoe UI',sans-serif;
}
.irc-mini-pricing { display:flex; align-items:center; flex-wrap:wrap; gap:5px; min-height:20px; }
.irc-sale-price  { font-size:15px; font-weight:700; color:#E1306C;
    font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',sans-serif; }
.irc-reg-price   { font-size:12px; color:#999; text-decoration:line-through;
    font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',sans-serif; }
.irc-norm-price  { font-size:15px; font-weight:700; color:#111;
    font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',sans-serif; }
.irc-badge {
    background:#ff5a1f; color:#fff; font-size:10px; font-weight:700;
    padding:2px 7px; border-radius:20px; letter-spacing:.3px;
    font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',sans-serif;
}
.irc-view-btn {
    display:block; background:#111; color:#fff !important;
    text-align:center; padding:10px; border-radius:8px;
    font-size:13px; font-weight:600; text-decoration:none !important;
    letter-spacing:.3px; transition:background .18s;
    font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',sans-serif;
    margin-top:auto;
}
.irc-view-btn:hover { background:#333 !important; }

/* ── Navigation arrows ───────────────────────────────────── */
/*
 * Arrows are positioned over the video area only (not over the
 * product card). top: 20px + half the video height.
 * Video height = (track_width / 5) * 16/9  ≈  use 38% of wrapper.
 */
.irc-arrow {
    position: absolute;
    top: calc(20px + ((100% - 112px) / 5 * 16 / 9 / 2));
    transform: translateY(400%);
    z-index: 10;
    width: 42px; height: 42px;
    border-radius: 50%;
    background: #fff;
    border: none;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    box-shadow: 0 2px 14px rgba(0,0,0,.20);
    transition: box-shadow .18s, transform .18s;
    padding: 0; flex-shrink: 0;
}
.irc-arrow:hover { box-shadow: 0 4px 22px rgba(0,0,0,.30); transform: translateY(400%) scale(1.08); }
.irc-arrow svg { width:18px; height:18px; color:#222; pointer-events:none; }
.irc-prev { left: 8px; }
.irc-next { right: 8px; }
.irc-arrow[disabled] { opacity:.2; pointer-events:none; }

/* ============================================================
   MODAL
   ============================================================ */
.irc-modal {
    display: none; position: fixed; inset: 0;
    z-index: 999999; align-items: center; justify-content: center;
}
.irc-modal.open { display: flex; }

.irc-modal-bg {
    position: absolute; inset: 0;
    background: rgba(0,0,0,.88);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    cursor: pointer;
}

.irc-modal-box {
    position: relative; z-index: 1;
    display: flex; align-items: stretch;
    border-radius: 20px; overflow: hidden;
    box-shadow: 0 30px 90px rgba(0,0,0,.6);
    max-height: 90vh;
    max-width: 820px;
    width: calc(100% - 32px);
}

.irc-modal-close {
    position: fixed; top: 100px; right: 16px; z-index: 1000000;
    background: rgba(0,0,0,.6); border: 1px solid #f1f1f1; color: #fff;
    font-size: 24px; width: 40px; height: 40px; 
    cursor: pointer; display: flex; align-items: center; justify-content: center;
    line-height: 1; transition: background .18s; font-family: sans-serif;
    box-shadow: 0 2px 12px rgba(0,0,0,.4);
}
.irc-modal-close:hover { background: rgba(0,0,0,.85); }

/* Video column */
.irc-modal-video-col {
    height: 90vh;
    width: calc(90vh * 9 / 16);
    flex-shrink: 0;
    background: #000;
}
#irc-modal-video {
    width: 100%; height: 100%;
    object-fit: cover; display: block; background: #000;
}

/* Product column — DESKTOP: original stacked layout */
.irc-modal-product-col {
    width: 280px; min-width: 240px;
    background: #fff;
    display: flex; flex-direction: column;
    overflow-y: auto;
    padding: 24px 20px 20px;
    gap: 14px; flex-shrink: 0;
}
.irc-modal-product-col:empty { display: none; }

.irc-modal-prod-img {
    width: 100%; aspect-ratio: 1;
    object-fit: cover; border-radius: 12px; display: block;
}

.irc-modal-prod-name {
    font-size: 15px; font-weight: 700; color: #111;
    line-height: 1.35; margin: 0;
    font-family: -apple-system,BlinkMacSystemFont,'Segoe UI',sans-serif;
}

.irc-modal-pricing { display:flex; align-items:center; flex-wrap:wrap; gap:7px; }
.irc-modal-price-sale { font-size:20px; font-weight:800; color:#000000;
    font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',sans-serif; }
.irc-modal-price-reg  { font-size:14px; color:#999; text-decoration:line-through;
    font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',sans-serif; }
.irc-modal-price-norm { font-size:20px; font-weight:800; color:#111;
    font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',sans-serif; }
.irc-modal-badge {
    background:#ff5a1f; color:#fff; font-size:11px; font-weight:700;
    padding:3px 9px; border-radius:20px;
    font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',sans-serif;
}

/* Desktop: row wrappers are invisible — children flow into the column as normal */
.irc-mp-row1    { display: contents; }
.irc-mp-meta    { display: contents; }
.irc-mp-row2    { display: contents; }
.irc-mp-swatches { display: contents; }
.irc-mp-actions { display: flex; flex-direction: column; gap: 8px; margin-top: auto; }

/* Variants */
.irc-var-label {
    font-size: 11px; font-weight: 700; color: #666;
    text-transform: uppercase; letter-spacing: .6px; margin: 0 0 4px;
    font-family: -apple-system,BlinkMacSystemFont,'Segoe UI',sans-serif;
}
.irc-variants { display: flex; flex-wrap: wrap; gap: 7px; }
.irc-swatch {
    display: flex; flex-direction: column; align-items: center; gap: 3px;
    border: 2px solid #e0e0e0; border-radius: 10px;
    background: #fff; cursor: pointer;
    padding: 4px 6px 5px;
    min-width: 52px; max-width: 68px;
    transition: border-color .15s, box-shadow .15s;
    font-family: -apple-system,BlinkMacSystemFont,'Segoe UI',sans-serif;
}
.irc-swatch:hover    { border-color: #888; }
.irc-swatch.selected { border-color: #111; box-shadow: 0 0 0 2px #111; }
.irc-swatch img      { width: 40px; height: 40px; object-fit: cover; border-radius: 6px; display: block; }
.irc-swatch-initials {
    width: 40px; height: 40px; background: #f0f0f0; border-radius: 6px;
    display: flex; align-items: center; justify-content: center;
    font-size: 11px; font-weight: 700; color: #555;
}
.irc-swatch-label {
    font-size: 9px; color: #444; text-align: center; line-height: 1.2;
    word-break: break-word;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.irc-swatch-hint {
    font-size: 12px; color: #e02020; margin: 0;
    font-family: -apple-system,BlinkMacSystemFont,'Segoe UI',sans-serif;
}

/* Buttons */
.irc-cart-form { width: 100%; }
.irc-modal-cart-btn {
    display: block; width: 100%;
    background: #111; color: #fff;
    border: none; border-radius: 10px;
    padding: 14px; font-size: 15px; font-weight: 700;
    cursor: pointer; text-align: center;
    transition: background .18s;
    font-family: -apple-system,BlinkMacSystemFont,'Segoe UI',sans-serif;
    white-space: nowrap;
}
.irc-modal-cart-btn:hover:not([disabled]) { background: #333; }
.irc-modal-cart-btn[disabled] { opacity: .35; cursor: not-allowed; }
.irc-modal-view-btn {
    display: block; width: 100%;
    background: transparent; color: #111 !important;
    border: 1.5px solid #ccc; border-radius: 10px;
    padding: 12px; font-size: 14px; font-weight: 600;
    text-align: center; text-decoration: none !important;
    font-family: -apple-system,BlinkMacSystemFont,'Segoe UI',sans-serif;
    transition: border-color .18s, background .18s;
    white-space: nowrap;
}
.irc-modal-view-btn:hover { border-color: #888; background: #f5f5f5 !important; color: #111 !important; }

/* ============================================================
   Responsive — Tablet
   ============================================================ */
@media (max-width: 1024px) {
    .irc-slide { flex: 0 0 calc((100% - 28px) / 3); }
    .irc-outer { padding: 16px 48px 24px; }
    .irc-modal-product-col { width: 240px; }
}

/* ============================================================
   Responsive — Mobile
   Full-screen video + single-row frosted drawer at bottom
   ============================================================ */
@media (max-width: 600px) {
    /* Carousel */
    .irc-slide  { flex: 0 0 100%; }
    .irc-outer  { padding: 12px 42px 20px; }
    .irc-arrow  { width: 34px; height: 34px; }
    .irc-arrow svg { width: 15px; height: 15px; }

    /* Modal: true full-screen */
    .irc-modal-bg { backdrop-filter: none; -webkit-backdrop-filter: none; background: #000; }
    .irc-modal-box {
        flex-direction: column;
        width: 100%; height: 100%;
        max-height: 100%; max-width: 100%;
        border-radius: 0; box-shadow: none;
        position: relative; overflow: visible;
    }

    /* Close button — fixed above top bar, left on mobile */
    .irc-modal-close { top: 50px; left: 14px; right: auto; }

    /* Video fills entire screen */
    .irc-modal-video-col { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 1; }
    #irc-modal-video { width: 100%; height: 100%; object-fit: contain; background: #000; }

    /*
     * MOBILE DRAWER — 2 rows:
     * Row 1: [56px image]  |  [name + price]
     * Row 2: [swatches]    |  [Add to Cart] [View Product]
     */
    .irc-modal-product-col {
        position: fixed;
        bottom: 0; left: 0; right: 0;
        z-index: 10;
        width: 100%;
        overflow-y: visible;
        -webkit-overflow-scrolling: touch;
        background: rgba(220,218,218,.55);
        backdrop-filter: blur(18px);
        -webkit-backdrop-filter: blur(18px);
        border-radius: 16px 16px 0 0;
        border-top: 1px solid rgba(255,255,255,.15);
        padding: 10px 12px 14px;
        display: flex !important;
        flex-direction: column !important;
        gap: 8px;
        min-width: 0;
    }
    /* Hide drag handle */
    .irc-modal-product-col::before { display: none; }

    /* Product image — hide from flow, shown inside row1 */
    .irc-modal-prod-img {
        width: 56px !important; height: 56px !important;
        border-radius: 8px; aspect-ratio: 1;
        flex-shrink: 0;
    }

    /* ROW 1: image left, name+price right */
    .irc-mp-row1 {
        display: flex !important;
        flex-direction: row;
        align-items: center;
        gap: 10px;
        flex-shrink: 0;
    }
    .irc-mp-meta {
        display: flex !important;
        flex-direction: column;
        gap: 3px;
        flex: 1; min-width: 0;
    }
    .irc-modal-prod-name {
        color: #fff !important; font-size: 12px !important; font-weight: 600;
        -webkit-line-clamp: 2; white-space: normal;
    }
    .irc-modal-pricing  { gap: 4px; }
    .irc-modal-price-sale { font-size: 13px !important; color: #000000 !important; }
    .irc-modal-price-norm { font-size: 13px !important; color: #fff !important; }
    .irc-modal-price-reg  { font-size: 10px !important; color: rgba(255,255,255,.45) !important; }
    .irc-modal-badge      { font-size: 9px; padding: 1px 5px; }

    /* ROW 2: swatches left, buttons right — both same row */
    .irc-mp-row2 {
        display: flex !important;
        flex-direction: row;
        align-items: center;
        gap: 8px;
    }
    .irc-mp-swatches {
        display: flex !important;
        flex-direction: row;
        align-items: center;
        flex: 1; min-width: 0;
        overflow-x: auto; overflow-y: hidden;
        scrollbar-width: none;
    }
    .irc-mp-swatches::-webkit-scrollbar { display: none; }
    .irc-variants  { flex-wrap: nowrap; gap: 5px; }
    .irc-swatch {
        flex-shrink: 0;
        min-width: 38px; max-width: 38px;
        padding: 2px; border-radius: 6px;
        border-color: rgba(255,255,255,.25);
        background: rgba(255,255,255,.08);
    }
    .irc-swatch img,
    .irc-swatch-initials { width: 32px !important; height: 32px !important; border-radius: 4px; }
    .irc-swatch:hover    { border-color: rgba(255,255,255,.55); }
    .irc-swatch.selected { border-color: #fff; box-shadow: 0 0 0 2px #fff; }
    .irc-swatch-hint     { display: none; }

    /* Buttons — side by side, right of swatches */
    .irc-mp-actions {
        display: flex !important;
        flex-direction: row;
        gap: 6px; flex-shrink: 0;
        align-items: center;
    }
    .irc-cart-form { width: auto; }
    .irc-modal-cart-btn {
        background: #fff; color: #111;
        padding: 8px 11px; font-size: 11px; font-weight: 700;
        border-radius: 8px; width: auto; white-space: nowrap;
    }
    .irc-modal-cart-btn:hover:not([disabled]) { background: #eee; }
    .irc-modal-view-btn {
        padding: 7px 11px; font-size: 11px; font-weight: 600;
        border-radius: 8px; width: auto; white-space: nowrap;
        border-color: rgba(255,255,255,.3) !important;
        color: #fff !important;
        background: rgba(255,255,255,.1) !important;
    }
    .irc-modal-view-btn:hover { background: rgba(255,255,255,.2) !important; }
}

/* Safe area — notched phones */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
    @media (max-width: 600px) {
        .irc-modal-product-col { padding-bottom: calc(10px + env(safe-area-inset-bottom)); }
    }
}
