/* ==========================================================================
   Trunk-or-Treat Event Map Stylesheet
   Mobile-First, Accessible, Festive Halloween Theme
   ========================================================================== */

:root {
  --bg-primary: #0b0e14;
  --bg-secondary: #141923;
  --bg-tertiary: #1c2331;
  --bg-card: #181f2c;
  --bg-card-hover: #222b3d;
  
  --text-primary: #f8fafc;
  --text-secondary: #cbd5e1;
  --text-muted: #94a3b8;
  
  --color-pumpkin: #ff6f00;
  --color-pumpkin-hover: #ff851a;
  --color-pumpkin-glow: rgba(255, 111, 0, 0.4);
  --color-purple: #8b5cf6;
  --color-purple-hover: #a78bfa;
  --color-green: #10b981;
  --color-red: #ef4444;
  --color-amber: #f59e0b;
  
  --border-subtle: rgba(255, 255, 255, 0.1);
  --border-focus: #ff6f00;
  
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --radius-full: 9999px;
  
  --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.5);
  --shadow-pumpkin: 0 0 20px rgba(255, 111, 0, 0.25);
  
  --font-main: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-spooky: 'Creepster', cursive, sans-serif;
  
  --touch-target-min: 44px;
}

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

html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-main);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background-image: 
    radial-gradient(circle at 15% 10%, rgba(139, 92, 246, 0.08) 0%, transparent 40%),
    radial-gradient(circle at 85% 30%, rgba(255, 111, 0, 0.08) 0%, transparent 40%),
    radial-gradient(circle at 50% 80%, rgba(255, 111, 0, 0.05) 0%, transparent 50%);
  background-attachment: fixed;
}

/* Accessibility: Skip Link */
.skip-link {
  position: absolute;
  top: -60px;
  left: 1rem;
  background: var(--color-pumpkin);
  color: #000;
  padding: 0.75rem 1.25rem;
  font-weight: 700;
  border-radius: var(--radius-sm);
  z-index: 99999;
  text-decoration: none;
  transition: top 0.2s ease;
}

.skip-link:focus {
  top: 1rem;
}

/* Focus Styles */
:focus-visible {
  outline: 3px solid var(--border-focus);
  outline-offset: 2px;
}

/* --------------------------------------------------------------------------
   Header
   -------------------------------------------------------------------------- */
.site-header {
  background: linear-gradient(180deg, rgba(20, 25, 35, 0.95) 0%, rgba(11, 14, 20, 0.9) 100%);
  border-bottom: 1px solid var(--border-subtle);
  padding: 1.75rem 1rem 1.25rem;
  text-align: center;
  position: relative;
}

.header-container {
  max-width: 960px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.header-logo-container {
  margin: 0 0 1rem;
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
}

.header-logo {
  display: block;
  max-width: 100%;
  width: 500px;
  height: auto;
  border-radius: var(--radius-lg);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.5), 0 0 25px rgba(255, 111, 0, 0.18);
  border: 1px solid rgba(255, 111, 0, 0.25);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.header-logo:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 36px rgba(0, 0, 0, 0.6), 0 0 30px rgba(255, 111, 0, 0.28);
}

.header-badge {
  display: inline-block;
  background: rgba(255, 111, 0, 0.15);
  color: var(--color-pumpkin);
  border: 1px solid rgba(255, 111, 0, 0.3);
  font-size: 0.8125rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 0.25rem 0.75rem;
  border-radius: var(--radius-full);
  margin-bottom: 0.75rem;
}

.header-title {
  font-size: 1.85rem;
  font-weight: 800;
  color: #ffffff;
  letter-spacing: -0.02em;
  line-height: 1.2;
  margin-bottom: 0.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.header-icon {
  font-size: 1.75rem;
}

.header-subtitle {
  color: var(--text-secondary);
  font-size: 1.05rem;
  max-width: 580px;
  margin-bottom: 1rem;
}

.header-summary {
  margin-top: 0.25rem;
}

.summary-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-subtle);
  padding: 0.4rem 1rem;
  border-radius: var(--radius-full);
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-secondary);
  box-shadow: var(--shadow-sm);
}

.summary-indicator {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--color-green);
  box-shadow: 0 0 8px var(--color-green);
  animation: pulse-slow 2s infinite ease-in-out;
}

@keyframes pulse-slow {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(0.85); }
}

/* --------------------------------------------------------------------------
   Layout & Content
   -------------------------------------------------------------------------- */
.main-content {
  flex: 1;
  padding: 1rem;
  max-width: 1140px;
  width: 100%;
  margin: 0 auto;
}

.content-wrapper {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

/* --------------------------------------------------------------------------
   Filters Section
   -------------------------------------------------------------------------- */
.filters-section {
  width: 100%;
}

.filter-container {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.filter-label {
  font-size: 0.8125rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.filter-group {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
  background: var(--bg-secondary);
  padding: 0.375rem;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-subtle);
}

.filter-btn {
  background: transparent;
  color: var(--text-secondary);
  border: none;
  border-radius: var(--radius-md);
  min-height: var(--touch-target-min);
  padding: 0.6rem 0.75rem;
  font-size: 0.9375rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.filter-btn:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
}

.filter-btn.active {
  background: var(--color-pumpkin);
  color: #0b0e14;
  font-weight: 800;
  box-shadow: 0 2px 10px rgba(255, 111, 0, 0.35);
}

.filter-btn .btn-icon {
  font-size: 1rem;
}

/* --------------------------------------------------------------------------
   Map Section
   -------------------------------------------------------------------------- */
.map-section {
  width: 100%;
}

.map-wrapper {
  position: relative;
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-md);
  background: var(--bg-secondary);
}

/* Mobile-first: approx 50-60% of viewport */
.map-container {
  width: 100%;
  height: 55vh;
  min-height: 340px;
  max-height: 540px;
  z-index: 1;
  position: relative;
  outline: none;
}

.map-loading {
  position: absolute;
  inset: 0;
  background: var(--bg-secondary);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  z-index: 10;
  color: var(--text-secondary);
  font-weight: 600;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 4px solid rgba(255, 111, 0, 0.2);
  border-top-color: var(--color-pumpkin);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* Map Legend */
.map-legend {
  position: absolute;
  bottom: 12px;
  right: 12px;
  background: rgba(11, 14, 20, 0.92);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  padding: 0.5rem 0.85rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  z-index: 500;
  box-shadow: var(--shadow-md);
}

.legend-title {
  font-size: 0.6875rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 0.35rem;
}

.legend-items {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.legend-marker {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  border: 1.5px solid #ffffff;
  flex-shrink: 0;
}

.legend-marker.marker-today {
  background: linear-gradient(135deg, #ff7a00, #ff3d00);
  box-shadow: 0 0 6px rgba(255, 111, 0, 0.7);
}

.legend-marker.marker-upcoming {
  background: linear-gradient(135deg, #8b5cf6, #6d28d9);
  box-shadow: 0 0 4px rgba(139, 92, 246, 0.4);
}

/* --------------------------------------------------------------------------
   Leaflet Custom Marker & Popup Overrides
   -------------------------------------------------------------------------- */
.custom-leaflet-marker {
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  cursor: pointer;
  filter: drop-shadow(0 3px 6px rgba(0,0,0,0.5));
  transition: transform 0.2s ease;
}

.custom-leaflet-marker:hover {
  transform: scale(1.15);
}

.marker-inner {
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  width: 36px;
  height: 36px;
  font-size: 1.2rem;
  background: var(--bg-secondary);
  border: 2px solid #ffffff;
}

.marker-inner.marker-today {
  width: 44px;
  height: 44px;
  font-size: 1.5rem;
  background: linear-gradient(135deg, #ff7a00, #ff3d00);
  border: 3px solid #ffffff;
  box-shadow: 0 0 16px rgba(255, 111, 0, 0.8);
  animation: pulse-ring 2s infinite ease-out;
}

.marker-inner.marker-upcoming {
  width: 36px;
  height: 36px;
  font-size: 1.25rem;
  background: linear-gradient(135deg, #8b5cf6, #6d28d9);
  border: 2px solid #ffffff;
}

@keyframes pulse-ring {
  0% { box-shadow: 0 0 0 0 rgba(255, 111, 0, 0.7); }
  70% { box-shadow: 0 0 0 14px rgba(255, 111, 0, 0); }
  100% { box-shadow: 0 0 0 0 rgba(255, 111, 0, 0); }
}

/* Popup Container */
.leaflet-popup-content-wrapper {
  background: var(--bg-card) !important;
  color: var(--text-primary) !important;
  border-radius: var(--radius-md) !important;
  border: 1px solid var(--border-subtle) !important;
  box-shadow: var(--shadow-lg) !important;
  padding: 0 !important;
  overflow: hidden;
}

.leaflet-popup-content {
  margin: 0 !important;
  line-height: 1.5 !important;
  font-family: var(--font-main) !important;
  min-width: 250px;
  max-width: 300px;
}

.leaflet-popup-tip {
  background: var(--bg-card) !important;
  border: 1px solid var(--border-subtle) !important;
}

.leaflet-container a.leaflet-popup-close-button {
  color: var(--text-muted) !important;
  top: 10px !important;
  right: 10px !important;
  font-size: 18px !important;
  padding: 4px !important;
  width: 28px !important;
  height: 28px !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  border-radius: 50% !important;
}

.leaflet-container a.leaflet-popup-close-button:hover {
  color: #fff !important;
  background: rgba(255, 255, 255, 0.1) !important;
}

/* Popup Content Card */
.popup-card {
  padding: 1.15rem;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.popup-header {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.popup-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: #ffffff;
  line-height: 1.3;
}

.popup-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-bottom: 0.25rem;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.2rem 0.5rem;
  border-radius: var(--radius-sm);
}

.badge-now {
  background: #dc2626;
  color: #ffffff;
  animation: pulse-red 1.5s infinite;
}

@keyframes pulse-red {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.75; }
}

.badge-today {
  background: var(--color-pumpkin);
  color: #0b0e14;
}

.badge-featured {
  background: #f59e0b;
  color: #0b0e14;
}

.popup-meta {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.meta-row {
  display: flex;
  align-items: flex-start;
  gap: 0.45rem;
}

.meta-icon {
  font-size: 0.95rem;
  flex-shrink: 0;
  margin-top: 0.1rem;
}

.popup-description {
  font-size: 0.84rem;
  color: var(--text-muted);
  line-height: 1.4;
  border-top: 1px solid var(--border-subtle);
  padding-top: 0.6rem;
}

.popup-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
  margin-top: 0.25rem;
}

.btn-popup {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.3rem;
  padding: 0.55rem 0.65rem;
  min-height: 38px;
  font-size: 0.8125rem;
  font-weight: 700;
  text-decoration: none;
  border-radius: var(--radius-sm);
  text-align: center;
  transition: all 0.2s ease;
  border: none;
  cursor: pointer;
}

.btn-popup-directions {
  background: var(--color-pumpkin);
  color: #0b0e14;
}

.btn-popup-directions:hover {
  background: var(--color-pumpkin-hover);
}

.btn-popup-details {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border: 1px solid var(--border-subtle);
}

.btn-popup-details:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

/* --------------------------------------------------------------------------
   Events List Section
   -------------------------------------------------------------------------- */
.events-section {
  width: 100%;
  margin-top: 0.5rem;
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.section-title {
  font-size: 1.35rem;
  font-weight: 800;
  color: #ffffff;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.active-filter-indicator {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--bg-secondary);
  padding: 0.25rem 0.75rem;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-subtle);
}

.events-grid {
  display: flex;
  flex-direction: column;
  gap: 1.75rem;
}

.event-date-group {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.date-group-heading {
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--color-pumpkin);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding-bottom: 0.35rem;
  border-bottom: 2px solid rgba(255, 111, 0, 0.3);
}

.date-cards-container {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
}

/* Event Card */
.event-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  position: relative;
  transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.event-card:hover {
  transform: translateY(-2px);
  border-color: rgba(255, 111, 0, 0.4);
  box-shadow: var(--shadow-md);
}

.event-card.card-today {
  border-color: rgba(255, 111, 0, 0.6);
  background: linear-gradient(180deg, rgba(255, 111, 0, 0.05) 0%, var(--bg-card) 40%);
}

.card-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.75rem;
}

.card-title-group {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.card-title {
  font-size: 1.18rem;
  font-weight: 800;
  color: #ffffff;
  line-height: 1.3;
}

.card-organizer {
  font-size: 0.8125rem;
  color: var(--text-muted);
  font-weight: 500;
}

.card-badges {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.25rem;
  flex-shrink: 0;
}

.card-meta-list {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  background: rgba(0, 0, 0, 0.2);
  padding: 0.75rem 0.85rem;
  border-radius: var(--radius-md);
  border: 1px solid rgba(255, 255, 255, 0.05);
  font-size: 0.9rem;
}

.card-meta-item {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  color: var(--text-secondary);
}

.meta-icon-wrapper {
  color: var(--color-pumpkin);
  font-size: 0.95rem;
  margin-top: 0.1rem;
}

.meta-highlight {
  font-weight: 700;
  color: #ffffff;
}

.card-description {
  font-size: 0.875rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

.card-actions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 0.65rem;
  margin-top: 0.25rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border-subtle);
}

.btn-card {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  min-height: var(--touch-target-min);
  padding: 0.6rem 1rem;
  font-size: 0.875rem;
  font-weight: 700;
  font-family: inherit;
  border-radius: var(--radius-md);
  text-decoration: none;
  cursor: pointer;
  transition: all 0.2s ease;
  border: none;
  text-align: center;
}

.btn-map-view {
  background: var(--bg-tertiary);
  color: #ffffff;
  border: 1px solid var(--border-subtle);
}

.btn-map-view:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.25);
}

.btn-directions {
  background: var(--color-pumpkin);
  color: #0b0e14;
}

.btn-directions:hover {
  background: var(--color-pumpkin-hover);
}

.btn-details {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border-subtle);
}

.btn-details:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #ffffff;
}

/* --------------------------------------------------------------------------
   Empty State
   -------------------------------------------------------------------------- */
.empty-state {
  text-align: center;
  padding: 3rem 1.5rem;
  background: var(--bg-card);
  border: 1px dashed var(--border-subtle);
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
}

.empty-icon {
  font-size: 3rem;
  margin-bottom: 0.25rem;
}

.empty-title {
  font-size: 1.3rem;
  font-weight: 800;
  color: #ffffff;
}

.empty-description {
  color: var(--text-secondary);
  max-width: 440px;
  font-size: 0.95rem;
  line-height: 1.5;
}

.reset-filter-btn {
  margin-top: 0.5rem;
  background: var(--color-pumpkin);
  color: #0b0e14;
  border: none;
  padding: 0.75rem 1.5rem;
  border-radius: var(--radius-md);
  font-weight: 700;
  font-size: 0.9375rem;
  font-family: inherit;
  cursor: pointer;
  min-height: var(--touch-target-min);
  transition: background 0.2s ease;
}

.reset-filter-btn:hover {
  background: var(--color-pumpkin-hover);
}

/* --------------------------------------------------------------------------
   Footer
   -------------------------------------------------------------------------- */
.site-footer {
  margin-top: 3rem;
  background: var(--bg-secondary);
  border-top: 1px solid var(--border-subtle);
  padding: 2rem 1rem;
  text-align: center;
}

.footer-container {
  max-width: 800px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
}

.footer-brand {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 1.05rem;
  color: #ffffff;
}

.footer-text {
  font-size: 0.875rem;
  color: var(--text-muted);
  max-width: 500px;
}

.footer-links {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.875rem;
  flex-wrap: wrap;
  justify-content: center;
}

.footer-link {
  color: var(--text-secondary);
  text-decoration: none;
  font-weight: 600;
  transition: color 0.2s ease;
}

.footer-link:hover {
  color: var(--color-pumpkin);
}

.footer-sep {
  color: var(--text-muted);
}

.footer-attribution {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.5rem;
}

.footer-attribution a {
  color: var(--text-secondary);
  text-decoration: underline;
}

.footer-attribution a:hover {
  color: var(--color-pumpkin);
}

/* --------------------------------------------------------------------------
   Responsive Media Queries (Desktop & Tablet)
   -------------------------------------------------------------------------- */
@media (min-width: 640px) {
  .header-title {
    font-size: 2.25rem;
  }
  
  .filter-group {
    display: inline-flex;
    align-self: flex-start;
  }
  
  .date-cards-container {
    grid-template-columns: repeat(2, 1fr);
  }
  
  .map-container {
    height: 480px;
  }
}

@media (min-width: 1024px) {
  .header-title {
    font-size: 2.5rem;
  }

  .content-wrapper {
    gap: 2rem;
  }
  
  .map-container {
    height: 520px;
  }
}
