/* =========================================
   Viagem Zero V1.0.0
   Dark-first · Map-forward · Mobile-first
   ========================================= */

:root {
    /* Typography */
    --font-main: 'Outfit', sans-serif;

    /* Dark theme (default) */
    --bg: #0f1419;
    --surface: rgba(22, 28, 36, 0.85);
    --surface-solid: #161c24;
    --text: #e8eaed;
    --text-muted: #9aa0a6;
    --accent: #f0a500;
    --accent-glow: rgba(240, 165, 0, 0.3);
    --border: rgba(255, 255, 255, 0.08);
    --glass-bg: rgba(22, 28, 36, 0.78);
    --glass-border: rgba(255, 255, 255, 0.1);
    --glass-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    --card-radius: 16px;
    --route-color: #f0a500;
    --route-glow: rgba(240, 165, 0, 0.5);
    --marker-bg: #f0a500;
    --marker-text: #0f1419;
    --loader-bg: #0f1419;
}

[data-theme="light"] {
    --bg: #f5f0eb;
    --surface: rgba(255, 255, 255, 0.85);
    --surface-solid: #ffffff;
    --text: #1a1a2e;
    --text-muted: #5f6368;
    --accent: #d4820a;
    --accent-glow: rgba(212, 130, 10, 0.2);
    --border: rgba(0, 0, 0, 0.08);
    --glass-bg: rgba(255, 255, 255, 0.78);
    --glass-border: rgba(0, 0, 0, 0.08);
    --glass-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    --route-color: #d4820a;
    --route-glow: rgba(212, 130, 10, 0.3);
    --marker-bg: #d4820a;
    --marker-text: #ffffff;
    --loader-bg: #f5f0eb;
}

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

html, body {
    height: 100%;
    font-family: var(--font-main);
    background: var(--bg);
    color: var(--text);
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
}

/* ---- Map ---- */
#map {
    position: absolute;
    inset: 0;
    z-index: 1;
}

/* Leaflet overrides */
.leaflet-control-zoom {
    border: none !important;
    box-shadow: var(--glass-shadow) !important;
}
.leaflet-control-zoom a {
    background: var(--surface-solid) !important;
    color: var(--text) !important;
    border: 1px solid var(--border) !important;
    width: 36px !important;
    height: 36px !important;
    line-height: 36px !important;
    font-size: 16px !important;
}
.leaflet-control-attribution {
    background: var(--glass-bg) !important;
    color: var(--text-muted) !important;
    font-size: 10px !important;
    backdrop-filter: blur(8px);
}
.leaflet-control-attribution a { color: var(--accent) !important; }

/* ---- Glass utility ---- */
.glass {
    background: var(--glass-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    box-shadow: var(--glass-shadow);
}

/* ---- Top bar ---- */
#topbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: var(--glass-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--glass-border);
}

.logo {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 20px;
    text-decoration: none;
    color: var(--text);
}
.logo-img {
    height: 28px;
    width: auto;
}
.logo-text {
    font-weight: 600;
    font-size: 16px;
    letter-spacing: 0.5px;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

#trip-selector {
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 6px 10px;
    font-family: var(--font-main);
    font-size: 13px;
    cursor: pointer;
    max-width: 160px;
}
#trip-selector:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

.icon-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    color: var(--text);
    font-family: var(--font-main);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}
.icon-btn:hover {
    background: var(--accent);
    color: var(--marker-text);
    border-color: var(--accent);
}

/* ---- Location card ---- */
#location-card {
    position: fixed;
    bottom: 170px;
    left: 16px;
    right: 16px;
    z-index: 1000;
    border-radius: var(--card-radius);
    padding: 20px;
    max-width: 420px;
    animation: slideUp 0.5s ease-out;
}

.card-header {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 12px;
}

.card-flag {
    width: 48px;
    height: 36px;
    border-radius: 6px;
    object-fit: cover;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.card-location {
    font-size: 20px;
    font-weight: 700;
    line-height: 1.2;
}

.card-country {
    font-size: 14px;
    color: var(--text-muted);
    font-weight: 400;
}

.card-meta {
    display: flex;
    gap: 20px;
    font-size: 13px;
    color: var(--text-muted);
}
.card-meta i {
    color: var(--accent);
    margin-right: 4px;
}

.card-notes {
    margin-top: 12px;
    font-size: 13px;
    color: var(--text-muted);
    font-style: italic;
    border-top: 1px solid var(--border);
    padding-top: 12px;
}

/* ---- Photo strip ---- */
#photo-strip {
    position: fixed;
    bottom: 165px;
    right: 16px;
    z-index: 999;
    border-radius: var(--card-radius);
    overflow: hidden;
    max-width: 440px;
    animation: slideUp 0.6s ease-out;
}

#photo-strip-inner {
    display: flex;
    gap: 2px;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}
#photo-strip-inner::-webkit-scrollbar { display: none; }

.strip-photo {
    flex: 0 0 auto;
    width: 140px;
    scroll-snap-align: start;
    cursor: pointer;
    transition: opacity 0.2s;
}
.strip-photo:hover { opacity: 0.85; }

.strip-photo img {
    width: 140px;
    height: 105px;
    object-fit: cover;
    display: block;
}

.strip-photo .strip-caption {
    padding: 6px 8px;
    font-size: 10px;
    color: var(--text-muted);
    background: var(--glass-bg);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ---- Country flags strip (scrollable, between stats and footer) ---- */
#flag-strip {
    position: fixed;
    bottom: 76px;
    left: 0;
    right: 0;
    z-index: 1000;
    background: var(--glass-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-top: 1px solid var(--glass-border);
    padding: 5px 16px;
    overflow: hidden;
}

.country-flags {
    display: flex;
    justify-content: center;
    gap: 6px;
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
}
.country-flags::-webkit-scrollbar { display: none; }

.country-flags img {
    width: 24px;
    height: 16px;
    border-radius: 2px;
    object-fit: cover;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
    flex-shrink: 0;
}

/* ---- Route animation ---- */
.route-animate {
    animation: drawRoute 2.5s ease-out forwards;
}

@keyframes drawRoute {
    from { stroke-dashoffset: var(--route-length); }
    to   { stroke-dashoffset: 0; }
}

/* ---- Stats bar ---- */
#stats-bar {
    position: fixed;
    bottom: 102px;
    left: 0;
    right: 0;
    z-index: 1000;
    padding: 12px 16px;
    border-top: 1px solid var(--glass-border);
    border-radius: 20px 20px 0 0;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    text-align: center;
}

.stat-value {
    display: block;
    font-size: 24px;
    font-weight: 700;
    color: var(--accent);
    line-height: 1.2;
}

.stat-label {
    display: block;
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 500;
}

.stat-sub {
    display: block;
    font-size: 11px;
    font-weight: 400;
    color: var(--text-muted);
    line-height: 1.2;
}

/* ---- Site footer (3-line stacked) ---- */
#site-footer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 8px 16px 10px;
    background: var(--glass-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-top: 1px solid var(--glass-border);
}

.footer-line {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.footer-logo-img {
    height: 16px;
    width: auto;
}

.footer-name {
    color: var(--accent);
    font-size: 13px;
}

.footer-tagline {
    font-size: 12px;
    color: var(--text-muted);
}

.footer-social {
    gap: 14px;
}
.footer-social a {
    color: var(--text-muted);
    font-size: 14px;
    text-decoration: none;
    transition: color 0.2s;
}
.footer-social a:hover {
    color: var(--accent);
}
.footer-site-link {
    font-size: 12px;
    font-weight: 500;
}

.footer-copy {
    font-size: 10px;
    color: var(--text-muted);
    flex-wrap: wrap;
}
.footer-copy a {
    color: var(--accent);
    text-decoration: none;
}
.footer-copy a:hover {
    text-decoration: underline;
}

/* ---- Loading overlay ---- */
#loading-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: var(--loader-bg);
    gap: 20px;
    transition: opacity 0.4s ease;
}
#loading-overlay.fade-out {
    opacity: 0;
    pointer-events: none;
}
#loading-overlay p {
    font-size: 14px;
    color: var(--text-muted);
}

.loader {
    display: flex;
    gap: 8px;
}
.loader-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--accent);
    animation: bounce 1.2s ease-in-out infinite;
}
.loader-dot:nth-child(2) { animation-delay: 0.2s; }
.loader-dot:nth-child(3) { animation-delay: 0.4s; }

/* ---- Custom markers ---- */
.stop-marker {
    width: 12px;
    height: 12px;
    background: var(--accent);
    border: 2px solid var(--surface-solid);
    border-radius: 50%;
    box-shadow: 0 0 8px var(--accent-glow);
}

.route-marker {
    width: 6px;
    height: 6px;
    background: var(--accent);
    border: 1px solid var(--surface-solid);
    border-radius: 50%;
    opacity: 0.4;
}

.current-marker {
    width: 18px;
    height: 18px;
    background: var(--accent);
    border: 3px solid var(--surface-solid);
    border-radius: 50%;
    box-shadow: 0 0 16px var(--accent-glow), 0 0 32px var(--accent-glow);
    animation: pulse 2s ease-in-out infinite;
}

.marker-popup {
    font-family: var(--font-main);
    text-align: center;
    padding: 4px;
}
.marker-popup strong {
    display: block;
    font-size: 14px;
    margin-bottom: 2px;
}
.marker-popup span {
    font-size: 12px;
    color: #666;
}

/* ---- Animations ---- */
@keyframes slideUp {
    from { opacity: 0; transform: translateY(30px); }
    to   { opacity: 1; transform: translateY(0); }
}

@keyframes bounce {
    0%, 80%, 100% { transform: translateY(0); }
    40% { transform: translateY(-12px); }
}

@keyframes pulse {
    0%, 100% { box-shadow: 0 0 16px var(--accent-glow), 0 0 32px var(--accent-glow); }
    50%      { box-shadow: 0 0 24px var(--accent-glow), 0 0 48px var(--accent-glow); }
}

/* ---- Hidden utility ---- */
.hidden { display: none !important; }

/* ---- Desktop layout ---- */
@media (min-width: 1024px) {
    #location-card {
        bottom: 180px;
        left: 24px;
        right: auto;
        width: 380px;
    }

    #photo-strip {
        bottom: 170px;
        right: 24px;
        max-width: 560px;
    }
    .strip-photo { width: 160px; }
    .strip-photo img { width: 160px; height: 120px; }

    #stats-bar { padding: 12px 32px; }
    .stat-value { font-size: 28px; }
}

/* ---- Small phones ---- */
@media (max-width: 480px) {
    #location-card {
        bottom: 160px;
        padding: 14px;
    }
    .card-location { font-size: 17px; }
    .card-flag { width: 40px; height: 30px; }

    #photo-strip { display: none; }

    .stat-value { font-size: 18px; }
    .stat-label { font-size: 9px; }

    #flag-strip { padding: 4px 12px; }
    .country-flags { gap: 4px; }
    .country-flags img { width: 20px; height: 14px; }

    #site-footer {
        padding: 6px 12px 8px;
        gap: 3px;
    }
    .footer-logo-img { height: 12px; }
    .footer-name { font-size: 11px; }
    .footer-tagline { font-size: 10px; }
    .footer-social { gap: 10px; }
    .footer-social a { font-size: 12px; }
    .footer-site-link { font-size: 10px; }
    .footer-copy { font-size: 9px; }
}

/* Safe area for notched phones */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
    #site-footer {
        padding-bottom: calc(8px + env(safe-area-inset-bottom));
    }
}
