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

:root {
    --pale-blue: #8aacb8;
    --warm-white: #f4f0ea;
    --deep-brown: #2c2418;
    --mid-brown: #3a3028;
    --ice-blue: #d4e4ea;
    --warm-sand: #e8e0d4;
    --terracotta: #b8603f;
    --muted-brown: #6b5e50;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Varela Round', sans-serif;
    background-color: var(--warm-white);
    color: var(--deep-brown);
    display: flex;
    min-height: 100vh;
    overflow-x: hidden;
}

/* Sidebar */
.sidebar {
    position: fixed;
    left: 0;
    top: 0;
    width: 240px;
    height: 100vh;
    background-color: var(--warm-sand);
    display: flex;
    flex-direction: column;
    padding: 2rem 1.5rem;
    z-index: 100;
    border-right: 1px solid rgba(138, 172, 184, 0.2);
}

.sidebar-logo {
    margin-bottom: 3rem;
    font-family: 'Nunito', sans-serif;
    font-size: 1.8rem;
    font-weight: 700;
    letter-spacing: -0.015em;
}

.logo-ai {
    color: var(--deep-brown);
}

.logo-ice {
    color: var(--pale-blue);
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    flex: 1;
}

.nav-link {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.85rem;
    color: var(--muted-brown);
    text-decoration: none;
    padding: 0.6rem 0.8rem;
    border-radius: 4px;
    transition: color 0.3s ease, background-color 0.3s ease;
}

.nav-link:hover {
    color: var(--deep-brown);
    background-color: rgba(138, 172, 184, 0.15);
}

.nav-link.active {
    color: var(--terracotta);
    background-color: rgba(184, 96, 63, 0.08);
}

.sidebar-footer {
    margin-top: auto;
}

.sidebar-footer .mono-text {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.75rem;
    color: var(--muted-brown);
    opacity: 0.6;
}

/* Main Content */
.content {
    margin-left: 240px;
    width: calc(100% - 240px);
}

.chapter {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4rem 3rem;
    position: relative;
}

.chapter-inner {
    max-width: 700px;
    width: 100%;
    text-align: center;
}

.chapter-title {
    font-family: 'Nunito', sans-serif;
    font-size: clamp(2.4rem, 5vw, 4.5rem);
    font-weight: 700;
    letter-spacing: -0.015em;
    color: var(--deep-brown);
    margin-bottom: 1.5rem;
    line-height: 1.1;
}

.chapter-text {
    font-size: 1.15rem;
    line-height: 1.7;
    color: var(--mid-brown);
    margin-bottom: 2.5rem;
    max-width: 560px;
    margin-left: auto;
    margin-right: auto;
}

.mono-text {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.8rem;
}

/* Fade Reveal */
.fade-reveal {
    opacity: 0;
    transform: translateY(24px);
    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);
}

.fade-reveal.visible {
    opacity: 1;
    transform: translateY(0);
}

/* Frost Dividers */
.frost-divider {
    width: 100%;
    height: 80px;
    margin-bottom: 2rem;
    opacity: 0.5;
}

.frost-divider svg {
    width: 100%;
    height: 100%;
}

.frost-path {
    fill: none;
    stroke: var(--pale-blue);
    stroke-width: 1.5;
    opacity: 0.6;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* Portal Circle */
.portal-circle {
    width: 200px;
    height: 200px;
    margin: 2rem auto;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.portal-ring {
    position: absolute;
    width: 100%;
    height: 100%;
    border: 2px solid var(--pale-blue);
    border-radius: 50%;
    opacity: 0.4;
    animation: portal-pulse 4s ease-in-out infinite;
}

.portal-ring.ring-2 {
    width: 70%;
    height: 70%;
    animation-delay: 0.8s;
    border-color: var(--terracotta);
    opacity: 0.3;
}

.portal-ring.ring-3 {
    width: 40%;
    height: 40%;
    animation-delay: 1.6s;
}

@keyframes portal-pulse {
    0%, 100% { transform: scale(1); opacity: 0.4; }
    50% { transform: scale(1.08); opacity: 0.7; }
}

/* Glass Grid */
.glass-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    max-width: 320px;
    margin: 0 auto;
}

.glass-cell {
    aspect-ratio: 1;
    background: linear-gradient(135deg, var(--ice-blue), rgba(138, 172, 184, 0.3));
    border: 1px solid rgba(138, 172, 184, 0.4);
    border-radius: 6px;
    transition: transform 0.4s ease, background 0.4s ease;
}

.glass-cell:hover {
    transform: scale(1.08);
    background: linear-gradient(135deg, var(--pale-blue), var(--ice-blue));
}

/* Library Cards */
.library-cards {
    display: flex;
    gap: 1.5rem;
    justify-content: center;
    flex-wrap: wrap;
}

.library-card {
    background: var(--warm-sand);
    border: 1px solid rgba(138, 172, 184, 0.3);
    border-radius: 8px;
    padding: 1.5rem 1.2rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    width: 160px;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.library-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 24px rgba(44, 36, 24, 0.08);
}

.card-crystal {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, var(--ice-blue), var(--pale-blue));
    clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
}

/* Emergence Glow */
.emergence-glow {
    display: flex;
    justify-content: center;
    margin-top: 2rem;
}

.glow-orb {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    background: radial-gradient(circle, var(--terracotta) 0%, rgba(184, 96, 63, 0.2) 50%, transparent 70%);
    animation: glow-breathe 3s ease-in-out infinite;
}

@keyframes glow-breathe {
    0%, 100% { transform: scale(1); opacity: 0.7; }
    50% { transform: scale(1.15); opacity: 1; }
}

/* Section-specific backgrounds */
#surface {
    background-color: var(--warm-white);
}

#looking-glass {
    background: linear-gradient(180deg, var(--warm-white) 0%, var(--ice-blue) 100%);
}

#ice-library {
    background-color: var(--ice-blue);
}

#emergence {
    background: linear-gradient(180deg, var(--ice-blue) 0%, var(--warm-white) 100%);
}

/* Mobile */
@media (max-width: 768px) {
    .sidebar {
        width: 100%;
        height: auto;
        position: relative;
        flex-direction: row;
        align-items: center;
        padding: 1rem;
        gap: 1rem;
    }

    .sidebar-logo {
        margin-bottom: 0;
        font-size: 1.3rem;
    }

    .sidebar-nav {
        flex-direction: row;
        gap: 0.3rem;
    }

    .sidebar-footer {
        display: none;
    }

    .content {
        margin-left: 0;
        width: 100%;
    }

    body {
        flex-direction: column;
    }

    .library-cards {
        flex-direction: column;
        align-items: center;
    }
}
