/* ============================================
   KLAUS EXPLORE MODE - Mobile-First CSS
   Dark theme matching CARTO Dark Tiles
   ============================================ */

:root {
    --klaus-bg: #1a1a2e;
    --klaus-surface: #16213e;
    --klaus-card: #0f3460;
    --klaus-primary: #e94560;
    --klaus-accent: #fbbf24;
    --klaus-text: #f0f0f0;
    --klaus-text-dim: #8892a4;
    --klaus-success: #4ade80;
    --klaus-border: rgba(255,255,255,0.1);
}

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

html, body {
    height: 100%;
    width: 100%;
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--klaus-bg);
    color: var(--klaus-text);
    -webkit-tap-highlight-color: transparent;
}

/* ── MAP ────────────────────────────── */
#explore-map {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    z-index: 1;
}

/* ── FAB BUTTON ─────────────────────── */
#fab-discover {
    position: fixed;
    bottom: 32px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;

    width: auto;
    padding: 16px 32px;
    border-radius: 50px;
    border: none;
    background: var(--klaus-primary);
    color: white;
    font-size: 17px;
    font-weight: 700;
    letter-spacing: 0.3px;
    cursor: pointer;
    box-shadow: 0 4px 24px rgba(233, 69, 96, 0.5);
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 8px;
}

#fab-discover:active {
    transform: translateX(-50%) scale(0.95);
}

#fab-discover.loading {
    opacity: 0.7;
    pointer-events: none;
}

#fab-discover .fab-icon {
    font-size: 20px;
}

/* ── BOTTOM SHEET ───────────────────── */
#bottom-sheet {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    z-index: 2000;
    background: var(--klaus-surface);
    border-radius: 20px 20px 0 0;
    transform: translateY(100%);
    transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    max-height: 70vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

#bottom-sheet.open {
    transform: translateY(0);
}

#bottom-sheet .sheet-handle {
    width: 40px;
    height: 4px;
    background: var(--klaus-border);
    border-radius: 2px;
    margin: 12px auto 8px;
    flex-shrink: 0;
}

#bottom-sheet .sheet-header {
    padding: 4px 20px 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

#bottom-sheet .sheet-header h2 {
    font-size: 18px;
    font-weight: 700;
}

#bottom-sheet .sheet-close {
    background: none;
    border: none;
    color: var(--klaus-text-dim);
    font-size: 24px;
    cursor: pointer;
    padding: 4px 8px;
}

/* ── SPOT LIST ──────────────────────── */
#spot-list {
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 0 16px 24px;
    flex: 1;
}

.spot-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 12px;
    border-radius: 14px;
    background: rgba(255,255,255,0.04);
    margin-bottom: 8px;
    cursor: pointer;
    transition: background 0.15s;
    border: 1px solid transparent;
}

.spot-item:active {
    background: rgba(255,255,255,0.1);
}

.spot-item.has-audio {
    border-color: rgba(74, 222, 128, 0.2);
}

.spot-icon {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    flex-shrink: 0;
}

.spot-icon.landmark { background: rgba(251, 191, 36, 0.15); }
.spot-icon.culture { background: rgba(102, 126, 234, 0.15); }
.spot-icon.historic { background: rgba(168, 85, 247, 0.15); }
.spot-icon.nightlife { background: rgba(233, 69, 96, 0.15); }
.spot-icon.food { background: rgba(251, 146, 60, 0.15); }
.spot-icon.nature { background: rgba(74, 222, 128, 0.15); }
.spot-icon.art { background: rgba(244, 114, 182, 0.15); }
.spot-icon.memorial { background: rgba(148, 163, 184, 0.15); }
.spot-icon.default { background: rgba(255,255,255,0.08); }

.spot-info {
    flex: 1;
    min-width: 0;
}

.spot-name {
    font-size: 15px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.spot-meta {
    font-size: 13px;
    color: var(--klaus-text-dim);
    margin-top: 2px;
    display: flex;
    gap: 8px;
    align-items: center;
}

.spot-distance {
    font-variant-numeric: tabular-nums;
}

.spot-cached-badge {
    font-size: 11px;
    background: rgba(74, 222, 128, 0.15);
    color: var(--klaus-success);
    padding: 1px 6px;
    border-radius: 4px;
}

.spot-arrow {
    color: var(--klaus-text-dim);
    font-size: 18px;
    flex-shrink: 0;
}

/* ── LOADING / GENERATING OVERLAY ──── */
#generating-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    z-index: 3000;
    background: rgba(26, 26, 46, 0.95);
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 40px;
}

#generating-overlay.active {
    display: flex;
}

#generating-overlay .gen-icon {
    font-size: 64px;
    margin-bottom: 24px;
    animation: pulse 1.5s ease-in-out infinite;
}

#generating-overlay .gen-spot-name {
    font-size: 22px;
    font-weight: 700;
    margin-bottom: 12px;
}

#generating-overlay .gen-status {
    font-size: 15px;
    color: var(--klaus-text-dim);
    margin-bottom: 32px;
    min-height: 48px;
}

.gen-dots {
    display: flex;
    gap: 8px;
    justify-content: center;
}

.gen-dots span {
    width: 10px;
    height: 10px;
    background: var(--klaus-primary);
    border-radius: 50%;
    animation: bounce 1.4s ease-in-out infinite;
}
.gen-dots span:nth-child(2) { animation-delay: 0.16s; }
.gen-dots span:nth-child(3) { animation-delay: 0.32s; }

@keyframes bounce {
    0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
    40% { transform: scale(1); opacity: 1; }
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.08); }
}

/* ── AUDIO PLAYER ───────────────────── */
#audio-player {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    z-index: 2500;
    background: var(--klaus-card);
    border-radius: 20px 20px 0 0;
    padding: 20px;
    transform: translateY(100%);
    transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 -4px 32px rgba(0,0,0,0.5);
}

#audio-player.active {
    transform: translateY(0);
}

.player-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 16px;
}

.player-spot-name {
    font-size: 18px;
    font-weight: 700;
    flex: 1;
    margin-right: 12px;
}

.player-category {
    font-size: 13px;
    color: var(--klaus-text-dim);
    margin-top: 4px;
}

.player-close {
    background: none;
    border: none;
    color: var(--klaus-text-dim);
    font-size: 20px;
    cursor: pointer;
    padding: 4px;
}

/* Progress bar */
.player-progress {
    width: 100%;
    height: 4px;
    background: rgba(255,255,255,0.1);
    border-radius: 2px;
    margin-bottom: 16px;
    overflow: hidden;
    cursor: pointer;
}

.player-progress-fill {
    height: 100%;
    background: var(--klaus-primary);
    border-radius: 2px;
    width: 0%;
    transition: width 0.3s linear;
}

/* Controls */
.player-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 24px;
}

.player-btn {
    background: none;
    border: none;
    color: var(--klaus-text);
    font-size: 28px;
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    transition: background 0.15s;
}

.player-btn:active {
    background: rgba(255,255,255,0.1);
}

.player-btn.play-pause {
    width: 56px;
    height: 56px;
    background: var(--klaus-primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
}

/* Feedback */
.player-feedback {
    display: flex;
    justify-content: center;
    gap: 16px;
    margin-top: 16px;
    padding-top: 12px;
    border-top: 1px solid var(--klaus-border);
}

.feedback-btn {
    background: rgba(255,255,255,0.06);
    border: 1px solid var(--klaus-border);
    border-radius: 20px;
    padding: 6px 16px;
    color: var(--klaus-text-dim);
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.15s;
}

.feedback-btn.active-up {
    background: rgba(74, 222, 128, 0.15);
    border-color: var(--klaus-success);
    color: var(--klaus-success);
}

.feedback-btn.active-down {
    background: rgba(233, 69, 96, 0.15);
    border-color: var(--klaus-primary);
    color: var(--klaus-primary);
}

/* ── GPS PERMISSION ─────────────────── */
#gps-prompt {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    z-index: 5000;
    background: var(--klaus-bg);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 40px;
}

#gps-prompt .gps-icon {
    font-size: 72px;
    margin-bottom: 24px;
}

#gps-prompt h1 {
    font-size: 24px;
    margin-bottom: 12px;
}

#gps-prompt p {
    color: var(--klaus-text-dim);
    font-size: 16px;
    margin-bottom: 32px;
    max-width: 300px;
    line-height: 1.5;
}

#gps-prompt button {
    padding: 14px 40px;
    border: none;
    border-radius: 50px;
    background: var(--klaus-primary);
    color: white;
    font-size: 17px;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(233, 69, 96, 0.4);
}

/* ── UTILITIES ──────────────────────── */
.hidden { display: none !important; }

/* Safe area for iOS */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
    #fab-discover { bottom: calc(32px + env(safe-area-inset-bottom)); }
    #audio-player { padding-bottom: calc(20px + env(safe-area-inset-bottom)); }
    #bottom-sheet { padding-bottom: env(safe-area-inset-bottom); }
}

/* ── QUICK-FACT IN LOADING ──────────── */
.gen-fact {
    font-size: 17px;
    color: var(--klaus-accent);
    font-weight: 600;
    line-height: 1.4;
    max-width: 320px;
    margin: 0 auto 24px;
    opacity: 0;
    transform: translateY(8px);
    transition: opacity 0.5s ease, transform 0.5s ease;
    min-height: 0;
}

.gen-fact.visible {
    opacity: 1;
    transform: translateY(0);
    min-height: 24px;
}

.gen-status.has-fact {
    font-size: 13px;
    color: var(--klaus-text-dim);
    opacity: 0.5;
    margin-bottom: 8px;
}

/* ── MARKER CONFIRM POPUP ──────────── */
.klaus-popup .leaflet-popup-content-wrapper {
    background: var(--klaus-surface, #16213e);
    color: var(--klaus-text, #f0f0f0);
    border-radius: 14px;
    box-shadow: 0 4px 24px rgba(0,0,0,0.5);
    border: 1px solid rgba(255,255,255,0.1);
}

.klaus-popup .leaflet-popup-tip {
    background: var(--klaus-surface, #16213e);
}

.klaus-popup .leaflet-popup-close-button {
    color: var(--klaus-text-dim, #8892a4);
    font-size: 18px;
}

.confirm-popup {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 4px 0;
    min-width: 160px;
}

.confirm-popup strong {
    font-size: 15px;
    font-weight: 700;
}

.confirm-meta {
    font-size: 13px;
    color: var(--klaus-text-dim, #8892a4);
}

.confirm-btn {
    margin-top: 6px;
    padding: 10px 16px;
    border: none;
    border-radius: 10px;
    background: var(--klaus-primary, #e94560);
    color: white;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    text-align: center;
    box-shadow: 0 2px 12px rgba(233, 69, 96, 0.4);
    transition: transform 0.1s;
}

.confirm-btn:active {
    transform: scale(0.96);
}

/* Leaflet overrides */
.leaflet-control-zoom { display: none !important; }
.leaflet-control-attribution { font-size: 9px !important; opacity: 0.4; }
