:root {
  --bg-top: #2b5876;
  --bg-bottom: #4e4376;
  --card: rgba(255, 255, 255, 0.12);
  --card-border: rgba(255, 255, 255, 0.18);
  --text: #f5f7fa;
  --text-dim: rgba(245, 247, 250, 0.72);
  --accent: #ffd86b;
}

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

html, body {
  height: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--text);
  background: linear-gradient(160deg, var(--bg-top), var(--bg-bottom));
  background-attachment: fixed;
  min-height: 100vh;
  display: flex;
  justify-content: center;
  transition: background 1.2s ease;
}

/* Sky themes driven by JS (data-weather on body) */
body[data-weather="clear-day"]   { --bg-top: #4a90d9; --bg-bottom: #87cefa; --text: #1a2b3c; --text-dim: rgba(26,43,60,0.7); }
body[data-weather="clear-night"] { --bg-top: #0b1026; --bg-bottom: #2c3e73; }
body[data-weather="cloudy"]      { --bg-top: #5d6d7e; --bg-bottom: #85929e; }
body[data-weather="rain"]        { --bg-top: #2c3e50; --bg-bottom: #4a6076; }
body[data-weather="snow"]        { --bg-top: #5b6a7d; --bg-bottom: #9fb0c3; --text: #1a2b3c; --text-dim: rgba(26,43,60,0.7); }
body[data-weather="thunder"]     { --bg-top: #1c1c2e; --bg-bottom: #3a3a52; }
body[data-weather="fog"]         { --bg-top: #6b7280; --bg-bottom: #9ca3af; }

.dashboard {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 480px;
  padding: 10px 20px 20px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

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

.brand {
  font-size: 1.3rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.refresh-btn {
  background: var(--card);
  border: 1px solid var(--card-border);
  color: var(--text);
  border-radius: 999px;
  width: 34px;
  height: 34px;
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  backdrop-filter: blur(8px);
}
.refresh-btn.is-refreshing {
  animation: spin 0.9s linear infinite;
}

.share-btn {
  background: var(--card);
  border: 1px solid var(--card-border);
  color: var(--text);
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  backdrop-filter: blur(8px);
}
.share-btn.copied {
  color: var(--accent);
  border-color: var(--accent);
}

.unit-toggle {
  background: var(--card);
  border: 1px solid var(--card-border);
  color: var(--text);
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 0.95rem;
  cursor: pointer;
  font-weight: 600;
  backdrop-filter: blur(8px);
}
.unit-sep { opacity: 0.5; margin: 0 2px; }
.unit-inactive { opacity: 0.45; }
.unit-active { color: var(--accent); }

/* Status / loading */
.status {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 60px 20px;
  text-align: center;
}
@keyframes spin { to { transform: rotate(360deg); } }
.retry-btn {
  background: var(--accent);
  color: #1a1a2e;
  border: none;
  border-radius: 999px;
  padding: 10px 22px;
  font-weight: 600;
  cursor: pointer;
  font-size: 0.95rem;
}

/* Full-viewport animated sky layer */
.sky {
  position: fixed;
  inset: 0;
  overflow: hidden;
  z-index: 0;
  pointer-events: none;
}

/* Sun */
.sun {
  position: absolute;
  top: 9%;
  left: 50%;
  transform: translateX(-50%);
  width: 130px;
  height: 130px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #fff3b0, #ffb733);
  box-shadow: 0 0 90px 26px rgba(255, 200, 80, 0.55);
}
.sun::before {
  content: "";
  position: absolute;
  inset: -34px;
  border-radius: 50%;
  background: conic-gradient(from 0deg, transparent 0 8%, rgba(255,216,107,0.5) 8% 10%, transparent 10% 100%);
  animation: spin 22s linear infinite;
}

/* Moon + stars */
.moon {
  position: absolute;
  top: 9%;
  left: 50%;
  transform: translateX(-50%);
  width: 100px;
  height: 100px;
  border-radius: 50%;
  background: radial-gradient(circle at 65% 35%, #fdfcf0, #cfd3e0);
  box-shadow: inset -14px -8px 0 -2px rgba(0,0,0,0.12), 0 0 50px 10px rgba(220,225,255,0.35);
}
.star {
  position: absolute;
  width: 3px;
  height: 3px;
  background: #fff;
  border-radius: 50%;
  animation: twinkle 2.5s ease-in-out infinite;
}
@keyframes twinkle { 0%,100% { opacity: 0.25; } 50% { opacity: 1; } }

/* Clouds */
.cloud {
  position: absolute;
  background: #f3f5f8;
  border-radius: 50px;
  opacity: 0.92;
  animation: drift linear infinite;
}
.cloud::before, .cloud::after {
  content: "";
  position: absolute;
  background: #f3f5f8;
  border-radius: 50%;
}
.cloud::before { width: 55%; height: 140%; top: -55%; left: 12%; }
.cloud::after  { width: 45%; height: 120%; top: -42%; right: 14%; }
@keyframes drift {
  from { transform: translateX(-180px); }
  to   { transform: translateX(calc(100vw + 180px)); }
}

/* Rain */
.drop {
  position: absolute;
  top: -6vh;
  width: 2px;
  height: 18px;
  background: linear-gradient(transparent, rgba(180, 210, 255, 0.9));
  border-radius: 2px;
  transform: rotate(var(--rain-tilt, 0deg));
  animation: fall linear infinite;
}
@keyframes fall {
  from { transform: translate(0, 0) rotate(var(--rain-tilt, 0deg)); }
  to   { transform: translate(var(--rain-dx, 0px), 108vh) rotate(var(--rain-tilt, 0deg)); }
}

/* Snow */
.flake {
  position: absolute;
  top: -6vh;
  color: #fff;
  font-size: 14px;
  animation: snowfall linear infinite;
}
@keyframes snowfall {
  0%   { transform: translateY(-6vh) translateX(0); }
  100% { transform: translateY(108vh) translateX(40px); }
}

/* Lightning */
.bolt {
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.85);
  opacity: 0;
  animation: flash 4.5s linear infinite;
}
@keyframes flash {
  0%, 92%, 100% { opacity: 0; }
  93%, 97% { opacity: 0; }
  94% { opacity: 0.9; }
  95% { opacity: 0.1; }
  96% { opacity: 0.8; }
}

/* Fog */
.fog-band {
  position: absolute;
  left: 0;
  width: 200%;
  height: 26px;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.55), transparent);
  animation: fogmove linear infinite;
}
@keyframes fogmove {
  from { transform: translateX(-50%); }
  to   { transform: translateX(0%); }
}

/* Weather content */
.content {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

/* Readout */
.readout {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  text-align: center;
  padding: 4px 0;
}
.location {
  font-size: 1.05rem;
  color: var(--text-dim);
}
.temp {
  font-size: 4.2rem;
  font-weight: 200;
  line-height: 1;
}
.condition {
  font-size: 1.25rem;
  font-weight: 500;
}
.feels {
  color: var(--text-dim);
  font-size: 0.95rem;
}

/* Metrics */
.metrics {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
.metrics li {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 16px;
  padding: 12px 8px;
  text-align: center;
  backdrop-filter: blur(8px);
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.metric-label { font-size: 0.72rem; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.05em; }
.metric-value { font-size: 1.05rem; font-weight: 600; }

/* Map */
.map-card {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 20px;
  padding: 14px 14px 16px;
  backdrop-filter: blur(8px);
}
.map-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 10px;
}
.map-title { font-size: 1.05rem; }
.map-link {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--accent);
  text-decoration: none;
}
.map-frame {
  position: relative;
  width: 100%;
  height: 220px;
  border-radius: 14px;
  overflow: hidden;
  background: rgba(0, 0, 0, 0.18);
}
.map-frame iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

/* Clothing recommendations */
.clothing {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 20px;
  padding: 18px;
  backdrop-filter: blur(8px);
}
.clothing-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
}
.clothing-title { font-size: 1.05rem; }
.clothing-headline {
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--accent);
}
.clothing-list {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.clothing-list li {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.14);
  border: 1px solid var(--card-border);
  border-radius: 999px;
  padding: 7px 14px 7px 8px;
  font-size: 0.9rem;
  font-weight: 500;
}
.clothing-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.16);
  font-size: 0.95rem;
  line-height: 1;
}

/* Driving conditions */
.driving {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 20px;
  padding: 18px;
  backdrop-filter: blur(8px);
}
.driving-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}
.driving-title { font-size: 1.05rem; }
.rating {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-weight: 600;
  font-size: 0.92rem;
}
.rating-dot {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: #9aa0a6;
}
.driving[data-level="good"] .rating-dot    { background: #46c46a; box-shadow: 0 0 8px rgba(70,196,106,0.7); }
.driving[data-level="caution"] .rating-dot { background: #f5b942; box-shadow: 0 0 8px rgba(245,185,66,0.7); }
.driving[data-level="hazard"] .rating-dot  { background: #ef5350; box-shadow: 0 0 8px rgba(239,83,80,0.7); }
.driving[data-level="good"] .rating-label    { color: #46c46a; }
.driving[data-level="caution"] .rating-label { color: #f5b942; }
.driving[data-level="hazard"] .rating-label  { color: #ef5350; }
.driving-summary {
  color: var(--text-dim);
  font-size: 0.95rem;
}
.driving-list {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}
.driving-list:empty { margin-top: 0; }
.driving-list li {
  background: rgba(255, 255, 255, 0.14);
  border: 1px solid var(--card-border);
  border-radius: 999px;
  padding: 7px 14px;
  font-size: 0.9rem;
  font-weight: 500;
}

.foot {
  text-align: center;
  font-size: 0.78rem;
  color: var(--text-dim);
  padding-top: 4px;
}
.foot a { color: var(--text-dim); }

@media (prefers-reduced-motion: reduce) {
  .sun::before, .cloud, .drop, .flake, .bolt, .fog-band, .star, .spinner {
    animation: none !important;
  }
}
