/* ============================================================
   Where's the Host? 🍌 Banana Beltline Bar Crawl — Styles
   Warm dark theme, banana yellow accents, fun vibes
   ============================================================ */

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

body {
  font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: #1a1018;
  color: #e8dfd0;
  min-height: 100vh;
  overflow-y: auto;
  overflow-x: hidden;
}

/* ---- Layout ---- */
#app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

header {
  padding: 12px 20px;
  background: linear-gradient(135deg, #2a1f1a 0%, #1f1628 100%);
  border-bottom: 2px solid #FFD70044;
  display: flex;
  align-items: baseline;
  gap: 12px;
  flex-shrink: 0;
}

header h1 {
  font-family: 'Fredoka', 'Inter', system-ui, sans-serif;
  font-size: 1.3rem;
  font-weight: 700;
  color: #FFD700;
  letter-spacing: -0.01em;
}

header .subtitle {
  font-size: 0.78rem;
  color: #b8a080;
  font-weight: 500;
}

#sim-status {
  font-size: 0.78rem;
  font-weight: 500;
  color: #b8a080;
}

#progress-bar-container {
  height: 4px;
  background: #2a2520;
  flex-shrink: 0;
}

#progress-bar {
  height: 100%;
  background: linear-gradient(90deg, #FFD700, #FF8C00, #FFD700);
  width: 0%;
  transition: width 0.4s ease;
  box-shadow: 0 0 8px #FFD70066;
}

/* ---- Event Info Section ---- */
#event-info {
  padding: 32px 24px 24px;
  max-width: 900px;
  margin: 0 auto;
  width: 100%;
}

#event-hero {
  text-align: center;
  margin-bottom: 28px;
}

#event-hero h2 {
  font-family: 'Fredoka', 'Inter', system-ui, sans-serif;
  font-size: 2rem;
  font-weight: 700;
  color: #FFD700;
  margin-bottom: 8px;
  letter-spacing: -0.01em;
}

.event-datetime {
  font-size: 1.1rem;
  color: #e8dfd0;
  font-weight: 600;
  margin-bottom: 4px;
}

.event-route-summary {
  font-size: 0.9rem;
  color: #b8a080;
  font-weight: 500;
}

#event-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

.event-card {
  background: #1f1a28;
  border: 1px solid #3d2e20;
  border-radius: 10px;
  padding: 20px;
}

.event-card h3 {
  font-family: 'Fredoka', 'Inter', system-ui, sans-serif;
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: #FFD700;
  margin-bottom: 12px;
  font-weight: 600;
}

.event-card p {
  font-size: 0.88rem;
  color: #c4b8a8;
  line-height: 1.6;
  margin-bottom: 8px;
}

.event-card p:last-child {
  margin-bottom: 0;
}

.route-list {
  padding-left: 20px;
  list-style: disc;
}

.route-list li {
  font-size: 0.85rem;
  color: #c4b8a8;
  margin-bottom: 6px;
  line-height: 1.5;
}

.route-list li strong {
  color: #e8dfd0;
}

.route-addr {
  display: block;
  font-size: 0.75rem;
  color: #8a7a6a;
  margin-top: 1px;
}

/* ---- Simulation Layout ---- */
#main-layout {
  display: grid;
  grid-template-columns: 290px 1fr;
  flex: 1;
  min-height: 0;
}

/* ---- Controls Panel ---- */
#controls {
  background: #1f1a28;
  border-right: 1px solid #3d2e20;
  overflow-y: auto;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.control-group {
  padding: 12px 0;
  border-bottom: 1px solid #2d2420;
}

.control-group:last-child {
  border-bottom: none;
}

.control-group h3 {
  font-family: 'Fredoka', 'Inter', system-ui, sans-serif;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: #FFD700;
  margin-bottom: 10px;
  font-weight: 600;
}

.control-group label {
  display: block;
  font-size: 0.82rem;
  color: #c4b8a8;
  margin-bottom: 10px;
  cursor: default;
}

.control-group label .val {
  float: right;
  color: #e8dfd0;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  min-width: 32px;
  text-align: right;
}

input[type="range"] {
  -webkit-appearance: none;
  width: 100%;
  height: 4px;
  border-radius: 2px;
  background: #3d2e20;
  outline: none;
  margin-top: 6px;
  display: block;
  cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #FFD700;
  cursor: pointer;
  border: 2px solid #1a1018;
  box-shadow: 0 0 0 2px #FFD70033;
  transition: box-shadow 0.15s;
}

input[type="range"]::-webkit-slider-thumb:hover {
  box-shadow: 0 0 0 4px #FFD70044;
}

/* Firefox range thumb */
input[type="range"]::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #FFD700;
  cursor: pointer;
  border: 2px solid #1a1018;
}

.hint {
  font-size: 0.72rem;
  color: #8a7a6a;
  margin-top: 4px;
}

/* Host picker */
.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.82rem;
  color: #c4b8a8;
  margin-bottom: 8px;
  cursor: pointer;
}

.checkbox-row input[type="checkbox"] {
  accent-color: #FFD700;
  width: 14px;
  height: 14px;
  cursor: pointer;
}

select {
  width: 100%;
  background: #241e18;
  border: 1px solid #3d2e20;
  color: #e8dfd0;
  padding: 7px 10px;
  border-radius: 6px;
  font-size: 0.8rem;
  font-family: inherit;
  margin-top: 4px;
  cursor: pointer;
  outline: none;
  transition: border-color 0.15s;
}

select:hover { border-color: #8a7a6a; }
select:focus { border-color: #FFD700; }
select:disabled { opacity: 0.35; cursor: not-allowed; }

#host-display-text {
  color: #FFD700;
  font-weight: 600;
}

/* Run controls */
#run-controls {
  display: flex;
  gap: 8px;
  padding: 14px 0 6px;
}

.btn-primary {
  flex: 1;
  background: linear-gradient(135deg, #FFD700, #FFA500);
  color: #1a1018;
  border: none;
  padding: 10px 12px;
  border-radius: 10px;
  font-family: 'Fredoka', 'Inter', system-ui, sans-serif;
  font-size: 0.92rem;
  font-weight: 700;
  cursor: pointer;
  letter-spacing: 0.02em;
  transition: background 0.15s, transform 0.1s, box-shadow 0.15s;
  box-shadow: 0 2px 12px #FFD70044;
}

.btn-primary:hover {
  background: linear-gradient(135deg, #FFE033, #FFB833);
  box-shadow: 0 4px 20px #FFD70066;
}

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

.btn-primary:disabled {
  background: #3d2e20;
  color: #7a6a5a;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.btn-secondary {
  flex: 1;
  background: transparent;
  color: #e8dfd0;
  border: 1px solid #3d2e20;
  padding: 10px 12px;
  border-radius: 10px;
  font-family: 'Fredoka', 'Inter', system-ui, sans-serif;
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.btn-secondary:hover {
  background: #2a2018;
  border-color: #FFD70066;
  color: #FFD700;
}

/* Stats panel */
#stats-panel {
  background: #1a1018;
  border: 1px solid #3d2e20;
  border-radius: 8px;
  padding: 12px;
  margin-top: 4px;
}

#stats-panel h3 {
  font-family: 'Fredoka', 'Inter', system-ui, sans-serif;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: #FFD700;
  margin-bottom: 10px;
  font-weight: 600;
}

.stat-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.8rem;
  margin-bottom: 7px;
  color: #9a8a7a;
}

.stat-row:last-child { margin-bottom: 0; }

.stat-val {
  color: #e8dfd0;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* ---- Right Content ---- */
#content {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

#map-container {
  flex: 1;
  min-height: 300px;
  position: relative;
  border-bottom: 2px solid #FFD70022;
}

/* Leaflet overrides */
.leaflet-container {
  background: #1f1a28 !important;
  font-family: inherit !important;
}

.leaflet-control-attribution {
  background: rgba(26, 16, 24, 0.85) !important;
  color: #8a7a6a !important;
  font-size: 9px !important;
  border-radius: 4px 0 0 0 !important;
}

.leaflet-control-attribution a { color: #FFD700 !important; }

.leaflet-control-zoom a {
  background: #1f1a28 !important;
  color: #c4b8a8 !important;
  border-color: #3d2e20 !important;
}

.leaflet-control-zoom a:hover {
  background: #2a2018 !important;
  color: #FFD700 !important;
}

.bar-tooltip {
  background: #1f1a28 !important;
  border: 1px solid #FFD70044 !important;
  color: #e8dfd0 !important;
  font-size: 12px !important;
  padding: 4px 8px !important;
  border-radius: 6px !important;
  box-shadow: 0 4px 12px rgba(0,0,0,0.5) !important;
}

.bar-tooltip::before { display: none !important; }

/* ---- Bottom Panel ---- */
#bottom-panel {
  display: flex;
  gap: 12px;
  padding: 8px 16px;
  height: 240px;
  flex-shrink: 0;
  background: #1a1018;
}

#charts-col {
  flex: 1;
  min-width: 0;
  display: flex;
  gap: 8px;
}

#drinks-wrapper,
#histogram-wrapper {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

#drinks-wrapper h3,
#histogram-wrapper h3 {
  font-size: 0.72rem;
  color: #9a8a7a;
  margin-bottom: 4px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

#drinks-canvas-wrapper,
#histogram-canvas-wrapper {
  flex: 1;
  background: #241e18;
  border-radius: 8px;
  border: 1px solid #2d2420;
  padding: 8px;
  min-height: 0;
  position: relative;
}

#right-col {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 175px;
  flex-shrink: 0;
}

/* Legend */
#legend {
  background: #241e18;
  border: 1px solid #2d2420;
  border-radius: 8px;
  padding: 12px;
}

#legend h3 {
  font-family: 'Fredoka', 'Inter', system-ui, sans-serif;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: #FFD700;
  margin-bottom: 10px;
  font-weight: 600;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.78rem;
  color: #c4b8a8;
  margin-bottom: 7px;
}

.legend-item:last-child { margin-bottom: 0; }

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  border: 1.5px solid rgba(255,255,255,0.15);
}

.dot-waiting   { background: #8B7355; }
.dot-searching { background: #FF8C00; }
.dot-tipped    { background: #FFD700; }
.dot-found     { background: #32CD32; }
.dot-host      { background: #FF4444; border-radius: 3px; }

/* ---- Collapsible Sim Settings ---- */
#sim-settings {
  margin-top: 4px;
}

#sim-settings > summary {
  font-family: 'Fredoka', 'Inter', system-ui, sans-serif;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: #8a7a6a;
  cursor: pointer;
  user-select: none;
  font-weight: 600;
  outline: none;
  list-style: none;
  padding: 10px 0;
  border-bottom: 1px solid #2d2420;
  transition: color 0.15s;
}

#sim-settings > summary:hover {
  color: #FFD700;
}

#sim-settings > summary::-webkit-details-marker { display: none; }

#sim-settings > summary::before {
  content: '▸ ';
  font-size: 0.6rem;
}

#sim-settings[open] > summary::before { content: '▾ '; }

#sim-settings[open] > summary {
  margin-bottom: 4px;
}

/* Assumptions list inside settings */
.assumptions-list {
  padding-left: 18px;
  margin-top: 4px;
}

.assumptions-list li {
  font-size: 0.72rem;
  color: #8a7a6a;
  margin-bottom: 5px;
  line-height: 1.5;
}

/* ---- Host Pulse Animation ---- */
.host-pulse-wrapper {
  position: relative;
  width: 40px;
  height: 40px;
}

.host-pulse-ring {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 2.5px solid #FF4444;
  animation: pulse-ring 1.6s ease-out infinite;
}

.host-pulse-dot {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #FF4444;
  box-shadow: 0 0 10px #FF444488, 0 0 20px #FF444433;
  border: 2px solid #FFD700;
  display: flex;
  align-items: center;
  justify-content: center;
}

@keyframes pulse-ring {
  0%   { transform: translate(-50%, -50%) scale(0.4); opacity: 1; }
  80%  { opacity: 0.4; }
  100% { transform: translate(-50%, -50%) scale(1.9); opacity: 0; }
}

/* ---- Celebration state ---- */
.sim-complete #progress-bar {
  background: linear-gradient(90deg, #FFD700, #32CD32, #FFD700);
  box-shadow: 0 0 12px #32CD3266;
}

/* ---- Scrollbar ---- */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #3d2e20; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #5a4a3a; }

/* ============================================================
   Mobile Responsive — stack everything vertically
   ============================================================ */
@media (max-width: 768px) {

  /* Header: wrap and shrink */
  header {
    flex-wrap: wrap;
    padding: 10px 14px;
    gap: 4px 10px;
  }

  header h1 {
    font-size: 1.1rem;
    width: 100%;
  }

  header .subtitle {
    font-size: 0.7rem;
  }

  /* Event info: stack cards vertically */
  #event-info {
    padding: 24px 14px 20px;
  }

  #event-hero h2 {
    font-size: 1.5rem;
  }

  .event-datetime {
    font-size: 1rem;
  }

  .event-route-summary {
    font-size: 0.82rem;
  }

  #event-cards {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .event-card {
    padding: 16px;
  }

  /* Main layout: single column, natural flow */
  #main-layout {
    grid-template-columns: 1fr;
  }

  /* Controls: horizontal strip instead of tall sidebar */
  #controls {
    border-right: none;
    border-bottom: 1px solid #3d2e20;
    padding: 10px 14px;
    max-height: none;
    overflow-y: visible;
  }

  /* Run buttons: sticky at top of controls for easy access */
  #run-controls {
    padding: 8px 0 4px;
  }

  .btn-primary, .btn-secondary {
    padding: 12px 14px;
    font-size: 1rem;
  }

  /* Larger touch targets for sliders */
  input[type="range"] {
    height: 6px;
    margin-top: 8px;
  }

  input[type="range"]::-webkit-slider-thumb {
    width: 20px;
    height: 20px;
  }

  input[type="range"]::-moz-range-thumb {
    width: 20px;
    height: 20px;
  }

  /* Content: no min-height constraint on mobile */
  #content {
    min-height: auto;
  }

  /* Map: fixed reasonable height */
  #map-container {
    min-height: 280px;
    height: 45vh;
    flex: none;
  }

  /* Bottom panel: vertical stack */
  #bottom-panel {
    flex-direction: column;
    height: auto;
    padding: 10px 14px;
    gap: 10px;
  }

  /* Charts: stack vertically */
  #charts-col {
    flex-direction: column;
    gap: 10px;
  }

  #drinks-wrapper,
  #histogram-wrapper {
    min-height: 160px;
  }

  #drinks-canvas-wrapper,
  #histogram-canvas-wrapper {
    min-height: 140px;
  }

  /* Right col (legend): full width */
  #right-col {
    width: 100%;
    flex-direction: row;
    gap: 10px;
  }

  #legend {
    flex: 1;
  }

  /* Legend items: compact horizontal flow */
  .legend-item {
    font-size: 0.72rem;
    margin-bottom: 5px;
  }

  /* Stats panel: 2-column grid */
  .stat-row {
    font-size: 0.78rem;
  }

  /* Select dropdown: larger for touch */
  select {
    padding: 10px 12px;
    font-size: 0.85rem;
  }
}

/* Extra small screens (< 400px) */
@media (max-width: 400px) {
  header h1 {
    font-size: 0.95rem;
  }

  #sim-status {
    font-size: 0.68rem;
  }

  header .subtitle {
    font-size: 0.62rem;
  }

  #event-hero h2 {
    font-size: 1.25rem;
  }

  .event-datetime {
    font-size: 0.9rem;
  }

  #right-col {
    flex-direction: column;
  }
}
