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

:root {
    --ground: #0c0e1a;
    --surface: #161822;
    --emerald: #1b7a4e;
    --amethyst: #6b3fa0;
    --sapphire: #2656a6;
    --ruby: #a63248;
    --frost: #e2e0dd;
    --lichen: #8a8b8e;
    --gold: #c9a84c;
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: var(--ground);
    font-family: 'DM Sans', sans-serif;
    font-weight: 300;
    color: var(--frost);
    font-feature-settings: 'kern' 1, 'liga' 1;
}

body {
    text-rendering: optimizeSpeed;
}

#bento-frame {
    position: absolute;
    inset: 24px;
    display: grid;
    grid-template-columns: 1.6fr 1fr 1fr;
    grid-template-rows: 1.2fr 1fr;
    grid-template-areas:
        "a b c"
        "a d e";
    gap: 4px;
}

.bento-cell {
    position: relative;
    background: var(--surface);
    overflow: hidden;
    padding: 32px;
    display: flex;
    align-items: flex-start;
    justify-content: flex-start;
    background-image:
        radial-gradient(circle at 2px 2px, rgba(226,224,221,0.04) 1px, transparent 1px);
    background-size: 24px 24px;
}

#cell-a {
    grid-area: a;
    align-items: center;
    justify-content: center;
    background: radial-gradient(ellipse at 30% 70%, rgba(27,122,78,0.12) 0%, transparent 60%),
                radial-gradient(ellipse at 80% 20%, rgba(107,63,160,0.08) 0%, transparent 50%),
                var(--surface);
    background-image:
        radial-gradient(ellipse at 30% 70%, rgba(27,122,78,0.12) 0%, transparent 60%),
        radial-gradient(ellipse at 80% 20%, rgba(107,63,160,0.08) 0%, transparent 50%),
        radial-gradient(circle at 2px 2px, rgba(226,224,221,0.04) 1px, transparent 1px);
    background-size: 100% 100%, 100% 100%, 24px 24px;
}

#cell-b {
    grid-area: b;
    flex-direction: column;
    justify-content: flex-end;
}

#cell-c {
    grid-area: c;
    align-items: flex-end;
}

#cell-d {
    grid-area: d;
    align-items: center;
    justify-content: center;
}

#cell-e {
    grid-area: e;
    flex-direction: column;
    justify-content: center;
}

.cell-content {
    opacity: 1;
    transition: opacity 400ms ease-out;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.cell-content.fading-out {
    opacity: 0;
    transition: opacity 400ms ease-out;
}

.cell-content.fading-in {
    opacity: 0;
    animation: fadeIn 600ms ease-in forwards;
}

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

.cell-border-overlay {
    position: absolute;
    inset: 0;
    border: 2px solid transparent;
    opacity: 0;
    transition: opacity 300ms ease;
    pointer-events: none;
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='60' height='60'%3E%3Cpath d='M10 0 L20 10 L15 25 L0 20 Z M30 5 L45 0 L50 15 L35 20 Z M55 25 L60 40 L50 50 L40 35 Z M5 35 L20 30 L25 45 L10 55 Z M30 40 L45 45 L40 60 L25 55 Z' fill='none' stroke='%23c9a84c' stroke-width='0.5' opacity='0.4'/%3E%3C/svg%3E") repeat;
    -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    padding: 4px;
}

.bento-cell:hover .cell-border-overlay {
    opacity: 0.2;
    transition: opacity 300ms ease;
}

.bento-cell:not(:hover) .cell-border-overlay {
    transition: opacity 500ms ease;
}

.cell-title {
    font-family: 'DM Serif Display', serif;
    font-weight: 400;
    font-size: clamp(2.2rem, 5vw, 5rem);
    letter-spacing: 0.02em;
    line-height: 1.08;
    text-rendering: optimizeLegibility;
    color: var(--frost);
    margin-bottom: 0.4em;
}

#cell-b .cell-title {
    font-size: clamp(1.4rem, 2.5vw, 2.2rem);
    text-transform: lowercase;
}

.cell-body {
    font-family: 'DM Sans', sans-serif;
    font-weight: 300;
    font-size: clamp(0.95rem, 1.4vw, 1.15rem);
    letter-spacing: 0.03em;
    line-height: 1.65;
    color: var(--frost);
    max-width: 38ch;
}

.cell-label {
    font-family: 'DM Mono', monospace;
    font-weight: 400;
    font-size: 0.75rem;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--lichen);
    font-variant-numeric: tabular-nums;
    margin-bottom: 1em;
    display: block;
}

.cell-illustration {
    width: 100%;
    max-width: 280px;
    height: auto;
    margin: 0 auto 1.5em;
}

.cell-illustration svg {
    width: 100%;
    height: auto;
    display: block;
}

.illustration-svg {
    position: absolute;
    width: 0;
    height: 0;
    overflow: hidden;
}

.draw-path path,
.draw-path line,
.draw-path rect,
.draw-path polygon,
.draw-path circle {
    stroke-dasharray: 1000;
    stroke-dashoffset: 1000;
    transition: stroke-dashoffset 2.5s ease-in-out;
}

.draw-path.revealed path,
.draw-path.revealed line,
.draw-path.revealed rect,
.draw-path.revealed polygon,
.draw-path.revealed circle {
    stroke-dashoffset: 0;
}

/* State dots */
#state-dots {
    position: fixed;
    bottom: 16px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 4px;
    z-index: 100;
}

.dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    border: none;
    background: rgba(138, 139, 142, 0.3);
    cursor: pointer;
    padding: 0;
    transition: background-color 400ms ease;
}

.dot.active {
    background: var(--emerald);
}

/* Frost particles */
.frost-particle {
    position: absolute;
    border-radius: 50%;
    background: rgba(226, 224, 221, 0.15);
    pointer-events: none;
    animation: floatUp 3s ease-out forwards;
}

@keyframes floatUp {
    from {
        opacity: 0.15;
        transform: translateY(0) translateX(var(--dx));
    }
    to {
        opacity: 0;
        transform: translateY(-40px) translateX(var(--dx));
    }
}

/* Responsive */
@media (max-width: 768px) {
    #bento-frame {
        grid-template-columns: 1fr 1fr;
        grid-template-rows: 1.5fr 1fr 1fr;
        grid-template-areas:
            "a a"
            "b c"
            "d e";
    }
}

@media (max-width: 480px) {
    #bento-frame {
        grid-template-columns: 1fr;
        grid-template-rows: repeat(5, 1fr);
        grid-template-areas:
            "a"
            "b"
            "c"
            "d"
            "e";
    }

    .bento-cell {
        padding: 20px;
    }
}
