/* ========================================
   lunchbox.dev — Styles
   Honeycomb developer toolkit portal
   ======================================== */

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

:root {
    --deep-night: #1a1027;
    --deep-night-mid: #2a1f3d;
    --candle-glow: #f0a830;
    --ember: #d4622b;
    --twilight-blue: #5b6abf;
    --dawn-lilac: #9b8ec4;
    --parchment: #f5f0e8;
    --wick: #fff4d6;
    --charcoal: #12091c;

    --font-display: 'Baloo 2', cursive;
    --font-body: 'Nunito', sans-serif;
    --font-code: 'Fira Code', monospace;

    --hex-w: 280px;
    --hex-h: 320px;
    --hex-gap: 3px;
}

html {
    scroll-behavior: smooth;
}

body.lunchbox-night {
    background: linear-gradient(135deg, #1a1027 0%, #2a1f3d 50%, #1a1027 100%);
    color: var(--parchment);
    font-family: var(--font-body);
    font-size: clamp(0.95rem, 1.8vw, 1.15rem);
    line-height: 1.65;
    min-height: 100vh;
    overflow-x: hidden;
}

/* --- Lid (Header) --- */
.lid {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
    background: linear-gradient(180deg, #12091c 0%, #1a1027 100%);
    border-bottom: 2px solid var(--candle-glow);
    box-shadow: 0 4px 20px rgba(240, 168, 48, 0.15);
}

.lid-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    max-width: 1400px;
    margin: 0 auto;
    padding: 0.6rem 2rem;
}

.clasp-logo {
    flex-shrink: 0;
}

.clasp-svg {
    width: 180px;
    height: 45px;
}

.clasp-left, .clasp-right {
    transition: transform 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.clasp-logo.opened .clasp-left {
    transform: translateX(-8px) rotate(-5deg);
    transform-origin: 30px 25px;
}

.clasp-logo.opened .clasp-right {
    transform: translateX(8px) rotate(5deg);
    transform-origin: 170px 25px;
}

.lid-nav {
    display: flex;
    list-style: none;
    gap: 0.25rem;
}

.lid-nav li a {
    display: block;
    padding: 0.5rem 1.2rem;
    color: var(--parchment);
    text-decoration: none;
    font-family: var(--font-body);
    font-weight: 600;
    font-size: 0.9rem;
    clip-path: polygon(15% 0%, 85% 0%, 100% 50%, 85% 100%, 15% 100%, 0% 50%);
    background: var(--twilight-blue);
    transition: background 0.3s, color 0.3s;
}

.lid-nav li a:hover {
    background: var(--candle-glow);
    color: var(--deep-night);
}

/* --- Lid Panel (Opening Animation) --- */
.lid-panel {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(180deg, #12091c, #1a1027);
    z-index: 200;
    transform-origin: top center;
    transition: transform 1.8s cubic-bezier(0.65, 0, 0.35, 1), opacity 0.4s ease 1.6s;
    border-bottom: 4px solid var(--candle-glow);
}

.lid-panel.opened {
    transform: perspective(800px) rotateX(-95deg);
    opacity: 0;
    pointer-events: none;
}

/* --- Compartments (Main) --- */
.compartments {
    position: relative;
    padding: 100px 2rem 4rem;
    min-height: 100vh;
}

.hex-life-bg {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    pointer-events: none;
    opacity: 0;
    transition: opacity 1s ease 2.5s;
}

body.revealed .hex-life-bg {
    opacity: 1;
}

/* --- Hex Grid --- */
.hex-grid {
    position: relative;
    z-index: 1;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem 0;
}

/* --- Hex Cell --- */
.hex-cell {
    width: var(--hex-w);
    height: var(--hex-h);
    clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
    background: var(--twilight-blue);
    margin: calc(var(--hex-gap) * -6) var(--hex-gap);
    position: relative;
    cursor: pointer;
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), filter 0.3s;
    opacity: 0;
    transform: scale(0.6);
}

.hex-cell.revealed {
    opacity: 1;
    transform: scale(1);
    transition: opacity 0.4s ease, transform 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Offset odd rows */
.hex-cell:nth-child(even) {
    margin-top: calc(var(--hex-h) * -0.12);
}

/* Inner content area clipped smaller to show border glow */
.hex-cell::before {
    content: '';
    position: absolute;
    inset: 3px;
    clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
    background: var(--deep-night);
    z-index: 0;
}

.hex-cell::after {
    content: '';
    position: absolute;
    inset: 0;
    clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
    box-shadow: inset 0 0 30px rgba(240, 168, 48, 0.05);
    z-index: 1;
    pointer-events: none;
    transition: box-shadow 0.4s;
}

.hex-cell:hover {
    transform: scale(1.05);
    z-index: 10;
}

.hex-cell:hover::after {
    box-shadow: inset 0 0 40px rgba(240, 168, 48, 0.25);
}

.hex-cell.glow-bright::after {
    box-shadow: inset 0 0 50px rgba(240, 168, 48, 0.3);
}

.hex-cell.glow-dim::after {
    box-shadow: inset 0 0 8px rgba(240, 168, 48, 0.03);
}

/* --- Candle Flame --- */
.candle-flame {
    position: absolute;
    top: 12%;
    left: 50%;
    transform: translateX(-50%);
    z-index: 5;
    pointer-events: none;
}

.flame-svg {
    width: 16px;
    height: 24px;
    filter: blur(0.5px);
}

.flame-path {
    animation: flameFlicker 0.8s ease-in-out infinite alternate;
    transform-origin: center bottom;
    fill: var(--candle-glow);
    opacity: 0.3;
    transition: opacity 0.3s;
}

.hex-cell:hover .flame-path {
    opacity: 1;
}

@keyframes flameFlicker {
    0% { transform: scaleY(0.95) scaleX(1) skewX(-2deg); }
    25% { transform: scaleY(1.05) scaleX(0.95) skewX(3deg); }
    50% { transform: scaleY(0.98) scaleX(1.02) skewX(-1deg); }
    75% { transform: scaleY(1.03) scaleX(0.98) skewX(2deg); }
    100% { transform: scaleY(1.05) scaleX(0.97) skewX(-3deg); }
}

/* --- Cell Content --- */
.cell-content {
    position: relative;
    z-index: 2;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    height: 100%;
    padding: 25% 12% 20%;
}

.hex-icon {
    width: 50px;
    height: 50px;
    clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
    background: var(--twilight-blue);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 0.6rem;
    padding: 8px;
}

.hex-icon svg {
    width: 100%;
    height: 100%;
}

.cell-content h3 {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: clamp(1.1rem, 2vw, 1.4rem);
    color: var(--wick);
    margin-bottom: 0.3rem;
    letter-spacing: 0.01em;
}

.cell-content p {
    font-size: 0.8rem;
    color: var(--dawn-lilac);
    line-height: 1.4;
}

/* --- Glitch Effect --- */
.hex-cell.glitching {
    animation: glitchBorder 0.3s steps(4);
}

@keyframes glitchBorder {
    0%, 100% { background: var(--twilight-blue); }
    25% { background: var(--candle-glow); }
    50% { background: var(--ember); }
    75% { background: var(--candle-glow); }
}

.hex-cell.glitching .cell-content {
    animation: glitchRGB 0.3s steps(3);
}

@keyframes glitchRGB {
    0% { filter: none; }
    33% { filter: saturate(2) hue-rotate(20deg); transform: translateX(2px); }
    66% { filter: saturate(0.5) hue-rotate(-20deg); transform: translateX(-2px); }
    100% { filter: none; transform: translateX(0); }
}

/* --- Thermos Sidebar --- */
.thermos {
    position: fixed;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 180px;
    z-index: 50;
    display: none;
}

@media (min-width: 1440px) {
    .thermos {
        display: block;
    }
}

.thermos-cap {
    background: var(--candle-glow);
    color: var(--deep-night);
    font-family: var(--font-display);
    font-weight: 700;
    text-align: center;
    padding: 0.5rem;
    border-radius: 50% 50% 0 0 / 30% 30% 0 0;
    font-size: 0.85rem;
}

.thermos-body {
    background: rgba(26, 16, 39, 0.9);
    border-left: 2px solid var(--candle-glow);
    border-right: 2px solid var(--candle-glow);
    border-bottom: 2px solid var(--candle-glow);
    border-radius: 0 0 50% 50% / 0 0 8% 8%;
    max-height: 400px;
    overflow: hidden;
    padding: 0.5rem;
}

.ticker {
    animation: tickerScroll 30s linear infinite;
}

.tick-item {
    padding: 0.5rem 0.3rem;
    font-size: 0.72rem;
    line-height: 1.4;
    border-bottom: 1px solid rgba(240, 168, 48, 0.15);
    color: var(--parchment);
}

.tick-time {
    display: block;
    color: var(--candle-glow);
    font-weight: 700;
    font-size: 0.65rem;
    margin-bottom: 0.15rem;
}

@keyframes tickerScroll {
    0% { transform: translateY(0); }
    100% { transform: translateY(-50%); }
}

/* --- Napkin Footer --- */
.napkin {
    position: relative;
    background: var(--parchment);
    padding: 4rem 2rem 3rem;
    margin-top: 4rem;
    box-shadow:
        inset 0 8px 20px rgba(18, 9, 28, 0.08),
        inset 5px 0 15px rgba(18, 9, 28, 0.04),
        inset -5px 0 15px rgba(18, 9, 28, 0.04);
}

.napkin::before {
    content: '';
    position: absolute;
    top: -20px;
    left: 10%;
    right: 10%;
    height: 20px;
    background: var(--parchment);
    clip-path: polygon(0% 100%, 5% 30%, 10% 80%, 20% 10%, 30% 70%, 40% 20%, 50% 90%, 60% 15%, 70% 75%, 80% 25%, 90% 60%, 95% 20%, 100% 100%);
}

.doodles {
    display: block;
    width: 100%;
    max-width: 700px;
    height: 120px;
    margin: 0 auto 2rem;
}

.doodle-path {
    stroke-dasharray: 300;
    stroke-dashoffset: 300;
    transition: stroke-dashoffset 1.5s ease;
}

.napkin.visible .doodle-path {
    stroke-dashoffset: 0;
}

.napkin.visible .doodle-path:nth-child(2) { transition-delay: 0.1s; }
.napkin.visible .doodle-path:nth-child(3) { transition-delay: 0.2s; }
.napkin.visible .doodle-path:nth-child(4) { transition-delay: 0.3s; }
.napkin.visible .doodle-path:nth-child(5) { transition-delay: 0.4s; }
.napkin.visible .doodle-path:nth-child(6) { transition-delay: 0.5s; }
.napkin.visible .doodle-path:nth-child(7) { transition-delay: 0.6s; }
.napkin.visible .doodle-path:nth-child(8) { transition-delay: 0.7s; }

.napkin-text {
    text-align: center;
    color: var(--deep-night);
}

.napkin-brand {
    font-family: var(--font-display);
    font-weight: 800;
    font-size: clamp(1.8rem, 4vw, 2.8rem);
    color: var(--deep-night);
    margin-bottom: 0.3rem;
}

.napkin-tagline {
    font-size: 1rem;
    color: var(--twilight-blue);
    margin-bottom: 1.5rem;
}

.napkin-links {
    display: flex;
    gap: 1.5rem;
    justify-content: center;
    margin-bottom: 1.5rem;
}

.napkin-links a {
    color: var(--ember);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.9rem;
    transition: color 0.2s;
}

.napkin-links a:hover {
    color: var(--candle-glow);
}

.napkin-copy {
    font-size: 0.8rem;
    color: var(--dawn-lilac);
}

/* --- Hex Overlay (expanded cell) --- */
.hex-overlay {
    position: fixed;
    inset: 0;
    z-index: 300;
    background: rgba(18, 9, 28, 0.92);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
}

.hex-overlay.active {
    opacity: 1;
    pointer-events: all;
}

.overlay-content {
    background: var(--deep-night);
    border: 2px solid var(--candle-glow);
    border-radius: 16px;
    max-width: 600px;
    width: 90%;
    padding: 2.5rem;
    position: relative;
    box-shadow: 0 0 60px rgba(240, 168, 48, 0.2);
    transform: scale(0.9);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.hex-overlay.active .overlay-content {
    transform: scale(1);
}

.overlay-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: none;
    border: none;
    color: var(--candle-glow);
    font-size: 2rem;
    cursor: pointer;
    line-height: 1;
    transition: color 0.2s;
}

.overlay-close:hover {
    color: var(--ember);
}

.overlay-body h2 {
    font-family: var(--font-display);
    font-weight: 800;
    font-size: clamp(1.6rem, 3vw, 2.4rem);
    color: var(--wick);
    margin-bottom: 1rem;
}

.overlay-body p {
    color: var(--parchment);
    margin-bottom: 1rem;
}

.overlay-body .code-block {
    background: var(--charcoal);
    border-left: 3px solid var(--candle-glow);
    padding: 1rem;
    border-radius: 4px;
    font-family: var(--font-code);
    font-size: 0.85rem;
    line-height: 1.5;
    color: var(--candle-glow);
    overflow-x: auto;
}

/* --- Responsive --- */
@media (max-width: 768px) {
    .hex-grid {
        flex-direction: column;
        align-items: center;
    }

    .hex-cell {
        clip-path: none;
        border-radius: 16px;
        width: 90%;
        max-width: 360px;
        height: auto;
        margin: 0.5rem 0;
    }

    .hex-cell:nth-child(odd) { transform: translateX(-8px); }
    .hex-cell:nth-child(even) { transform: translateX(8px); margin-top: 0.5rem; }
    .hex-cell.revealed:nth-child(odd) { transform: translateX(-8px); }
    .hex-cell.revealed:nth-child(even) { transform: translateX(8px); }

    .hex-cell::before {
        clip-path: none;
        border-radius: 14px;
    }

    .cell-content {
        padding: 1.5rem 1rem;
    }

    .candle-flame {
        display: none;
    }

    .lid-nav {
        display: none;
    }

    .compartments {
        padding: 80px 1rem 2rem;
    }
}

@media (max-width: 500px) {
    .lid-inner {
        padding: 0.5rem 1rem;
    }

    .clasp-svg {
        width: 140px;
        height: 36px;
    }
}
