/* ============================================
   weather.zxzx.app — 8-Bit TV Forecast
   Retro Television Weather Screen
   ============================================ */

:root {
  /* DESIGN_FOUNDATION.md core palette */
  --ink: #171717;
  --paper: #fffaf0;
  --soft: #f4efe3;
  --line: #d7cdb9;
  --blue-action: #214f96;
  --green-util: #167a57;
  --red-ent: #b43b35;
  --yellow-accent: #ffe08a;

  --w-bg: #1a1028;
  --w-bg-deep: #0d0818;
  --w-panel: #1e1435;
  --w-panel-alt: #241a3d;
  --w-border: #3a2a5a;
  --w-border-bright: #5a4a8a;

  /* TV cabinet — warm vintage appliance */
  --w-tv-frame: var(--soft);
  --w-tv-frame-light: #f9f5ec;
  --w-tv-frame-dark: var(--line);

  --w-tv-screen-bg: #0e0e0a;
  --w-blue: #5a90cc;
  --w-blue-dim: #3568a0;
  --w-blue-bright: #80b4e0;
  --w-cyan: #58c4c0;
  --w-amber: #f0c858;
  --w-amber-dim: #b89830;
  --w-orange: #e08844;
  --w-red: #cc4840;
  --w-red-dim: #993330;
  --w-green: #44b870;
  --w-green-dim: #1a8a5a;
  --w-white: #e8e0d0;
  --w-gray: #8a8070;
  --w-gray-dark: #5a5548;
  --w-rain: #6090b8;
  --w-snow: #d8d0c0;
  --w-storm: #e8c848;
  --w-gold: #e0b830;

  --font-display: 'Press Start 2P', 'VT323', monospace;
  --font-data: 'VT323', 'Share Tech Mono', monospace;
  --font-mono: 'Share Tech Mono', 'VT323', 'Consolas', monospace;
}

/* ============================================
   ZXZX 2026 DESIGN PASS — Broadcast forecast
   ============================================ */

body {
  background:
    radial-gradient(circle at 50% 0%, rgba(255,224,138,.18), transparent 34%),
    linear-gradient(180deg, #071a31 0%, #102944 42%, #08131f 100%);
}

#weather-app {
  filter: drop-shadow(0 22px 40px rgba(0,0,0,.42));
}

.tv-frame {
  box-shadow: 0 0 0 2px rgba(255,255,255,.12), 0 24px 80px rgba(0,0,0,.42);
}

.tv-screen {
  background:
    radial-gradient(circle at 50% 20%, rgba(255,255,255,.12), transparent 38%),
    linear-gradient(180deg, rgba(15,45,78,.85), rgba(3,13,24,.94));
}

.weather-main {
  align-items: center;
}

.weather-temp-area {
  text-shadow: 0 0 20px rgba(255,224,138,.45);
}

.stats-row .stat-item,
.forecast-days .forecast-day {
  backdrop-filter: blur(3px);
  background: rgba(255,255,255,.08);
  border-color: rgba(255,255,255,.16);
}

.ticker-bar {
  border-top: 1px solid rgba(255,224,138,.35);
}

/* Korean text: avoid Press Start 2P (garbled glyphs), use pixel-style KR font */
[lang="ko"] {
  --font-display: 'Nanum Gothic Coding', 'DungGeunMo', monospace;
}

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

html {
  height: 100%;
}

body {
  font-family: var(--font-mono);
  background: var(--w-bg);
  color: var(--w-white);
  min-height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow-x: hidden;
  font-size: 14px;
  line-height: 1.3;
  -webkit-font-smoothing: none;
}

/* ── CRT Scanlines ── */
.scanlines {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9999;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(0, 0, 0, 0.1) 2px,
    rgba(0, 0, 0, 0.1) 4px
  );
}

/* CRT flicker */
.crt-flicker {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9998;
  opacity: 0;
  background: rgba(220, 210, 190, 0.02);
  animation: crt-flicker 4s ease-in-out infinite;
}

@keyframes crt-flicker {
  0%, 94%, 100% { opacity: 0; }
  95% { opacity: 1; }
  96% { opacity: 0; }
  97% { opacity: 0.6; }
  98% { opacity: 0; }
}

/* ── Main Container ── */
#weather-app {
  width: 100%;
  max-width: 760px;
  display: flex;
  flex-direction: column;
  gap: 0;
  position: relative;
  z-index: 1;
  padding: 8px;
}

/* ── Title Bar ── */
.titlebar {
  background: linear-gradient(90deg, #1a0a2e, #2a1a4a, #1a0a2e);
  border: 2px solid var(--w-border);
  border-bottom: none;
  padding: 3px 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.titlebar-left {
  display: flex;
  align-items: center;
  gap: 6px;
}

.titlebar-icon {
  font-size: 13px;
}

.titlebar-text {
  font-family: var(--font-display);
  font-size: 9px;
  color: var(--w-amber);
  font-weight: bold;
  letter-spacing: 2px;
  text-shadow: 0 0 8px var(--w-amber-dim);
}

.titlebar-controls {
  display: flex;
  gap: 2px;
}

.titlebar-ctrl {
  width: 16px;
  height: 14px;
  background: var(--w-gray-dark);
  border: 1px outset #556;
  font-size: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--w-bg);
  font-weight: bold;
  font-family: var(--font-mono);
  cursor: default;
  user-select: none;
}

/* ── Menu Bar ── */
.menu-bar {
  background: var(--w-panel-alt);
  border-left: 2px solid var(--w-border);
  border-right: 2px solid var(--w-border);
  padding: 2px 4px;
  display: flex;
  gap: 0;
}

.menu-item {
  font-family: var(--font-mono);
  font-size: 14px;
  color: var(--w-gray);
  padding: 2px 8px;
  cursor: pointer;
  background: none;
  border: none;
  transition: all 0.15s;
}

.menu-item:hover {
  background: rgba(215, 205, 185, 0.12);
  color: var(--w-blue);
}

.menu-item .underline {
  text-decoration: underline;
  color: var(--w-amber);
}

/* ── TV Frame ── */
.tv-frame {
  background: var(--soft);
  border: 3px solid var(--line);
  border-radius: 16px;
  padding: 18px;
  position: relative;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.5),
    inset 0 -1px 2px rgba(0, 0, 0, 0.08),
    0 6px 24px rgba(0, 0, 0, 0.2);
}

.tv-screen {
  background: var(--w-tv-screen-bg);
  border: 4px solid #1a1814;
  border-radius: 12px;
  position: relative;
  overflow: hidden;
  box-shadow:
    inset 0 0 60px rgba(0, 0, 0, 0.6),
    inset 0 0 20px rgba(0, 0, 0, 0.4),
    0 0 8px rgba(0, 0, 0, 0.2);
  min-height: 420px;
}

.tv-screen::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 12px;
  background: radial-gradient(
    ellipse at 40% 35%,
    rgba(200, 180, 140, 0.05) 0%,
    transparent 50%
  );
  pointer-events: none;
  z-index: 5;
}

.tv-screen::after {
  content: '';
  position: absolute;
  top: -30%;
  left: -30%;
  width: 50%;
  height: 50%;
  background: radial-gradient(
    ellipse at center,
    rgba(255, 255, 255, 0.03) 0%,
    transparent 60%
  );
  transform: rotate(-25deg);
  pointer-events: none;
  z-index: 6;
}

/* Canvas */
.weather-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
  border-radius: 12px;
}

/* TV Content overlay */
.tv-content {
  position: relative;
  z-index: 3;
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  min-height: 420px;
}

/* ── Channel Badge ── */
.channel-badge {
  position: absolute;
  top: 12px;
  right: 14px;
  font-family: var(--font-display);
  font-size: 9px;
  color: var(--w-white);
  background: rgba(0, 0, 0, 0.5);
  padding: 3px 6px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  text-shadow: 0 0 4px rgba(255, 255, 255, 0.4);
  animation: channel-blink 6s ease-in-out infinite;
}

@keyframes channel-blink {
  0%, 80%, 100% { opacity: 1; }
  85% { opacity: 0.2; }
  90% { opacity: 1; }
  95% { opacity: 0.2; }
}

/* ── LIVE Badge ── */
.live-badge {
  position: absolute;
  top: 12px;
  left: 14px;
  font-family: var(--font-display);
  font-size: 8px;
  color: var(--w-red);
  background: rgba(0, 0, 0, 0.6);
  padding: 3px 8px;
  border: 1px solid var(--w-red-dim);
  display: flex;
  align-items: center;
  gap: 5px;
  text-shadow: 0 0 6px var(--w-red);
}

.live-dot {
  width: 6px;
  height: 6px;
  background: var(--w-red);
  border-radius: 50%;
  animation: live-pulse 1s ease-in-out infinite;
  box-shadow: 0 0 4px var(--w-red);
}

@keyframes live-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.2; }
}

/* ── Location Bar ── */
.location-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 36px;
  margin-bottom: 8px;
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(215, 205, 185, 0.15);
}

.location-icon {
  font-size: 14px;
}

#location-name {
  font-family: var(--font-data);
  font-size: 18px;
  color: var(--w-blue);
  text-shadow: 0 0 6px var(--w-blue-dim);
  flex: 1;
  letter-spacing: 1px;
}

.location-btn {
  font-size: 18px;
  background: none;
  border: 1px solid var(--w-border-bright);
  color: var(--w-blue);
  cursor: pointer;
  padding: 1px 6px;
  font-family: var(--font-mono);
  transition: all 0.2s;
  border-radius: 3px;
}

.location-btn:hover {
  background: rgba(215, 205, 185, 0.15);
  color: var(--w-blue-bright);
}

/* ── Main Weather Display ── */
.weather-main {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 0;
  flex-wrap: wrap;
}

.weather-icon-area {
  flex-shrink: 0;
}

.weather-icon {
  font-size: 52px;
  display: block;
  text-shadow: 0 0 12px rgba(240, 200, 88, 0.3);
  animation: icon-float 3s ease-in-out infinite;
}

@keyframes icon-float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-4px); }
}

.weather-temp-area {
  display: flex;
  align-items: flex-start;
}

.temp-value {
  font-family: var(--font-display);
  font-size: 48px;
  color: var(--w-white);
  text-shadow:
    0 0 10px rgba(255, 255, 255, 0.3),
    2px 2px 0 rgba(0, 0, 0, 0.5);
  line-height: 1;
  letter-spacing: 2px;
}

.temp-unit {
  font-family: var(--font-display);
  font-size: 16px;
  color: var(--w-amber);
  margin-top: 4px;
  margin-left: 2px;
  text-shadow: 0 0 6px var(--w-amber-dim);
}

.weather-condition {
  font-family: var(--font-display);
  font-size: 10px;
  color: var(--w-amber);
  letter-spacing: 2px;
  text-shadow: 0 0 6px var(--w-amber-dim);
  margin-left: auto;
  text-align: right;
  max-width: 160px;
}

/* ── Stats Row ── */
.stats-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  margin: 8px 0;
  padding: 10px 0;
  border-top: 1px solid rgba(215, 205, 185, 0.12);
  border-bottom: 1px solid rgba(215, 205, 185, 0.12);
}

.stat-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 6px 4px;
  background: rgba(0, 10, 30, 0.4);
  border: 1px solid rgba(215, 205, 185, 0.1);
  border-radius: 4px;
}

.stat-icon {
  font-size: 16px;
}

.stat-label {
  font-family: var(--font-display);
  font-size: 6px;
  color: var(--w-gray);
  letter-spacing: 1px;
}

.stat-value {
  font-family: var(--font-data);
  font-size: 20px;
  color: var(--w-cyan);
  text-shadow: 0 0 4px rgba(88, 196, 192, 0.3);
  letter-spacing: 1px;
}

/* ── Forecast Strip ── */
.forecast-strip {
  margin-top: auto;
  padding-top: 8px;
}

.forecast-label {
  font-family: var(--font-display);
  font-size: 7px;
  color: var(--w-gray);
  letter-spacing: 2px;
  margin-bottom: 6px;
}

.forecast-days {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 4px;
}

.forecast-day {
  background: rgba(0, 10, 30, 0.5);
  border: 1px solid rgba(215, 205, 185, 0.12);
  border-radius: 4px;
  padding: 6px 4px;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.forecast-day-name {
  font-family: var(--font-display);
  font-size: 7px;
  color: var(--w-gray);
  letter-spacing: 1px;
}

.forecast-day-icon {
  font-size: 22px;
}

.forecast-day-temps {
  display: flex;
  justify-content: center;
  gap: 6px;
  font-family: var(--font-data);
  font-size: 16px;
}

.forecast-day-high {
  color: var(--w-orange);
  text-shadow: 0 0 3px rgba(224, 136, 68, 0.3);
}

.forecast-day-low {
  color: var(--w-blue);
  text-shadow: 0 0 3px rgba(90, 144, 204, 0.3);
}

/* ── TV Knobs ── */
.tv-controls {
  display: flex;
  justify-content: flex-end;
  gap: 24px;
  padding: 10px 24px 4px;
  align-items: center;
}

.tv-knob-group {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
}

.tv-knob {
  width: 28px;
  height: 28px;
  background: radial-gradient(circle at 40% 35%,
    #f0ebe0,
    var(--soft),
    var(--line)
  );
  border-radius: 50%;
  border: 2px solid var(--line);
  cursor: pointer;
  position: relative;
  box-shadow:
    0 2px 4px rgba(0, 0, 0, 0.2),
    inset 0 1px 2px rgba(255, 255, 255, 0.4);
  transition: transform 0.3s ease;
}

.tv-knob:hover {
  transform: rotate(45deg);
}

.tv-knob:active {
  transform: rotate(90deg);
}

.knob-indicator {
  position: absolute;
  top: 3px;
  left: 50%;
  width: 2px;
  height: 6px;
  background: var(--ink);
  transform: translateX(-50%);
  border-radius: 1px;
}

.knob-label {
  font-family: var(--font-display);
  font-size: 7px;
  color: var(--w-gray-dark);
  letter-spacing: 1px;
}

/* ── Ticker Bar ── */
.ticker-bar {
  background: var(--w-bg-deep);
  border-left: 2px solid var(--w-border);
  border-right: 2px solid var(--w-border);
  border-bottom: 1px solid var(--w-border);
  overflow: hidden;
  white-space: nowrap;
  height: 24px;
  position: relative;
}

.ticker-scroll {
  display: inline-block;
  animation: ticker-scroll 40s linear infinite;
  font-family: var(--font-data);
  font-size: 16px;
  letter-spacing: 1px;
  color: var(--w-amber);
  line-height: 24px;
  text-shadow: 0 0 4px var(--w-amber-dim);
}

@keyframes ticker-scroll {
  0% { transform: translateX(100vw); }
  100% { transform: translateX(-100%); }
}

.ticker-scroll .ticker-sep {
  color: var(--w-gray-dark);
  margin: 0 12px;
}

/* ── Status Bar ── */
.status-bar {
  background: var(--w-panel-alt);
  border-left: 2px solid var(--w-border);
  border-right: 2px solid var(--w-border);
  border-top: 1px solid var(--w-border);
  padding: 3px 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--w-gray);
}

.status-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.status-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.lang-bar {
  display: flex;
  gap: 1px;
}

.lang-btn {
  font-family: var(--font-mono);
  font-size: 12px;
  padding: 1px 5px;
  background: var(--w-panel);
  border: 1px solid var(--w-border);
  color: var(--w-gray);
  cursor: pointer;
  transition: all 0.15s;
}

.lang-btn:hover {
  color: var(--w-blue);
  border-color: var(--w-border-bright);
}

.lang-btn.active {
  background: var(--w-blue-dim);
  color: var(--w-white);
  border-color: var(--w-blue);
  text-shadow: 0 0 4px var(--w-blue);
}

/* ── Footer ── */
.weather-footer {
  background: var(--w-panel-alt);
  border: 2px solid var(--w-border);
  border-top: none;
  padding: 6px 10px;
  text-align: center;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--w-gray-dark);
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.footer-link {
  color: var(--w-gray);
  text-decoration: none;
  transition: color 0.15s;
}

.footer-link:hover {
  color: var(--w-blue);
  text-shadow: 0 0 4px var(--w-blue-dim);
}

.footer-sep {
  color: var(--w-border);
}

/* ── Utilities ── */
.text-red { color: var(--w-red); }
.text-green { color: var(--w-green); }
.text-blue { color: var(--w-blue); }
.text-amber { color: var(--w-amber); }
.text-cyan { color: var(--w-cyan); }
.text-gray { color: var(--w-gray); }
.text-white { color: var(--w-white); }

/* ── Loading / Error States ── */
.weather-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 300px;
  font-family: var(--font-display);
  font-size: 10px;
  color: var(--w-gray);
  gap: 12px;
}

.loading-dots::after {
  content: '';
  animation: loading-dots 1.5s infinite;
}

@keyframes loading-dots {
  0% { content: ''; }
  25% { content: '.'; }
  50% { content: '..'; }
  75% { content: '...'; }
}

/* ── Snowflake flash for blizzard ── */
.tv-screen.flash-snow {
  animation: flash-white 0.15s;
}

@keyframes flash-white {
  0% { background: var(--w-tv-screen-bg); }
  50% { background: rgba(255, 255, 255, 0.08); }
  100% { background: var(--w-tv-screen-bg); }
}

/* Lightning flash */
.tv-screen.flash-lightning {
  animation: flash-lightning 0.2s;
}

@keyframes flash-lightning {
  0% { background: var(--w-tv-screen-bg); }
  20% { background: rgba(255, 255, 200, 0.15); }
  40% { background: var(--w-tv-screen-bg); }
  60% { background: rgba(255, 255, 200, 0.1); }
  100% { background: var(--w-tv-screen-bg); }
}

/* ── Scrollbar ── */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: var(--w-bg-deep);
}

::-webkit-scrollbar-thumb {
  background: var(--w-border);
}

::-webkit-scrollbar-thumb:hover {
  background: var(--w-border-bright);
}

/* ── Responsive ── */
@media (max-width: 600px) {
  #weather-app {
    padding: 4px;
  }

  .titlebar-text {
    font-size: 7px;
    letter-spacing: 1px;
  }

  .menu-bar {
    display: none;
  }

  .tv-frame {
    padding: 10px;
    border-radius: 10px;
  }

  .tv-screen {
    border-radius: 8px;
    min-height: 380px;
  }

  .tv-content {
    padding: 12px 14px;
    min-height: 380px;
  }

  .temp-value {
    font-size: 36px;
  }

  .weather-icon {
    font-size: 40px;
  }

  .weather-condition {
    font-size: 8px;
    max-width: 120px;
  }

  .stats-row {
    grid-template-columns: repeat(2, 1fr);
    gap: 4px;
  }

  .forecast-days {
    grid-template-columns: repeat(5, 1fr);
    gap: 3px;
  }

  .forecast-day-icon {
    font-size: 18px;
  }

  .forecast-day-temps {
    font-size: 14px;
    gap: 4px;
  }

  .tv-controls {
    padding: 8px 16px 2px;
    gap: 16px;
  }
}

@media (max-width: 400px) {
  .temp-value {
    font-size: 30px;
  }

  .weather-main {
    gap: 10px;
  }

  .weather-condition {
    font-size: 7px;
    max-width: 90px;
  }

  .forecast-day-name {
    font-size: 6px;
  }

  .forecast-day-icon {
    font-size: 16px;
  }

  .forecast-day-temps {
    font-size: 12px;
    flex-direction: column;
    gap: 1px;
  }

  .stat-label {
    font-size: 5px;
  }

  .stat-value {
    font-size: 16px;
  }
}
