/* ============================================================
   FastWeather — style.css
   Mobile-first. System fonts. No images. Dark/light/auto.
   ============================================================ */

/* --- Custom properties (light mode defaults) --- */
:root {
  --bg:               #f8fafc;
  --surface:          #ffffff;
  --text:             #0f172a;
  --text-muted:       #64748b;
  --accent:           #0284c7;
  --accent-dim:       #e0f2fe;
  --border:           #e2e8f0;
  --btn-bg:           #e2e8f0;
  --btn-text:         #334155;
  --btn-active-bg:    #0284c7;
  --btn-active-text:  #ffffff;
  --shadow:           0 1px 4px rgba(0, 0, 0, 0.08);
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, Arial, sans-serif;
  --radius: 10px;
}

/* --- Dark mode: via system preference --- */
@media (prefers-color-scheme: dark) {
  :root {
    --bg:               #0f172a;
    --surface:          #1e293b;
    --text:             #f1f5f9;
    --text-muted:       #94a3b8;
    --accent:           #38bdf8;
    --accent-dim:       #0c4a6e;
    --border:           #334155;
    --btn-bg:           #334155;
    --btn-text:         #cbd5e1;
    --btn-active-bg:    #38bdf8;
    --btn-active-text:  #0f172a;
    --shadow:           0 1px 4px rgba(0, 0, 0, 0.4);
  }
}

/* --- Dark mode: explicit user override --- */
[data-theme="dark"] {
  --bg:               #0f172a;
  --surface:          #1e293b;
  --text:             #f1f5f9;
  --text-muted:       #94a3b8;
  --accent:           #38bdf8;
  --accent-dim:       #0c4a6e;
  --border:           #334155;
  --btn-bg:           #334155;
  --btn-text:         #cbd5e1;
  --btn-active-bg:    #38bdf8;
  --btn-active-text:  #0f172a;
  --shadow:           0 1px 4px rgba(0, 0, 0, 0.4);
}

/* --- Light mode: explicit user override --- */
[data-theme="light"] {
  --bg:               #f8fafc;
  --surface:          #ffffff;
  --text:             #0f172a;
  --text-muted:       #64748b;
  --accent:           #0284c7;
  --accent-dim:       #e0f2fe;
  --border:           #e2e8f0;
  --btn-bg:           #e2e8f0;
  --btn-text:         #334155;
  --btn-active-bg:    #0284c7;
  --btn-active-text:  #ffffff;
  --shadow:           0 1px 4px rgba(0, 0, 0, 0.08);
}

/* --- Reset --- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  transition: background 0.2s ease, color 0.2s ease;
}

/* --- App shell --- */
#app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

/* --- Header --- */
#header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.6rem 1rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
  box-shadow: var(--shadow);
}

.location-btn {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  background: none;
  border: none;
  color: var(--text);
  font-family: var(--font);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  min-height: 44px;
  padding: 0 0.25rem;
  border-radius: 6px;
  transition: background 0.15s;
}
.location-btn:hover { background: var(--btn-bg); }

.header-actions {
  display: flex;
  gap: 0.25rem;
}

.icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  min-height: 44px;
  background: none;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 1.2rem;
  color: var(--text);
  transition: background 0.15s;
}
.icon-btn:hover { background: var(--btn-bg); }

/* --- Main --- */
#main {
  flex: 1;
  padding: 1.5rem 1rem 1rem;
}

/* --- Loading --- */
.loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 4rem 0;
  color: var(--text-muted);
  gap: 0.75rem;
}
.loading span {
  font-size: 3rem;
  animation: sway 2.5s ease-in-out infinite;
  display: block;
}
@keyframes sway {
  0%, 100% { transform: translateY(0); opacity: 1; }
  50%       { transform: translateY(-6px); opacity: 0.6; }
}

/* --- Current conditions --- */
.current {
  text-align: center;
  padding: 0.5rem 0 1.75rem;
}

.current-primary {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
  line-height: 1;
  margin-bottom: 0.2rem;
}

.condition-emoji {
  font-size: 3.25rem;
}

.temp-big {
  font-size: 5rem;
  font-weight: 200;
  letter-spacing: -3px;
  line-height: 1;
}

.condition-label {
  font-size: 1.05rem;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
  letter-spacing: 0.01em;
}

.current-details {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.4rem 1rem;
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-bottom: 0.9rem;
  min-height: 1.4rem;
}

.hilo {
  display: flex;
  justify-content: center;
  gap: 1.75rem;
  font-size: 1.05rem;
  font-weight: 500;
}

/* --- Forecast sections --- */
.forecast-section {
  margin-top: 1.25rem;
  border-top: 1px solid var(--border);
  padding-top: 1rem;
}

.section-label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
}

/* --- Hourly scroll --- */
.hourly-scroll {
  display: flex;
  gap: 0.4rem;
  overflow-x: auto;
  padding-bottom: 0.5rem;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
.hourly-scroll::-webkit-scrollbar { height: 4px; }
.hourly-scroll::-webkit-scrollbar-track { background: transparent; }
.hourly-scroll::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.hour-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
  min-width: 54px;
  flex-shrink: 0;
  background: var(--surface);
  border-radius: var(--radius);
  padding: 0.55rem 0.25rem;
  box-shadow: var(--shadow);
}
.hour-label   { font-size: 0.68rem; color: var(--text-muted); white-space: nowrap; }
.hour-emoji   { font-size: 1.4rem; }
.hour-temp    { font-size: 0.875rem; font-weight: 600; }
.hour-precip  { font-size: 0.68rem; color: var(--accent); min-height: 0.9rem; }

/* --- Daily list --- */
.day-row {
  display: grid;
  grid-template-columns: 3.25rem 1.75rem 1fr auto;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.925rem;
}
.day-row:last-child { border-bottom: none; }
.day-label  { font-weight: 600; }
.day-emoji  { font-size: 1.2rem; text-align: center; }
.day-temps  { color: var(--text-muted); font-size: 0.875rem; }
.day-precip { color: var(--accent); font-size: 0.8rem; text-align: right; }

/* --- Error --- */
.error {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 4rem 0;
  gap: 1rem;
  color: var(--text-muted);
}

.btn {
  background: var(--accent);
  color: white;
  border: none;
  border-radius: var(--radius);
  padding: 0.6rem 1.5rem;
  font-size: 0.95rem;
  font-family: var(--font);
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
}
.btn:hover { opacity: 0.88; }

/* --- Settings overlay + panel (bottom sheet) --- */
.settings-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: 100;
  display: flex;
  align-items: flex-end;
  animation: fade-in 0.15s ease;
}

@keyframes fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.settings-panel {
  background: var(--surface);
  border-radius: 18px 18px 0 0;
  padding: 1.25rem 1rem calc(1.5rem + env(safe-area-inset-bottom));
  width: 100%;
  max-height: 85dvh;
  overflow-y: auto;
  animation: slide-up 0.2s ease;
}

@keyframes slide-up {
  from { transform: translateY(20px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

.settings-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border);
}

.setting-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.7rem 0;
  border-bottom: 1px solid var(--border);
  gap: 0.5rem;
  font-size: 0.9rem;
  font-weight: 500;
}
.setting-row:last-child { border-bottom: none; }

.setting-row--column {
  flex-direction: column;
  align-items: flex-start;
  gap: 0.5rem;
}

/* Toggle buttons */
.toggle-group {
  display: flex;
  gap: 0.3rem;
  flex-wrap: wrap;
}

.toggle-btn {
  background: var(--btn-bg);
  color: var(--btn-text);
  border: none;
  border-radius: 6px;
  padding: 0.3rem 0.65rem;
  font-size: 0.82rem;
  font-family: var(--font);
  font-weight: 500;
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
  white-space: nowrap;
}
.toggle-btn.active {
  background: var(--btn-active-bg);
  color: var(--btn-active-text);
  font-weight: 700;
}

/* Checkboxes */
.checkbox-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 1.25rem;
}
.checkbox-group label {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.875rem;
  cursor: pointer;
}
.checkbox-group input[type="checkbox"] {
  accent-color: var(--accent);
  width: 16px;
  height: 16px;
}

/* Location input */
.location-input-group {
  display: flex;
  gap: 0.5rem;
  width: 100%;
}
.location-input-group input {
  flex: 1;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.5rem 0.75rem;
  font-size: 0.95rem;
  font-family: var(--font);
  color: var(--text);
  min-height: 44px;
  transition: border-color 0.15s;
}
.location-input-group input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-dim);
}

.btn-sm {
  background: var(--accent);
  color: white;
  border: none;
  border-radius: var(--radius);
  padding: 0 1rem;
  font-size: 0.9rem;
  font-family: var(--font);
  font-weight: 600;
  cursor: pointer;
  min-height: 44px;
  white-space: nowrap;
  transition: opacity 0.15s;
}
.btn-sm:hover { opacity: 0.88; }

.settings-status {
  font-size: 0.82rem;
  color: var(--accent);
  min-height: 1.1em;
}
.settings-status.error { color: #ef4444; }

/* --- Footer --- */
#footer {
  display: flex;
  justify-content: space-between;
  padding: 0.5rem 1rem calc(0.5rem + env(safe-area-inset-bottom));
  font-size: 0.72rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
}

/* --- Utility --- */
.hidden { display: none !important; }
