/* layer-2.wiki -- Isometric Technical Wiki */

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

:root {
    --deep-protocol: #0E1018;
    --substrate-slate: #1C1E26;
    --conduit-gray: #3A3D4A;
    --chalk: #E8E4DC;
    --rollup-amber: #D4A03C;
    --channel-teal: #3C8A8A;
    --bridge-copper: #B87333;
    --patina: #7A8A7E;
    --proof-violet: #6A5ACD;
    --compression-green: #4A7A52;
    --font-display: 'IBM Plex Mono', monospace;
    --font-body: 'Literata', serif;
    --font-code: 'Fira Code', monospace;
    --font-annotation: 'Commissioner', sans-serif;
    --sidebar-width: 280px;
}

html {
    scroll-behavior: smooth;
}

body {
    background: var(--deep-protocol);
    color: var(--chalk);
    font-family: var(--font-body);
    font-weight: 400;
    font-size: clamp(0.95rem, 1.1vw, 1.1rem);
    line-height: 1.72;
    overflow-x: hidden;
}

/* ---- Scroll Progress ---- */
.scroll-progress {
    position: fixed;
    top: 0;
    left: 0;
    height: 2px;
    width: 0%;
    background: linear-gradient(to right, var(--channel-teal), var(--rollup-amber));
    z-index: 1000;
    transition: width 0.1s linear;
}

/* ---- Isometric Grid Underlay ---- */
.iso-grid-underlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    pointer-events: none;
}

/* ---- Sidebar ---- */
.sidebar {
    position: fixed;
    left: 0;
    top: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--substrate-slate);
    z-index: 100;
    padding: 2rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    border-right: 1px solid var(--conduit-gray);
    transition: width 0.4s ease, opacity 0.3s ease;
    overflow: hidden;
}

.sidebar.collapsed {
    width: 0;
    padding: 0;
    opacity: 0;
    border-right: none;
}

.sidebar-title {
    font-family: var(--font-annotation);
    font-weight: 300;
    font-size: 0.78rem;
    letter-spacing: 0.12em;
    color: var(--patina);
    text-transform: uppercase;
}

.layer-stack {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.layer-block {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.6rem 0.8rem;
    border-left: 3px solid transparent;
    text-decoration: none;
    transition: border-color 0.2s ease, background 0.2s ease;
    cursor: pointer;
    position: relative;
}

.layer-block:hover {
    background: rgba(58, 61, 74, 0.3);
}

.layer-block.active {
    border-left-color: var(--rollup-amber);
    background: rgba(58, 61, 74, 0.2);
}

.iso-block-face {
    width: 32px;
    height: 18px;
    border: 1px solid;
    transition: opacity 0.2s ease, border-width 0.2s ease;
}

.iso-block-face.top {
    transform: skewX(-30deg);
}

.iso-block-face.side {
    transform: skewY(15deg);
    margin-top: -4px;
    width: 24px;
}

.layer-block:hover .iso-block-face {
    opacity: 0.35;
    border-width: 2px;
}

.layer-label {
    font-family: var(--font-annotation);
    font-weight: 300;
    font-size: 0.78rem;
    letter-spacing: 0.04em;
    color: var(--patina);
}

/* ---- Sidebar Toggle ---- */
.sidebar-toggle {
    display: none;
    position: fixed;
    top: 1rem;
    left: 1rem;
    z-index: 200;
    background: var(--substrate-slate);
    border: 1px solid var(--conduit-gray);
    color: var(--chalk);
    font-size: 1.2rem;
    width: 40px;
    height: 40px;
    cursor: pointer;
    border-radius: 4px;
}

/* ---- Main Content ---- */
.main-content {
    margin-left: var(--sidebar-width);
    position: relative;
    z-index: 1;
    transition: margin-left 0.4s ease;
}

.main-content.expanded {
    margin-left: 0;
}

/* ---- Hero ---- */
.hero-section {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 4rem 3rem;
    gap: 2rem;
}

.hero-inner {
    flex: 1;
}

.hero-title {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: clamp(3rem, 12vw, 8rem);
    letter-spacing: 0.06em;
    color: var(--chalk);
    line-height: 1;
    opacity: 0;
    transform: translateY(20px);
    animation: heroFadeIn 0.8s ease forwards;
}

.hero-subtitle {
    font-family: var(--font-annotation);
    font-weight: 300;
    font-size: 1.1rem;
    color: var(--patina);
    margin-top: 1rem;
    opacity: 0;
    animation: heroFadeIn 0.6s ease 0.8s forwards;
}

@keyframes heroFadeIn {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.hero-iso-stack {
    flex: 0 0 300px;
}

.hero-stack-svg {
    width: 100%;
    height: auto;
}

.iso-stack-block {
    opacity: 0;
    transform: translateY(30px);
    animation: stackBuild 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

.iso-stack-block:nth-child(1) { animation-delay: 0.3s; }
.iso-stack-block:nth-child(2) { animation-delay: 0.42s; }
.iso-stack-block:nth-child(3) { animation-delay: 0.54s; }
.iso-stack-block:nth-child(4) { animation-delay: 0.66s; }
.iso-stack-block:nth-child(5) { animation-delay: 0.78s; }

@keyframes stackBuild {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ---- Connectors ---- */
.connector {
    height: 40px;
    display: flex;
    justify-content: center;
}

.connector-svg {
    width: 100px;
    height: 40px;
}

.conn-line {
    stroke-dasharray: 60;
    stroke-dashoffset: 60;
    transition: stroke-dashoffset 0.6s ease;
}

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

/* ---- Content Sections ---- */
.content-section {
    padding: 0;
    margin: 2rem 0;
    transform: rotateX(1deg) rotateY(-0.5deg);
    transform-origin: left center;
    box-shadow: 4px 8px 20px rgba(0, 0, 0, 0.3);
}

.section-header {
    height: 60px;
    display: flex;
    align-items: center;
    padding: 0 2rem;
    width: 0%;
    overflow: hidden;
    transition: width 0.4s ease-out;
}

.section-header.expanded {
    width: 100%;
}

.section-header h2 {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: clamp(1.3rem, 3vw, 2.4rem);
    letter-spacing: 0.06em;
    color: var(--deep-protocol);
    white-space: nowrap;
}

.section-body {
    display: grid;
    grid-template-columns: 65% 35%;
    background: var(--substrate-slate);
}

.text-panel {
    padding: 2rem;
}

.text-panel p {
    margin-bottom: 1rem;
}

.text-panel em {
    font-weight: 600;
}

.text-panel strong {
    font-weight: 600;
    color: var(--chalk);
}

.diagram-panel {
    background: #22242E;
    border-left: 1px solid var(--conduit-gray);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.section-diagram {
    width: 100%;
    height: auto;
}

.annotation {
    font-family: var(--font-annotation);
    font-weight: 300;
    font-size: 0.78rem;
    letter-spacing: 0.04em;
    color: var(--patina);
}

code {
    font-family: var(--font-code);
    font-weight: 400;
    font-size: 0.88rem;
    background: var(--conduit-gray);
    padding: 0.15em 0.4em;
    border-radius: 2px;
    color: var(--rollup-amber);
    position: relative;
}

code::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    width: 3px;
    height: 0%;
    background: var(--proof-violet);
    transition: height 0.2s ease;
    border-radius: 2px 0 0 2px;
}

code:hover::before {
    height: 100%;
}

/* ---- Animation Slide In ---- */
.anim-slide {
    opacity: 0;
    transform: translateX(40px);
    transition: opacity 0.5s ease, transform 0.5s ease;
}

.anim-slide.visible {
    opacity: 1;
    transform: translateX(0);
}

.anim-slide:nth-child(2) {
    transition-delay: 0.08s;
}

/* ---- Breakout Panels ---- */
.breakout-panel {
    background: var(--deep-protocol);
    width: 100vw;
    margin-left: calc(var(--sidebar-width) * -1);
    padding: 3rem 2rem;
    position: relative;
    z-index: 2;
}

.breakout-inner {
    max-width: 900px;
    margin: 0 auto;
    transform: scale(0.85);
    transition: transform 0.8s ease;
}

.breakout-panel.in-view .breakout-inner {
    transform: scale(1);
}

.breakout-diagram {
    width: 100%;
    height: auto;
}

/* ---- State Diff Columns (decorative) ---- */
.content-section::after {
    content: '';
    position: absolute;
    right: -20px;
    top: 0;
    width: 8px;
    height: 100%;
    background: repeating-linear-gradient(
        to bottom,
        var(--rollup-amber) 0px,
        var(--rollup-amber) 8px,
        var(--channel-teal) 8px,
        var(--channel-teal) 16px,
        var(--bridge-copper) 16px,
        var(--bridge-copper) 24px,
        transparent 24px,
        transparent 32px
    );
    opacity: 0.15;
}

/* ---- Footer ---- */
.site-footer {
    padding: 4rem 2rem;
    text-align: center;
}

/* ---- Responsive ---- */
@media (max-width: 768px) {
    .sidebar {
        width: 0;
        padding: 0;
        opacity: 0;
    }

    .sidebar.open {
        width: 260px;
        padding: 2rem 1rem;
        opacity: 1;
    }

    .sidebar-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .main-content {
        margin-left: 0;
    }

    .breakout-panel {
        margin-left: 0;
    }

    .hero-section {
        flex-direction: column;
        padding: 3rem 1.5rem;
    }

    .hero-iso-stack {
        flex: 0 0 auto;
        width: 200px;
    }

    .hero-title {
        font-size: clamp(2rem, 10vw, 4rem);
    }

    .section-body {
        grid-template-columns: 1fr;
    }

    .diagram-panel {
        border-left: none;
        border-top: 1px solid var(--conduit-gray);
    }

    .content-section {
        transform: none;
    }

    .content-section::after {
        display: none;
    }
}

/* ---- Reduced Motion ---- */
@media (prefers-reduced-motion: reduce) {
    .hero-title,
    .hero-subtitle {
        animation: none;
        opacity: 1;
        transform: none;
    }

    .iso-stack-block {
        animation: none;
        opacity: 1;
        transform: none;
    }

    .anim-slide {
        opacity: 1;
        transform: none;
        transition: none;
    }

    .section-header {
        width: 100%;
        transition: none;
    }

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

    .breakout-inner {
        transform: scale(1);
        transition: none;
    }
}
