/* ==========================================================================
   Expedition Command Center: Modern Tactical Road Theme
   ========================================================================== */

:root {
  --bg-main: #0B0F19;
  --bg-card: #151D2E;
  --bg-card-hover: #1E293B;
  --bg-accent: #1E293B;
  
  --text-primary: #F8FAFC;
  --text-secondary: #94A3B8;
  --text-muted: #64748B;
  
  --leg1-orange: #FF5722;
  --leg1-glow: rgba(255, 87, 34, 0.25);
  
  --leg2-blue: #0288D1;
  --leg2-glow: rgba(2, 136, 209, 0.25);
  
  --leg3-emerald: #10B981;
  --leg3-glow: rgba(16, 185, 129, 0.25);
  
  --accent-amber: #F59E0B;
  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.15);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background-color: var(--bg-main);
  color: var(--text-primary);
  line-height: 1.5;
  overflow-x: hidden;
  min-height: 100vh;
}

/* Scrollbars */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: #0b0f19;
}
::-webkit-scrollbar-thumb {
  background: #283548;
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
  background: #3b4d66;
}

/* High Contrast Header */
header {
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  background: rgba(11, 15, 25, 0.92);
  border-bottom: 1px solid var(--border-subtle);
  position: sticky;
  top: 0;
  z-index: 1000;
}

/* Tactical Tab Bar */
.tab-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-secondary);
  border-bottom: 2px solid transparent;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.tab-btn:hover {
  color: var(--text-primary);
}

.tab-btn.active {
  color: #38BDF8;
  border-bottom-color: #38BDF8;
  background: rgba(56, 189, 248, 0.05);
}

/* Big Motorcycle Touch Targets (at least 44-48px) */
.touch-btn {
  min-height: 48px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.75rem 1.25rem;
  font-weight: 700;
  letter-spacing: 0.025em;
  border-radius: 0.5rem;
  transition: transform 0.1s ease, background-color 0.2s ease, box-shadow 0.2s ease;
  cursor: pointer;
  user-select: none;
}

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

/* Card Styling */
.tactical-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 0.75rem;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.tactical-card:hover {
  border-color: var(--border-strong);
}

/* Leg Badges */
.badge-leg1 {
  background-color: var(--leg1-orange);
  color: white;
  box-shadow: 0 0 10px var(--leg1-glow);
}

.badge-leg2 {
  background-color: var(--leg2-blue);
  color: white;
  box-shadow: 0 0 10px var(--leg2-glow);
}

.badge-leg3 {
  background-color: var(--leg3-emerald);
  color: white;
  box-shadow: 0 0 10px var(--leg3-glow);
}

/* Leaflet Map overrides */
#expedition-map {
  width: 100%;
  height: 100%;
  min-height: 480px;
  background: #0b0f19;
  z-index: 1;
}

.leaflet-container {
  background: #0f172a !important;
  font-family: inherit !important;
}

.leaflet-popup-content-wrapper {
  background: #ffffff !important;
  border-radius: 8px !important;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.5) !important;
}

/* Custom Marker glow effects */
.custom-wp-marker {
  background: transparent;
  border: none;
}

/* Live Check-in Pulse Animation */
@keyframes beaconPulse {
  0% { transform: scale(0.95); opacity: 0.8; }
  50% { transform: scale(1.3); opacity: 0.2; }
  100% { transform: scale(0.95); opacity: 0.8; }
}

.beacon-pulse {
  animation: beaconPulse 2s infinite ease-in-out;
}

/* Notification Toast */
#toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  background: #1e293b;
  color: #f8fafc;
  border-left: 4px solid #38bdf8;
  padding: 12px 18px;
  border-radius: 6px;
  box-shadow: 0 10px 15px -3px rgba(0,0,0,0.4);
  font-size: 0.875rem;
  animation: slideInRight 0.3s ease;
}

@keyframes slideInRight {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* Pre-ride checklist item */
.checklist-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.checklist-item:hover {
  background: rgba(255, 255, 255, 0.06);
}

.checklist-item.checked {
  background: rgba(16, 185, 129, 0.1);
  border-color: rgba(16, 185, 129, 0.3);
  text-decoration: line-through;
  color: var(--text-muted);
}

/* Map Layer Control & Tooltips */
.map-layer-control button.active-layer {
  background-color: #2563EB !important;
  color: #FFFFFF !important;
}

.tactical-tooltip {
  background: rgba(15, 23, 42, 0.95) !important;
  color: #F8FAFC !important;
  border: 1px solid rgba(255, 255, 255, 0.15) !important;
  border-radius: 6px !important;
  padding: 6px 10px !important;
  font-family: inherit !important;
  font-size: 12px !important;
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.5) !important;
}

/* ==========================================================================
   COMMERCIAL SPLIT-SCREEN COCKPIT & MOBILE ADAPTIVE DRAWER
   ========================================================================== */

/* Split Screen Layout (Desktop >= 1024px) */
.cockpit-container {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 61px);
  overflow: hidden;
}

@media (min-width: 1024px) {
  .cockpit-split {
    display: grid;
    grid-template-columns: 460px 1fr;
    height: 100%;
    overflow: hidden;
  }
}

/* Discovery Feed Sidebar */
.discovery-sidebar {
  background: #0B0F19;
  border-right: 1px solid rgba(255, 255, 255, 0.08);
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 10;
}

.discovery-scroll-area {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
}

/* Route Cards */
.route-item-card {
  background: #151D2E;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 0.75rem;
  padding: 1rem;
  margin-bottom: 0.875rem;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  cursor: pointer;
  position: relative;
  overflow: hidden;
}

.route-item-card:hover {
  border-color: rgba(245, 158, 11, 0.5);
  background: #1A2438;
  transform: translateY(-2px);
  box-shadow: 0 10px 20px -5px rgba(0, 0, 0, 0.4);
}

.route-item-card.active {
  border-color: #F59E0B;
  box-shadow: 0 0 0 1px #F59E0B, 0 10px 25px -5px rgba(245, 158, 11, 0.2);
  background: #1C273E;
}

/* Vector SVG Icon System */
.moto-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.moto-icon img,
.moto-icon svg {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* Native Sponsor Ad Units (Monetization) */
.ad-slot-card {
  background: linear-gradient(135deg, rgba(30, 41, 59, 0.7) 0%, rgba(15, 23, 42, 0.9) 100%);
  border: 1px dashed rgba(245, 158, 11, 0.35);
  border-radius: 0.75rem;
  padding: 0.875rem;
  margin-bottom: 0.875rem;
  position: relative;
}

.ad-badge {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #94A3B8;
  background: rgba(0, 0, 0, 0.4);
  padding: 2px 6px;
  border-radius: 4px;
  display: inline-block;
  font-weight: 700;
}

/* Mobile Slide-up Route Drawer (< 1024px) */
#mobile-route-drawer {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 56px; /* above mobile nav */
  background: #0F172A;
  border-top: 1px solid rgba(245, 158, 11, 0.3);
  border-radius: 1.25rem 1.25rem 0 0;
  box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.6);
  z-index: 100;
  transform: translateY(105%);
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  max-height: 80vh;
  display: flex;
  flex-direction: column;
}

#mobile-route-drawer.open {
  transform: translateY(0);
}

.drawer-drag-handle {
  width: 36px;
  height: 4px;
  border-radius: 2px;
  background: #475569;
  margin: 10px auto 4px;
}

/* MapLibre 3D Vector Map Container */
#expedition-map {
  width: 100%;
  height: 100%;
  min-height: 380px;
  background: #080C14;
}

.maplibregl-popup-content {
  background: #151D2E !important;
  color: #F8FAFC !important;
  border: 1px solid rgba(245, 158, 11, 0.4) !important;
  border-radius: 0.75rem !important;
  padding: 12px 14px !important;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.6) !important;
}

.maplibregl-popup-anchor-top .maplibregl-popup-tip {
  border-bottom-color: #151D2E !important;
}
.maplibregl-popup-anchor-bottom .maplibregl-popup-tip {
  border-top-color: #151D2E !important;
}


/* ==========================================================================
   OFFLINE PRINT / TANK-BAG DOSSIER STYLESHEET
   Optimized for physical paper, zero toner waste, and clear sunlight legibility
   ========================================================================== */
@media print {
  /* Hide interactive non-printable elements */
  header,
  nav,
  #login-modal,
  #shared-snapshot-banner,
  #rider-broadcast-panel,
  .touch-btn,
  button,
  input,
  .no-print {
    display: none !important;
  }

  /* Reset background and text to crisp pure monochrome */
  body, html, main, .tactical-card {
    background: #FFFFFF !important;
    color: #000000 !important;
    font-size: 11pt !important;
    line-height: 1.4 !important;
  }

  /* Show only the active section or print target */
  .tab-content {
    display: block !important;
  }

  /* Optimize tactical cards for clean paper layout */
  .tactical-card {
    border: 1px solid #000000 !important;
    box-shadow: none !important;
    page-break-inside: avoid !important;
    margin-bottom: 15px !important;
    padding: 12px !important;
  }

  /* Force headers and text dark */
  h1, h2, h3, h4, strong, p, span, div {
    color: #000000 !important;
    text-shadow: none !important;
  }

  /* Print Header with timestamp & safety notice */
  body::before {
    content: "MOTORCYCLERIDEPLANNER.COM • OFFLINE FIELD RECON & TANK-BAG CUE SHEET";
    display: block;
    text-align: center;
    font-weight: 900;
    font-size: 12pt;
    border-bottom: 2px solid #000;
    padding-bottom: 6px;
    margin-bottom: 12px;
  }

  /* Pre-ride Checklist Print Box */
  .print-pre-ride-container {
    display: block !important;
    border: 2px solid #000000 !important;
    background: #FFFFFF !important;
    page-break-after: avoid !important;
    page-break-inside: avoid !important;
    margin-bottom: 20px !important;
    padding: 12px 16px !important;
  }

  /* Page breaks between major legs */
  .print-page-break {
    page-break-before: always !important;
  }
}


/* ==========================================================================
   2026-09-14 HOTFIX (Cortana) — layout breakage, not styling.
   NOTE: this fix was applied directly on VPS2 at 01:48Z and was CLOBBERED at
   ~01:55Z by a full-site push from another Mac session (preserved mtimes +
   ._AppleDouble files in the web root). It now lives in the repo so that any
   deploy from here carries it. Deploy from this repo, not from a loose folder.
   ========================================================================== */

/* [1] Desktop map rendered BLANK.
   .cockpit-container above carries the only definite height (calc(100vh - 61px)),
   but that class NEVER APPEARS in the markup. So .cockpit-split{height:100%} had
   no definite parent height and resolved to auto: .discovery-sidebar grew to fit
   all 252 route cards instead of scrolling, and #expedition-map{h-full} inherited
   43,898px. WebGL caps the canvas at 4,096px, so the viewport showed an empty
   slice of an enormous map and threw repeated "GPU stall due to ReadPixels".
   Measured after fix: 786x720. */
@media (min-width: 1024px) {
  .cockpit-split { height: 720px; }
}

/* [2] Mobile horizontal page overflow: documentElement.scrollWidth was 627px in a
   390px viewport. The header row is flex with justify-between; the right button
   cluster is flex-shrink-0 and the h1 (site name + FREE + PUBLIC VIEW badges)
   would not shrink, so the row forced the document wide. After fix: 390 = 390. */
@media (max-width: 1023px) {
  header h1 { min-width: 0; font-size: .8rem; }
  header h1 > span { display: none; }
  header > div.max-w-7xl { gap: .5rem; }
  header > div.max-w-7xl > div:first-child { min-width: 0; flex: 1 1 auto; }
}
