/*
 * WX Weather — Atmospheric Observatory
 * Deep navy-black with warm amber accents, card sections, elegant typography
 */

:root {
  --bg: #080b12;
  --bg-surface: #0e1219;
  --bg-card: #121821;
  --fg: #d4dae8;
  --fg-dim: #6d7a94;
  --fg-muted: #3a4562;
  --accent: #d4a04a;
  --accent-glow: rgba(212, 160, 74, 0.15);
  --precip: #5a9fd4;
  --precip-glow: rgba(90, 159, 212, 0.12);
  --warm: #d47040;
  --cool: #5a9fd4;
  --bar-bg: #1a2133;
  --border: #1c2438;
  --hover: #151c28;
  --card-border: #1e2740;
  --font-display: 'Playfair Display', Georgia, serif;
  --font: 'JetBrains Mono', 'SF Mono', 'Cascadia Code', monospace;
  --radius: 10px;
  --radius-sm: 6px;
}

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

body {
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font);
  font-size: 13px;
  font-weight: 400;
  line-height: 1.6;
  max-width: 960px;
  margin: 0 auto;
  padding: 24px 20px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Atmospheric background glow */
body::after {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  background:
    radial-gradient(ellipse at 30% -20%, rgba(90, 159, 212, 0.045) 0%, transparent 55%),
    radial-gradient(ellipse at 75% 110%, rgba(212, 160, 74, 0.035) 0%, transparent 50%);
  z-index: -1;
}

/* ═══════════════════════════════════════
   Header
   ═══════════════════════════════════════ */

header {
  margin-bottom: 28px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.header-row {
  display: flex;
  align-items: center;
  gap: 16px;
}

h1 {
  font-family: var(--font-display);
  font-size: 30px;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 1px;
  flex-shrink: 0;
  line-height: 1;
}

/* ═══════════════════════════════════════
   Search
   ═══════════════════════════════════════ */

.search-container {
  position: relative;
  flex: 1;
  max-width: 340px;
  display: flex;
}

#search-input {
  flex: 1;
  min-width: 0;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-right: none;
  border-radius: var(--radius-sm) 0 0 var(--radius-sm);
  color: var(--fg);
  font-family: var(--font);
  font-size: 13px;
  padding: 8px 12px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
}

#search-input:focus {
  border-color: var(--accent);
  background: var(--bg-card);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

#search-input::placeholder {
  color: var(--fg-muted);
}

.search-btn {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  color: var(--fg-dim);
  padding: 8px 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  transition: color 0.2s, border-color 0.2s;
}

.search-btn:hover {
  color: var(--accent);
  border-color: var(--accent);
}

.result-name {
  color: var(--fg);
}

.result-detail {
  color: var(--fg-dim);
  font-size: 12px;
}

/* Search results page */

.search-results-page {
  padding: 24px 0;
}

.search-results-prompt {
  color: var(--fg-dim);
  margin-bottom: 16px;
}

.search-results-page-list {
  list-style: none;
  background: var(--bg-card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  overflow: hidden;
}

.search-results-page-item {
  padding: 12px 16px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  gap: 8px;
  border-bottom: 1px solid var(--border);
  transition: background 0.15s;
}

.search-results-page-item:last-child {
  border-bottom: none;
}

.search-results-page-item:hover {
  background: var(--hover);
}

/* ═══════════════════════════════════════
   Loading & Prompt
   ═══════════════════════════════════════ */

.loading {
  padding: 64px 0;
  color: var(--fg-dim);
  text-align: center;
}

.loading-text {
  animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

.prompt {
  padding: 64px 0;
  color: var(--fg-dim);
  text-align: center;
}

.error-msg {
  padding: 20px;
  color: var(--warm);
  background: rgba(212, 112, 64, 0.07);
  border: 1px solid rgba(212, 112, 64, 0.18);
  border-radius: var(--radius);
}

/* ═══════════════════════════════════════
   Forecast Layout
   ═══════════════════════════════════════ */

.forecast {
  animation: fadeIn 0.35s ease-out;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.location-header {
  margin-bottom: 24px;
  display: flex;
  align-items: baseline;
  gap: 12px;
  flex-wrap: wrap;
}

.location-name {
  font-size: 16px;
  font-weight: 600;
  color: var(--fg);
  text-transform: uppercase;
  letter-spacing: 1.5px;
}

.location-meta {
  color: var(--fg-dim);
  font-size: 12px;
}

/* ═══════════════════════════════════════
   Buttons
   ═══════════════════════════════════════ */

.locate-btn {
  margin-left: auto;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--fg-dim);
  padding: 6px 8px;
  cursor: pointer;
  line-height: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.locate-btn:hover {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-glow);
}

.settings-btn {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--fg-dim);
  font-size: 16px;
  padding: 5px 9px;
  cursor: pointer;
  line-height: 1;
  transition: all 0.2s;
}

.settings-btn:hover {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-glow);
}

/* ═══════════════════════════════════════
   Settings Panel
   ═══════════════════════════════════════ */

.settings-panel {
  display: none;
  background: var(--bg-card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 16px 20px;
  margin-bottom: 20px;
  animation: fadeIn 0.2s ease-out;
}

.settings-panel.open {
  display: block;
}

.settings-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}

.settings-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: var(--accent);
}

.settings-close {
  background: none;
  border: none;
  color: var(--fg-muted);
  font-size: 20px;
  cursor: pointer;
  line-height: 1;
  padding: 0 2px;
  transition: color 0.2s;
}

.settings-close:hover {
  color: var(--fg);
}

.settings-group {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}

.settings-group:last-child {
  margin-bottom: 0;
}

.settings-label {
  color: var(--fg-dim);
  font-size: 12px;
  min-width: 100px;
}

.settings-options {
  display: flex;
  gap: 0;
}

.settings-option {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  color: var(--fg-dim);
  font-family: var(--font);
  font-size: 12px;
  padding: 5px 14px;
  cursor: pointer;
  transition: all 0.2s;
}

.settings-option:first-child {
  border-right: none;
  border-radius: var(--radius-sm) 0 0 var(--radius-sm);
}

.settings-option:last-child {
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

.settings-option:hover {
  color: var(--fg);
}

.settings-option.active {
  background: rgba(212, 160, 74, 0.14);
  color: var(--accent);
  border-color: var(--accent);
  font-weight: 500;
}

/* ═══════════════════════════════════════
   Favorites Bar
   ═══════════════════════════════════════ */

.favorites-bar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 20px;
  padding: 0;
}

.fav-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-card);
  border: 1px solid var(--card-border);
  border-radius: 20px;
  color: var(--fg-dim);
  font-family: var(--font);
  font-size: 12px;
  padding: 5px 14px;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s;
}

.fav-item:hover {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-glow);
}

.fav-remove {
  color: var(--fg-muted);
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  transition: color 0.2s;
}

.fav-remove:hover {
  color: var(--warm);
}

/* Star/favorite toggle */

.fav-star {
  background: none;
  border: none;
  color: var(--fg-muted);
  font-size: 20px;
  cursor: pointer;
  padding: 0 2px;
  line-height: 1;
  vertical-align: middle;
  transition: all 0.25s;
}

.fav-star:hover {
  color: var(--accent);
  filter: drop-shadow(0 0 6px var(--accent-glow));
}

.fav-star-active {
  color: var(--accent);
  filter: drop-shadow(0 0 4px var(--accent-glow));
}

/* ═══════════════════════════════════════
   Sections (Card containers)
   ═══════════════════════════════════════ */

.section {
  margin-bottom: 24px;
  background: var(--bg-card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 18px 0 0;
  overflow: hidden;
  animation: sectionIn 0.4s ease-out both;
}

.forecast section:nth-of-type(1) { animation-delay: 0.04s; }
.forecast section:nth-of-type(2) { animation-delay: 0.12s; }
.forecast section:nth-of-type(3) { animation-delay: 0.2s; }

@keyframes sectionIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

h2 {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 2.5px;
  color: var(--accent);
  margin: 0 0 12px;
  padding: 0 20px 10px;
  border-bottom: 1px solid var(--border);
}

/* ═══════════════════════════════════════
   Tables
   ═══════════════════════════════════════ */

.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

thead th {
  text-align: left;
  color: var(--fg-muted);
  font-weight: 500;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1px;
  padding: 6px 10px;
  border-bottom: 1px solid var(--border);
}

thead th:first-child { padding-left: 20px; }
thead th:last-child { padding-right: 20px; }

thead th.num {
  text-align: right;
}

td {
  padding: 7px 10px;
  border-bottom: 1px solid rgba(28, 36, 56, 0.5);
}

td:first-child { padding-left: 20px; }
td:last-child { padding-right: 20px; }

td.num {
  text-align: right;
}

tbody tr:last-child td {
  border-bottom: none;
}

/* ═══════════════════════════════════════
   Show More Toggle
   ═══════════════════════════════════════ */

.hidden { display: none; }

.show-more-cell {
  text-align: center;
  border-bottom: none !important;
  padding: 10px 20px;
}

.show-more-btn {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--fg-dim);
  font-family: var(--font);
  font-size: 12px;
  padding: 6px 18px;
  cursor: pointer;
  transition: all 0.2s;
}

.show-more-btn:hover {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-glow);
}

/* ═══════════════════════════════════════
   Row Highlight (current hour / today)
   ═══════════════════════════════════════ */

.row-now {
  background: rgba(212, 160, 74, 0.055);
}

.row-now td:first-child {
  box-shadow: inset 3px 0 0 var(--accent);
}

/* ═══════════════════════════════════════
   Hourly Table
   ═══════════════════════════════════════ */

.time-col { color: var(--fg-dim); }
.temp { color: var(--fg); font-weight: 600; }
.feels { color: var(--fg-dim); }
.wind { color: var(--fg-dim); }
.cond { color: var(--fg-dim); font-size: 12px; }

.has-precip {
  color: var(--precip) !important;
  font-weight: 600;
}

/* ═══════════════════════════════════════
   Daily Table — Temperature Bars
   ═══════════════════════════════════════ */

.bar-header {
  min-width: 220px;
}

.bar-cell {
  min-width: 220px;
  padding: 7px 10px;
}

.temp-bar-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.temp-low {
  width: 36px;
  text-align: right;
  font-size: 12px;
  font-weight: 400;
}

.temp-high {
  width: 36px;
  font-size: 12px;
  font-weight: 600;
}

.temp-bar-track {
  flex: 1;
  height: 8px;
  background: var(--bar-bg);
  border-radius: 4px;
  position: relative;
  min-width: 80px;
}

.temp-bar-fill {
  position: absolute;
  top: 0;
  height: 100%;
  border-radius: 4px;
  box-shadow: 0 0 10px rgba(255, 255, 255, 0.04);
  animation: barGrow 0.6s ease-out both;
  transform-origin: left center;
}

@keyframes barGrow {
  from { transform: scaleX(0); opacity: 0.3; }
  to { transform: scaleX(1); opacity: 1; }
}

.day-col {
  font-weight: 600;
  min-width: 90px;
}

/* ═══════════════════════════════════════
   Precipitation Section
   ═══════════════════════════════════════ */

.precip-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 0 20px 10px;
  margin-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.precip-header h2 {
  margin-bottom: 0;
  padding: 0;
  border-bottom: none;
}

.precip-total {
  color: var(--precip);
  font-weight: 600;
  font-size: 14px;
}

.precip-table {
  text-align: center;
}

.precip-table th {
  text-align: center;
  min-width: 64px;
}

.precip-bar-cell {
  text-align: center;
  vertical-align: bottom;
  padding: 7px 10px;
}

.micro-bar {
  width: 100%;
  max-width: 36px;
  margin: 0 auto 4px;
  background: var(--precip);
  opacity: 0.4;
  border-radius: 2px;
  transition: height 0.3s ease;
}

.row-label {
  text-align: left !important;
  color: var(--fg-dim);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1px;
  width: 50px;
}

.cumul-val {
  text-align: center;
  color: var(--fg-muted);
  font-size: 12px;
}

.precip-bars-row td span {
  font-size: 12px;
}

/* ═══════════════════════════════════════
   Nearby City Picker
   ═══════════════════════════════════════ */

.nearby-picker {
  padding: 24px 0;
  animation: fadeIn 0.35s ease-out;
}

.nearby-prompt {
  color: var(--fg-dim);
  margin-bottom: 16px;
}

.nearby-list {
  list-style: none;
  background: var(--bg-card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  margin-bottom: 16px;
  overflow: hidden;
}

.nearby-item {
  padding: 12px 16px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  gap: 8px;
  border-bottom: 1px solid var(--border);
  transition: background 0.15s;
}

.nearby-item:last-child {
  border-bottom: none;
}

.nearby-item:hover {
  background: var(--hover);
}

.nearby-exact {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--fg-dim);
  font-family: var(--font);
  font-size: 12px;
  padding: 8px 16px;
  cursor: pointer;
  transition: all 0.2s;
}

.nearby-exact:hover {
  color: var(--accent);
  border-color: var(--accent);
}

/* ═══════════════════════════════════════
   Footer
   ═══════════════════════════════════════ */

.site-footer {
  margin-top: 48px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  color: var(--fg-muted);
  font-size: 11px;
}

.site-footer a {
  color: var(--fg-dim);
  text-decoration: none;
  transition: color 0.2s;
}

.site-footer a:hover {
  color: var(--accent);
}

/* ═══════════════════════════════════════
   Clickable Daily Rows
   ═══════════════════════════════════════ */

.daily-row {
  cursor: pointer;
  transition: background 0.15s;
}

.daily-row:hover {
  background: var(--hover);
}

.daily-row:hover td:first-child {
  box-shadow: inset 3px 0 0 var(--fg-dim);
}

.daily-row.row-now:hover td:first-child {
  box-shadow: inset 3px 0 0 var(--accent);
}

/* ═══════════════════════════════════════
   Day Detail View
   ═══════════════════════════════════════ */

.day-forecast {
  animation: fadeIn 0.35s ease-out;
}

.day-header {
  margin-bottom: 24px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
}

.back-link {
  color: var(--accent);
  text-decoration: none;
  font-size: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 5px 14px;
  transition: all 0.2s;
}

.back-link:hover {
  background: var(--accent-glow);
  border-color: var(--accent);
}

.day-overview h2 {
  font-family: var(--font-display);
  font-size: 22px;
  letter-spacing: 0;
  text-transform: none;
  color: var(--fg);
  padding: 0 20px 0;
  margin-bottom: 16px;
  border-bottom: none;
}

.day-summary {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 0 20px 16px;
}

.day-temps {
  max-width: 300px;
}

.day-bar-track {
  min-width: 120px;
}

.day-details {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
}

.day-detail {
  color: var(--fg-dim);
  font-size: 13px;
}

.day-detail strong {
  color: var(--fg-muted);
  font-weight: 400;
}

.day-nav {
  display: flex;
  justify-content: space-between;
  padding: 16px 0;
  border-top: 1px solid var(--border);
  margin-top: 20px;
}

.day-nav-link {
  color: var(--fg-dim);
  text-decoration: none;
  font-size: 12px;
  transition: color 0.2s;
}

.day-nav-link:hover {
  color: var(--accent);
}

.day-nav-link.disabled {
  visibility: hidden;
}

.no-data {
  color: var(--fg-dim);
  font-style: italic;
  padding: 20px;
}

/* ═══════════════════════════════════════
   Responsive
   ═══════════════════════════════════════ */

@media (max-width: 600px) {
  body {
    padding: 14px 10px;
    font-size: 12px;
  }

  h1 {
    font-size: 24px;
  }

  .header-row {
    flex-wrap: wrap;
    gap: 10px;
  }

  .search-container {
    max-width: 100%;
    order: 3;
    flex-basis: 100%;
  }

  .section {
    border-radius: 8px;
    padding-top: 14px;
  }

  h2 {
    padding: 0 14px 8px;
  }

  thead th:first-child,
  td:first-child {
    padding-left: 14px;
  }

  thead th:last-child,
  td:last-child {
    padding-right: 14px;
  }

  .precip-header {
    padding: 0 14px 8px;
  }

  .day-overview h2 {
    padding: 0 14px 0;
    font-size: 18px;
  }

  .day-summary {
    padding: 0 14px 14px;
  }

  .bar-cell, .bar-header {
    min-width: 180px;
  }

  .show-more-cell {
    padding: 8px 14px;
  }

  .no-data {
    padding: 16px 14px;
  }
}
