/* ============================================
   npc.quest - Isometric RPG Town + Art Deco
   ============================================ */

/* --- CSS Custom Properties (Palette) --- */
:root {
    --bg-deep: #1E1610;
    --bg-mid: #2D2218;
    --surface: #3D3024;
    --gold: #C9A96E;
    --terracotta: #C87941;
    --teal: #4A8B7F;
    --text-primary: #EDE4D3;
    --text-secondary: #A89B8C;
    --highlight: #E07A3A;
    --deco-gold: #D4AF37;

    --font-display: 'Poiret One', cursive;
    --font-sub: 'Josefin Sans', sans-serif;
    --font-body: 'Source Sans 3', sans-serif;
    --font-mono: 'IBM Plex Mono', monospace;
}

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

html {
    scroll-behavior: smooth;
    font-size: 16px;
}

body {
    background-color: var(--bg-deep);
    color: var(--text-primary);
    font-family: var(--font-body);
    font-weight: 400;
    line-height: 1.7;
    font-size: clamp(1rem, 1.15vw, 1.15rem);
    overflow-x: hidden;
}

/* --- Quest Line (Vertical Gold Bar) --- */
.quest-line {
    position: fixed;
    left: 8vw;
    top: 0;
    bottom: 0;
    width: 2px;
    background: rgba(201, 169, 110, 0.15);
    z-index: 100;
}

.quest-line-fill {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 0%;
    background: var(--deco-gold);
    transition: height 0.3s ease-out;
}

.quest-diamond {
    position: absolute;
    left: 50%;
    width: 12px;
    height: 12px;
    background: var(--bg-mid);
    border: 2px solid var(--gold);
    transform: translate(-50%, -50%) rotate(45deg);
    transition: background 0.4s ease, border-color 0.4s ease;
    z-index: 101;
}

.quest-diamond[data-section="0"] { top: 12.5%; }
.quest-diamond[data-section="1"] { top: 37.5%; }
.quest-diamond[data-section="2"] { top: 62.5%; }
.quest-diamond[data-section="3"] { top: 87.5%; }

.quest-diamond.active {
    background: var(--deco-gold);
    border-color: var(--highlight);
    box-shadow: 0 0 12px rgba(212, 175, 55, 0.5);
}

/* --- Sections (Scenes) --- */
.scene {
    position: relative;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: clamp(4rem, 8vh, 8rem) 2rem;
    overflow: hidden;
}

.scene-content {
    position: relative;
    max-width: 1100px;
    width: 100%;
    z-index: 2;
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* --- Rooftop (Hero Section) --- */
.rooftop {
    background: var(--bg-deep);
}

.rooftop::before {
    content: '';
    position: absolute;
    inset: 0;
    background:
        radial-gradient(ellipse at 50% 80%, rgba(201, 169, 110, 0.06) 0%, transparent 60%),
        radial-gradient(ellipse at 30% 20%, rgba(74, 139, 127, 0.04) 0%, transparent 50%);
    pointer-events: none;
}

/* Hero Title */
.hero-title {
    font-family: var(--font-display);
    font-weight: 400;
    font-size: clamp(2.8rem, 7vw, 5.5rem);
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--text-primary);
    text-align: center;
    margin-bottom: 2rem;
    position: relative;
}

.hero-title .letter {
    display: inline-block;
    transform: translateY(calc(var(--i) * 0.15em));
    animation: shimmer 3s ease-in-out infinite;
    animation-delay: calc(var(--i) * 0.1s);
    background: linear-gradient(
        90deg,
        var(--gold) 0%,
        var(--text-primary) 40%,
        var(--gold) 80%,
        var(--text-primary) 100%
    );
    background-size: 200% 100%;
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.hero-title .letter-dot {
    display: inline-block;
    color: var(--terracotta);
    -webkit-text-fill-color: var(--terracotta);
    margin: 0 0.05em;
}

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

/* Scroll Chevron */
.scroll-chevron {
    margin-top: 3rem;
    color: var(--gold);
    animation: pulseChevron 2s ease-in-out infinite;
    cursor: pointer;
}

@keyframes pulseChevron {
    0%, 100% { opacity: 0.4; transform: translateY(0); }
    50% { opacity: 1; transform: translateY(6px); }
}

/* --- Speech Bubbles --- */
.speech-bubble {
    background: var(--surface);
    color: var(--text-primary);
    border-radius: 1.2rem;
    padding: 1.5rem 2rem;
    position: relative;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
    max-width: 560px;
    width: 100%;
    transform: scale(1);
    opacity: 1;
    transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.4s ease;
}

.speech-bubble.hidden {
    transform: scale(0.7);
    opacity: 0;
}

.speech-bubble.visible {
    transform: scale(1);
    opacity: 1;
}

.bubble-tail {
    position: absolute;
    bottom: -10px;
    left: 28px;
    width: 0;
    height: 0;
    border-left: 12px solid transparent;
    border-right: 12px solid transparent;
    border-top: 12px solid var(--surface);
}

.hero-bubble {
    margin-bottom: 1rem;
}

.hero-bubble p {
    font-family: var(--font-sub);
    font-weight: 300;
    font-size: clamp(1.1rem, 2.2vw, 1.5rem);
    letter-spacing: 0.06em;
    color: var(--text-secondary);
}

/* Quest Text inside bubbles */
.quest-text {
    border-left: 4px solid var(--deco-gold);
    padding-left: 1rem;
}

.stat {
    font-family: var(--font-mono);
    font-weight: 400;
    font-size: 0.9em;
    color: var(--terracotta);
}

/* --- Library Section --- */
.library {
    background: var(--bg-mid);
}

.library::before {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(ellipse at 60% 40%, rgba(74, 139, 127, 0.05) 0%, transparent 50%);
    pointer-events: none;
}

.section-title {
    font-family: var(--font-display);
    font-weight: 400;
    font-size: clamp(2.2rem, 5vw, 4rem);
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--gold);
    text-align: center;
    margin-bottom: 0.5rem;
}

.section-label {
    font-family: var(--font-sub);
    font-weight: 300;
    font-size: clamp(0.9rem, 1.5vw, 1.1rem);
    letter-spacing: 0.06em;
    color: var(--text-secondary);
    text-align: center;
    margin-bottom: 3rem;
}

.library-bubbles {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    align-items: center;
    width: 100%;
}

.library-bubbles .speech-bubble:nth-child(even) {
    align-self: flex-end;
}

.library-bubbles .speech-bubble:nth-child(odd) {
    align-self: flex-start;
}

.library-bubbles .speech-bubble:nth-child(even) .bubble-tail {
    left: auto;
    right: 28px;
}

/* --- Forge Section --- */
.forge {
    background: linear-gradient(180deg, var(--bg-mid) 0%, var(--bg-deep) 100%);
}

.forge-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 2rem;
    width: 100%;
    max-width: 800px;
}

.forge-card {
    background: var(--surface);
    border-radius: 0.5rem;
    padding: 2rem;
    position: relative;
    cursor: pointer;
    transition: transform 0.35s ease, box-shadow 0.35s ease, opacity 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    transform: translateY(0);
    opacity: 1;
    overflow: hidden;
}

.forge-card.hidden {
    opacity: 0;
    transform: translateY(30px);
}

.forge-card.visible {
    opacity: 1;
    transform: translateY(0);
}

.forge-card:hover {
    transform: translateY(-8px);
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.4);
}

/* Card Corner Ornaments */
.card-corner {
    position: absolute;
    width: 16px;
    height: 16px;
}

.card-corner::before,
.card-corner::after {
    content: '';
    position: absolute;
    background: var(--gold);
}

.card-corner.tl { top: 8px; left: 8px; }
.card-corner.tl::before { width: 12px; height: 1.5px; top: 0; left: 0; }
.card-corner.tl::after { width: 1.5px; height: 12px; top: 0; left: 0; }

.card-corner.tr { top: 8px; right: 8px; }
.card-corner.tr::before { width: 12px; height: 1.5px; top: 0; right: 0; }
.card-corner.tr::after { width: 1.5px; height: 12px; top: 0; right: 0; }

.card-corner.bl { bottom: 8px; left: 8px; }
.card-corner.bl::before { width: 12px; height: 1.5px; bottom: 0; left: 0; }
.card-corner.bl::after { width: 1.5px; height: 12px; bottom: 0; left: 0; }

.card-corner.br { bottom: 8px; right: 8px; }
.card-corner.br::before { width: 12px; height: 1.5px; bottom: 0; right: 0; }
.card-corner.br::after { width: 1.5px; height: 12px; bottom: 0; right: 0; }

.card-icon {
    color: var(--gold);
    margin-bottom: 1rem;
}

.card-title {
    font-family: var(--font-sub);
    font-weight: 600;
    font-size: clamp(1.1rem, 2.2vw, 1.5rem);
    letter-spacing: 0.06em;
    color: var(--text-primary);
    margin-bottom: 0.75rem;
}

.card-body {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.5s ease, opacity 0.5s ease;
    opacity: 0;
}

.forge-card.expanded .card-body {
    max-height: 200px;
    opacity: 1;
}

.card-body p {
    color: var(--text-secondary);
    font-size: 0.95rem;
    line-height: 1.65;
}

/* --- Dungeon Section --- */
.dungeon {
    background: var(--bg-deep);
    position: relative;
}

.dungeon::before {
    content: '';
    position: absolute;
    inset: 0;
    background:
        radial-gradient(ellipse at 50% 30%, rgba(30, 22, 16, 0.0) 0%, var(--bg-deep) 70%),
        radial-gradient(ellipse at 50% 60%, rgba(200, 121, 65, 0.04) 0%, transparent 50%);
    pointer-events: none;
}

/* Deco Archway */
.deco-archway {
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: min(600px, 80vw);
    height: 100%;
    pointer-events: none;
    z-index: 1;
}

.arch-left, .arch-right {
    position: absolute;
    bottom: 0;
    width: 3px;
    height: 100%;
    background: linear-gradient(to top, var(--gold), transparent);
    opacity: 0.3;
}

.arch-left { left: 0; }
.arch-right { right: 0; }

.arch-top {
    position: absolute;
    top: 5%;
    left: 0;
    right: 0;
    height: 80px;
    border: 2px solid transparent;
    border-top-color: var(--gold);
    border-left-color: var(--gold);
    border-right-color: var(--gold);
    border-radius: 300px 300px 0 0;
    opacity: 0.25;
}

.arch-keystone {
    position: absolute;
    top: calc(5% - 8px);
    left: 50%;
    transform: translate(-50%, -50%) rotate(45deg);
    width: 16px;
    height: 16px;
    background: var(--deco-gold);
    opacity: 0.6;
}

/* Farewell Bubble */
.farewell-bubble {
    margin: 2rem 0;
    text-align: center;
}

.farewell-bubble p {
    font-family: var(--font-sub);
    font-weight: 300;
    font-size: clamp(1rem, 1.8vw, 1.3rem);
    letter-spacing: 0.04em;
    color: var(--text-secondary);
}

/* Diamond Badges */
.diamond-badges {
    display: flex;
    gap: 3rem;
    justify-content: center;
    align-items: center;
    margin: 3rem 0;
}

.diamond-badge {
    width: 80px;
    height: 80px;
    background: var(--surface);
    border: 2px solid var(--gold);
    transform: rotate(45deg);
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    transition: transform 0.35s ease, background 0.35s ease, border-color 0.35s ease, opacity 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    opacity: 1;
}

.diamond-badge.hidden {
    opacity: 0;
    transform: rotate(45deg) scale(0.5);
}

.diamond-badge.visible {
    opacity: 1;
    transform: rotate(45deg) scale(1);
}

.diamond-badge:hover {
    background: var(--gold);
    border-color: var(--highlight);
    transform: rotate(45deg) scale(1.1);
}

.badge-text {
    transform: rotate(-45deg);
    font-family: var(--font-sub);
    font-weight: 600;
    font-size: 0.75rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--text-primary);
}

.diamond-badge:hover .badge-text {
    color: var(--bg-deep);
}

/* Footer */
.site-footer {
    margin-top: 4rem;
    text-align: center;
    z-index: 2;
    position: relative;
}

.footer-text {
    font-family: var(--font-sub);
    font-weight: 300;
    font-size: 0.9rem;
    color: var(--text-secondary);
    letter-spacing: 0.06em;
}

/* --- Art Deco Fan Divider --- */
.deco-fan-divider {
    width: 120px;
    height: 60px;
    margin: 0 auto 2rem;
    position: relative;
    overflow: hidden;
}

.deco-fan-divider::before {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    width: 120px;
    height: 120px;
    transform: translateX(-50%);
    border-radius: 50%;
    background: conic-gradient(
        from 180deg,
        transparent 0deg,
        var(--gold) 0deg,
        transparent 12deg,
        transparent 24deg,
        var(--gold) 24deg,
        transparent 36deg,
        transparent 48deg,
        var(--gold) 48deg,
        transparent 60deg,
        transparent 72deg,
        var(--gold) 72deg,
        transparent 84deg,
        transparent 96deg,
        var(--gold) 96deg,
        transparent 108deg,
        transparent 120deg,
        var(--gold) 120deg,
        transparent 132deg,
        transparent 144deg,
        var(--gold) 144deg,
        transparent 156deg,
        transparent 168deg,
        var(--gold) 168deg,
        transparent 180deg
    );
    opacity: 0.35;
}

/* --- Isometric Platforms --- */
.iso-platform {
    position: absolute;
    z-index: 0;
    pointer-events: none;
}

.hero-platform {
    bottom: 15%;
    right: 8%;
    opacity: 0.25;
}

.library-platform {
    top: 10%;
    left: 5%;
    opacity: 0.2;
}

.forge-platform {
    top: 8%;
    right: 5%;
    opacity: 0.2;
}

.dungeon-iso-platform {
    position: relative;
    margin-top: 2rem;
    opacity: 0.2;
    display: flex;
    justify-content: center;
}

/* Isometric Buildings */
.iso-building {
    position: relative;
    transform: rotateX(60deg) rotateZ(-45deg);
    transform-style: preserve-3d;
}

.iso-block {
    position: relative;
    background: var(--gold);
    margin-bottom: 4px;
}

/* Tower (Hero) */
.tower .block-1 {
    width: 60px;
    height: 60px;
    opacity: 0.4;
}

.tower .block-2 {
    width: 44px;
    height: 44px;
    margin: 0 auto;
    opacity: 0.5;
}

.tower .block-3 {
    width: 28px;
    height: 28px;
    margin: 0 auto;
    opacity: 0.6;
}

.tower .iso-spire {
    width: 0;
    height: 0;
    margin: 0 auto;
    border-left: 14px solid transparent;
    border-right: 14px solid transparent;
    border-bottom: 24px solid var(--gold);
    opacity: 0.7;
}

/* Library building */
.bookshelf .block-1 {
    width: 80px;
    height: 50px;
    opacity: 0.3;
}

.bookshelf .block-2 {
    width: 80px;
    height: 30px;
    opacity: 0.4;
}

.bookshelf .shelf-detail {
    width: 80px;
    height: 2px;
    background: var(--terracotta);
    opacity: 0.5;
    margin-top: 8px;
}

/* Anvil (Forge) */
.anvil .block-1 {
    width: 50px;
    height: 35px;
    opacity: 0.35;
    border-radius: 0 0 4px 4px;
}

.anvil .block-2 {
    width: 30px;
    height: 25px;
    margin: 0 auto;
    opacity: 0.45;
}

.anvil .anvil-detail {
    width: 60px;
    height: 8px;
    background: var(--terracotta);
    opacity: 0.3;
    margin: 4px auto 0;
    border-radius: 4px;
}

/* Dungeon Gate */
.dungeon-gate .block-1 {
    width: 70px;
    height: 50px;
    opacity: 0.3;
}

.dungeon-gate .block-2 {
    width: 50px;
    height: 20px;
    margin: 0 auto;
    opacity: 0.4;
}

.dungeon-gate .gate-bars {
    width: 50px;
    height: 30px;
    margin: 4px auto 0;
    background: repeating-linear-gradient(
        90deg,
        var(--gold) 0px,
        var(--gold) 3px,
        transparent 3px,
        transparent 10px
    );
    opacity: 0.25;
}

/* --- Compass Rose --- */
.compass-rose {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    width: 60px;
    height: 60px;
    color: var(--gold);
    cursor: pointer;
    z-index: 200;
    transition: transform 0.3s ease;
}

.compass-rose:hover {
    transform: scale(1.15);
}

.compass-progress {
    position: absolute;
    top: 0;
    left: 0;
}

.progress-ring {
    stroke: var(--deco-gold);
    transition: stroke-dashoffset 0.4s ease;
}

.compass-needle, .compass-arrow {
    transform-origin: 30px 30px;
    transition: transform 0.5s ease;
}

/* --- Deco Border (top of hero) --- */
.deco-border-top {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: repeating-linear-gradient(
        90deg,
        var(--gold) 0px,
        var(--gold) 20px,
        transparent 20px,
        transparent 28px,
        var(--deco-gold) 28px,
        var(--deco-gold) 32px,
        transparent 32px,
        transparent 40px
    );
    opacity: 0.3;
}

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

    .iso-building {
        transform: rotateX(60deg) rotateZ(-45deg) scale(0.5);
    }

    .compass-rose {
        bottom: 1rem;
        right: 50%;
        transform: translateX(50%);
    }

    .compass-rose:hover {
        transform: translateX(50%) scale(1.15);
    }

    .forge-grid {
        grid-template-columns: 1fr;
    }

    .library-bubbles .speech-bubble:nth-child(even),
    .library-bubbles .speech-bubble:nth-child(odd) {
        align-self: center;
    }

    .diamond-badges {
        gap: 1.5rem;
    }

    .diamond-badge {
        width: 64px;
        height: 64px;
    }

    .hero-title {
        letter-spacing: 0.08em;
    }

    .scene {
        padding: clamp(3rem, 6vh, 6rem) 1.2rem;
    }
}

/* --- Noise / Grain Overlay --- */
body::after {
    content: '';
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 9999;
    opacity: 0.06;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='noise'%3E%3CfeTurbulence baseFrequency='0.65' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)'/%3E%3C/svg%3E");
}
