/* === Base Reset & Global === */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: 'Lora', serif;
    font-weight: 400;
    font-size: clamp(0.95rem, 1.2vw, 1.1rem);
    line-height: 1.65;
    color: #4a4553;
    background-color: #f2ece3;
}

/* === Typography === */
h1, h2, h3 {
    font-family: 'Playfair Display', serif;
    letter-spacing: -0.02em;
    color: #2d2a32;
}

h2 {
    font-weight: 700;
    font-size: clamp(1.5rem, 3vw, 2.5rem);
    margin-bottom: 0.6em;
}

p {
    max-width: 38em;
}

p + p {
    margin-top: 0.8em;
}

.body-secondary {
    font-weight: 600;
    font-style: italic;
    opacity: 0.85;
}

/* === Hero Section === */
.hero {
    position: relative;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: flex-start;
    padding: 4rem 6vw;
    background-color: #f2ece3;
    overflow: hidden;
}

.hero-bg-shapes {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    pointer-events: none;
}

.hero-leaf {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 200px;
    height: 300px;
    z-index: 1;
    pointer-events: none;
}

.leaf-vine {
    stroke-dasharray: 600;
    stroke-dashoffset: 600;
    animation: leafGrow 3s ease-out 0.5s forwards;
}

@keyframes leafGrow {
    to { stroke-dashoffset: 0; }
}

.hero-title {
    font-weight: 900;
    font-size: clamp(3rem, 8vw, 7rem);
    color: #2d2a32;
    position: relative;
    z-index: 2;
    line-height: 1.05;
}

.hero-subtitle {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.9rem;
    letter-spacing: 0.03em;
    color: #4a4553;
    margin-top: 1.5rem;
    position: relative;
    z-index: 2;
}

/* Shape animations */
.shape-rotate {
    animation: shapeRotate 20s linear infinite;
    transform-origin: center;
}

.shape-drift {
    animation: shapeDrift 20s ease-in-out infinite;
}

@keyframes shapeRotate {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

@keyframes shapeDrift {
    0%, 100% { transform: translate(0, 0); }
    25% { transform: translate(10px, -8px); }
    50% { transform: translate(-5px, 12px); }
    75% { transform: translate(8px, 5px); }
}

/* === Zigzag Dividers === */
.zigzag-divider {
    width: 100%;
    overflow: hidden;
    line-height: 0;
    padding: 1rem 0;
}

.zigzag-divider svg {
    width: 200%;
    height: 24px;
    display: block;
}

.zigzag-fill {
    animation: zigzagCrawl 26.67s linear infinite;
}

@keyframes zigzagCrawl {
    from { transform: translateX(0); }
    to { transform: translateX(-800px); }
}

/* === Masonry Zone === */
.masonry-zone {
    position: relative;
    padding: 4rem 6vw 4rem 4vw;
}

.masonry-grid {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    grid-auto-rows: minmax(120px, auto);
    gap: 20px;
    max-width: 1400px;
}

/* Tile base */
.tile {
    padding: 24px;
    border: 3px solid #2d2a32;
    border-radius: 2px;
    position: relative;
    overflow: hidden;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1),
                box-shadow 0.3s cubic-bezier(0.4, 0, 0.2, 1),
                border-color 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    /* Hidden for scroll reveal */
    opacity: 0;
    transform: translateY(20px);
}

.tile.visible {
    opacity: 1;
    transform: translateY(0);
    transition: opacity 0.5s ease-out, transform 0.5s ease-out,
                box-shadow 0.3s cubic-bezier(0.4, 0, 0.2, 1),
                border-color 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.tile:hover {
    transform: translateY(-6px);
    box-shadow: 0 8px 24px rgba(45, 42, 50, 0.12);
    border-color: #c9a84c;
}

.tile.visible:hover {
    transform: translateY(-6px);
}

/* Tile sizes */
.tile-wide {
    grid-column: span 6;
    grid-row: span 2;
}

.tile-tall {
    grid-column: span 4;
    grid-row: span 3;
}

.tile-small {
    grid-column: span 3;
    grid-row: span 2;
}

.tile-medium {
    grid-column: span 5;
    grid-row: span 2;
}

/* Tile colors */
.tile-terracotta {
    background-color: #c4826e;
    border-color: #3d5a4a;
    color: #f2ece3;
}
.tile-terracotta h2 { color: #f2ece3; }
.tile-terracotta p { color: #f2ece3; }

.tile-cobalt {
    background-color: #7b8fb5;
    border-color: #2d2a32;
    color: #f2ece3;
}
.tile-cobalt h2 { color: #f2ece3; }
.tile-cobalt p { color: #d8d2c8; }

.tile-mustard {
    background-color: #c9a84c;
    border-color: #2d2a32;
    color: #2d2a32;
}

.tile-sage {
    background-color: #b5c4b1;
    border-color: #3d5a4a;
    color: #2d2a32;
}

.tile-rose {
    background-color: #c89b9b;
    border-color: #2d2a32;
    color: #2d2a32;
}

.tile-parchment {
    background-color: #f2ece3;
    border-color: #c4826e;
    color: #2d2a32;
}

.tile-terracotta-alt {
    background-color: #c4826e;
    border-color: #c9a84c;
    color: #f2ece3;
}
.tile-terracotta-alt h2 { color: #f2ece3; }
.tile-terracotta-alt p { color: #f2ece3; }

.tile-mustard-alt {
    background-color: #c9a84c;
    border-color: #3d5a4a;
    color: #2d2a32;
}

.tile-cobalt-alt {
    background-color: #7b8fb5;
    border-color: #c9a84c;
    color: #f2ece3;
}
.tile-cobalt-alt h2 { color: #f2ece3; }
.tile-cobalt-alt p { color: #d8d2c8; }

.tile-sage-alt {
    background-color: #b5c4b1;
    border-color: #c4826e;
    color: #2d2a32;
}

/* Tile decorations */
.tile-deco {
    position: absolute;
    top: 0;
    right: 0;
    width: 80px;
    height: 80px;
    pointer-events: none;
}

.tile-leaf {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 60px;
    height: 80px;
    pointer-events: none;
}

.tile-leaf-right {
    left: auto;
    right: 8px;
    width: 50px;
    height: 90px;
}

/* Blueprint grid underlay */
.blueprint-grid {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image:
        linear-gradient(rgba(45, 42, 50, 0.05) 1px, transparent 1px),
        linear-gradient(90deg, rgba(45, 42, 50, 0.05) 1px, transparent 1px);
    background-size: 20px 20px;
    pointer-events: none;
}

/* Compile dots */
.compile-dot {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background-color: #c4826e;
    animation: compilePulse 2s cubic-bezier(0.4, 0, 0.2, 1) infinite;
    transition: animation-duration 0.3s;
}

.tile-cobalt .compile-dot,
.tile-cobalt-alt .compile-dot {
    background-color: #c9a84c;
}

.tile-terracotta .compile-dot,
.tile-terracotta-alt .compile-dot {
    background-color: #7b8fb5;
}

.tile:hover .compile-dot {
    animation-duration: 1s;
}

@keyframes compilePulse {
    0%, 100% { transform: scale(1); opacity: 0.8; }
    50% { transform: scale(1.3); opacity: 1; }
}

/* === Floating Annotations === */
.annotation {
    position: absolute;
    background-color: #2d2a32;
    color: #d8d2c8;
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.75rem;
    letter-spacing: 0.03em;
    padding: 8px 14px;
    white-space: nowrap;
    z-index: 5;
    pointer-events: none;
}

.annotation-1 {
    top: 8%;
    right: 2vw;
    transform: rotate(-3deg);
}

.annotation-2 {
    top: 35%;
    right: 1vw;
    transform: rotate(2deg);
    background-color: #3d5a4a;
    color: #f2ece3;
}

.annotation-3 {
    top: 58%;
    right: 3vw;
    transform: rotate(-4deg);
    background-color: #c4826e;
    color: #f2ece3;
}

.annotation-4 {
    top: 80%;
    right: 1.5vw;
    transform: rotate(3deg);
    background-color: #c9a84c;
    color: #2d2a32;
}

/* === Bottom Zone === */
.bottom-zone {
    position: relative;
    padding: 6rem 6vw 4rem;
    min-height: 50vh;
    overflow: hidden;
}

.bottom-vine {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 300px;
    pointer-events: none;
    z-index: 0;
}

.bottom-content {
    position: relative;
    z-index: 1;
    max-width: 700px;
}

.bottom-content h2 {
    font-weight: 900;
    font-size: clamp(2rem, 4vw, 3.5rem);
    margin-bottom: 1rem;
    color: #2d2a32;
}

.bottom-content p {
    color: #4a4553;
    margin-bottom: 1rem;
}

.bottom-tagline {
    font-family: 'Playfair Display', serif;
    font-weight: 700;
    font-size: clamp(1.2rem, 2vw, 1.6rem);
    color: #c4826e;
    margin-top: 2rem;
    font-style: italic;
}

/* === Squiggle Trail === */
#squiggle-trail {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 9999;
    overflow: hidden;
}

.squiggle {
    position: absolute;
    pointer-events: none;
    opacity: 0.4;
    animation: squiggleFade 800ms ease-out forwards;
}

@keyframes squiggleFade {
    from { opacity: 0.4; transform: scale(1); }
    to { opacity: 0; transform: scale(0); }
}

/* === Responsive === */
@media (max-width: 900px) {
    .masonry-grid {
        grid-template-columns: repeat(6, 1fr);
    }

    .tile-wide { grid-column: span 6; }
    .tile-tall { grid-column: span 3; grid-row: span 2; }
    .tile-small { grid-column: span 3; }
    .tile-medium { grid-column: span 3; }

    .annotation { display: none; }

    .hero { padding: 3rem 4vw; }
    .masonry-zone { padding: 2rem 4vw; }
}

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

    .tile-wide,
    .tile-tall,
    .tile-small,
    .tile-medium {
        grid-column: span 1;
        grid-row: span 1;
    }

    .hero-title {
        font-size: clamp(2.5rem, 10vw, 4rem);
    }
}
