/* =========================================================
   tanso.biz — element 006, observed
   palette:
     #0D0D1A  deep void
     #1A1A3E  midnight indigo
     #3D5A80  steel blue
     #98C1D9  pale electron blue
     #E0FBFC  ice white
     #EE6C4D  carbon ember
     #293241  charcoal slate
   typography:
     Chakra Petch  — display / headings
     Source Serif 4 — body (humanist serif)
     IBM Plex Mono  — data labels, captions
   ========================================================= */

:root {
    --void: #0D0D1A;
    --midnight: #1A1A3E;
    --steel: #3D5A80;
    --electron: #98C1D9;
    --ice: #E0FBFC;
    --ember: #EE6C4D;
    --charcoal: #293241;

    --font-display: "Chakra Petch", "Space Grotesk", "Inter", system-ui, sans-serif;
    --font-body: "Source Serif 4", "IBM Plex Serif", Georgia, serif;
    --font-mono: "IBM Plex Mono", "SF Mono", Menlo, monospace;

    --grid-gutter: 5vw;
    --max-width: 1440px;

    --ease-narrative: cubic-bezier(0.22, 1, 0.36, 1);
}

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

html {
    background: var(--void);
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-body);
    font-size: 1.125rem;
    line-height: 1.72;
    letter-spacing: 0.01em;
    color: var(--ice);
    background:
        radial-gradient(1200px 800px at 85% 15%, rgba(61, 90, 128, 0.25), transparent 60%),
        radial-gradient(900px 700px at 10% 80%, rgba(26, 26, 62, 0.55), transparent 60%),
        linear-gradient(135deg, var(--void) 0%, var(--midnight) 65%, #12122a 100%);
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
}

/* -------- Grain overlay ---------------------------------- */
.grain-overlay {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 100;
    opacity: 0.05;
    mix-blend-mode: overlay;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='200' height='200'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 1  0 0 0 0 1  0 0 0 0 1  0 0 0 0.7 0'/></filter><rect width='200' height='200' filter='url(%23n)'/></svg>");
    background-size: 200px 200px;
}

/* =========================================================
   Shared utilities
   ========================================================= */
.eyebrow {
    font-family: var(--font-mono);
    font-size: 0.78rem;
    letter-spacing: 0.22em;
    text-transform: uppercase;
    color: var(--ember);
    display: inline-block;
    padding-bottom: 0.4em;
    border-bottom: 1px solid rgba(238, 108, 77, 0.35);
}

.mono-label {
    font-family: var(--font-mono);
    font-size: 0.78rem;
    font-weight: 500;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--electron);
}

.mono-caption {
    font-family: var(--font-mono);
    font-size: 0.78rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: rgba(152, 193, 217, 0.55);
    display: block;
    margin-top: 1.2rem;
}

.section-heading {
    font-family: var(--font-display);
    font-size: clamp(1.6rem, 3.5vw, 2.8rem);
    font-weight: 600;
    letter-spacing: -0.01em;
    line-height: 1.15;
    color: var(--ice);
    margin-top: 0.6rem;
}

.section-heading em {
    font-style: italic;
    color: var(--electron);
    font-weight: 500;
}

.section {
    position: relative;
    width: 100%;
    padding: 8vh var(--grid-gutter);
}

/* =========================================================
   Section 1 — The Lattice (Hero)
   ========================================================= */
.section--lattice {
    min-height: 100vh;
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    grid-template-rows: auto 1fr auto;
    column-gap: 1.5vw;
    padding-top: 6vh;
    padding-bottom: 4vh;
    overflow: hidden;
}

.lattice__readout {
    grid-column: 1 / span 12;
    display: flex;
    justify-content: space-between;
    font-family: var(--font-mono);
    font-size: 0.72rem;
    letter-spacing: 0.22em;
    text-transform: uppercase;
    color: rgba(224, 251, 252, 0.4);
    padding-bottom: 1.5rem;
    border-bottom: 1px solid rgba(152, 193, 217, 0.12);
}

.lattice__title-block {
    grid-column: 1 / span 5;
    grid-row: 2 / 3;
    align-self: end;
    position: relative;
    padding-bottom: 2vh;
}

.lattice__kanji {
    position: absolute;
    top: -6vh;
    left: -1vw;
    font-family: var(--font-display);
    font-size: clamp(12rem, 22vw, 18rem);
    font-weight: 700;
    color: rgba(61, 90, 128, 0.10);
    line-height: 0.85;
    letter-spacing: -0.05em;
    pointer-events: none;
    user-select: none;
    z-index: 0;
}

.lattice__eyebrow {
    position: relative;
    font-family: var(--font-mono);
    font-size: 0.82rem;
    letter-spacing: 0.3em;
    text-transform: uppercase;
    color: var(--ember);
    display: block;
    margin-bottom: 1.4rem;
    z-index: 1;
}

.lattice__name {
    position: relative;
    font-family: var(--font-display);
    font-size: clamp(3.5rem, 9vw, 7rem);
    font-weight: 700;
    letter-spacing: -0.02em;
    line-height: 0.95;
    color: var(--ice);
    z-index: 1;
}

.lattice__dot {
    color: var(--ember);
    display: inline-block;
    transform: translateY(-0.05em);
}

.lattice__tag {
    position: relative;
    display: inline-block;
    margin-top: 1.4rem;
    font-family: var(--font-mono);
    font-size: 0.82rem;
    letter-spacing: 0.2em;
    color: var(--electron);
    padding: 0.35em 0.9em;
    border: 1px solid rgba(152, 193, 217, 0.3);
    z-index: 1;
}

.lattice__diagram {
    grid-column: 7 / span 6;
    grid-row: 2 / 3;
    position: relative;
    transform: translateY(10vh);
    aspect-ratio: 600 / 700;
    width: 100%;
    max-height: 80vh;
    overflow: hidden;
    clip-path: polygon(6% 0, 100% 0, 100% 94%, 94% 100%, 0 100%, 0 6%);
}

.lattice-svg {
    width: 100%;
    height: 100%;
    display: block;
    transition: transform 0.6s var(--ease-narrative);
}

.lattice__scan-line {
    position: absolute;
    inset: 0;
    pointer-events: none;
    background: linear-gradient(180deg, transparent 49.6%, rgba(152, 193, 217, 0.25) 50%, transparent 50.4%);
    background-size: 100% 6vh;
    animation: scan 7s linear infinite;
    mix-blend-mode: screen;
    opacity: 0.5;
}

@keyframes scan {
    0% { background-position: 0 -8vh; }
    100% { background-position: 0 100vh; }
}

.lattice__scroll-cue {
    grid-column: 1 / span 12;
    grid-row: 3 / 4;
    align-self: end;
    display: flex;
    align-items: center;
    gap: 1.5rem;
    font-family: var(--font-mono);
    font-size: 0.75rem;
    letter-spacing: 0.3em;
    text-transform: uppercase;
    color: rgba(224, 251, 252, 0.5);
    padding-top: 2rem;
}

.scroll-cue__line {
    flex: 0 0 12vw;
    height: 1px;
    background: linear-gradient(90deg, var(--ember), transparent);
}

/* =========================================================
   Section 2 — Allotropes
   ========================================================= */
.section--allotropes {
    padding-top: 16vh;
    padding-bottom: 12vh;
    background: linear-gradient(225deg, rgba(13, 13, 26, 0) 0%, rgba(26, 26, 62, 0.6) 40%, rgba(13, 13, 26, 1) 100%);
}

.allotropes__header {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    margin-bottom: 10vh;
}

.allotropes__header .eyebrow {
    grid-column: 2 / span 4;
    margin-bottom: 1rem;
}

.allotropes__header .section-heading {
    grid-column: 2 / span 8;
    max-width: 22ch;
}

.allotropes__grid {
    display: flex;
    flex-direction: column;
    gap: 18vh;
}

.allotrope {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    column-gap: 1.5vw;
    align-items: start;
}

/* Default: prose 2-6 (40%), image 8-12 (55%+gutter) */
.allotrope__prose {
    grid-column: 2 / span 4;
    max-width: 38ch;
    font-family: var(--font-body);
}

.allotrope__image {
    grid-column: 8 / span 5;
    transform: translateY(var(--parallax-offset, 4vh));
}

/* Offset alternation — still asymmetric, never mirrored */
.allotrope--offset .allotrope__prose {
    grid-column: 3 / span 4;
}

.allotrope--offset .allotrope__image {
    grid-column: 8 / span 4;
    transform: translateY(var(--parallax-offset, 4vh));
}

.allotrope__prose .mono-label {
    display: block;
    color: var(--ember);
    margin-bottom: 1.2rem;
}

.allotrope__prose p {
    margin-bottom: 1.4rem;
    color: rgba(224, 251, 252, 0.88);
}

.allotrope__prose p.mono-caption {
    margin-top: 2rem;
}

/* Duotone container */
.duotone {
    position: relative;
    width: 100%;
    aspect-ratio: 400 / 480;
    overflow: hidden;
    clip-path: polygon(0 0, 100% 0, 100% 92%, 92% 100%, 0 100%);
    isolation: isolate;
    border: 1px solid rgba(152, 193, 217, 0.1);
}

.duotone--clip {
    clip-path: polygon(8% 0, 100% 0, 100% 100%, 0 100%, 0 8%);
}

.duotone__svg {
    width: 100%;
    height: 100%;
    display: block;
    filter: grayscale(100%) contrast(1.1);
}

.duotone__overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, var(--void), var(--steel));
    mix-blend-mode: color;
    opacity: 0.85;
    pointer-events: none;
}

/* Reveal (IntersectionObserver) */
.reveal-left, .reveal-right {
    opacity: 0;
    transition: opacity 0.9s var(--ease-narrative), transform 0.9s var(--ease-narrative);
    will-change: transform, opacity;
}

.reveal-left {
    transform: translateX(-40px);
}

.reveal-right {
    transform: translateX(40px);
    transition-delay: 0.2s;
}

.is-revealed.reveal-left,
.is-revealed.reveal-right {
    opacity: 1;
    transform: translate3d(0, var(--parallax-offset, 0), 0);
}

.allotrope__image.reveal-right.is-revealed {
    transform: translate3d(0, var(--parallax-offset, 4vh), 0);
}

/* =========================================================
   Section 3 — The Bonds
   ========================================================= */
.section--bonds {
    padding-top: 14vh;
    padding-bottom: 14vh;
    background:
        linear-gradient(135deg, rgba(13, 13, 26, 1) 0%, rgba(41, 50, 65, 0.8) 50%, rgba(13, 13, 26, 1) 100%);
    position: relative;
    overflow: hidden;
}

.section--bonds::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(152, 193, 217, 0.3), transparent);
}

.bonds__header {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    margin-bottom: 9vh;
}

.bonds__header .eyebrow {
    grid-column: 3 / span 4;
    margin-bottom: 1rem;
}

.bonds__header .section-heading {
    grid-column: 3 / span 8;
    max-width: 24ch;
}

.bonds__strip {
    min-height: 60vh;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1.8vw;
    align-items: stretch;
    padding: 0 2vw;
}

.bond {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 1.5rem;
    padding: 2rem 1.4rem;
    background: linear-gradient(180deg, rgba(41, 50, 65, 0.5), rgba(13, 13, 26, 0.8));
    border: 1px solid rgba(152, 193, 217, 0.12);
    position: relative;
    transition: border-color 0.4s var(--ease-narrative), transform 0.4s var(--ease-narrative);
    cursor: crosshair;
}

.bond:nth-child(1) { transform: translateY(0); }
.bond:nth-child(2) { transform: translateY(3vh); }
.bond:nth-child(3) { transform: translateY(-2vh); }
.bond:nth-child(4) { transform: translateY(4vh); }

.bond:hover {
    border-color: var(--ember);
}

.bond__frame {
    width: 100%;
    aspect-ratio: 3 / 2;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem;
    background:
        repeating-linear-gradient(
            45deg,
            transparent 0,
            transparent 14px,
            rgba(152, 193, 217, 0.04) 14px,
            rgba(152, 193, 217, 0.04) 15px
        ),
        radial-gradient(circle at center, rgba(61, 90, 128, 0.18), transparent 70%);
}

.bond__svg {
    width: 100%;
    height: 100%;
    display: block;
    transition: transform 0.1s linear;
}

.bond.is-vibrating .bond__svg {
    animation: vibrate 0.05s linear 6;
}

@keyframes vibrate {
    0%, 100% { transform: translate(0, 0); }
    25% { transform: translate(2px, -1px); }
    50% { transform: translate(-1px, 2px); }
    75% { transform: translate(1px, -2px); }
}

.bond figcaption {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.bond__name {
    font-family: var(--font-display);
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--ice);
    letter-spacing: 0.01em;
}

.bond .mono-caption {
    margin-top: 0;
    color: rgba(152, 193, 217, 0.65);
}

.bonds__footnote {
    margin-top: 8vh;
    margin-left: 20%;
    max-width: 52ch;
    font-family: var(--font-body);
    font-style: italic;
    font-size: 1rem;
    color: rgba(224, 251, 252, 0.6);
    line-height: 1.6;
}

/* =========================================================
   Section 4 — The Residue
   ========================================================= */
.section--residue {
    min-height: 95vh;
    padding-top: 18vh;
    padding-bottom: 6vh;
    background: linear-gradient(225deg, #09091a 0%, #040410 60%, #000000 100%);
    position: relative;
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    grid-template-rows: 1fr auto;
    overflow: hidden;
}

.residue__glow {
    position: absolute;
    top: 30%;
    left: 25%;
    width: 55vw;
    height: 55vw;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(238, 108, 77, 0.25) 0%, rgba(61, 90, 128, 0.12) 40%, transparent 70%);
    filter: blur(60px);
    opacity: 0.18;
    animation: glow 6s ease-in-out infinite;
    pointer-events: none;
    mix-blend-mode: screen;
}

@keyframes glow {
    0%, 100% { opacity: 0.15; }
    50% { opacity: 0.3; }
}

.residue__body {
    grid-column: 3 / span 5;
    grid-row: 1 / 2;
    align-self: center;
    position: relative;
    z-index: 2;
}

.residue__body .eyebrow {
    margin-bottom: 2rem;
}

.residue__prose {
    font-family: var(--font-body);
    font-size: clamp(1.15rem, 1.6vw, 1.4rem);
    line-height: 1.8;
    letter-spacing: 0.01em;
    color: rgba(224, 251, 252, 0.9);
    margin-bottom: 2.8rem;
}

.residue__sign {
    color: rgba(238, 108, 77, 0.7);
    letter-spacing: 0.28em;
}

.residue__footer {
    grid-column: 2 / span 10;
    grid-row: 2 / 3;
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    padding-top: 6vh;
    border-top: 1px solid rgba(152, 193, 217, 0.1);
    position: relative;
    z-index: 2;
}

/* =========================================================
   Responsive
   ========================================================= */
@media (max-width: 980px) {
    .section--lattice {
        grid-template-rows: auto auto auto auto;
    }

    .lattice__title-block {
        grid-column: 1 / span 12;
        grid-row: 2 / 3;
    }

    .lattice__diagram {
        grid-column: 1 / span 12;
        grid-row: 3 / 4;
        transform: translateY(0);
        margin-top: 4vh;
        max-height: 60vh;
    }

    .lattice__scroll-cue {
        grid-row: 4 / 5;
    }

    .allotrope, .allotrope--offset {
        grid-template-columns: 1fr;
        gap: 4vh;
    }

    .allotrope__prose,
    .allotrope--offset .allotrope__prose {
        grid-column: 1 / -1;
        max-width: 100%;
    }

    .allotrope__image,
    .allotrope--offset .allotrope__image {
        grid-column: 1 / -1;
        transform: none;
    }

    .allotropes__header .eyebrow,
    .allotropes__header .section-heading,
    .bonds__header .eyebrow,
    .bonds__header .section-heading {
        grid-column: 1 / -1;
    }

    .bonds__strip {
        grid-template-columns: repeat(2, 1fr);
        gap: 2vh 2vw;
    }

    .bond:nth-child(n) {
        transform: translateY(0);
    }

    .bonds__footnote {
        margin-left: 0;
    }

    .residue__body {
        grid-column: 1 / -1;
    }

    .residue__footer {
        grid-column: 1 / -1;
        flex-direction: column;
        gap: 0.8rem;
    }
}

@media (max-width: 560px) {
    .bonds__strip {
        grid-template-columns: 1fr;
    }

    .lattice__readout {
        flex-direction: column;
        gap: 0.4rem;
    }
}
