/* ==========================================
   MMIDDL.com - Neubrutalist Botanical Almanac
   ========================================== */

/* CSS Custom Properties */
:root {
    --bg-primary: #F2EBD9;
    --bg-secondary: #E8DFC8;
    --text-primary: #4A4A3A;
    --text-secondary: #5A5A4A;
    --accent-terracotta: #B5543A;
    --accent-sage: #8B8B6A;
    --accent-goldenrod: #C4B998;
    --accent-mustard: #C9A84C;
    --accent-verdigris: #7A8B6A;

    --font-display: 'Righteous', cursive;
    --font-heading: 'Abril Fatface', serif;
    --font-body: 'Source Serif 4', serif;
    --font-mono: 'Space Mono', monospace;

    --border-thick: 3px solid #4A4A3A;
    --shadow-offset: 4px 4px 0 #C4B998;
    --grid-border: 4px solid rgba(139, 139, 106, 0.15);
}

/* ==========================================
   RESET & BASE
   ========================================== */

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

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

body {
    font-family: var(--font-body);
    font-weight: 400;
    font-size: 17px;
    line-height: 1.72;
    letter-spacing: 0.01em;
    color: var(--text-secondary);
    background-color: var(--bg-primary);
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

/* SVG filter container */
.svg-filters {
    position: absolute;
    width: 0;
    height: 0;
    overflow: hidden;
}

/* ==========================================
   COVER / HERO
   ========================================== */

.cover {
    position: relative;
    width: 100vw;
    height: 100vh;
    min-height: 600px;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--bg-primary);
    z-index: 100;
    overflow: hidden;
}

.cover-inner {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
}

/* Root system SVG */
.root-system {
    position: absolute;
    width: 60vw;
    max-width: 800px;
    height: auto;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -40%);
    opacity: 0.85;
}

.root-path {
    stroke-dasharray: var(--path-length, 1000);
    stroke-dashoffset: var(--path-length, 1000);
    animation: drawRoot 4s ease-out forwards;
}

.root-main { animation-delay: 0s; }
.root-left-1 { animation-delay: 0.4s; }
.root-right-1 { animation-delay: 0.6s; }
.root-left-2 { animation-delay: 0.8s; }
.root-right-2 { animation-delay: 1s; }
.rootlet-l1 { animation-delay: 1.2s; }
.rootlet-l2 { animation-delay: 1.4s; }
.rootlet-l3 { animation-delay: 1.6s; }
.rootlet-l4 { animation-delay: 1.8s; }
.rootlet-r1 { animation-delay: 1.3s; }
.rootlet-r2 { animation-delay: 1.5s; }
.rootlet-r3 { animation-delay: 1.7s; }
.rootlet-r4 { animation-delay: 1.9s; }
.hair-1 { animation-delay: 2.0s; }
.hair-2 { animation-delay: 2.1s; }
.hair-3 { animation-delay: 2.2s; }
.hair-4 { animation-delay: 2.3s; }
.hair-5 { animation-delay: 2.4s; }
.hair-6 { animation-delay: 2.5s; }
.ground-line { animation-delay: 0.2s; }

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

/* Cover title */
.cover-title {
    position: relative;
    z-index: 10;
    font-family: var(--font-display);
    font-size: 18vw;
    line-height: 0.95;
    letter-spacing: 0.08em;
    color: var(--text-primary);
    text-transform: uppercase;
    display: flex;
    gap: 0.02em;
    margin-top: -8vh;
}

.cover-title .letter {
    display: inline-block;
    opacity: 0;
    transform: translateY(30px) rotate(2deg);
    animation: stampLetter 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

.cover-title .letter[data-index="0"] { animation-delay: 3.8s; }
.cover-title .letter[data-index="1"] { animation-delay: 3.95s; }
.cover-title .letter[data-index="2"] { animation-delay: 4.1s; }
.cover-title .letter[data-index="3"] { animation-delay: 4.25s; }
.cover-title .letter[data-index="4"] { animation-delay: 4.4s; }
.cover-title .letter[data-index="5"] { animation-delay: 4.55s; }

@keyframes stampLetter {
    0% {
        opacity: 0;
        transform: translateY(30px) rotate(2deg);
    }
    100% {
        opacity: 1;
        transform: translateY(0) rotate(0deg);
    }
}

/* Cover subtitle */
.cover-subtitle {
    position: relative;
    z-index: 10;
    font-family: var(--font-heading);
    font-size: 3vw;
    color: var(--accent-terracotta);
    opacity: 0;
    animation: fadeInSubtitle 1.2s ease forwards;
    animation-delay: 4.8s;
    margin-top: 1vh;
    letter-spacing: 0.04em;
}

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

/* Cover peel animation */
.cover.peeling {
    animation: peelCover 1.2s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

@keyframes peelCover {
    from {
        clip-path: inset(0 0 0 0);
    }
    to {
        clip-path: inset(0 0 100% 0);
    }
}

/* ==========================================
   MAIN CONTENT
   ========================================== */

.main-content {
    position: relative;
    display: flex;
    min-height: 100vh;
    background-color: var(--bg-primary);
}

/* Grid lines (visible background grid) */
.grid-lines {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    pointer-events: none;
    z-index: 0;
}

.grid-line {
    flex: 1;
    border-right: var(--grid-border);
}

.grid-line:last-child {
    border-right: none;
}

/* ==========================================
   LEFT RAIL NAVIGATION
   ========================================== */

.left-rail {
    position: fixed;
    top: 0;
    left: 0;
    width: 20%;
    height: 100vh;
    z-index: 50;
    padding: 40px 0 40px 24px;
    display: flex;
    align-items: center;
    background: linear-gradient(90deg, var(--bg-primary) 85%, transparent);
    clip-path: polygon(0 0, 92% 0, 100% 3%, 95% 8%, 100% 15%, 93% 22%, 98% 30%, 94% 38%, 100% 45%, 92% 52%, 97% 60%, 93% 68%, 100% 75%, 94% 82%, 98% 90%, 92% 96%, 95% 100%, 0 100%);
}

.rail-inner {
    width: 100%;
}

.rail-label {
    font-family: var(--font-mono);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--accent-sage);
    margin-bottom: 24px;
    padding-left: 8px;
}

.rail-nav {
    list-style: none;
}

.rail-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 8px;
    font-family: var(--font-mono);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--text-secondary);
    cursor: pointer;
    transition: transform 0.2s ease, color 0.2s ease, border-left 0.2s ease;
    border-left: 4px solid transparent;
    margin-left: -4px;
}

.rail-item:hover {
    color: var(--text-primary);
    transform: translateX(4px);
}

.rail-item.active {
    color: var(--accent-terracotta);
    border-left-color: var(--accent-terracotta);
    transform: rotate(2deg);
    font-weight: 700;
}

.leaf-bullet {
    flex-shrink: 0;
}

/* ==========================================
   CONTENT AREA
   ========================================== */

.content-area {
    flex: 1;
    margin-left: 20%;
    padding: 60px 48px 60px 48px;
    position: relative;
    z-index: 1;
}

/* ==========================================
   CONTENT BLOCKS
   ========================================== */

.content-block {
    position: relative;
    margin-bottom: 32px;
    opacity: 0;
    transform: scale(1.03);
    transition: opacity 0.4s ease, transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.content-block.visible {
    opacity: 1;
    transform: scale(1);
}

.block-inner {
    position: relative;
    border: var(--border-thick);
    background-color: var(--bg-primary);
    padding: 40px;
    box-shadow: 0 0 0 0 var(--accent-goldenrod);
    transition: box-shadow 0.3s ease 0.1s, transform 0.15s ease-out;
}

.content-block.visible .block-inner {
    box-shadow: var(--shadow-offset);
}

/* Block header */
.block-header {
    margin-bottom: 32px;
    padding-bottom: 16px;
    border-bottom: 2px solid rgba(139, 139, 106, 0.2);
}

.block-label {
    display: block;
    font-family: var(--font-mono);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--accent-sage);
    margin-bottom: 8px;
}

.block-title {
    font-family: var(--font-heading);
    font-size: 42px;
    color: var(--accent-terracotta);
    line-height: 1.1;
    letter-spacing: 0.01em;
}

/* F-pattern layout */
.f-layout {
    display: flex;
    gap: 48px;
}

.f-text {
    flex: 3;
    min-width: 0;
}

.f-text p {
    max-width: 62ch;
    margin-bottom: 1.2em;
    color: var(--text-secondary);
}

.f-text p:last-child {
    margin-bottom: 0;
}

.f-illustration {
    flex: 2;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
}

/* ==========================================
   BOTANICAL PLATES
   ========================================== */

.botanical-plate {
    width: 100%;
    max-width: 300px;
    height: auto;
}

.draw-path {
    stroke-dasharray: var(--path-length, 500);
    stroke-dashoffset: var(--path-length, 500);
    transition: stroke-dashoffset 1.2s ease;
}

.scroll-draw.drawn .draw-path.phase-roots {
    stroke-dashoffset: 0;
    transition-delay: 0s;
    transition-duration: 1s;
}

.scroll-draw.drawn .draw-path.phase-stems {
    stroke-dashoffset: 0;
    transition-delay: 0.4s;
    transition-duration: 1s;
}

.scroll-draw.drawn .draw-path.phase-leaves {
    stroke-dashoffset: 0;
    transition-delay: 0.8s;
    transition-duration: 1s;
}

.scroll-draw.drawn .draw-path.phase-flowers {
    stroke-dashoffset: 0;
    transition-delay: 1.2s;
    transition-duration: 1s;
}

/* Specimen labels */
.specimen-label {
    margin-top: 16px;
    padding: 8px 16px;
    border: 1px solid var(--accent-sage);
    background: var(--bg-secondary);
    font-family: var(--font-mono);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--accent-sage);
    text-align: center;
    width: 100%;
    max-width: 300px;
}

/* Marginal sketch */
.marginal-sketch {
    max-width: 200px;
}

.marginal-sketch .botanical-plate {
    max-width: 200px;
}

/* ==========================================
   ORGANIC BLOBS
   ========================================== */

.organic-blob {
    position: absolute;
    z-index: -1;
    pointer-events: none;
    opacity: 0.5;
}

.blob-1 {
    width: 300px;
    height: 280px;
    background: var(--bg-secondary);
    border-radius: 43% 57% 64% 36% / 52% 38% 62% 48%;
    top: -40px;
    right: -60px;
    animation: blobDrift1 40s ease-in-out infinite;
}

.blob-2 {
    width: 250px;
    height: 230px;
    background: rgba(139, 139, 106, 0.12);
    border-radius: 57% 43% 36% 64% / 38% 62% 48% 52%;
    bottom: -30px;
    left: -50px;
    animation: blobDrift2 40s ease-in-out infinite;
}

.blob-3 {
    width: 280px;
    height: 260px;
    background: var(--bg-secondary);
    border-radius: 64% 36% 43% 57% / 48% 52% 38% 62%;
    top: 20px;
    right: -40px;
    animation: blobDrift3 40s ease-in-out infinite;
}

.blob-4 {
    width: 220px;
    height: 200px;
    background: rgba(139, 139, 106, 0.12);
    border-radius: 36% 64% 57% 43% / 62% 48% 52% 38%;
    bottom: -20px;
    left: -30px;
    animation: blobDrift1 40s ease-in-out infinite reverse;
}

.blob-5 {
    width: 260px;
    height: 240px;
    background: var(--bg-secondary);
    border-radius: 52% 48% 38% 62% / 43% 57% 64% 36%;
    top: -30px;
    right: -50px;
    animation: blobDrift2 40s ease-in-out infinite reverse;
}

.blob-6 {
    width: 200px;
    height: 180px;
    background: rgba(139, 139, 106, 0.12);
    border-radius: 48% 52% 62% 38% / 57% 43% 36% 64%;
    bottom: -40px;
    right: -30px;
    animation: blobDrift3 40s ease-in-out infinite;
}

@keyframes blobDrift1 {
    0%, 100% { transform: translate(0, 0) rotate(0deg); }
    25% { transform: translate(10px, -8px) rotate(2deg); }
    50% { transform: translate(-5px, 12px) rotate(-1deg); }
    75% { transform: translate(8px, 5px) rotate(1deg); }
}

@keyframes blobDrift2 {
    0%, 100% { transform: translate(0, 0) rotate(0deg); }
    25% { transform: translate(-8px, 10px) rotate(-2deg); }
    50% { transform: translate(12px, -5px) rotate(1deg); }
    75% { transform: translate(-5px, -8px) rotate(-1deg); }
}

@keyframes blobDrift3 {
    0%, 100% { transform: translate(0, 0) rotate(0deg); }
    25% { transform: translate(6px, 10px) rotate(1deg); }
    50% { transform: translate(-10px, -6px) rotate(-2deg); }
    75% { transform: translate(4px, -10px) rotate(1deg); }
}

/* ==========================================
   BOTANICAL DIVIDER
   ========================================== */

.botanical-divider {
    display: flex;
    justify-content: center;
    margin: 0 auto;
    padding: 16px 0;
    width: 60%;
}

.botanical-divider svg {
    width: 100%;
    max-width: 400px;
    height: auto;
}

/* ==========================================
   PULL QUOTE
   ========================================== */

.pull-quote {
    font-family: var(--font-heading);
    font-size: 28px;
    color: var(--accent-terracotta);
    line-height: 1.4;
    margin-bottom: 1.5em;
    padding-left: 24px;
    border-left: 4px solid var(--accent-terracotta);
    font-style: normal;
}

/* ==========================================
   ALMANAC GRID
   ========================================== */

.almanac-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 24px;
}

.almanac-card {
    border: var(--border-thick);
    background: var(--bg-primary);
    padding: 24px;
    box-shadow: var(--shadow-offset);
    transition: transform 0.15s ease-out, box-shadow 0.15s ease-out;
}

.almanac-card-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 2px solid rgba(139, 139, 106, 0.2);
}

.almanac-month {
    font-family: var(--font-display);
    font-size: 20px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-primary);
}

.almanac-year {
    font-family: var(--font-mono);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--accent-sage);
}

.almanac-card-body h3 {
    font-family: var(--font-heading);
    font-size: 24px;
    color: var(--accent-terracotta);
    margin-bottom: 12px;
    line-height: 1.2;
}

.almanac-card-body p {
    font-size: 15px;
    line-height: 1.65;
    color: var(--text-secondary);
}

.almanac-card-footer {
    display: flex;
    gap: 8px;
    margin-top: 16px;
    flex-wrap: wrap;
}

.almanac-tag {
    font-family: var(--font-mono);
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--accent-sage);
    padding: 4px 10px;
    border: 1px solid var(--accent-sage);
    background: var(--bg-secondary);
}

/* ==========================================
   FOOTER
   ========================================== */

.site-footer {
    margin-top: 64px;
    padding: 48px 40px;
    border-top: var(--border-thick);
    background: var(--bg-secondary);
}

.footer-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 24px;
}

.footer-brand {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.footer-title {
    font-family: var(--font-display);
    font-size: 32px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-primary);
}

.footer-tagline {
    font-family: var(--font-heading);
    font-size: 18px;
    color: var(--accent-terracotta);
}

.footer-meta {
    display: flex;
    gap: 32px;
}

.footer-label {
    font-family: var(--font-mono);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--accent-sage);
}

.footer-decoration svg {
    width: 200px;
    height: auto;
    opacity: 0.6;
}

/* ==========================================
   TILT-3D STYLES (applied via JS)
   ========================================== */

.tilt-target {
    transform-style: preserve-3d;
    transition: transform 0.15s ease-out;
}

.tilt-target .block-inner,
.almanac-card {
    transition: transform 0.15s ease-out, box-shadow 0.15s ease-out;
}

/* ==========================================
   MOBILE RESPONSIVE
   ========================================== */

@media (max-width: 1024px) {
    .left-rail {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: auto;
        clip-path: none;
        padding: 12px 16px;
        background: var(--bg-primary);
        border-bottom: var(--border-thick);
        z-index: 200;
    }

    .rail-inner {
        display: flex;
        align-items: center;
        gap: 16px;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .rail-label {
        margin-bottom: 0;
        white-space: nowrap;
        flex-shrink: 0;
    }

    .rail-nav {
        display: flex;
        gap: 4px;
    }

    .rail-item {
        white-space: nowrap;
        padding: 6px 12px;
        border-left: none;
        border-bottom: 3px solid transparent;
        margin-left: 0;
    }

    .rail-item.active {
        border-left-color: transparent;
        border-bottom-color: var(--accent-terracotta);
        transform: none;
    }

    .rail-item:hover {
        transform: none;
    }

    .content-area {
        margin-left: 0;
        padding: 80px 24px 40px;
    }

    .grid-lines {
        display: none;
    }

    .cover-title {
        font-size: 20vw;
    }

    .cover-subtitle {
        font-size: 5vw;
    }
}

@media (max-width: 768px) {
    .f-layout {
        flex-direction: column;
        gap: 32px;
    }

    .f-illustration {
        align-items: center;
    }

    .block-inner {
        padding: 24px;
    }

    .block-title {
        font-size: 32px;
    }

    .almanac-grid {
        grid-template-columns: 1fr;
    }

    .pull-quote {
        font-size: 22px;
    }

    .cover-title {
        font-size: 24vw;
    }

    .cover-subtitle {
        font-size: 6vw;
    }

    .root-system {
        width: 80vw;
    }

    .footer-meta {
        flex-direction: column;
        align-items: center;
        gap: 8px;
    }

    .content-area {
        padding: 80px 16px 32px;
    }

    .left-rail {
        padding: 8px 12px;
    }

    .rail-item {
        font-size: 10px;
        padding: 4px 8px;
    }

    .rail-label {
        font-size: 10px;
    }
}
