/* Meteobit — 8-bit / CRT aesthetic */
:root {
  --bg-0: #070912;
  --bg-1: #0b0f1a;
  --bg-2: #121a33;
  --ink: #eaf1ff;
  --ink-dim: #8fa7d4;
  --accent: #5cf0c6;   /* arcade mint */
  --accent-2: #ffd24a; /* coin yellow */
  --danger: #ff5470;   /* neon pink */
  --cyan: #56d1ff;
  --violet: #b388ff;
  --border: #24305f;
  --border-hi: #3b4f9c;
  --pixel: 2px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --font-display: 'Press Start 2P', ui-monospace, 'Courier New', monospace;
  --font-text: 'VT323', ui-monospace, 'Courier New', monospace;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
html { background: var(--bg-0); }

body {
  font-family: var(--font-text);
  color: var(--ink);
  background:
    radial-gradient(1000px 600px at 20% -10%, rgba(92,240,198,0.08), transparent 60%),
    radial-gradient(800px 500px at 120% 10%, rgba(179,136,255,0.10), transparent 60%),
    linear-gradient(180deg, #05070f 0%, #0a0f20 60%, #070912 100%);
  overflow-x: hidden;
  -webkit-font-smoothing: none;
  font-smooth: never;
  image-rendering: pixelated;
  -webkit-tap-highlight-color: transparent;
}

/* Decorative overlays */
.scanlines,
.vignette {
  position: fixed; inset: 0; pointer-events: none; z-index: 2;
}
.scanlines {
  background-image: repeating-linear-gradient(
    to bottom,
    rgba(255, 255, 255, 0.04) 0 1px,
    transparent 1px 3px
  );
  mix-blend-mode: overlay;
  opacity: 0.6;
  animation: flicker 6s infinite steps(60);
}
.vignette {
  background:
    radial-gradient(120% 90% at 50% 50%, transparent 55%, rgba(0,0,0,0.6) 100%);
}

@keyframes flicker {
  0%, 97%, 100% { opacity: 0.6; }
  98% { opacity: 0.35; }
  99% { opacity: 0.8; }
}

/* Layout */
main.crt {
  position: relative;
  z-index: 1;
  width: min(100%, 720px);
  max-width: 720px;
  margin: 0 auto;
  padding:
    calc(14px + var(--safe-top))
    clamp(14px, 4vw, 24px)
    calc(24px + var(--safe-bottom));
  display: grid;
  gap: 14px;
}

main.crt > * {
  min-width: 0;
}

/* Pixel cards */
.card {
  background: linear-gradient(180deg, rgba(18,26,51,0.9), rgba(11,15,26,0.9));
  border: var(--pixel) solid var(--border-hi);
  box-shadow:
    0 0 0 var(--pixel) #000,
    inset 0 0 0 var(--pixel) #0c1430,
    0 10px 0 0 rgba(0,0,0,0.35);
  padding: 16px;
  border-radius: 2px;
  position: relative;
}
.card::before {
  /* pixel corner notches */
  content: "";
  position: absolute; inset: -4px;
  background:
    linear-gradient(#000,#000) top left / 4px 4px no-repeat,
    linear-gradient(#000,#000) top right / 4px 4px no-repeat,
    linear-gradient(#000,#000) bottom left / 4px 4px no-repeat,
    linear-gradient(#000,#000) bottom right / 4px 4px no-repeat;
  pointer-events: none;
}

/* Topbar */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px;
  padding: 4px 2px;
}
.topbar > * { min-width: 0; }
.brand {
  display: flex; align-items: center; gap: 10px;
}
.brand-logo {
  display: inline-grid; place-items: center;
  width: 36px; height: 36px;
  background: #0c1430;
  border: var(--pixel) solid var(--border-hi);
  box-shadow: 0 0 0 var(--pixel) #000;
  animation: pixelbob 3.5s ease-in-out infinite;
}
@keyframes pixelbob {
  0%,100% { transform: translateY(0); }
  50%     { transform: translateY(-2px); }
}
.brand h1 {
  font-family: var(--font-display);
  font-size: clamp(14px, 4.2vw, 18px);
  letter-spacing: 2px;
  margin: 0;
  color: var(--accent);
  text-shadow:
    0 0 2px #0f0,
    0 0 10px rgba(92,240,198,0.35),
    2px 2px 0 #0b0f1a;
}

.btn-ghost, .btn-primary, .linkbtn {
  font-family: var(--font-display);
  font-size: 10px;
  letter-spacing: 1px;
  cursor: pointer;
  border: var(--pixel) solid var(--border-hi);
  background: #0c1430;
  color: var(--ink);
  padding: 8px 10px;
  border-radius: 2px;
  box-shadow:
    0 0 0 var(--pixel) #000,
    0 3px 0 0 #000;
  transition: transform 80ms steps(2), box-shadow 80ms steps(2), background 120ms;
  display: inline-flex; align-items: center; gap: 8px;
  image-rendering: pixelated;
}
.btn-ghost:hover, .btn-primary:hover { background: #121c44; }
.btn-ghost:active, .btn-primary:active {
  transform: translateY(3px);
  box-shadow: 0 0 0 var(--pixel) #000, 0 0 0 0 #000;
}
.btn-primary {
  background: var(--accent);
  color: #052017;
  border-color: #1a7b60;
  text-shadow: 1px 1px 0 rgba(255,255,255,0.25);
}
.btn-primary:hover { filter: brightness(1.05); background: var(--accent); }

.pixel-icon { color: var(--accent-2); }

.linkbtn {
  background: transparent;
  border: none;
  box-shadow: none;
  padding: 0;
  color: var(--ink-dim);
}
.linkbtn:hover { color: var(--accent); }

/* Search */
.search-wrap {
  display: flex; align-items: center; gap: 8px;
  background: #0c1430;
  border: var(--pixel) solid var(--border-hi);
  box-shadow: 0 0 0 var(--pixel) #000, inset 0 0 0 1px #0a1130;
  padding: 10px 12px;
  border-radius: 2px;
}
.search-wrap > * { min-width: 0; }
.prompt { color: var(--accent); font-family: var(--font-display); font-size: 12px; }
#q {
  flex: 1;
  background: transparent;
  border: 0;
  outline: none;
  color: var(--ink);
  font-family: var(--font-text);
  font-size: 22px;
  letter-spacing: 1px;
  caret-color: var(--accent);
  min-width: 0;
}
#q::placeholder { color: #4f6aa8; }

.suggestions {
  list-style: none; margin: 8px 0 0; padding: 0;
  background: #0c1430;
  border: var(--pixel) solid var(--border-hi);
  box-shadow: 0 0 0 var(--pixel) #000;
  max-height: 240px; overflow: auto;
  border-radius: 2px;
}
.suggestions li {
  padding: 10px 12px;
  cursor: pointer;
  font-size: 18px;
  display: flex; justify-content: space-between; gap: 12px;
  border-bottom: 1px dashed #1a2552;
}
.suggestions li:last-child { border-bottom: 0; }
.suggestions li:hover,
.suggestions li[aria-selected="true"] {
  background: #121c44;
  color: var(--accent);
}
.suggestions li .muted { color: var(--ink-dim); font-size: 14px; }

/* Status */
.status {
  font-size: 18px;
  color: var(--ink-dim);
  min-height: 22px;
  padding: 0 2px;
}
.status.error { color: var(--danger); }
.status .load-dots::after {
  content: '';
  display: inline-block;
  animation: dots 1.2s steps(4) infinite;
}
@keyframes dots {
  0%   { content: ''; }
  25%  { content: '.'; }
  50%  { content: '..'; }
  75%  { content: '...'; }
  100% { content: ''; }
}

/* Current */
.current-head {
  display: flex; justify-content: space-between; align-items: flex-start;
  gap: 12px;
}
.current-head > *,
.current-body > *,
.stats > div,
.daily li > * {
  min-width: 0;
}
.eyebrow {
  font-family: var(--font-display);
  font-size: 9px;
  letter-spacing: 2px;
  margin: 0 0 6px;
  color: var(--accent-2);
}
.place {
  font-family: var(--font-display);
  font-size: clamp(14px, 4.5vw, 18px);
  margin: 0;
  color: var(--ink);
  text-shadow: 2px 2px 0 #000;
}
.time { margin: 4px 0 0; font-size: 18px; color: var(--ink-dim); }
.current-icon {
  width: 84px; height: 84px;
  display: grid; place-items: center;
  image-rendering: pixelated;
  filter: drop-shadow(0 0 6px rgba(92,240,198,0.35));
  animation: iconfloat 4s ease-in-out infinite;
}
@keyframes iconfloat {
  0%,100% { transform: translateY(0); }
  50%     { transform: translateY(-3px); }
}

.current-body {
  display: flex; align-items: baseline; gap: 16px;
  margin-top: 8px;
}
.temp {
  font-family: var(--font-display);
  font-size: clamp(48px, 14vw, 76px);
  color: var(--accent);
  text-shadow:
    0 0 2px #0f0,
    0 0 14px rgba(92,240,198,0.35),
    3px 3px 0 #000;
  line-height: 1;
}
.temp-unit { font-size: 0.5em; color: var(--accent-2); margin-left: 2px; }
.condition {
  font-size: 22px;
  color: var(--ink);
  letter-spacing: 1px;
  text-transform: uppercase;
}

.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin: 14px 0 0;
  padding: 0;
}
.stats > div {
  background: #0a1130;
  border: var(--pixel) solid var(--border);
  box-shadow: inset 0 0 0 1px #000;
  padding: 8px;
  text-align: center;
}
.stats dt {
  font-family: var(--font-display);
  font-size: 8px;
  color: var(--ink-dim);
  letter-spacing: 1.5px;
  margin-bottom: 4px;
}
.stats dd {
  margin: 0;
  font-size: 20px;
  color: var(--ink);
}
@media (max-width: 420px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
}

/* Panels */
.panel-title {
  font-family: var(--font-display);
  font-size: 10px;
  letter-spacing: 2px;
  color: var(--cyan);
  margin: 0 0 10px;
  text-shadow: 0 0 6px rgba(86,209,255,0.35);
}

/* Hourly row */
.hourly {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  padding-bottom: 6px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
}
.hourly::-webkit-scrollbar { height: 6px; }
.hourly::-webkit-scrollbar-thumb { background: var(--border-hi); border-radius: 0; }
.hour {
  flex: 0 0 auto;
  width: 76px;
  padding: 10px 6px;
  text-align: center;
  background: #0a1130;
  border: var(--pixel) solid var(--border);
  scroll-snap-align: start;
  animation: pop 280ms steps(4);
}
.hour .h-time {
  font-family: var(--font-display);
  font-size: 8px;
  color: var(--ink-dim);
  letter-spacing: 1px;
  margin-bottom: 4px;
}
.hour .h-icon { width: 28px; height: 28px; margin: 0 auto 4px; image-rendering: pixelated; }
.hour .h-temp { font-size: 20px; color: var(--ink); }
.hour .h-pop {
  font-family: var(--font-display);
  font-size: 8px;
  color: var(--cyan);
  margin-top: 2px;
}

@keyframes pop {
  0%   { transform: translateY(4px); opacity: 0; }
  100% { transform: translateY(0); opacity: 1; }
}

/* Daily list */
.daily {
  list-style: none;
  margin: 0; padding: 0;
  display: grid; gap: 6px;
}
.daily li {
  display: grid;
  grid-template-columns: 80px 40px 1fr 90px;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  background: #0a1130;
  border: var(--pixel) solid var(--border);
  font-size: 20px;
}
.daily li .d-day {
  font-family: var(--font-display);
  font-size: 9px;
  letter-spacing: 1px;
  color: var(--accent-2);
}
.daily li .d-icon { width: 24px; height: 24px; image-rendering: pixelated; }
.daily li .d-bar {
  position: relative;
  height: 8px;
  background: #050a1d;
  border: 1px solid var(--border);
}
.daily li .d-bar .d-range {
  position: absolute;
  top: 0; bottom: 0;
  background: linear-gradient(90deg, var(--cyan), var(--accent), var(--accent-2));
  box-shadow: 0 0 6px rgba(92,240,198,0.4);
}
.daily li .d-temps {
  text-align: right;
  white-space: nowrap;
}
.daily li .d-temps .lo { color: var(--ink-dim); }
.daily li .d-temps .hi { color: var(--ink); font-weight: 700; }

@media (max-width: 700px) {
  main.crt {
    gap: 12px;
    padding:
      calc(12px + var(--safe-top))
      12px
      calc(20px + var(--safe-bottom));
  }

  .topbar {
    align-items: stretch;
    flex-wrap: wrap;
  }

  .brand {
    min-width: 0;
    flex: 1 1 180px;
  }

  .btn-ghost {
    width: 100%;
    justify-content: center;
  }

  .search-wrap {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
  }

  #q {
    width: 100%;
    font-size: clamp(18px, 5vw, 22px);
  }

  .current-head,
  .current-body {
    align-items: flex-start;
    flex-direction: column;
  }

  .current-icon {
    width: 72px;
    height: 72px;
  }

  .condition {
    font-size: 20px;
  }

  .stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .hourly {
    gap: 8px;
    margin-inline: -4px;
    padding-inline: 4px;
  }

  .hour {
    width: 68px;
  }

  .daily li {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      'day temps'
      'icon icon'
      'bar bar';
    gap: 8px 10px;
    font-size: 18px;
  }

  .daily li .d-day { grid-area: day; }
  .daily li .d-icon { grid-area: icon; }
  .daily li .d-bar { grid-area: bar; }
  .daily li .d-temps { grid-area: temps; }

  .foot {
    flex-wrap: wrap;
    row-gap: 6px;
    text-align: center;
  }
}

@media (max-width: 480px) {
  .brand h1 {
    font-size: 14px;
    letter-spacing: 1px;
  }

  .btn-ghost,
  .btn-primary {
    font-size: 9px;
    padding: 8px;
  }

  .search-wrap {
    gap: 6px;
    padding: 9px 10px;
  }

  #q {
    font-size: 17px;
    letter-spacing: 0.5px;
  }

  .current.card,
  .panel.card {
    padding: 14px;
  }

  .temp {
    font-size: clamp(42px, 17vw, 62px);
  }

  .condition {
    font-size: 18px;
  }

  .stats {
    grid-template-columns: 1fr;
  }

  .hour {
    width: 64px;
    padding: 9px 4px;
  }

  .daily li {
    padding: 8px;
    font-size: 16px;
  }

  .daily li .d-day,
  .daily li .d-temps {
    font-size: 8px;
  }

  .daily li .d-icon {
    width: 20px;
    height: 20px;
  }
}

/* Footer */
.foot {
  display: flex; align-items: center; justify-content: center;
  gap: 10px;
  font-family: var(--font-display);
  font-size: 8px;
  color: var(--ink-dim);
  letter-spacing: 2px;
  padding: 8px 0;
}
.foot .dot { opacity: 0.5; }
.blink { color: var(--accent); animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0; } }

/* Accessibility helper */
.sr-only {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  .scanlines, .blink, .brand-logo, .current-icon, .hour { animation: none !important; }
  * { transition: none !important; }
}

/* Focus states */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
