/* Pixel Weather. Builds on site.css. */

.visually-hidden {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.wx-scene {
  --sky: #cdc2f5;
  position: relative;
  overflow: hidden;
  min-height: 460px;
  padding-top: 20px;
  background: var(--sky);
  color: var(--ink);
}
.wx-scene[data-sky='clear-day'] { --sky: #bfe3ff; }
.wx-scene[data-sky='cloudy-day'] { --sky: #cdc2f5; }
.wx-scene[data-sky='overcast'] { --sky: #b7b0d6; }
.wx-scene[data-sky='fog'] { --sky: #d6d1e6; }
.wx-scene[data-sky='rain'] { --sky: #8f86c4; }
.wx-scene[data-sky='storm'] { --sky: #5a4c9c; color: #f4f0ff; }
.wx-scene[data-sky='snow'] { --sky: #e4e9ff; }
.wx-scene[data-sky='clear-night'] { --sky: #2a1a6e; color: #f4f0ff; }
.wx-scene[data-sky='clear-night'] .back-link,
.wx-scene[data-sky='storm'] .back-link { color: #f4f0ff; }
.wx-scene[data-sky='clear-night'] .cloud,
.wx-scene[data-sky='clear-day'] .c3 { opacity: 0.35; }

.back-link { color: var(--ink); text-decoration: none; }
.back-link:hover { text-decoration: underline; color: inherit; }

.wx-rain {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: none;
  background-image: url(/img/raindrops.svg);
  background-size: 32px 32px;
  image-rendering: pixelated;
  opacity: 0.8;
}
.wx-scene[data-sky='rain'] .wx-rain,
.wx-scene[data-sky='storm'] .wx-rain { display: block; animation: rainfall 0.6s steps(4) infinite; }
@keyframes rainfall { from { background-position: 0 0; } to { background-position: -8px 32px; } }

.wx-now {
  position: relative;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 32px;
  padding: 56px 16px 90px;
  flex-wrap: wrap;
  text-align: left;
}
.wx-icon { width: 144px; }
.wx-place { margin: 0; font-family: var(--pixel); font-size: 16px; text-transform: uppercase; }
.wx-temp { margin: 4px 0; font-family: var(--pixel); font-weight: 700; font-size: clamp(64px, 12vw, 120px); line-height: 1; }
.wx-unit { font-size: 0.4em; vertical-align: top; margin-left: 4px; }
.wx-cond {
  display: inline-block;
  margin: 6px 0 0;
  padding: 4px 14px;
  font-family: var(--pixel);
  font-size: 14px;
  text-transform: uppercase;
  color: var(--ink);
  background: var(--panel);
  border: 3px solid var(--ink);
  border-radius: 999px;
}
.wx-updated { margin: 10px 0 0; font-size: 12px; opacity: 0.85; min-height: 1.2em; }
.wx-scene .ground { position: absolute; left: 0; right: 0; bottom: 0; z-index: 2; }

.wx-main { padding-top: 48px; }
.wx-search { display: flex; gap: 10px; flex-wrap: wrap; max-width: 720px; }
.wx-search input {
  flex: 1;
  min-width: 200px;
  font: inherit;
  font-size: 16px;
  color: var(--panel-ink);
  background: #f4f0ff;
  border: 3px solid var(--ink);
  padding: 10px 12px;
  min-height: 48px;
}
.wx-search input:focus { outline: none; box-shadow: 0 0 0 3px var(--pink); }
.btn-ghost { background: var(--panel); }
.wx-status { min-height: 1.6em; margin: 10px 0 0; color: var(--muted); font-size: 14px; }
.wx-status[data-kind='error'] { color: #ffb4c8; font-weight: 600; }

.wx-results { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; max-width: 720px; }
.wx-result {
  width: 100%;
  text-align: left;
  font: inherit;
  color: var(--panel-ink);
  background: var(--panel);
  border: 3px solid var(--ink);
  padding: 10px 12px;
  cursor: pointer;
  min-height: 44px;
}
.wx-result:hover, .wx-result:focus-visible { background: #fff6c2; }

.wx-block { margin-top: 48px; }
.wx-h { font-size: clamp(24px, 3.6vw, 34px); }
.wx-stats { margin-bottom: 0; }
.wx-stats .skill-name { font-size: 20px; }

.wx-days {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
  max-width: 820px;
}
.wx-day {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 14px 8px;
  background: var(--panel);
  color: var(--ink);
  border: 3px solid var(--ink);
  box-shadow: 4px 4px 0 var(--ink);
  text-align: center;
}
.wx-day-name { font-family: var(--pixel); font-size: 14px; text-transform: uppercase; }
.wx-day-icon { width: 48px; }
.wx-day-temps { font-family: var(--pixel); font-size: 15px; }
.wx-day-rain { font-size: 12px; color: #5d4aa8; min-height: 1.2em; }

.wx-credit { margin-top: 40px; color: var(--muted); }
.wx-credit a { color: var(--mint); }

@media (max-width: 760px) {
  .wx-now { gap: 16px; padding: 32px 16px 80px; }
  .wx-icon { width: 96px; }
  .wx-days { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .wx-days .wx-day:first-child { grid-column: 1 / -1; }
}

@media (prefers-reduced-motion: reduce) {
  .wx-scene .wx-rain { animation: none; }
}
@media (max-width: 380px) {
  .wx-stats .skill { padding: 10px; min-width: 0; }
  .wx-stats .skill-name { font-size: 13px; }
}

/* ---------- Live upgrade: 8 stats, hourly strip, suggestions ---------- */
.wx-stats { grid-template-columns: repeat(4, minmax(0, 1fr)); max-width: 820px; }
.wx-stats .skill-name { overflow-wrap: anywhere; }

.wx-hours {
  list-style: none;
  margin: 0;
  padding: 4px 8px 14px 4px;
  display: flex;
  gap: 10px;
  max-width: 820px;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scroll-snap-type: x proximity;
  scrollbar-width: thin;
  scrollbar-color: var(--line) transparent;
  -webkit-overflow-scrolling: touch;
}
.wx-hours:focus-visible { outline: 3px solid var(--pink); outline-offset: 2px; }
.wx-hour {
  flex: 0 0 auto;
  width: 72px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 10px 4px;
  background: var(--panel);
  color: var(--ink);
  border: 3px solid var(--ink);
  box-shadow: 3px 3px 0 var(--ink);
  scroll-snap-align: start;
  text-align: center;
}
.wx-hour.is-now { background: var(--yellow); }
.wx-hour-time { font-family: var(--pixel); font-size: 12px; text-transform: uppercase; }
.wx-hour-icon { width: 32px; }
.wx-hour-temp { font-family: var(--pixel); font-size: 15px; }
.wx-hour-rain { font-size: 11px; color: #5d4aa8; min-height: 1.2em; }

.wx-results { max-height: 300px; overflow-y: auto; }
.wx-result.is-active { background: #fff6c2; box-shadow: 0 0 0 3px var(--pink); }

.wx-updated::before { content: ''; display: inline-block; width: 8px; height: 8px; margin-right: 6px; background: var(--mint); border: 2px solid var(--ink); vertical-align: 0; }
@media (prefers-reduced-motion: no-preference) {
  .wx-updated::before { animation: wx-live 1.6s steps(2) infinite; }
}
@keyframes wx-live { 50% { opacity: 0.25; } }
.wx-updated:empty::before { display: none; }

@media (max-width: 760px) {
  .wx-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .wx-hour { width: 64px; }
}
.wx-stats .skill { display: flex; flex-direction: column; align-items: flex-start; justify-content: center; gap: 6px; min-width: 0; padding: 10px 12px; }
.wx-stats .skill-name { white-space: nowrap; overflow-wrap: normal; font-size: 18px; }
@media (max-width: 380px) { .wx-stats .skill-name { font-size: 14px; } }
