/* ============================================
   historical.quest - Styles
   Neomorphic Crystalline Game Board
   ============================================ */

/* --- CSS Custom Properties --- */
:root {
    --coastal-surface: #E8F0F4;
    --shadow-dark: #C0D0D8;
    --shadow-light: #FFFFFF;
    --crystal-teal: #40A0A0;
    --crystal-amber: #D0A060;
    --period-red: #C04040;
    --text-dark: #2A3A40;
    --vector-muted: #6A8090;

    --font-headline: 'Zilla Slab', serif;
    --font-body: 'Merriweather', serif;
    --font-ui: 'Poppins', sans-serif;

    --neo-shadow-ext: 6px 6px 12px #C0D0D8, -6px -6px 12px #FFFFFF;
    --neo-shadow-pressed: inset 4px 4px 8px #C0D0D8, inset -4px -4px 8px #FFFFFF;
    --neo-shadow-ext-lg: 10px 10px 20px #C0D0D8, -10px -10px 20px #FFFFFF;
}

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

html {
    scroll-behavior: smooth;
}

body {
    background-color: var(--coastal-surface);
    color: var(--text-dark);
    font-family: var(--font-body);
    font-weight: 400;
    line-height: 1.8;
    font-size: clamp(14px, 1vw, 16px);
    overflow-x: hidden;
}

/* --- Section Heading --- */
.section-heading {
    font-family: var(--font-headline);
    font-weight: 600;
    font-size: clamp(28px, 4vw, 48px);
    letter-spacing: 0.02em;
    color: var(--text-dark);
    margin-bottom: 0.5em;
}

/* ============================================
   HERO SECTION
   ============================================ */
#hero {
    width: 100%;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 60px 8vw;
    position: relative;
    overflow: hidden;
    background: var(--coastal-surface);
}

#hero-content {
    width: 45%;
    position: relative;
    z-index: 2;
    padding-left: 5%;
    opacity: 0;
    animation: fadeInLogotype 500ms ease-out 300ms forwards;
}

#logotype {
    font-family: var(--font-headline);
    font-weight: 700;
    font-size: clamp(32px, 5vw, 64px);
    letter-spacing: 0.02em;
    color: var(--text-dark);
    line-height: 1.2;
    margin-bottom: 0.3em;
}

#hero-tagline {
    font-family: var(--font-body);
    font-size: clamp(15px, 1.2vw, 18px);
    color: var(--vector-muted);
    line-height: 1.7;
    max-width: 400px;
}

@keyframes fadeInLogotype {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}

/* --- Hero Crystal --- */
#hero-crystal {
    width: 40%;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    z-index: 1;
}

#crystal-shape {
    width: clamp(220px, 28vw, 380px);
    height: clamp(220px, 28vw, 380px);
    background: var(--coastal-surface);
    clip-path: polygon(50% 0%, 93% 25%, 93% 75%, 50% 100%, 7% 75%, 7% 25%);
    box-shadow: var(--neo-shadow-ext-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    animation: crystalRotate 8s linear infinite, crystalExtrude 800ms ease-out forwards;
}

#crystal-shape::before {
    content: '';
    position: absolute;
    inset: 2px;
    clip-path: polygon(50% 0%, 93% 25%, 93% 75%, 50% 100%, 7% 75%, 7% 25%);
    border: 1px solid rgba(255, 255, 255, 0.3);
    pointer-events: none;
}

@keyframes crystalRotate {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

@keyframes crystalExtrude {
    from {
        box-shadow: 0 0 0 #C0D0D8, 0 0 0 #FFFFFF;
        opacity: 0.5;
    }
    to {
        box-shadow: 10px 10px 20px #C0D0D8, -10px -10px 20px #FFFFFF;
        opacity: 1;
    }
}

#crystal-icon {
    width: 60%;
    height: 60%;
    animation: crystalRotateReverse 8s linear infinite;
}

@keyframes crystalRotateReverse {
    from { transform: rotate(0deg); }
    to { transform: rotate(-360deg); }
}

/* ============================================
   QUEST CARDS SECTION (Broken Grid)
   ============================================ */
#quest-cards {
    padding: 100px 8vw 80px;
    text-align: center;
}

#quest-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 40px 30px;
    max-width: 1100px;
    margin: 50px auto 0;
}

.quest-card {
    background: var(--coastal-surface);
    border-radius: 18px;
    box-shadow: var(--neo-shadow-ext);
    padding: 36px 28px;
    cursor: pointer;
    transition: transform 0.35s cubic-bezier(0.25, 0.46, 0.45, 0.94),
                box-shadow 0.3s ease;
    position: relative;
    opacity: 0;
    transform: translateY(-30px);
}

/* Broken-grid offsets via nth-child */
.quest-card:nth-child(1) { transform: translate(8px, 6px) rotate(-2deg); opacity: 1; }
.quest-card:nth-child(2) { transform: translate(-5px, -8px) rotate(1.5deg); opacity: 1; }
.quest-card:nth-child(3) { transform: translate(10px, 4px) rotate(-1deg); opacity: 1; }
.quest-card:nth-child(4) { transform: translate(-8px, 7px) rotate(2.5deg); opacity: 1; }
.quest-card:nth-child(5) { transform: translate(6px, -6px) rotate(-1.8deg); opacity: 1; }
.quest-card:nth-child(6) { transform: translate(-4px, 5px) rotate(1.2deg); opacity: 1; }

/* Entrance animation states (set by JS) */
.quest-card.animate-in:nth-child(1) { animation: cardDrop 500ms cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards; animation-delay: 0ms; --final-tx: 8px; --final-ty: 6px; --final-rot: -2deg; }
.quest-card.animate-in:nth-child(2) { animation: cardDrop 500ms cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards; animation-delay: 120ms; --final-tx: -5px; --final-ty: -8px; --final-rot: 1.5deg; }
.quest-card.animate-in:nth-child(3) { animation: cardDrop 500ms cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards; animation-delay: 240ms; --final-tx: 10px; --final-ty: 4px; --final-rot: -1deg; }
.quest-card.animate-in:nth-child(4) { animation: cardDrop 500ms cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards; animation-delay: 360ms; --final-tx: -8px; --final-ty: 7px; --final-rot: 2.5deg; }
.quest-card.animate-in:nth-child(5) { animation: cardDrop 500ms cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards; animation-delay: 480ms; --final-tx: 6px; --final-ty: -6px; --final-rot: -1.8deg; }
.quest-card.animate-in:nth-child(6) { animation: cardDrop 500ms cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards; animation-delay: 600ms; --final-tx: -4px; --final-ty: 5px; --final-rot: 1.2deg; }

@keyframes cardDrop {
    0% {
        opacity: 0;
        transform: translate(var(--final-tx), -30px) rotate(0deg);
    }
    100% {
        opacity: 1;
        transform: translate(var(--final-tx), var(--final-ty)) rotate(var(--final-rot));
    }
}

/* Hover: lift, straighten, brighten */
.quest-card:hover {
    transform: translate(0, -8px) rotate(0deg) !important;
    box-shadow: 8px 8px 16px #C0D0D8, -8px -8px 16px #FFFFFF;
}

.quest-card:active {
    box-shadow: var(--neo-shadow-pressed);
    transform: translate(0, 0) rotate(0deg) !important;
}

.quest-card-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.quest-icon {
    width: 70px;
    height: 70px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.quest-icon svg {
    width: 100%;
    height: 100%;
}

.quest-title {
    font-family: var(--font-headline);
    font-weight: 600;
    font-size: clamp(18px, 2vw, 24px);
    letter-spacing: 0.02em;
    color: var(--text-dark);
}

.quest-period {
    font-family: var(--font-body);
    font-size: 13px;
    color: var(--vector-muted);
}

.quest-badge {
    font-family: var(--font-ui);
    font-weight: 600;
    font-size: 11px;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--shadow-light);
    background: var(--crystal-teal);
    padding: 4px 14px;
    border-radius: 20px;
}

/* ============================================
   FEATURED QUEST SECTION
   ============================================ */
#featured-quest {
    padding: 80px 8vw 100px;
}

#featured-container {
    background: var(--coastal-surface);
    border-radius: 24px;
    box-shadow: var(--neo-shadow-ext-lg);
    padding: 50px 48px;
    max-width: 1200px;
    margin: 0 auto;
}

#featured-header {
    display: flex;
    align-items: baseline;
    gap: 20px;
    margin-bottom: 40px;
    flex-wrap: wrap;
}

#featured-era-label {
    font-family: var(--font-ui);
    font-weight: 600;
    font-size: 12px;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--shadow-light);
    background: var(--crystal-amber);
    padding: 5px 16px;
    border-radius: 20px;
}

#featured-inner-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: auto auto;
    gap: 36px;
}

#featured-timeline {
    grid-column: 1 / -1;
}

.featured-subheading {
    font-family: var(--font-headline);
    font-weight: 600;
    font-size: clamp(18px, 2vw, 24px);
    letter-spacing: 0.02em;
    color: var(--text-dark);
    margin-bottom: 20px;
}

/* --- Timeline --- */
.timeline {
    display: flex;
    align-items: flex-start;
    gap: 0;
    position: relative;
    padding: 20px 0;
}

.timeline::before {
    content: '';
    position: absolute;
    top: 30px;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--shadow-dark);
    border-radius: 2px;
}

.timeline-node {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    position: relative;
    z-index: 1;
    cursor: pointer;
}

.timeline-dot {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--coastal-surface);
    box-shadow: 3px 3px 6px #C0D0D8, -3px -3px 6px #FFFFFF;
    border: 2px solid var(--shadow-dark);
    transition: all 0.3s ease;
}

.timeline-node.active .timeline-dot {
    background: var(--crystal-teal);
    border-color: var(--crystal-teal);
    box-shadow: 0 0 8px rgba(64, 160, 160, 0.4);
}

.timeline-node:hover .timeline-dot {
    border-color: var(--crystal-teal);
    transform: scale(1.2);
}

.timeline-label {
    font-family: var(--font-ui);
    font-weight: 500;
    font-size: 11px;
    letter-spacing: 0.04em;
    color: var(--vector-muted);
    text-align: center;
    text-transform: uppercase;
}

.timeline-node::after {
    content: attr(data-year);
    font-family: var(--font-body);
    font-size: 12px;
    color: var(--text-dark);
    font-weight: 700;
}

/* --- Character Cards --- */
.character-grid {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
}

.character-card {
    background: var(--coastal-surface);
    border-radius: 16px;
    box-shadow: var(--neo-shadow-ext);
    padding: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    width: 120px;
    clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.character-card:hover {
    transform: translateY(-4px);
}

.character-avatar {
    width: 50px;
    height: 50px;
}

.character-avatar svg {
    width: 100%;
    height: 100%;
}

.character-name {
    font-family: var(--font-headline);
    font-weight: 600;
    font-size: 13px;
    color: var(--text-dark);
}

.character-role {
    font-family: var(--font-ui);
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--vector-muted);
}

/* --- Objectives --- */
.objectives-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.objective {
    display: flex;
    align-items: center;
    gap: 14px;
    font-family: var(--font-body);
    font-size: 14px;
    color: var(--vector-muted);
    padding: 12px 18px;
    background: var(--coastal-surface);
    border-radius: 12px;
    box-shadow: var(--neo-shadow-ext);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.objective:hover {
    transform: translateX(4px);
}

.objective.completed {
    color: var(--text-dark);
}

.objective.active {
    color: var(--crystal-teal);
    box-shadow: 4px 4px 10px #C0D0D8, -4px -4px 10px #FFFFFF, inset 0 0 0 2px rgba(64, 160, 160, 0.2);
}

.objective-check {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    flex-shrink: 0;
    background: var(--coastal-surface);
    box-shadow: inset 2px 2px 4px #C0D0D8, inset -2px -2px 4px #FFFFFF;
    color: var(--vector-muted);
}

.objective.completed .objective-check {
    background: var(--crystal-teal);
    box-shadow: none;
    color: var(--shadow-light);
}

.objective.active .objective-check {
    box-shadow: inset 2px 2px 4px #C0D0D8, inset -2px -2px 4px #FFFFFF, 0 0 6px rgba(64, 160, 160, 0.3);
}

/* ============================================
   CRYSTAL COLLECTION SECTION
   ============================================ */
#crystal-collection {
    padding: 80px 8vw 100px;
    text-align: center;
}

#collection-subtitle {
    font-family: var(--font-body);
    font-size: 15px;
    color: var(--vector-muted);
    margin-bottom: 50px;
}

#badges-track {
    display: flex;
    justify-content: center;
    gap: 30px;
    flex-wrap: wrap;
    max-width: 1100px;
    margin: 0 auto;
}

.badge-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    cursor: pointer;
}

.badge-crystal {
    width: 80px;
    height: 80px;
    clip-path: polygon(30% 0%, 70% 0%, 100% 30%, 100% 70%, 70% 100%, 30% 100%, 0% 70%, 0% 30%);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    position: relative;
}

.badge-crystal::after {
    content: '';
    position: absolute;
    inset: 1px;
    clip-path: polygon(30% 0%, 70% 0%, 100% 30%, 100% 70%, 70% 100%, 30% 100%, 0% 70%, 0% 30%);
    border: 1px solid rgba(255, 255, 255, 0.3);
    pointer-events: none;
}

.badge-icon {
    font-size: 26px;
    line-height: 1;
    z-index: 1;
}

/* Unlocked badges */
.badge-item.unlocked .badge-crystal {
    background: var(--coastal-surface);
    box-shadow: 5px 5px 10px #C0D0D8, -5px -5px 10px #FFFFFF, 0 0 8px rgba(64, 160, 160, 0.4);
}

.badge-item.unlocked .badge-icon {
    color: var(--crystal-teal);
}

.badge-item.unlocked:hover .badge-crystal {
    transform: translateY(-6px);
    box-shadow: 5px 5px 10px #C0D0D8, -5px -5px 10px #FFFFFF, 0 0 14px rgba(64, 160, 160, 0.5);
}

/* Locked badges */
.badge-item.locked .badge-crystal {
    background: var(--coastal-surface);
    box-shadow: inset 4px 4px 8px #C0D0D8, inset -4px -4px 8px #FFFFFF;
}

.badge-item.locked .badge-icon {
    color: var(--shadow-dark);
    opacity: 0.5;
}

.badge-item.locked:hover .badge-crystal {
    box-shadow: inset 5px 5px 10px #C0D0D8, inset -5px -5px 10px #FFFFFF;
}

.badge-label {
    font-family: var(--font-ui);
    font-weight: 600;
    font-size: 11px;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--vector-muted);
}

.badge-item.unlocked .badge-label {
    color: var(--text-dark);
}

/* Shake animation for badges */
@keyframes badgeShake {
    0%, 100% { transform: translateX(0); }
    16% { transform: translateX(-2px); }
    33% { transform: translateX(2px); }
    50% { transform: translateX(-2px); }
    66% { transform: translateX(2px); }
    83% { transform: translateX(-2px); }
}

.badge-item.shaking .badge-crystal {
    animation: badgeShake 180ms ease-in-out;
}

/* Pulse animation for unlocked badges */
@keyframes badgePulse {
    0%, 100% { box-shadow: 5px 5px 10px #C0D0D8, -5px -5px 10px #FFFFFF, 0 0 8px rgba(64, 160, 160, 0.4); }
    50% { box-shadow: 5px 5px 10px #C0D0D8, -5px -5px 10px #FFFFFF, 0 0 16px rgba(64, 160, 160, 0.6); }
}

.badge-item.unlocked.pulsing .badge-crystal {
    animation: badgePulse 1.2s ease-in-out infinite;
}

/* Shatter animation */
@keyframes shatterOut {
    0% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.4); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

.badge-item.shattering .badge-crystal {
    animation: shatterOut 600ms ease-out forwards;
}

/* ============================================
   FOOTER
   ============================================ */
#site-footer {
    background: linear-gradient(180deg, var(--coastal-surface) 0%, #DCE8EE 100%);
    padding: 50px 8vw 40px;
    text-align: center;
}

#footer-nav {
    display: flex;
    justify-content: center;
    gap: 14px;
    margin-bottom: 30px;
    flex-wrap: wrap;
}

.footer-pill {
    font-family: var(--font-ui);
    font-weight: 600;
    font-size: 12px;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-dark);
    background: var(--coastal-surface);
    border: none;
    padding: 10px 22px;
    border-radius: 30px;
    box-shadow: 4px 4px 8px #C0D0D8, -4px -4px 8px #FFFFFF;
    cursor: pointer;
    transition: all 0.3s ease;
}

.footer-pill:hover {
    box-shadow: 6px 6px 12px #C0D0D8, -6px -6px 12px #FFFFFF;
    transform: translateY(-2px);
    color: var(--crystal-teal);
}

.footer-pill:active {
    box-shadow: inset 3px 3px 6px #C0D0D8, inset -3px -3px 6px #FFFFFF;
    transform: translateY(0);
}

#footer-text {
    font-family: var(--font-body);
    font-size: 13px;
    color: var(--vector-muted);
}

/* ============================================
   QUEST OVERLAY
   ============================================ */
#quest-overlay {
    position: fixed;
    inset: 0;
    background: rgba(42, 58, 64, 0.6);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.35s ease, visibility 0.35s ease;
}

#quest-overlay.overlay-hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

#quest-overlay.overlay-visible {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

#overlay-content {
    background: var(--coastal-surface);
    border-radius: 24px;
    box-shadow: var(--neo-shadow-ext-lg);
    padding: 48px;
    max-width: 600px;
    width: 90%;
    position: relative;
    transform: scale(0.9);
    transition: transform 0.35s ease;
}

#quest-overlay.overlay-visible #overlay-content {
    transform: scale(1);
}

#overlay-close {
    position: absolute;
    top: 18px;
    right: 22px;
    background: var(--coastal-surface);
    border: none;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    box-shadow: 3px 3px 6px #C0D0D8, -3px -3px 6px #FFFFFF;
    font-size: 22px;
    color: var(--text-dark);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

#overlay-close:hover {
    box-shadow: inset 3px 3px 6px #C0D0D8, inset -3px -3px 6px #FFFFFF;
}

#overlay-title {
    font-family: var(--font-headline);
    font-weight: 700;
    font-size: clamp(24px, 3.5vw, 36px);
    letter-spacing: 0.02em;
    color: var(--text-dark);
    margin-bottom: 8px;
}

#overlay-period {
    font-family: var(--font-ui);
    font-weight: 600;
    font-size: 12px;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--crystal-amber);
    margin-bottom: 20px;
}

#overlay-description {
    font-family: var(--font-body);
    font-size: 15px;
    color: var(--vector-muted);
    line-height: 1.8;
    margin-bottom: 28px;
}

#overlay-quests-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.overlay-quest-item {
    background: var(--coastal-surface);
    border-radius: 12px;
    box-shadow: 3px 3px 6px #C0D0D8, -3px -3px 6px #FFFFFF;
    padding: 12px 18px;
    font-family: var(--font-body);
    font-size: 14px;
    color: var(--text-dark);
    display: flex;
    align-items: center;
    gap: 10px;
    transition: transform 0.3s ease;
}

.overlay-quest-item:hover {
    transform: translateX(4px);
}

.overlay-quest-marker {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--period-red);
    flex-shrink: 0;
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 900px) {
    #hero {
        flex-direction: column;
        text-align: center;
        padding: 80px 6vw 60px;
        gap: 40px;
    }

    #hero-content {
        width: 100%;
        padding-left: 0;
    }

    #hero-tagline {
        max-width: 100%;
        margin: 0 auto;
    }

    #hero-crystal {
        width: 100%;
    }

    #quest-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 30px 20px;
    }

    #featured-inner-grid {
        grid-template-columns: 1fr;
    }

    #featured-container {
        padding: 36px 28px;
    }

    .timeline {
        flex-direction: column;
        align-items: flex-start;
        gap: 16px;
    }

    .timeline::before {
        top: 0;
        bottom: 0;
        left: 9px;
        width: 3px;
        height: 100%;
        right: auto;
    }

    .timeline-node {
        flex-direction: row;
        gap: 14px;
    }

    .character-grid {
        justify-content: center;
    }

    #badges-track {
        gap: 20px;
    }

    .badge-crystal {
        width: 65px;
        height: 65px;
    }
}

@media (max-width: 600px) {
    #quest-grid {
        grid-template-columns: 1fr;
        gap: 24px;
    }

    #featured-header {
        flex-direction: column;
        gap: 10px;
    }

    .character-card {
        width: 100px;
    }

    #badges-track {
        gap: 16px;
    }

    .badge-crystal {
        width: 56px;
        height: 56px;
    }

    .badge-icon {
        font-size: 20px;
    }
}
