/* ============================================
   nonri.day - Goblincore Tech Tutorial
   Forest Floor Terminal Aesthetic
   ============================================ */

/* --- CSS Custom Properties --- */
:root {
    --forest-floor: #1c1b16;
    --decayed-bark: #2a2720;
    --undergrowth-black: #1a1a14;
    --lichen-gray: #c4bfab;
    --bone-parchment: #f2e6d0;
    --aurora-ember: #e8a849;
    --moss-glow: #6b8f5e;
    --aurora-violet: #8b6bbd;
    --spore-amber: #c97d3c;
    --mycelium-white: #e9e3d4;
    --deep-loam: #3d3828;
    --northern-green: #3ca67a;
    --twilight-magenta: #a355a0;
}

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

html {
    scroll-behavior: smooth;
    scrollbar-width: thin;
    scrollbar-color: var(--deep-loam) var(--forest-floor);
}

body {
    background-color: var(--forest-floor);
    color: var(--lichen-gray);
    font-family: 'Source Sans 3', 'Source Sans Pro', sans-serif;
    font-weight: 400;
    font-size: clamp(1rem, 1.8vw, 1.15rem);
    line-height: 1.72;
    overflow-x: hidden;
}

body.hero-locked {
    overflow: hidden;
}

/* --- Paper Grain SVG Filter --- */
svg.paper-grain-filter {
    position: absolute;
    width: 0;
    height: 0;
}

/* --- Aurora Background Layer --- */
.aurora-bg {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
    opacity: 0;
}

/* --- Sidebar Navigation --- */
.sidebar-nav {
    position: fixed;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    z-index: 100;
    display: flex;
    flex-direction: column;
    gap: 20px;
    padding: 20px 12px;
    background: rgba(28, 27, 22, 0.6);
    border-radius: 0 8px 8px 0;
    backdrop-filter: blur(4px);
}

.nav-icon {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    color: var(--mycelium-white);
    opacity: 0.5;
    text-decoration: none;
    transition: transform 300ms ease, opacity 300ms ease, color 300ms ease, filter 300ms ease;
    cursor: pointer;
}

.nav-icon:hover {
    transform: scale(1.15);
    opacity: 1;
    color: var(--aurora-ember);
    filter: drop-shadow(0 0 6px rgba(232, 168, 73, 0.4));
}

.nav-icon.active {
    color: var(--moss-glow);
    opacity: 0.9;
    filter: drop-shadow(0 0 6px rgba(107, 143, 94, 0.4));
}

.nav-icon::after {
    content: attr(data-tooltip);
    position: absolute;
    left: 48px;
    top: 50%;
    transform: translateY(-50%);
    background: var(--decayed-bark);
    color: var(--bone-parchment);
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 0.8rem;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 200ms ease;
    border: 1px solid var(--deep-loam);
}

.nav-icon:hover::after {
    opacity: 1;
}

/* --- Hero Section --- */
.hero {
    position: relative;
    width: 100%;
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    z-index: 1;
}

.hero-aurora {
    position: absolute;
    top: 0;
    left: -20%;
    width: 140%;
    height: 40%;
    background: linear-gradient(
        90deg,
        var(--northern-green) 25%,
        var(--aurora-violet) 55%,
        var(--twilight-magenta) 85%
    );
    background-size: 200% 200%;
    animation: auroraShift 8s ease-in-out infinite;
    filter: blur(40px);
    opacity: 0;
    transition: opacity 1200ms ease;
    z-index: 1;
}

@keyframes auroraShift {
    0%, 100% {
        background-position: 0% 50%;
    }
    50% {
        background-position: 100% 50%;
    }
}

.hero-content {
    position: relative;
    z-index: 2;
    text-align: center;
    padding: 0 20px;
}

.hero-title {
    font-family: 'Playfair Display', serif;
    font-weight: 900;
    font-size: clamp(3rem, 8vw, 7rem);
    letter-spacing: -0.02em;
    color: var(--aurora-ember);
    line-height: 1.1;
    margin-bottom: 24px;
}

.hero-title .letter {
    display: inline-block;
    opacity: 0;
    transform: translateY(12px);
    transition: opacity 400ms ease, transform 400ms ease;
}

.hero-title .letter.visible {
    opacity: 1;
    transform: translateY(0);
}

.hero-subtitle {
    font-family: 'Source Sans 3', sans-serif;
    font-weight: 400;
    font-style: italic;
    font-size: 1.2rem;
    color: var(--lichen-gray);
    opacity: 0;
    transition: opacity 600ms ease;
}

.hero-subtitle.visible {
    opacity: 1;
}

.scroll-hint {
    position: absolute;
    bottom: 40px;
    left: 50%;
    transform: translateX(-50%);
    color: var(--lichen-gray);
    opacity: 0;
    animation: scrollBounce 2s ease-in-out infinite;
    animation-delay: 3s;
    z-index: 2;
}

.scroll-hint.visible {
    opacity: 0.5;
}

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

/* --- Mycelium Dividers --- */
.mycelium-divider {
    position: relative;
    width: 100%;
    max-width: 800px;
    margin: 0 auto;
    padding: 20px 0;
    overflow: visible;
}

.mycelium-divider svg {
    width: 100%;
    height: 60px;
    overflow: visible;
}

.mycelium-path {
    stroke: var(--mycelium-white);
    opacity: 0.3;
    stroke-linecap: round;
    stroke-dasharray: 1000;
    stroke-dashoffset: 1000;
    transition: stroke-dashoffset 800ms ease;
}

.mycelium-divider.revealed .mycelium-path {
    stroke-dashoffset: 0;
}

/* --- Content Sections --- */
.content-section {
    position: relative;
    padding: 40px 20px;
    z-index: 1;
}

.content-block {
    position: relative;
    max-width: 720px;
    background-color: var(--decayed-bark);
    padding: 48px 40px;
    margin-bottom: 60px;
    box-shadow: inset 0 0 60px rgba(28, 27, 22, 0.5);
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 600ms cubic-bezier(0.25, 0.46, 0.45, 0.94),
                transform 600ms cubic-bezier(0.25, 0.46, 0.45, 0.94);
    /* Torn paper edges */
    clip-path: polygon(
        0% 2%, 3% 0%, 7% 1%, 12% 0%, 18% 1.5%, 25% 0%, 32% 0.5%,
        40% 0%, 48% 1%, 55% 0%, 63% 0.8%, 70% 0%, 78% 1.2%, 85% 0%,
        92% 0.5%, 97% 0%, 100% 1.5%,
        100% 97%, 97% 100%, 92% 98.5%, 85% 100%, 78% 99%, 70% 100%,
        63% 98.8%, 55% 100%, 48% 99.2%, 40% 100%, 32% 98%, 25% 100%,
        18% 99%, 12% 100%, 7% 98.5%, 3% 100%, 0% 98%
    );
}

.content-block.revealed {
    opacity: 1;
    transform: translateY(0);
}

/* Zigzag layout: odd left, even right */
.content-block.odd {
    margin-left: 3vw;
}

.content-block.even {
    margin-left: 8vw;
}

/* Paper grain noise effect */
.content-block::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.7' numOctaves='5' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='200' height='200' filter='url(%23n)' opacity='0.04'/%3E%3C/svg%3E");
    opacity: 0.4;
    pointer-events: none;
    z-index: 0;
}

.content-block > * {
    position: relative;
    z-index: 1;
}

/* Stain marks */
.stain {
    position: absolute;
    border-radius: 50%;
    background: radial-gradient(circle, var(--spore-amber) 0%, transparent 70%);
    pointer-events: none;
    z-index: 0;
}

.stain-1 {
    width: 50px;
    height: 50px;
    top: 20px;
    right: 40px;
    opacity: 0.1;
}

.stain-2 {
    width: 40px;
    height: 40px;
    bottom: 30px;
    left: 25px;
    opacity: 0.08;
}

.stain-3 {
    width: 60px;
    height: 60px;
    top: 40px;
    left: 60px;
    opacity: 0.12;
}

.stain-4 {
    width: 35px;
    height: 35px;
    top: 15px;
    right: 80px;
    opacity: 0.09;
}

/* Aurora insight blocks */
.content-block.aurora-insight {
    border-image: linear-gradient(135deg, var(--northern-green) 0%, var(--aurora-violet) 50%, var(--twilight-magenta) 100%) 1;
    border-width: 2px;
    border-style: solid;
    /* Need to override clip-path border conflict -- use box-shadow glow instead */
    clip-path: none;
    border-radius: 2px;
}

.content-block.aurora-insight::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--northern-green), var(--aurora-violet), var(--twilight-magenta));
    opacity: 0.7;
}

/* --- Typography --- */
.content-block h2 {
    font-family: 'Playfair Display', serif;
    font-weight: 900;
    font-size: clamp(1.8rem, 3.5vw, 2.8rem);
    letter-spacing: -0.02em;
    color: var(--bone-parchment);
    margin-bottom: 24px;
    line-height: 1.2;
    transition: transform 200ms ease;
}

.content-block h2:hover {
    transform: scale(1.02);
}

.content-block p {
    max-width: 65ch;
    margin-bottom: 20px;
    color: var(--lichen-gray);
}

.content-block p:last-of-type {
    margin-bottom: 0;
}

/* --- Code Blocks --- */
.code-block {
    background-color: rgba(26, 26, 20, 0.9);
    border-left: 3px solid rgba(107, 143, 94, 0.7);
    padding: 20px 24px;
    margin: 24px 0;
    box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.3);
    border-radius: 2px;
    overflow-x: auto;
    transition: border-color 300ms ease, transform 200ms ease;
}

.code-block:hover {
    border-left-color: var(--moss-glow);
    transform: scale(1.005);
}

.code-block code {
    display: block;
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 400;
    font-size: 0.92em;
    color: #d4cfb8;
    line-height: 1.7;
    white-space: pre;
}

.code-prompt {
    color: var(--moss-glow);
    font-weight: 500;
}

.code-comment {
    color: var(--spore-amber);
    opacity: 0.7;
}

/* Inline code */
.inline-code {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.88em;
    font-weight: 500;
    color: var(--spore-amber);
    background: rgba(26, 26, 20, 0.6);
    padding: 2px 6px;
    border-radius: 3px;
}

/* --- Links --- */
a {
    color: var(--lichen-gray);
    text-decoration: none;
    position: relative;
    transition: color 300ms ease;
}

.content-block a {
    display: inline-block;
    position: relative;
}

.content-block a::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 0;
    width: 0%;
    height: 2px;
    background-color: var(--aurora-ember);
    transition: width 300ms ease;
}

.content-block a:hover {
    color: var(--bone-parchment);
}

.content-block a:hover::after {
    width: 100%;
}

.content-block a:visited {
    color: var(--aurora-violet);
}

/* --- Closing Section --- */
.closing-block {
    opacity: 0;
    transform: translateY(30px);
}

.closing-block.revealed {
    opacity: 1;
    transform: translateY(0);
}

.closing-signature {
    font-family: 'Playfair Display', serif;
    font-weight: 900;
    font-style: italic;
    font-size: 1.15rem;
    color: var(--aurora-ember);
    margin-top: 32px;
    opacity: 0.8;
}

/* --- Forest Watermarks --- */
.forest-watermark {
    position: fixed;
    pointer-events: none;
    z-index: 0;
    opacity: 0.2;
}

.watermark-1 {
    top: 25%;
    right: 5%;
    color: var(--moss-glow);
}

.watermark-2 {
    top: 55%;
    right: 8%;
    color: var(--spore-amber);
}

.watermark-3 {
    top: 40%;
    left: calc(60px + 2%);
    color: var(--moss-glow);
}

.watermark-4 {
    top: 72%;
    left: calc(60px + 4%);
    color: var(--spore-amber);
}

/* --- Aurora Pools --- */
.aurora-pool {
    position: absolute;
    border-radius: 50%;
    pointer-events: none;
    z-index: 0;
    filter: blur(60px);
}

.pool-1 {
    width: 300px;
    height: 200px;
    top: 120vh;
    left: 10%;
    background: radial-gradient(ellipse, var(--northern-green) 0%, transparent 70%);
    opacity: 0.08;
}

.pool-2 {
    width: 250px;
    height: 180px;
    top: 220vh;
    right: 15%;
    background: radial-gradient(ellipse, var(--aurora-violet) 0%, transparent 70%);
    opacity: 0.06;
}

.pool-3 {
    width: 280px;
    height: 160px;
    top: 320vh;
    left: 20%;
    background: radial-gradient(ellipse, var(--twilight-magenta) 0%, transparent 70%);
    opacity: 0.07;
}

/* --- Responsive --- */
@media (max-width: 768px) {
    .sidebar-nav {
        display: none;
    }

    .content-block.odd,
    .content-block.even {
        margin-left: 5%;
        margin-right: 5%;
        padding: 32px 24px;
    }

    .content-block {
        max-width: 100%;
    }

    .forest-watermark {
        display: none;
    }
}

@media (max-width: 480px) {
    .hero-title {
        font-size: clamp(2.4rem, 12vw, 4rem);
    }

    .content-block h2 {
        font-size: clamp(1.4rem, 6vw, 2rem);
    }

    .code-block {
        padding: 14px 16px;
    }

    .code-block code {
        font-size: 0.82em;
    }
}
