/* ============================================
   namu.quest — Glitch Forest Quest Platform
   ============================================ */

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

html {
    scroll-behavior: smooth;
}

body {
    background-color: #1A3A28;
    color: #F0EDE0;
    font-family: 'Merriweather', Georgia, serif;
    font-weight: 400;
    font-size: clamp(15px, 1vw, 17px);
    line-height: 2.0;
    overflow-x: hidden;
}

/* --- Typography --- */
h1, h2, .quest-title {
    font-family: 'Bebas Neue', 'Arial Narrow', sans-serif;
    font-weight: 400;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

/* --- Glitch Canopy (Hero) --- */
#glitch-canopy {
    position: relative;
    width: 100%;
    height: 100vh;
    background-color: #1A3A28;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    overflow: hidden;
}

#canopy-content {
    position: relative;
    z-index: 2;
    margin-left: 15%;
}

#site-title {
    font-family: 'Bebas Neue', 'Arial Narrow', sans-serif;
    font-size: clamp(48px, 8vw, 120px);
    letter-spacing: 0.06em;
    color: #F0EDE0;
    text-shadow:
        -2px 0 #E83838,
        2px 0 #38E8E8;
    position: relative;
    opacity: 0;
    animation: titleAssemble 0.6s ease-out 0.3s forwards;
}

@keyframes titleAssemble {
    0% {
        opacity: 0;
        text-shadow:
            -4px 0 #E83838,
            4px 0 #38E8E8;
        transform: translateX(-10px);
    }
    50% {
        opacity: 1;
        text-shadow:
            -3px 0 #E83838,
            3px 0 #38E8E8;
    }
    100% {
        opacity: 1;
        text-shadow:
            -2px 0 #E83838,
            2px 0 #38E8E8;
        transform: translateX(0);
    }
}

#site-title:hover {
    text-shadow:
        -4px 0 #E83838,
        4px 0 #38E8E8;
    transition: text-shadow 0.2s ease;
}

#canopy-subtitle {
    font-family: 'Merriweather', Georgia, serif;
    font-style: italic;
    font-size: clamp(14px, 1.2vw, 18px);
    color: #6A7A68;
    margin-top: 1rem;
    opacity: 0;
    animation: fadeIn 0.8s ease-out 0.9s forwards;
}

@keyframes fadeIn {
    to { opacity: 1; }
}

/* --- Glitch Lines (Canopy) --- */
.glitch-line {
    position: absolute;
    left: 0;
    width: 100%;
    height: 3px;
    background-color: #E83838;
    z-index: 3;
    opacity: 0;
    transform: translateX(0);
}

.glitch-line-1 {
    top: 30%;
    animation: glitchLineShift 0.1s ease-in-out 0s 1 forwards,
               glitchLineFade 0.1s ease-in-out 0.1s 1 forwards;
}

.glitch-line-2 {
    top: 55%;
    background-color: #38E8E8;
    animation: glitchLineShift 0.1s ease-in-out 0.1s 1 forwards,
               glitchLineFade 0.1s ease-in-out 0.2s 1 forwards;
}

.glitch-line-3 {
    top: 78%;
    animation: glitchLineShift 0.1s ease-in-out 0.2s 1 forwards,
               glitchLineFade 0.1s ease-in-out 0.3s 1 forwards;
}

@keyframes glitchLineShift {
    0% {
        opacity: 0.8;
        transform: translateX(-100%);
    }
    50% {
        opacity: 1;
        transform: translateX(20px);
    }
    100% {
        opacity: 0.8;
        transform: translateX(0);
    }
}

@keyframes glitchLineFade {
    to {
        opacity: 0;
    }
}

/* --- Canopy Glitch Pseudo-Elements --- */
#glitch-canopy::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: repeating-linear-gradient(
        0deg,
        transparent,
        transparent 4px,
        rgba(26, 58, 40, 0.3) 4px,
        rgba(26, 58, 40, 0.3) 5px
    );
    pointer-events: none;
    z-index: 1;
    opacity: 0.4;
}

/* --- Quest Log (F-Pattern Layout) --- */
#quest-log {
    padding: 6rem 0;
    position: relative;
}

/* --- Quest Entry --- */
.quest-entry {
    margin-left: 15%;
    max-width: 65%;
    margin-bottom: 4rem;
    position: relative;
}

.quest-entry .quest-title {
    font-size: clamp(28px, 3.5vw, 56px);
    color: #F0EDE0;
    margin-bottom: 1rem;
    text-shadow:
        -2px 0 #E83838,
        2px 0 #38E8E8;
    transition: text-shadow 0.2s ease;
}

.quest-entry .quest-title:hover {
    text-shadow:
        -4px 0 #E83838,
        4px 0 #38E8E8;
}

.quest-entry .quest-body p {
    color: #F0EDE0;
    line-height: 2.0;
}

/* --- Glitch Entry (Every 5th) --- */
.quest-entry-glitch {
    transition: transform 0.2s ease, opacity 0.2s ease;
}

.quest-entry-glitch.glitch-active {
    animation: entryGlitch 0.2s ease-in-out;
}

@keyframes entryGlitch {
    0% {
        transform: translateX(0);
    }
    25% {
        transform: translateX(8px);
    }
    50% {
        transform: translateX(-4px);
    }
    75% {
        transform: translateX(8px);
    }
    100% {
        transform: translateX(0);
    }
}

.quest-entry-glitch.glitch-active .quest-title {
    text-shadow:
        -4px 0 #E83838,
        4px 0 #38E8E8;
}

/* --- Glitch Disruption Lines on Every 5th Entry --- */
.quest-entry-glitch::before {
    content: '';
    position: absolute;
    left: -5%;
    width: 110%;
    height: 2px;
    top: -8px;
    background: linear-gradient(90deg, transparent 0%, #E83838 20%, #38E8E8 50%, transparent 100%);
    opacity: 0.6;
}

.quest-entry-glitch::after {
    content: '';
    position: absolute;
    left: -5%;
    width: 110%;
    height: 3px;
    bottom: -8px;
    background: linear-gradient(90deg, transparent 0%, #38E8E8 30%, #E83838 70%, transparent 100%);
    opacity: 0.6;
}

/* --- Specimen Cards --- */
.specimen-card {
    position: relative;
    margin-left: 15%;
    max-width: 50%;
    margin-bottom: 4rem;
    padding: 2rem 2.5rem;
    border: 1px solid #6A7A68;
    overflow: hidden;
    transition: transform 0.3s ease;
}

.specimen-card:hover {
    transform: rotate(0.5deg);
}

.specimen-card .marble-texture {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0.15;
    z-index: 0;
    pointer-events: none;
}

.specimen-card.specimen-visible .marble-texture {
    animation: marbleReveal 0.8s ease-out forwards;
}

@keyframes marbleReveal {
    from { opacity: 0.08; }
    to { opacity: 0.15; }
}

.specimen-data {
    position: relative;
    z-index: 1;
}

.specimen-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    padding: 0.4rem 0;
    border-bottom: 1px solid rgba(106, 122, 104, 0.3);
}

.specimen-row:last-child {
    border-bottom: none;
}

.specimen-label {
    font-family: 'Bebas Neue', 'Arial Narrow', sans-serif;
    font-size: 14px;
    letter-spacing: 0.06em;
    color: #C8B898;
}

.specimen-value {
    font-family: 'Merriweather', Georgia, serif;
    font-style: italic;
    font-size: 14px;
    color: #F0EDE0;
}

/* --- Quest Map (Footer) --- */
#quest-map {
    padding: 4rem 0 6rem;
    position: relative;
    border-top: 1px solid #6A7A68;
    margin-top: 2rem;
}

#map-title {
    font-size: clamp(28px, 3.5vw, 56px);
    color: #F0EDE0;
    margin-left: 15%;
    margin-bottom: 2rem;
    text-shadow:
        -2px 0 #E83838,
        2px 0 #38E8E8;
}

#map-container {
    margin-left: 10%;
    margin-right: 10%;
}

#quest-network {
    width: 100%;
    height: auto;
    max-height: 500px;
}

/* --- Quest Connections --- */
.quest-connection {
    stroke: #6A7A68;
    stroke-width: 1.5;
    stroke-dasharray: 1000;
    stroke-dashoffset: 1000;
    transition: stroke 0.3s ease;
}

.quest-connection.connection-drawn {
    animation: drawConnection 1.5s ease-out forwards;
}

@keyframes drawConnection {
    to {
        stroke-dashoffset: 0;
    }
}

/* --- Quest Nodes --- */
.quest-node circle {
    transition: transform 0.3s ease, filter 0.3s ease;
    transform-origin: center;
}

.quest-node.completed circle {
    fill: #48C878;
    filter: drop-shadow(0 0 4px #48C878);
}

.quest-node.active circle {
    fill: #48C878;
    filter: drop-shadow(0 0 8px #48C878);
    animation: nodePulseAmbient 2s ease-in-out infinite;
}

@keyframes nodePulseAmbient {
    0%, 100% {
        filter: drop-shadow(0 0 4px #48C878);
    }
    50% {
        filter: drop-shadow(0 0 12px #48C878);
    }
}

.quest-node.upcoming circle {
    fill: #6A7A68;
    opacity: 0.5;
}

.quest-node:hover circle {
    animation: nodePulseHover 0.3s ease forwards;
}

@keyframes nodePulseHover {
    to {
        transform: scale(1.3);
        filter: drop-shadow(0 0 12px #48C878);
    }
}

.node-label {
    font-family: 'Bebas Neue', 'Arial Narrow', sans-serif;
    font-size: 10px;
    letter-spacing: 0.08em;
}

/* --- Scanline Overlay (Subtle) --- */
body::after {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: repeating-linear-gradient(
        0deg,
        transparent,
        transparent 2px,
        rgba(0, 0, 0, 0.03) 2px,
        rgba(0, 0, 0, 0.03) 4px
    );
    pointer-events: none;
    z-index: 9999;
}

/* --- Scrollbar Styling --- */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: #1A3A28;
}

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

::-webkit-scrollbar-thumb:hover {
    background: #48C878;
}

/* --- Responsive Adjustments --- */
@media (max-width: 768px) {
    .quest-entry {
        margin-left: 8%;
        max-width: 84%;
    }

    .specimen-card {
        margin-left: 8%;
        max-width: 84%;
    }

    #canopy-content {
        margin-left: 8%;
    }

    #map-title {
        margin-left: 8%;
    }

    #map-container {
        margin-left: 4%;
        margin-right: 4%;
    }

    .specimen-row {
        flex-direction: column;
        gap: 0.2rem;
    }
}
