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

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

body {
    background-color: #f4f0eb;
    color: #4a4a5e;
    font-family: 'Source Sans 3', 'Source Sans Pro', sans-serif;
    font-weight: 400;
    line-height: 1.72;
    letter-spacing: 0.005em;
    overflow-x: hidden;
    perspective: 800px;
    perspective-origin: 50% 50%;
}

.svg-filters {
    position: absolute;
    width: 0;
    height: 0;
    overflow: hidden;
}

/* ===== BACKGROUND LAYER (z: -200px) ===== */
.background-layer {
    position: fixed;
    top: -5%;
    left: -5%;
    width: 110%;
    height: 110%;
    background-color: #f4f0eb;
    filter: url(#marble-vein-bg) blur(2px);
    z-index: -1;
    transform: translateZ(-200px) scale(1.1);
    pointer-events: none;
}

/* ===== FOREGROUND LAYER (z: 100px) - Terminal Nav ===== */
.foreground-layer {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
    padding: 1rem 2rem;
    background: rgba(44, 44, 58, 0.92);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transform: translateZ(100px);
    opacity: 0;
    transition: opacity 0.4s ease;
    pointer-events: none;
}

.foreground-layer.visible {
    opacity: 1;
    pointer-events: auto;
}

.terminal-breadcrumb {
    font-family: 'JetBrains Mono', monospace;
    font-size: clamp(0.75rem, 1.2vw, 0.9rem);
    color: #6b8f71;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.25rem;
}

.prompt-symbol {
    color: #5a8a7a;
    font-weight: 500;
}

.prompt-path {
    color: #b8a88a;
}

.prompt-dollar {
    color: #6b8f71;
}

.nav-dir {
    color: #6b8f71;
    text-decoration: none;
    position: relative;
    padding: 0.1rem 0.3rem;
    transition: color 0.2s ease;
}

.nav-dir::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 0;
    width: 0;
    height: 1.5px;
    background: #b8a88a;
    transition: width 0.3s ease;
}

.nav-dir:hover {
    color: #c9a89a;
}

.nav-dir:hover::after {
    width: 100%;
}

.terminal-cursor {
    display: inline-block;
    width: 2px;
    height: 1.1em;
    background: #5a8a7a;
    animation: chisel-blink 1.2s step-end infinite;
    margin-left: 2px;
}

/* ===== CONTENT LAYER ===== */
.content-layer {
    position: relative;
    z-index: 1;
}

/* ===== LAYER 1: HERO ===== */
.layer-hero {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.marble-surface {
    width: 100%;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background-color: #f4f0eb;
    filter: url(#marble-vein-1);
    position: relative;
}

.hero-content {
    text-align: center;
    padding: 2rem;
}

.hero-title {
    font-family: 'Libre Baskerville', serif;
    font-weight: 700;
    font-size: clamp(3rem, 8vw, 6rem);
    color: #1a1a28;
    letter-spacing: 0.02em;
    line-height: 1.1;
    margin-bottom: 2rem;
}

.hero-terminal {
    font-family: 'JetBrains Mono', monospace;
    font-size: clamp(0.85rem, 1.4vw, 1rem);
    color: #6b8f71;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0;
}

.terminal-prompt {
    color: #5a8a7a;
}

.typewriter-text {
    display: inline;
}

.chisel-cursor {
    display: inline-block;
    width: 2px;
    height: 1.2em;
    background: #5a8a7a;
    animation: chisel-blink 1.2s step-end infinite;
    vertical-align: middle;
    margin-left: 1px;
}

@keyframes chisel-blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}

.scroll-chevron {
    position: absolute;
    bottom: 3rem;
    left: 50%;
    transform: translateX(-50%);
    animation: chevron-pulse 2s ease-in-out infinite;
    display: block;
    text-decoration: none;
}

@keyframes chevron-pulse {
    0%, 100% { opacity: 0.6; }
    50% { opacity: 1; }
}

/* ===== LAYER TRANSITIONS ===== */
.layer-transition-divider {
    padding: 1rem 0;
}

.vein-divider {
    width: 100%;
    height: 20px;
    display: block;
}

/* ===== STONE TABLETS ===== */
.stone-tablet {
    background-color: #f4f0eb;
    border-radius: 6px;
    padding: clamp(2rem, 4vw, 3.5rem);
    box-shadow:
        0 2px 8px rgba(44, 44, 58, 0.06),
        0 8px 24px rgba(44, 44, 58, 0.04),
        inset 0 1px 0 rgba(255, 255, 255, 0.6);
    border: 1px solid rgba(184, 168, 138, 0.2);
    position: relative;
    overflow: hidden;
}

.stone-tablet::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #f4f0eb;
    filter: url(#marble-vein-1);
    opacity: 0.5;
    pointer-events: none;
    z-index: 0;
}

.stone-tablet > * {
    position: relative;
    z-index: 1;
}

.tablet-deep {
    background-color: #e8e0d6;
}

.tablet-deep::before {
    background-color: #e8e0d6;
    filter: url(#marble-vein-3);
    opacity: 0.7;
}

/* Tablet sizes */
.tablet-full {
    width: 85%;
    max-width: 1100px;
    margin: 0 auto;
}

.tablet-pair {
    display: flex;
    gap: 2rem;
    width: 85%;
    max-width: 1100px;
    margin: 0 auto;
    align-items: flex-start;
}

.tablet-half {
    flex: 1;
    min-width: 0;
}

/* ===== TYPOGRAPHY ===== */
.tablet-heading {
    font-family: 'Libre Baskerville', serif;
    font-weight: 700;
    font-size: clamp(1.6rem, 3.5vw, 2.4rem);
    color: #1a1a28;
    letter-spacing: 0.02em;
    line-height: 1.3;
    margin-bottom: 1.5rem;
    position: relative;
}

.heading-underline {
    display: block;
    width: 100%;
    height: 4px;
    margin-top: 0.5rem;
}

.tablet-body {
    font-family: 'Source Sans 3', sans-serif;
    font-weight: 400;
    font-size: clamp(1rem, 1.8vw, 1.15rem);
    color: #4a4a5e;
    line-height: 1.72;
    letter-spacing: 0.005em;
    margin-bottom: 1.25rem;
}

.heading-deep {
    color: #2c2c3a;
}

.body-deep {
    color: #4a4a5e;
}

/* ===== TERMINAL CONTAINERS ===== */
.terminal-container {
    background: #2c2c3a;
    border-radius: 6px;
    overflow: hidden;
    font-family: 'JetBrains Mono', monospace;
    font-size: clamp(0.8rem, 1.2vw, 0.95rem);
}

.terminal-header {
    background: rgba(90, 138, 122, 0.15);
    padding: 0.6rem 1rem;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.terminal-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #5a8a7a;
    opacity: 0.5;
}

.terminal-dot:first-child {
    background: #c9a89a;
}

.terminal-dot:nth-child(2) {
    background: #b8a88a;
}

.terminal-title {
    font-size: 0.75rem;
    color: #8c7b6b;
    margin-left: auto;
    font-family: 'JetBrains Mono', monospace;
}

.terminal-body {
    padding: 1rem 1.2rem;
    line-height: 1.6;
}

.terminal-line {
    white-space: pre;
    min-height: 1.4em;
}

.terminal-line-empty {
    height: 0.8em;
}

.t-prompt {
    color: #5a8a7a;
}

.t-cmd {
    color: #6b8f71;
}

.t-perm {
    color: #8c7b6b;
    opacity: 0.6;
}

.t-dir {
    color: #6b8f71;
}

.t-file {
    color: #c9a89a;
}

.t-output {
    color: #b8a88a;
    opacity: 0.85;
}

.t-heading {
    color: #5a8a7a;
    font-weight: 500;
}

.t-table {
    color: #6b8f71;
    opacity: 0.8;
}

.dir-link {
    text-decoration: none;
    position: relative;
}

.dir-link::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 0;
    width: 0;
    height: 1px;
    background: #b8a88a;
    transition: width 0.3s ease;
}

.dir-link:hover {
    color: #c9a89a;
}

.dir-link:hover::after {
    width: 100%;
}

.terminal-deep {
    box-shadow: 0 20px 60px rgba(42, 42, 58, 0.3);
    margin: 2rem 0;
}

/* ===== BLOCKQUOTE ===== */
.marble-blockquote {
    border-left: 3px solid #b8a88a;
    padding: 1.5rem 2rem;
    margin: 2rem 0;
    position: relative;
}

.blockquote-leaf {
    position: absolute;
    top: -4px;
    left: -10px;
}

.marble-blockquote p {
    font-family: 'Libre Baskerville', serif;
    font-style: italic;
    font-size: clamp(0.95rem, 1.6vw, 1.1rem);
    color: #4a4a5e;
    line-height: 1.72;
}

/* ===== CROSS SECTION ===== */
.cross-section-container {
    margin-bottom: 2rem;
    border-radius: 4px;
    overflow: hidden;
}

.cross-section-svg {
    width: 100%;
    height: auto;
    display: block;
}

/* ===== ROOT NETWORKS ===== */
.root-network {
    width: 85%;
    max-width: 1100px;
    margin: 0 auto;
    height: 80px;
    overflow: hidden;
}

.root-svg {
    width: 100%;
    height: 100%;
}

.root-network-inline {
    height: 40px;
    margin-bottom: 1.5rem;
    overflow: hidden;
}

.root-svg-inline {
    width: 100%;
    height: 100%;
}

/* ===== DRAW LINE ANIMATION ===== */
.draw-line {
    stroke-dasharray: 1000;
    stroke-dashoffset: 1000;
    transition: stroke-dashoffset 0.8s cubic-bezier(0.22, 1, 0.36, 1);
}

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

.root-line {
    stroke-dasharray: 500;
    stroke-dashoffset: 500;
    transition: stroke-dashoffset 0.8s cubic-bezier(0.22, 1, 0.36, 1);
}

.root-line.drawn {
    stroke-dashoffset: 0;
}

/* ===== SLAB ANIMATION ===== */
.animate-slab {
    opacity: 0;
    transform: translateY(40px);
    transition: opacity 0.6s cubic-bezier(0.22, 1, 0.36, 1),
                transform 0.6s cubic-bezier(0.22, 1, 0.36, 1);
}

.animate-slab.visible {
    opacity: 1;
    transform: translateY(0);
}

/* ===== SECTIONS SPACING ===== */
.layer {
    padding: 4rem 0;
}

.layer-provenance {
    padding-top: 2rem;
}

/* ===== FOOTER ===== */
.layer-footer {
    padding: 4rem 0;
    text-align: center;
}

.footer-content {
    width: 85%;
    max-width: 600px;
    margin: 0 auto;
}

.footer-terminal {
    font-family: 'JetBrains Mono', monospace;
    font-size: clamp(0.8rem, 1.2vw, 0.9rem);
    margin-bottom: 1rem;
}

.footer-text {
    font-family: 'Source Sans 3', sans-serif;
    font-weight: 600;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: #8c7b6b;
    margin-bottom: 1rem;
}

.footer-vein {
    width: 120px;
    height: 4px;
    display: inline-block;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
    .tablet-pair {
        flex-direction: column;
        width: 92%;
    }

    .tablet-full {
        width: 92%;
    }

    .root-network {
        width: 92%;
    }

    .foreground-layer {
        padding: 0.75rem 1rem;
    }

    .terminal-breadcrumb {
        font-size: 0.7rem;
    }

    .stone-tablet {
        padding: 1.5rem;
    }
}

@media (max-width: 480px) {
    .hero-title {
        font-size: 2.4rem;
    }

    .tablet-pair {
        width: 95%;
    }

    .tablet-full {
        width: 95%;
    }
}

/* ===== REDUCED MOTION ===== */
@media (prefers-reduced-motion: reduce) {
    .animate-slab {
        opacity: 1;
        transform: none;
        transition: none;
    }

    .draw-line,
    .root-line {
        stroke-dashoffset: 0;
        transition: none;
    }

    .chisel-cursor,
    .terminal-cursor {
        animation: none;
        opacity: 1;
    }

    .scroll-chevron {
        animation: none;
        opacity: 0.8;
    }
}
