/* style.css */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    overflow: hidden; /* No traditional scrolling */
    background-color: #0d1117; /* Dark mode aesthetic */
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    color: #ffffff;
    user-select: none; /* Prevent text selection while dragging */
}

/* The viewport handles window sizing and hides anything outside it */
#viewport {
    position: relative;
    width: 100vw;
    height: 100vh;
    overflow: hidden;
    touch-action: none;
    z-index: 10;
}

#map {
    position: absolute;
    top: 0;
    left: 0;
    width: 4000px;
    height: 4000px;
    background-image: url('assets/map-bgX4.webp');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    transform-origin: 0 0;
    cursor: grab;
    z-index: 20;
    touch-action: none;
    will-change: transform;
    backface-visibility: hidden;
    transform-style: preserve-3d;
}

#map:active {
    cursor: grabbing;
}

/* Welcome Title */
#welcome-title {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    padding: 40px 60px;
    border-radius: 24px;
    text-align: center;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    z-index: 25;
    pointer-events: none; /* User drags right through it */
}

#welcome-title h1 {
    font-size: 64px;
    font-weight: 800;
    margin-bottom: 12px;
    background: linear-gradient(135deg, #38bdf8, #818cf8, #c084fc);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.4));
}

#welcome-title p {
    font-size: 20px;
    color: #e2e8f0;
    font-weight: 500;
    letter-spacing: 0.5px;
}

/* POI Styles */
.poi-wrapper {
    position: absolute;
    width: 120px;
    height: 120px;
    z-index: 30;
    cursor: pointer;
    touch-action: none;
}

.poi {
    width: 100%;
    height: 100%;
    object-fit: contain;
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), filter 0.3s ease;
    filter: drop-shadow(0 10px 15px rgba(0, 0, 0, 0.5));
    will-change: transform;
    backface-visibility: hidden;
    transform-style: preserve-3d;
}

.poi-wrapper:hover .poi,
.poi-wrapper.near .poi {
    transform: scale(1.1) translateY(-10px);
    filter: drop-shadow(0 15px 20px rgba(74, 222, 128, 0.6)); /* Vibrant green glow */
}

/* Tooltip */
.poi-tooltip {
    position: absolute;
    bottom: 110%; /* Above the icon */
    left: 50%;
    transform: translateX(-50%) translateY(10px);
    background: rgba(15, 23, 42, 0.8);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #f8fafc;
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease, transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    z-index: 40;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

.poi-wrapper:hover .poi-tooltip,
.poi-wrapper.near .poi-tooltip {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* Parallax Layers */
.layer {
    position: absolute;
    top: -1000px; /* Oversize to allow panning */
    left: -1000px;
    width: 6000px;
    height: 6000px;
    pointer-events: none; /* Let clicks pass through */
    will-change: transform;
    backface-visibility: hidden;
    transform-style: preserve-3d;
}

#parallax-bg {
    z-index: 1;
    /* Example deep background blobs */
    background: 
        radial-gradient(circle at 20% 30%, rgba(56, 189, 248, 0.05) 0%, transparent 20%),
        radial-gradient(circle at 80% 70%, rgba(74, 222, 128, 0.05) 0%, transparent 20%);
}

#parallax-fg {
    z-index: 50; /* Above the map */
    /* Example foreground blurry particles */
    background-image: radial-gradient(circle, rgba(255,255,255,0.1) 2px, transparent 2px);
    background-size: 300px 300px;
    filter: blur(4px);
    opacity: 0.6;
}

/* Modal Overlay */
#modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    opacity: 1;
    transition: opacity 0.4s ease;
}

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

#modal {
    position: relative;
    background: #1e293b;
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 40px;
    border-radius: 24px;
    max-width: 500px;
    width: 90%;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    transform: scale(1) translateY(0);
    transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

#modal-overlay.hidden #modal {
    transform: scale(0.9) translateY(20px);
}

#modal-close {
    position: absolute;
    top: 20px;
    right: 20px;
    background: none;
    border: none;
    color: #94a3b8;
    font-size: 24px;
    cursor: pointer;
    transition: color 0.2s;
}

#modal-close:hover {
    color: #fff;
}

#modal-title {
    font-size: 28px;
    margin-bottom: 16px;
    color: #f8fafc;
}

#modal-description {
    font-size: 16px;
    color: #cbd5e1;
    line-height: 1.6;
    margin-bottom: 32px;
    overflow-y: auto;
    max-height: 60vh;
    padding-right: 12px; /* For scrollbar */
}

/* Scrollbar styling for modal */
#modal-description::-webkit-scrollbar {
    width: 6px;
}
#modal-description::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 4px;
}
#modal-description::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 4px;
}
#modal-description::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}

.btn {
    display: inline-block;
    padding: 12px 24px;
    background: linear-gradient(135deg, #3b82f6, #8b5cf6);
    color: #fff;
    text-decoration: none;
    font-weight: 600;
    border-radius: 12px;
    transition: transform 0.2s, box-shadow 0.2s;
}

.btn:hover {
    background: #0ea5e9;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(56, 189, 248, 0.4);
}

/* Contact Form */
#contact-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-top: 10px;
}

#contact-form input, #contact-form textarea {
    background: rgba(15, 23, 42, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 12px;
    color: white;
    font-family: inherit;
    font-size: 16px;
    outline: none;
    transition: border-color 0.2s;
}

#contact-form input:focus, #contact-form textarea:focus {
    border-color: #38bdf8;
}

#contact-status {
    font-size: 14px;
    margin-top: 8px;
    text-align: center;
}

/* Player Character */
#player {
    position: absolute;
    top: 0;
    left: 0;
    width: 100px;
    height: 100px;
    margin-left: -50px; /* Center horizontally */
    margin-top: -50px;  /* Center vertically */
    z-index: 2000; /* Extremely high to stay above map forever */
    pointer-events: none; /* Let drags pass through */
    filter: drop-shadow(0 15px 20px rgba(0, 0, 0, 0.6));
    will-change: transform;
}

#player-sprite {
    width: 100%;
    height: 100%;
    object-fit: contain;
    will-change: transform;
}

/* Walking animation */
@keyframes bobbing {
    0% { transform: scale(1) translateY(0); }
    100% { transform: scale(1.05) translateY(-5px); }
}

#player.walking #player-sprite {
    animation: bobbing 0.2s alternate infinite ease-in-out;
}

/* ==========================================================================
   RPG MECHANICS & MOBILE JOYSTICK
   ========================================================================== */
#joystick-container {
    position: fixed;
    bottom: 30px;
    left: 30px;
    width: 100px;
    height: 100px;
    z-index: 1000;
    display: none; /* Only show on touch devices via JS */
    pointer-events: none; /* Let touches pass if not on the base */
}

#joystick-base {
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.4);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    pointer-events: auto; /* Catch touches here */
    position: relative;
    backdrop-filter: blur(5px);
}

#joystick-knob {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, #10b981, #059669);
    border-radius: 50%;
    position: absolute;
    top: 50%;
    left: 50%;
    margin-top: -20px;
    margin-left: -20px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.4);
    pointer-events: none;
    transition: transform 0.05s linear;
}

/* ==========================================================================
   PASSPORT ACHIEVEMENT SYSTEM
   ========================================================================== */

/* Passport Button */
#passport-btn {
    position: fixed;
    top: 20px;
    right: 20px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: rgba(15, 23, 42, 0.8);
    backdrop-filter: blur(10px);
    border: 2px solid rgba(255, 255, 255, 0.1);
    color: #fff;
    cursor: pointer;
    z-index: 1500;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 4px 15px rgba(0,0,0,0.5);
    transition: transform 0.2s ease, background 0.2s ease;
}

#passport-btn:hover {
    transform: scale(1.1);
    background: rgba(30, 41, 59, 0.9);
}

/* Passport Modal Overlay */
#passport-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(15, 23, 42, 0.85); /* Dark blue slate tint */
    backdrop-filter: blur(15px);
    z-index: 3000;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    padding: 60px 20px 20px;
    overflow-y: auto;
    color: #f8fafc;
    transition: opacity 0.3s ease;
}

#passport-modal.hidden {
    display: none;
    opacity: 0;
}

#passport-modal h2 {
    font-size: 2.5rem;
    margin-bottom: 5px;
    color: #f1f5f9;
    text-shadow: 0 2px 10px rgba(0,0,0,0.5);
    text-align: center;
}

.passport-subtitle {
    font-size: 1.1rem;
    color: #94a3b8;
    margin-bottom: 40px;
    text-align: center;
}

#passport-close {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 40px;
    height: 40px;
    font-size: 1.5rem;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: white;
    border-radius: 50%;
    cursor: pointer;
    transition: background 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

#passport-close:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Stamp Grid */
#passport-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 30px;
    width: 100%;
    max-width: 800px;
}

.stamp-slot {
    background: rgba(255, 255, 255, 0.03);
    border: 1px dashed rgba(255, 255, 255, 0.2);
    border-radius: 16px;
    padding: 15px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    aspect-ratio: 1 / 1;
    transition: all 0.3s ease;
    text-align: center;
}

.stamp-slot img {
    width: 70px;
    height: 70px;
    object-fit: contain;
    transition: all 0.4s ease;
}

.stamp-slot .stamp-name {
    margin-top: 10px;
    font-size: 0.85rem;
    font-weight: 500;
    transition: color 0.3s ease;
}

/* Locked vs Unlocked States */
.stamp-slot.locked {
    box-shadow: inset 0 0 20px rgba(0,0,0,0.2);
}

.stamp-slot.locked img {
    filter: grayscale(100%) brightness(0.4) contrast(1.2);
    opacity: 0.5;
}

.stamp-slot.locked .stamp-name {
    color: #475569;
}

.stamp-slot.unlocked {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.4);
    box-shadow: 0 10px 20px rgba(0,0,0,0.2);
    transform: translateY(-5px);
}

.stamp-slot.unlocked img {
    filter: none;
    opacity: 1;
    transform: scale(1.1) rotate(-5deg);
    filter: drop-shadow(0 5px 10px rgba(0,0,0,0.3));
}

.stamp-slot.unlocked .stamp-name {
    color: #e2e8f0;
}

/* On-Screen Stamp Unlock Animation */
#stamp-animation-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    pointer-events: none; /* Let user keep clicking */
    z-index: 4000;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: radial-gradient(circle, rgba(0,0,0,0.4) 0%, rgba(0,0,0,0) 70%);
}

#stamp-animation-overlay.hidden {
    display: none;
}

#stamp-animation-img {
    width: 250px;
    height: 250px;
    object-fit: contain;
    filter: drop-shadow(0 15px 30px rgba(0,0,0,0.6));
    animation: stamp-flash 2.5s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

#stamp-animation-text {
    margin-top: 30px;
    font-size: 3rem;
    color: white;
    text-shadow: 0 4px 15px rgba(0,0,0,0.8);
    animation: stamp-fade-up 2.5s ease forwards;
}

@keyframes stamp-flash {
    0% { transform: scale(5) rotate(45deg); opacity: 0; }
    15% { transform: scale(0.9) rotate(-10deg); opacity: 1; }
    25% { transform: scale(1.1) rotate(-5deg); opacity: 1; }
    80% { transform: scale(1) rotate(-5deg); opacity: 1; }
    100% { transform: scale(0) rotate(-20deg); opacity: 0; }
}

@keyframes stamp-fade-up {
    0% { transform: translateY(50px); opacity: 0; }
    15% { transform: translateY(0); opacity: 1; }
    80% { transform: translateY(0); opacity: 1; }
    100% { transform: translateY(-50px); opacity: 0; }
}

/* Confetti Canvas */
#confetti-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    pointer-events: none;
    z-index: 5000;
}
