/* ============================================
   KL WEATHER — Kuala Lumpur Live Forecast
   Dark Glassmorphism · Tropical Warm Tones
   ============================================ */

/* ---------- Reset & Base ---------- */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  font-family: 'Outfit', system-ui, sans-serif;
  min-height: 100vh;
  color: #f0f0f5;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  position: relative;
}

/* ---------- Animated Background ---------- */
.bg-gradient {
  position: fixed; inset: 0; z-index: -2;
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 30%, #0f3460 60%, #1a1a2e 100%);
  background-size: 400% 400%;
  animation: bgShift 20s ease infinite;
}
@keyframes bgShift {
  0%, 100% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
}
.bg-particles {
  position: fixed; inset: 0; z-index: -1;
  overflow: hidden;
  pointer-events: none;
}
.particle {
  position: absolute;
  width: 4px; height: 4px;
  border-radius: 50%;
  background: rgba(255, 179, 71, 0.3);
  animation: floatUp linear infinite;
}
@keyframes floatUp {
  0% { transform: translateY(100vh) translateX(0); opacity: 0; }
  10% { opacity: 1; }
  90% { opacity: 1; }
  100% { transform: translateY(-10vh) translateX(40px); opacity: 0; }
}

/* ---------- Container ---------- */
.container {
  max-width: 900px;
  margin: 0 auto;
  padding: 1.5rem 1.5rem 3rem;
}

/* ---------- Header ---------- */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 2rem;
  flex-wrap: wrap;
  gap: 1rem;
}
.header__left {
  display: flex;
  align-items: center;
  gap: 0.8rem;
}
.header__logo {
  display: flex;
  animation: spin 20s linear infinite;
}
@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}
.header__title {
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, #FFB347, #FF6B35);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.header__subtitle {
  font-size: 0.78rem;
  color: rgba(255,255,255,0.45);
  letter-spacing: 0.03em;
}
.header__right {
  display: flex;
  align-items: center;
  gap: 1rem;
}
.refresh-btn {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.55rem 1.1rem;
  border-radius: 100px;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.1);
  color: rgba(255,255,255,0.7);
  font-size: 0.82rem;
  font-weight: 400;
  transition: all 0.3s;
  backdrop-filter: blur(10px);
}
.refresh-btn:hover {
  background: rgba(255, 179, 71, 0.15);
  border-color: rgba(255, 179, 71, 0.3);
  color: #FFB347;
}
.refresh-btn.spinning svg {
  animation: spin 0.8s ease;
}
.header__time {
  font-size: 0.85rem;
  color: rgba(255,255,255,0.5);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
}

/* ---------- Current Weather Hero ---------- */
.current {
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 28px;
  padding: 2.5rem 2rem;
  text-align: center;
  position: relative;
  overflow: hidden;
  backdrop-filter: blur(20px);
  margin-bottom: 1.5rem;
}
.current::before {
  content: '';
  position: absolute;
  top: -50%; left: -50%;
  width: 200%; height: 200%;
  background: radial-gradient(circle at center, rgba(255,179,71,0.06) 0%, transparent 50%);
  animation: pulse 6s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 0.5; }
  50% { opacity: 1; }
}
.current__main {
  position: relative;
  z-index: 1;
}
.current__icon {
  display: flex;
  justify-content: center;
  margin-bottom: 1rem;
  animation: floatIcon 3s ease-in-out infinite;
}
@keyframes floatIcon {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}
.current__temp-wrap {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  gap: 0.2rem;
}
.current__temp {
  font-size: 5.5rem;
  font-weight: 200;
  line-height: 1;
  letter-spacing: -0.04em;
  background: linear-gradient(135deg, #fff, #FFB347);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.current__temp-unit {
  font-size: 2rem;
  font-weight: 300;
  color: rgba(255,179,71,0.8);
  margin-top: 0.5rem;
}
.current__desc {
  font-size: 1.15rem;
  font-weight: 400;
  color: rgba(255,255,255,0.85);
  margin-top: 0.5rem;
  text-transform: capitalize;
}
.current__feels {
  font-size: 0.85rem;
  color: rgba(255,255,255,0.4);
  margin-top: 0.3rem;
}
.current__badge {
  position: absolute;
  top: 1.2rem; right: 1.2rem;
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.8rem;
  border-radius: 100px;
  background: rgba(46, 213, 115, 0.12);
  border: 1px solid rgba(46, 213, 115, 0.25);
  color: #2ed573;
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.03em;
  z-index: 2;
}
.current__badge .live-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: #2ed573;
  animation: blink 1.5s ease infinite;
}
@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

/* ---------- Metrics Grid ---------- */
.metrics {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.metric-card {
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 18px;
  padding: 1.2rem;
  display: flex;
  align-items: center;
  gap: 0.9rem;
  backdrop-filter: blur(10px);
  transition: all 0.3s;
  opacity: 0;
  transform: translateY(15px);
  animation: fadeUp 0.5s forwards;
}
.metric-card:nth-child(1) { animation-delay: 0.05s; }
.metric-card:nth-child(2) { animation-delay: 0.1s; }
.metric-card:nth-child(3) { animation-delay: 0.15s; }
.metric-card:nth-child(4) { animation-delay: 0.2s; }
.metric-card:nth-child(5) { animation-delay: 0.25s; }
.metric-card:nth-child(6) { animation-delay: 0.3s; }
@keyframes fadeUp {
  to { opacity: 1; transform: translateY(0); }
}
.metric-card:hover {
  background: rgba(255,179,71,0.06);
  border-color: rgba(255,179,71,0.15);
  transform: translateY(-3px);
}
.metric-card__icon {
  width: 42px; height: 42px;
  border-radius: 12px;
  background: rgba(255,179,71,0.08);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #FFB347;
  flex-shrink: 0;
}
.metric-card__body {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}
.metric-card__label {
  font-size: 0.72rem;
  color: rgba(255,255,255,0.4);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.metric-card__value {
  font-size: 1.1rem;
  font-weight: 500;
  color: rgba(255,255,255,0.9);
  font-variant-numeric: tabular-nums;
}

/* ---------- Sun Bar ---------- */
.sun-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 18px;
  padding: 1.2rem 1.5rem;
  margin-bottom: 1.5rem;
  backdrop-filter: blur(10px);
  flex-wrap: wrap;
  gap: 0.8rem;
}
.sun-bar__item {
  display: flex;
  align-items: center;
  gap: 0.7rem;
}
.sun-bar__icon {
  color: #FFB347;
  display: flex;
}
.sun-bar__label {
  font-size: 0.72rem;
  color: rgba(255,255,255,0.4);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  display: block;
}
.sun-bar__value {
  font-size: 0.95rem;
  font-weight: 500;
  color: rgba(255,255,255,0.9);
  font-variant-numeric: tabular-nums;
  display: block;
}
.sun-bar__divider {
  width: 1px;
  height: 32px;
  background: rgba(255,255,255,0.08);
}

/* ---------- Section Title ---------- */
.section-title {
  font-size: 1.1rem;
  font-weight: 500;
  color: rgba(255,255,255,0.7);
  margin-bottom: 1rem;
  letter-spacing: -0.01em;
}

/* ---------- Hourly ---------- */
.hourly {
  margin-bottom: 1.5rem;
}
.hourly__scroll {
  display: flex;
  gap: 0.6rem;
  overflow-x: auto;
  padding-bottom: 0.5rem;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,179,71,0.3) transparent;
}
.hourly__scroll::-webkit-scrollbar {
  height: 4px;
}
.hourly__scroll::-webkit-scrollbar-track {
  background: transparent;
}
.hourly__scroll::-webkit-scrollbar-thumb {
  background: rgba(255,179,71,0.2);
  border-radius: 2px;
}
.hour-card {
  flex-shrink: 0;
  width: 70px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 16px;
  padding: 0.8rem 0.5rem;
  text-align: center;
  transition: all 0.3s;
}
.hour-card:hover {
  background: rgba(255,179,71,0.08);
  border-color: rgba(255,179,71,0.15);
}
.hour-card__time {
  font-size: 0.72rem;
  color: rgba(255,255,255,0.4);
  margin-bottom: 0.5rem;
}
.hour-card__icon {
  display: flex;
  justify-content: center;
  margin-bottom: 0.5rem;
}
.hour-card__temp {
  font-size: 0.95rem;
  font-weight: 500;
  color: rgba(255,255,255,0.9);
}
.hour-card__rain {
  font-size: 0.65rem;
  color: rgba(100, 180, 255, 0.6);
  margin-top: 0.2rem;
}

/* ---------- Forecast ---------- */
.forecast {
  margin-bottom: 1.5rem;
}
.forecast__list {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}
.forecast-row {
  display: grid;
  grid-template-columns: 80px 50px 1fr auto;
  align-items: center;
  gap: 1rem;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 16px;
  padding: 0.9rem 1.2rem;
  transition: all 0.3s;
}
.forecast-row:hover {
  background: rgba(255,179,71,0.06);
  border-color: rgba(255,179,71,0.15);
  transform: translateX(4px);
}
.forecast-row__day {
  font-size: 0.9rem;
  font-weight: 500;
  color: rgba(255,255,255,0.85);
}
.forecast-row__icon {
  display: flex;
  justify-content: center;
}
.forecast-row__desc {
  font-size: 0.78rem;
  color: rgba(255,255,255,0.4);
  text-transform: capitalize;
}
.forecast-row__temps {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}
.forecast-row__max {
  font-size: 1.1rem;
  font-weight: 500;
  color: rgba(255,255,255,0.9);
  font-variant-numeric: tabular-nums;
}
.forecast-row__min {
  font-size: 0.9rem;
  color: rgba(255,255,255,0.35);
  font-variant-numeric: tabular-nums;
}
.forecast-row__rain {
  font-size: 0.72rem;
  color: rgba(100, 180, 255, 0.5);
  margin-left: 0.5rem;
}

/* ---------- Footer ---------- */
.footer {
  text-align: center;
  padding: 1.5rem 0 0;
  border-top: 1px solid rgba(255,255,255,0.06);
  margin-top: 1rem;
}
.footer p {
  font-size: 0.75rem;
  color: rgba(255,255,255,0.3);
  line-height: 1.7;
}
.footer a {
  color: rgba(255,179,71,0.6);
  transition: color 0.3s;
}
.footer a:hover { color: #FFB347; }
.footer__updated {
  margin-top: 0.3rem !important;
  font-variant-numeric: tabular-nums;
}

/* ---------- Loading ---------- */
.loading {
  position: fixed; inset: 0; z-index: 9999;
  background: #0f0f1a;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.2rem;
  transition: opacity 0.5s, visibility 0.5s;
}
.loading.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}
.loading__spinner {
  width: 48px; height: 48px;
  border: 3px solid rgba(255,179,71,0.15);
  border-top-color: #FFB347;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
.loading p {
  color: rgba(255,255,255,0.4);
  font-size: 0.9rem;
}

/* ---------- Error State ---------- */
.error-state {
  text-align: center;
  padding: 3rem 1rem;
  color: rgba(255,255,255,0.5);
}
.error-state h3 {
  font-size: 1.2rem;
  margin-bottom: 0.5rem;
  color: rgba(255,107,53,0.8);
}
.error-state p {
  font-size: 0.85rem;
}

/* ---------- Responsive ---------- */
@media (max-width: 700px) {
  .metrics { grid-template-columns: repeat(2, 1fr); }
  .current__temp { font-size: 4rem; }
  .sun-bar { justify-content: flex-start; }
  .sun-bar__divider:nth-of-type(2),
  .sun-bar__divider:nth-of-type(4) { display: none; }
  .sun-bar { gap: 1.2rem; }
  .forecast-row { grid-template-columns: 60px 40px 1fr auto; gap: 0.6rem; padding: 0.8rem 1rem; }
}
@media (max-width: 420px) {
  .metrics { grid-template-columns: 1fr; }
  .current { padding: 2rem 1rem; }
  .current__temp { font-size: 3.5rem; }
  .header__title { font-size: 1.2rem; }
  .sun-bar__divider { display: none; }
}
