/* ═══════════════════════════════════════════════
   THE CREATIVE LOOP
   Pinned, scroll-scrubbed sequence:
   1. centred title  →  2. title splits, orbit turns
   →  3. title+orbit slide left, the seven-stage loop
      circuit draws itself on the right
═══════════════════════════════════════════════ */
.cl-section {
    position: relative;
    background: #000000;
}

.cl-pin {
    position: relative;
    height: 100vh;
    height: 100dvh;
    width: 100%;
    overflow: hidden;
}

/* ambient depth behind everything */
.cl-bg {
    position: absolute;
    inset: 0;
    pointer-events: none;
    background:
        radial-gradient(ellipse 60% 50% at 50% 46%, rgba(79, 122, 244, 0.15), transparent 70%),
        radial-gradient(ellipse 44% 52% at 22% 50%, rgba(99, 126, 236, 0.11), transparent 70%),
        radial-gradient(ellipse 46% 44% at 78% 50%, rgba(192, 64, 230, 0.10), transparent 72%),
        radial-gradient(ellipse 42% 42% at 20% 74%, rgba(29, 232, 181, 0.07), transparent 72%),
        #000000;
}

/* ─── Stage: title + orbit (moves as one unit) ─── */
.cl-stage {
    position: absolute;
    top: 50%;
    left: 50%;
    z-index: 2;
    width: max-content;
    max-width: 92vw;
    will-change: transform, left;
    /* xPercent/yPercent -50 are applied by GSAP */
}

.cl-title {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0;
    white-space: nowrap;
    font-family: 'Bricolage Grotesque', sans-serif;
    font-weight: 600;
    font-size: clamp(36px, 7vw, 104px);
    line-height: 1;
    letter-spacing: -0.04em;
    color: #ffffff;
}

.cl-title-part { display: inline-block; will-change: transform; }

/* ─── Orbit graphic that sits between the two words ─── */
.cl-orbit {
    display: inline-block;
    position: relative;
    width: 0;            /* animated open by GSAP */
    aspect-ratio: 1 / 1;
    flex: 0 0 auto;
    opacity: 0;          /* animated by GSAP */
    margin: 0 -0.06em;
    overflow: visible;
}

.cl-orbit-svg {
    width: 100%;
    height: 100%;
    display: block;
    overflow: visible;
    transition: filter 420ms var(--ease-out);
}

.cl-orbit-ticks line {
    stroke: rgba(255, 255, 255, 0.65);
    stroke-width: 1.4;
    stroke-linecap: round;
}

.cl-orbit-rings {
    transform-box: fill-box;
    transform-origin: center;
    will-change: transform;
}

.cl-orbit-rings ellipse {
    stroke: rgba(210, 220, 255, 0.34);
    stroke-width: 1;
    fill: none;
}

.cl-orbit-dot {
    fill: #ffffff;
    filter: drop-shadow(0 0 6px rgba(255, 255, 255, 0.8));
}

.cl-section.is-loop-open .cl-orbit-svg {
    filter: drop-shadow(0 0 18px rgba(255, 255, 255, 0.12));
}

.cl-section.is-loop-open .cl-orbit-core {
    animation: clOrbitCorePulse 3.8s ease-in-out infinite;
}

.cl-section.is-loop-open .cl-orbit-dot {
    animation: clOrbitDotPulse 1.9s ease-in-out infinite;
}

@keyframes clOrbitCorePulse {
    0%, 100% { opacity: 0.86; }
    50% { opacity: 1; }
}

@keyframes clOrbitDotPulse {
    0%, 100% { opacity: 0.72; }
    50% { opacity: 1; }
}

/* ─── Right-hand panel: the loop, drawn as a live circuit ─── */
.cl-panel {
    position: absolute;
    top: clamp(100px, 12vh, 140px);
    right: clamp(32px, 4.6vw, 88px);
    bottom: clamp(24px, 4vh, 52px);
    z-index: 2;
    width: clamp(520px, 46vw, 700px);
    max-width: 92vw;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
}

.cl-kicker {
    font-family: 'Bricolage Grotesque', sans-serif;
    width: max-content;
    max-width: 100%;
    margin: 0 auto clamp(10px, 1.8vh, 18px) 34px;
    padding: 7px 12px;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(255, 255, 255, 0.035);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    font-size: clamp(8px, 1.1vh, 10px);
    font-weight: 700;
    letter-spacing: 0.13em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.66);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    will-change: transform, opacity;
}
.cl-kicker span { color: rgba(122, 150, 250, 0.75); margin: 0 0.4em; }

.cl-flow {
    position: relative;
    min-height: 0;
}

/* circuit svg is generated by JS: rail through the 7 nodes,
   then a return path up the right edge, closing the loop */
.cl-flow-svg {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    display: block;
    overflow: visible;
    pointer-events: none;
}

.cl-flow-track {
    fill: none;
    stroke: rgba(158, 180, 255, 0.24);
    stroke-width: 1.2;
}

/* stroke colour comes from the userSpaceOnUse gradient built in JS,
   so the pulse shifts blue → purple → teal as it travels */
.cl-flow-comet {
    fill: none;
    stroke-width: 2.4;
    stroke-linecap: round;
    opacity: 0;
    filter: drop-shadow(0 0 7px rgba(255, 255, 255, 0.45));
    transition: opacity 600ms var(--ease-out);
}

.cl-section.is-loop-live .cl-flow-comet { opacity: 1; }

.cl-flow-arrow { fill: rgba(255, 255, 255, 0.75); }

.cl-steps {
    list-style: none;
    box-sizing: border-box;
    margin: 0;
    height: 100%;
    padding: clamp(26px, 3.4vh, 38px) 46px clamp(14px, 2.2vh, 24px) 0;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: clamp(5px, 0.9vh, 12px);
}

.cl-step {
    position: relative;
    padding-left: 34px;
    will-change: transform, opacity;
}

.cl-step-head {
    position: relative;
    display: flex;
    align-items: baseline;
    gap: 10px;
}

.cl-step-node {
    position: absolute;
    left: -30px;
    top: 50%;
    width: 9px;
    height: 9px;
    transform: translateY(-50%);
    border-radius: 50%;
    background: #0c0d11;
    border: 1px solid color-mix(in srgb, var(--cl-accent, #4f7af4) 75%, #ffffff 25%);
    box-shadow:
        0 0 0 4px #000000,
        0 0 10px color-mix(in srgb, var(--cl-accent, #4f7af4) 45%, transparent);
    transition:
        background 300ms var(--ease-out),
        border-color 300ms var(--ease-out),
        box-shadow 300ms var(--ease-out);
}

.cl-step-idx {
    font-family: 'Bricolage Grotesque', sans-serif;
    font-size: clamp(9px, 1.15vh, 11px);
    font-weight: 700;
    letter-spacing: 0.12em;
    font-variant-numeric: tabular-nums;
    color: color-mix(in srgb, var(--cl-accent, #4f7af4) 62%, #ffffff 38%);
    transition: color 300ms var(--ease-out);
}

.cl-step-name {
    font-family: 'Bricolage Grotesque', sans-serif;
    font-size: clamp(15px, 2.1vh, 20px);
    font-weight: 600;
    letter-spacing: -0.02em;
    line-height: 1.1;
    color: #ffffff;
    margin: 0;
    transition: color 300ms var(--ease-out);
}

.cl-step-body {
    font-family: 'Plus Jakarta Sans', sans-serif;
    margin: clamp(4px, 0.7vh, 7px) 0 0;
    max-width: 58ch;
    font-size: clamp(11px, 1.5vh, 14px);
    font-weight: 500;
    line-height: 1.45;
    letter-spacing: -0.01em;
    color: rgba(255, 255, 255, 0.72);
    text-wrap: pretty;
    transition: color 300ms var(--ease-out);
}

/* hover + "signal passing through" states */
.cl-step:hover .cl-step-node {
    border-color: color-mix(in srgb, var(--cl-accent, #4f7af4) 40%, #ffffff 60%);
}

.cl-step:hover .cl-step-body { color: rgba(255, 255, 255, 0.85); }

.cl-step.is-hot .cl-step-node {
    background: color-mix(in srgb, var(--cl-accent, #4f7af4) 55%, #ffffff 45%);
    border-color: color-mix(in srgb, var(--cl-accent, #4f7af4) 40%, #ffffff 60%);
    box-shadow:
        0 0 0 4px #000000,
        0 0 16px color-mix(in srgb, var(--cl-accent, #4f7af4) 90%, #ffffff 10%);
}

.cl-step.is-hot .cl-step-idx {
    color: color-mix(in srgb, var(--cl-accent, #4f7af4) 40%, #ffffff 60%);
}

.cl-step.is-hot .cl-step-body { color: rgba(255, 255, 255, 0.88); }

/* vertical label sitting on the return edge of the circuit */
.cl-flow-return {
    position: absolute;
    top: 50%;
    right: 0;
    transform: translate(50%, -50%);
    margin: 0;
    writing-mode: vertical-rl;
    font-family: 'Bricolage Grotesque', sans-serif;
    font-size: clamp(8px, 1.1vh, 10px);
    font-weight: 700;
    letter-spacing: 0.22em;
    text-transform: uppercase;
    white-space: nowrap;
    color: rgba(255, 255, 255, 0.55);
    background: #000000;
    padding: 12px 1px;
    will-change: opacity;
}

/* ─── Static fallback (mobile / reduced-motion): normal flow ─── */
.cl-section.is-static .cl-pin {
    height: auto;
    overflow: visible;
    padding: clamp(50px, 9vh, 96px) clamp(22px, 6vw, 80px) clamp(64px, 10vh, 112px);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: clamp(26px, 5vh, 52px);
}
.cl-section.is-static .cl-stage {
    position: static;
    transform: none !important;
    width: 100%;
    max-width: none;
    text-align: center;
}
/* mobile wordmark: small orbit crown over a one-line "The Creative Loop" */
.cl-section.is-static .cl-title {
    display: grid;
    grid-auto-flow: column;
    grid-template-columns: max-content max-content;
    justify-content: center;
    align-items: baseline;
    column-gap: 0.26em;
    white-space: nowrap;
    font-size: clamp(30px, 8.6vw, 54px);
}
.cl-section.is-static .cl-title-part { transform: none !important; }
.cl-section.is-static .cl-title-left { grid-row: 2; grid-column: 1; }
.cl-section.is-static .cl-title-right { grid-row: 2; grid-column: 2; }
.cl-section.is-static .cl-orbit {
    grid-row: 1;
    grid-column: 1 / -1;
    justify-self: center;
    width: clamp(64px, 17vw, 88px) !important;
    opacity: 1 !important;
    transform: none !important;
    margin: 0 auto clamp(12px, 3.4vw, 18px);
}
.cl-section.is-static .cl-panel {
    position: static;
    display: block;
    width: 100%;
    max-width: 640px;
}
.cl-section.is-static .cl-kicker {
    margin-left: 0;
    opacity: 1 !important;
    transform: none !important;
    white-space: normal;
}
.cl-section.is-static .cl-flow-svg { display: none; }
.cl-section.is-static .cl-steps {
    height: auto;
    position: relative;
    padding: 8px 0 0;
    justify-content: flex-start;
    gap: clamp(24px, 5vh, 36px);
}
.cl-section.is-static .cl-steps::before {
    content: "";
    position: absolute;
    left: 8px;
    top: 14px;
    bottom: 8px;
    width: 1px;
    background: linear-gradient(180deg, transparent, rgba(255, 255, 255, 0.16) 6%, rgba(255, 255, 255, 0.16) 94%, transparent);
}
.cl-section.is-static .cl-step {
    opacity: 1 !important;
    transform: none !important;
}
.cl-section.is-static .cl-step-name { font-size: clamp(17px, 5vw, 20px); }
.cl-section.is-static .cl-step-idx { font-size: 10px; }
.cl-section.is-static .cl-step-body {
    font-size: clamp(13px, 3.6vw, 15px);
    max-width: none;
}
.cl-section.is-static .cl-flow-return {
    position: static;
    writing-mode: horizontal-tb;
    transform: none;
    opacity: 1 !important;
    background: transparent;
    padding: 22px 0 0 34px;
    font-size: 9px;
}

/* pre-JS safety net: below the animated breakpoint, mirror the
   static layout so nothing overlaps before scripts run */
@media (max-width: 1023px) {
    .cl-pin {
        height: auto;
        overflow: visible;
        padding: clamp(72px, 12vh, 130px) clamp(24px, 7vw, 80px);
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: clamp(40px, 7vh, 72px);
    }
    .cl-stage {
        position: static;
        width: 100%;
        max-width: none;
        text-align: center;
    }
    .cl-title {
        flex-direction: column;
        white-space: normal;
        gap: clamp(6px, 2vw, 14px);
        font-size: clamp(30px, 8.6vw, 54px);
    }
    .cl-panel {
        position: static;
        display: block;
        width: 100%;
        max-width: 640px;
    }
    .cl-kicker { margin-left: 0; white-space: normal; }
    .cl-steps {
        height: auto;
        position: relative;
        padding: 8px 0 0;
        justify-content: flex-start;
        gap: clamp(24px, 5vh, 36px);
    }
    .cl-steps::before {
        content: "";
        position: absolute;
        left: 8px;
        top: 14px;
        bottom: 8px;
        width: 1px;
        background: linear-gradient(180deg, transparent, rgba(255, 255, 255, 0.16) 6%, rgba(255, 255, 255, 0.16) 94%, transparent);
    }
    .cl-step-name { font-size: clamp(17px, 5vw, 20px); }
    .cl-step-idx { font-size: 10px; }
    .cl-step-body {
        font-size: clamp(13px, 3.6vw, 15px);
        max-width: none;
    }
    .cl-flow-return {
        position: static;
        writing-mode: horizontal-tb;
        transform: none;
        background: transparent;
        padding: 22px 0 0 34px;
        font-size: 9px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .cl-section.is-loop-open .cl-orbit-core,
    .cl-section.is-loop-open .cl-orbit-dot {
        animation: none;
    }

    .cl-step-node,
    .cl-step-idx,
    .cl-step-name,
    .cl-step-body,
    .cl-flow-comet {
        transition: none;
    }
}
