/* ============================================
   RRIDDL.com - Fairycore Tech Fusion
   ============================================ */

/* === CSS RESET & BASE === */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

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

body {
    font-family: 'DM Sans', sans-serif;
    font-weight: 400;
    font-size: clamp(1rem, 1.8vw, 1.125rem);
    line-height: 1.72;
    color: #4A4458;
    overflow-x: hidden;
    position: relative;
    /* Tall gradient background: morning lavender -> rose quartz -> mint cream -> twilight periwinkle */
    background: linear-gradient(
        to bottom,
        #E8DFF0 0%,
        #E8DFF0 15%,
        #F2E0E6 30%,
        #F2E0E6 45%,
        #E0F0E8 60%,
        #E0F0E8 75%,
        #D8DBF0 90%,
        #D8DBF0 100%
    );
    background-attachment: fixed;
    min-height: 100vh;
}

/* === PAPER TEXTURE OVERLAY === */
#paper-texture {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 100;
    pointer-events: none;
    opacity: 0.03;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cline x1='0' y1='12' x2='200' y2='14' stroke='%234A4458' stroke-width='0.3'/%3E%3Cline x1='0' y1='38' x2='200' y2='36' stroke='%234A4458' stroke-width='0.2'/%3E%3Cline x1='0' y1='67' x2='200' y2='69' stroke='%234A4458' stroke-width='0.3'/%3E%3Cline x1='0' y1='95' x2='200' y2='93' stroke='%234A4458' stroke-width='0.2'/%3E%3Cline x1='0' y1='121' x2='200' y2='123' stroke='%234A4458' stroke-width='0.3'/%3E%3Cline x1='0' y1='148' x2='200' y2='146' stroke='%234A4458' stroke-width='0.2'/%3E%3Cline x1='0' y1='175' x2='200' y2='177' stroke='%234A4458' stroke-width='0.3'/%3E%3Cline x1='15' y1='0' x2='13' y2='200' stroke='%234A4458' stroke-width='0.2'/%3E%3Cline x1='52' y1='0' x2='54' y2='200' stroke='%234A4458' stroke-width='0.15'/%3E%3Cline x1='89' y1='0' x2='87' y2='200' stroke='%234A4458' stroke-width='0.2'/%3E%3Cline x1='134' y1='0' x2='136' y2='200' stroke='%234A4458' stroke-width='0.15'/%3E%3Cline x1='172' y1='0' x2='170' y2='200' stroke='%234A4458' stroke-width='0.2'/%3E%3C/svg%3E");
    background-repeat: repeat;
}

/* === SCROLL PROGRESS INDICATOR === */
#scroll-progress {
    position: fixed;
    top: 0;
    left: 0;
    width: 2px;
    height: 0%;
    background: linear-gradient(to bottom, #C8A2C8, #98D8C8);
    z-index: 1000;
    transition: height 0.1s linear;
}

/* === MOTH NAVIGATION === */
#nav-moth {
    position: fixed;
    top: 20px;
    left: 20px;
    z-index: 999;
    background: none;
    border: none;
    cursor: pointer;
    padding: 6px;
    transition: transform 0.3s ease;
}

#nav-moth:hover {
    transform: scale(1.15);
}

.moth-sigil .moth-wing-left {
    transform-origin: 16px 16px;
    animation: flutter-left 3s ease-in-out infinite;
}

.moth-sigil .moth-wing-right {
    transform-origin: 16px 16px;
    animation: flutter-right 3s ease-in-out infinite;
}

@keyframes flutter-left {
    0%, 100% { transform: rotate(0deg); }
    50% { transform: rotate(-8deg); }
}

@keyframes flutter-right {
    0%, 100% { transform: rotate(0deg); }
    50% { transform: rotate(8deg); }
}

/* === NAVIGATION OVERLAY === */
#nav-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 998;
    background: linear-gradient(135deg, rgba(232, 223, 240, 0.92), rgba(200, 162, 200, 0.88));
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.4s ease, visibility 0.4s ease;
    backdrop-filter: blur(8px);
}

#nav-overlay.active {
    opacity: 1;
    visibility: visible;
}

.nav-panel {
    display: flex;
    flex-direction: column;
    gap: 28px;
}

.nav-link {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 500;
    font-size: clamp(1.4rem, 3vw, 2rem);
    letter-spacing: 0.01em;
    color: #3B3256;
    text-decoration: none;
    transition: color 0.3s ease, transform 0.3s ease;
    display: block;
}

.nav-link:hover {
    color: #E8A0B0;
    transform: translateX(10px);
}

/* === PARALLAX MID-LAYER === */
#parallax-layer {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    pointer-events: none;
    overflow: hidden;
}

.parallax-element {
    position: absolute;
    will-change: transform;
    transition: opacity 0.3s ease;
}

.parallax-element.circuit:hover {
    opacity: 1 !important;
}

.circuit-node {
    animation: circuit-pulse 2s ease-in-out infinite;
}

@keyframes circuit-pulse {
    0%, 100% {
        r: 3;
        opacity: 0.35;
        filter: none;
    }
    50% {
        r: 5;
        opacity: 0.6;
        filter: drop-shadow(0 0 4px rgba(152, 216, 200, 0.4));
    }
}

/* === FIREFLY PARTICLES === */
#fireflies {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 50;
    pointer-events: none;
    overflow: hidden;
}

.firefly {
    position: absolute;
    bottom: -10px;
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: radial-gradient(circle, #D4B870 0%, rgba(212, 184, 112, 0) 70%);
    animation: firefly-rise linear infinite, firefly-pulse 2s ease-in-out infinite alternate, firefly-drift 4s ease-in-out infinite alternate;
}

@keyframes firefly-rise {
    0% {
        bottom: -10px;
        opacity: 0;
    }
    5% {
        opacity: 0.3;
    }
    80% {
        opacity: 0.7;
    }
    100% {
        bottom: 110vh;
        opacity: 0;
    }
}

@keyframes firefly-pulse {
    0% { opacity: 0.3; transform: scale(1); }
    100% { opacity: 0.8; transform: scale(1.3); }
}

@keyframes firefly-drift {
    0% { transform: translateX(-15px); }
    100% { transform: translateX(15px); }
}

/* === CONTENT LAYOUT === */
.section {
    position: relative;
    z-index: 10;
    max-width: 680px;
    margin: 0 auto;
    padding: 0 24px;
}

/* === SECTION 1: OPENING === */
.section-opening {
    max-width: 100%;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    padding: 0;
}

.hero-moth {
    position: absolute;
    width: 40vw;
    max-width: 500px;
    opacity: 0;
    z-index: 0;
    animation: moth-fade-in 2s ease-out 1s forwards;
}

@keyframes moth-fade-in {
    0% { opacity: 0; }
    100% { opacity: 0.15; }
}

.hero-moth .moth-wing-left {
    transform-origin: 200px 150px;
    animation: hero-flutter-left 4s ease-in-out infinite;
}

.hero-moth .moth-wing-right {
    transform-origin: 200px 150px;
    animation: hero-flutter-right 4s ease-in-out infinite;
}

@keyframes hero-flutter-left {
    0%, 100% { transform: rotate(0deg) scaleX(1); }
    50% { transform: rotate(-3deg) scaleX(0.97); }
}

@keyframes hero-flutter-right {
    0%, 100% { transform: rotate(0deg) scaleX(1); }
    50% { transform: rotate(3deg) scaleX(0.97); }
}

.hero-content {
    position: relative;
    z-index: 5;
    text-align: center;
}

.hero-title {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 700;
    font-size: clamp(3rem, 12vw, 10rem);
    letter-spacing: -0.03em;
    line-height: 1.05;
    color: #3B3256;
    margin-bottom: 20px;
}

.hero-title .letter {
    display: inline-block;
    opacity: 0;
    transform: translateY(30px);
    animation: letter-in 0.5s ease-out forwards;
}

@keyframes letter-in {
    0% {
        opacity: 0;
        transform: translateY(30px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

.hero-tagline {
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 400;
    font-size: 0.85rem;
    letter-spacing: 0.02em;
    color: #7A8B7A;
    opacity: 0;
    animation: tagline-in 0.8s ease-out 2.25s forwards;
}

@keyframes tagline-in {
    0% {
        opacity: 0;
        transform: translateY(10px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

/* === WATERCOLOR DIVIDERS === */
.watercolor-divider {
    position: relative;
    z-index: 10;
    margin: 60px 0;
    width: 100%;
    overflow: hidden;
}

/* === WATERCOLOR CLEARINGS === */
.watercolor-clearing {
    margin: 80px -24px;
    width: calc(100% + 48px);
    position: relative;
    overflow: hidden;
}

.section-opening + .watercolor-divider {
    margin-top: 0;
}

/* === SECTION GENERAL === */
.section-descent,
.section-riddles,
.section-network,
.section-twilight {
    padding-top: 60px;
    padding-bottom: 60px;
}

/* === TEXT PASSAGES === */
.text-passage {
    margin-bottom: 40px;
}

.text-passage p {
    font-family: 'DM Sans', sans-serif;
    font-weight: 400;
    font-size: clamp(1rem, 1.8vw, 1.125rem);
    line-height: 1.72;
    color: #4A4458;
}

/* === SECTION HEADINGS === */
.section-heading {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 500;
    font-size: clamp(1.1rem, 2.5vw, 1.6rem);
    letter-spacing: 0.01em;
    color: #5E6B5A;
    margin-bottom: 40px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.heading-moth {
    flex-shrink: 0;
}

/* === ANNOTATION TEXT === */
.annotation {
    font-family: 'IBM Plex Mono', monospace !important;
    font-weight: 400 !important;
    font-size: 0.85em !important;
    letter-spacing: 0.02em;
    color: #7A8B7A !important;
    line-height: 1.6 !important;
}

/* === CODE BLOCKS === */
.code-block {
    font-family: 'IBM Plex Mono', monospace !important;
    font-weight: 400 !important;
    font-size: 0.85em !important;
    letter-spacing: 0.02em;
    color: #7A8B7A !important;
    background: rgba(224, 240, 232, 0.4);
    border-left: 2px solid #98D8C8;
    padding: 20px 24px;
    border-radius: 0 4px 4px 0;
    line-height: 1.8 !important;
}

.code-line {
    display: block;
    padding-left: 16px;
}

.inline-code {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.85em;
    background: rgba(224, 240, 232, 0.5);
    padding: 2px 6px;
    border-radius: 3px;
    border: 1px solid rgba(152, 216, 200, 0.3);
}

/* === FADE-IN ANIMATION === */
.fade-in-up {
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.6s ease-out, transform 0.6s ease-out;
}

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

/* === SECTION: TWILIGHT === */
.section-twilight {
    padding-bottom: 0;
}

.clearing-final {
    margin-bottom: 0;
}

.end-transmission {
    text-align: center;
    padding: 60px 24px 80px;
}

.end-transmission p {
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 400;
    font-size: 0.85rem;
    letter-spacing: 0.02em;
    color: #C8A2C8;
    opacity: 0.5;
}

/* === MOBILE RESPONSIVE === */
@media (max-width: 768px) {
    .section {
        padding: 0 24px;
    }

    .hero-title {
        font-size: clamp(2.5rem, 14vw, 5rem);
    }

    .watercolor-clearing {
        margin: 60px -24px;
        width: calc(100% + 48px);
    }

    .watercolor-divider {
        margin: 40px 0;
    }

    #nav-moth {
        top: 14px;
        left: 14px;
    }

    .parallax-element {
        display: none;
    }

    .firefly:nth-child(n+10) {
        display: none;
    }
}

/* === SELECTION HIGHLIGHT === */
::selection {
    background: rgba(200, 162, 200, 0.3);
    color: #3B3256;
}

/* === SCROLLBAR STYLING === */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: #E8DFF0;
}

::-webkit-scrollbar-thumb {
    background: #C8A2C8;
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: #E8A0B0;
}
