/* =====================================================
   scriptgrapher.com — kinetic typography
   Palette: #0A0A0A #141414 #222222 #888888
            #E8E8E8 #F0F0F0 #FFFFFF #FF2D2D
   Fonts:   Archivo Black, Space Grotesk, DM Mono, Instrument Serif
   ===================================================== */

* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --bg-primary: #0A0A0A;
    --bg-secondary: #141414;
    --grid-line: #222222;
    --text-meta: #888888;
    --text-muted: #E8E8E8;
    --text-primary: #F0F0F0;
    --text-pure: #FFFFFF;
    --signal: #FF2D2D;
    --signal-soft: rgba(255, 45, 45, 0.20);
    --signal-glow: rgba(255, 45, 45, 0.50);

    --font-body: "Space Grotesk", system-ui, sans-serif;
    --font-display: "Archivo Black", "Space Grotesk", sans-serif;
    --font-mono: "DM Mono", "JetBrains Mono", monospace;
    --font-serif: "Instrument Serif", "Times New Roman", serif;

    --stage-pad: 15vw;
    --section-tilt: 5deg;
    --counter-tilt: -3deg;
}

html, body {
    background: var(--bg-primary);
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 16px;
    line-height: 1.7;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    min-height: 100vh;
    cursor: default;
    background:
        radial-gradient(circle at 20% 10%, rgba(255,45,45,0.04), transparent 50%),
        radial-gradient(circle at 80% 80%, rgba(255,255,255,0.02), transparent 60%),
        var(--bg-primary);
}

/* ----- Global Stage / Sections ------------------------------- */
.stage {
    position: relative;
    width: 100%;
    overflow: hidden;
}

.section {
    position: relative;
    width: 100%;
    min-height: 100vh;
    padding: 8vh var(--stage-pad);
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-primary);
    overflow: hidden;
    margin-top: -40px;
    border-top: 1px solid transparent;
    z-index: 1;
}

.section:nth-of-type(odd of .section) {
    background: var(--bg-primary);
}
.section:nth-of-type(even of .section) {
    background: var(--bg-secondary);
}

.section--tilt-right .section-content {
    transform: rotate(var(--section-tilt));
    transform-origin: 50% 50%;
}

.section--tilt-left .section-content {
    transform: rotate(calc(-1 * var(--section-tilt)));
    transform-origin: 50% 50%;
}

/* counter-rotated text */
.section--tilt-right .section-text { transform: rotate(var(--counter-tilt)); }
.section--tilt-left  .section-text { transform: rotate(calc(-1 * var(--counter-tilt))); }

.section-content {
    position: relative;
    width: 100%;
    max-width: 1400px;
    display: grid;
    grid-template-columns: 40fr 60fr;
    gap: 6vw;
    align-items: center;
}

.section-content--reverse {
    grid-template-columns: 60fr 40fr;
}

.section-text {
    position: relative;
    z-index: 2;
    transition: transform 600ms cubic-bezier(0.34, 1.56, 0.64, 1);
}

.section-text--right { text-align: left; }

/* ----- Hero -------------------------------------------------- */
.section--hero {
    min-height: 100vh;
    flex-direction: column;
    justify-content: center;
    background: var(--bg-primary);
    padding-top: 5vh;
    padding-bottom: 5vh;
    margin-top: 0;
    overflow: hidden;
}

.hero-meta {
    position: absolute;
    top: 4vh;
    left: var(--stage-pad);
    right: var(--stage-pad);
    display: flex;
    justify-content: space-between;
    gap: 2rem;
    z-index: 5;
}

.mono-label {
    font-family: var(--font-mono);
    font-size: 11px;
    line-height: 1.4;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--text-meta);
}

.mono-label--pulse {
    color: var(--signal);
    animation: pulseSignal 2s ease-in-out infinite;
    display: inline-flex;
    align-items: center;
    gap: 0.5em;
}
.dot-red {
    width: 6px; height: 6px; border-radius: 50%;
    background: var(--signal);
    box-shadow: 0 0 8px var(--signal-glow);
}

@keyframes pulseSignal {
    0%, 100% { opacity: 0.8; }
    50% { opacity: 1; }
}

.hero-stage {
    position: relative;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
}

.hero-title {
    font-family: var(--font-display);
    font-weight: 400;
    color: var(--text-primary);
    line-height: 0.85;
    letter-spacing: -0.04em;
    text-transform: uppercase;
    display: flex;
    flex-wrap: nowrap;
    justify-content: center;
    align-items: baseline;
    width: 100%;
    font-size: clamp(48px, 13vw, 240px);
    user-select: none;
    will-change: transform;
}

.hero-letter {
    display: inline-block;
    transform: translateY(120vh) rotate(20deg);
    opacity: 0;
    will-change: transform, opacity, color, text-shadow;
    transition: color 220ms ease, text-shadow 220ms ease;
    position: relative;
}

.hero-letter.is-revealed {
    animation: heroLetterIn 700ms cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes heroLetterIn {
    0%   { transform: translate(var(--from-x, 0), var(--from-y, 110vh)) rotate(var(--from-r, 18deg)); opacity: 0; }
    60%  { opacity: 1; }
    100% { transform: translate(0, 0) rotate(0); opacity: 1; }
}

/* idle breathing — applied after intro */
.hero-letter.is-breathing {
    animation: heroBreathe 4s ease-in-out infinite;
}
.hero-letter.is-breathing:nth-child(2n)  { animation-delay: 0.3s; }
.hero-letter.is-breathing:nth-child(3n)  { animation-delay: 0.6s; animation-duration: 4.6s; }
.hero-letter.is-breathing:nth-child(4n)  { animation-delay: 0.9s; animation-duration: 5.2s; }
.hero-letter.is-breathing:nth-child(5n)  { animation-delay: 1.1s; animation-duration: 4.4s; }

@keyframes heroBreathe {
    0%, 100% { transform: translate3d(var(--mx, 0), var(--my, 0), 0) scale(1.00); }
    50%      { transform: translate3d(var(--mx, 0), calc(var(--my, 0px) - 3px), 0) scale(1.02); }
}

.hero-letter[data-letter="G"] { color: var(--text-pure); }

.hero-measure {
    position: relative;
    width: min(78%, 980px);
    margin-top: 2.4rem;
    display: flex;
    align-items: center;
    justify-content: center;
}
.measure-line {
    flex: 1;
    height: 1px;
    background: var(--grid-line);
}
.measure-tick {
    position: absolute;
    top: -6px;
    width: 1px;
    height: 13px;
    background: var(--text-meta);
}
.measure-tick--left  { left: 0; }
.measure-tick--right { right: 0; }
.measure-text {
    position: absolute;
    top: -22px;
    left: 50%;
    transform: translateX(-50%);
    font-family: var(--font-mono);
    font-size: 10px;
    letter-spacing: 0.12em;
    color: var(--text-meta);
    text-transform: uppercase;
    background: var(--bg-primary);
    padding: 0 12px;
}

.hero-tagline {
    margin-top: 4rem;
    text-align: center;
    color: var(--text-muted);
    font-family: var(--font-body);
    font-size: clamp(14px, 1.2vw, 18px);
    letter-spacing: 0.02em;
    line-height: 1.8;
    max-width: 720px;
}
.tag-line {
    display: block;
    overflow: hidden;
}
.tag-line:last-child { color: var(--text-meta); }

.hero-scroll-cue {
    position: absolute;
    bottom: 4vh;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.6rem;
    color: var(--text-meta);
}
.scroll-arrow {
    font-family: var(--font-mono);
    font-size: 18px;
    color: var(--signal);
    animation: scrollNudge 2s ease-in-out infinite;
}
@keyframes scrollNudge {
    0%, 100% { transform: translateY(0); opacity: 0.7; }
    50%      { transform: translateY(8px); opacity: 1; }
}

/* ----- Interstitial (scroll-zoom) --------------------------- */
.interstitial {
    position: relative;
    width: 100%;
    height: 80vh;
    background: var(--bg-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    margin-top: -40px;
}

.interstitial-word {
    font-family: var(--font-serif);
    font-style: italic;
    font-weight: 400;
    color: var(--text-pure);
    line-height: 1;
    letter-spacing: -0.04em;
    text-transform: lowercase;
    font-size: 14px;
    transition: none;
    will-change: font-size, letter-spacing, color;
    white-space: nowrap;
    transform-origin: 50% 50%;
}

.interstitial[data-zoom-word="SHATTER"] .interstitial-word,
.interstitial[data-zoom-word="REFORM"]  .interstitial-word {
    color: var(--signal);
}
.interstitial[data-zoom-word="WAVE"] .interstitial-word {
    color: var(--text-primary);
}
.interstitial[data-zoom-word="PRINT"] .interstitial-word {
    color: var(--text-muted);
}

/* ----- Section Headings + Body ------------------------------- */
.section-heading {
    font-family: var(--font-display);
    font-weight: 400;
    line-height: 0.92;
    letter-spacing: -0.03em;
    text-transform: uppercase;
    color: var(--text-pure);
    font-size: clamp(40px, 5.6vw, 88px);
    margin-bottom: 1.8rem;
    transition: transform 300ms ease;
}
.section-heading:hover {
    transform: skewX(2deg);
}
.heading-break {
    display: block;
    height: 0;
    width: 100%;
}

.bounce-letter {
    display: inline-block;
    transform: translateY(40px);
    opacity: 0;
    transition: transform 500ms cubic-bezier(0.34, 1.56, 0.64, 1), opacity 500ms ease;
}
.is-in-view .bounce-letter {
    transform: translateY(0);
    opacity: 1;
}

.section-body {
    color: var(--text-muted);
    font-family: var(--font-body);
    font-weight: 400;
    font-size: 17px;
    line-height: 1.7;
    letter-spacing: 0.005em;
    max-width: 38ch;
    margin-bottom: 1.6rem;
    opacity: 0;
    transform: translateX(-60px);
    transition: opacity 500ms ease, transform 500ms cubic-bezier(0.22, 1, 0.36, 1);
}
.section--tilt-left .section-body {
    transform: translateX(60px);
}
.is-in-view .section-body {
    opacity: 1;
    transform: translateX(0);
}

.section-meta {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 0.6rem 1.6rem;
    align-items: baseline;
    font-family: var(--font-mono);
    font-size: 11px;
    letter-spacing: 0.1em;
    color: var(--text-meta);
    text-transform: uppercase;
    border-top: 1px solid var(--grid-line);
    padding-top: 1rem;
    max-width: 36ch;
    opacity: 0;
    transition: opacity 600ms ease 200ms;
}
.is-in-view .section-meta { opacity: 1; }

.meta-key { color: var(--text-meta); }
.meta-val {
    color: var(--text-primary);
    font-family: var(--font-mono);
}

/* ----- Specimen container ----------------------------------- */
.section-specimen {
    position: relative;
    aspect-ratio: 4 / 3;
    width: 100%;
    background: rgba(20, 20, 20, 0.6);
    border: 1px solid var(--grid-line);
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.specimen-grid {
    position: absolute;
    inset: 0;
    background-image:
        linear-gradient(to right, rgba(34,34,34,0.5) 1px, transparent 1px),
        linear-gradient(to bottom, rgba(34,34,34,0.5) 1px, transparent 1px);
    background-size: 24px 24px;
    opacity: 0;
    transition: opacity 700ms ease;
    pointer-events: none;
}
.is-in-view .specimen-grid { opacity: 0.4; }

.specimen-caption {
    position: absolute;
    bottom: 1rem;
    left: 1rem;
    z-index: 3;
}

/* ----- Orbit specimen --------------------------------------- */
.orbit-stage {
    position: relative;
    width: 70%;
    aspect-ratio: 1 / 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.orbit-letter {
    position: absolute;
    font-family: var(--font-display);
    font-size: clamp(24px, 4vw, 56px);
    color: var(--text-primary);
    text-transform: uppercase;
    line-height: 1;
    transform-origin: center;
    animation: orbitSpin 12s linear infinite;
    --orbit-i: 0;
    animation-delay: calc(var(--orbit-i) * -2s);
    will-change: transform;
}

@keyframes orbitSpin {
    from { transform: rotate(0deg) translateX(36%) rotate(0deg); }
    to   { transform: rotate(360deg) translateX(36%) rotate(-360deg); }
}

.orbit-letter:nth-child(1)  { color: var(--text-pure); }
.orbit-letter:nth-child(2)  { color: var(--text-primary); }
.orbit-letter:nth-child(3)  { color: var(--text-muted); }
.orbit-letter:nth-child(4)  { color: var(--text-meta); }
.orbit-letter:nth-child(5)  { color: var(--signal); }
.orbit-letter:nth-child(6)  { color: var(--text-primary); }

.orbit-center {
    position: relative;
    z-index: 2;
    font-family: var(--font-serif);
    font-style: italic;
    font-size: clamp(40px, 6vw, 88px);
    color: var(--text-pure);
    line-height: 1;
    text-shadow: 0 0 24px rgba(255,45,45,0.25);
}

/* ----- Shatter specimen ------------------------------------- */
.shatter-stage {
    position: relative;
    width: 88%;
    height: 60%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.shatter-word, .shatter-replacement {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.04em;
    font-family: var(--font-display);
    text-transform: uppercase;
    font-size: clamp(36px, 7vw, 96px);
    line-height: 1;
    letter-spacing: -0.02em;
}

.shard {
    color: var(--text-pure);
    display: inline-block;
    will-change: transform, clip-path, opacity;
    transition: transform 700ms cubic-bezier(0.7, 0, 0.84, 0), opacity 600ms ease, clip-path 700ms ease;
    clip-path: polygon(0 0, 100% 0, 100% 100%, 0 100%);
}
.shatter-stage.is-broken .shard {
    transform: translate(var(--sx, 0), var(--sy, 0)) rotate(var(--sr, 0deg));
    opacity: 0;
    clip-path: polygon(0 0, 100% 25%, 70% 100%, 25% 80%);
}

.reform {
    color: var(--signal);
    display: inline-block;
    opacity: 0;
    transform: translateY(40px);
    transition: opacity 500ms ease, transform 600ms cubic-bezier(0.34, 1.56, 0.64, 1);
}
.shatter-stage.is-broken .reform {
    opacity: 1;
    transform: translateY(0);
}
.shatter-stage.is-broken .reform:nth-child(1) { transition-delay: 350ms; }
.shatter-stage.is-broken .reform:nth-child(2) { transition-delay: 420ms; }
.shatter-stage.is-broken .reform:nth-child(3) { transition-delay: 490ms; }
.shatter-stage.is-broken .reform:nth-child(4) { transition-delay: 560ms; }
.shatter-stage.is-broken .reform:nth-child(5) { transition-delay: 630ms; }
.shatter-stage.is-broken .reform:nth-child(6) { transition-delay: 700ms; }

/* ----- Proximity specimen ----------------------------------- */
.proximity-stage {
    position: relative;
    width: 100%;
    height: 70%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.2em;
    overflow: hidden;
    cursor: crosshair;
}

.proximity-line {
    display: flex;
    gap: 0.04em;
    line-height: 0.9;
}

.prox-letter {
    font-family: var(--font-display);
    text-transform: uppercase;
    font-size: clamp(36px, 7vw, 96px);
    color: var(--text-primary);
    transition: color 200ms ease, text-shadow 200ms ease, transform 220ms cubic-bezier(0.34, 1.56, 0.64, 1);
    will-change: transform, color, text-shadow;
    display: inline-block;
}

/* ----- Wave specimen ---------------------------------------- */
.wave-stage {
    position: relative;
    width: 84%;
    height: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.04em;
}
.wave-letter {
    --wave-i: 0;
    display: inline-block;
    font-family: var(--font-display);
    text-transform: uppercase;
    font-size: clamp(40px, 8vw, 110px);
    color: var(--text-primary);
    line-height: 1;
    will-change: transform, color;
    animation: waveFloat 2.4s ease-in-out infinite;
    animation-delay: calc(var(--wave-i) * 120ms);
}
.wave-letter:nth-child(2n)   { color: var(--text-muted); }
.wave-letter:nth-child(3n+1) { color: var(--signal); }

@keyframes waveFloat {
    0%, 100% { transform: translateY(0) skewX(0deg); }
    25%      { transform: translateY(-22px) skewX(-2deg); }
    50%      { transform: translateY(0) skewX(0deg); }
    75%      { transform: translateY(22px) skewX(2deg); }
}

/* ----- Closing ---------------------------------------------- */
.section--closing {
    flex-direction: column;
    justify-content: center;
    text-align: center;
    background: var(--bg-primary);
    padding-top: 12vh;
    padding-bottom: 12vh;
}

.closing-stack {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2.4rem;
    max-width: 1100px;
    width: 100%;
}

.closing-headline {
    font-family: var(--font-display);
    font-weight: 400;
    color: var(--text-primary);
    text-transform: uppercase;
    line-height: 0.95;
    letter-spacing: -0.03em;
    font-size: clamp(40px, 8vw, 130px);
    margin: 0;
}
.closing-headline .bounce-letter:last-child {
    color: var(--signal);
}

.colophon {
    width: 100%;
    max-width: 760px;
    border-top: 1px solid var(--grid-line);
    border-bottom: 1px solid var(--grid-line);
    padding: 1.5rem 0;
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
}
.colophon-row {
    display: grid;
    grid-template-columns: 140px 1fr;
    align-items: center;
    gap: 1rem;
    text-align: left;
    color: var(--text-muted);
    font-size: 14px;
}
.colophon-val {
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 14px;
    letter-spacing: 0.01em;
}
.swatch {
    display: inline-block;
    width: 14px;
    height: 14px;
    margin-right: 4px;
    border: 1px solid var(--grid-line);
    vertical-align: middle;
}

.closing-mark {
    display: flex;
    align-items: baseline;
    gap: 0;
    font-family: var(--font-serif);
    font-style: italic;
    font-size: clamp(40px, 6vw, 84px);
    color: var(--text-pure);
}
.closing-glyph {
    color: var(--signal);
    font-family: var(--font-display);
    font-style: normal;
    font-size: 1.2em;
    line-height: 0.5;
    margin-left: 0.05em;
}

/* ----- Vertical timeline rule ------------------------------- */
.vertical-rule {
    position: fixed;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 1px;
    height: 100%;
    background: transparent;
    z-index: 0;
    pointer-events: none;
}
.vrule-fill {
    display: block;
    width: 1px;
    height: 0%;
    background: var(--text-muted);
    opacity: 0.18;
}

/* per-section timeline accent */
.timeline-line {
    position: absolute;
    left: 50%;
    top: 0;
    width: 1px;
    height: 0%;
    background: var(--grid-line);
    transform: translateX(-50%);
    z-index: 0;
    transition: height 700ms cubic-bezier(0.22, 1, 0.36, 1);
}
.is-in-view .timeline-line { height: 100%; }

/* ----- Typewriter labels ------------------------------------ */
.typewriter {
    display: inline-block;
    overflow: hidden;
    white-space: nowrap;
    border-right: 1px solid var(--signal);
    width: 0;
    color: var(--text-meta);
    margin-bottom: 1.2rem;
    padding-right: 4px;
}
.is-in-view .typewriter {
    animation: typeReveal 1200ms steps(20, end) forwards, caretBlink 0.6s steps(1, end) infinite;
}
@keyframes typeReveal {
    from { width: 0; }
    to   { width: 100%; }
}
@keyframes caretBlink {
    50% { border-right-color: transparent; }
}

/* ----- Cursor trail layer ----------------------------------- */
.cursor-trail-layer {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 9999;
    overflow: hidden;
}

.cursor-char {
    position: absolute;
    font-family: var(--font-mono);
    font-size: 10px;
    color: var(--signal);
    opacity: 0.4;
    will-change: transform, opacity;
    animation: cursorFade 600ms ease-out forwards;
    text-transform: uppercase;
    pointer-events: none;
    user-select: none;
}
@keyframes cursorFade {
    0%   { opacity: 0.4; transform: translateY(0); }
    100% { opacity: 0;   transform: translateY(-10px); }
}

/* ----- Responsive ------------------------------------------- */
@media (max-width: 960px) {
    :root {
        --stage-pad: 6vw;
        --section-tilt: 3deg;
        --counter-tilt: -2deg;
    }
    .section-content,
    .section-content--reverse {
        grid-template-columns: 1fr;
        gap: 3rem;
    }
    .hero-meta {
        flex-direction: column;
        gap: 0.4rem;
    }
    .section-specimen { aspect-ratio: 5 / 4; }
    .section-body { max-width: 100%; }
    .colophon-row {
        grid-template-columns: 1fr;
        gap: 0.2rem;
    }
}

@media (max-width: 600px) {
    .hero-title { font-size: clamp(40px, 18vw, 90px); }
    .interstitial { height: 60vh; }
    .section { padding-top: 6vh; padding-bottom: 6vh; }
}
