/* Creosote Stink Predictor - Styles */

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #f5f5f5;
  color: #333;
  min-height: 100vh;
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

/* ===== Mobile header (hidden on desktop) ===== */
.header-mobile {
  display: none; /* shown only at mobile breakpoint */
  background: #1a237e;
  color: #fff;
  padding: 8px 14px;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.header-mobile-title {
  font-size: 1rem;
  font-weight: 700;
}

.header-mobile-right a {
  color: #fff;
  opacity: 0.8;
  font-size: 0.8rem;
  text-decoration: underline;
}

/* ===== Main Layout — sidebar left, map right ===== */
.main {
  display: flex;
  height: 100vh;
  min-height: 400px;
}

/* ===== Left Sidebar ===== */
.sidebar {
  width: 300px;
  flex-shrink: 0;
  background: #fff;
  overflow-y: auto;
  border-right: 1px solid #e0e0e0;
  padding: 16px;
  display: flex;
  flex-direction: column;
}

.sidebar-brand {
  padding-bottom: 14px;
  margin-bottom: 12px;
  border-bottom: 2px solid #1a237e;
}

.sidebar-brand h1 {
  font-size: 1.15rem;
  font-weight: 700;
  color: #1a237e;
  line-height: 1.2;
}

.sidebar-brand-sub {
  font-size: 0.8rem;
  color: #666;
  margin-top: 2px;
}

.sidebar-about {
  font-size: 0.75rem;
  color: #1a237e;
  text-decoration: none;
  opacity: 0.7;
}

.sidebar-about:hover {
  opacity: 1;
  text-decoration: underline;
}

.sidebar h2 {
  font-size: 0.9rem;
  font-weight: 600;
  color: #1a237e;
  margin-bottom: 8px;
  padding-bottom: 4px;
  border-bottom: 2px solid #e8eaf6;
}

.sidebar-footer {
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px solid #eee;
  font-size: 0.7rem;
  color: #999;
  line-height: 1.5;
}

.sidebar-footer a {
  color: #1a237e;
  text-decoration: none;
}

/* ===== Map + Timeline column ===== */
.map-timeline-column {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.map-container {
  flex: 1;
  min-width: 0;
  position: relative;
}

#map {
  width: 100%;
  height: 100%;
}

.plant-marker {
  background: none;
  border: none;
}

.plant-icon {
  font-size: 28px;
  filter: drop-shadow(1px 1px 2px rgba(0,0,0,0.5));
  cursor: pointer;
}

/* ===== Risk Banner — overlaid on map ===== */
.risk-banner {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  padding: 0;
  background: rgba(232, 245, 233, 0.75);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition: background 0.3s ease;
}

.risk-level {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 4px;
}

.risk-label {
  font-size: 1.5rem;
  font-weight: 700;
}

.risk-score {
  font-size: 1.1rem;
  opacity: 0.8;
}

.risk-detail {
  font-size: 0.85rem;
  color: #555;
  margin-bottom: 4px;
}

.risk-description {
  font-size: 0.9rem;
  font-weight: 500;
}

/* ===== Conditions ===== */
.condition-row {
  display: flex;
  justify-content: space-between;
  padding: 5px 0;
  font-size: 0.85rem;
  border-bottom: 1px solid #f0f0f0;
}

.condition-label {
  color: #666;
}

.condition-value {
  font-weight: 500;
}

.inversion-likely {
  color: #d32f2f;
  font-weight: 700;
}

.inversion-possible {
  color: #f57c00;
  font-weight: 600;
}

.inversion-unlikely {
  color: #388e3c;
}

/* ===== Wind Compass ===== */
.compass-container {
  display: flex;
  justify-content: center;
  margin: 10px 0;
}

.compass-svg {
  width: 120px;
  height: 120px;
}

.compass-label {
  font-size: 12px;
  fill: #666;
  font-weight: 600;
}

.compass-speed {
  font-size: 20px;
  font-weight: 700;
  fill: #333;
}

.compass-unit {
  font-size: 10px;
  fill: #999;
}

/* ===== Plant Cards ===== */
.plant-card {
  background: #fafafa;
  border: 1px solid #e0e0e0;
  border-radius: 6px;
  padding: 10px;
  margin-bottom: 10px;
}

.plant-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
}

.plant-card-name {
  font-weight: 600;
  font-size: 0.85rem;
}

.plant-card-risk {
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 10px;
  text-transform: uppercase;
}

.plant-card-detail {
  font-size: 0.8rem;
  color: #666;
  padding: 2px 0;
}

.plant-card-weather-note {
  font-size: 0.78rem;
  color: #444;
  background: #f5f0e8;
  border-left: 3px solid #ff9800;
  padding: 6px 8px;
  margin-top: 6px;
  line-height: 1.4;
  border-radius: 0 4px 4px 0;
}

/* ===== Timeline ===== */
.timeline-container {
  flex: none;
  background: #fff;
  border-top: 1px solid #e0e0e0;
  padding: 8px 0;
}

.timeline-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px 6px;
}

.timeline-container h3 {
  font-size: 0.8rem;
  color: #666;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin: 0;
}

.scoring-mode-select {
  font-size: 0.75rem;
  padding: 3px 6px;
  border: 1px solid #ccc;
  border-radius: 4px;
  background: #f9f9f9;
  color: #444;
  cursor: pointer;
}

#timeline {
  display: flex;
  overflow-x: auto;
  padding: 0 12px 8px;
  gap: 2px;
  scrollbar-width: thin;
}

.timeline-cell {
  flex-shrink: 0;
  width: 52px;
  padding: 4px 2px;
  text-align: center;
  cursor: pointer;
  border-radius: 6px;
  transition: background 0.15s;
  border: 2px solid transparent;
  position: relative;
}

.timeline-cell:hover {
  background: #f0f0f0;
}

.timeline-cell.selected {
  background: #e8eaf6;
  border-color: #1a237e;
}

.timeline-day {
  font-size: 0.65rem;
  font-weight: 700;
  color: #1a237e;
  height: 14px;
}

.timeline-hour {
  font-size: 0.7rem;
  color: #666;
}

.timeline-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  margin: 4px auto;
}

.timeline-wind {
  display: inline-block;
  font-size: 0.8rem;
  color: #999;
  line-height: 1;
}

.timeline-temp {
  font-size: 0.7rem;
  color: #888;
}

/* ===== Loading / Error ===== */
.loading {
  text-align: center;
  padding: 20px;
  color: #666;
  font-style: italic;
}

.error {
  text-align: center;
  padding: 20px;
  color: #d32f2f;
}

/* ===== About Modal ===== */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 10000;
  justify-content: center;
  align-items: center;
}

.modal-overlay.active {
  display: flex;
}

.modal {
  background: #fff;
  border-radius: 8px;
  padding: 24px;
  max-width: 600px;
  max-height: 80vh;
  overflow-y: auto;
  margin: 20px;
}

.modal h2 {
  margin-bottom: 12px;
  color: #1a237e;
}

.modal p {
  margin-bottom: 10px;
  font-size: 0.9rem;
  line-height: 1.5;
}

.modal .close-btn {
  display: inline-block;
  margin-top: 12px;
  padding: 8px 20px;
  background: #1a237e;
  color: #fff;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.9rem;
}

/* ============================================
   Responsive — Tablet (sidebar on top)
   ============================================ */
@media (max-width: 768px) {
  .header-mobile {
    display: flex;
  }

  .sidebar-brand {
    display: none;
  }

  .main {
    flex-direction: column;
    height: auto;
  }

  .sidebar {
    width: 100%;
    border-right: none;
    border-bottom: 1px solid #e0e0e0;
    order: 2; /* sidebar goes below map+timeline on mobile */
  }

  .map-timeline-column {
    flex: none;
    order: 1;
  }

  .map-container {
    flex: none;
    height: 55vh;
    min-height: 300px;
  }

  .sidebar-footer {
    text-align: center;
    padding-top: 10px;
  }
}

/* ============================================
   Responsive — Phone
   ============================================ */
@media (max-width: 480px) {
  .header-mobile {
    padding: 6px 12px;
  }

  .header-mobile-title {
    font-size: 0.9rem;
  }

  .risk-banner {
    padding: 0;
  }

  .risk-gauge {
    gap: 8px;
    padding: 6px 10px;
  }

  .risk-gauge-meter {
    width: 100px;
  }

  .risk-gauge-details {
    font-size: 0.72rem;
  }

  .risk-gauge-score {
    font-size: 22px;
  }

  .risk-gauge-label {
    font-size: 10px;
  }

  .compass-svg-animated {
    width: 100px;
    height: 100px;
  }

  .map-container {
    height: 50vh;
    min-height: 250px;
  }

  .sidebar {
    padding: 12px;
  }

  .sidebar h2 {
    font-size: 0.85rem;
    margin-bottom: 6px;
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
  }

  .compass-container {
    margin: 6px 0;
  }

  .plant-card {
    padding: 8px;
    margin-bottom: 8px;
  }

  .plant-card-name {
    font-size: 0.8rem;
  }

  .plant-card-detail {
    font-size: 0.75rem;
    padding: 1px 0;
  }

  .plant-card-weather-note {
    font-size: 0.73rem;
    padding: 5px 6px;
    margin-top: 4px;
  }

  .condition-row {
    font-size: 0.8rem;
    padding: 4px 0;
  }

  .timeline-container {
    padding: 6px 0;
  }

  .timeline-container h3 {
    font-size: 0.75rem;
    padding: 0 12px 4px;
  }

  #timeline,
  .timeline-enhanced {
    padding: 0 8px 6px;
    -webkit-overflow-scrolling: touch;
    scroll-snap-type: x proximity;
  }

  .timeline-cell {
    width: 48px;
    min-height: 44px;
    scroll-snap-align: start;
  }

  .timeline-hour {
    font-size: 0.65rem;
  }

  .timeline-dot {
    width: 12px;
    height: 12px;
  }

  .timeline-temp {
    font-size: 0.65rem;
  }

  .modal {
    margin: 8px;
    padding: 16px;
    max-height: 90vh;
    border-radius: 6px;
  }

  .modal h2 {
    font-size: 1.1rem;
  }

  .modal p {
    font-size: 0.82rem;
  }

  .modal .close-btn {
    width: 100%;
    padding: 12px;
    font-size: 1rem;
  }

  .leaflet-popup-content {
    font-size: 0.8rem;
    max-width: 280px !important;
    margin: 8px 12px !important;
  }
}

/* ============================================
   Landscape phone
   ============================================ */
@media (max-width: 768px) and (orientation: landscape) {
  .main {
    flex-direction: row;
    height: calc(100vh - 36px);
  }

  .map-timeline-column {
    order: 1;
  }

  .map-container {
    height: auto;
    flex: 1;
    max-height: none;
  }

  .sidebar {
    width: 260px;
    order: 2;
    border-right: none;
    border-left: 1px solid #e0e0e0;
    border-bottom: none;
    overflow-y: auto;
  }
}

/* ============================================
   Dark mode
   ============================================ */
@media (prefers-color-scheme: dark) {
  body {
    background: #121212;
    color: #e0e0e0;
  }

  .header-mobile {
    background: #0d1147;
  }

  .sidebar {
    background: #1e1e1e;
    border-color: #333;
  }

  .sidebar-brand h1 {
    color: #8c9eff;
  }

  .sidebar-brand-sub {
    color: #999;
  }

  .sidebar-brand {
    border-bottom-color: #5c6bc0;
  }

  .sidebar-about {
    color: #8c9eff;
  }

  .sidebar h2 {
    color: #8c9eff;
    border-bottom-color: #333;
  }

  .sidebar-footer {
    border-top-color: #333;
    color: #666;
  }

  .sidebar-footer a {
    color: #8c9eff;
  }

  .plant-card {
    background: #262626;
    border-color: #444;
  }

  .plant-card-detail {
    color: #aaa;
  }

  .plant-card-weather-note {
    background: #2a2518;
    color: #ccc;
  }

  .condition-row {
    border-bottom-color: #333;
  }

  .condition-label {
    color: #aaa;
  }

  .timeline-container {
    background: #1e1e1e;
    border-color: #333;
  }

  .timeline-container h3 {
    color: #aaa;
  }

  .timeline-cell:hover {
    background: #333;
  }

  .timeline-cell.selected {
    background: #1a237e;
    border-color: #5c6bc0;
  }

  .timeline-day {
    color: #8c9eff;
  }

  .timeline-hour {
    color: #aaa;
  }

  .timeline-temp {
    color: #999;
  }

  .risk-banner {
    background: rgba(27, 46, 27, 0.75);
  }

  .risk-detail {
    color: #bbb;
  }

  .risk-gauge-time {
    color: #e0e0e0;
  }

  .risk-gauge-details {
    color: #bbb;
  }

  .modal {
    background: #1e1e1e;
    color: #e0e0e0;
  }

  .modal h2 {
    color: #8c9eff;
  }

  .risk-gauge-score {
    fill: currentColor;
  }

  .risk-gauge-label {
    fill: currentColor;
  }

  .risk-gauge-desc {
    opacity: 0.9;
  }

  .condition-row .warm { color: #ff8a65; }
  .condition-row .cool { color: #64b5f6; }
  .condition-row .humid { color: #4fc3f7; }

  .compass-svg-animated circle { stroke: #444; }
  .compass-svg-animated .compass-label { fill: #aaa; }
  .compass-svg-animated line[stroke="#ccc"] { stroke: #555; }

  .plant-card-animated { background: #262626; border-color: #444; }
  .plant-card-chevron { color: #888; }

  .timeline-enhanced { scrollbar-color: #555 #1e1e1e; }
  .timeline-now-dot { background: #64b5f6; }
}

/* ============================================
   Preact Component Styles
   ============================================ */

/* Risk Gauge */
.risk-gauge {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 8px 16px;
}

.risk-gauge-meter {
  flex-shrink: 0;
  width: 140px;
}

.risk-gauge-svg {
  width: 100%;
  height: auto;
}

.risk-gauge-arc {
  /* animated via JS requestAnimationFrame */
}

.risk-gauge-score {
  font-size: 28px;
  font-weight: 800;
}

.risk-gauge-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.risk-gauge-details {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 0.8rem;
  color: #444;
}

.risk-gauge-time {
  font-weight: 600;
  color: #222;
}

.risk-gauge-wind {
  font-size: 0.78rem;
}

.risk-gauge-inv {
  font-size: 0.78rem;
}

.risk-gauge-desc {
  font-weight: 600;
  font-size: 0.85rem;
  margin-top: 1px;
}

.risk-gauge-loc-note {
  font-size: 0.7rem;
  color: #888;
  font-style: italic;
  margin-top: 2px;
}

/* Animated Compass */
.compass-wrap {
  display: flex;
  justify-content: center;
}

.compass-svg-animated {
  width: 120px;
  height: 120px;
  display: block;
  overflow: visible;
}

/* Condition highlights */
.condition-row .warm { color: #e65100; font-weight: 600; }
.condition-row .cool { color: #1565c0; font-weight: 600; }
.condition-row .humid { color: #0097a7; font-weight: 600; }
.condition-row .vol-very-high { color: #b71c1c; font-weight: 700; }
.condition-row .vol-high { color: #f44336; font-weight: 600; }
.condition-row .vol-moderate { color: #ff9800; }
.condition-row .vol-low { color: #4caf50; }
.condition-row .vol-very-low { color: #388e3c; }

/* Plant Card Animated */
.plant-card-animated {
  transition: box-shadow 0.2s, transform 0.15s;
}

.plant-card-animated:hover {
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  transform: translateY(-1px);
}

.plant-card-header-left {
  display: flex;
  align-items: center;
  gap: 6px;
}

.plant-card-chevron {
  font-size: 0.65rem;
  color: #999;
  transition: transform 0.2s ease;
  display: inline-block;
}

.plant-card-chevron.open {
  transform: rotate(90deg);
}

.plant-card-summary {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-top: 4px;
}

.plant-card-body {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid #eee;
  animation: slideDown 0.2s ease-out;
}

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Timeline Enhanced */
.timeline-enhanced {
  display: flex;
  overflow-x: auto;
  padding: 0 12px 8px;
  gap: 2px;
  scrollbar-width: thin;
}

.timeline-dot-wrap {
  display: flex;
  justify-content: center;
  padding: 2px 0;
}

.timeline-dot {
  transition: box-shadow 0.3s, transform 0.2s;
}

.timeline-cell:hover .timeline-dot {
  transform: scale(1.3);
}

.timeline-now-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #1a237e;
  margin: 2px auto 0;
  animation: pulse 2s infinite;
}

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