/* ============================================================
   Weaving Threads - Instagram reels rail
   "The Reel Atelier" - dark editorial break, inline IG /embed players
   Scoped: .wt-reels  |  Behaviour: assets/js/instagram-reels.js

   NOTE: nothing may overlay .wt-reels__media - the iframe must stay
   fully tappable or inline playback breaks.
   ============================================================ */

.wt-reels {
    position: relative;
    isolation: isolate;
    overflow: hidden;
    background: linear-gradient(168deg, #241d16 0%, #1a1511 52%, #120e0b 100%);
    color: var(--wt-cream, #f4eee6);
    /* Measured: the Instagram embed needs ~608px internally or its comment
       row is clipped. Keep ~9:16 so the iframe fills cleanly. */
    --wt-reel-w: 348px;
    --wt-reel-h: 620px;
}

/* ambient warm light, purely decorative */
.wt-reels__glow {
    position: absolute;
    inset: -30% -10% auto -10%;
    height: 70%;
    background:
        radial-gradient(closest-side at 22% 35%, rgba(214, 176, 122, 0.20), transparent 100%),
        radial-gradient(closest-side at 78% 20%, rgba(244, 238, 230, 0.10), transparent 100%);
    pointer-events: none;
    z-index: -1;
}

.wt-reels__inner {
    max-width: var(--wt-copy, 1180px);
    margin: 0 auto;
    padding: 72px 24px 64px;
}

/* ---------- header ---------- */
.wt-reels__head {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 28px;
    padding-bottom: 26px;
    margin-bottom: 34px;
    border-bottom: 1px solid rgba(244, 238, 230, 0.16);
}

.wt-reels .wt-kicker {
    color: rgba(244, 238, 230, 0.62);
}

.wt-reels .wt-display {
    color: var(--wt-cream, #f4eee6);
    font-size: clamp(1.9rem, 3.4vw, 2.9rem);
    max-width: 18ch;
}

.wt-reels .wt-lede {
    color: rgba(244, 238, 230, 0.66);
    max-width: 46ch;
}

.wt-reels__tools {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.wt-reels__follow {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 20px;
    border: 1px solid rgba(244, 238, 230, 0.32);
    color: var(--wt-cream, #f4eee6);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    text-decoration: none;
    transition: background 0.25s ease, color 0.25s ease, border-color 0.25s ease;
}

.wt-reels__follow:hover,
.wt-reels__follow:focus-visible {
    background: var(--wt-cream, #f4eee6);
    border-color: var(--wt-cream, #f4eee6);
    color: #1a1511;
}

/* desktop-only arrows */
.wt-reels__arrow {
    width: 44px;
    height: 44px;
    display: none;
    place-items: center;
    padding: 0;
    border: 1px solid rgba(244, 238, 230, 0.32);
    background: transparent;
    color: var(--wt-cream, #f4eee6);
    cursor: pointer;
    transition: background 0.25s ease, color 0.25s ease, opacity 0.25s ease;
}

.wt-reels__arrow:hover:not([disabled]) {
    background: var(--wt-cream, #f4eee6);
    color: #1a1511;
}

.wt-reels__arrow[disabled] {
    opacity: 0.28;
    cursor: default;
}

.wt-reels__arrow svg {
    width: 16px;
    height: 16px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.6;
}

/* ---------- rail ---------- */
.wt-reels__viewport {
    position: relative;
}

/* fade the trailing edge so the rail reads as continuous */
.wt-reels__viewport::after {
    content: "";
    position: absolute;
    top: 0;
    right: -1px;
    width: 90px;
    height: 100%;
    background: linear-gradient(90deg, rgba(18, 14, 11, 0), #14100c 82%);
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s ease;
    z-index: 2;
}

.wt-reels__viewport[data-overflow="1"]::after {
    opacity: 1;
}

.wt-reels__viewport[data-at-end="1"]::after {
    opacity: 0;
}

.wt-reels__rail {
    display: flex;
    gap: 22px;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 4px;
    scrollbar-width: none;
}

.wt-reels__rail::-webkit-scrollbar {
    display: none;
}

/* desktop drag-to-scroll */
.wt-reels__rail.is-draggable {
    cursor: grab;
}

.wt-reels__rail.is-dragging {
    cursor: grabbing;
    scroll-snap-type: none;
    user-select: none;
}

.wt-reels__card {
    flex: 0 0 var(--wt-reel-w);
    width: var(--wt-reel-w);
    scroll-snap-align: start;
    margin: 0;
    transition: transform 0.4s cubic-bezier(0.22, 0.61, 0.36, 1);
}

/* the gallery mount around each player */
.wt-reels__media {
    position: relative;
    width: 100%;
    height: var(--wt-reel-h);
    overflow: hidden;
    background: linear-gradient(165deg, #3a2f25 0%, #241d16 60%, #1a1511 100%);
    border: 1px solid rgba(244, 238, 230, 0.14);
    box-shadow: 0 18px 44px rgba(0, 0, 0, 0.42);
    transition: box-shadow 0.4s ease, border-color 0.4s ease;
}

.wt-reels__card:hover .wt-reels__media {
    border-color: rgba(244, 238, 230, 0.3);
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55);
}

/* skeleton shimmer, sits BEHIND the iframe and stops once loaded */
.wt-reels__media::before {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(
        100deg,
        rgba(244, 238, 230, 0) 20%,
        rgba(244, 238, 230, 0.09) 44%,
        rgba(244, 238, 230, 0) 68%
    );
    background-size: 220% 100%;
    animation: wt-reels-shimmer 1.9s linear infinite;
    z-index: 0;
}

.wt-reels__media[data-ready="1"]::before {
    animation: none;
    opacity: 0;
}

@keyframes wt-reels-shimmer {
    from { background-position: 130% 0; }
    to   { background-position: -30% 0; }
}

.wt-reels__embed {
    position: relative;
    z-index: 1;
    display: block;
    width: 100%;
    height: 100%;
    border: 0;
    background: transparent;
    opacity: 0;
    transition: opacity 0.45s ease;
}

.wt-reels__embed[data-loaded="1"] {
    opacity: 1;
}

/* ---------- caption row: editorial numeral + link ---------- */
.wt-reels__meta {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    margin-top: 14px;
}

.wt-reels__index {
    font-family: var(--wt-display, "Cormorant Garamond", Georgia, serif);
    font-size: 26px;
    line-height: 1;
    letter-spacing: 0.02em;
    color: rgba(244, 238, 230, 0.42);
}

.wt-reels__cta {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: rgba(244, 238, 230, 0.82);
    text-decoration: none;
    border-bottom: 1px solid rgba(244, 238, 230, 0.28);
    padding-bottom: 3px;
    transition: color 0.25s ease, border-color 0.25s ease;
}

.wt-reels__cta:hover,
.wt-reels__cta:focus-visible {
    color: #fff;
    border-bottom-color: #fff;
}

/* ---------- progress ---------- */
.wt-reels__foot {
    display: flex;
    align-items: center;
    gap: 20px;
    margin-top: 30px;
}

.wt-reels__progress {
    position: relative;
    flex: 1;
    height: 1px;
    background: rgba(244, 238, 230, 0.18);
}

.wt-reels__progress-bar {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    width: 18%;
    background: var(--wt-cream, #f4eee6);
    transition: width 0.18s linear, left 0.18s linear;
}

.wt-reels__hint {
    margin: 0;
    flex-shrink: 0;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: rgba(244, 238, 230, 0.5);
}

/* ---------- desktop ---------- */
@media (min-width: 992px) {
    .wt-reels__arrow {
        display: grid;
    }

    .wt-reels__card:hover {
        transform: translateY(-6px);
    }
}

/* ---------- mobile ---------- */
@media (max-width: 767.98px) {
    .wt-reels {
        --wt-reel-w: min(84vw, 345px);
        --wt-reel-h: 615px;
    }

    /* rail bleeds to the edge, header keeps its gutter */
    .wt-reels__inner {
        padding: 52px 0 48px 20px;
    }

    .wt-reels__head {
        flex-direction: column;
        align-items: flex-start;
        gap: 18px;
        margin-right: 20px;
        padding-bottom: 22px;
        margin-bottom: 26px;
    }

    .wt-reels__follow {
        width: 100%;
        justify-content: center;
    }

    .wt-reels__rail {
        padding-right: 20px;
    }

    .wt-reels__foot {
        margin-right: 20px;
    }

    .wt-reels__viewport::after {
        width: 48px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .wt-reels__card,
    .wt-reels__media,
    .wt-reels__embed,
    .wt-reels__progress-bar {
        transition: none;
    }

    .wt-reels__media::before {
        animation: none;
    }
}
