/**
 * Journey Map Styles
 *
 * Vintage/antique map aesthetic for the interactive journey visualization.
 * Uses the memorial system's design language (cream, sage, gold, charcoal)
 * with sepia filters and aged paper textures.
 */

/* ============================================
   CSS CUSTOM PROPERTIES
   ============================================ */
:root {
    /* Memorial palette */
    --color-cream: #faf8f5;
    --color-warm-white: #f5f2ed;
    --color-sage: #a8b5a0;
    --color-sage-dark: #6b7865;
    --color-charcoal: #3d3d3d;
    --color-soft-black: #2a2a2a;
    --color-gold: #c9a962;
    --color-gold-light: #dcc584;

    /* Vintage paper tones */
    --paper: #f4efe2;
    --paper-dark: #ece4d2;
    --ink: #1d1b16;
    --ink-muted: rgba(29, 27, 22, 0.7);

    /* Typography - newspaper style with Times New Roman */
    --font-display: 'Times New Roman', Times, 'Noto Serif', Georgia, serif;
    --font-body: 'Times New Roman', Times, 'Noto Serif', Georgia, serif;

    /* Spacing */
    --header-height: 120px;
    --footer-height: 80px;
    --panel-padding: 1.5rem;

    /* Transitions */
    --transition-fast: 150ms ease;
    --transition-medium: 300ms ease;
    --transition-slow: 500ms ease;
}

/* ============================================
   BASE STYLES
   ============================================ */
*,
*::before,
*::after {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    padding: 0;
    height: 100%;
    overflow: hidden;
    background-color: var(--paper);
}

body {
    font-family: var(--font-body);
    font-weight: 400;
    color: var(--charcoal);
    line-height: 1.6;
    display: flex;
    flex-direction: column;
}

/* ============================================
   HEADER
   ============================================ */
.journey-header {
    position: relative;
    z-index: 100;
    background: linear-gradient(to bottom, var(--paper) 0%, var(--paper-dark) 100%);
    border-bottom: 1px solid rgba(29, 27, 22, 0.15);
    padding: 1rem 1.5rem;
    text-align: center;
    flex-shrink: 0;
}

.journey-nav {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
    font-size: 0.85rem;
    font-weight: 400;
    letter-spacing: 0.02em;
}

.nav-link {
    color: var(--color-sage-dark);
    text-decoration: none;
    transition: color var(--transition-fast);
}

.nav-link:hover {
    color: var(--color-gold);
}

.nav-divider {
    color: var(--ink-muted);
    opacity: 0.5;
}

.nav-current {
    color: var(--ink);
    font-weight: 500;
}

.journey-title {
    font-family: var(--font-display);
    font-size: clamp(1.75rem, 5vw, 2.5rem);
    font-weight: 400;
    color: var(--ink);
    margin: 0 0 0.25rem 0;
    letter-spacing: 0.02em;
}

.journey-subtitle {
    font-size: 0.9rem;
    color: var(--ink-muted);
    margin: 0;
    font-weight: 300;
}

/* ============================================
   MAP CONTAINER
   ============================================ */
.map-wrapper {
    position: relative;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

.map-container {
    position: absolute;
    inset: 0;
    /* Vintage filter effect */
    filter: sepia(0.18) contrast(1.02) saturate(0.92);
}

/* Vignette overlay for aged look */
.map-vignette {
    position: absolute;
    inset: 0;
    pointer-events: none;
    background: radial-gradient(
        ellipse at center,
        transparent 40%,
        rgba(244, 239, 226, 0.25) 70%,
        rgba(236, 228, 210, 0.5) 100%
    );
    z-index: 5;
}

/* ============================================
   LOADING STATE
   ============================================ */
.map-loading {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: var(--paper);
    z-index: 1000;
    transition: opacity var(--transition-medium);
}

.map-loading.hidden {
    opacity: 0;
    pointer-events: none;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--paper-dark);
    border-top-color: var(--color-gold);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading-text {
    margin-top: 1rem;
    font-size: 0.9rem;
    color: var(--ink-muted);
    font-weight: 300;
}

/* ============================================
   CONTROL PANEL
   ============================================ */
.control-panel {
    position: absolute;
    top: 1rem;
    left: 1rem;
    z-index: 50;
    background: rgba(250, 248, 245, 0.95);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid rgba(29, 27, 22, 0.1);
    border-radius: 8px;
    padding: 0.875rem 1rem;
    box-shadow: 0 4px 16px rgba(29, 27, 22, 0.08);
}

.control-stats {
    display: flex;
    gap: 1.25rem;
    margin-bottom: 0.75rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid rgba(29, 27, 22, 0.08);
}

.stat {
    text-align: center;
}

.stat-value {
    display: block;
    font-family: var(--font-display);
    font-size: 1.35rem;
    font-weight: 600;
    color: var(--color-sage-dark);
    line-height: 1.1;
    letter-spacing: -0.02em;
}

.stat-label {
    display: block;
    font-size: 0.6rem;
    color: var(--ink-muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-top: 0.15rem;
}

.control-buttons {
    display: flex;
    gap: 0.5rem;
}

.control-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    padding: 0.45rem 0.75rem;
    font-family: var(--font-body);
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--paper);
    background: var(--color-sage-dark);
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap;
}

.control-btn:hover {
    background: var(--color-gold);
}

.control-btn:active {
    transform: scale(0.97);
}

.control-btn.secondary {
    color: var(--ink-muted);
    background: transparent;
    border: 1px solid rgba(29, 27, 22, 0.15);
    padding: 0.4rem 0.7rem;
}

.control-btn.secondary:hover {
    border-color: var(--color-sage-dark);
    color: var(--color-sage-dark);
    background: rgba(29, 27, 22, 0.03);
}

.control-btn.playing {
    background: var(--color-gold);
}

.control-btn.playing .play-icon::before {
    content: '';
    display: inline-block;
    width: 8px;
    height: 8px;
    background: currentColor;
    border-radius: 1px;
    border: none;
}

.control-btn.playing .btn-text {
    display: none;
}

.control-btn.playing::after {
    content: 'Pause';
}

.play-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 10px;
    height: 10px;
}

.play-icon::before {
    content: '';
    display: block;
    width: 0;
    height: 0;
    border-left: 7px solid currentColor;
    border-top: 4px solid transparent;
    border-bottom: 4px solid transparent;
}

/* ============================================
   MAP LEGEND
   ============================================ */
.map-legend {
    position: absolute;
    bottom: 1rem;
    left: 1rem;
    z-index: 50;
    background: rgba(250, 248, 245, 0.95);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid rgba(29, 27, 22, 0.1);
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(29, 27, 22, 0.08);
    font-size: 0.7rem;
    overflow: hidden;
    transition: all var(--transition-medium);
}

.legend-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    width: 100%;
    padding: 0.5rem 0.75rem;
    background: transparent;
    border: none;
    cursor: pointer;
    font-family: var(--font-body);
    text-align: left;
    transition: background var(--transition-fast);
}

.legend-toggle:hover {
    background: rgba(29, 27, 22, 0.03);
}

.legend-title {
    font-family: var(--font-body);
    font-size: 0.65rem;
    font-weight: 600;
    color: var(--ink-muted);
    margin: 0;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.legend-toggle-icon {
    width: 12px;
    height: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--ink-muted);
    transition: transform var(--transition-fast);
}

.legend-toggle-icon::before {
    content: '';
    display: block;
    width: 0;
    height: 0;
    border-left: 4px solid transparent;
    border-right: 4px solid transparent;
    border-top: 5px solid currentColor;
}

.map-legend.collapsed .legend-toggle-icon {
    transform: rotate(-90deg);
}

.legend-content {
    max-height: 200px;
    overflow: hidden;
    transition: max-height var(--transition-medium), padding var(--transition-medium);
}

.map-legend.collapsed .legend-content {
    max-height: 0;
}

.legend-list {
    list-style: none;
    margin: 0;
    padding: 0 0.75rem 0.6rem;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.legend-marker {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    border: 1.5px solid;
    flex-shrink: 0;
}

.legend-marker.origin {
    background: var(--color-gold);
    border-color: var(--color-gold);
}

.legend-marker.peacecorps {
    background: var(--color-sage);
    border-color: var(--color-sage-dark);
}

.legend-marker.journey {
    background: var(--paper);
    border-color: var(--color-sage-dark);
}

.legend-line {
    width: 18px;
    height: 2px;
    flex-shrink: 0;
}

.legend-line.ship {
    background: repeating-linear-gradient(
        90deg,
        var(--color-sage) 0px,
        var(--color-sage) 3px,
        transparent 3px,
        transparent 6px
    );
}

.legend-line.motorcycle {
    background: repeating-linear-gradient(
        90deg,
        var(--color-sage-dark) 0px,
        var(--color-sage-dark) 2px,
        transparent 2px,
        transparent 5px
    );
}

.legend-label {
    color: var(--ink-muted);
    font-size: 0.68rem;
}

/* ============================================
   INFO PANEL (Waypoint Details)
   ============================================ */
.info-panel {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 60;
    background: rgba(250, 248, 245, 0.98);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-top: 1px solid rgba(29, 27, 22, 0.1);
    padding: 1.25rem 1.5rem;
    transform: translateY(100%);
    transition: transform var(--transition-medium);
    box-shadow: 0 -4px 24px rgba(29, 27, 22, 0.12);
}

.info-panel.active {
    transform: translateY(0);
}

.info-panel[aria-hidden="false"] {
    transform: translateY(0);
}

.info-close {
    position: absolute;
    top: 0.875rem;
    right: 1rem;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 1px solid rgba(29, 27, 22, 0.15);
    border-radius: 50%;
    font-size: 1.1rem;
    color: var(--ink-muted);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.info-close:hover {
    border-color: var(--color-sage-dark);
    color: var(--color-sage-dark);
    background: rgba(29, 27, 22, 0.03);
}

.info-content {
    max-width: 540px;
    margin: 0 auto;
}

.info-date {
    display: inline-block;
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--color-sage-dark);
    margin-bottom: 0.35rem;
}

.info-title {
    font-family: var(--font-display);
    font-size: 1.35rem;
    font-weight: 500;
    color: var(--ink);
    margin: 0 0 0.5rem 0;
    line-height: 1.25;
}

.info-excerpt {
    font-size: 0.875rem;
    color: var(--ink-muted);
    margin: 0 0 0.75rem 0;
    line-height: 1.65;
    font-style: italic;
}

.info-link {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--color-sage-dark);
    text-decoration: none;
    transition: color var(--transition-fast);
}

.info-link:hover {
    color: var(--color-gold);
}

.info-link.hidden {
    display: none;
}

/* ============================================
   LOCATION INDICATOR (During Playback)
   ============================================ */
.location-indicator {
    position: absolute;
    top: 1rem;
    left: 50%;
    transform: translateX(-50%);
    z-index: 55;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    background: rgba(250, 248, 245, 0.95);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid rgba(29, 27, 22, 0.1);
    border-radius: 16px;
    padding: 0.4rem 0.875rem;
    box-shadow: 0 4px 16px rgba(29, 27, 22, 0.08);
    font-size: 0.75rem;
    opacity: 0;
    transition: opacity var(--transition-medium);
}

.location-indicator.visible {
    opacity: 1;
}

.location-indicator[aria-hidden="false"] {
    opacity: 1;
}

.location-icon {
    width: 6px;
    height: 6px;
    background: var(--color-gold);
    border-radius: 50%;
    animation: pulse 1.5s ease-in-out infinite;
}

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

.location-name {
    font-weight: 500;
    color: var(--ink);
    letter-spacing: -0.01em;
}

/* ============================================
   FOOTER
   ============================================ */
.journey-footer {
    position: relative;
    z-index: 100;
    background: var(--paper-dark);
    border-top: 1px solid rgba(29, 27, 22, 0.15);
    padding: 1rem 1.5rem;
    text-align: center;
    flex-shrink: 0;
}

.journey-footer p {
    margin: 0;
    font-size: 0.85rem;
    color: var(--ink-muted);
}

.journey-footer p + p {
    margin-top: 0.25rem;
}

.journey-footer a {
    color: var(--color-sage-dark);
    text-decoration: none;
    font-weight: 500;
    transition: color var(--transition-fast);
}

.journey-footer a:hover {
    color: var(--color-gold);
}

/* ============================================
   MAPBOX CUSTOM MARKERS
   ============================================ */
.marker {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 2px solid;
    cursor: pointer;
    transition: all var(--transition-fast);
    box-shadow: 0 1px 3px rgba(29, 27, 22, 0.15);
}

.marker:hover {
    transform: scale(1.25);
    box-shadow: 0 2px 6px rgba(29, 27, 22, 0.2);
}

.marker.active {
    transform: scale(1.4);
    box-shadow: 0 0 0 3px rgba(107, 120, 101, 0.25);
}

.marker-origin {
    background: var(--color-gold);
    border-color: var(--color-gold);
    width: 14px;
    height: 14px;
}

.marker-peacecorps {
    background: var(--color-sage);
    border-color: var(--color-sage-dark);
}

.marker-journey {
    background: var(--paper);
    border-color: var(--color-sage-dark);
}

.marker-destination {
    background: var(--color-gold);
    border-color: var(--color-gold);
    width: 16px;
    height: 16px;
}

/* Mapbox popup overrides */
.mapboxgl-popup-content {
    background: rgba(250, 248, 245, 0.98) !important;
    backdrop-filter: blur(8px) !important;
    -webkit-backdrop-filter: blur(8px) !important;
    border: 1px solid rgba(29, 27, 22, 0.1) !important;
    border-radius: 6px !important;
    padding: 0.5rem 0.75rem !important;
    box-shadow: 0 4px 12px rgba(29, 27, 22, 0.1) !important;
    font-family: var(--font-body) !important;
}

.mapboxgl-popup-tip {
    border-top-color: rgba(250, 248, 245, 0.98) !important;
}

.mapboxgl-popup-close-button {
    color: var(--ink-muted) !important;
    font-size: 1rem !important;
    padding: 0.2rem 0.4rem !important;
}

.mapboxgl-popup-close-button:hover {
    color: var(--color-sage-dark) !important;
    background: transparent !important;
}

.popup-title {
    font-family: var(--font-display);
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--ink);
    margin: 0 0 0.15rem 0;
}

.popup-date {
    font-size: 0.65rem;
    color: var(--color-sage-dark);
    font-weight: 500;
}

/* ============================================
   MAPBOX CONTROLS STYLING
   ============================================ */
.mapboxgl-ctrl-group {
    background: var(--paper) !important;
    border: 1px solid rgba(29, 27, 22, 0.15) !important;
    box-shadow: 0 2px 8px rgba(29, 27, 22, 0.1) !important;
}

.mapboxgl-ctrl-group button {
    background-color: var(--paper) !important;
}

.mapboxgl-ctrl-group button:hover {
    background-color: var(--paper-dark) !important;
}

.mapboxgl-ctrl-group button + button {
    border-top: 1px solid rgba(29, 27, 22, 0.1) !important;
}

/* ============================================
   BASEMAP SWITCHER
   ============================================ */
.basemap-switcher {
    position: absolute;
    bottom: 1rem;
    right: 1rem;
    z-index: 50;
    display: flex;
    gap: 0.35rem;
    background: rgba(250, 248, 245, 0.95);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid rgba(29, 27, 22, 0.1);
    border-radius: 6px;
    padding: 0.3rem;
    box-shadow: 0 4px 16px rgba(29, 27, 22, 0.08);
}

.basemap-option {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 0;
    background: transparent;
    border: 2px solid transparent;
    border-radius: 4px;
    cursor: pointer;
    transition: all var(--transition-fast);
    overflow: hidden;
}

.basemap-option:hover {
    border-color: rgba(29, 27, 22, 0.2);
}

.basemap-option.active {
    border-color: var(--color-sage-dark);
}

.basemap-icon {
    width: 100%;
    height: 100%;
    border-radius: 2px;
    background-size: cover;
    background-position: center;
}

.basemap-icon.light {
    background: linear-gradient(135deg, #f5f5f5 0%, #e8e8e8 50%, #ddd 100%);
}

.basemap-icon.satellite {
    background: linear-gradient(135deg, #2d4a3e 0%, #1a3a2a 50%, #3d5a4e 100%);
}

.basemap-icon.streets {
    background: linear-gradient(135deg, #fff 0%, #f0f0f0 25%, #e5e5e5 50%, #ddd 100%);
    position: relative;
}

/* Add simple road pattern for streets icon */
.basemap-icon.streets::before {
    content: '';
    position: absolute;
    inset: 0;
    background:
        linear-gradient(90deg, transparent 45%, #bbb 45%, #bbb 55%, transparent 55%),
        linear-gradient(0deg, transparent 45%, #bbb 45%, #bbb 55%, transparent 55%);
}

/* ============================================
   RESPONSIVE DESIGN
   ============================================ */

/* Tablet and below */
@media (max-width: 768px) {
    .journey-header {
        padding: 0.75rem 1rem;
    }

    .journey-title {
        font-size: 1.5rem;
    }

    .journey-subtitle {
        font-size: 0.8rem;
    }

    .control-panel {
        top: 0.75rem;
        left: 0.75rem;
        padding: 0.75rem 0.875rem;
    }

    .control-stats {
        gap: 1rem;
        margin-bottom: 0.6rem;
        padding-bottom: 0.6rem;
    }

    .stat-value {
        font-size: 1.15rem;
    }

    .stat-label {
        font-size: 0.55rem;
    }

    .control-btn {
        padding: 0.4rem 0.6rem;
        font-size: 0.7rem;
    }

    .control-btn.secondary {
        padding: 0.35rem 0.55rem;
    }

    .map-legend {
        bottom: 0.75rem;
        left: 0.75rem;
    }

    .legend-toggle {
        padding: 0.4rem 0.6rem;
    }

    .legend-title {
        font-size: 0.6rem;
    }

    .legend-list {
        padding: 0 0.6rem 0.5rem;
        gap: 0.3rem;
    }

    .legend-label {
        font-size: 0.62rem;
    }

    .info-panel {
        padding: 1.25rem;
    }

    .info-title {
        font-size: 1.25rem;
    }

    .info-excerpt {
        font-size: 0.9rem;
    }

    .journey-footer {
        padding: 0.75rem 1rem;
    }

    .journey-footer p {
        font-size: 0.8rem;
    }
}

/* Mobile */
@media (max-width: 480px) {
    .journey-nav {
        font-size: 0.75rem;
        gap: 0.4rem;
    }

    .journey-title {
        font-size: 1.25rem;
    }

    .control-panel {
        top: auto;
        bottom: 0.75rem;
        left: 50%;
        transform: translateX(-50%);
        width: calc(100% - 1.5rem);
        padding: 0.625rem 0.75rem;
    }

    .control-stats {
        justify-content: center;
        gap: 1.5rem;
    }

    .control-buttons {
        flex-direction: row;
        justify-content: center;
    }

    .control-btn {
        flex: 1;
        max-width: 120px;
    }

    .map-legend {
        bottom: auto;
        top: 0.75rem;
        left: 0.75rem;
    }

    /* Start collapsed on mobile */
    .map-legend.mobile-collapsed .legend-content {
        max-height: 0;
    }

    .info-panel {
        max-height: 50vh;
        overflow-y: auto;
    }

    .location-indicator {
        top: 0.75rem;
        padding: 0.4rem 0.75rem;
        font-size: 0.8rem;
    }

    .basemap-switcher {
        bottom: auto;
        top: 0.75rem;
        right: 0.75rem;
    }

    .basemap-option {
        width: 28px;
        height: 28px;
    }
}

/* ============================================
   REDUCED MOTION
   ============================================ */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }

    .location-icon {
        animation: none;
    }
}
