/* cells.css - RHAea's two steps on the home page (cells.js): the clay parts slide in from the side; the mill wastewater has a wavy clay surface and fades back to paper after step 2 */

.cells-section {
    --cells-dry:     var(--paper, #FBEADC);
    --cells-wet:     #46352A;
    --cells-ridge:   #2A1D17;
    --cells-ink-dry: var(--paper-ink, #1B1B18);
    --cells-ink-wet: #F3E3CC;
    --cells-pad: clamp(1.5rem, 6vw, 5rem);
    position: relative;
    z-index: 10;
    /* the parts slide in from past the edge */
    overflow-x: clip;
    background: var(--cells-dry);
    color: var(--cells-ink-dry);
}

/* the intro, the two steps and the close share one column */
.cells-intro,
.cells-band,
.cells-close { padding-inline: var(--cells-pad); }
.cells-intro > *,
.cell-stage,
.cells-close-inner { max-width: 1100px; margin-inline: auto; }

.cells-intro { padding-block: clamp(2.5rem, 6vh, 4.5rem) clamp(1.5rem, 4vh, 3rem); }
.cells-title {
    margin-block: 0;
    font-family: 'Quicksand', sans-serif;
    font-size: clamp(1.9rem, calc(3.6vw * var(--fs-scale, 1)), 3.2rem);
    font-weight: 500;
    letter-spacing: -0.9px;
    line-height: 1.08;
    color: inherit;
}

.cells-band { padding-block: clamp(0.5rem, 2vh, 1.5rem) clamp(1rem, 3vh, 2rem); }
.cells-band--wet {
    background: var(--cells-wet);
    color: var(--cells-ink-wet);
}

/* the top of the wastewater: a dark clay ridge over the lighter body, one S-curve across the page */
.cells-wave {
    display: block;
    width: 100%;
    height: clamp(80px, 11vw, 170px);
    margin-top: clamp(0.5rem, 2vh, 1.5rem);
    /* a hair into the band, so no seam shows */
    margin-bottom: -1px;
    overflow: visible;
    filter: drop-shadow(0 -4px 8px rgba(42, 29, 23, 0.16));
}
.cells-wave-ridge { fill: var(--cells-ridge); }
.cells-wave-body  { fill: var(--cells-wet); }

/* the way out: a long, eased gradient back to paper.
   the stops are a smoothstep, so neither end shows an edge */
.cells-fade {
    --from: var(--cells-dry);
    --to:   var(--cells-wet);
    height: clamp(200px, 40vh, 360px);
    background: linear-gradient(to bottom, var(--from), var(--to));
    background: linear-gradient(to bottom,
        var(--from),
        color-mix(in srgb, var(--from), var(--to)  2.8%) 10%,
        color-mix(in srgb, var(--from), var(--to) 10.4%) 20%,
        color-mix(in srgb, var(--from), var(--to) 21.6%) 30%,
        color-mix(in srgb, var(--from), var(--to) 35.2%) 40%,
        color-mix(in srgb, var(--from), var(--to) 50%)   50%,
        color-mix(in srgb, var(--from), var(--to) 64.8%) 60%,
        color-mix(in srgb, var(--from), var(--to) 78.4%) 70%,
        color-mix(in srgb, var(--from), var(--to) 89.6%) 80%,
        color-mix(in srgb, var(--from), var(--to) 97.2%) 90%,
        var(--to));
}
.cells-fade--out {
    --from: var(--cells-wet);
    --to:   var(--cells-dry);
}

/* ── the head: kicker and title left, the words right ── */
.cell-head {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr);
    grid-template-areas: "kicker copy" "title copy";
    column-gap: clamp(1.5rem, 5vw, 4rem);
    align-items: end;
    margin-bottom: clamp(1.5rem, 4vh, 2.8rem);
}
.cell-kicker {
    grid-area: kicker;
    margin: 0 0 0.5rem;
    font-family: 'Quicksand', sans-serif;
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: inherit;
    opacity: 0.62;
}
.cell-title {
    grid-area: title;
    margin: 0;
    font-family: 'Quicksand', sans-serif;
    font-size: clamp(1.9rem, calc(3.6vw * var(--fs-scale, 1)), 3.2rem);
    font-weight: 500;
    letter-spacing: -0.9px;
    line-height: 1.05;
    color: inherit;
}
.cell-copy {
    grid-area: copy;
    margin: 0;
    max-width: 52ch;
    font-family: 'Quicksand', sans-serif;
    font-size: clamp(0.95rem, calc(1.2vw * var(--fs-scale, 1)), 1.12rem);
    font-weight: 500;
    line-height: 1.55;
    color: inherit;
}

/* ── the close ── */
.cells-close { padding-block: clamp(2.5rem, 7vh, 4.5rem) clamp(3rem, 8vh, 5rem); }
.cells-close-inner {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: space-between;
    gap: 1.6rem 3rem;
}

/* ── a scene: a fixed-ratio box, every part placed in % of it ── */
.cell-scene {
    --ar: 1100 / 480;
    position: relative;
    width: 100%;
    aspect-ratio: var(--ar);
}
.cell-scene--two { --ar: 1100 / 620; }

.cell-fig,
.cell-item { position: absolute; left: var(--x); top: var(--y); width: var(--w); }
.clay {
    display: block;
    width: 100%;
    height: auto;
    /* one light, high and to the left, as in the steps above */
    filter: saturate(0.95)
            drop-shadow(1px 2px 1px rgba(40, 28, 16, 0.34))
            drop-shadow(8px 14px 14px rgba(40, 28, 16, 0.20));
}

/* the cells carry their own labels, sized off the cell so they stay in the ring */
.cell-fig { container-type: inline-size; }
.cell-tag {
    position: absolute;
    transform: translate(-50%, -50%);
    font-family: 'Quicksand', sans-serif;
    font-size: clamp(10px, 2.5cqi, 20px);
    font-weight: 700;
    line-height: 1.15;
    text-align: center;
    white-space: nowrap;
    color: inherit;
}

/* ── step 1 ── */
.cell-scene--one .cell-fig { --x: 0%; --y: 2.5%; --w: 62%; }
.cell-scene--one .cell-tag--ring  { left: 24.4%; top: 52.5%; }
.cell-scene--one .cell-tag--gene  { left: 24.6%; top: 33%; }
.cell-scene--one .cell-tag--dna   { left: 66.5%; top: 31%; }

.cell-prot--1 { --x: 70%;   --y: 7.5%;  --w: 17%; }
.cell-prot--2 { --x: 85%;   --y: 30%;   --w: 13%; }
.cell-prot--3 { --x: 67.5%; --y: 42.5%; --w: 19%; }
.cell-prot--4 { --x: 87%;   --y: 60%;   --w: 11%; }
.cell-prot--5 { --x: 72%;   --y: 77.5%; --w: 15%; }
.cell-prot--6 { --x: 88%;   --y: 90%;   --w: 10%; }

/* ── step 2 ── */
.cell-scene--two .cell-fig { --x: 36%; --y: 0%; --w: 64%; }
.cell-scene--two .cell-tag--ring { left: 29.2%; top: 52.5%; color: #0B2E17; }

.cell-rl--1 { --x: 1%;  --y: 6%;  --w: 27%; }
.cell-rl--2 { --x: 3%;  --y: 30%; --w: 24%; }
.cell-rl--3 { --x: 28%; --y: 58%; --w: 27%; }
.cell-rl--4 { --x: 58%; --y: 66%; --w: 26%; }
.cell-rl--5 { --x: 2%;  --y: 62%; --w: 20%; }
.cell-rl--6 { --x: 30%; --y: 80%; --w: 22%; }
/* always on the wastewater, so the clay is graded for it: more saturation, lift and contrast, a faint rim light */
.cell-scene--two .clay {
    filter: saturate(1.4) brightness(1.55) contrast(1.15)
            drop-shadow(0 0 1.5px rgba(255, 244, 214, 0.38))
            drop-shadow(1px 2px 1px rgba(0, 0, 0, 0.45))
            drop-shadow(8px 14px 14px rgba(0, 0, 0, 0.32));
}
/* the cell is bright already; it only needs the shadow */
.cell-scene--two .cell-fig .clay {
    filter: saturate(1.05)
            drop-shadow(1px 2px 1px rgba(0, 0, 0, 0.45))
            drop-shadow(8px 14px 14px rgba(0, 0, 0, 0.32));
}

/* ── the entrance: the cell and the copies slide in from their side, a beat apart ── */
.pop {
    --dx: 0px;
    --rot: 0deg;
    /* where it ends up; without the script that is all there is */
    transform: rotate(var(--rot));
}
.pop--left  { --dx: -48px; }
.pop--right { --dx: 48px; }

.cells-ready .pop {
    transition: opacity 0.6s ease var(--d, 0.25s),
                transform 0.7s cubic-bezier(0.22, 0.7, 0.2, 1) var(--d, 0.25s);
}
.cells-ready .cell-scene:not(.is-in) .pop   { opacity: 0; transform: translateX(var(--dx)) rotate(var(--rot)); }

.cell-fig { --d: 0s; }
:is(.cell-prot--1, .cell-rl--1) { --d: 0.2s; }
:is(.cell-prot--2, .cell-rl--2) { --d: 0.26s; }
:is(.cell-prot--3, .cell-rl--3) { --d: 0.32s; }
:is(.cell-prot--4, .cell-rl--4) { --d: 0.38s; }
:is(.cell-prot--5, .cell-rl--5) { --d: 0.44s; }
:is(.cell-prot--6, .cell-rl--6) { --d: 0.5s; }

/* reduced motion: everything is simply there */
html[data-reduce-motion] .cells-ready .cell-scene:not(.is-in) .pop { opacity: 1; transform: rotate(var(--rot)); }
html[data-reduce-motion] .cells-ready .pop { transition: none; }
@media (prefers-reduced-motion: reduce) {
    .cells-ready .cell-scene:not(.is-in) .pop { opacity: 1; transform: rotate(var(--rot)); }
    .cells-ready .pop { transition: none; }
}

/* ── phone: one column, the cell on top, the parts below it ── */
@media (max-width: 700px) {
    .cell-head {
        grid-template-columns: minmax(0, 1fr);
        grid-template-areas: "kicker" "title" "copy";
        row-gap: 0.4rem;
    }
    .cell-copy { margin-top: 0.7rem; }

    .cell-scene--one { --ar: 360 / 520; }
    .cell-scene--two { --ar: 360 / 570; }

    .cell-scene--one .cell-fig,
    .cell-scene--two .cell-fig { --x: 0%; --y: 0%; --w: 100%; }


    .cell-prot--1 { --x: 6%;  --y: 49%; --w: 36%; }
    .cell-prot--2 { --x: 55%; --y: 51%; --w: 30%; }
    .cell-prot--3 { --x: 20%; --y: 60.5%; --w: 42%; }
    .cell-prot--4 { --x: 62%; --y: 69%; --w: 28%; }
    .cell-prot--5 { --x: 8%;  --y: 76%; --w: 32%; }
    .cell-prot--6 { --x: 52%; --y: 85%; --w: 36%; }

    .cell-rl--1 { --x: 4%;  --y: 37%; --w: 52%; }
    .cell-rl--2 { --x: 46%; --y: 45%; --w: 50%; }
    .cell-rl--3 { --x: 2%;  --y: 54%; --w: 46%; }
    .cell-rl--4 { --x: 50%; --y: 62%; --w: 46%; }
    .cell-rl--5 { --x: 6%;  --y: 71%; --w: 40%; }
    .cell-rl--6 { --x: 44%; --y: 80%; --w: 50%; }
}
