:root {
    --abyss: #0a0e1a;
    --vault: #0d1321;
    --chamber: #111827;
    --depth: #0f172a;
    --complete: #0f1629;
    --signal: #3a7bd5;
    --chalk: #e2e8f0;
    --fog: #94a3b8;
    --steel: #6b7fa3;
    --pulse: #22d3ee;
}

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

html {
    scroll-behavior: smooth;
}

body {
    background-color: var(--abyss);
    color: var(--chalk);
    font-family: 'Source Sans 3', sans-serif;
    font-weight: 400;
    font-size: clamp(1rem, 1.1vw, 1.15rem);
    line-height: 1.72;
    overflow-x: hidden;
    position: relative;
}

/* Concrete noise texture overlay */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    filter: url(#noiseFilter);
    opacity: 0.03;
    pointer-events: none;
    z-index: 9999;
}

/* Sections */
.section {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    padding: 4rem 2rem;
}

/* Hero */
.section--hero {
    background-color: var(--abyss);
    overflow: hidden;
}

.puzzle-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(2, 1fr);
    gap: 2px;
    background-color: rgba(58, 123, 213, 0.15);
    padding: 2px;
    width: fit-content;
}

.puzzle-letter {
    font-family: 'Libre Franklin', sans-serif;
    font-weight: 900;
    font-size: clamp(5rem, 14vw, 12rem);
    letter-spacing: -0.04em;
    text-transform: uppercase;
    color: var(--chalk);
    background-color: var(--abyss);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.1em 0.2em;
    will-change: transform;
    transition: none;
}

.hero-wave {
    position: absolute;
    bottom: 20%;
    left: 0;
    width: 100%;
    height: 40px;
    opacity: 0;
    transition: opacity 0.6s ease;
}

.hero-wave.active {
    opacity: 1;
}

.hero-wave path {
    stroke-dasharray: 2400;
    stroke-dashoffset: 2400;
    transition: stroke-dashoffset 1.2s ease-out;
}

.hero-wave.active path {
    stroke-dashoffset: 0;
}

/* Thesis */
.section--thesis {
    background: linear-gradient(var(--vault), var(--chamber));
    position: relative;
}

.wave-bg-pattern {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0.08;
    pointer-events: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='40' viewBox='0 0 160 40'%3E%3Cpath d='M0 20 Q20 10 40 20 Q60 30 80 20 Q100 10 120 20 Q140 30 160 20' stroke='%233a7bd5' stroke-width='1' fill='none'/%3E%3Cpath d='M0 28 Q20 18 40 28 Q60 38 80 28 Q100 18 120 28 Q140 38 160 28' stroke='%233a7bd5' stroke-width='0.5' fill='none'/%3E%3C/svg%3E");
    background-size: 160px 40px;
}

.thesis-content {
    max-width: 42ch;
    text-align: left;
}

.thesis-content p {
    margin-bottom: 1.5em;
    color: var(--chalk);
}

/* Wave dividers */
.wave-divider {
    width: 80%;
    max-width: 600px;
    height: 20px;
    margin-top: 3rem;
}

.wave-draw {
    stroke-dasharray: 2400;
    stroke-dashoffset: 2400;
    transition: stroke-dashoffset 1s ease-out;
}

.wave-draw.drawn {
    stroke-dashoffset: 0;
}

/* Pieces */
.section--piece {
    position: relative;
    overflow: hidden;
}

.section--piece-01 {
    background: linear-gradient(var(--chamber), var(--vault));
}

.section--piece-02 {
    background: linear-gradient(var(--vault), var(--depth));
}

.section--piece-03 {
    background: linear-gradient(var(--depth), var(--chamber));
}

.piece-numeral {
    position: absolute;
    font-family: 'Libre Franklin', sans-serif;
    font-weight: 900;
    font-size: clamp(15rem, 30vw, 25rem);
    color: rgba(58, 123, 213, 0.05);
    line-height: 1;
    pointer-events: none;
    user-select: none;
}

.section--piece-01 .piece-numeral {
    right: 5%;
    top: 50%;
    transform: translateY(-50%);
}

.section--piece-02 .piece-numeral {
    left: 5%;
    top: 50%;
    transform: translateY(-50%);
}

.piece-numeral--center {
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%) !important;
}

.piece-content {
    max-width: 42ch;
    position: relative;
    z-index: 1;
}

.piece-content--left {
    align-self: flex-start;
    margin-left: 10%;
}

.piece-content--right {
    align-self: flex-end;
    margin-right: 10%;
}

.piece-content--center {
    text-align: center;
}

.piece-heading {
    font-family: 'Libre Franklin', sans-serif;
    font-weight: 800;
    font-size: clamp(1.8rem, 3.5vw, 3rem);
    color: var(--chalk);
    margin-bottom: 1rem;
}

.piece-content p {
    color: var(--fog);
    margin-bottom: 1.5em;
}

/* Assembly */
.section--assembly {
    background-color: var(--complete);
    min-height: 100vh;
}

.assembly-blocks {
    display: flex;
    gap: 2px;
    background-color: rgba(58, 123, 213, 0.15);
    padding: 2px;
    margin-bottom: 3rem;
}

.assembly-block {
    width: clamp(120px, 20vw, 200px);
    height: clamp(120px, 20vw, 200px);
    border: 1px solid var(--signal);
    background-color: var(--complete);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transform: translateY(40px);
    transition: opacity 0.8s cubic-bezier(0.22, 1, 0.36, 1), transform 0.8s cubic-bezier(0.22, 1, 0.36, 1);
}

.assembly-block.visible {
    opacity: 1;
    transform: translateY(0);
}

.assembly-label {
    font-family: 'Fira Code', monospace;
    font-size: 0.85rem;
    letter-spacing: 0.04em;
    color: var(--steel);
    text-transform: uppercase;
}

.assembly-wave {
    width: 80%;
    max-width: 800px;
    height: 40px;
    opacity: 0;
    transition: opacity 0.6s ease;
    margin-bottom: 3rem;
}

.assembly-wave.active {
    opacity: 1;
}

.assembly-wave path {
    stroke-dasharray: 2400;
    stroke-dashoffset: 2400;
    transition: stroke-dashoffset 1.2s ease-out;
}

.assembly-wave.active path {
    stroke-dashoffset: 0;
}

.assembly-ethos {
    font-family: 'Libre Franklin', sans-serif;
    font-weight: 800;
    font-size: clamp(1.2rem, 2.5vw, 2rem);
    color: var(--chalk);
    text-align: center;
    max-width: 60ch;
}

/* Signature / Footer */
.section--signature {
    min-height: auto;
    padding: 4rem 2rem 3rem;
    background-color: var(--abyss);
    gap: 1rem;
}

.signature-rule {
    width: 60px;
    border: none;
    border-top: 1px solid var(--signal);
    margin-bottom: 1rem;
}

.signature-domain {
    font-family: 'Fira Code', monospace;
    font-size: 0.85rem;
    letter-spacing: 0.04em;
    color: var(--steel);
}

.signature-copy {
    font-family: 'Source Sans 3', sans-serif;
    font-size: 0.8rem;
    color: var(--fog);
}

/* Reveal animations */
.reveal-item {
    opacity: 0;
    transform: translateY(24px);
    transition: opacity 0.8s cubic-bezier(0.22, 1, 0.36, 1), transform 0.8s cubic-bezier(0.22, 1, 0.36, 1);
}

.reveal-item.visible {
    opacity: 1;
    transform: translateY(0);
}

/* Responsive */
@media (max-width: 768px) {
    .puzzle-grid {
        grid-template-columns: repeat(2, 1fr);
        grid-template-rows: repeat(3, 1fr);
    }

    .piece-content--left,
    .piece-content--right {
        align-self: center;
        margin-left: 5%;
        margin-right: 5%;
    }

    .assembly-blocks {
        flex-direction: column;
    }

    .piece-numeral {
        font-size: clamp(8rem, 20vw, 15rem);
    }
}
