/* npc.quest - Victorian Curiosity Cabinet meets Tabletop RPG */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --deep-bg: #1e0f0a;
    --surface: #f5e6d0;
    --text: #2a1810;
    --copper: #c47832;
    --rose: #e8654a;
    --plum: #6b2d5b;
    --gold: #d4a54a;
    --mist: #f9ede0;
}

body {
    background: var(--deep-bg);
    color: var(--surface);
    font-family: 'Nunito Sans', sans-serif;
    font-weight: 400;
    font-size: clamp(0.95rem, 1.2vw, 1.15rem);
    line-height: 1.72;
    overflow-x: hidden;
}

/* Compass Rose Navigation */
.compass-rose {
    position: fixed;
    top: 24px;
    right: 24px;
    z-index: 1000;
    cursor: pointer;
}

.compass-menu {
    position: absolute;
    top: 50%;
    left: 50%;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.compass-rose:hover .compass-menu {
    opacity: 1;
    pointer-events: all;
}

.compass-item {
    position: absolute;
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.75rem;
    color: var(--gold);
    text-decoration: none;
    white-space: nowrap;
    padding: 4px 10px;
    background: var(--deep-bg);
    border: 1px solid var(--gold);
    border-radius: 3px;
    transition: background 0.2s, color 0.2s;
}

.compass-item:hover {
    background: var(--gold);
    color: var(--deep-bg);
}

.compass-item:nth-child(1) { transform: translate(-50%, -50%) translate(0, -50px); }
.compass-item:nth-child(2) { transform: translate(-50%, -50%) translate(60px, 0); }
.compass-item:nth-child(3) { transform: translate(-50%, -50%) translate(0, 50px); }
.compass-item:nth-child(4) { transform: translate(-50%, -50%) translate(-70px, 0); }

/* Hero Section */
.hero {
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    background: var(--deep-bg);
    overflow: hidden;
}

.hero-glow {
    position: absolute;
    inset: 0;
    background: radial-gradient(ellipse at 20% 80%, #c4783244, #6b2d5b22, transparent 70%);
    pointer-events: none;
}

.hero-frame {
    position: absolute;
    width: 60vw;
    max-width: 800px;
    height: auto;
}

.frame-path {
    stroke-dasharray: 5000;
    stroke-dashoffset: 5000;
    animation: drawFrame 2.5s ease-out 0.3s forwards;
}

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

.hero-content {
    position: relative;
    z-index: 2;
    text-align: center;
    opacity: 0;
    animation: fadeIn 0.8s ease 2s forwards;
}

.hero-title {
    font-family: 'Josefin Sans', sans-serif;
    font-weight: 700;
    font-size: clamp(3rem, 7vw, 5.5rem);
    letter-spacing: 0.15em;
    color: var(--surface);
    margin-bottom: 0.3em;
}

.hero-subtitle {
    font-family: 'Nunito Sans', sans-serif;
    font-weight: 400;
    font-size: clamp(1rem, 2vw, 1.4rem);
    color: var(--gold);
    opacity: 0;
    animation: fadeIn 0.6s ease 2.4s forwards;
}

.scroll-indicator {
    position: absolute;
    bottom: 40px;
    left: 50%;
    transform: translateX(-50%);
    animation: bounce 2s ease-in-out infinite;
    opacity: 0;
    animation: fadeIn 0.5s ease 3s forwards, bounce 2s ease-in-out 3s infinite;
}

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

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

/* Diagonal Sections */
.diagonal-section {
    min-height: 90vh;
    position: relative;
    padding: 120px 5vw;
    background: linear-gradient(135deg, var(--deep-bg), #2a1810);
}

.diagonal-section.left-lean {
    clip-path: polygon(0 0, 100% 6%, 100% 100%, 0 94%);
}

.diagonal-section.right-lean {
    clip-path: polygon(0 6%, 100% 0, 100% 94%, 0 100%);
}

.section-inner {
    max-width: 1200px;
    margin: 0 auto;
}

.section-header {
    font-family: 'Josefin Sans', sans-serif;
    font-weight: 600;
    font-size: clamp(1.2rem, 2.5vw, 2rem);
    color: var(--copper);
    margin-bottom: 48px;
    opacity: 0;
    transform: translateX(-30px);
    transition: opacity 0.5s ease-out, transform 0.5s ease-out;
}

.section-header.visible {
    opacity: 1;
    transform: translateX(0);
}

.right-lean .section-header {
    transform: translateX(30px);
}

.right-lean .section-header.visible {
    transform: translateX(0);
}

/* NPC Grid */
.npc-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 40px;
    justify-items: center;
}

/* NPC Card */
.npc-card {
    max-width: 380px;
    width: 100%;
    background: var(--deep-bg);
    border-radius: 8px;
    padding: 20px;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    opacity: 0;
    transform: translateY(20px);
}

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

.npc-card:hover {
    transform: translateY(-6px);
    box-shadow: 0 12px 32px #1e0f0a66;
}

.npc-card:hover .npc-frame {
    filter: drop-shadow(0 0 6px #d4a54a88);
}

.npc-frame-wrapper {
    position: relative;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 16px;
}

.npc-frame {
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    transition: filter 0.3s ease;
}

.npc-frame rect,
.npc-frame path {
    stroke-dasharray: 2000;
    stroke-dashoffset: 2000;
    transition: stroke-dashoffset 1.5s ease;
}

.npc-card.visible .npc-frame rect,
.npc-card.visible .npc-frame path {
    stroke-dashoffset: 0;
}

.npc-portrait {
    width: 200px;
    height: 240px;
    margin: 20px auto;
}

.npc-portrait svg {
    width: 100%;
    height: 100%;
}

.npc-name {
    font-family: 'Josefin Sans', sans-serif;
    font-weight: 600;
    font-size: clamp(1.1rem, 2vw, 1.4rem);
    color: var(--copper);
    margin-bottom: 8px;
}

.npc-class {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
}

.npc-class-label {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.8rem;
    color: var(--gold);
}

.npc-description {
    font-size: 0.95rem;
    color: var(--mist);
    margin-bottom: 16px;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.stat-bars {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.stat-bar {
    height: 4px;
    background: #2a181066;
    border-radius: 2px;
    overflow: hidden;
}

.stat-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--copper), var(--gold));
    border-radius: 2px;
    transition: width 0.8s ease;
}

/* Quest Board */
.quest-board {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 24px;
}

.quest-card {
    background: var(--surface);
    background-image: url("data:image/svg+xml,%3Csvg width='4' height='4' xmlns='http://www.w3.org/2000/svg'%3E%3Crect width='1' height='1' x='1' y='1' fill='%232a1810' opacity='0.03'/%3E%3C/svg%3E");
    padding: 24px;
    border-radius: 4px;
    transition: transform 0.3s ease, box-shadow 0.3s ease, z-index 0s;
    position: relative;
}

.quest-card:hover {
    transform: rotate(0deg) translateY(-4px) !important;
    box-shadow: 0 8px 24px #1e0f0a44;
    z-index: 10;
}

.quest-title {
    font-family: 'Josefin Sans', sans-serif;
    font-weight: 600;
    font-size: 1.1rem;
    color: var(--text);
    margin-bottom: 8px;
}

.quest-text {
    font-size: 0.9rem;
    color: var(--text);
    line-height: 1.6;
    margin-bottom: 12px;
}

.quest-tag {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.75rem;
    color: var(--rose);
    border: 1px solid var(--rose);
    padding: 2px 8px;
    border-radius: 3px;
}

/* Mystics Section Tessellation */
.mystics-section {
    position: relative;
}

.tessellation-bg {
    position: absolute;
    inset: 0;
    opacity: 0;
    transition: opacity 1.5s ease;
    background-image: url("data:image/svg+xml,%3Csvg width='60' height='60' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M30 0 L60 15 L60 45 L30 60 L0 45 L0 15 Z' fill='none' stroke='%23d4a54a' stroke-width='0.5'/%3E%3C/svg%3E");
    background-size: 60px 60px;
    pointer-events: none;
}

.mystics-section.visible .tessellation-bg {
    opacity: 0.05;
}

/* Cultural Section / Footer */
.cultural-section {
    padding: 80px 5vw;
    text-align: center;
}

.knotwork-divider {
    width: 60%;
    max-width: 600px;
    margin: 0 auto 40px;
    display: block;
}

.closing-text {
    font-family: 'Nunito Sans', sans-serif;
    font-size: clamp(1rem, 1.5vw, 1.2rem);
    color: var(--gold);
    opacity: 0.8;
    line-height: 2;
}

/* Mobile adjustments */
@media (max-width: 768px) {
    .diagonal-section.left-lean {
        clip-path: polygon(0 0, 100% 3%, 100% 100%, 0 97%);
    }
    .diagonal-section.right-lean {
        clip-path: polygon(0 3%, 100% 0, 100% 97%, 0 100%);
    }

    .hero-frame {
        width: 85vw;
    }

    .compass-rose {
        top: auto;
        bottom: 20px;
        right: 50%;
        transform: translateX(50%);
    }

    .compass-item:nth-child(1) { transform: translate(-50%, -50%) translate(0, -45px); }
    .compass-item:nth-child(2) { transform: translate(-50%, -50%) translate(55px, 0); }
    .compass-item:nth-child(3) { transform: translate(-50%, -50%) translate(0, 45px); }
    .compass-item:nth-child(4) { transform: translate(-50%, -50%) translate(-60px, 0); }

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

    .quest-board {
        grid-template-columns: 1fr;
    }

    .npc-portrait {
        width: 160px;
        height: 192px;
    }
}
