/* WeatherNext Forecast — dark glass theme (ภาษาไทย) */

:root {
  --bg-0: #070c1a;
  --bg-1: #0b1226;
  --card: rgba(255, 255, 255, 0.045);
  --card-border: rgba(148, 163, 184, 0.16);
  --text-1: #e6edf7;
  --text-2: #9aa8bd;
  --text-3: #64748b;
  --accent: #38bdf8;
  --accent-2: #818cf8;
  --good: #34d399;
  --warn: #fbbf24;
  --danger: #f87171;
  --rain: #60a5fa;
  --radius: 18px;
  --shadow: 0 18px 50px rgba(2, 6, 23, 0.5);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans Thai", "Sukhumvit Set", Tahoma, sans-serif;
  color: var(--text-1);
  background:
    radial-gradient(1100px 500px at 85% -10%, rgba(56, 189, 248, 0.14), transparent 60%),
    radial-gradient(900px 480px at -10% 20%, rgba(129, 140, 248, 0.12), transparent 60%),
    linear-gradient(180deg, var(--bg-0), var(--bg-1) 60%, #050810);
  min-height: 100vh;
  line-height: 1.55;
}

.container { max-width: 1080px; margin: 0 auto; padding: 0 18px; }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3 { margin: 0; font-weight: 700; letter-spacing: 0.2px; }
h2 { font-size: 1.05rem; }
h3 { font-size: 0.95rem; color: var(--text-1); }

.muted { color: var(--text-2); }
.small { font-size: 0.8rem; }
.hidden { display: none !important; }

/* ---------- Header ---------- */
.site-header { padding: 22px 0 10px; }
.header-inner { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.brand { display: flex; align-items: center; gap: 13px; }
.brand-mark {
  width: 52px; height: 52px; border-radius: 15px;
  display: grid; place-items: center;
  background: rgba(56, 189, 248, 0.09);
  border: 1px solid rgba(56, 189, 248, 0.25);
  box-shadow: inset 0 0 22px rgba(56, 189, 248, 0.12);
}
.brand-text h1 { font-size: 1.18rem; }
.brand-text p { margin: 2px 0 0; font-size: 0.8rem; color: var(--text-2); }
.brand-text strong { color: var(--accent); font-weight: 600; }

/* ---------- Search ---------- */
.search-section { padding: 8px 0 4px; position: relative; z-index: 30; }
.search-row { display: flex; flex-direction: column; gap: 10px; }
.search-wrap { position: relative; }
.search-input-wrap {
  display: flex; align-items: center; gap: 10px;
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 14px;
  padding: 10px 14px;
  backdrop-filter: blur(14px);
  transition: border-color 0.2s, box-shadow 0.2s;
}
.search-input-wrap:focus-within {
  border-color: rgba(56, 189, 248, 0.55);
  box-shadow: 0 0 0 4px rgba(56, 189, 248, 0.12);
}
.search-input-wrap .icon { color: var(--text-3); flex: none; }
#search-input {
  flex: 1; background: none; border: none; outline: none;
  color: var(--text-1); font-size: 0.95rem; font-family: inherit;
}
#search-input::placeholder { color: var(--text-3); }

.btn-icon {
  flex: none; display: grid; place-items: center;
  width: 34px; height: 34px; border-radius: 10px;
  background: rgba(56, 189, 248, 0.12);
  border: 1px solid rgba(56, 189, 248, 0.3);
  color: var(--accent); cursor: pointer;
  transition: background 0.15s, transform 0.15s;
}
.btn-icon:hover { background: rgba(56, 189, 248, 0.22); transform: translateY(-1px); }
.btn-icon:active { transform: translateY(0); }
.btn-icon.loading { animation: pulse 1s ease-in-out infinite; pointer-events: none; }

@keyframes pulse { 50% { opacity: 0.45; } }

.search-results {
  position: absolute; top: calc(100% + 8px); left: 0; right: 0;
  background: #0d1530f2;
  border: 1px solid var(--card-border);
  border-radius: 14px;
  box-shadow: var(--shadow);
  overflow: hidden;
  backdrop-filter: blur(18px);
  z-index: 40;
}
.search-result-item {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  width: 100%; text-align: left;
  padding: 11px 15px;
  background: none; border: none; cursor: pointer;
  color: var(--text-1); font-family: inherit; font-size: 0.9rem;
  border-bottom: 1px solid rgba(148, 163, 184, 0.07);
}
.search-result-item:last-child { border-bottom: none; }
.search-result-item:hover, .search-result-item.active { background: rgba(56, 189, 248, 0.1); }
.search-result-item .place-name { font-weight: 600; }
.search-result-item .place-detail { font-size: 0.78rem; color: var(--text-2); }

.quick-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  padding: 6px 14px; border-radius: 999px;
  background: var(--card); border: 1px solid var(--card-border);
  color: var(--text-2); font-size: 0.82rem; font-family: inherit;
  cursor: pointer; transition: all 0.15s;
}
.chip:hover { color: var(--text-1); border-color: rgba(56, 189, 248, 0.5); background: rgba(56, 189, 248, 0.1); }
.chip.active { color: #06121f; background: linear-gradient(135deg, var(--accent), var(--accent-2)); border-color: transparent; font-weight: 600; }

/* ---------- Cards ---------- */
.content { display: flex; flex-direction: column; gap: 16px; padding: 16px 0 30px; }
.card {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 20px 22px;
  backdrop-filter: blur(14px);
  box-shadow: var(--shadow);
}
.card-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 8px; margin-bottom: 12px; }
.card-head .muted { margin: 0; }

/* ---------- Hero ---------- */
.hero-card {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 18px;
  background:
    radial-gradient(600px 240px at 90% 0%, rgba(56, 189, 248, 0.14), transparent 65%),
    radial-gradient(420px 200px at 8% 110%, rgba(129, 140, 248, 0.12), transparent 60%),
    var(--card);
  padding: 26px 28px;
}
.hero-place { min-width: 200px; }
.hero-place h2 { font-size: 1.3rem; }
.hero-place .muted { margin: 3px 0 0; font-size: 0.85rem; }
.hero-main { display: flex; align-items: center; gap: 18px; }
.hero-temp { font-size: 4rem; font-weight: 800; line-height: 1; letter-spacing: -2px;
  background: linear-gradient(135deg, #7dd3fc, #a5b4fc);
  -webkit-background-clip: text; background-clip: text; color: transparent; }
.hero-temp sup { font-size: 1.6rem; font-weight: 600; letter-spacing: 0; }
.hero-desc { display: flex; flex-direction: column; gap: 2px; }
.hero-desc .desc { font-size: 1.05rem; font-weight: 600; }
.hero-desc .feels { font-size: 0.82rem; color: var(--text-2); }
.hero-icon { width: 84px; height: 84px; flex: none; }
.hero-stats { display: flex; gap: 10px; flex-wrap: wrap; }
.stat {
  min-width: 96px;
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid rgba(148, 163, 184, 0.12);
  border-radius: 13px;
  padding: 10px 14px;
}
.stat .label { font-size: 0.72rem; color: var(--text-3); display: flex; align-items: center; gap: 5px; }
.stat .value { font-size: 1.02rem; font-weight: 700; margin-top: 2px; }
.stat .value small { font-size: 0.72rem; color: var(--text-2); font-weight: 500; }

/* ---------- Charts ---------- */
.chart-holder { position: relative; }
.chart-holder svg { display: block; width: 100%; height: auto; }
.chart-card { overflow: hidden; }

.chart-tooltip {
  position: absolute; pointer-events: none; z-index: 20;
  background: #0d1530fa;
  border: 1px solid rgba(56, 189, 248, 0.35);
  border-radius: 11px;
  padding: 9px 12px;
  font-size: 0.78rem;
  box-shadow: var(--shadow);
  white-space: nowrap;
  transform: translate(-50%, calc(-100% - 14px));
}
.chart-tooltip .tt-time { color: var(--text-2); font-size: 0.72rem; margin-bottom: 3px; }
.chart-tooltip .tt-row { display: flex; align-items: center; gap: 7px; }
.chart-tooltip .tt-dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }

.legend { display: flex; flex-wrap: wrap; gap: 12px; font-size: 0.74rem; color: var(--text-2); }
.legend-item { display: flex; align-items: center; gap: 6px; }
.swatch { width: 14px; height: 9px; border-radius: 3px; display: inline-block; }
.swatch-mean { background: linear-gradient(90deg, #38bdf8, #818cf8); height: 3px; border-radius: 2px; }
.swatch-p90 { background: rgba(56, 189, 248, 0.28); }
.swatch-minmax { background: rgba(56, 189, 248, 0.12); }
.swatch-rain { background: rgba(96, 165, 250, 0.75); }
.swatch-prob { background: #fbbf24; height: 3px; border-radius: 2px; }

/* axis text */
.axis-text { font-size: 11px; fill: var(--text-3); font-family: inherit; }
.axis-text.day-label { fill: var(--text-2); font-weight: 600; }

/* ---------- Daily list ---------- */
.daily-list { display: flex; flex-direction: column; }
.daily-row {
  display: grid;
  grid-template-columns: 108px 34px 1fr 150px 84px;
  align-items: center; gap: 12px;
  padding: 11px 6px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.08);
}
.daily-row:last-child { border-bottom: none; }
.daily-row .d-date { font-size: 0.85rem; }
.daily-row .d-date .d-dow { font-weight: 700; }
.daily-row .d-date .d-md { color: var(--text-2); font-size: 0.76rem; }
.daily-row .d-icon { width: 30px; height: 30px; }
.daily-row .d-rain { font-size: 0.78rem; color: var(--rain); text-align: right; white-space: nowrap; }
.daily-row .d-rain.norain { color: var(--text-3); }
.daily-row .d-wind { font-size: 0.76rem; color: var(--text-2); text-align: right; white-space: nowrap; }

.d-range { position: relative; height: 8px; border-radius: 5px; background: rgba(148, 163, 184, 0.1); }
.d-range .r-members { position: absolute; top: -3px; height: 14px; border-radius: 7px; background: rgba(56, 189, 248, 0.14); }
.d-range .r-mean { position: absolute; top: 0; height: 8px; border-radius: 5px; background: linear-gradient(90deg, #38bdf8, #818cf8); }
.d-temps { display: flex; justify-content: space-between; font-size: 0.82rem; font-weight: 600; margin-top: 4px; }
.d-temps .t-min { color: var(--text-2); }
.daily-cell-temps { min-width: 150px; }

/* ---------- About ---------- */
.about-grid { display: grid; grid-template-columns: 1.2fr 1fr; gap: 20px; }
.about-text p { margin: 0 0 10px; font-size: 0.9rem; color: var(--text-2); }
.about-text strong { color: var(--text-1); }
.spec-table-wrap { overflow-x: auto; }
.spec-table { width: 100%; border-collapse: collapse; font-size: 0.82rem; }
.spec-table th, .spec-table td { text-align: left; padding: 7px 10px; border-bottom: 1px solid rgba(148, 163, 184, 0.1); }
.spec-table th { color: var(--text-3); font-weight: 500; white-space: nowrap; }
.spec-table td { color: var(--text-1); }
.spec-table tr:last-child th, .spec-table tr:last-child td { border-bottom: none; }
.about-links { font-size: 0.8rem; color: var(--text-2); margin: 14px 0 0; }
.howto {
  margin-top: 16px; padding: 14px 16px;
  background: rgba(56, 189, 248, 0.06);
  border: 1px solid rgba(56, 189, 248, 0.18);
  border-radius: 13px;
}
.howto h3 { margin-bottom: 8px; }
.howto ul { margin: 0; padding-left: 20px; }
.howto li { font-size: 0.84rem; color: var(--text-2); margin-bottom: 5px; }
.howto li strong { color: var(--text-1); }

/* ---------- Status ---------- */
.status-area { padding: 40px 0; }
.skeleton-block {
  height: 120px; border-radius: var(--radius);
  background: linear-gradient(100deg, rgba(148,163,184,0.07) 40%, rgba(148,163,184,0.15) 50%, rgba(148,163,184,0.07) 60%);
  background-size: 200% 100%;
  animation: shimmer 1.3s infinite;
  margin-bottom: 14px;
}
@keyframes shimmer { to { background-position: -200% 0; } }

.error-box {
  text-align: center; padding: 34px 20px;
  background: rgba(248, 113, 113, 0.07);
  border: 1px solid rgba(248, 113, 113, 0.3);
  border-radius: var(--radius);
}
.error-box p { color: var(--text-2); margin: 8px 0 16px; font-size: 0.9rem; }
.error-box .err-title { color: var(--danger); font-weight: 700; font-size: 1.02rem; }
.btn-retry {
  padding: 9px 22px; border-radius: 11px; border: none; cursor: pointer;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #06121f; font-weight: 700; font-family: inherit; font-size: 0.9rem;
  transition: transform 0.15s, opacity 0.15s;
}
.btn-retry:hover { transform: translateY(-1px); opacity: 0.92; }

/* ---------- Footer ---------- */
.site-footer {
  border-top: 1px solid rgba(148, 163, 184, 0.1);
  padding: 20px 0 34px; margin-top: 8px;
}
.site-footer p { font-size: 0.78rem; color: var(--text-3); margin: 0; text-align: center; }
.site-footer strong { color: var(--text-2); }

/* ---------- Refresh bar ---------- */
.refresh-bar {
  display: flex; align-items: center; gap: 10px;
  padding: 0 8px 2px;
}
.btn-refresh {
  width: 30px; height: 30px; border-radius: 50%; flex: none;
  display: grid; place-items: center;
  background: var(--card);
  border: 1px solid var(--card-border);
  color: var(--text-2); cursor: pointer;
  transition: color 0.15s, border-color 0.15s, opacity 0.15s;
}
.btn-refresh:hover { color: var(--accent); border-color: rgba(56, 189, 248, 0.5); }
.btn-refresh:disabled { opacity: 0.55; cursor: default; }
.btn-refresh.spinning svg { animation: rotate 0.9s linear infinite; }
@keyframes rotate { to { transform: rotate(360deg); } }

/* ---------- AQI card (compact) ---------- */
.aqi-card { padding: 14px 18px; }
.aqi-compact { display: flex; align-items: center; gap: 14px; }
.aqi-donut-sm { position: relative; width: 64px; height: 64px; flex: none; }
.aqi-donut-sm svg { display: block; width: 100%; height: 100%; }
.aqi-center-sm {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 1px;
}
.aqi-value-sm { font-size: 1.05rem; font-weight: 800; line-height: 1; }
.aqi-unit-sm { font-size: 0.52rem; color: var(--text-3); letter-spacing: 0.3px; }
.aqi-meta { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.aqi-level-line { display: flex; align-items: baseline; gap: 7px; }
.aqi-level { font-size: 1.02rem; font-weight: 700; }
.aqi-meta .muted strong { color: var(--text-1); }
.aqi-source { color: var(--text-3); font-size: 0.7rem; }

/* ---------- Responsive ---------- */
@media (max-width: 720px) {
  .brand-text p { display: none; }
  .hero-main { width: 100%; justify-content: space-between; }
  .hero-temp { font-size: 3.2rem; }
  .hero-icon { width: 64px; height: 64px; }
  .hero-stats { width: 100%; }
  .stat { flex: 1; min-width: 84px; }
  .daily-row { grid-template-columns: 84px 26px 1fr 70px; }
  .daily-row .d-wind { display: none; }
  .about-grid { grid-template-columns: 1fr; }
  .chart-card .card-head { flex-direction: column; align-items: flex-start; }
}
@media (max-width: 480px) {
  .daily-row { grid-template-columns: 74px 24px 1fr; }
  .daily-row .d-rain { display: none; }
  .hero-card { padding: 20px; }
}
