/* ===========================================
   layer2.quest — Brutalist Bento-Box Design
   Colors: #9ab0c8, #f27a6e, #f0a84c, #e8edf4, #b388f5, #1b2838, #5ec4d4
   Fonts: Caveat (display), IBM Plex Sans (body), IBM Plex Mono (data)
   =========================================== */

/* --- CSS Custom Properties --- */
:root {
    --color-steel: #9ab0c8;
    --color-coral: #f27a6e;
    --color-amber: #f0a84c;
    --color-frost: #e8edf4;
    --color-violet: #b388f5;
    --color-midnight: #1b2838;
    --color-cyan: #5ec4d4;

    --font-display: 'Caveat', cursive;
    --font-body: 'IBM Plex Sans', sans-serif;
    --font-mono: 'IBM Plex Mono', monospace;

    --gap: clamp(8px, 1.5vw, 16px);
    --cell-radius: 2px;
    --cell-border: 2px solid rgba(154, 176, 200, 0.3);
}

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

html {
    scroll-behavior: smooth;
    font-size: 16px;
    background: var(--color-midnight);
}

body {
    font-family: var(--font-body);
    color: var(--color-frost);
    background: var(--color-midnight);
    line-height: 1.6;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

/* --- Connection Lines SVG Overlay --- */
.connection-lines {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1000;
    opacity: 0.15;
}

/* --- Bento Grid System --- */
.bento-section {
    padding: var(--gap);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.bento-grid {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    gap: var(--gap);
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
}

.bento-cell {
    background: rgba(27, 40, 56, 0.85);
    border: var(--cell-border);
    border-radius: var(--cell-radius);
    padding: clamp(16px, 3vw, 32px);
    position: relative;
    overflow: hidden;
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94),
                transform 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.bento-cell.revealed {
    opacity: 1;
    transform: translateY(0);
}

/* Concrete texture overlay */
.bento-cell::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image:
        radial-gradient(circle at 20% 80%, rgba(154, 176, 200, 0.03) 0%, transparent 50%),
        radial-gradient(circle at 80% 20%, rgba(94, 196, 212, 0.03) 0%, transparent 50%);
    pointer-events: none;
}

/* Cell hover effect - brutalist shift */
.bento-cell:hover {
    border-color: rgba(94, 196, 212, 0.5);
    box-shadow: 4px 4px 0 rgba(94, 196, 212, 0.15);
}

/* --- Blueprint Annotations --- */
.blueprint-annotation {
    display: inline-block;
    font-family: var(--font-mono);
    font-size: 0.65rem;
    color: var(--color-steel);
    text-transform: uppercase;
    letter-spacing: 0.15em;
    opacity: 0.6;
    margin-bottom: 8px;
    position: relative;
}

.blueprint-annotation::after {
    content: attr(data-annotation);
    position: absolute;
    left: calc(100% + 12px);
    top: 50%;
    transform: translateY(-50%);
    font-family: var(--font-display);
    font-size: 0.85rem;
    color: var(--color-amber);
    opacity: 0.7;
    white-space: nowrap;
    font-weight: 400;
}

/* --- Typography --- */
.site-title {
    font-family: var(--font-display);
    font-size: clamp(3rem, 8vw, 6rem);
    font-weight: 700;
    line-height: 1.1;
    color: var(--color-frost);
    letter-spacing: -0.02em;
}

.title-dot {
    color: var(--color-coral);
}

.site-subtitle {
    font-family: var(--font-body);
    font-size: clamp(0.9rem, 2vw, 1.1rem);
    font-weight: 300;
    color: var(--color-steel);
    margin-top: 8px;
    letter-spacing: 0.05em;
}

.section-heading {
    font-family: var(--font-display);
    font-size: clamp(2.5rem, 6vw, 5rem);
    font-weight: 700;
    line-height: 1.1;
    color: var(--color-frost);
    position: relative;
}

.section-heading::after {
    content: '';
    display: block;
    width: 60px;
    height: 3px;
    background: var(--color-coral);
    margin-top: 12px;
}

/* --- SECTION 1: Hero Grid --- */
.hero-grid {
    grid-template-rows: auto auto;
}

.hero-title-cell {
    grid-column: 1 / 9;
    grid-row: 1 / 2;
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-height: 400px;
}

.hero-stat-cell {
    grid-column: 9 / 13;
    grid-row: 1 / 2;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    background: linear-gradient(135deg, rgba(27, 40, 56, 0.95), rgba(94, 196, 212, 0.08));
}

.hero-tagline-cell {
    grid-column: 1 / 8;
    grid-row: 2 / 3;
}

.hero-scroll-cell {
    grid-column: 8 / 13;
    grid-row: 2 / 3;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Hero SVG Network */
.hero-node-network {
    width: 100%;
    max-width: 400px;
    margin-top: 24px;
}

.node-dot {
    fill: var(--color-cyan);
    opacity: 0;
    animation: nodePulse 2s ease-in-out infinite;
}

.node-dot.active {
    opacity: 1;
}

.node-line {
    stroke: var(--color-cyan);
    stroke-width: 1.5;
    stroke-linecap: round;
    opacity: 0.4;
    stroke-dasharray: 200;
    stroke-dashoffset: 200;
    transition: stroke-dashoffset 1.5s ease;
}

.node-line.drawn {
    stroke-dashoffset: 0;
}

@keyframes nodePulse {
    0%, 100% { opacity: 0.5; r: inherit; }
    50% { opacity: 1; }
}

/* Stats */
.stat-number {
    font-family: var(--font-mono);
    font-size: clamp(2.5rem, 5vw, 4rem);
    font-weight: 700;
    color: var(--color-cyan);
    line-height: 1;
}

.stat-label {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--color-steel);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-top: 8px;
}

.stat-sublabel {
    font-family: var(--font-body);
    font-size: 0.7rem;
    color: var(--color-steel);
    opacity: 0.6;
    margin-top: 4px;
}

/* Tagline */
.tagline-text {
    font-family: var(--font-body);
    font-size: clamp(1.2rem, 2.5vw, 1.8rem);
    font-weight: 300;
    line-height: 1.5;
    color: var(--color-steel);
}

.tagline-highlight {
    color: var(--color-coral);
    font-weight: 600;
}

/* Scroll Indicator */
.scroll-indicator {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    animation: scrollBounce 2s ease-in-out infinite;
}

.scroll-arrow-svg {
    width: 24px;
    height: 40px;
}

.scroll-ball {
    animation: scrollBallMove 2s ease-in-out infinite;
}

@keyframes scrollBallMove {
    0%, 100% { cy: 8; }
    50% { cy: 14; }
}

@keyframes scrollBounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(8px); }
}

.scroll-text {
    font-family: var(--font-display);
    font-size: 1rem;
    color: var(--color-cyan);
    opacity: 0.7;
}

/* --- SECTION 2: What is L2 Grid --- */
.what-grid {
    grid-template-rows: auto auto auto;
}

.what-heading-cell {
    grid-column: 1 / 13;
    grid-row: 1 / 2;
}

.what-diagram-cell {
    grid-column: 1 / 7;
    grid-row: 2 / 3;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 280px;
}

.what-explain-cell {
    grid-column: 7 / 13;
    grid-row: 2 / 3;
    display: flex;
    align-items: center;
}

.what-analogy-cell {
    grid-column: 1 / 13;
    grid-row: 3 / 4;
    background: linear-gradient(135deg, rgba(242, 122, 110, 0.06), rgba(27, 40, 56, 0.9));
    border-left: 4px solid var(--color-coral);
}

/* Layer Diagram SVG */
.layer-diagram {
    width: 100%;
    max-width: 350px;
}

.layer-rect {
    fill: none;
    stroke-width: 2;
}

.layer1-rect {
    stroke: var(--color-steel);
    fill: rgba(154, 176, 200, 0.08);
}

.layer2-rect {
    stroke: var(--color-cyan);
    fill: rgba(94, 196, 212, 0.08);
}

.layer-label {
    font-family: var(--font-mono);
    font-size: 10px;
    fill: var(--color-frost);
    font-weight: 500;
}

.layer2-label {
    fill: var(--color-cyan);
}

.layer-arrow {
    stroke: var(--color-steel);
    stroke-width: 2;
    stroke-dasharray: 100;
    stroke-dashoffset: 100;
    fill: none;
    marker-end: url(#arrowhead);
}

.layer-arrow.drawn {
    stroke-dashoffset: 0;
    transition: stroke-dashoffset 1s ease;
}

.layer-bridge {
    stroke: var(--color-amber);
    stroke-width: 1.5;
    stroke-dasharray: 4 4;
    fill: none;
    stroke-dasharray: 300;
    stroke-dashoffset: 300;
}

.layer-bridge.drawn {
    stroke-dashoffset: 0;
    transition: stroke-dashoffset 2s ease;
}

.bridge-label {
    font-family: var(--font-display);
    font-size: 11px;
    fill: var(--color-amber);
    font-weight: 700;
}

/* Text styles */
.explain-text, .analogy-text, .growth-text {
    font-family: var(--font-body);
    font-size: clamp(0.95rem, 1.5vw, 1.1rem);
    line-height: 1.8;
    color: var(--color-frost);
    font-weight: 300;
}

.highlight-text {
    color: var(--color-coral);
    font-weight: 600;
}

.mono-highlight {
    font-family: var(--font-mono);
    color: var(--color-cyan);
    font-weight: 700;
    background: rgba(94, 196, 212, 0.1);
    padding: 2px 6px;
    border-radius: 2px;
}

.analogy-text {
    font-style: italic;
    color: var(--color-steel);
}

/* --- SECTION 3: Types Grid --- */
.types-grid {
    grid-template-rows: auto auto auto;
}

.types-heading-cell {
    grid-column: 1 / 13;
    grid-row: 1 / 2;
}

.types-rollup-cell {
    grid-column: 1 / 5;
    grid-row: 2 / 3;
}

.types-zk-cell {
    grid-column: 5 / 9;
    grid-row: 2 / 3;
}

.types-state-cell {
    grid-column: 9 / 13;
    grid-row: 2 / 3;
}

.types-compare-cell {
    grid-column: 1 / 13;
    grid-row: 3 / 4;
}

/* Type Cards */
.type-card {
    display: flex;
    flex-direction: column;
    gap: 12px;
    transition: transform 0.3s ease, border-color 0.3s ease;
}

.type-card:hover {
    transform: translateY(-4px);
}

.type-card[data-type='optimistic']:hover {
    border-color: var(--color-coral);
}

.type-card[data-type='zk']:hover {
    border-color: var(--color-violet);
}

.type-card[data-type='state']:hover {
    border-color: var(--color-cyan);
}

.type-icon {
    width: 60px;
    height: 60px;
}

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

.type-circle, .type-rect, .type-diamond, .type-check {
    stroke-dasharray: 200;
    stroke-dashoffset: 200;
    transition: stroke-dashoffset 1.5s ease;
}

.type-circle.drawn, .type-rect.drawn, .type-diamond.drawn, .type-check.drawn {
    stroke-dashoffset: 0;
}

.type-zk-text {
    font-family: var(--font-mono);
    font-size: 16px;
    fill: var(--color-violet);
    font-weight: 700;
}

.type-name {
    font-family: var(--font-display);
    font-size: clamp(1.3rem, 2.5vw, 1.8rem);
    font-weight: 700;
    color: var(--color-frost);
}

.type-desc {
    font-family: var(--font-body);
    font-size: 0.85rem;
    color: var(--color-steel);
    line-height: 1.6;
    font-weight: 300;
}

.type-examples {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: auto;
}

.type-tag {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    color: var(--color-cyan);
    background: rgba(94, 196, 212, 0.1);
    border: 1px solid rgba(94, 196, 212, 0.2);
    padding: 3px 8px;
    border-radius: 2px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.type-stat {
    display: flex;
    align-items: baseline;
    gap: 8px;
    padding-top: 12px;
    border-top: 1px solid rgba(154, 176, 200, 0.15);
    margin-top: 8px;
}

.type-stat-value {
    font-family: var(--font-mono);
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--color-amber);
}

.type-stat-label {
    font-family: var(--font-mono);
    font-size: 0.65rem;
    color: var(--color-steel);
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

/* Comparison Table */
.compare-table {
    width: 100%;
    border-collapse: collapse;
    font-family: var(--font-mono);
    font-size: 0.8rem;
}

.compare-table th {
    text-align: left;
    padding: 10px 16px;
    border-bottom: 2px solid var(--color-steel);
    color: var(--color-frost);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-size: 0.7rem;
}

.compare-table td {
    padding: 10px 16px;
    border-bottom: 1px solid rgba(154, 176, 200, 0.1);
    color: var(--color-steel);
}

.compare-table tr:hover td {
    background: rgba(94, 196, 212, 0.04);
}

.cell-good {
    color: var(--color-cyan);
}

.cell-mid {
    color: var(--color-amber);
}

.cell-low {
    color: var(--color-coral);
}

/* --- SECTION 4: Ecosystem Grid --- */
.eco-grid {
    grid-template-rows: auto auto auto;
}

.eco-heading-cell {
    grid-column: 1 / 13;
    grid-row: 1 / 2;
}

.eco-network-cell {
    grid-column: 1 / 7;
    grid-row: 2 / 3;
    min-height: 350px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.eco-tvl-cell {
    grid-column: 7 / 13;
    grid-row: 2 / 3;
}

.eco-growth-cell {
    grid-column: 1 / 13;
    grid-row: 3 / 4;
    background: linear-gradient(135deg, rgba(179, 136, 245, 0.06), rgba(27, 40, 56, 0.9));
    border-left: 4px solid var(--color-violet);
}

/* Ecosystem Network SVG */
.ecosystem-network {
    width: 100%;
    max-width: 500px;
}

.eco-node {
    fill: rgba(27, 40, 56, 0.9);
    stroke-width: 2;
}

.eco-node-main {
    stroke: var(--color-frost);
    fill: rgba(232, 237, 244, 0.1);
}

.eco-node-l2 {
    stroke: var(--color-cyan);
    fill: rgba(94, 196, 212, 0.08);
    transition: fill 0.3s ease;
}

.eco-node-l2:hover {
    fill: rgba(94, 196, 212, 0.2);
}

.eco-node-label {
    font-family: var(--font-mono);
    font-size: 10px;
    fill: var(--color-frost);
    font-weight: 600;
}

.eco-main-label {
    font-size: 14px;
    font-weight: 700;
}

.eco-line {
    stroke: var(--color-cyan);
    stroke-width: 1;
    opacity: 0.3;
    stroke-dasharray: 500;
    stroke-dashoffset: 500;
    transition: stroke-dashoffset 2s ease;
}

.eco-line.drawn {
    stroke-dashoffset: 0;
}

.eco-line-cross {
    stroke: var(--color-violet);
    stroke-dasharray: 4 4;
    opacity: 0.2;
}

.eco-line-cross.drawn {
    stroke-dashoffset: 0;
}

/* Node pulse animation */
.eco-node-l2 {
    animation: ecoNodeGlow 3s ease-in-out infinite;
}

@keyframes ecoNodeGlow {
    0%, 100% { stroke-opacity: 0.6; }
    50% { stroke-opacity: 1; }
}

/* TVL Display */
.tvl-display {
    display: flex;
    align-items: baseline;
    gap: 2px;
    margin-bottom: 8px;
}

.tvl-dollar {
    font-family: var(--font-mono);
    font-size: 1.5rem;
    color: var(--color-amber);
    font-weight: 300;
}

.tvl-number {
    font-family: var(--font-mono);
    font-size: clamp(2.5rem, 5vw, 4rem);
    font-weight: 700;
    color: var(--color-amber);
    line-height: 1;
}

.tvl-suffix {
    font-family: var(--font-mono);
    font-size: 1.5rem;
    color: var(--color-amber);
    font-weight: 300;
}

.tvl-label {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    color: var(--color-steel);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-bottom: 24px;
}

/* TVL Bars */
.tvl-bar-container {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.tvl-bar {
    position: relative;
    height: 28px;
    background: rgba(154, 176, 200, 0.06);
    border-radius: 2px;
    overflow: hidden;
}

.tvl-bar-fill {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    width: 0%;
    background: var(--bar-color);
    opacity: 0.3;
    border-radius: 2px;
    transition: width 1.5s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.tvl-bar.animated .tvl-bar-fill {
    width: calc(var(--target-width, 0) * 1%);
}

.tvl-bar-text {
    position: relative;
    z-index: 1;
    font-family: var(--font-mono);
    font-size: 0.7rem;
    color: var(--color-frost);
    line-height: 28px;
    padding-left: 10px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* --- SECTION 5: Quest Grid --- */
.quest-grid {
    grid-template-rows: auto auto auto auto;
}

.quest-heading-cell {
    grid-column: 1 / 13;
    grid-row: 1 / 2;
}

.quest-vision-cell {
    grid-column: 1 / 8;
    grid-row: 2 / 3;
}

.quest-cta-cell {
    grid-column: 8 / 13;
    grid-row: 2 / 3;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 20px;
}

.quest-footer-cell {
    grid-column: 1 / 13;
    grid-row: 3 / 4;
    text-align: center;
    background: rgba(27, 40, 56, 0.6);
}

/* Quest Items */
.quest-items {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.quest-item {
    display: flex;
    gap: 20px;
    padding: 20px 0;
    border-bottom: 1px solid rgba(154, 176, 200, 0.1);
    transition: border-color 0.3s ease;
}

.quest-item:last-child {
    border-bottom: none;
}

.quest-item:hover {
    border-color: rgba(242, 122, 110, 0.3);
}

.quest-item-marker {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    color: var(--color-coral);
    font-weight: 700;
    min-width: 30px;
    padding-top: 4px;
}

.quest-item-title {
    font-family: var(--font-display);
    font-size: clamp(1.2rem, 2vw, 1.5rem);
    font-weight: 700;
    color: var(--color-frost);
    margin-bottom: 4px;
}

.quest-item-desc {
    font-family: var(--font-body);
    font-size: 0.85rem;
    color: var(--color-steel);
    line-height: 1.6;
    font-weight: 300;
}

/* Quest Path SVG */
.quest-path-svg {
    width: 100%;
    max-width: 300px;
}

.quest-path {
    stroke-dasharray: 500;
    stroke-dashoffset: 500;
    transition: stroke-dashoffset 2.5s ease;
}

.quest-path.drawn {
    stroke-dashoffset: 0;
}

.quest-endpoint {
    opacity: 0;
    transition: opacity 0.5s ease 2s;
}

.quest-path.drawn ~ .quest-endpoint,
.quest-endpoint.visible {
    opacity: 1;
}

.quest-cta-text {
    font-family: var(--font-body);
    font-size: clamp(1rem, 1.8vw, 1.3rem);
    line-height: 1.7;
    color: var(--color-frost);
    font-weight: 300;
}

/* Footer */
.footer-content {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 12px;
}

.footer-brand {
    font-family: var(--font-display);
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--color-frost);
}

.footer-divider {
    color: var(--color-steel);
    opacity: 0.4;
}

.footer-tagline {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--color-steel);
    letter-spacing: 0.05em;
}

.construction-tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.construction-bracket {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    color: var(--color-amber);
}

.construction-text {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    color: var(--color-amber);
    text-transform: uppercase;
    letter-spacing: 0.15em;
    animation: constructionBlink 2s ease-in-out infinite;
}

@keyframes constructionBlink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

/* --- Responsive --- */
@media (max-width: 900px) {
    .hero-title-cell {
        grid-column: 1 / 13;
        min-height: 300px;
    }
    .hero-stat-cell {
        grid-column: 1 / 13;
    }
    .hero-tagline-cell {
        grid-column: 1 / 13;
    }
    .hero-scroll-cell {
        grid-column: 1 / 13;
    }
    .what-diagram-cell {
        grid-column: 1 / 13;
    }
    .what-explain-cell {
        grid-column: 1 / 13;
    }
    .types-rollup-cell,
    .types-zk-cell,
    .types-state-cell {
        grid-column: 1 / 13;
    }
    .eco-network-cell {
        grid-column: 1 / 13;
    }
    .eco-tvl-cell {
        grid-column: 1 / 13;
    }
    .quest-vision-cell {
        grid-column: 1 / 13;
    }
    .quest-cta-cell {
        grid-column: 1 / 13;
    }
}

@media (max-width: 600px) {
    :root {
        --gap: 6px;
    }
    .bento-cell {
        padding: 16px;
    }
    .compare-table {
        font-size: 0.65rem;
    }
    .compare-table th,
    .compare-table td {
        padding: 6px 8px;
    }
}

/* --- Background Grid Pattern --- */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image:
        linear-gradient(rgba(154, 176, 200, 0.03) 1px, transparent 1px),
        linear-gradient(90deg, rgba(154, 176, 200, 0.03) 1px, transparent 1px);
    background-size: 40px 40px;
    pointer-events: none;
    z-index: -1;
}

/* --- Reveal transition delays --- */
.bento-cell:nth-child(1) { transition-delay: 0s; }
.bento-cell:nth-child(2) { transition-delay: 0.1s; }
.bento-cell:nth-child(3) { transition-delay: 0.2s; }
.bento-cell:nth-child(4) { transition-delay: 0.3s; }
.bento-cell:nth-child(5) { transition-delay: 0.4s; }
.bento-cell:nth-child(6) { transition-delay: 0.5s; }
