/* ==========================================================================
   Homepage — Why It Matters (assets/js/home/why.js).
   1. "Noise to signal": once the scene is on screen it plays by itself: a
      field of drifting particles (the noise) pulls into one line of light
      (the signal) and the copy arrives along it.
   2. The signal opens: a slit of light that widens into the N monogram
      film (looping, silent) as it scrolls into view.
   3. Words we work by (a white section of its own): design quotes, one at a
      time, word by word, with the authors' names to choose from.
   Without JavaScript, or with reduced motion, everything is simply shown.
   ========================================================================== */

.ns {
    --ns-ink: #f6f4fb;
    --ns-muted: rgba(226, 224, 236, 0.68);
    --ns-gutter: clamp(1.25rem, 4.2vw, 3.5rem);
    position: relative;
    overflow-x: clip;
    color: var(--ns-ink);
    background:
        radial-gradient(70rem 36rem at 50% 42%, rgba(124, 58, 237, 0.12), transparent 70%),
        linear-gradient(180deg, #05060f 0%, #04050c 55%, #090a10 100%);
    font-family: "Manrope", sans-serif;
}

/* ---------- The stage ---------- */

.ns-stage {
    /* Scroll choreography (set by the script; these are the finished values). */
    --ns-noise: 1;
    --ns-reveal: 1;
    --ns-lede: 1;
    --ns-pts: 3;
    position: relative;
}

.ns-canvas {
    display: none;
}

.ns-copy {
    max-width: 82rem;
    margin: 0 auto;
    padding: clamp(5.5rem, 11vw, 9rem) var(--ns-gutter) 0;
}

.ns-label {
    margin-bottom: clamp(1.6rem, 3.5vh, 2.4rem);
}

.ns-title {
    display: grid;
    gap: clamp(3rem, 11vh, 6.5rem);
    margin: 0;
    font-size: clamp(2.3rem, 5.6vw, 5.2rem);
    font-weight: 800;
    line-height: 1;
    letter-spacing: -0.045em;
}

.ns-noise,
.ns-signal {
    display: block;
}

/* The problem, fading back as the noise resolves. */
.ns-noise {
    color: rgba(226, 224, 236, 0.9);
    opacity: calc(0.26 + var(--ns-noise) * 0.74);
}

/* The answer, wiped in from the left along the line. */
.ns-signal {
    position: relative;
    /* Room for descenders (the g in "through") inside the clipped gradient. */
    padding-bottom: 0.22em;
    margin-bottom: -0.14em;
    color: transparent;
    background: linear-gradient(92deg, #ffffff 0%, #e9e1ff 38%, #b9e6fb 70%, #f8c6e0 100%);
    -webkit-background-clip: text;
    background-clip: text;
}

/* Static layouts draw the line themselves; the live scene paints it. */
.ns-signal::before {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    top: calc(clamp(3rem, 11vh, 6.5rem) / -2);
    height: 2px;
    background: linear-gradient(90deg, #7c3aed, #0ea5e9 55%, #f472b6);
    box-shadow: 0 0 18px rgba(14, 165, 233, 0.55);
}

.ns-lede {
    max-width: 36rem;
    margin: clamp(1.4rem, 3vh, 2rem) 0 0;
    font-size: clamp(1.02rem, 1.3vw, 1.2rem);
    line-height: 1.7;
    color: var(--ns-muted);
    opacity: var(--ns-lede);
    transform: translate3d(0, calc((1 - var(--ns-lede)) * 18px), 0);
}

.ns-points {
    display: grid;
    gap: 0.9rem;
    margin: clamp(2rem, 5vh, 3rem) 0 0;
    padding: 0;
    list-style: none;
}

.ns-point {
    --ns-on: clamp(0, calc(var(--ns-pts) - var(--i, 0)), 1);
    display: flex;
    align-items: center;
    gap: 0.85rem;
    font-size: clamp(1rem, 1.2vw, 1.12rem);
    font-weight: 600;
    color: var(--ns-ink);
    opacity: calc(0.18 + var(--ns-on) * 0.82);
    transform: translate3d(0, calc((1 - var(--ns-on)) * 12px), 0);
}

.ns-dot {
    flex: none;
    width: 0.6rem;
    height: 0.6rem;
    border-radius: 50%;
    background: linear-gradient(135deg, #7c3aed, #0ea5e9);
    box-shadow: 0 0 calc(var(--ns-on) * 14px) rgba(14, 165, 233, 0.85);
}

.ns-point:nth-child(2) .ns-dot {
    background: linear-gradient(135deg, #0ea5e9, #a78bfa);
}

.ns-point:nth-child(3) .ns-dot {
    background: linear-gradient(135deg, #a78bfa, #f472b6);
    box-shadow: 0 0 calc(var(--ns-on) * 14px) rgba(244, 114, 182, 0.85);
}

@media (min-width: 960px) {
    .ns-points {
        grid-template-columns: repeat(3, minmax(0, max-content));
        column-gap: clamp(2rem, 4vw, 3.5rem);
    }
}

/* ---------- The live scene (motion allowed, script running) ---------- */

.ns.is-live .ns-stage {
    min-height: clamp(32rem, 80vh, 48rem);
    overflow: hidden;
}

.ns.is-live .ns-canvas {
    position: absolute;
    inset: 0;
    display: block;
    width: 100%;
    height: 100%;
}

.ns.is-live .ns-copy {
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-height: inherit;
    padding-top: clamp(4.5rem, 10vh, 6.5rem);
    padding-bottom: clamp(1.5rem, 4vh, 3rem);
    pointer-events: none;
}

.ns.is-live .ns-signal {
    clip-path: inset(-0.3em calc((1 - var(--ns-reveal)) * 100%) -0.3em 0);
}

.ns.is-live .ns-signal::before {
    display: none;
}

/* While the field is still noise, the problem line flickers with static. */
.ns.is-live .ns-stage.is-noisy .ns-noise {
    animation: ns-static 0.42s steps(3) infinite;
}

@keyframes ns-static {
    0% { transform: translate3d(0, 0, 0); text-shadow: 1px 0 rgba(14, 165, 233, 0.45), -1px 0 rgba(244, 114, 182, 0.45); }
    33% { transform: translate3d(-1px, 0.5px, 0); text-shadow: -1.5px 0 rgba(14, 165, 233, 0.4), 1px 0 rgba(244, 114, 182, 0.4); }
    66% { transform: translate3d(1px, -0.5px, 0); text-shadow: 0.5px 0 rgba(14, 165, 233, 0.5), -0.5px 0 rgba(244, 114, 182, 0.5); }
    100% { transform: translate3d(0, 0, 0); text-shadow: none; }
}

@media (max-width: 767px) {
    .ns-title {
        gap: clamp(2.4rem, 8vh, 4rem);
    }

    /* On phones the copy sets the height. */
    .ns.is-live .ns-stage {
        min-height: 0;
    }

    .ns.is-live .ns-copy {
        padding-bottom: 3.5rem;
    }
}

/* ---------- The signal opens into the N monogram ----------
   --rv (0 → 1, set by the script as it scrolls into view) opens a slit of
   light into the full photograph; without the script it is simply open. */

.ns-reveal {
    --rv: 1;
    position: relative;
    margin-top: clamp(0.5rem, 3vw, 2rem);
}

.ns-reveal-frame {
    position: relative;
    aspect-ratio: 21 / 9;
    overflow: hidden;
    background: #04050c;
    clip-path: inset(calc((1 - var(--rv)) * 50%) 0 calc((1 - var(--rv)) * 50%) 0);
}

.ns-reveal-frame video {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transform: scale(calc(1.24 - var(--rv) * 0.24));
    filter: brightness(calc(0.55 + var(--rv) * 0.45));
}

/* The two edges of the opening carry the signal's light. */
.ns-reveal::before,
.ns-reveal::after {
    content: "";
    position: absolute;
    z-index: 1;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, rgba(124, 58, 237, 0), #7c3aed 15%, #0ea5e9 50%, #f472b6 85%, rgba(244, 114, 182, 0));
    box-shadow: 0 0 18px rgba(14, 165, 233, 0.7);
    opacity: calc(1 - var(--rv));
    pointer-events: none;
}

.ns-reveal::before {
    top: calc((1 - var(--rv)) * 50%);
}

.ns-reveal::after {
    bottom: calc((1 - var(--rv)) * 50%);
}

/* Soft hand-offs into the dark above and the white below. */
.ns-reveal-frame::after {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    background: linear-gradient(180deg, rgba(9, 10, 16, 0.55) 0%, rgba(9, 10, 16, 0) 18%, rgba(9, 10, 16, 0) 82%, rgba(9, 10, 16, 0.35) 100%);
}

@media (max-width: 767px) {
    .ns-reveal-frame {
        aspect-ratio: 4 / 3;
    }
}

/* ==========================================================================
   Words we work by
   ========================================================================== */

.nq {
    --nq-ink: #0c0b1d;
    --nq-muted: #6b6a7a;
    position: relative;
    overflow-x: clip;
    padding: clamp(5rem, 11vw, 8.5rem) 0 clamp(4.5rem, 10vw, 7.5rem);
    color: var(--nq-ink);
    background:
        radial-gradient(48rem 26rem at 0% 0%, rgba(124, 58, 237, 0.07), transparent 70%),
        radial-gradient(40rem 24rem at 100% 100%, rgba(14, 165, 233, 0.07), transparent 70%),
        #ffffff;
    font-family: "Manrope", sans-serif;
}

/* A slow-moving glow of the three brand colours behind the quotes. */
.nq-glow {
    position: absolute;
    inset: 0;
    overflow: hidden;
    pointer-events: none;
}

.nq-glow span {
    position: absolute;
    width: clamp(18rem, 38vw, 34rem);
    aspect-ratio: 1;
    border-radius: 50%;
    filter: blur(70px);
    opacity: 0.28;
}

.nq-glow span:nth-child(1) {
    top: -12%;
    right: 4%;
    background: #7c3aed;
}

.nq-glow span:nth-child(2) {
    top: 30%;
    right: -10%;
    background: #0ea5e9;
    opacity: 0.22;
}

.nq-glow span:nth-child(3) {
    bottom: -30%;
    right: 22%;
    background: #f472b6;
    opacity: 0.22;
}

@media (prefers-reduced-motion: no-preference) {
    .nq-glow span:nth-child(1) { animation: nq-orbit 22s ease-in-out infinite; }
    .nq-glow span:nth-child(2) { animation: nq-orbit 26s ease-in-out -8s infinite reverse; }
    .nq-glow span:nth-child(3) { animation: nq-orbit 30s ease-in-out -15s infinite; }
}

@keyframes nq-orbit {
    0%, 100% { transform: translate3d(0, 0, 0) scale(1); }
    33% { transform: translate3d(-12%, 10%, 0) scale(1.12); }
    66% { transform: translate3d(8%, -8%, 0) scale(0.92); }
}

.nq-shell {
    position: relative;
    max-width: 72rem;
    margin: 0 auto;
    padding: 0 clamp(1.25rem, 4.2vw, 3.5rem);
}

.nq-label {
    margin-bottom: clamp(3.5rem, 7vw, 5.5rem);
}

.nq-stage {
    position: relative;
    padding-left: clamp(0rem, 9vw, 8.5rem);
}

/* A large quote mark in the brand gradient, drifting gently. */
.nq-mark {
    position: absolute;
    top: -0.3em;
    left: -0.06em;
    font-size: clamp(9rem, 22vw, 19rem);
    font-weight: 800;
    line-height: 1;
    color: transparent;
    background: linear-gradient(135deg, #7c3aed 0%, #0ea5e9 55%, #f472b6 100%);
    -webkit-background-clip: text;
    background-clip: text;
    opacity: 0.9;
    pointer-events: none;
}

@media (max-width: 767px) {
    .nq {
        padding-top: 4rem;
    }

    .nq-label {
        margin-bottom: 2.25rem;
    }

    .nq-stage {
        padding-top: clamp(3.5rem, 16vw, 5rem);
        padding-left: 0;
    }

    .nq-mark {
        top: -0.2em;
        font-size: clamp(8rem, 34vw, 11rem);
    }
}

/* Every quote shares one cell, so the space never jumps between them. */
.nq-stack {
    display: grid;
}

.nq-quote {
    grid-area: 1 / 1;
    align-self: center;
    margin: 0;
}

.nq-quote:not(.is-current) {
    visibility: hidden;
}

.nq-text {
    margin: 0;
}

.nq-text p {
    margin: 0;
    font-size: clamp(2rem, 5.2vw, 4.75rem);
    font-weight: 800;
    line-height: 1.06;
    letter-spacing: -0.04em;
    color: var(--nq-ink);
    text-wrap: balance;
}

.nq-by {
    display: flex;
    align-items: center;
    gap: 0.9rem;
    margin-top: clamp(1.4rem, 3vw, 2rem);
    font-family: "Space Grotesk", sans-serif;
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.24em;
    text-transform: uppercase;
    color: #6d28d9;
}

.nq-by::before {
    content: "";
    width: 2.5rem;
    height: 2px;
    background: linear-gradient(90deg, #7c3aed, #0ea5e9);
    transform-origin: left;
}

/* The key words of each quote, in the brand gradient. */
.nq-em {
    font-style: normal;
    color: transparent;
    background: linear-gradient(100deg, #7c3aed 0%, #0ea5e9 55%, #f472b6 100%);
    -webkit-background-clip: text;
    background-clip: text;
    /* Room for descenders inside the clipped gradient. */
    padding-bottom: 0.12em;
    margin-bottom: -0.12em;
}

/* With the script: each quote arrives word by word and leaves the same way. */
.nq.is-live .nq-w {
    display: inline-block;
    opacity: 0;
    transform: translate3d(0, 0.4em, 0);
    filter: blur(8px);
    transition:
        opacity 0.55s ease,
        transform 0.8s cubic-bezier(0.22, 1, 0.36, 1),
        filter 0.55s ease;
    transition-delay: calc(var(--i, 0) * 0.045s);
}

.nq.is-live .nq-quote.is-in .nq-w {
    opacity: 1;
    transform: none;
    filter: none;
}

.nq.is-live .nq-quote.is-out .nq-w {
    opacity: 0;
    transform: translate3d(0, -0.25em, 0);
    filter: blur(6px);
    transition-duration: 0.35s;
    transition-delay: calc(var(--i, 0) * 0.012s);
}

.nq.is-live .nq-by {
    opacity: 0;
    transform: translate3d(0, 10px, 0);
    transition: opacity 0.5s ease, transform 0.7s cubic-bezier(0.22, 1, 0.36, 1);
}

.nq.is-live .nq-by::before {
    transform: scaleX(0);
    transition: transform 0.8s cubic-bezier(0.22, 1, 0.36, 1);
}

.nq.is-live .nq-quote.is-in .nq-by {
    opacity: 1;
    transform: none;
    transition-delay: calc(var(--n, 6) * 0.045s + 0.15s);
}

.nq.is-live .nq-quote.is-in .nq-by::before {
    transform: none;
    transition-delay: calc(var(--n, 6) * 0.045s + 0.3s);
}

@media (prefers-reduced-motion: no-preference) {
    .nq.is-live .nq-mark {
        animation: nq-drift 9s ease-in-out infinite;
    }
}

@keyframes nq-drift {
    0%, 100% { transform: translate3d(0, 0, 0) rotate(0deg); }
    50% { transform: translate3d(0, -0.06em, 0) rotate(-2deg); }
}

/* ---------- The authors: choose a quote; the active name's line fills as
   its quote plays ---------- */

.nq-authors {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.4rem 0.35rem;
    margin-top: clamp(2.5rem, 5vw, 3.75rem);
    padding-top: 1.25rem;
    border-top: 1px solid rgba(12, 11, 29, 0.1);
}

.nq-authors[hidden] {
    display: none;
}

.nq-author {
    position: relative;
    padding: 0.55rem 0.7rem 0.75rem;
    border: 0;
    border-radius: 0.375rem;
    background: transparent;
    font-family: "Space Grotesk", sans-serif;
    font-size: 0.74rem;
    font-weight: 700;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    white-space: nowrap;
    color: rgba(12, 11, 29, 0.42);
    cursor: pointer;
    transition: color 0.35s ease, background-color 0.35s ease, scale 0.35s ease;
}

.nq-author:hover {
    color: var(--nq-ink);
    background: rgba(124, 58, 237, 0.06);
    scale: 1.04;
}

.nq-author[aria-pressed="true"] {
    color: var(--nq-ink);
}

.nq-author-bar {
    position: absolute;
    left: 0.7rem;
    right: 0.7rem;
    bottom: 0.4rem;
    height: 2px;
    overflow: hidden;
    border-radius: 2px;
    background: rgba(12, 11, 29, 0.08);
    opacity: 0;
}

.nq-author[aria-pressed="true"] .nq-author-bar {
    opacity: 1;
}

.nq-author-bar span {
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, #7c3aed, #0ea5e9 60%, #f472b6);
    transform: scaleX(0);
    transform-origin: left;
}

.nq-author[aria-pressed="true"] .nq-author-bar span {
    animation: nq-progress var(--nq-dur, 7.5s) linear forwards;
}

.nq.is-held .nq-author[aria-pressed="true"] .nq-author-bar span {
    animation-play-state: paused;
}

@keyframes nq-progress {
    to { transform: scaleX(1); }
}

.nq-author:focus-visible {
    outline: 2px solid #6d28d9;
    outline-offset: 2px;
}

@media (max-width: 767px) {
    /* One swipeable row of names on phones. */
    .nq-authors {
        flex-wrap: nowrap;
        margin-right: calc(-1 * clamp(1.25rem, 4.2vw, 3.5rem));
        padding-right: clamp(1.25rem, 4.2vw, 3.5rem);
        overflow-x: auto;
        scrollbar-width: none;
    }

    .nq-authors::-webkit-scrollbar {
        display: none;
    }
}

/* ---------- Phones and small tablets: step through the quotes ----------
   In place of the row of names: a step back, the count (its line filling as
   the quote plays, as the active name's does above), and a step forward. A
   swipe across the quote steps too, the quote leaning with the finger. */

.nq-nav {
    display: none;
}

@media (max-width: 899px) {
    .nq.is-live .nq-authors {
        display: none;
    }

    .nq.is-live .nq-nav {
        display: flex;
        align-items: center;
        gap: 1rem;
        margin-top: clamp(2.25rem, 5vw, 3rem);
        padding-top: 1.25rem;
        border-top: 1px solid rgba(12, 11, 29, 0.1);
    }

    .nq-step {
        display: inline-grid;
        place-items: center;
        flex: none;
        width: 2.9rem;
        height: 2.9rem;
        padding: 0;
        border: 1px solid var(--nq-ink);
        border-radius: 0.375rem;
        background: var(--nq-ink);
        color: #fff;
        box-shadow: 0 10px 22px -12px rgba(12, 11, 29, 0.55);
        cursor: pointer;
        -webkit-tap-highlight-color: transparent;
        transition: background-color 0.3s ease, border-color 0.3s ease, scale 0.25s ease;
    }

    .nq-step svg {
        width: 1.05rem;
        height: 1.05rem;
    }

    .nq-step:active {
        border-color: #6d28d9;
        background: #6d28d9;
        scale: 0.92;
    }

    .nq-step:focus-visible {
        outline: 2px solid #6d28d9;
        outline-offset: 2px;
    }

    .nq-nav-mid {
        display: grid;
        flex: 1;
        gap: 0.6rem;
        min-width: 0;
    }

    .nq-count {
        font-family: "Space Grotesk", sans-serif;
        font-size: 0.74rem;
        font-weight: 700;
        letter-spacing: 0.2em;
        text-align: center;
        color: rgba(12, 11, 29, 0.55);
        font-variant-numeric: tabular-nums;
    }

    .nq-count-now {
        color: var(--nq-ink);
    }

    .nq-nav-bar {
        position: relative;
        height: 2px;
        overflow: hidden;
        border-radius: 2px;
        background: rgba(12, 11, 29, 0.08);
    }

    .nq-nav-bar span {
        position: absolute;
        inset: 0;
        background: linear-gradient(90deg, #7c3aed, #0ea5e9 60%, #f472b6);
        transform: scaleX(0);
        transform-origin: left;
        animation: nq-progress var(--nq-dur, 7.5s) linear forwards;
    }

    .nq.is-held .nq-nav-bar span {
        animation-play-state: paused;
    }

    /* Horizontal swipes are the script's; vertical ones scroll the page. */
    .nq-stage {
        touch-action: pan-y;
    }

    .nq-stack {
        transition: translate 0.55s cubic-bezier(0.22, 1, 0.36, 1);
    }

    .nq.is-swiping .nq-stack {
        transition: none;
    }
}

/* ---------- Reduced motion ---------- */

@media (prefers-reduced-motion: reduce) {
    .nq-nav-bar span,
    .nq-stack {
        animation: none !important;
        transition: none !important;
    }

    .nq.is-live .nq-w,
    .nq.is-live .nq-by,
    .nq.is-live .nq-by::before {
        opacity: 1 !important;
        transform: none !important;
        filter: none !important;
        transition: none !important;
    }

    .nq-author-bar span {
        animation: none !important;
    }

    .ns-reveal {
        --rv: 1 !important;
    }
}
