/* ==========================================
   lunchbox.dev - Rebel Steampunk Lunchroom
   Victorian Ornament x Punk Energy
   ========================================== */

/* --- CSS Custom Properties --- */
:root {
    --bg-deep: #1a1510;
    --bg-card: #2a2218;
    --text-primary: #e8dcc8;
    --brass: #c49a3c;
    --thorn-red: #a8323a;
    --riot-cyan: #22d4b7;
    --text-secondary: #8a7e6d;
    --ember-glow: #3d2e1a;
    --spine-width: max(2px, 0.15vw);
    --spine-width-junction: max(4px, 0.3vw);
}

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

html {
    scroll-behavior: smooth;
    overflow-x: hidden;
}

body {
    background-color: var(--bg-deep);
    color: var(--text-primary);
    font-family: 'Source Serif 4', Georgia, serif;
    font-weight: 400;
    font-size: clamp(1rem, 1.8vw, 1.2rem);
    line-height: 1.72;
    letter-spacing: 0.005em;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

/* --- Typography --- */
h1, h2, h3 {
    font-family: 'Libre Baskerville', 'Georgia', serif;
    font-weight: 700;
    line-height: 1.15;
    text-shadow: 1px 1px 0 rgba(0,0,0,0.15);
    color: var(--text-primary);
}

h1 {
    font-size: clamp(2rem, 5vw, 4rem);
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

h2 {
    font-size: clamp(1.5rem, 3.5vw, 2.8rem);
    letter-spacing: 0.04em;
}

p {
    margin-bottom: 1.2em;
}

p + p {
    text-indent: 1.5em;
}

/* --- Cartouche (Opening Section) --- */
.cartouche {
    position: relative;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-deep);
    overflow: hidden;
}

.cartouche-inner {
    position: relative;
    text-align: center;
    padding: 4rem 2rem;
    opacity: 0;
    animation: cartoucheFadeIn 1.5s ease-out 0.3s forwards;
}

@keyframes cartoucheFadeIn {
    0% { opacity: 0; transform: scale(0.95); }
    100% { opacity: 1; transform: scale(1); }
}

.cartouche-frame {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 90%;
    max-width: 800px;
    height: auto;
    opacity: 0;
    animation: frameFadeIn 2s ease-out 0.8s forwards;
}

@keyframes frameFadeIn {
    0% { opacity: 0; }
    100% { opacity: 0.7; }
}

.cartouche-vine,
.cartouche-spiral {
    stroke-dasharray: 600;
    stroke-dashoffset: 600;
    animation: drawPath 2.5s ease-out 1s forwards;
}

.cartouche-corner {
    stroke-dasharray: 200;
    stroke-dashoffset: 200;
    animation: drawPath 2s ease-out 1.5s forwards;
}

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

.site-title {
    position: relative;
    z-index: 2;
    margin-bottom: 1rem;
}

.site-title span {
    display: inline-block;
    opacity: 0;
    animation: letterStamp 0.1s ease-out forwards;
}

.cartouche-subtitle-vine {
    position: relative;
    z-index: 2;
    margin: 0.5rem auto;
    width: 60%;
    max-width: 400px;
}

.subtitle-vine {
    width: 100%;
    height: auto;
}

.vine-draw {
    stroke-dasharray: 300;
    stroke-dashoffset: 300;
    animation: drawPath 1.5s ease-out 2s forwards;
}

.cartouche-tagline {
    position: relative;
    z-index: 2;
    font-family: 'Stint Ultra Condensed', serif;
    font-size: clamp(0.8rem, 1.4vw, 1rem);
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--text-secondary);
    margin-top: 1.5rem;
    opacity: 0;
    animation: fadeInUp 1s ease-out 2.5s forwards;
}

@keyframes fadeInUp {
    0% { opacity: 0; transform: translateY(15px); }
    100% { opacity: 1; transform: translateY(0); }
}

/* --- Lens Flare --- */
.lens-flare {
    position: absolute;
    pointer-events: none;
    width: 300px;
    height: 300px;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    opacity: 0;
    z-index: 1;
}

#cartouche-flare {
    background:
        radial-gradient(circle at center, rgba(232,220,200,0.9) 0%, transparent 8%),
        radial-gradient(circle at center, rgba(196,154,60,0.4) 0%, transparent 20%),
        radial-gradient(circle at center, rgba(196,154,60,0.2) 0%, transparent 35%),
        radial-gradient(circle at center, rgba(196,154,60,0.08) 0%, transparent 55%);
    mix-blend-mode: screen;
    animation: flareBloom 1.5s ease-out 1.8s forwards;
}

@keyframes flareBloom {
    0% { opacity: 0; transform: translate(-50%, -50%) scale(0.3); }
    50% { opacity: 1; transform: translate(-50%, -50%) scale(1.2); }
    100% { opacity: 0.15; transform: translate(-50%, -50%) scale(1); }
}

/* --- Timeline Container --- */
.timeline-container {
    position: relative;
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 2rem 6rem;
}

/* --- Timeline Spine SVG --- */
.timeline-spine {
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 40px;
    height: 100%;
    z-index: 1;
    pointer-events: none;
}

.spine-path {
    stroke-dasharray: 5000;
    stroke-dashoffset: 5000;
    transition: stroke-dashoffset 0.05s linear;
}

/* --- Timeline Nodes --- */
.timeline-node {
    position: relative;
    display: flex;
    align-items: flex-start;
    margin-bottom: clamp(8rem, 15vh, 14rem);
    z-index: 2;
}

.node-right {
    flex-direction: row;
    padding-left: calc(50% + 48px);
}

.node-left {
    flex-direction: row-reverse;
    padding-right: calc(50% + 48px);
}

/* --- Medallion --- */
.medallion {
    position: absolute;
    left: 50%;
    top: 0;
    transform: translateX(-50%);
    width: 64px;
    height: 64px;
    z-index: 5;
    flex-shrink: 0;
}

.medallion-svg {
    width: 100%;
    height: 100%;
    opacity: 0;
    transition: opacity 0.4s ease;
}

.timeline-node.is-visible .medallion-svg {
    opacity: 1;
}

.timeline-node.is-visible .medallion-svg circle:first-child {
    animation: medallionPulse 0.4s ease-out;
}

@keyframes medallionPulse {
    0% { transform-origin: center; r: 28; }
    50% { r: 33; }
    100% { r: 28; }
}

/* --- Rivet Dots --- */
.rivet {
    position: absolute;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--brass);
    left: 50%;
    transform: translateX(-50%);
}

.rivet::after {
    content: '';
    position: absolute;
    top: 1px;
    left: 1px;
    width: 3px;
    height: 3px;
    border-radius: 50%;
    background: var(--text-primary);
    opacity: 0.3;
}

.rivet-top {
    top: -12px;
}

.rivet-bottom {
    bottom: -12px;
}

/* --- Node Flare --- */
.node-flare {
    width: 120px;
    height: 120px;
    top: 50%;
    left: 50%;
    background:
        radial-gradient(circle at center, rgba(232,220,200,0.7) 0%, transparent 10%),
        radial-gradient(circle at center, rgba(196,154,60,0.3) 0%, transparent 25%),
        radial-gradient(circle at center, rgba(196,154,60,0.1) 0%, transparent 45%);
    mix-blend-mode: screen;
}

.timeline-node.is-visible .node-flare {
    animation: nodeFlareBloom 0.6s ease-out 1s forwards;
}

@keyframes nodeFlareBloom {
    0% { opacity: 0; transform: translate(-50%, -50%) scale(0.2); }
    50% { opacity: 0.8; transform: translate(-50%, -50%) scale(1.1); }
    100% { opacity: 0.15; transform: translate(-50%, -50%) scale(1); }
}

/* --- Connectors --- */
.connector {
    position: absolute;
    top: 20px;
    width: 100px;
    height: 20px;
    z-index: 3;
}

.connector-right {
    left: calc(50% + 32px);
}

.connector-left {
    right: calc(50% + 32px);
}

.connector-svg {
    width: 100%;
    height: 100%;
}

.connector-path {
    stroke-dasharray: 200;
    stroke-dashoffset: 200;
    transition: stroke-dashoffset 0.5s ease-out;
}

.timeline-node.is-visible .connector-path {
    stroke-dashoffset: 0;
    transition-delay: 0.4s;
}

/* --- Content Blocks --- */
.content-block {
    position: relative;
    background: var(--bg-card);
    border: 1px solid rgba(196, 154, 60, 0.15);
    padding: 2.5rem 2rem;
    max-width: 42vw;
    width: 100%;
    overflow: hidden;
}

.node-right .content-block {
    margin-left: 20px;
}

.node-left .content-block {
    margin-right: 20px;
}

/* --- Skeleton Ornament --- */
.skeleton-ornament {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 10;
    background: var(--bg-card);
    overflow: hidden;
    opacity: 1;
    transition: opacity 0.3s ease-out;
}

.skeleton-ornament::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background:
        repeating-linear-gradient(
            90deg,
            transparent 0%,
            rgba(61, 46, 26, 0.5) 25%,
            transparent 50%
        );
    background-size: 200% 100%;
    animation: skeletonShimmer 2s ease-in-out infinite;
}

.skeleton-ornament::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 80%;
    height: 60%;
    border: 1px solid var(--ember-glow);
    border-radius: 50%;
    opacity: 0.4;
    animation: skeletonPulse 2s ease-in-out infinite;
}

@keyframes skeletonShimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

@keyframes skeletonPulse {
    0%, 100% { opacity: 0.2; border-color: var(--bg-card); }
    50% { opacity: 0.5; border-color: var(--ember-glow); }
}

.timeline-node.is-visible .skeleton-ornament {
    opacity: 0;
    transition-delay: 0.9s;
}

/* --- Content Inner --- */
.content-inner {
    position: relative;
    opacity: 0;
    transition: opacity 0.3s ease-out;
    z-index: 5;
}

.timeline-node.is-visible .content-inner {
    opacity: 1;
    transition-delay: 1.0s;
}

/* --- Corner Cartouches --- */
.corner-cartouche {
    position: absolute;
    width: 40px;
    height: 40px;
    z-index: 6;
    opacity: 0.4;
    transition: opacity 0.3s ease;
}

.content-block:hover .corner-cartouche {
    opacity: 0.8;
}

.corner-cartouche path {
    stroke-dasharray: 100;
    stroke-dashoffset: 100;
    transition: stroke-dashoffset 0.8s ease-out;
}

.timeline-node.is-visible .corner-cartouche path {
    stroke-dashoffset: 0;
    transition-delay: 0.6s;
}

.ct-tl { top: 8px; left: 8px; }
.ct-tr { top: 8px; right: 8px; }
.ct-bl { bottom: 8px; left: 8px; }
.ct-br { bottom: 8px; right: 8px; }

/* --- Node Label --- */
.node-label {
    display: block;
    font-family: 'Stint Ultra Condensed', serif;
    font-size: clamp(0.7rem, 1.2vw, 0.9rem);
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

/* --- Links & Interactive Hover --- */
a {
    color: var(--text-primary);
    text-decoration: underline;
    text-decoration-color: var(--riot-cyan);
    text-underline-offset: 3px;
    transition: color 0.2s ease;
}

a:hover {
    color: var(--riot-cyan);
}

/* --- Vine Dividers --- */
.vine-divider {
    position: relative;
    width: 100%;
    margin: 2rem 0;
    z-index: 2;
}

.vine-divider-svg {
    width: 100%;
    height: 40px;
}

.divider-vine-path {
    stroke-dasharray: 2000;
    stroke-dashoffset: 2000;
    transition: stroke-dashoffset 1.2s ease-out;
}

.vine-divider.is-visible .divider-vine-path {
    stroke-dashoffset: 0;
}

/* --- Vine Terminus --- */
.vine-terminus {
    display: flex;
    justify-content: center;
    padding: 2rem 0 4rem;
    z-index: 2;
    position: relative;
}

.terminus-svg {
    width: 60px;
    height: 80px;
    opacity: 0.6;
}

/* --- Footer Plaque --- */
.footer-plaque {
    position: relative;
    text-align: center;
    padding: 3rem 2rem 4rem;
    border-top: 1px solid rgba(196, 154, 60, 0.1);
}

.footer-vine {
    width: 60%;
    max-width: 400px;
    margin: 0 auto 1.5rem;
}

.footer-vine svg {
    width: 100%;
    height: auto;
}

.footer-text {
    font-family: 'Stint Ultra Condensed', serif;
    font-size: clamp(0.7rem, 1.2vw, 0.9rem);
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--text-secondary);
}

.footer-rivets {
    display: flex;
    justify-content: center;
    gap: 16px;
    margin-top: 1.2rem;
}

.rivet-dot {
    display: block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--brass);
    position: relative;
}

.rivet-dot::after {
    content: '';
    position: absolute;
    top: 1px;
    left: 1px;
    width: 3px;
    height: 3px;
    border-radius: 50%;
    background: var(--text-primary);
    opacity: 0.3;
}

/* --- Active medallion indicator (riot cyan) --- */
.medallion.is-active .medallion-svg circle:first-child {
    stroke: var(--riot-cyan);
    transition: stroke 0.3s ease;
}

/* --- Hover states with riot cyan --- */
.content-block {
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.content-block:hover {
    border-color: rgba(34, 212, 183, 0.3);
    box-shadow: 0 0 30px rgba(34, 212, 183, 0.05);
}

/* --- Mobile Adaptation (< 768px) --- */
@media (max-width: 768px) {
    .timeline-container {
        padding: 0 1rem 4rem;
    }

    .timeline-spine {
        left: 8vw;
        transform: none;
    }

    .timeline-node {
        display: block;
        margin-bottom: clamp(5rem, 10vh, 8rem);
    }

    .node-right,
    .node-left {
        padding-left: calc(8vw + 56px);
        padding-right: 0;
        flex-direction: row;
    }

    .medallion {
        left: 8vw;
        transform: translateX(-50%);
    }

    .connector-right,
    .connector-left {
        left: calc(8vw + 32px);
        right: auto;
    }

    .content-block {
        max-width: none;
        width: 100%;
        margin-left: 16px;
        margin-right: 0;
    }

    .node-left .content-block {
        margin-right: 0;
        margin-left: 16px;
    }

    .cartouche-frame {
        width: 100%;
    }

    h1 {
        font-size: clamp(1.5rem, 8vw, 2.5rem);
        letter-spacing: 0.04em;
    }
}

/* --- Small screen adjustments --- */
@media (max-width: 480px) {
    .content-block {
        padding: 1.5rem 1rem;
    }

    .corner-cartouche {
        width: 24px;
        height: 24px;
    }

    .cartouche-inner {
        padding: 2rem 1rem;
    }
}
