/* thefirst.quest - Brutalist concrete monument reclaimed by nature */

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

:root {
    --foundation: #1A1A1A;
    --aggregate: #3A3A3A;
    --weathered: #6A6A6A;
    --lichen: #8A8A8A;
    --chalk: #B0B0B0;
    --formwork: #D4D4D4;
    --plaster: #E8E8E8;
    --raw-canvas: #F5F5F0;
    --shadow: #0A0A0A;
    --structure: #2A2A2A;
    --body-text: #4A4A4A;
    --meta: #7A7A7A;
    --skeleton-dark: #E0E0E0;
    --white: #FFFFFF;
}

html {
    scroll-snap-type: y proximity;
    scroll-behavior: smooth;
}

body {
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 400;
    font-size: clamp(0.875rem, 1.5vw, 1.0625rem);
    line-height: 1.75;
    color: var(--weathered);
    background-color: var(--raw-canvas);
    overflow-x: hidden;
}

/* === Navigation === */
#main-nav {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    background-color: var(--raw-canvas);
    z-index: 100;
    border-bottom: 1px solid var(--formwork);
}

.nav-domain {
    font-family: 'Nunito', sans-serif;
    font-weight: 800;
    font-size: 1rem;
    color: var(--foundation);
    text-transform: lowercase;
    letter-spacing: -0.02em;
}

.nav-hamburger {
    display: flex;
    flex-direction: column;
    gap: 5px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
}

.nav-hamburger span {
    display: block;
    width: 24px;
    height: 2px;
    background-color: var(--foundation);
    transition: transform 0.3s ease, opacity 0.3s ease;
}

.nav-menu {
    position: absolute;
    top: 48px;
    right: 0;
    background-color: var(--raw-canvas);
    border: 1px solid var(--formwork);
    border-top: none;
    display: none;
    flex-direction: column;
    padding: 12px 24px;
    gap: 8px;
}

.nav-menu.open {
    display: flex;
}

.nav-item {
    position: relative;
    cursor: pointer;
    padding: 4px 0;
}

.nav-skeleton {
    width: 100px;
    height: 12px;
    border-radius: 4px;
}

.nav-item:hover .nav-skeleton {
    display: none;
}

.nav-item:hover::after {
    content: attr(data-label);
    font-family: 'Nunito', sans-serif;
    font-weight: 300;
    font-size: 0.75rem;
    color: var(--weathered);
    animation: fadeResolve 0.3s ease forwards;
}

@keyframes fadeResolve {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* === Ghost Grid Lines === */
.ghost-grid {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    z-index: 1;
    opacity: 0.4;
}

/* === Skeleton Loading === */
.skeleton-bar {
    background: linear-gradient(90deg, var(--plaster) 25%, var(--raw-canvas) 50%, var(--plaster) 75%);
    background-size: 200% 100%;
    animation: shimmer 2s infinite linear;
    border-radius: 4px;
}

.skeleton-still {
    animation: none;
    background: var(--plaster);
}

@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.skeleton-zone {
    max-width: 800px;
    margin: 40px auto;
    padding: 24px 32px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    position: relative;
}

.skeleton-zone:hover .skeleton-bar {
    animation-duration: 0.8s;
}

.skeleton-tooltip {
    position: absolute;
    bottom: -8px;
    left: 50%;
    transform: translateX(-50%);
    font-family: 'Nunito', sans-serif;
    font-weight: 300;
    font-size: 0.75rem;
    color: var(--lichen);
    opacity: 0;
    transition: opacity 0.3s ease;
    white-space: nowrap;
}

.skeleton-zone:hover .skeleton-tooltip {
    opacity: 1;
}

.skeleton-wide { width: 80%; height: 16px; }
.skeleton-medium { width: 55%; height: 14px; }
.skeleton-narrow { width: 35%; height: 12px; }

/* === Sections === */
.section {
    position: relative;
    scroll-snap-align: start;
}

/* === Section 1: The Blueprint === */
.section-blueprint {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    padding-top: 48px;
}

.blueprint-grid {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image:
        linear-gradient(var(--aggregate) 1px, transparent 1px),
        linear-gradient(90deg, var(--aggregate) 1px, transparent 1px);
    background-size: 120px 120px;
    opacity: 0.15;
    pointer-events: none;
}

.blueprint-content {
    text-align: center;
    z-index: 10;
    position: relative;
}

.domain-title {
    font-family: 'Nunito', sans-serif;
    font-weight: 800;
    font-size: clamp(2rem, 5vw, 4.5rem);
    color: var(--foundation);
    text-transform: lowercase;
    letter-spacing: -0.02em;
    opacity: 0;
    animation: fadeIn 1s 0.5s ease forwards;
}

.tagline-skeleton {
    margin: 20px auto 0;
    width: 60%;
    max-width: 400px;
}

.tagline-bar {
    width: 100%;
    height: 16px;
}

.tagline {
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 400;
    font-size: clamp(0.875rem, 1.5vw, 1.0625rem);
    color: var(--weathered);
    margin-top: 16px;
    opacity: 0;
    animation: fadeIn 0.8s 2s ease forwards;
}

.tagline-skeleton {
    opacity: 1;
    animation: fadeOut 0.5s 1.8s ease forwards;
}

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

@keyframes fadeOut {
    from { opacity: 1; }
    to { opacity: 0; height: 0; margin: 0; overflow: hidden; }
}

/* Fern intro */
.fern-intro {
    position: absolute;
    bottom: 40px;
    right: 60px;
    width: 120px;
    height: 160px;
    z-index: 10;
}

.fern-path {
    stroke-dasharray: 500;
    stroke-dashoffset: 500;
}

.fern-intro .fern-path {
    animation: unfurlFern 1.2s 1.5s ease forwards;
}

.fern-leaf {
    stroke-dasharray: 60;
    stroke-dashoffset: 60;
}

.fern-intro .fern-leaf {
    animation: unfurlFern 0.6s 2.2s ease forwards;
}

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

/* === Section 2: The Pour === */
.section-pour {
    padding: 80px 24px;
    position: relative;
}

/* === Panels (concrete slabs) === */
.panel {
    max-width: 800px;
    margin: 60px auto;
    background-color: var(--raw-canvas);
    border: 2px solid var(--foundation);
    padding: 0;
    position: relative;
    box-shadow: 8px 8px 0 rgba(10, 10, 10, 0.2);
    filter: url(#noise);
    opacity: 0;
    transform: translateY(40px);
    transition: opacity 0.6s cubic-bezier(0.34, 1.56, 0.64, 1), transform 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

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

.panel-1 { margin-left: calc(50% - 404px); }
.panel-2 { margin-left: calc(50% - 396px); }
.panel-3 { margin-left: calc(50% - 400px); }

@media (max-width: 900px) {
    .panel-1, .panel-2, .panel-3 { margin-left: auto; margin-right: auto; }
}

.panel-inner {
    padding: 40px 48px;
}

.step-number {
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 600;
    font-size: 0.9375rem;
    color: var(--foundation);
    background-color: var(--plaster);
    padding: 2px 6px;
    display: inline-block;
    margin-bottom: 16px;
}

.panel-title {
    font-family: 'Nunito', sans-serif;
    font-weight: 800;
    font-size: clamp(1.5rem, 3vw, 2.5rem);
    color: var(--foundation);
    text-transform: lowercase;
    letter-spacing: -0.02em;
    margin-bottom: 20px;
}

.panel-text {
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 400;
    font-size: clamp(0.875rem, 1.5vw, 1.0625rem);
    line-height: 1.75;
    color: var(--weathered);
    margin-bottom: 24px;
}

.code-block {
    background-color: var(--plaster);
    padding: 16px 20px;
    border-left: 3px solid var(--aggregate);
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 400;
    font-size: 0.875rem;
    line-height: 1.8;
    color: var(--foundation);
}

.code-block code {
    font-family: inherit;
}

/* === Moss Patches === */
.moss-patch {
    position: absolute;
    pointer-events: none;
}

.moss-tl { top: -8px; left: -8px; width: 40px; height: 40px; }
.moss-tr { top: -8px; right: -8px; width: 40px; height: 40px; }
.moss-br { bottom: -8px; right: -8px; width: 40px; height: 40px; }
.moss-bl { bottom: -8px; left: -8px; width: 40px; height: 40px; }
.moss-skeleton { position: absolute; top: -10px; right: 20px; width: 40px; height: 40px; }

/* === Cracks === */
.crack {
    position: absolute;
    background-color: var(--chalk);
    pointer-events: none;
}

.crack-1 {
    width: 1px;
    height: 60px;
    top: 30%;
    left: 25%;
    transform: rotate(12deg);
}

.crack-2 {
    width: 1px;
    height: 40px;
    top: 55%;
    right: 20%;
    transform: rotate(-8deg);
}

.crack-3 {
    width: 1px;
    height: 80px;
    top: 20%;
    left: 40%;
    transform: rotate(5deg);
}

.crack-4 {
    width: 1px;
    height: 100px;
    top: 10%;
    left: 30%;
    transform: rotate(15deg);
}

.crack-5 {
    width: 1px;
    height: 70px;
    top: 40%;
    right: 25%;
    transform: rotate(-12deg);
}

.crack-6 {
    width: 1px;
    height: 50px;
    bottom: 20%;
    left: 55%;
    transform: rotate(8deg);
}

/* === Plant Stems === */
.plant-stem {
    position: absolute;
    width: 30px;
    height: 60px;
    pointer-events: none;
}

.stem-1 {
    bottom: -10px;
    left: 26%;
}

/* === Fern Divider === */
.fern-divider {
    text-align: center;
    padding: 40px 0;
}

.fern-divider-svg {
    width: 200px;
    height: 60px;
}

/* === Fern Edge (growth section) === */
.fern-edge {
    position: absolute;
    bottom: -20px;
    left: -20px;
    width: 80px;
    height: 120px;
    z-index: 5;
}

/* === Section 3: Growth === */
.section-growth {
    padding: 80px 24px;
    position: relative;
}

.section-growth .panel {
    overflow: visible;
}

.section-growth .moss-patch {
    width: 50px;
    height: 50px;
}

.section-growth .moss-tl { top: -12px; left: -12px; }
.section-growth .moss-tr { top: -12px; right: -12px; }
.section-growth .moss-br { bottom: -12px; right: -12px; }
.section-growth .moss-bl { bottom: -12px; left: -12px; }

.skeleton-overgrown {
    position: relative;
}

/* === Section 4: The Ruin === */
.section-ruin {
    padding: 80px 24px 160px;
    position: relative;
    min-height: 100vh;
}

.fern-overlay {
    position: absolute;
    pointer-events: none;
    z-index: 5;
    opacity: 0.7;
}

.fern-overlay-1 {
    top: 0;
    left: 5%;
    width: 200px;
    height: 300px;
}

.fern-overlay-2 {
    top: 10%;
    right: 8%;
    width: 180px;
    height: 280px;
    transform: scaleX(-1);
}

.panel-ruin {
    position: relative;
    z-index: 10;
    overflow: visible;
}

.moss-heavy-1 { top: -15px; left: -15px; width: 80px; height: 80px; }
.moss-heavy-2 { bottom: -15px; right: -15px; width: 80px; height: 80px; }
.moss-heavy-3 { bottom: -10px; left: 30%; width: 80px; height: 80px; }

.skeleton-abandoned {
    opacity: 0.5;
}

/* === Final Message === */
.final-message {
    text-align: center;
    padding: 120px 24px 80px;
    position: relative;
    z-index: 10;
}

.final-text {
    font-family: 'Nunito', sans-serif;
    font-weight: 300;
    font-size: clamp(1.25rem, 3vw, 2rem);
    color: var(--lichen);
    opacity: 0;
    transition: opacity 4s ease;
}

.final-text.visible {
    opacity: 1;
}

.final-moss {
    text-align: center;
    padding-bottom: 80px;
}

.final-moss svg {
    width: 100px;
    height: 60px;
}

/* === Fern animations for scroll-triggered elements === */
.fern-fiddlehead:not(.fern-intro) .fern-path {
    stroke-dasharray: 500;
    stroke-dashoffset: 500;
    transition: stroke-dashoffset 1.2s ease;
}

.fern-fiddlehead:not(.fern-intro).animate .fern-path {
    stroke-dashoffset: 0;
}

.fern-fiddlehead:not(.fern-intro) .fern-leaf {
    stroke-dasharray: 60;
    stroke-dashoffset: 60;
    transition: stroke-dashoffset 0.6s 0.8s ease;
}

.fern-fiddlehead:not(.fern-intro).animate .fern-leaf {
    stroke-dashoffset: 0;
}

/* === Reduced Motion === */
@media (prefers-reduced-motion: reduce) {
    .skeleton-bar {
        animation: none;
        background: var(--plaster);
    }
    .domain-title, .tagline {
        animation: none;
        opacity: 1;
    }
    .tagline-skeleton {
        display: none;
    }
    .fern-path, .fern-leaf {
        stroke-dashoffset: 0;
        animation: none;
    }
    .panel {
        opacity: 1;
        transform: none;
        transition: none;
    }
    .final-text {
        opacity: 1;
        transition: none;
    }
}

/* === Responsive === */
@media (max-width: 600px) {
    .panel-inner {
        padding: 24px 20px;
    }
    .fern-intro {
        width: 80px;
        height: 110px;
        right: 20px;
        bottom: 20px;
    }
    .fern-overlay-1, .fern-overlay-2 {
        width: 120px;
        height: 180px;
    }
    .skeleton-zone {
        padding: 16px 20px;
    }
}
