/* ============================================
   cbdc.study — Neubrutalist Botanical Field Guide
   ============================================ */

/* CSS Custom Properties */
:root {
    --bg-ivory: #f4f0e8;
    --bg-amethyst: #4a1a6b;
    --text-black: #0a0a0a;
    --text-cream: #f8f4ec;
    --accent-emerald: #0d7c4a;
    --accent-ruby: #c2185b;
    --accent-sapphire: #1565c0;
    --accent-amber: #e6a817;
    --border-black: #0a0a0a;
    --font-primary: 'Commissioner', sans-serif;
}

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

html {
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-primary);
    font-weight: 400;
    font-size: clamp(1rem, 1.2vw, 1.25rem);
    line-height: 1.65;
    color: var(--text-black);
    background-color: var(--bg-ivory);
    /* Diamond pattern background */
    background-image: 
        linear-gradient(45deg, rgba(10,10,10,0.05) 25%, transparent 25%),
        linear-gradient(-45deg, rgba(10,10,10,0.05) 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, rgba(10,10,10,0.05) 75%),
        linear-gradient(-45deg, transparent 75%, rgba(10,10,10,0.05) 75%);
    background-size: 16px 16px;
    background-position: 0 0, 0 8px, 8px -8px, -8px 0px;
}

/* ============================================
   Sections
   ============================================ */
.section {
    position: relative;
    width: 100%;
    border-bottom: 4px solid var(--border-black);
    padding: clamp(4rem, 8vh, 10rem) clamp(3rem, 6vw, 8rem);
    overflow: hidden;
}

.section--ivory {
    background-color: var(--bg-ivory);
    color: var(--text-black);
}

.section--amethyst {
    background-color: var(--bg-amethyst);
    color: var(--text-cream);
}

.section--emerald {
    background-color: var(--accent-emerald);
    color: var(--text-cream);
}

.section--canopy {
    background-color: var(--bg-amethyst);
    color: var(--text-cream);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
}

/* Hero section */
#specimen-label {
    min-height: 100vh;
    display: flex;
    align-items: center;
    gap: 4rem;
}

/* ============================================
   Corner Marks
   ============================================ */
.corner-marks {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 1;
}

.corner-mark {
    position: absolute;
    width: 20px;
    height: 20px;
}

.corner-mark::before,
.corner-mark::after {
    content: '';
    position: absolute;
    background: var(--text-black);
}

.section--amethyst .corner-mark::before,
.section--amethyst .corner-mark::after,
.section--emerald .corner-mark::before,
.section--emerald .corner-mark::after,
.section--canopy .corner-mark::before,
.section--canopy .corner-mark::after {
    background: var(--text-cream);
    opacity: 0.4;
}

.corner-mark::before {
    width: 1px;
    height: 20px;
    left: 50%;
}

.corner-mark::after {
    width: 20px;
    height: 1px;
    top: 50%;
}

.corner-mark--tl { top: 16px; left: 16px; }
.corner-mark--tr { top: 16px; right: 16px; }
.corner-mark--bl { bottom: 16px; left: 16px; }
.corner-mark--br { bottom: 16px; right: 16px; }

/* ============================================
   Section Content
   ============================================ */
.section__content {
    position: relative;
    z-index: 2;
}

.section__content--left {
    width: 55%;
    max-width: 650px;
}

.section__content--right {
    width: 55%;
    max-width: 650px;
    margin-left: auto;
}

.section__content--full {
    width: 100%;
    margin-bottom: 2rem;
}

.section__heading {
    font-family: var(--font-primary);
    font-weight: 800;
    font-size: clamp(2rem, 5vw, 4rem);
    line-height: 1.1;
    letter-spacing: -0.02em;
    margin-bottom: 2rem;
    text-shadow: 3px 3px 0 var(--accent-emerald);
}

.section--amethyst .section__heading {
    text-shadow: 3px 3px 0 var(--accent-ruby);
}

.section--emerald .section__heading {
    text-shadow: 3px 3px 0 var(--border-black);
}

.section--canopy .section__heading {
    text-shadow: 3px 3px 0 var(--accent-sapphire);
}

.section__body {
    margin-bottom: 2rem;
    max-width: 600px;
}

.section__body--intro {
    max-width: 700px;
    margin-bottom: 1rem;
}

/* Amber highlights */
.highlight-amber {
    color: var(--accent-amber);
    font-weight: 600;
    position: relative;
    cursor: default;
}

.highlight-amber::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 0;
    height: 2px;
    background: var(--accent-amber);
    transition: width 0.4s ease;
}

.highlight-amber:hover::after {
    width: 100%;
}

/* ============================================
   Hero Title
   ============================================ */
.hero-title {
    margin-bottom: 3rem;
}

.hero-title__main {
    display: block;
    font-family: var(--font-primary);
    font-weight: 900;
    font-size: clamp(4rem, 12vw, 9rem);
    line-height: 1;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--text-black);
    text-shadow: 4px 4px 0 var(--accent-emerald);
}

.hero-title__sub {
    display: block;
    font-family: var(--font-primary);
    font-weight: 300;
    font-size: clamp(1.5rem, 3vw, 3rem);
    letter-spacing: 0.2em;
    color: var(--text-black);
    margin-top: 0.5rem;
}

/* ============================================
   Specimen Box
   ============================================ */
.specimen-box {
    background: var(--bg-ivory);
    border: 4px solid var(--border-black);
    box-shadow: 8px 8px 0 var(--border-black);
    padding: 1.5rem 2rem;
    transform: rotate(-1.5deg);
    max-width: 480px;
    position: relative;
    overflow: hidden;
    max-height: 0;
    transition: max-height 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94), padding 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    padding-top: 0;
    padding-bottom: 0;
}

.specimen-box.is-revealed {
    max-height: 300px;
    padding: 1.5rem 2rem;
}

.specimen-box__label {
    display: block;
    font-family: var(--font-primary);
    font-weight: 300;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.18em;
    color: var(--accent-ruby);
    margin-bottom: 0.75rem;
}

.specimen-box__text {
    font-family: var(--font-primary);
    font-weight: 400;
    font-size: clamp(0.9rem, 1.1vw, 1.1rem);
    line-height: 1.6;
    color: var(--text-black);
}

/* ============================================
   Illustrations
   ============================================ */
.section__illustration {
    position: relative;
    z-index: 2;
}

.section__illustration--right {
    position: absolute;
    right: clamp(2rem, 6vw, 8rem);
    top: 50%;
    transform: translateY(-50%);
    width: 35%;
    max-width: 400px;
}

.section__illustration--center {
    width: 100%;
    max-width: 700px;
    margin: 2rem auto 0;
}

.section__illustration--full {
    width: 100%;
    position: relative;
}

/* Seedling SVG */
.seedling-illustration {
    width: 100%;
    height: auto;
}

.seedling-stem {
    stroke-dasharray: 300;
    stroke-dashoffset: 300;
    animation: drawStem 1.5s ease-out 0.5s forwards;
}

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

.seedling-leaf {
    transition: opacity 0.6s ease;
}

.seedling-leaf--left {
    animation: fadeLeaf 0.8s ease 1.5s forwards;
}

.seedling-leaf--right {
    animation: fadeLeaf 0.8s ease 1.8s forwards;
}

.seedling-leaf--top,
.seedling-leaf--top2 {
    animation: fadeLeaf 0.8s ease 2.1s forwards;
}

.seedling-leaf-vein--left {
    animation: fadeLeaf 0.6s ease 1.7s forwards;
}

.seedling-leaf-vein--right {
    animation: fadeLeaf 0.6s ease 2.0s forwards;
}

.seedling-symbol {
    animation: fadeLeaf 0.6s ease 2.4s forwards;
}

@keyframes fadeLeaf {
    to { opacity: 1; }
}

/* Roots SVG */
.roots-illustration {
    width: 100%;
    height: auto;
}

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

.root-path.is-animated {
    animation: drawRoot 1.5s ease-out forwards;
}

.root-path--retail.is-animated { animation-delay: 0s; }
.root-path--wholesale.is-animated { animation-delay: 0.2s; }
.root-path--crossborder.is-animated { animation-delay: 0.4s; }
.root-path--minor1.is-animated { animation-delay: 0.6s; }
.root-path--minor2.is-animated { animation-delay: 0.8s; }
.root-path--minor3.is-animated { animation-delay: 1.0s; }
.root-path--main.is-animated { animation-delay: 0s; }

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

.root-node.is-animated,
.root-label.is-animated {
    animation: fadeIn 0.6s ease forwards;
}

@keyframes fadeIn {
    to { opacity: 1; }
}

.root-label {
    font-family: var(--font-primary);
    font-weight: 300;
    font-size: 11px;
    letter-spacing: 0.18em;
    fill: var(--text-cream);
    text-transform: uppercase;
    opacity: 0;
}

/* Growth Rings */
.rings-illustration {
    width: 100%;
    height: auto;
}

.growth-ring {
    transform-origin: 300px 300px;
    transition: opacity 0.6s ease, transform 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.growth-ring.is-visible {
    opacity: 1 !important;
    transform: scale(1);
}

.ring-label.is-visible {
    opacity: 1 !important;
    transition: opacity 0.5s ease;
}

.ring-label__year {
    font-family: var(--font-primary);
    font-weight: 800;
    font-size: 18px;
    fill: var(--text-black);
}

.ring-label__desc {
    font-family: var(--font-primary);
    font-weight: 400;
    font-size: 12px;
    fill: var(--text-black);
}

/* Branches SVG */
.branches-illustration {
    width: 100%;
    height: auto;
    min-height: 300px;
}

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

.branch-path.is-drawn {
    animation: drawBranch 1s ease-out forwards;
}

.branch-trunk.is-drawn { animation-delay: 0s; }
.branch-fork-1a.is-drawn { animation-delay: 0.3s; }
.branch-fork-1b.is-drawn { animation-delay: 0.3s; }
.branch-fork-2a.is-drawn { animation-delay: 0.7s; }
.branch-fork-2b.is-drawn { animation-delay: 0.7s; }
.branch-fork-2c.is-drawn { animation-delay: 0.7s; }
.branch-fork-2d.is-drawn { animation-delay: 0.7s; }

.branch-label-trunk {
    transition: opacity 0.5s ease 0.3s;
}

.branch-label-trunk.is-visible {
    opacity: 1 !important;
}

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

/* Branch terminus labels */
.branch-labels {
    position: absolute;
    inset: 0;
    pointer-events: none;
}

.branch-terminus {
    position: absolute;
    background: var(--bg-ivory);
    color: var(--text-black);
    border: 3px solid var(--border-black);
    box-shadow: 6px 6px 0 var(--border-black);
    padding: 1rem 1.2rem;
    max-width: 220px;
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 0.5s ease, transform 0.5s ease, border-left-color 0.3s ease;
    pointer-events: auto;
    cursor: pointer;
}

.branch-terminus.is-visible {
    opacity: 1;
    transform: translateY(0);
}

.branch-terminus.is-selected {
    transform: scale(1.05);
    border-left: 4px solid var(--accent-ruby);
}

.branch-terminus__label {
    display: block;
    font-family: var(--font-primary);
    font-weight: 300;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.18em;
    color: var(--accent-ruby);
    margin-bottom: 0.5rem;
}

.branch-terminus__desc {
    font-family: var(--font-primary);
    font-weight: 400;
    font-size: 0.8rem;
    line-height: 1.5;
    color: var(--text-black);
}

/* Position branch terminus boxes */
.branch-terminus--1a { top: 3%; left: 46%; }
.branch-terminus--1b { top: 56%; left: 46%; }
.branch-terminus--2a { top: 0%; right: 2%; }
.branch-terminus--2b { top: 28%; right: 2%; }
.branch-terminus--2c { top: 48%; right: 2%; }
.branch-terminus--2d { top: 74%; right: 2%; }

/* ============================================
   Canopy Section
   ============================================ */
.canopy-leaves {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 60%;
    z-index: 1;
}

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

.canopy-content {
    position: relative;
    z-index: 2;
    display: flex;
    flex-wrap: wrap;
    gap: 2rem;
    justify-content: center;
    padding: 2rem 0 4rem;
    min-height: 40vh;
    align-items: flex-end;
}

.canopy-box {
    max-height: none;
    padding: 1.5rem 2rem;
    max-width: 340px;
    flex: 1 1 280px;
    transform: rotate(0deg);
}

.canopy-box--1 {
    transform: rotate(-1deg);
    opacity: 0;
    animation: driftInLeft 1s ease 0.3s forwards;
}

.canopy-box--2 {
    transform: rotate(0.5deg);
    opacity: 0;
    animation: driftInBottom 1s ease 0.6s forwards;
}

.canopy-box--3 {
    transform: rotate(1deg);
    opacity: 0;
    animation: driftInRight 1s ease 0.9s forwards;
}

.canopy-box.is-drifted-in {
    opacity: 1;
}

@keyframes driftInLeft {
    from {
        opacity: 0;
        transform: translateX(-60px) rotate(-3deg);
    }
    to {
        opacity: 1;
        transform: translateX(0) rotate(-1deg);
    }
}

@keyframes driftInBottom {
    from {
        opacity: 0;
        transform: translateY(60px) rotate(2deg);
    }
    to {
        opacity: 1;
        transform: translateY(0) rotate(0.5deg);
    }
}

@keyframes driftInRight {
    from {
        opacity: 0;
        transform: translateX(60px) rotate(3deg);
    }
    to {
        opacity: 1;
        transform: translateX(0) rotate(1deg);
    }
}

/* Leaf vein divider */
.leaf-vein-divider {
    width: 100%;
    position: relative;
    z-index: 2;
    margin-top: 2rem;
}

.leaf-vein-divider svg {
    width: 100%;
    height: 30px;
}

/* ============================================
   Chevron
   ============================================ */
.section__chevron {
    position: absolute;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%);
    z-index: 3;
    animation: bounceChevron 2s ease-in-out infinite;
}

.section__chevron svg {
    width: 40px;
    height: 24px;
}

@keyframes bounceChevron {
    0%, 100% { transform: translateX(-50%) translateY(0); }
    50% { transform: translateX(-50%) translateY(8px); }
}

/* ============================================
   Growth Rings Section Layout
   ============================================ */
#growth-rings {
    display: flex;
    flex-direction: column;
}

#growth-rings .section__content--right {
    text-align: right;
}

/* ============================================
   Branching Paths Section Layout
   ============================================ */
#branching-paths .section__illustration--full {
    min-height: 400px;
}

/* ============================================
   Reduced Motion
   ============================================ */
@media (prefers-reduced-motion: reduce) {
    .seedling-stem {
        animation: none;
        stroke-dashoffset: 0;
    }
    .seedling-leaf,
    .seedling-leaf-vein--left,
    .seedling-leaf-vein--right,
    .seedling-symbol {
        animation: none;
        opacity: 1;
    }
    .root-path {
        stroke-dashoffset: 0;
    }
    .root-node,
    .root-label {
        opacity: 1;
    }
    .growth-ring {
        opacity: 1 !important;
    }
    .ring-label {
        opacity: 1 !important;
    }
    .branch-path {
        stroke-dashoffset: 0;
    }
    .branch-terminus {
        opacity: 1;
        transform: translateY(0);
    }
    .canopy-box--1,
    .canopy-box--2,
    .canopy-box--3 {
        animation: none;
        opacity: 1;
    }
    .section__chevron {
        animation: none;
    }
}

/* ============================================
   Mobile Breakpoint
   ============================================ */
@media (max-width: 768px) {
    .section {
        padding: clamp(1.5rem, 4vw, 3rem);
    }

    #specimen-label {
        flex-direction: column;
        gap: 2rem;
        padding-top: 6rem;
        padding-bottom: 8rem;
    }

    .section__content--left,
    .section__content--right {
        width: 100%;
        max-width: none;
        margin-left: 0;
    }

    .section__illustration--right {
        position: relative;
        right: auto;
        top: auto;
        transform: none;
        width: 80%;
        max-width: 300px;
        margin: 0 auto;
    }

    .hero-title__main {
        font-size: clamp(3rem, 15vw, 6rem);
    }

    .hero-title__sub {
        font-size: clamp(1rem, 4vw, 2rem);
    }

    .specimen-box {
        max-width: 100%;
    }

    .rings-illustration {
        max-width: 100%;
        overflow: visible;
    }

    .ring-label__year {
        font-size: 14px;
    }

    .ring-label__desc {
        font-size: 10px;
    }

    /* Branch section mobile */
    .branches-illustration {
        min-height: 200px;
    }

    .branch-labels {
        position: relative;
        display: flex;
        flex-direction: column;
        gap: 1rem;
        margin-top: 1.5rem;
    }

    .branch-terminus {
        position: relative;
        top: auto !important;
        left: auto !important;
        right: auto !important;
        max-width: 100%;
        opacity: 1;
        transform: none;
    }

    .canopy-content {
        flex-direction: column;
        align-items: center;
    }

    .canopy-box {
        max-width: 100%;
        flex: 1 1 auto;
    }
}
