/* ==========================================================================
   Hanes Eisteddfod Genedlaethol Cymru - Design System & Stylesheet
   ========================================================================== */

:root {
    --bg-dark: #070a0f;
    --bg-card: rgba(13, 19, 32, 0.9);
    --bg-card-hover: rgba(20, 29, 48, 0.96);
    --border-glass: rgba(212, 175, 55, 0.3);
    --border-glass-bright: rgba(212, 175, 55, 0.7);
    
    --gold-primary: #e6c666;
    --gold-light: #fff2a3;
    --gold-dark: #b89228;
    --gold-gradient: linear-gradient(135deg, #fce07a 0%, #d4af37 50%, #997a15 100%);

    --dragon-red: #d32f2f;
    --dragon-red-glow: rgba(211, 47, 47, 0.6);

    --text-main: #f1f5f9;
    --text-muted: #94a3b8;
    --text-dim: #64748b;

    --font-heading: 'Cinzel', serif;
    --font-body: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;

    --shadow-glow: 0 0 30px rgba(212, 175, 55, 0.35);
    --shadow-card: 0 20px 40px rgba(0, 0, 0, 0.85);
    
    --radius-sm: 8px;
    --radius-md: 14px;
    --radius-lg: 20px;
    --radius-full: 9999px;

    --transition-fast: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

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

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

#app-container {
    position: relative;
    width: 100vw;
    height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Map Canvas */
#map {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    background: #090d14;
}

.leaflet-container {
    background-color: var(--bg-dark) !important;
    font-family: var(--font-body) !important;
}

.leaflet-control-zoom {
    border: none !important;
    box-shadow: var(--shadow-card) !important;
    margin-right: 20px !important;
    margin-bottom: 90px !important;
}

.leaflet-control-zoom-in, .leaflet-control-zoom-out {
    background: var(--bg-card) !important;
    color: var(--gold-primary) !important;
    border: 1px solid var(--border-glass) !important;
    backdrop-filter: blur(12px);
    width: 38px !important;
    height: 38px !important;
    line-height: 38px !important;
    border-radius: var(--radius-sm) !important;
    transition: var(--transition-fast);
}

.leaflet-control-zoom-in:hover, .leaflet-control-zoom-out:hover {
    background: var(--bg-card-hover) !important;
    color: #ffffff !important;
    border-color: var(--gold-primary) !important;
}

/* Clean Minimal Brand Badge (Top Left) */
#minimal-brand {
    position: absolute;
    top: 20px;
    left: 20px;
    z-index: 10;
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 20px;
    border-radius: var(--radius-lg);
    pointer-events: auto;
}

.glass-card {
    background: var(--bg-card);
    border: 1px solid var(--border-glass);
    backdrop-filter: blur(16px);
    box-shadow: var(--shadow-card);
}

.logo-badge {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-md);
    background: var(--gold-gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-glow);
    flex-shrink: 0;
}

.stone-circle-svg {
    width: 30px;
    height: 30px;
}

.brand-text h1 {
    font-family: var(--font-heading);
    font-size: 1.15rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    background: var(--gold-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.brand-text .subtitle {
    font-size: 0.78rem;
    color: var(--text-muted);
}

/* Map Legend / Key (Bottom Left) */
#map-legend {
    position: absolute;
    bottom: 95px;
    left: 20px;
    z-index: 10;
    padding: 10px 16px;
    border-radius: var(--radius-md);
    font-size: 0.78rem;
}

.legend-title {
    font-family: var(--font-heading);
    font-size: 0.82rem;
    color: var(--gold-primary);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.legend-items {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-main);
}

.legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
}

.dot-gold {
    background: var(--gold-primary);
    box-shadow: 0 0 8px var(--gold-primary);
}

.dot-blue {
    background: #3b82f6;
    border: 1px solid #ffffff;
}

.dot-crimson {
    background: var(--dragon-red);
    box-shadow: 0 0 10px var(--dragon-red-glow);
    border: 1.5px solid var(--gold-primary);
}

/* Map Markers */
.custom-marker {
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.3s ease;
}

.marker-inner {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #3b82f6;
    border: 2px solid #ffffff;
    box-shadow: 0 0 10px rgba(0,0,0,0.5);
    opacity: 0.75;
    transition: all 0.3s ease;
}

.custom-marker.has-images .marker-inner {
    background: var(--gold-primary);
    box-shadow: 0 0 14px var(--gold-primary);
    opacity: 1;
}

.custom-marker.current .marker-inner {
    width: 22px;
    height: 22px;
    background: var(--dragon-red);
    border: 3px solid var(--gold-primary);
    box-shadow: 0 0 25px var(--dragon-red-glow), 0 0 15px var(--gold-primary);
    animation: markerPulse 1.8s infinite;
    opacity: 1;
}

@keyframes markerPulse {
    0% { box-shadow: 0 0 0 0 rgba(211, 47, 47, 0.8), 0 0 15px var(--gold-primary); }
    70% { box-shadow: 0 0 0 18px rgba(211, 47, 47, 0), 0 0 25px var(--gold-primary); }
    100% { box-shadow: 0 0 0 0 rgba(211, 47, 47, 0), 0 0 15px var(--gold-primary); }
}

/* Tooltip */
.custom-tooltip {
    background: var(--bg-card) !important;
    border: 1px solid var(--border-glass) !important;
    color: var(--text-main) !important;
    border-radius: var(--radius-sm) !important;
    padding: 6px 12px !important;
    font-family: var(--font-body) !important;
    font-size: 13px !important;
    font-weight: 500 !important;
    box-shadow: var(--shadow-card) !important;
    backdrop-filter: blur(10px);
}

/* ==========================================================================
   ADAPTIVE POP-UP MAP PIN BILLBOARD WITH MULTI-EVENT SELECTOR & VIEWER LINK
   ========================================================================== */
.hero-pin-container {
    position: relative;
    width: 400px;
    max-width: 90vw;
    filter: drop-shadow(0 20px 30px rgba(0, 0, 0, 0.9));
    transform-origin: bottom center;
    animation: heroPinPopIn 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes heroPinPopIn {
    0% { opacity: 0; transform: scale(0.4) translateY(30px); }
    100% { opacity: 1; transform: scale(1) translateY(0); }
}

.hero-pin-card {
    background: rgba(11, 16, 26, 0.95);
    border: 2px solid var(--gold-primary);
    border-radius: var(--radius-lg);
    overflow: hidden;
    backdrop-filter: blur(20px);
    box-shadow: 0 0 35px rgba(212, 175, 55, 0.4), 0 25px 50px rgba(0,0,0,0.85);
    display: flex;
    flex-direction: column;
}

/* Pin Header */
.pin-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 18px;
    background: rgba(0, 0, 0, 0.55);
    border-bottom: 1px solid var(--border-glass);
}

.pin-title-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.pin-year-badge {
    display: inline-block;
    font-family: var(--font-heading);
    font-size: 1.3rem;
    font-weight: 900;
    color: var(--gold-primary);
    background: var(--gold-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    line-height: 1.1;
}

.pin-title {
    font-family: var(--font-heading);
    font-size: 0.95rem;
    font-weight: 700;
    color: #ffffff;
    line-height: 1.35;
    word-break: break-word;
    white-space: normal;
}

.pin-close-btn {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #ffffff;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    flex-shrink: 0;
    transition: var(--transition-fast);
}

.pin-close-btn:hover {
    background: var(--dragon-red);
    border-color: var(--dragon-red);
    color: #ffffff;
}

/* Multi-Event Selector Tabs */
.pin-multi-selector {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
    padding: 8px 18px;
    background: rgba(0, 0, 0, 0.4);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.multi-label {
    font-size: 0.75rem;
    color: var(--text-dim);
    margin-right: 4px;
}

.multi-tab {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: var(--text-muted);
    font-size: 0.75rem;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: var(--radius-full);
    cursor: pointer;
    transition: var(--transition-fast);
}

.multi-tab:hover {
    background: rgba(255, 255, 255, 0.2);
    color: #ffffff;
}

.multi-tab.active {
    background: var(--gold-gradient);
    color: #0f172a;
    border-color: var(--gold-primary);
}

/* Pin Media Wrapper */
.pin-media-wrapper {
    position: relative;
    width: 100%;
    height: 260px;
    background: #04070d;
    overflow: hidden;
    cursor: pointer;
}

.pin-media-wrapper img {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
    object-position: center !important;
    display: block !important;
    transition: transform 0.4s ease;
}

.pin-media-wrapper:hover img {
    transform: scale(1.04);
}

/* Slideshow Nav Controls */
.pin-slide-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 10;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(10, 15, 26, 0.8);
    border: 1px solid var(--border-glass-bright);
    color: var(--gold-primary);
    font-size: 15px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition-fast);
    backdrop-filter: blur(8px);
}

.pin-slide-nav:hover {
    background: var(--gold-gradient);
    color: #0f172a;
    box-shadow: 0 0 12px rgba(212, 175, 55, 0.6);
}

.pin-slide-prev { left: 10px; }
.pin-slide-next { right: 10px; }

/* Image Counter Pill Overlay */
.pin-counter-pill {
    position: absolute;
    bottom: 10px;
    right: 10px;
    background: rgba(0, 0, 0, 0.8);
    color: var(--gold-primary);
    font-size: 0.78rem;
    font-weight: 700;
    padding: 4px 10px;
    border-radius: var(--radius-full);
    border: 1px solid var(--border-glass);
    backdrop-filter: blur(6px);
}

.pin-source-tag {
    position: absolute;
    top: 10px;
    left: 10px;
    background: rgba(0, 0, 0, 0.8);
    color: #e2e8f0;
    font-size: 0.72rem;
    padding: 4px 10px;
    border-radius: var(--radius-sm);
    backdrop-filter: blur(6px);
}

/* National Library Viewer Link Button - "Gweld Rhagor o Delweddau" */
.pin-viewer-link {
    position: absolute;
    bottom: 10px;
    left: 10px;
    background: rgba(12, 18, 30, 0.88);
    border: 1px solid var(--border-glass-bright);
    color: var(--gold-primary);
    font-size: 0.76rem;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: var(--radius-full);
    text-decoration: none;
    backdrop-filter: blur(8px);
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: var(--transition-fast);
    z-index: 12;
}

.pin-viewer-link:hover {
    background: var(--gold-gradient);
    color: #0f172a;
    border-color: var(--gold-primary);
    box-shadow: 0 0 10px rgba(212, 175, 55, 0.6);
}

/* Dots Indicator */
.pin-dots {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    padding: 8px;
    background: rgba(0, 0, 0, 0.4);
}

.pin-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    transition: all 0.2s ease;
}

.pin-dot.active {
    background: var(--gold-primary);
    width: 16px;
    border-radius: var(--radius-full);
}

/* Pin Stem / Pointer */
.hero-pin-stem {
    width: 0;
    height: 0;
    margin: 0 auto;
    border-left: 16px solid transparent;
    border-right: 16px solid transparent;
    border-top: 18px solid var(--gold-primary);
    filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.8));
}

/* Fullscreen Lightbox Modal */
#lightbox-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
}

#lightbox-modal.hidden { display: none; }

.lightbox-overlay {
    position: absolute;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.92);
    backdrop-filter: blur(25px);
}

.lightbox-dialog {
    position: relative;
    z-index: 101;
    max-width: 90vw;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
}

.btn-close-lightbox {
    position: absolute;
    top: -45px;
    right: 0;
    background: none;
    border: none;
    color: #ffffff;
    font-size: 26px;
    cursor: pointer;
}

.lightbox-img-wrapper {
    max-width: 85vw;
    max-height: 70vh;
    border-radius: var(--radius-md);
    overflow: hidden;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.9);
    border: 1px solid var(--border-glass-bright);
}

.lightbox-img-wrapper img {
    max-width: 100%;
    max-height: 70vh;
    display: block;
    object-fit: contain;
}

.lightbox-caption {
    text-align: center;
    color: var(--text-main);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}

.lightbox-caption h4 {
    font-family: var(--font-heading);
    font-size: 1.1rem;
    color: var(--gold-primary);
}

.lightbox-viewer-btn {
    background: var(--gold-gradient);
    color: #0f172a;
    font-weight: 700;
    font-size: 0.85rem;
    padding: 6px 16px;
    border-radius: var(--radius-full);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-top: 4px;
    box-shadow: 0 0 15px rgba(212, 175, 55, 0.4);
    transition: var(--transition-fast);
}

.lightbox-viewer-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 0 20px rgba(212, 175, 55, 0.7);
}

/* Bottom Timeline Bar */
#timeline-bar {
    position: absolute;
    bottom: 20px;
    left: 20px;
    right: 20px;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    padding: 14px 28px;
    border-radius: var(--radius-lg);
}

.glass-bar {
    background: var(--bg-card);
    border: 1px solid var(--border-glass);
    backdrop-filter: blur(16px);
    box-shadow: var(--shadow-card);
}

.timeline-main-controls {
    display: flex;
    align-items: center;
    gap: 10px;
}

.btn-control {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: var(--text-main);
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition-fast);
}

.btn-control:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: var(--gold-primary);
    color: var(--gold-primary);
}

.btn-play {
    width: 44px;
    height: 44px;
    background: var(--gold-gradient);
    border: none;
    color: #0f172a;
    font-size: 16px;
    box-shadow: var(--shadow-glow);
}

.btn-play:hover {
    transform: scale(1.08);
}

.timeline-slider-container {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 16px;
    font-family: var(--font-heading);
    font-size: 0.9rem;
    color: var(--text-muted);
}

.slider-wrapper {
    position: relative;
    flex: 1;
    display: flex;
    align-items: center;
}

input[type="range"]#timeline-slider {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 8px;
    border-radius: var(--radius-full);
    background: rgba(255, 255, 255, 0.12);
    outline: none;
    cursor: pointer;
    z-index: 2;
}

input[type="range"]#timeline-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--gold-gradient);
    border: 2px solid #ffffff;
    box-shadow: 0 0 12px rgba(212, 175, 55, 0.7);
    cursor: pointer;
    transition: transform 0.2s;
}

input[type="range"]#timeline-slider::-webkit-slider-thumb:hover {
    transform: scale(1.2);
}

.slider-progress-fill {
    position: absolute;
    left: 0;
    height: 8px;
    border-radius: var(--radius-full);
    background: var(--gold-gradient);
    pointer-events: none;
    z-index: 1;
}

.timeline-status {
    font-size: 0.9rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 10px;
    font-variant-numeric: tabular-nums;
}

#current-year-display {
    font-family: var(--font-heading);
    font-weight: 900;
    color: var(--gold-primary);
    font-size: 1.15rem;
}
