/* ============================================================
   BEINC — Polaroid Ring (Section CSS)

   360° polaroid carousel rendered in WebGL (Three.js) with a
   scroll-pinned heading + line that scrambles text mid-scroll.

   Section layout (symmetric, equal spaces S = 25vh, T = overlay h):
     [S top][T text initial][S][R = 100vh ring][S][T final slot][S bot]
   Total height H = 4S + 2T + R, set by JS at runtime.

   Depends on: global.css
   ============================================================ */

/* ── Section wrapper ── */
.polaroid-ring {
    position: relative;
    width: 100%;
    height: 250vh;    /* fallback; JS overrides */
    background: var(--color-white);
    margin-bottom: 10vh;   /* breathing room before the gtor section starts */
}

/* Paint the margin-bottom area cream so the body's black doesn't show
   through. Pseudo-element sits right below the section's content box and
   extends 10vh down — exactly filling the margin gap. */
.polaroid-ring::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    height: 10vh;
    background: var(--color-white);
    pointer-events: none;
}

/* ── Pre / post buffers — symmetric vertical breathing room ── */
.polaroid-ring__pre-buffer,
.polaroid-ring__post-buffer {
    width: 100%;
    height: 75vh;     /* fallback; JS overrides */
}

/* ── Ring container in NATURAL FLOW (not sticky) ──
   Ring rises with scroll, naturally fills viewport when its DOM
   position aligns with viewport top, then continues rising out.
   Text is JS-pinned at viewport center independently. */
.polaroid-ring__pin {
    position: relative;
    width: 100%;
    height: 100vh;
    z-index: 1;
    overflow: clip;   /* iOS-safe */
}

.polaroid-ring__stage {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    display: block;
    z-index: 1;
}

/* ── Edge fades — soft cream vignette over the ring's extremes ── */
.polaroid-ring__fade {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 18%;
    pointer-events: none;
    z-index: 2;
}

.polaroid-ring__fade--left {
    left: 0;
    background: linear-gradient(
        to right,
        rgba(255, 251, 240, 1) 0%,
        rgba(255, 251, 240, 0) 100%
    );
}

.polaroid-ring__fade--right {
    right: 0;
    background: linear-gradient(
        to left,
        rgba(255, 251, 240, 1) 0%,
        rgba(255, 251, 240, 0) 100%
    );
}

/* ── Heading overlay ──
   Two positioning modes, switched by JS on phase boundaries (NOT
   updated per scroll frame). The previous JS-driven approach was
   one frame behind the compositor on mobile, causing visible shake
   while the section scrolled past.

   Phase 1 + 3 (initial / final): position: absolute, JS sets
     --text-y once on boundary entry.
   Phase 2 (pinned): .is-pinned → position: fixed at viewport
     center. Browser compositor handles it natively — no JS per-
     frame work, no shake. */
.polaroid-ring__overlay {
    position: absolute;
    left: 50%;
    top: 0;
    transform: translate3d(-50%, var(--text-y, 0px), 0);
    z-index: 3;   /* above fades (z:2) and canvas (z:1) */

    width: clamp(340px, 48vw, 560px);
    padding: 20px;
    box-sizing: border-box;

    background: rgba(255, 251, 240, 0.5);
    backdrop-filter: blur(40px);
    -webkit-backdrop-filter: blur(40px);
    border-radius: var(--radius);

    text-align: center;
    will-change: transform;
}

.polaroid-ring__overlay.is-pinned {
    position: fixed;
    top: 50%;
    transform: translate3d(-50%, -50%, 0);
}

.polaroid-ring__heading {
    font-family: var(--font-heading);
    font-weight: var(--font-weight-medium);
    letter-spacing: var(--tracking-tight);
    color: var(--color-black2);
    font-size: clamp(28px, 3.4vw, 48px);
    line-height: 1.1;
    margin: 0 0 18px 0;
    text-align: center;
    text-wrap: balance;
    word-break: keep-all;           /* don't split words mid-scramble */

    /* Size-stable container so the scramble can't reshape the box.
       The match-case scramble (see JS) keeps widths stable; these
       rules clip any stray overflow rather than letting the
       container resize. */
    min-height: 4em;
    max-height: 4em;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.polaroid-ring__line {
    height: 6px;
    background: var(--color-black2);
    width: var(--line-w, 25px);
    margin: 0 auto;
    will-change: width;
}


/* ── Tablet (≤ 1023) ── */
@media (max-width: 1023px) {
    .polaroid-ring__overlay {
        width: clamp(300px, 60vw, 440px);
        padding: 18px;
    }
    .polaroid-ring__heading {
        font-size: clamp(24px, 3.6vw, 36px);
        margin-bottom: 16px;
    }
    .polaroid-ring__fade { width: 15%; }
}


/* ── Mobile (≤ 639) ── */
@media (max-width: 639px) {
    .polaroid-ring__overlay {
        width: min(360px, 88vw);
        padding: 16px;
    }
    .polaroid-ring__heading {
        font-size: clamp(22px, 6vw, 30px);
        margin-bottom: 14px;
        min-height: 4.2em;
        max-height: 4.2em;
    }
    .polaroid-ring__line {
        height: 5px;
        width: var(--line-w, 18px);
    }
    .polaroid-ring__fade { width: 12%; }
}
