/* thesecond.world - Generative botanical codex */

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

:root {
    --deep-burgundy: #4A1228;
    --wine: #6B2D3E;
    --mulberry: #8B4A5E;
    --dusty-rose: #B07080;
    --vellum: #FAF0E8;
    --aged-cream: #F0E0D0;
    --petal-blush: #F5DDD5;
    --bone-white: #FDF8F4;
}

body {
    font-family: 'Alegreya', serif;
    font-weight: 400;
    font-size: clamp(0.9375rem, 1.5vw, 1.0625rem);
    line-height: 1.7;
    color: var(--wine);
    background-color: var(--vellum);
    overflow-x: hidden;
    padding-bottom: 48px;
}

/* === Growth Canvas (background) === */
#growth-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
}

/* === Cultural Band === */
.cultural-band {
    height: 60px;
    overflow: hidden;
    position: relative;
    z-index: 10;
    background-color: var(--aged-cream);
}

.textile-pattern {
    width: 100%;
    height: 60px;
}

.textile-path {
    stroke-dasharray: 5000;
    stroke-dashoffset: 5000;
    animation: drawTextile 1.2s 0.3s ease forwards;
}

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

/* === Cover Section === */
.cover {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    z-index: 10;
    padding: 80px 24px;
}

.cover-title {
    font-family: 'Fraunces', serif;
    font-weight: 700;
    font-size: clamp(2.25rem, 5vw, 4rem);
    color: var(--wine);
    text-align: center;
    font-variation-settings: 'WONK' 0, 'SOFT' 0;
    transition: font-variation-settings 1s ease;
}

.cover-title.animated {
    font-variation-settings: 'WONK' 1, 'SOFT' 100;
}

.cover-tagline {
    font-family: 'Alegreya', serif;
    font-style: italic;
    font-size: clamp(1rem, 1.8vw, 1.25rem);
    color: var(--mulberry);
    margin-top: 16px;
    opacity: 0;
    animation: fadeIn 0.8s 1s ease forwards;
}

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

/* === Card Grid: The Garden === */
.garden {
    position: relative;
    z-index: 10;
    padding: 60px 32px;
}

.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 24px;
    max-width: 1200px;
    margin: 0 auto;
}

.card {
    aspect-ratio: 3/4;
    background-color: var(--vellum);
    border: 1px solid var(--wine);
    padding: 24px;
    position: relative;
    display: flex;
    flex-direction: column;
    transform: translate(
        calc(sin(var(--i) * 1.3) * 6px),
        calc(sin(var(--i) * 0.7) * 4px)
    ) rotate(calc(sin(var(--i) * 0.7) * 1.2deg));
    transition: transform 0.3s ease, background-color 0.3s ease, box-shadow 0.3s ease;
    opacity: 0;
}

.card.visible {
    opacity: 1;
    animation: cardEnter 0.5s ease forwards;
}

.card:hover {
    background-color: var(--petal-blush);
    box-shadow: 4px 4px 16px rgba(74, 18, 40, 0.12);
}

@keyframes cardEnter {
    from { opacity: 0; transform: translateY(16px); }
    to { opacity: 1; transform: translate(calc(sin(var(--i) * 1.3) * 6px), calc(sin(var(--i) * 0.7) * 4px)) rotate(calc(sin(var(--i) * 0.7) * 1.2deg)); }
}

.card-label {
    font-family: 'Fraunces', serif;
    font-weight: 300;
    font-size: 0.8125rem;
    color: var(--mulberry);
    letter-spacing: 0.04em;
    margin-bottom: 12px;
}

.card-title {
    font-family: 'Fraunces', serif;
    font-weight: 700;
    font-size: clamp(1.25rem, 2.5vw, 1.75rem);
    color: var(--wine);
    margin-bottom: 12px;
    font-variation-settings: 'WONK' 0, 'SOFT' 0;
    transition: font-variation-settings 0.8s ease;
}

.card.visible .card-title {
    font-variation-settings: 'WONK' 1, 'SOFT' 100;
}

.card-body {
    font-family: 'Alegreya', serif;
    font-weight: 400;
    font-size: clamp(0.875rem, 1.4vw, 1rem);
    line-height: 1.7;
    color: var(--wine);
    flex: 1;
}

.card-botanical {
    width: 80px;
    height: 100px;
    position: absolute;
    bottom: 12px;
    right: 12px;
    opacity: 0.6;
}

.card-border-ornament {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 8px;
    background: repeating-linear-gradient(
        90deg,
        var(--wine) 0px,
        var(--wine) 4px,
        transparent 4px,
        transparent 8px,
        var(--mulberry) 8px,
        var(--mulberry) 10px,
        transparent 10px,
        transparent 16px
    );
    opacity: 0.5;
}

/* === Deep Growth === */
.deep-growth {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    z-index: 10;
}

#deep-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
}

.deep-text {
    text-align: center;
    position: relative;
    z-index: 10;
    padding: 40px;
}

.deep-verse {
    font-family: 'Fraunces', serif;
    font-weight: 300;
    font-size: clamp(1.5rem, 3vw, 2.25rem);
    color: var(--wine);
    line-height: 2;
    opacity: 0;
    transition: opacity 1.5s ease;
}

.deep-verse.visible {
    opacity: 1;
}

/* === Bottom Navigation === */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 32px;
    background-color: var(--vellum);
    border-top: 1px solid var(--wine);
    z-index: 100;
}

.bnav-link {
    font-family: 'Alegreya', serif;
    font-size: 0.875rem;
    color: var(--mulberry);
    text-decoration: none;
    position: relative;
    transition: color 0.3s ease;
}

.bnav-link.active {
    color: var(--wine);
}

.bnav-link.active::after {
    content: '';
    position: absolute;
    bottom: -4px;
    left: 0;
    right: 0;
    height: 1px;
    background-color: var(--mulberry);
    animation: vineGrow 0.6s ease forwards;
}

@keyframes vineGrow {
    from { transform: scaleX(0); }
    to { transform: scaleX(1); }
}

/* === Leaf cursor trail === */
.leaf-trail {
    position: fixed;
    width: 8px;
    height: 8px;
    pointer-events: none;
    z-index: 200;
    opacity: 0.3;
}

/* === Reduced Motion === */
@media (prefers-reduced-motion: reduce) {
    .textile-path {
        stroke-dashoffset: 0;
        animation: none;
    }
    .cover-title {
        font-variation-settings: 'WONK' 1, 'SOFT' 100;
        transition: none;
    }
    .cover-tagline {
        opacity: 1;
        animation: none;
    }
    .card {
        opacity: 1;
        animation: none;
    }
    .deep-verse {
        opacity: 1;
        transition: none;
    }
}

/* === Responsive === */
@media (max-width: 600px) {
    .card-grid {
        grid-template-columns: 1fr;
    }
    .garden {
        padding: 40px 16px;
    }
    .card {
        aspect-ratio: auto;
        min-height: 300px;
    }
}
