:root {
    --deep-moss: #1A2E1A;
    --aged-linen: #E8E0D4;
    --warm-charcoal: #2C2C28;
    --faded-lichen: #A8B5A0;
    --kintsugi-gold: #C4943A;
    --forest-shadow: #0D1F0D;
    --celadon: #7BA88C;
    --fired-clay: #B5654A;
    --porcelain: #F2EDE6;
    --stone-wash: #D4CFC6;
    color-scheme: dark;
}

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

body {
    background-color: var(--deep-moss);
    color: var(--faded-lichen);
    font-family: 'Source Sans 3', sans-serif;
    font-weight: 400;
    font-size: clamp(0.95rem, 1.8vw, 1.1rem);
    line-height: 1.75;
    letter-spacing: 0.01em;
    overflow-x: hidden;
}

/* Bento Trays */
.bento-tray {
    max-width: 1100px;
    margin: 0 auto;
    padding: 16px;
    position: relative;
}

.bento-tray + .bento-tray {
    margin-top: 0;
}

/* Cells */
.cell {
    background: var(--aged-linen);
    color: var(--warm-charcoal);
    border-radius: 8px 4px 12px 6px;
    padding: 32px;
    position: relative;
    overflow: hidden;
}

/* Hero */
.tray-hero {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
}

.cell-hero {
    background: transparent;
    color: var(--faded-lichen);
    text-align: center;
    padding: 0;
}

.hero-title {
    font-family: 'EB Garamond', serif;
    font-weight: 700;
    font-size: clamp(3rem, 10vw, 8rem);
    letter-spacing: 0.05em;
    line-height: 1.15;
    color: var(--porcelain);
    position: relative;
}

.kintsugi-cracks {
    width: min(400px, 80vw);
    height: 80px;
    margin-top: -30px;
    position: relative;
}

.crack-line {
    stroke-dasharray: 400;
    stroke-dashoffset: 400;
    animation: drawCrack 3s ease-out forwards;
    filter: drop-shadow(0 0 3px rgba(196, 148, 58, 0.4));
}

.crack-delay {
    animation-delay: 1s;
}

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

.hero-sub {
    font-family: 'EB Garamond', serif;
    font-style: italic;
    font-size: clamp(1rem, 2vw, 1.4rem);
    color: var(--faded-lichen);
    margin-top: 24px;
    opacity: 0.7;
}

.meander-border {
    width: min(600px, 80vw);
    height: 2px;
    background: var(--kintsugi-gold);
    opacity: 0.5;
    margin-top: 40px;
}

/* 3-column tray */
.tray-3col {
    display: grid;
    grid-template-columns: 2fr 1fr;
    grid-template-rows: 1fr 1fr;
    gap: 16px;
}

.tray-3col .cell-large {
    grid-row: 1 / 3;
}

/* 2-column tray */
.tray-2col {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

/* 4-column micro tray */
.tray-4col {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
}

/* Full-width tray */
.tray-full {
    display: flex;
    justify-content: center;
    padding: 16px;
}

.cell-statement {
    background: transparent;
    padding: 8vh 32px;
    text-align: center;
}

/* Section Title */
.section-title {
    font-family: 'EB Garamond', serif;
    font-weight: 500;
    font-size: clamp(1.5rem, 3vw, 2.8rem);
    letter-spacing: 0.02em;
    line-height: 1.15;
    color: var(--warm-charcoal);
    margin-bottom: 20px;
}

.body-text {
    margin-bottom: 1.2rem;
}

/* Illustration cells */
.cell-illustration {
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--porcelain);
}

.illustration {
    width: 100%;
    max-width: 160px;
    height: auto;
}

.illustration-large {
    width: min(200px, 50vw);
    height: auto;
}

/* Draw animation */
.draw-line {
    stroke-dasharray: 500;
    stroke-dashoffset: 500;
    transition: stroke-dashoffset 2s ease-out;
}

.draw-delay {
    transition-delay: 0.3s;
}

.draw-delay-2 {
    transition-delay: 0.6s;
}

.cell.revealed .draw-line {
    stroke-dashoffset: 0;
}

/* Code block */
.cell-code {
    background: var(--porcelain);
    padding: 24px;
    border-left: 4px solid var(--kintsugi-gold);
    display: flex;
    align-items: center;
}

.code-block {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.85rem;
    line-height: 1.6;
    color: var(--warm-charcoal);
    white-space: pre-wrap;
    margin: 0;
}

.code-kw { color: var(--celadon); }
.code-fn { color: var(--fired-clay); }

/* Micro cells */
.cell-micro {
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.cell-marble {
    background: var(--porcelain);
}

.marble-tile {
    width: 100%;
    height: 100%;
    position: relative;
}

.marble-tile::before {
    content: '';
    position: absolute;
    inset: 0;
    background:
        linear-gradient(135deg, transparent 40%, rgba(212, 207, 198, 0.4) 50%, transparent 60%),
        linear-gradient(45deg, transparent 45%, rgba(212, 207, 198, 0.3) 50%, transparent 55%);
}

.marble-alt::before {
    background:
        linear-gradient(160deg, transparent 35%, rgba(212, 207, 198, 0.5) 45%, transparent 55%),
        linear-gradient(70deg, transparent 50%, rgba(196, 148, 58, 0.15) 55%, transparent 60%);
}

.cell-kanji {
    background: var(--deep-moss);
}

.kanji-char {
    font-family: 'EB Garamond', serif;
    font-size: 2.5rem;
    color: var(--faded-lichen);
    opacity: 0.5;
}

/* Pull Quote */
.pull-quote {
    font-family: 'EB Garamond', serif;
    font-style: italic;
    font-weight: 400;
    font-size: clamp(2rem, 5vw, 4rem);
    color: var(--porcelain);
    letter-spacing: 0.02em;
    line-height: 1.3;
    opacity: 0.85;
}

/* Gold Seams */
.gold-seam {
    position: absolute;
    background: var(--kintsugi-gold);
    z-index: 5;
    pointer-events: none;
    filter: drop-shadow(0 0 3px rgba(196, 148, 58, 0.4));
    transition: opacity 0.3s ease, filter 0.3s ease;
}

.seam-vertical {
    width: 2px;
    height: 60%;
    top: 20%;
    right: calc(33.33% - 1px);
    opacity: 0.5;
}

.seam-center {
    width: 2px;
    height: 70%;
    top: 15%;
    left: calc(50% - 1px);
    opacity: 0.5;
}

/* Ending */
.cell-ending {
    background: transparent;
    text-align: center;
    padding: 8vh 24px;
}

.ending-text {
    font-family: 'EB Garamond', serif;
    font-style: italic;
    font-size: clamp(1rem, 2vw, 1.4rem);
    color: var(--faded-lichen);
    margin-top: 24px;
    opacity: 0.6;
}

.tray-final {
    padding-bottom: 10vh;
}

/* Reveal */
[data-reveal] {
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 1.2s cubic-bezier(0.25, 0.1, 0.25, 1), transform 1.2s cubic-bezier(0.25, 0.1, 0.25, 1);
}

[data-reveal].revealed {
    opacity: 1;
    transform: translateY(0);
}

/* Responsive */
@media (max-width: 768px) {
    .tray-3col,
    .tray-2col,
    .tray-4col {
        grid-template-columns: 1fr;
    }

    .tray-3col .cell-large {
        grid-row: auto;
    }

    .tray-4col {
        grid-template-columns: 1fr 1fr;
    }

    .cell-micro {
        aspect-ratio: auto;
        min-height: 120px;
    }

    .gold-seam {
        display: none;
    }

    .cell {
        border-radius: 6px;
    }
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
    .crack-line {
        animation: none;
        stroke-dashoffset: 0;
    }

    .draw-line {
        stroke-dashoffset: 0;
        transition: none;
    }

    [data-reveal] {
        opacity: 1;
        transform: none;
        transition: none;
    }
}
