/* === RESET & BASE === */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
    font-size: 16px;
}

body {
    font-family: 'Varela Round', sans-serif;
    color: #2C2520;
    background-color: #F5F0E8;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

/* === REVEAL ANIMATION === */
.reveal {
    opacity: 0;
    transform: translateY(24px);
    transition: opacity 1.2s ease-out, transform 1.2s ease-out;
}

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

/* === CHAPTER NUMBERS === */
.chapter-number {
    position: absolute;
    left: clamp(0.5rem, 2vw, 2rem);
    top: 50%;
    transform: translateY(-50%) rotate(-90deg);
    font-family: 'Nunito', sans-serif;
    font-weight: 900;
    font-size: clamp(3rem, 6vw, 6rem);
    color: rgba(196, 154, 61, 0.12);
    letter-spacing: 0.05em;
    pointer-events: none;
    z-index: 1;
}

.chapter-number-light {
    color: rgba(250, 248, 244, 0.1);
}

.chapter-number-dark {
    color: rgba(250, 248, 244, 0.08);
}

/* === SECTION RULE === */
.section-rule {
    border: none;
    border-top: 1px solid #D4C5A9;
    width: 40%;
    margin: 2rem auto 3rem;
}

/* === SECTION HEADING === */
.section-heading {
    font-family: 'Nunito', sans-serif;
    font-weight: 700;
    font-size: clamp(2rem, 4vw, 3.5rem);
    letter-spacing: 0.02em;
    text-align: center;
    margin-bottom: 0.5rem;
}

/* === READING COLUMN === */
.reading-column {
    max-width: 55ch;
    margin: 0 auto;
    padding: 6rem 1.5rem;
    position: relative;
}

/* === BODY TEXT === */
.body-text {
    font-family: 'Varela Round', sans-serif;
    font-size: clamp(1rem, 1.2vw, 1.125rem);
    line-height: 1.75;
    margin-bottom: 1.5rem;
    color: #2C2520;
}

.body-text-light {
    color: #F5F0E8;
}

/* === DROP CAP === */
.has-dropcap::first-letter {
    float: left;
    font-family: 'Nunito', sans-serif;
    font-weight: 900;
    font-size: 4em;
    line-height: 0.8;
    margin-right: 0.1em;
    margin-top: 0.05em;
    color: #C49A3D;
}

/* === PULL QUOTE === */
.pull-quote {
    font-family: 'Caveat', cursive;
    font-size: clamp(1.25rem, 2vw, 1.5rem);
    color: #8B6914;
    border-left: 4px solid #C49A3D;
    padding: 1rem 1.5rem;
    margin: 2.5rem 0;
    font-style: normal;
}

/* === MARGIN NOTES === */
.margin-note {
    position: absolute;
    right: -14rem;
    width: 12rem;
    font-family: 'Caveat', cursive;
    font-size: clamp(0.875rem, 1vw, 1rem);
    color: #8B6914;
    line-height: 1.5;
}

.note-marker {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.75rem;
    font-weight: 400;
    vertical-align: super;
    color: #C49A3D;
    margin-right: 0.25rem;
}

.note-text {
    display: block;
    margin-top: 0.25rem;
}

/* === SECTION: TITLE PAGE === */
#title-page {
    position: relative;
    height: 100vh;
    background-color: #2C2520;
    display: flex;
    align-items: center;
    overflow: hidden;
}

.title-content {
    position: relative;
    z-index: 2;
    padding-left: clamp(2rem, 8vw, 10rem);
    animation: fadeInTitle 2.5s ease-out forwards;
    opacity: 0;
}

@keyframes fadeInTitle {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.hero-mark {
    font-family: 'Nunito', sans-serif;
    font-weight: 900;
    font-size: clamp(8rem, 25vw, 28rem);
    color: #FAF8F4;
    letter-spacing: -0.03em;
    line-height: 0.9;
}

.hero-subtitle {
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 300;
    font-size: clamp(1rem, 2vw, 1.5rem);
    color: #D4C5A9;
    letter-spacing: 0.5em;
    text-transform: uppercase;
    margin-top: 1rem;
}

.fullerene-container {
    position: absolute;
    right: 5%;
    top: 50%;
    transform: translateY(-50%);
    width: clamp(250px, 40vw, 500px);
    height: clamp(250px, 40vw, 500px);
    z-index: 1;
}

#fullerene {
    width: 100%;
    height: 100%;
    animation: spinFullerene 60s linear infinite;
}

@keyframes spinFullerene {
    to { transform: rotateY(360deg); }
}

.fullerene-container {
    perspective: 800px;
    transform-style: preserve-3d;
}

#fullerene {
    transform-style: preserve-3d;
}

/* Vertex pulse */
.fullerene-vertex {
    animation: vertexPulse 3s ease-in-out infinite;
}

@keyframes vertexPulse {
    0%, 100% { opacity: 0.4; }
    50% { opacity: 1; }
}

/* === SECTION: LIGHT BACKGROUND === */
.section-light {
    position: relative;
    background-color: #F5F0E8;
}

.section-dark {
    position: relative;
    background-color: #2C2520;
}

/* === SECTION: ALLOTROPE GALLERY === */
#allotrope-gallery {
    position: relative;
}

.allotrope-panel {
    min-height: 80vh;
    display: flex;
    align-items: center;
    padding: clamp(3rem, 6vw, 6rem);
    position: relative;
    overflow: hidden;
}

.allotrope-panel .allotrope-text {
    flex: 1;
    max-width: 50ch;
    padding: 2rem;
}

.allotrope-panel .allotrope-visual {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 300px;
}

.allotrope-panel.reverse {
    flex-direction: row-reverse;
}

.allotrope-name {
    font-family: 'Nunito', sans-serif;
    font-weight: 900;
    font-size: clamp(4rem, 10vw, 10rem);
    letter-spacing: -0.03em;
    line-height: 1;
    margin-bottom: 1.5rem;
}

/* Panel colors */
.panel-diamond {
    background-color: #4A3728;
}
.panel-diamond .allotrope-name { color: #D4C5A9; }

.panel-graphite {
    background-color: #F5F0E8;
}
.panel-graphite .allotrope-name { color: #4A3728; }

.panel-fullerene {
    background-color: #8B7355;
}
.panel-fullerene .allotrope-name { color: #FAF8F4; }

.panel-graphene {
    background-color: #D4C5A9;
}
.panel-graphene .allotrope-name { color: #2C2520; }

.crystal-svg {
    width: clamp(200px, 30vw, 350px);
    height: auto;
}

/* === Graphene highlight animation === */
.graphene-highlight {
    animation: sweepHighlight 4s ease-in-out infinite;
}

@keyframes sweepHighlight {
    0% { transform: translateX(-100px) translateY(-100px); }
    50% { transform: translateX(50px) translateY(50px); }
    100% { transform: translateX(-100px) translateY(-100px); }
}

/* === SECTION: THE ARCHIVE === */
#the-archive {
    position: relative;
    padding-bottom: 6rem;
}

#the-archive .reading-column {
    padding-bottom: 2rem;
}

.photo-collage {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    grid-template-rows: auto;
    gap: 1.5rem;
    max-width: 900px;
    margin: 0 auto;
    padding: 0 2rem;
}

.vintage-photo {
    transform: rotate(var(--photo-tilt, 0deg));
    transition: transform 0.6s ease, box-shadow 0.6s ease;
    cursor: default;
}

.vintage-photo:hover {
    transform: rotate(0deg) scale(1.02);
    box-shadow: 0 6px 20px rgba(44, 37, 32, 0.4);
}

.photo-surface {
    width: 100%;
    aspect-ratio: 4 / 3;
    background: linear-gradient(135deg, #D4C5A9 0%, #8B7355 50%, #4A3728 100%);
    border: 3px solid #F5F0E8;
    border-radius: 2px;
    box-shadow: 0 2px 8px rgba(44, 37, 32, 0.3);
    position: relative;
    overflow: hidden;
}

.photo-surface::before {
    content: '';
    position: absolute;
    inset: 0;
    background: repeating-conic-gradient(#8B7355 0% 25%, transparent 0% 50%) 0 0 / 3px 3px;
    opacity: 0.08;
}

.photo-portrait .photo-surface {
    aspect-ratio: 3 / 4;
}

.photo-caption {
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 300;
    font-size: 0.7rem;
    color: #8B7355;
    margin-top: 0.5rem;
    letter-spacing: 0.03em;
}

/* === SECTION: TRANSFORMATION === */
#the-transformation {
    position: relative;
    background-color: #F5F0E8;
    transition: background-color 0.05s linear;
}

#the-transformation .section-heading {
    color: inherit;
}

#the-transformation .section-rule {
    border-color: currentColor;
    opacity: 0.3;
}

#the-transformation .body-text {
    color: inherit;
}

#the-transformation .pull-quote {
    color: inherit;
    opacity: 0.85;
    border-left-color: currentColor;
}

/* === SECTION: COLOPHON === */
#colophon {
    min-height: 60vh;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

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

.element-symbol {
    width: 120px;
    height: 140px;
    border: 2px solid #D4C5A9;
    border-radius: 8px;
    margin: 0 auto 2rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.atomic-number {
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 300;
    font-size: 0.875rem;
    color: #8B7355;
    letter-spacing: 0.05em;
}

.symbol {
    font-family: 'Nunito', sans-serif;
    font-weight: 900;
    font-size: 4rem;
    color: #FAF8F4;
    line-height: 1;
}

.atomic-weight {
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 300;
    font-size: 0.875rem;
    color: #8B7355;
    letter-spacing: 0.05em;
}

.colophon-name {
    font-family: 'Varela Round', sans-serif;
    font-size: 1rem;
    color: #D4C5A9;
    letter-spacing: 0.1em;
}

/* === BLOB DIVIDERS === */
.allotrope-panel + .allotrope-panel {
    clip-path: polygon(
        0% 4%, 8% 1%, 16% 3%, 25% 0%, 33% 2%, 42% 0.5%, 50% 3%, 58% 1%, 67% 2.5%, 75% 0%, 83% 3%, 92% 1%, 100% 2.5%,
        100% 100%, 0% 100%
    );
}

/* === RESPONSIVE === */
@media (max-width: 768px) {
    .chapter-number {
        display: none;
    }

    .margin-note {
        position: static;
        width: 100%;
        background-color: #FAF8F4;
        padding: 1rem;
        border-radius: 4px;
        margin-bottom: 1.5rem;
        right: auto;
    }

    .allotrope-panel,
    .allotrope-panel.reverse {
        flex-direction: column;
        text-align: center;
        padding: 3rem 1.5rem;
        min-height: auto;
    }

    .allotrope-panel .allotrope-text {
        max-width: 100%;
    }

    .photo-collage {
        grid-template-columns: repeat(2, 1fr);
    }

    .vintage-photo {
        grid-column: auto !important;
        grid-row: auto !important;
    }

    .hero-mark {
        font-size: clamp(5rem, 20vw, 12rem);
    }

    .title-content {
        padding-left: 2rem;
    }

    .fullerene-container {
        opacity: 0.3;
        right: -10%;
    }
}

@media (min-width: 769px) and (max-width: 1200px) {
    .reading-column {
        max-width: 65ch;
    }
}

@media (min-width: 1200px) {
    .reading-column {
        max-width: 55ch;
    }
}
