:root {
    --terracotta: #C2703E;
    --fired-clay: #A85A32;
    --bg-earth: #F5EDE4;
    --surface: #E8DDD0;
    --text-umber: #2C2017;
    --text-smoke: #9B8B7A;
    --bg-deep: #1E1410;
    --ember: #E8944C;
    --shadow-deep: #6B3520;
    --font-display: 'Sora', sans-serif;
    --font-body: 'Source Serif 4', Georgia, serif;
    --font-mono: 'DM Mono', monospace;
}

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

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

body {
    background-color: var(--bg-earth);
    color: var(--text-umber);
    font-family: var(--font-body);
    min-height: 100vh;
    position: relative;
    overflow-x: hidden;
}

/* ============================================
   DOT-MATRIX TEXTURE (3% opacity background)
   ============================================ */
.dot-texture {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    z-index: 0;
    background-image: radial-gradient(circle, rgba(44, 32, 23, 0.03) 1px, transparent 1px);
    background-size: 4px 4px;
}

/* ============================================
   SECTION 1: HERO (100vh)
   ============================================ */
.section-hero {
    min-height: 100vh;
    display: flex;
    align-items: flex-start;
    position: relative;
    padding: 8vh 4rem 4rem;
    z-index: 1;
    overflow: hidden;
}

.hero-content {
    position: relative;
    z-index: 2;
    max-width: 600px;
    padding-top: 10vh;
}

/* Letter-by-letter logotype with stagger animation */
.hero-title {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: clamp(3rem, 6vw + 0.5rem, 5.5rem);
    color: var(--text-umber);
    margin-bottom: 2.5rem;
    line-height: 1.1;
    display: flex;
    gap: 0;
}

.hero-title .char {
    display: inline-block;
    opacity: 0;
    transform: translateY(20px);
    animation: charEnter 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

.hero-title .char.breathing {
    animation: charEnter 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) forwards,
               breathe 6s ease-in-out infinite;
    animation-fill-mode: forwards, none;
}

@keyframes charEnter {
    0% {
        opacity: 0;
        transform: translateY(20px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes breathe {
    0%, 100% {
        letter-spacing: 0.02em;
    }
    50% {
        letter-spacing: 0.12em;
    }
}

/* Pulse-attention glow behind hero tagline */
.pulse-attention {
    position: absolute;
    width: 160px;
    height: 160px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(232, 148, 76, 0.2) 0%, transparent 70%);
    animation: pulseGlow 3s ease-in-out infinite;
    pointer-events: none;
    z-index: -1;
}

.pulse-hero {
    left: -50px;
    top: calc(10vh + 5rem);
}

@keyframes pulseGlow {
    0%, 100% {
        transform: scale(0.8);
        opacity: 0.08;
    }
    50% {
        transform: scale(1.2);
        opacity: 0.18;
    }
}

.hero-tagline {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: clamp(1.1rem, 2vw, 1.5rem);
    color: var(--terracotta);
    margin-bottom: 1.5rem;
    letter-spacing: 0.02em;
}

.hero-body {
    font-family: var(--font-body);
    font-weight: 400;
    font-size: clamp(1rem, 1.2vw + 0.4rem, 1.25rem);
    line-height: 1.72;
    color: var(--text-umber);
    max-width: 50ch;
}

/* CSS-only 3D Terracotta Sphere */
.terracotta-sphere {
    position: absolute;
    right: 15%;
    top: 50%;
    transform: translateY(-50%);
    width: 300px;
    height: 300px;
    border-radius: 50%;
    background: radial-gradient(
        circle at 35% 35%,
        var(--ember) 0%,
        var(--terracotta) 40%,
        #8B4A28 70%,
        var(--shadow-deep) 100%
    );
    animation: shadowRotate 20s linear infinite;
    z-index: 1;
}

@keyframes shadowRotate {
    0% {
        box-shadow:
            inset -20px -20px 40px rgba(107, 53, 32, 0.5),
            inset 10px 10px 30px rgba(232, 148, 76, 0.3),
            8px 12px 40px rgba(107, 53, 32, 0.5);
    }
    25% {
        box-shadow:
            inset -25px -10px 40px rgba(107, 53, 32, 0.5),
            inset 15px 15px 30px rgba(232, 148, 76, 0.3),
            12px 8px 40px rgba(107, 53, 32, 0.5);
    }
    50% {
        box-shadow:
            inset -15px 10px 40px rgba(107, 53, 32, 0.5),
            inset 5px 20px 30px rgba(232, 148, 76, 0.3),
            8px -4px 40px rgba(107, 53, 32, 0.5);
    }
    75% {
        box-shadow:
            inset 5px -15px 40px rgba(107, 53, 32, 0.5),
            inset -5px 10px 30px rgba(232, 148, 76, 0.3),
            -4px 8px 40px rgba(107, 53, 32, 0.5);
    }
    100% {
        box-shadow:
            inset -20px -20px 40px rgba(107, 53, 32, 0.5),
            inset 10px 10px 30px rgba(232, 148, 76, 0.3),
            8px 12px 40px rgba(107, 53, 32, 0.5);
    }
}

/* Horizon bar - sweeps in from left */
.horizon-bar {
    position: absolute;
    bottom: 12vh;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(to right, var(--terracotta), transparent 80%);
    z-index: 3;
    transform: scaleX(0);
    transform-origin: left center;
    animation: horizonSweep 1.5s ease-out 1s forwards;
}

@keyframes horizonSweep {
    0% {
        transform: scaleX(0);
    }
    100% {
        transform: scaleX(1);
    }
}

/* ============================================
   SHARED TYPOGRAPHY & UI ELEMENTS
   ============================================ */
.meta-label {
    display: block;
    font-family: var(--font-mono);
    font-size: 0.85rem;
    letter-spacing: 0.04em;
    color: var(--text-smoke);
    margin-bottom: 1rem;
}

.mono-inline {
    font-family: var(--font-mono);
    font-size: 0.9em;
    color: var(--terracotta);
    letter-spacing: 0.02em;
}

.terrace-heading {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: clamp(1.5rem, 3vw + 0.5rem, 2.5rem);
    color: var(--text-umber);
    letter-spacing: 0.02em;
    margin-bottom: 1.2rem;
}

.terrace-body {
    font-family: var(--font-body);
    font-weight: 400;
    font-size: clamp(1rem, 1.2vw + 0.4rem, 1.25rem);
    line-height: 1.72;
    color: var(--text-umber);
    margin-bottom: 1.5rem;
    max-width: 65ch;
}

.terrace-body:last-child {
    margin-bottom: 0;
}

/* Circuit-trace corner marks on content blocks */
.circuit-corner {
    position: absolute;
    width: 8px;
    height: 8px;
}

.circuit-tl {
    top: 0;
    left: 0;
    border-top: 1.5px solid var(--terracotta);
    border-left: 1.5px solid var(--terracotta);
}

.circuit-br {
    bottom: 0;
    right: 0;
    border-bottom: 1.5px solid var(--terracotta);
    border-right: 1.5px solid var(--terracotta);
}

/* ============================================
   SECTION 2: CONTENT TERRACES
   ============================================ */
.section-terrace {
    display: grid;
    grid-template-columns: 55% 45%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 96px 2rem;
    gap: 2rem;
    position: relative;
    z-index: 1;
}

/* Parametric grid overlay */
.parametric-grid {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image:
        repeating-linear-gradient(0deg, transparent, transparent 47px, rgba(194, 112, 62, 0.05) 47px, rgba(194, 112, 62, 0.05) 48px),
        repeating-linear-gradient(90deg, transparent, transparent 47px, rgba(194, 112, 62, 0.05) 47px, rgba(194, 112, 62, 0.05) 48px);
    pointer-events: none;
    z-index: 0;
}

.content-terrace {
    display: flex;
    flex-direction: column;
    gap: 64px;
    position: relative;
    z-index: 1;
}

.terrace-block {
    position: relative;
    border-left: 4px solid var(--terracotta);
    padding: 2rem 2rem 2rem 2.5rem;
    background-color: rgba(232, 221, 208, 0.4);
}

.terrace-visual {
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    z-index: 1;
    perspective: 800px;
}

/* CSS 3D Cube with preserve-3d */
.cube-scene {
    perspective: 800px;
    width: 160px;
    height: 160px;
}

.css-cube {
    width: 160px;
    height: 160px;
    position: relative;
    transform-style: preserve-3d;
    animation: cubeRotate 30s linear infinite;
}

@keyframes cubeRotate {
    0% {
        transform: rotateX(15deg) rotateY(0deg);
    }
    100% {
        transform: rotateX(15deg) rotateY(360deg);
    }
}

.cube-face {
    position: absolute;
    width: 160px;
    height: 160px;
    border: 1px solid rgba(44, 32, 23, 0.2);
    backface-visibility: visible;
}

.cube-front {
    background: var(--terracotta);
    transform: translateZ(80px);
    opacity: 0.85;
}

.cube-back {
    background: var(--fired-clay);
    transform: rotateY(180deg) translateZ(80px);
    opacity: 0.85;
}

.cube-right {
    background: var(--ember);
    transform: rotateY(90deg) translateZ(80px);
    opacity: 0.75;
}

.cube-left {
    background: var(--terracotta);
    transform: rotateY(-90deg) translateZ(80px);
    opacity: 0.75;
}

.cube-top {
    background: var(--ember);
    transform: rotateX(90deg) translateZ(80px);
    opacity: 0.65;
}

.cube-bottom {
    background: var(--fired-clay);
    transform: rotateX(-90deg) translateZ(80px);
    opacity: 0.65;
}

/* ============================================
   BEZIER CURVE TRANSITIONS
   ============================================ */
.bezier-transition {
    width: 100%;
    height: 80px;
    position: relative;
    z-index: 1;
    overflow: hidden;
}

.bezier-transition svg {
    width: 100%;
    height: 100%;
    display: block;
}

/* ============================================
   SECTION 3: DEEP TERRACE
   Background shifts to Dry Plaster
   ============================================ */
.section-deep {
    max-width: 1200px;
    margin: 0 auto;
    padding: 160px 2rem 160px 6rem;
    display: grid;
    grid-template-columns: 45% 1fr;
    gap: 3rem;
    position: relative;
    z-index: 1;
    background-color: var(--surface);
    border-radius: 2px;
}

.timeline-line {
    position: absolute;
    left: calc(45% + 3rem);
    top: 160px;
    bottom: 160px;
    width: 0;
    border-left: 2px dotted rgba(194, 112, 62, 0.3);
    z-index: 0;
}

.deep-content {
    display: flex;
    flex-direction: column;
    gap: 96px;
    position: relative;
    z-index: 1;
}

.deep-block {
    position: relative;
    padding: 2rem;
}

.deep-heading {
    animation: breatheSlow 10s ease-in-out infinite;
}

@keyframes breatheSlow {
    0%, 100% {
        letter-spacing: 0.02em;
    }
    50% {
        letter-spacing: 0.08em;
    }
}

.deep-visual {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3rem;
    position: relative;
    z-index: 1;
}

.wireframe-motif {
    opacity: 0.7;
    transition: opacity 0.6s ease;
}

.wireframe-secondary {
    opacity: 0.5;
}

/* ============================================
   SECTION 4: GROUND / FOOTER
   Background transitions from Bleached Earth to Burnt Sienna Deep
   ============================================ */
.section-ground {
    background: linear-gradient(to bottom, var(--surface) 0%, var(--bg-deep) 40%);
    padding: 256px 2rem 160px;
    text-align: center;
    position: relative;
    z-index: 1;
    min-height: 50vh;
}

.ground-content {
    position: relative;
    display: inline-block;
}

.pulse-footer {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 120px;
    height: 120px;
    z-index: 0;
}

.ground-label {
    color: var(--text-smoke);
}

.ground-text {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: clamp(1.5rem, 3vw, 2.5rem);
    color: var(--bg-earth);
    letter-spacing: 0.04em;
    position: relative;
    z-index: 2;
    margin-bottom: 2rem;
}

.ground-sub {
    position: relative;
    z-index: 2;
}

.ground-mono {
    color: var(--text-smoke);
    font-size: 1rem;
}

/* ============================================
   SCROLL-TRIGGERED REVEAL ANIMATION
   ============================================ */
.fade-reveal {
    opacity: 0;
    transform: translateX(-30px);
    transition: opacity 0.8s ease-out, transform 0.8s ease-out;
}

.fade-reveal.visible {
    opacity: 1;
    transform: translateX(0);
}

/* Staggered entrance via data-delay attribute handled in JS */

/* ============================================
   REDUCED MOTION
   ============================================ */
@media (prefers-reduced-motion: reduce) {
    .fade-reveal {
        transition: none;
        opacity: 1;
        transform: none;
    }
    .hero-title .char {
        animation: none;
        opacity: 1;
        transform: none;
    }
    .css-cube {
        animation: none;
        transform: rotateX(15deg) rotateY(30deg);
    }
    .terracotta-sphere {
        animation: none;
        box-shadow:
            inset -20px -20px 40px rgba(107, 53, 32, 0.5),
            inset 10px 10px 30px rgba(232, 148, 76, 0.3),
            8px 12px 40px rgba(107, 53, 32, 0.5);
    }
    .pulse-attention {
        animation: none;
        opacity: 0.12;
    }
    .horizon-bar {
        animation: none;
        transform: scaleX(1);
    }
    .deep-heading {
        animation: none;
    }
}

/* ============================================
   RESPONSIVE: TABLET
   ============================================ */
@media (max-width: 960px) {
    .section-hero {
        padding: 6vh 2rem 4rem;
    }

    .terracotta-sphere {
        width: 220px;
        height: 220px;
        right: 5%;
    }

    .section-terrace {
        grid-template-columns: 1fr;
        padding: 64px 2rem;
    }

    .terrace-visual {
        order: -1;
        padding: 2rem 0;
    }

    .section-deep {
        grid-template-columns: 1fr;
        padding: 80px 2rem;
    }

    .deep-visual {
        flex-direction: row;
        justify-content: center;
    }

    .timeline-line {
        display: none;
    }
}

/* ============================================
   RESPONSIVE: MOBILE
   ============================================ */
@media (max-width: 600px) {
    .section-hero {
        padding: 4vh 1.5rem 3rem;
    }

    .hero-content {
        padding-top: 6vh;
    }

    .terracotta-sphere {
        width: 150px;
        height: 150px;
        right: -20px;
        opacity: 0.6;
    }

    .content-terrace {
        gap: 40px;
    }

    .terrace-block {
        padding: 1.5rem 1.5rem 1.5rem 2rem;
    }

    .terrace-body {
        font-size: 1rem;
    }

    .section-deep {
        padding: 60px 1.5rem;
    }

    .deep-content {
        gap: 60px;
    }

    .deep-visual {
        display: none;
    }

    .section-ground {
        padding: 160px 1.5rem 100px;
    }

    .cube-scene,
    .css-cube {
        width: 120px;
        height: 120px;
    }

    .cube-face {
        width: 120px;
        height: 120px;
    }

    .cube-front { transform: translateZ(60px); }
    .cube-back { transform: rotateY(180deg) translateZ(60px); }
    .cube-right { transform: rotateY(90deg) translateZ(60px); }
    .cube-left { transform: rotateY(-90deg) translateZ(60px); }
    .cube-top { transform: rotateX(90deg) translateZ(60px); }
    .cube-bottom { transform: rotateX(-90deg) translateZ(60px); }

    .bezier-transition {
        height: 50px;
    }
}
