/* === npc.quest — Goblincore Quest Log === */

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

/* === BASE === */
body {
    background-color: #f2ece0;
    color: #5c4a3a;
    font-family: 'Crimson Text', Georgia, serif;
    font-size: clamp(1rem, 1.8vw, 1.15rem);
    line-height: 1.75;
    overflow-x: hidden;
    /* Marble/parchment texture via layered gradients */
    background-image:
        radial-gradient(ellipse at 20% 50%, rgba(212,203,184,0.4) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 20%, rgba(143,164,122,0.15) 0%, transparent 40%),
        radial-gradient(ellipse at 50% 80%, rgba(196,154,60,0.08) 0%, transparent 45%),
        radial-gradient(ellipse at 70% 60%, rgba(212,203,184,0.3) 0%, transparent 35%),
        radial-gradient(ellipse at 30% 30%, rgba(155,77,106,0.05) 0%, transparent 30%);
}

/* === SCROLL INDICATOR (walking figure) === */
#scroll-indicator {
    position: fixed;
    left: 22px;
    top: 80px;
    z-index: 100;
    opacity: 0;
    transition: opacity 0.5s;
}
#scroll-indicator.visible {
    opacity: 0.7;
}

/* === TIMELINE PATH === */
#timeline-path {
    position: fixed;
    left: 20px;
    top: 0;
    width: 60px;
    height: 100vh;
    z-index: 5;
    opacity: 0;
    transition: opacity 0.8s;
    pointer-events: none;
}
#timeline-path.visible {
    opacity: 1;
}

/* === TITLE SCROLL === */
#title-scroll {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    background-color: #f2ece0;
    background-image:
        radial-gradient(ellipse at 25% 45%, rgba(212,203,184,0.5) 0%, transparent 50%),
        radial-gradient(ellipse at 75% 55%, rgba(143,164,122,0.12) 0%, transparent 45%),
        radial-gradient(ellipse at 50% 30%, rgba(196,154,60,0.06) 0%, transparent 40%);
}

.title-content {
    text-align: center;
    position: relative;
}

#title-scroll h1 {
    font-family: 'Caveat', cursive;
    font-size: clamp(3.5rem, 9vw, 8rem);
    font-weight: 700;
    color: #4a3728;
    text-shadow:
        0 0 1px #4a3728,
        0 0 3px rgba(74,55,40,0.3),
        1px 1px 0 rgba(74,55,40,0.15);
    line-height: 1.1;
    margin-bottom: 0.3em;
}

.subtitle {
    font-family: 'Crimson Text', serif;
    font-style: italic;
    font-size: clamp(1.1rem, 2.5vw, 1.6rem);
    color: #7a6b5d;
    letter-spacing: 0.02em;
}

/* Mushroom */
.mushroom-container {
    position: absolute;
    bottom: -60px;
    right: -80px;
    animation: mushroomPulse 3s ease-in-out infinite;
}
.mushroom-glow {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 100px;
    height: 100px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(143,164,122,0.3) 0%, transparent 70%);
    animation: glowPulse 3s ease-in-out infinite;
}
@keyframes mushroomPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}
@keyframes glowPulse {
    0%, 100% { opacity: 0.5; transform: translate(-50%, -50%) scale(1); }
    50% { opacity: 1; transform: translate(-50%, -50%) scale(1.2); }
}

/* Moth */
.moth-svg {
    position: absolute;
    top: -30px;
    right: -40px;
    animation: mothFloat 8s ease-in-out infinite;
    opacity: 0.6;
}
@keyframes mothFloat {
    0% { transform: translate(0, 0) rotate(0deg); }
    25% { transform: translate(-15px, -10px) rotate(-5deg); }
    50% { transform: translate(5px, -20px) rotate(3deg); }
    75% { transform: translate(-10px, -5px) rotate(-2deg); }
    100% { transform: translate(0, 0) rotate(0deg); }
}

/* Scroll arrow */
.scroll-arrow {
    margin-top: 3rem;
    animation: arrowBounce 2s ease-in-out infinite;
    opacity: 0.5;
}
@keyframes arrowBounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(10px); }
}

/* === WAYPOINTS === */
#waypoints {
    padding: 4rem 0 2rem 90px;
    position: relative;
    max-width: 1100px;
}

.waypoint {
    display: flex;
    align-items: flex-start;
    gap: 1.5rem;
    margin-bottom: 5rem;
    opacity: 0;
    transform: translateX(30px);
    transition: opacity 0.7s ease, transform 0.7s ease;
}
.waypoint.revealed {
    opacity: 1;
    transform: translateX(0) rotate(calc(var(--card-rotation, 0) * 1deg));
}

.waypoint-node {
    flex-shrink: 0;
    margin-top: 1rem;
}

/* Encounter cards */
.encounter-card {
    background-color: #f2ece0;
    background-image:
        radial-gradient(ellipse at 30% 40%, rgba(212,203,184,0.5) 0%, transparent 50%),
        radial-gradient(ellipse at 70% 70%, rgba(143,164,122,0.1) 0%, transparent 40%);
    padding: 2rem 2.5rem;
    max-width: 600px;
    width: 100%;
    position: relative;
    border: 1.5px solid #8fa47a;
}

.torn-1 {
    clip-path: polygon(
        0% 3%, 5% 0%, 12% 4%, 20% 1%, 30% 3%, 40% 0%, 50% 2%, 60% 0%, 70% 3%, 80% 1%, 90% 4%, 95% 0%, 100% 3%,
        100% 97%, 95% 100%, 88% 96%, 78% 100%, 68% 97%, 58% 100%, 48% 97%, 38% 100%, 28% 96%, 18% 100%, 8% 97%, 3% 100%, 0% 97%
    );
}
.torn-2 {
    clip-path: polygon(
        2% 0%, 10% 3%, 18% 0%, 28% 4%, 38% 1%, 48% 3%, 58% 0%, 68% 2%, 78% 0%, 88% 3%, 96% 0%, 100% 2%,
        98% 100%, 90% 97%, 82% 100%, 72% 96%, 62% 100%, 52% 97%, 42% 100%, 32% 96%, 22% 100%, 12% 97%, 4% 100%, 0% 98%
    );
}

.card-inner {
    position: relative;
}

.npc-name {
    font-family: 'Caveat', cursive;
    font-size: clamp(2rem, 5vw, 3rem);
    color: #4a3728;
    text-shadow: 0 0 1px #4a3728, 0 0 3px rgba(74,55,40,0.3);
    line-height: 1.2;
    margin-bottom: 0.2em;
}

.npc-role {
    font-family: 'Sono', sans-serif;
    font-weight: 500;
    font-size: clamp(0.7rem, 1.2vw, 0.85rem);
    letter-spacing: 0.04em;
    color: #7a6b5d;
    text-transform: uppercase;
    display: inline-block;
    background: #d4cbb8;
    padding: 0.15em 0.6em;
    border-radius: 2px;
    margin-bottom: 1em;
}

.speech-scroll {
    position: relative;
    background: rgba(212,203,184,0.4);
    border-left: 3px solid #c49a3c;
    padding: 1em 1.2em;
    margin: 1em 0;
    border-radius: 0 4px 4px 0;
}

.dialogue {
    font-family: 'Crimson Text', serif;
    font-style: italic;
    color: #4a3728;
    font-size: clamp(1rem, 1.6vw, 1.1rem);
}

.dialogue-note {
    font-family: 'Crimson Text', serif;
    color: #7a6b5d;
    font-size: 0.9em;
    margin-top: 0.4em;
}

.portrait-frame {
    width: 60px;
    height: 70px;
    border: 2px solid #8fa47a;
    border-radius: 3px;
    position: absolute;
    top: 0;
    right: 0;
    background: #f2ece0;
    display: flex;
    align-items: center;
    justify-content: center;
}
.portrait-empty {
    width: 40px;
    height: 50px;
    border: 1px dashed #d4cbb8;
    border-radius: 2px;
}

.quest-item {
    position: absolute;
    bottom: -5px;
    right: 10px;
    opacity: 0.6;
}

/* Key turning animation */
.turning-key {
    transform-origin: 25px 25px;
}
.midpoint.revealed .turning-key {
    animation: keyTurn 2s ease-in-out forwards;
}
@keyframes keyTurn {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* === CELTIC DIVIDER === */
.celtic-divider {
    text-align: center;
    padding: 2rem 0;
    opacity: 0.7;
}

/* === HOARD === */
#hoard {
    padding: 4rem 2rem 6rem;
    background-color: #d4cbb8;
    background-image:
        radial-gradient(ellipse at 40% 30%, rgba(242,236,224,0.4) 0%, transparent 50%),
        radial-gradient(ellipse at 70% 70%, rgba(46,36,24,0.08) 0%, transparent 40%);
    position: relative;
}

.hoard-title-wrap {
    text-align: center;
    margin-bottom: 3rem;
    opacity: 0;
    transition: opacity 1s ease;
}
.hoard-title-wrap.revealed {
    opacity: 1;
}

.hoard-title {
    font-family: 'Caveat', cursive;
    font-size: clamp(2.5rem, 6vw, 4.5rem);
    color: #4a3728;
    text-shadow: 0 0 1px #4a3728, 0 0 3px rgba(74,55,40,0.3);
}

.unfurl-line {
    width: 0;
    height: 2px;
    background: #c49a3c;
    margin: 0.5rem auto;
    transition: width 1.5s ease;
}
.hoard-title-wrap.revealed .unfurl-line {
    width: 200px;
}

/* Pojagi-inspired border */
#hoard::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 8px;
    background: repeating-linear-gradient(
        90deg,
        #8fa47a 0px, #8fa47a 20px,
        #c49a3c 20px, #c49a3c 35px,
        #9b4d6a 35px, #9b4d6a 50px,
        #6b7f52 50px, #6b7f52 68px,
        #d4cbb8 68px, #d4cbb8 80px
    );
    opacity: 0.5;
}

.hoard-grid {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.5rem;
    max-width: 900px;
    margin: 0 auto;
}

.hoard-item {
    width: var(--size, 150px);
    height: var(--size, 150px);
    background: #f2ece0;
    border: 1.5px solid #8fa47a;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    transform: rotate(var(--rot, 0deg));
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    clip-path: polygon(
        1% 3%, 8% 0%, 18% 2%, 30% 0%, 42% 3%, 55% 0%, 68% 2%, 80% 0%, 92% 3%, 100% 1%,
        99% 97%, 90% 100%, 78% 97%, 65% 100%, 52% 98%, 40% 100%, 28% 97%, 15% 100%, 5% 98%, 0% 100%
    );
    margin: -5px;
    opacity: 0;
    transition: transform 0.3s ease, box-shadow 0.3s ease, opacity 0.6s ease;
}
.hoard-item.revealed {
    opacity: 1;
}
.hoard-item:hover {
    transform: rotate(0deg) translateY(-5px);
    box-shadow: 0 4px 15px rgba(46,36,24,0.15);
    z-index: 10;
}

.item-label {
    font-family: 'Caveat', cursive;
    font-size: 1rem;
    color: #4a3728;
    text-align: center;
}

/* === FOOTER === */
#cave-floor {
    background-color: #2e2418;
    padding: 4rem 2rem;
    text-align: center;
}
.footer-text {
    font-family: 'Caveat', cursive;
    font-size: clamp(1.5rem, 3vw, 2rem);
    color: #d4cbb8;
    margin-bottom: 1rem;
}
.footer-sub {
    font-family: 'Crimson Text', serif;
    font-style: italic;
    color: #7a6b5d;
    font-size: 0.95rem;
    line-height: 1.8;
    margin-bottom: 2rem;
}
.footer-mushrooms {
    opacity: 0.5;
}

/* === RESPONSIVE === */
@media (max-width: 768px) {
    #waypoints {
        padding-left: 20px;
        padding-right: 15px;
    }
    .waypoint {
        flex-direction: column;
        gap: 0.8rem;
    }
    .encounter-card {
        padding: 1.5rem;
    }
    .portrait-frame {
        display: none;
    }
    #timeline-path {
        display: none;
    }
    #scroll-indicator {
        display: none;
    }
    .hoard-item {
        --size: 120px !important;
    }
}
