/* ============================================
   RIVERGATOR DESIGN SYSTEM
   Shared variables, typography, and base styles
   ============================================ */

:root {
  /* River palette */
  --river-blue: #1B4965;
  --river-deep: #0D2B3E;
  --river-light: #5FA8D3;
  --river-mist: #EBF5FB;

  /* Earth palette */
  --sand: #F5F0E8;
  --sand-dark: #E8E0D0;
  --forest: #2D5016;

  /* Marker colors */
  --access-green: #27AE60;
  --camp-orange: #E67E22;
  --hazard-red: #E74C3C;
  --water-blue: #3498DB;
  --wild-green: #1ABC9C;

  /* Neutral */
  --text: #1a1a1a;
  --text-muted: #7a7a7a;
  --text-light: #aaa;
  --border: #e8e8e8;
  --bg-card: #ffffff;

  /* Spacing */
  --safe-top: max(12px, env(safe-area-inset-top));
  --safe-bottom: max(8px, env(safe-area-inset-bottom));

  /* Type scale */
  --font-body: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI', sans-serif;
  --font-display: 'Georgia', 'Times New Roman', serif;
}

/* ===== RESET ===== */
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { height: 100%; }
body {
  font-family: var(--font-body);
  color: var(--text);
  background: var(--sand);
  min-height: 100%;
  -webkit-font-smoothing: antialiased;
}

/* ===== TYPOGRAPHY ===== */
.font-display { font-family: var(--font-display); }
.text-muted { color: var(--text-muted); }
.text-uppercase { text-transform: uppercase; letter-spacing: 1px; }
.text-small { font-size: 11px; }
.text-xs { font-size: 10px; }

/* ===== BOTTOM NAV ===== */
.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0;
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  display: flex;
  padding: 6px 0;
  padding-bottom: var(--safe-bottom);
  z-index: 1000;
}

.nav-item {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; gap: 3px; cursor: pointer;
  padding: 4px 0;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 10px; font-weight: 600;
  transition: color 0.15s;
}

.nav-item.active { color: var(--river-blue); }
.nav-icon { font-size: 22px; line-height: 1; }
.nav-label { letter-spacing: 0.3px; }

/* ===== CARDS ===== */
.card {
  background: var(--bg-card);
  border-radius: 14px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  overflow: hidden;
}

/* ===== GAUGE COMPONENTS ===== */
.gauge-strip {
  display: flex; gap: 10px; overflow-x: auto;
  padding: 12px 16px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.gauge-strip::-webkit-scrollbar { display: none; }

.gauge-card {
  flex-shrink: 0;
  background: var(--river-mist);
  border-radius: 12px;
  padding: 10px 14px;
  min-width: 130px;
}

.gauge-name { font-size: 11px; font-weight: 600; color: var(--river-blue); }
.gauge-reading { font-size: 20px; font-weight: 700; color: var(--text); margin-top: 2px; }
.gauge-info { font-size: 10px; color: var(--text-muted); margin-top: 2px; }
.gauge-trend-up { color: var(--access-green); }
.gauge-trend-down { color: var(--water-blue); }

/* ===== WAYPOINT COMPONENTS ===== */
.waypoint {
  display: flex; align-items: flex-start; gap: 14px;
  padding: 14px 20px;
  cursor: pointer;
  transition: background 0.15s;
  position: relative;
}
.waypoint:active { background: #f8f6f2; }

.waypoint-icon {
  width: 36px; height: 36px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; flex-shrink: 0;
}
.waypoint-icon.access { background: rgba(39,174,96,0.12); color: var(--access-green); }
.waypoint-icon.camp { background: rgba(230,126,34,0.12); color: var(--camp-orange); }
.waypoint-icon.hazard { background: rgba(231,76,60,0.12); color: var(--hazard-red); }
.waypoint-icon.water { background: rgba(52,152,219,0.12); color: var(--water-blue); }
.waypoint-icon.wild { background: rgba(26,188,156,0.12); color: var(--wild-green); }

.waypoint-connector {
  position: absolute; left: 37px; top: 50px; bottom: -14px;
  width: 2px; background: #e8e8e8;
}
.waypoint:last-child .waypoint-connector { display: none; }

.waypoint-info { flex: 1; min-width: 0; }
.waypoint-name { font-size: 15px; font-weight: 600; color: var(--text); line-height: 1.3; }
.waypoint-detail { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.waypoint-preview {
  font-size: 12px; color: var(--river-blue); margin-top: 4px;
  font-style: italic; line-height: 1.4;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}

.waypoint-dist { flex-shrink: 0; text-align: right; padding-top: 2px; }
.dist-num { font-size: 15px; font-weight: 700; color: var(--river-blue); }
.dist-unit { font-size: 10px; color: var(--text-muted); }

/* ===== CONDITION BADGE ===== */
.condition-badge {
  display: inline-flex; align-items: center; gap: 4px;
  background: rgba(26,188,156,0.1); border: 1px solid rgba(26,188,156,0.3);
  border-radius: 8px; padding: 2px 8px;
  font-size: 10px; font-weight: 600; color: var(--wild-green);
  margin-top: 4px;
}

/* ===== NARRATIVE DRAWER ===== */
.narrative-overlay {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  z-index: 2000; background: rgba(0,0,0,0.5);
  opacity: 0; pointer-events: none;
  transition: opacity 0.3s;
}
.narrative-overlay.open { opacity: 1; pointer-events: all; }

.narrative-drawer {
  position: absolute; bottom: 0; left: 0; right: 0;
  background: var(--sand);
  border-radius: 20px 20px 0 0;
  max-height: 90vh;
  top: max(40px, env(safe-area-inset-top));
  transform: translateY(100%);
  transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  overflow: hidden;
  display: flex; flex-direction: column;
}
.narrative-overlay.open .narrative-drawer { transform: translateY(0); }

.narrative-header {
  padding: 16px 20px;
  padding-right: 56px; /* room for close button */
  background: white;
  border-bottom: 1px solid var(--sand-dark);
  flex-shrink: 0;
}
.narrative-handle { width: 36px; height: 4px; border-radius: 2px; background: #d0d0d0; margin: 0 auto 12px; cursor: pointer; padding: 6px 0; background-clip: content-box; }
.narrative-mile { font-size: 11px; font-weight: 600; color: var(--river-blue); text-transform: uppercase; letter-spacing: 1px; }
.narrative-place { font-size: 20px; font-weight: 700; color: var(--text); font-family: var(--font-display); margin-top: 4px; line-height: 1.3; word-wrap: break-word; }
.narrative-meta { display: flex; gap: 16px; margin-top: 8px; }
.meta-tag { font-size: 11px; color: var(--text-muted); display: flex; align-items: center; gap: 4px; }
.narrative-close {
  position: absolute; top: 16px; right: 16px;
  width: 32px; height: 32px; border-radius: 50%;
  background: #f0f0f0; border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; color: var(--text-muted);
}

.narrative-body { padding: 20px; overflow-y: auto; flex: 1; -webkit-overflow-scrolling: touch; }
.narrative-text { font-family: var(--font-display); font-size: 16px; line-height: 1.7; color: #2a2a2a; }
.narrative-text p { margin-bottom: 16px; }
.narrative-attribution {
  font-size: 12px; color: var(--text-muted); font-style: italic;
  margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--sand-dark);
}

/* ===== EXPANDABLE WEATHER ===== */
.weather-expand { display: none; }
.weather-expand.open { display: block; }

/* ===== LOADING SKELETON ===== */
@keyframes shimmer {
  0% { background-position: -200px 0; }
  100% { background-position: 200px 0; }
}
.skeleton {
  background: linear-gradient(90deg, #f0ede6 25%, #e8e4dc 50%, #f0ede6 75%);
  background-size: 400px 100%;
  animation: shimmer 1.5s infinite;
  border-radius: 8px;
}

/* ===== UPDATE BANNER ===== */
.update-banner {
  position: fixed; top: 0; left: 0; right: 0; z-index: 9999;
  background: var(--river-blue); color: white; text-align: center;
  padding: 10px 16px; font-size: 13px; font-weight: 600;
  transform: translateY(-100%); transition: transform 0.3s;
  cursor: pointer;
}
.update-banner.show { transform: translateY(0); }

/* ===== GPS DOT ===== */
.gps-dot {
  width: 20px; height: 20px; position: relative;
}
.gps-dot-center {
  width: 20px; height: 20px; border-radius: 50%;
  background: #4285F4; border: 3px solid white;
  box-shadow: 0 0 12px rgba(66,133,244,0.5), 0 2px 8px rgba(0,0,0,0.3);
  position: relative; z-index: 2;
}
.gps-dot-ring {
  position: absolute; top: -10px; left: -10px;
  width: 40px; height: 40px; border-radius: 50%;
  background: rgba(66,133,244,0.15);
  animation: gps-pulse 2s ease-out infinite;
  z-index: 1;
}
@keyframes gps-pulse {
  0% { transform: scale(0.8); opacity: 1; }
  100% { transform: scale(2.5); opacity: 0; }
}

/* ===== RESPONSIVE ===== */
@media (min-width: 768px) {
  body { max-width: 480px; margin: 0 auto; box-shadow: 0 0 40px rgba(0,0,0,0.1); }
  .bottom-nav { max-width: 480px; left: 50%; transform: translateX(-50%); }
}
