:root {
    --frost-white: #f4f7f2;
    --forest-midnight: #1a2e19;
    --deep-leaf-ink: #2c3e2a;
    --body-ink: #3d4a3b;
    --amber-sap: #c4943a;
    --frost-sage: #8aab84;
    --glass-mist: rgba(244, 247, 242, 0.72);
    --vein-line: #c8d5c4;
    --new-growth: #5a9e4f;
    --sage-mist: #6b8068;
    --stem-deep: #4a6741;
    --stem-light: #a8c5a0;
    --leaf-white: #e8efe6;
    --display-font: "Cormorant Garamond", Garamond, serif;
    --body-font: "Source Serif 4", Georgia, serif;
    --label-font: "Space Grotesk", Inter, Helvetica, sans-serif;
}

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

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

body {
    min-height: 100vh;
    overflow-x: hidden;
    background: var(--frost-white);
    color: var(--body-ink);
    font-family: var(--body-font);
    font-size: clamp(1rem, 1.1vw, 1.15rem);
    line-height: 1.72;
}

button {
    appearance: none;
    border: 0;
    background: none;
    color: inherit;
    font: inherit;
    cursor: pointer;
}

.grain-source {
    position: absolute;
    pointer-events: none;
}

.grain-plane {
    position: fixed;
    inset: 0;
    z-index: 900;
    pointer-events: none;
    opacity: 0.08;
    filter: url(#grain);
    mix-blend-mode: multiply;
    background:
        radial-gradient(circle at 10% 20%, rgba(200, 213, 196, 0.38), transparent 22%),
        radial-gradient(circle at 80% 70%, rgba(138, 171, 132, 0.18), transparent 28%),
        repeating-radial-gradient(circle at 45% 50%, rgba(44, 62, 42, 0.12) 0 1px, transparent 1px 4px);
}

.prototype-container {
    position: relative;
    isolation: isolate;
}

.prototype-section {
    --section-bg: var(--frost-white);
    --section-fg: var(--body-ink);
    --title-color: var(--deep-leaf-ink);
    --cell-bg: var(--glass-mist);
    --cell-border: var(--vein-line);
    position: relative;
    min-height: 100vh;
    padding: clamp(5rem, 8vw, 7rem) clamp(2rem, 5vw, 5rem);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    scroll-snap-align: start;
    scroll-snap-stop: always;
    color: var(--section-fg);
    background:
        radial-gradient(circle at 52% 45%, rgba(168, 197, 160, 0.18), transparent 34%),
        linear-gradient(180deg, var(--section-bg) 0%, var(--section-bg) 70%, color-mix(in srgb, var(--section-bg), transparent 10%) 100%);
}

.prototype-section::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    bottom: -40vh;
    height: 80vh;
    z-index: 0;
    pointer-events: none;
    background: linear-gradient(to bottom, transparent, rgba(26, 46, 25, 0.24));
}

.prototype-section[data-theme="dark"] {
    --section-bg: var(--forest-midnight);
    --section-fg: #dce8d7;
    --title-color: var(--leaf-white);
    --cell-bg: rgba(26, 46, 25, 0.72);
    --cell-border: var(--stem-deep);
    background:
        radial-gradient(circle at 60% 38%, rgba(90, 158, 79, 0.18), transparent 34%),
        linear-gradient(180deg, var(--forest-midnight), #20391f 58%, var(--forest-midnight));
}

.prototype-section[data-theme="dark"]::after {
    background: linear-gradient(to bottom, transparent, rgba(244, 247, 242, 0.15));
}

.vein-field {
    position: absolute;
    inset: -10%;
    z-index: 0;
    opacity: 0.15;
    pointer-events: none;
    background:
        linear-gradient(31deg, transparent 49.7%, var(--vein-line) 49.9%, transparent 50.2%),
        linear-gradient(149deg, transparent 49.7%, var(--vein-line) 49.9%, transparent 50.2%),
        linear-gradient(90deg, transparent 49.8%, var(--vein-line) 50%, transparent 50.2%);
    background-size: 34vw 34vw, 30vw 30vw, 42vw 42vw;
    transform: rotate(-7deg) scale(1.2);
}

.section-leaf {
    position: absolute;
    right: -7vw;
    bottom: -2vh;
    width: min(40vw, 520px);
    z-index: 0;
    opacity: 0.6;
    fill: none;
    stroke: var(--vein-line);
    stroke-width: 1;
    transform: rotate(-14deg);
}

.section-header {
    position: relative;
    z-index: 2;
    width: min(760px, 90vw);
    margin-bottom: clamp(2.4rem, 5vw, 4rem);
    text-align: center;
}

.stage-label,
.cell-index,
.section-subtitle {
    font-family: var(--label-font);
    font-size: 0.75rem;
    font-weight: 500;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--sage-mist);
}

.prototype-section[data-theme="dark"] .stage-label,
.prototype-section[data-theme="dark"] .section-subtitle,
.prototype-section[data-theme="dark"] .cell-index {
    color: var(--stem-light);
}

.section-title {
    margin: 0.1em 0 0.08em;
    color: var(--title-color);
    font-family: var(--display-font);
    font-size: clamp(2.8rem, 5.5vw, 5.2rem);
    font-weight: 600;
    letter-spacing: -0.02em;
    line-height: 1.08;
}

.section-title .letter {
    display: inline-block;
    opacity: 0;
    transform: translateY(20px);
}

.prototype-section.title-visible .section-title .letter {
    animation: letter-reveal 720ms cubic-bezier(0.16, 1, 0.3, 1) forwards;
    animation-delay: calc(var(--letter-index) * 30ms);
}

.prototype-section[data-theme="dark"].title-visible .section-title .letter {
    animation-name: letter-reveal-glow;
}

.section-subtitle {
    max-width: none;
}

.hexagon-grid {
    position: relative;
    z-index: 2;
    display: grid;
    grid-template-columns: repeat(3, clamp(280px, 22vw, 380px));
    grid-auto-rows: calc(clamp(280px, 22vw, 380px) * 0.872);
    justify-content: center;
    width: min(100%, 1220px);
    min-height: calc(clamp(280px, 22vw, 380px) * 2.03);
    gap: 2px;
    perspective: 1200px;
}

.hex-cell {
    position: relative;
    width: clamp(280px, 22vw, 380px);
    height: calc(clamp(280px, 22vw, 380px) * 1.1547);
    padding: clamp(1.4rem, 2.1vw, 2rem);
    clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: flex-start;
    overflow: hidden;
    border: 1px solid var(--cell-border);
    background:
        radial-gradient(circle at center, transparent 0%, rgba(200, 213, 196, 0.2) 100%),
        var(--cell-bg);
    color: var(--section-fg);
    backdrop-filter: blur(12px);
    box-shadow: inset 0 0 0 1px rgba(244, 247, 242, 0.2), 0 18px 42px rgba(26, 46, 25, 0.08);
    opacity: 0;
    transform: scale(0.3) rotate(60deg);
    transform-origin: center;
    transition: transform 350ms cubic-bezier(0.34, 1.56, 0.64, 1), opacity 350ms ease, border-color 350ms ease, backdrop-filter 350ms ease, box-shadow 350ms ease;
}

.hex-cell:nth-child(n+4) {
    transform: translateX(50%) scale(0.3) rotate(60deg);
}

.hex-cell.visible {
    opacity: 1;
    transform: scale(1) rotate(0deg);
}

.hex-cell:nth-child(n+4).visible {
    transform: translateX(50%) scale(1) rotate(0deg);
}

.hex-cell::before,
.hex-cell::after {
    content: "";
    position: absolute;
    pointer-events: none;
}

.hex-cell::before {
    right: 18%;
    top: 18%;
    width: 34px;
    height: 18px;
    border-top: 1px solid var(--vein-line);
    border-radius: 50%;
    transform: rotate(-28deg);
    opacity: 0.75;
}

.hex-cell::after {
    inset: 14%;
    background: linear-gradient(135deg, transparent 49.3%, rgba(200, 213, 196, 0.22) 49.8%, transparent 50.4%);
    opacity: 0.45;
}

.hex-cell > * {
    position: relative;
    z-index: 1;
}

.cell-index {
    display: block;
    margin-bottom: 0.7rem;
    color: var(--amber-sap);
    font-size: 0.65rem;
}

.hex-cell h2 {
    margin-bottom: 0.75rem;
    color: var(--title-color);
    font-family: var(--display-font);
    font-size: clamp(1.26rem, 1.6vw, 1.72rem);
    font-weight: 600;
    letter-spacing: -0.02em;
    line-height: 1.08;
}

.hex-cell p {
    max-width: 62ch;
    font-size: clamp(0.88rem, 0.92vw, 1rem);
    line-height: 1.56;
}

.hex-cell:hover,
.hex-cell.hovered {
    z-index: 4;
    border-color: var(--new-growth);
    backdrop-filter: blur(20px);
    box-shadow: 0 0 0 1px rgba(90, 158, 79, 0.35), 0 22px 60px rgba(90, 158, 79, 0.18);
    transform: scale(1.08) rotate(0deg);
}

.hex-cell:nth-child(n+4):hover,
.hex-cell:nth-child(n+4).hovered {
    transform: translateX(50%) scale(1.08) rotate(0deg);
}

.hexagon-grid.has-hover .hex-cell.visible:not(.hovered) {
    opacity: 0.7;
    transform: scale(0.97) rotate(0deg);
}

.hexagon-grid.has-hover .hex-cell.visible:nth-child(n+4):not(.hovered) {
    transform: translateX(50%) scale(0.97) rotate(0deg);
}

.dark-swatch {
    background: linear-gradient(rgba(26, 46, 25, 0.92), rgba(26, 46, 25, 0.92)), var(--forest-midnight);
}

.ink-swatch h2,
.ink-swatch .cell-index {
    color: var(--deep-leaf-ink);
}

.amber-swatch .cell-index,
.amber-swatch h2 {
    color: var(--amber-sap);
}

.sage-swatch .cell-index,
.sage-swatch h2 {
    color: var(--frost-sage);
}

.growth-swatch .cell-index,
.growth-swatch h2 {
    color: var(--new-growth);
}

.stem-navigation {
    position: fixed;
    left: 0;
    top: 0;
    z-index: 1000;
    width: 8px;
    height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3rem;
}

.stem-line {
    position: absolute;
    top: 10%;
    bottom: 10%;
    left: 50%;
    width: 2px;
    overflow: hidden;
    transform: translateX(-50%);
    background: linear-gradient(to bottom, var(--stem-deep), var(--stem-light));
    opacity: 0.78;
}

.stem-wave {
    position: absolute;
    left: 50%;
    top: var(--wave-start, 0%);
    width: 8px;
    height: var(--wave-size, 24%);
    opacity: 0;
    transform: translateX(-50%) translateY(-120%);
    background: linear-gradient(to bottom, transparent, var(--new-growth), transparent);
}

.stem-navigation.wave-active .stem-wave {
    animation: stem-wave 900ms cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.stem-node {
    position: relative;
    z-index: 1;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 2px solid var(--stem-light);
    background: var(--frost-sage);
    transition: transform 300ms ease, background-color 300ms ease, box-shadow 300ms ease;
}

.stem-node:hover,
.stem-node.active {
    background: var(--new-growth);
    box-shadow: 0 0 18px rgba(90, 158, 79, 0.55);
}

.stem-node:hover {
    transform: scale(1.4);
}

.stem-node.active {
    animation: stem-pulse 2s ease-in-out infinite;
}

.stem-leaf {
    position: absolute;
    left: 10px;
    top: -3px;
    width: 18px;
    height: 10px;
    border-top: 1px solid var(--vein-line);
    border-radius: 50%;
    opacity: 0.7;
    transform: rotate(-26deg);
}

@keyframes stem-pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.3); }
}

@keyframes stem-wave {
    0% { opacity: 0; transform: translateX(-50%) translateY(-120%); }
    20% { opacity: 1; }
    100% { opacity: 0; transform: translateX(-50%) translateY(120%); }
}

@keyframes letter-reveal {
    0% { opacity: 0; transform: translateY(20px); }
    100% { opacity: 1; transform: translateY(0); }
}

@keyframes letter-reveal-glow {
    0% { opacity: 0; transform: translateY(20px); text-shadow: 0 0 40px rgba(90, 158, 79, 0.4); }
    70% { text-shadow: 0 0 40px rgba(90, 158, 79, 0.4); }
    100% { opacity: 1; transform: translateY(0); text-shadow: 0 0 0 rgba(90, 158, 79, 0); }
}

@media (max-width: 1180px) {
    .hexagon-grid {
        grid-template-columns: repeat(2, clamp(300px, 38vw, 380px));
        grid-auto-rows: calc(clamp(300px, 38vw, 380px) * 0.89);
        min-height: calc(clamp(300px, 38vw, 380px) * 3.02);
    }

    .hex-cell {
        width: clamp(300px, 38vw, 380px);
        height: calc(clamp(300px, 38vw, 380px) * 1.1547);
    }

    .hex-cell:nth-child(n+3) {
        transform: translateX(50%) scale(0.3) rotate(60deg);
    }

    .hex-cell:nth-child(n+3).visible {
        transform: translateX(50%) scale(1) rotate(0deg);
    }

    .hex-cell:nth-child(n+3):hover,
    .hex-cell:nth-child(n+3).hovered {
        transform: translateX(50%) scale(1.08) rotate(0deg);
    }

    .hexagon-grid.has-hover .hex-cell.visible:nth-child(n+3):not(.hovered) {
        transform: translateX(50%) scale(0.97) rotate(0deg);
    }
}

@media (max-width: 720px) {
    html {
        scroll-snap-type: none;
    }

    .stem-navigation {
        left: 0;
        top: 0;
        width: 100%;
        height: 48px;
        flex-direction: row;
        gap: 1.5rem;
        background: rgba(244, 247, 242, 0.58);
        backdrop-filter: blur(12px);
    }

    .stem-line {
        left: 5%;
        right: 5%;
        top: 50%;
        bottom: auto;
        width: 90%;
        height: 2px;
        transform: translateY(-50%);
        background: linear-gradient(to right, var(--stem-deep), var(--stem-light));
    }

    .stem-wave {
        top: 50%;
        left: var(--wave-start, 0%);
        width: var(--wave-size, 24%);
        height: 8px;
        transform: translateX(-120%) translateY(-50%);
        background: linear-gradient(to right, transparent, var(--new-growth), transparent);
    }

    .stem-navigation.wave-active .stem-wave {
        animation-name: stem-wave-horizontal;
    }

    .stem-leaf {
        left: 2px;
        top: 10px;
    }

    .prototype-section {
        min-height: auto;
        padding: 6rem 1rem 3rem;
    }

    .section-leaf {
        width: 72vw;
        right: -22vw;
    }

    .hexagon-grid {
        display: flex;
        flex-direction: column;
        width: min(100%, 440px);
        min-height: 0;
        gap: 1rem;
    }

    .hex-cell,
    .hex-cell:nth-child(n+3),
    .hex-cell:nth-child(n+4) {
        width: 100%;
        height: auto;
        min-height: 210px;
        clip-path: none;
        border-radius: 24px;
        transform: scale(0.3) rotate(12deg);
    }

    .hex-cell.visible,
    .hex-cell:nth-child(n+3).visible,
    .hex-cell:nth-child(n+4).visible,
    .hexagon-grid.has-hover .hex-cell.visible:nth-child(n+3):not(.hovered),
    .hexagon-grid.has-hover .hex-cell.visible:nth-child(n+4):not(.hovered) {
        transform: scale(1) rotate(0deg);
    }

    .hex-cell:hover,
    .hex-cell.hovered,
    .hex-cell:nth-child(n+3):hover,
    .hex-cell:nth-child(n+3).hovered,
    .hex-cell:nth-child(n+4):hover,
    .hex-cell:nth-child(n+4).hovered {
        transform: scale(1.03) rotate(0deg);
    }

    .section-title {
        font-size: clamp(2.6rem, 16vw, 4.2rem);
    }
}

@keyframes stem-wave-horizontal {
    0% { opacity: 0; transform: translateX(-120%) translateY(-50%); }
    20% { opacity: 1; }
    100% { opacity: 0; transform: translateX(120%) translateY(-50%); }
}
