/* ========================================
   Sophie's Stroll — Baby-Friendly Theme
   ======================================== */

:root {
  --pink: #FF9EB5;
  --pink-light: #FFD4DF;
  --pink-bg: #FFF5F7;
  --mint: #B8E6D0;
  --mint-dark: #7ECBA1;
  --lavender: #C9B8E8;
  --yellow: #FFD93D;
  --yellow-light: #FFF8E1;
  --purple: #5C4B6B;
  --purple-light: #8B7BA0;
  --shade-good: #51CF66;
  --shade-mid: #FFD93D;
  --shade-bad: #FF6B6B;
  --white: #FFFFFF;
  --shadow: rgba(92, 75, 107, 0.1);
  --shadow-md: rgba(92, 75, 107, 0.15);

  --header-height: 90px;
  --footer-height: 48px;
}

/* ---- Reset & Base ---- */

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

body {
  margin: 0;
  font-family: 'Baloo 2', 'Segoe UI', sans-serif;
  background: var(--pink-bg);
  color: var(--purple);
  overflow-x: hidden;
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
}

h1, h2, h3 { margin: 0; }

.hidden { display: none !important; }

/* ---- Floating Clouds ---- */

.cloud {
  position: fixed;
  z-index: 0;
  pointer-events: none;
  animation: float-cloud linear infinite;
}
.cloud-1 { top: 6%;  animation-duration: 40s; }
.cloud-2 { top: 18%; animation-duration: 55s; animation-delay: -18s; }
.cloud-3 { top: 35%; animation-duration: 48s; animation-delay: -30s; }

@keyframes float-cloud {
  0%   { transform: translateX(-160px); opacity: 0; }
  5%   { opacity: 1; }
  95%  { opacity: 1; }
  100% { transform: translateX(calc(100vw + 160px)); opacity: 0; }
}

/* ---- Header ---- */

header {
  background: linear-gradient(135deg, var(--pink-light) 0%, var(--lavender) 50%, var(--mint) 100%);
  padding: 0.6rem 1.5rem;
  position: relative;
  z-index: 10;
  box-shadow: 0 4px 24px var(--shadow-md);
  flex-shrink: 0;
}

.header-content {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  max-width: 1200px;
  margin: 0 auto;
}

.stroller-icon {
  flex-shrink: 0;
  animation: wobble 4s ease-in-out infinite;
}

@keyframes wobble {
  0%, 100% { transform: rotate(-4deg) translateY(0); }
  25%      { transform: rotate(2deg) translateY(-3px); }
  50%      { transform: rotate(-2deg) translateY(0); }
  75%      { transform: rotate(3deg) translateY(-2px); }
}

header h1 {
  font-size: 2rem;
  font-weight: 800;
  color: var(--purple);
  line-height: 1.1;
  text-shadow: 2px 2px 0 rgba(255,255,255,0.5);
}

.tagline {
  margin: 0;
  font-size: 0.95rem;
  color: var(--purple-light);
  font-weight: 500;
}

/* ---- Main Layout ---- */

main {
  flex: 1;
  display: flex;
  min-height: 0;
  position: relative;
  z-index: 1;
}

/* ---- Map ---- */

#map-wrap {
  flex: 1;
  position: relative;
  min-height: 400px;
}

#map {
  width: 100%;
  height: 100%;
  z-index: 1;
}

.leaflet-container {
  font-family: 'Baloo 2', sans-serif;
}

/* Custom markers */
.custom-marker {
  background: none !important;
  border: none !important;
}

.marker-bubble {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.8rem;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.2));
  animation: marker-drop 0.4s ease-out;
}

@keyframes marker-drop {
  0%   { transform: translateY(-30px); opacity: 0; }
  60%  { transform: translateY(4px); }
  100% { transform: translateY(0); opacity: 1; }
}

.leaflet-div-icon.sun-map-marker {
  background: none !important;
  border: none !important;
  box-shadow: none !important;
  font-size: 1.4rem;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: pulse-sun 2s ease-in-out infinite;
}

@keyframes pulse-sun {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.2); }
}

/* ---- Map Overlay ---- */

#map-overlay {
  position: absolute;
  top: 0; right: 0; bottom: 0; left: 0;
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 245, 247, 0.5);
  cursor: pointer;
  transition: opacity 0.4s;
}

#map-overlay.hidden {
  display: none;
}

.overlay-content {
  text-align: center;
  animation: gentle-pulse 2s ease-in-out infinite;
}

.overlay-icon {
  font-size: 3rem;
  display: block;
  margin-bottom: 0.3rem;
}

.overlay-content p {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--purple);
  background: rgba(255,255,255,0.85);
  padding: 0.5rem 1.2rem;
  border-radius: 30px;
  box-shadow: 0 2px 12px var(--shadow);
}

@keyframes gentle-pulse {
  0%, 100% { transform: scale(1); opacity: 0.9; }
  50%      { transform: scale(1.05); opacity: 1; }
}

/* ---- Panel ---- */

#panel {
  width: 360px;
  overflow-y: auto;
  background: var(--white);
  box-shadow: -4px 0 24px var(--shadow-md);
  display: flex;
  flex-direction: column;
  z-index: 5;
}

.panel-section {
  padding: 1.2rem 1.4rem;
}

.controls h2 {
  font-size: 1.3rem;
  font-weight: 700;
  margin-bottom: 0.6rem;
  color: var(--purple);
}

.hint {
  font-size: 0.95rem;
  color: var(--purple-light);
  margin: 0 0 1rem 0;
  padding: 0.6rem 0.8rem;
  background: var(--yellow-light);
  border-radius: 12px;
  border-left: 4px solid var(--yellow);
}

/* ---- Input Group ---- */

.input-group {
  margin-bottom: 1rem;
}

.input-group label {
  display: block;
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: 0.4rem;
  color: var(--purple);
}

.input-group input[type="datetime-local"] {
  width: 100%;
  padding: 0.6rem 0.8rem;
  font-family: 'Baloo 2', sans-serif;
  font-size: 1rem;
  border: 2px solid var(--pink-light);
  border-radius: 12px;
  color: var(--purple);
  background: var(--white);
  transition: border-color 0.2s;
}

.input-group input:focus {
  outline: none;
  border-color: var(--pink);
  box-shadow: 0 0 0 3px rgba(255, 158, 181, 0.2);
}

/* ---- Buttons ---- */

#find-route {
  width: 100%;
  padding: 0.85rem 1rem;
  font-family: 'Baloo 2', cursive;
  font-size: 1.15rem;
  font-weight: 700;
  background: linear-gradient(135deg, var(--mint-dark), var(--mint));
  color: white;
  border: none;
  border-radius: 50px;
  cursor: pointer;
  transition: all 0.25s ease;
  text-shadow: 1px 1px 0 rgba(0,0,0,0.08);
  box-shadow: 0 4px 16px rgba(126, 203, 161, 0.4);
  position: relative;
  overflow: hidden;
}

#find-route::after {
  content: '';
  position: absolute;
  top: 0; left: -100%;
  width: 100%; height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
  transition: left 0.5s;
}

#find-route:hover:not(:disabled)::after {
  left: 100%;
}

#find-route:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 6px 22px rgba(126, 203, 161, 0.5);
}

#find-route:active:not(:disabled) {
  transform: translateY(0);
}

#find-route:disabled {
  background: #e0dce4;
  color: #a9a0b4;
  box-shadow: none;
  cursor: not-allowed;
  text-shadow: none;
}

.clear-btn {
  width: 100%;
  padding: 0.55rem 1rem;
  font-family: 'Baloo 2', cursive;
  font-size: 0.95rem;
  font-weight: 600;
  background: transparent;
  color: var(--purple-light);
  border: 2px solid var(--pink-light);
  border-radius: 50px;
  cursor: pointer;
  margin-top: 0.6rem;
  transition: all 0.2s;
}

.clear-btn:hover {
  background: var(--pink-bg);
  border-color: var(--pink);
  color: var(--purple);
}

/* ---- Loading ---- */

#loading {
  padding: 2.5rem 1.4rem;
  text-align: center;
}

.loading-baby {
  font-size: 3.5rem;
  display: inline-block;
  animation: baby-bounce 0.8s ease-in-out infinite;
}

@keyframes baby-bounce {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  30%      { transform: translateY(-24px) rotate(-5deg); }
  50%      { transform: translateY(-28px) rotate(5deg); }
  80%      { transform: translateY(4px); }
}

.loading-text {
  font-size: 1rem;
  color: var(--purple-light);
  margin: 0.5rem 0 0;
  animation: pulse-text 1.5s ease-in-out infinite;
}

@keyframes pulse-text {
  0%, 100% { opacity: 0.6; }
  50%      { opacity: 1; }
}

/* ---- Results ---- */

#results {
  padding: 0 1.4rem 1.4rem;
}

#results h2 {
  font-size: 1.2rem;
  font-weight: 700;
  margin-bottom: 0.8rem;
}

/* ---- Route Card ---- */

.route-card {
  background: var(--white);
  border-radius: 16px;
  padding: 1rem 1.1rem;
  margin-bottom: 0.8rem;
  box-shadow: 0 2px 12px var(--shadow);
  border: 2.5px solid transparent;
  transition: all 0.25s ease;
  cursor: pointer;
}

.route-card:hover {
  border-color: var(--lavender);
  transform: translateY(-1px);
  box-shadow: 0 4px 16px var(--shadow-md);
}

.route-card.selected {
  border-color: var(--purple);
  box-shadow: 0 4px 16px var(--shadow-md);
}

.route-card.best {
  background: linear-gradient(135deg, rgba(184, 230, 208, 0.15), var(--white));
  border-color: var(--mint-dark);
}

.best-badge {
  display: inline-block;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--mint-dark);
  background: rgba(126, 203, 161, 0.15);
  padding: 0.15rem 0.6rem;
  border-radius: 20px;
  margin-bottom: 0.4rem;
}

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

.route-name {
  font-weight: 700;
  font-size: 1.05rem;
}

.route-stats {
  font-size: 0.85rem;
  color: var(--purple-light);
}

/* Shade meter */
.shade-meter {
  height: 14px;
  background: rgba(255, 158, 181, 0.2);
  border-radius: 7px;
  overflow: hidden;
  margin-bottom: 0.5rem;
}

.shade-meter-fill {
  height: 100%;
  border-radius: 7px;
  transition: width 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  position: relative;
}

.shade-meter-fill::after {
  content: '';
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: linear-gradient(180deg, rgba(255,255,255,0.3) 0%, transparent 60%);
  border-radius: 7px;
}

.shade-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.shade-percent {
  font-weight: 700;
  font-size: 1rem;
}

.shade-desc {
  font-size: 0.85rem;
  color: var(--purple-light);
}

/* ---- Sun Info Badge ---- */

#sun-info {
  padding: 0 1.4rem 1.2rem;
}

.sun-badge {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--yellow-light);
  padding: 0.6rem 1rem;
  border-radius: 12px;
  font-size: 0.9rem;
  border: 1px solid rgba(255, 217, 61, 0.3);
}

.sun-icon-badge {
  font-size: 1.3rem;
}

/* ---- Special Cards ---- */

.error-card, .night-card {
  text-align: center;
  padding: 1.5rem;
  border-radius: 16px;
  background: var(--white);
  box-shadow: 0 2px 12px var(--shadow);
}

.error-card { border: 2px solid var(--shade-bad); }
.error-icon { font-size: 2.5rem; display: block; margin-bottom: 0.5rem; }

.night-card { border: 2px solid var(--lavender); background: linear-gradient(135deg, #f0ecf5, var(--white)); }
.night-icon { font-size: 3rem; display: block; margin-bottom: 0.5rem; }
.night-card h3 { margin-bottom: 0.3rem; }
.night-card p { color: var(--purple-light); margin: 0; }

/* ---- Footer ---- */

footer {
  text-align: center;
  padding: 0.8rem 1rem;
  color: var(--purple-light);
  font-size: 0.85rem;
  background: rgba(255,255,255,0.5);
  flex-shrink: 0;
  z-index: 1;
}

footer p { margin: 0; }

/* ---- Responsive ---- */

@media (max-width: 800px) {
  main {
    flex-direction: column;
  }

  #map-wrap {
    height: 50vh;
    height: 50dvh;
    min-height: 250px;
    flex: none;
  }

  #panel {
    width: 100%;
    flex: 1;
    overflow-y: auto;
    box-shadow: 0 -4px 24px var(--shadow-md);
  }

  header h1 { font-size: 1.5rem; }
  .tagline  { font-size: 0.85rem; }
  .stroller-icon svg { width: 50px; height: 46px; }
}

@media (max-width: 480px) {
  .header-content { gap: 0.5rem; }
  header h1 { font-size: 1.3rem; }
  .panel-section { padding: 1rem; }
  #results { padding: 0 1rem 1rem; }
  #sun-info { padding: 0 1rem 1rem; }
}

/* ---- Leaflet Overrides ---- */

.leaflet-control-attribution {
  font-family: 'Baloo 2', sans-serif !important;
  font-size: 0.7rem !important;
}

.leaflet-bar a {
  color: var(--purple) !important;
}
