/* namu.farm — wet glass greenhouse */

:root {
    --reservoir-teal: #0e3b3a;
    --moss-jelly: #5b8a6e;
    --sap-amber: #d8a14a;
    --bauble-cream: #f4ead7;
    --sky-rose: #e9b8a8;
    --annotation-rust: #8a4a2a;
    --shadow-marsh: #1a2826;
    --bubble-clear: rgba(244, 234, 215, 0.18);

    --hex-w: 200px;
    --hex-h: 230px;

    --speed: 1;

    --display-font: "Fraunces", Georgia, serif;
    --rounded-font: "Fredoka", "Trebuchet MS", sans-serif;
    --body-font: "Atkinson Hyperlegible", system-ui, sans-serif;
    --mono-font: "DM Mono", "SFMono-Regular", monospace;
    --hand-font: "Caveat", cursive;
}

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

html, body {
    background: var(--bauble-cream);
    color: var(--shadow-marsh);
    font-family: var(--body-font);
    font-size: clamp(0.95rem, 1.05vw, 1.05rem);
    line-height: 1.65;
    overflow-x: hidden;
}

html {
    scroll-behavior: smooth;
}

body {
    min-height: 100vh;
    position: relative;
}

/* hairline lattice afterimage behind every floor */
.hex-lattice-bg {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 0;
    opacity: 1;
    mix-blend-mode: multiply;
    transition: opacity 1.2s ease-in-out;
}

.hex-lattice-bg.thicken {
    opacity: 3.2;
}

/* Vertical hex-rail navigation pinned right edge */
.hex-rail {
    position: fixed;
    right: 18px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    flex-direction: column;
    gap: 14px;
    z-index: 50;
    padding: 12px 6px;
    background: rgba(244, 234, 215, 0.5);
    border-radius: 18px;
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
}

.rail-node {
    width: 30px;
    height: 36px;
    background: transparent;
    border: 0;
    cursor: pointer;
    padding: 0;
    color: var(--node-color, var(--moss-jelly));
    opacity: 0.45;
    transition: opacity 0.5s ease, transform 0.5s ease;
    position: relative;
}

.rail-node svg {
    width: 100%;
    height: 100%;
    fill: currentColor;
    filter: drop-shadow(0 1px 2px rgba(26, 40, 38, 0.25));
}

.rail-node:hover {
    opacity: 0.85;
    transform: scale(1.1);
}

.rail-node.active {
    opacity: 1;
    color: var(--sap-amber);
    animation: breathing calc(4s / var(--speed)) ease-in-out infinite;
}

.rail-label {
    position: absolute;
    right: 110%;
    top: 50%;
    transform: translateY(-50%);
    font-family: var(--mono-font);
    font-size: 0.7rem;
    color: var(--annotation-rust);
    white-space: nowrap;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

.rail-node:hover .rail-label,
.rail-node.active .rail-label {
    opacity: 0.9;
}

/* Seed badge bottom-left */
.seed-badge {
    position: fixed;
    left: 18px;
    bottom: 18px;
    z-index: 50;
    font-family: var(--mono-font);
    font-size: 0.78rem;
    font-weight: 300;
    color: var(--annotation-rust);
    background: rgba(244, 234, 215, 0.7);
    padding: 6px 12px;
    border-radius: 14px;
    cursor: pointer;
    text-transform: lowercase;
    letter-spacing: 0.04em;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    transition: transform 0.3s ease, background 0.3s ease;
    user-select: none;
}

.seed-badge:hover {
    transform: scale(1.04);
    background: rgba(216, 161, 74, 0.25);
}

.seed-label {
    opacity: 0.55;
    margin-right: 6px;
}

/* Sit-with-her overlay */
.sit-overlay {
    position: fixed;
    inset: 0;
    background: var(--shadow-marsh);
    opacity: 0;
    pointer-events: none;
    z-index: 30;
    transition: opacity 1.4s ease;
}

.sit-overlay.active {
    opacity: 0.12;
}

/* Farm container with scroll-snap */
.farm {
    scroll-snap-type: y mandatory;
    overflow-y: auto;
    height: 100vh;
    position: relative;
    z-index: 1;
}

.floor {
    scroll-snap-align: start;
    min-height: 100vh;
    position: relative;
    padding: 70px 80px 70px 60px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* Floor margin glyph (top-right small hex) */
.floor-margin-glyph {
    position: absolute;
    top: 32px;
    right: 90px;
    width: 14px;
    height: 16px;
    z-index: 10;
    animation: glyph-rotate 9000s linear infinite;
}

.floor.in-view .floor-margin-glyph {
    animation: glyph-rotate 9000s linear infinite, glyph-pulse calc(4s / var(--speed)) ease-in-out infinite;
}

.floor-margin-glyph svg {
    width: 100%;
    height: 100%;
    fill: currentColor;
    filter: drop-shadow(0 0 3px rgba(216, 161, 74, 0.5));
}

@keyframes glyph-rotate {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

@keyframes glyph-pulse {
    0%, 100% { transform: scale(1) rotate(var(--r, 0deg)); }
    50% { transform: scale(1.06) rotate(var(--r, 0deg)); }
}

/* Floor header */
.floor-header {
    margin-bottom: 32px;
    max-width: 60ch;
}

.floor-label {
    font-family: var(--rounded-font);
    font-weight: 500;
    font-size: clamp(0.95rem, 1.4vw, 1.2rem);
    letter-spacing: 0.04em;
    color: var(--annotation-rust);
    text-transform: lowercase;
    display: inline-block;
    margin-bottom: 10px;
}

.floor-title {
    font-family: var(--display-font);
    font-variation-settings: "opsz" 144, "SOFT" 100, "wght" 400;
    font-weight: 400;
    font-size: clamp(2.4rem, 6vw, 4.8rem);
    letter-spacing: -0.02em;
    line-height: 1;
    color: var(--shadow-marsh);
    margin-bottom: 14px;
}

.floor-koan {
    font-family: var(--rounded-font);
    font-weight: 400;
    font-size: clamp(1rem, 1.4vw, 1.2rem);
    letter-spacing: 0.02em;
    color: var(--annotation-rust);
    max-width: 40ch;
}

/* Hex grid: CSS Grid with manual offset trick */
.hex-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, calc(var(--hex-w) * 0.75));
    grid-auto-rows: calc(var(--hex-h) * 0.5);
    gap: 4px 0;
    flex: 1;
    align-content: center;
    justify-content: center;
    position: relative;
    z-index: 2;
}

.hex {
    width: var(--hex-w);
    height: var(--hex-h);
    grid-row: span 2;
    clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
    background: var(--bubble-clear);
    position: relative;
    transition: transform 0.45s cubic-bezier(0.34, 1.56, 0.64, 1), background 0.4s ease, filter 0.4s ease;
    cursor: default;
    border: 1.5px solid transparent;
    overflow: hidden;
}

/* offset every other column */
.hex-grid > .hex:nth-child(even) {
    transform: translateY(calc(var(--hex-h) * 0.5));
}

.hex-inner {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 14% 18%;
    gap: 6px;
}

/* Hex hover: 8% swell + amber inner glow */
.hex:hover {
    transform: scale(1.08);
    background: rgba(216, 161, 74, 0.08);
    filter: drop-shadow(0 0 12px rgba(216, 161, 74, 0.35));
    z-index: 5;
}

.hex-grid > .hex:nth-child(even):hover {
    transform: translateY(calc(var(--hex-h) * 0.5)) scale(1.08);
}

/* Hex border via outline using clip-path inset trick (pseudo lattice border) */
.hex::before {
    content: "";
    position: absolute;
    inset: 1px;
    clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
    background: transparent;
    border: 0;
    box-shadow: inset 0 0 0 1.5px var(--annotation-rust);
    opacity: 0.55;
    pointer-events: none;
    transition: opacity 0.4s ease;
}

.hex:hover::before {
    opacity: 0.85;
}

/* Floor B1 — Reservoir liquid hexes */
.floor--reservoir {
    background: radial-gradient(ellipse at 50% 80%, #133f3e 0%, var(--reservoir-teal) 40%, #082626 100%);
    color: var(--bauble-cream);
}

.floor--reservoir .floor-title { color: var(--bauble-cream); }
.floor--reservoir .floor-label { color: var(--sap-amber); }
.floor--reservoir .floor-koan { color: var(--sky-rose); opacity: 0.85; }

.hex--liquid {
    background: linear-gradient(180deg, rgba(91, 138, 110, 0.28) 0%, rgba(14, 59, 58, 0.6) 100%);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
}

.hex--liquid .hex-inner::before {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, transparent 30%, rgba(91, 138, 110, 0.4) 70%, rgba(14, 59, 58, 0.7) 100%);
    animation: liquid-ripple calc(8s / var(--speed)) ease-in-out infinite;
    z-index: -1;
}

@keyframes liquid-ripple {
    0%, 100% { transform: translateY(0) scale(1); }
    50% { transform: translateY(-2%) scale(1.02); }
}

.hex-data {
    font-family: var(--mono-font);
    font-weight: 300;
    font-size: 0.78rem;
    color: var(--bauble-cream);
    text-transform: lowercase;
    letter-spacing: 0.02em;
    opacity: 0.85;
}

.hex--liquid .hex-data {
    color: var(--bauble-cream);
}

.bubble-canvas {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 3;
}

/* Floor 1 — Sprout Bay */
.floor--sprouts {
    background: radial-gradient(ellipse at 30% 70%, #f7f0dd 0%, var(--bauble-cream) 50%, #ead9b8 100%);
}

.hex--sprout .pixel-sprite {
    width: 64%;
    height: 50%;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
    shape-rendering: crispEdges;
}

.hex--sprout .sprout-name {
    font-family: var(--display-font);
    font-variation-settings: "opsz" 144, "SOFT" 100, "wght" 400;
    font-size: 1.05rem;
    color: var(--shadow-marsh);
    margin-top: 2px;
    line-height: 1;
}

.hex--sprout .sprout-story {
    font-family: var(--body-font);
    font-size: 0.66rem;
    color: var(--annotation-rust);
    line-height: 1.35;
    max-width: 90%;
    opacity: 0.85;
}

.hex--sprout .sprout-data {
    font-family: var(--mono-font);
    font-weight: 300;
    font-size: 0.62rem;
    color: var(--moss-jelly);
    text-transform: lowercase;
}

/* Floor 2 — Growth Hall */
.floor--growth {
    background: radial-gradient(ellipse at 70% 30%, #e3edd9 0%, #d5e3c9 50%, #b8cdb1 100%);
}

.hex--vignette {
    background: rgba(244, 234, 215, 0.55);
}

.iso-icon {
    width: 60%;
    height: 50%;
    animation: iso-rotate calc(60s / var(--speed)) linear infinite;
    transform-origin: center;
}

@keyframes iso-rotate {
    0%, 100% { transform: rotate(0deg); }
    25% { transform: rotate(2deg); }
    75% { transform: rotate(-2deg); }
}

.vignette-title {
    font-family: var(--rounded-font);
    font-weight: 500;
    font-size: 0.95rem;
    color: var(--shadow-marsh);
    text-transform: lowercase;
    letter-spacing: 0.02em;
}

.hex--visitors {
    background: rgba(216, 161, 74, 0.12);
}

.visitor-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin-top: 6px;
}

.visitor-list li {
    font-family: var(--mono-font);
    font-weight: 300;
    font-size: 0.78rem;
    color: var(--annotation-rust);
    text-transform: lowercase;
    letter-spacing: 0.04em;
}

/* Floor 3 — Canopy (sparse, position absolute) */
.floor--canopy {
    background: radial-gradient(ellipse at 50% 100%, #f5e3d7 0%, #f4ead7 50%, #ecd9bd 100%);
}

.canopy-field {
    position: relative;
    flex: 1;
    width: 100%;
}

.hex--sky {
    position: absolute;
    left: var(--cx, 50%);
    top: var(--cy, 50%);
    transform: translate(-50%, -50%);
    width: 160px;
    height: 184px;
    background: rgba(233, 184, 168, 0.28);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
    animation: sky-drift calc(22s / var(--speed)) ease-in-out infinite;
    animation-delay: var(--ad, 0s);
}

.hex--sky:hover {
    transform: translate(-50%, -50%) scale(1.08);
}

.hex--sky:nth-of-type(2) { --ad: -5s; }
.hex--sky:nth-of-type(3) { --ad: -9s; }
.hex--sky:nth-of-type(4) { --ad: -3s; }
.hex--sky:nth-of-type(5) { --ad: -14s; }

@keyframes sky-drift {
    0%, 100% { translate: 0 0; }
    33% { translate: -8px 6px; }
    66% { translate: 5px -7px; }
}

.hex--sky .vignette-title {
    color: var(--annotation-rust);
}

.hex--sky .hex-data {
    color: var(--annotation-rust);
}

/* Crystalline shards drifting */
.shard {
    position: absolute;
    left: var(--sx, 50%);
    top: var(--sy, 50%);
    width: 24px;
    height: 24px;
    pointer-events: none;
    animation: shard-float calc(28s / var(--speed)) ease-in-out infinite;
    animation-delay: var(--sd, 0s);
    filter: drop-shadow(0 0 4px rgba(233, 184, 168, 0.5));
}

@keyframes shard-float {
    0%, 100% {
        transform: translate(0, 0) rotate(0deg);
        opacity: 0.7;
    }
    25% {
        transform: translate(40px, -20px) rotate(90deg);
        opacity: 0.9;
    }
    50% {
        transform: translate(60px, 20px) rotate(180deg);
        opacity: 0.6;
    }
    75% {
        transform: translate(20px, 40px) rotate(270deg);
        opacity: 0.85;
    }
}

/* Floor 4 — Skylight */
.floor--skylight {
    background: radial-gradient(ellipse at 50% 30%, #fbeee0 0%, var(--sky-rose) 50%, #d89b87 100%);
    align-items: center;
    justify-content: center;
}

.skylight-stage {
    position: relative;
    width: 100%;
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.annotation {
    position: absolute;
    font-family: var(--hand-font);
    font-weight: 500;
    font-size: clamp(1.4rem, 2.2vw, 2.1rem);
    color: var(--annotation-rust);
    transform: rotate(-6deg);
    pointer-events: none;
    opacity: 0.85;
}

.annotation--left {
    left: 8%;
    top: 22%;
}

.annotation--right {
    right: 6%;
    bottom: 22%;
    transform: rotate(4deg);
}

.hex--skylight {
    width: clamp(360px, 52vw, 640px);
    height: clamp(414px, 60vw, 736px);
    background: radial-gradient(ellipse at 35% 30%, rgba(244, 234, 215, 0.92) 0%, rgba(233, 184, 168, 0.6) 60%, rgba(216, 161, 74, 0.4) 100%);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    box-shadow: 0 30px 80px rgba(26, 40, 38, 0.18);
}

.hex--skylight .hex-inner {
    padding: 8%;
    gap: 14px;
}

.namu-mark {
    font-family: var(--display-font);
    font-variation-settings: "opsz" 144, "SOFT" 100, "wght" 400;
    font-size: clamp(3.8rem, 8vw, 6.4rem);
    line-height: 1;
    letter-spacing: -0.04em;
    color: var(--shadow-marsh);
    margin-bottom: 4px;
}

.tree-stage {
    width: 60%;
    height: 36%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.tree-stage svg {
    width: 100%;
    height: 100%;
}

.tree-name {
    font-family: var(--display-font);
    font-variation-settings: "opsz" 144, "SOFT" 100, "wght" 400;
    font-size: clamp(1.6rem, 3.2vw, 2.6rem);
    line-height: 1.05;
    color: var(--annotation-rust);
}

.tree-story {
    font-family: var(--body-font);
    font-size: clamp(0.85rem, 1vw, 0.95rem);
    color: var(--shadow-marsh);
    max-width: 32ch;
    line-height: 1.55;
    opacity: 0.85;
}

.tree-meta {
    font-family: var(--mono-font);
    font-weight: 300;
    font-size: 0.78rem;
    color: var(--annotation-rust);
    text-transform: lowercase;
}

.hex--sit {
    position: absolute;
    bottom: 8%;
    right: 14%;
    width: 180px;
    height: 207px;
    background: rgba(216, 161, 74, 0.25);
    border: 0;
    cursor: pointer;
    transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1), background 0.4s ease;
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
    color: inherit;
    font-family: inherit;
}

.hex--sit:hover {
    transform: scale(1.08);
    background: rgba(216, 161, 74, 0.45);
}

.hex--sit.active {
    background: rgba(91, 138, 110, 0.45);
}

.sit-text {
    font-family: var(--hand-font);
    font-weight: 500;
    font-size: 1.4rem;
    color: var(--annotation-rust);
    line-height: 1.2;
    max-width: 80%;
    text-align: center;
}

/* Inflated 3D sapling form */
.sapling-svg {
    width: 100%;
    height: 100%;
    animation: breathing calc(0.6s * 10 / var(--speed)) ease-in-out infinite;
    animation-delay: var(--breath-delay, 0s);
}

@keyframes breathing {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.015); }
}

/* Pixel sprite breathing */
.pixel-sprite {
    animation: pixel-sway calc(0.5s / var(--speed)) steps(2) infinite;
}

@keyframes pixel-sway {
    0% { transform: translateX(0); }
    50% { transform: translateX(1px); }
    100% { transform: translateX(0); }
}

/* During "sit", slow all breathing/sway */
body.sitting {
    --speed: 0.5;
}

/* When dim is active, the page lowers brightness slightly */
body.sitting .farm {
    filter: brightness(0.92);
    transition: filter 1s ease;
}

/* Reservoir floor's hexes inherit liquid border color tweak */
.floor--reservoir .hex::before {
    box-shadow: inset 0 0 0 1.5px rgba(244, 234, 215, 0.35);
    opacity: 0.7;
}

/* Skylight hex border: warmer */
.floor--skylight .hex::before {
    box-shadow: inset 0 0 0 2px var(--annotation-rust);
    opacity: 0.5;
}

/* Floor 4 hex--sit border */
.hex--sit::before {
    content: "";
    position: absolute;
    inset: 1px;
    clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
    box-shadow: inset 0 0 0 1.5px var(--annotation-rust);
    opacity: 0.6;
    pointer-events: none;
}

/* Responsive tweaks */
@media (max-width: 900px) {
    :root { --hex-w: 150px; --hex-h: 173px; }
    .floor { padding: 60px 50px 60px 30px; }
    .hex-rail { right: 8px; gap: 10px; padding: 8px 4px; }
    .rail-node { width: 22px; height: 26px; }
    .rail-label { display: none; }
    .annotation--left { left: 4%; top: 12%; }
    .annotation--right { right: 4%; bottom: 12%; }
    .hex--sit { right: 4%; bottom: 4%; width: 130px; height: 150px; }
}

@media (max-width: 560px) {
    :root { --hex-w: 110px; --hex-h: 127px; }
    .floor { padding: 50px 40px 50px 20px; }
    .floor-title { font-size: clamp(2rem, 9vw, 3rem); }
    .hex--sit { width: 110px; height: 127px; }
    .sit-text { font-size: 1rem; }
}

/* Floor reservoir slightly thicker liquid feel */
.floor--reservoir .hex--liquid {
    box-shadow: inset 0 0 24px rgba(91, 138, 110, 0.25);
}

/* Currently in-view floor visual hint via lattice thickening handled by JS class */
