:root {
  color-scheme: dark;
  font-family: "Avenir Next", Avenir, "Trebuchet MS", sans-serif;
  background: #7898a0;
  --ink: #172b2b;
  --paper: #f3eddf;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
}

body {
  background: #7898a0;
}

button,
input {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

.window,
#weather-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
}

#weather-canvas {
  display: block;
}

.window::after {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  content: "";
  opacity: .14;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 220 220' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.28'/%3E%3C/svg%3E");
  mix-blend-mode: soft-light;
}

.loading {
  position: absolute;
  z-index: 4;
  left: 50%;
  bottom: max(39px, env(safe-area-inset-bottom));
  display: flex;
  gap: 7px;
  padding: 13px 16px;
  translate: -50% 0;
  transition: opacity .35s ease, visibility .35s ease;
}

.loading.hidden {
  opacity: 0;
  visibility: hidden;
}

.loading i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--paper);
  box-shadow: 0 1px 3px rgb(23 43 43 / .3);
  animation: breathe 1.15s infinite ease-in-out;
}

.loading i:nth-child(2) { animation-delay: .16s; }
.loading i:nth-child(3) { animation-delay: .32s; }

@keyframes breathe {
  0%, 70%, 100% { opacity: .32; translate: 0 1px; }
  35% { opacity: 1; translate: 0 -3px; }
}

.search-wrap {
  position: absolute;
  z-index: 5;
  left: 50%;
  bottom: max(92px, calc(env(safe-area-inset-bottom) + 72px));
  width: min(390px, calc(100% - 36px));
  color: var(--ink);
  opacity: 0;
  pointer-events: none;
  translate: -50% 12px;
  transition: opacity .2s ease, translate .26s cubic-bezier(.2,.8,.2,1);
}

.search-wrap.visible {
  opacity: 1;
  pointer-events: auto;
  translate: -50% 0;
}

.search {
  display: grid;
  grid-template-columns: 46px 1fr 46px;
  height: 54px;
  overflow: hidden;
  border: 2px solid rgb(23 43 43 / .88);
  border-radius: 4px;
  background: #f3eddf;
  box-shadow: 5px 6px 0 rgb(23 43 43 / .24);
}

.search:focus-within {
  outline: 4px solid #ffdd64;
  outline-offset: 2px;
}

.search input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  color: var(--ink);
  background: transparent;
  font-size: 17px;
  letter-spacing: .01em;
}

.search input::placeholder {
  color: rgb(23 43 43 / .58);
}

.search input::-webkit-search-cancel-button {
  display: none;
}

.search button,
.open-search,
.source {
  display: grid;
  border: 0;
  color: currentColor;
  background: transparent;
  cursor: pointer;
  place-items: center;
}

.search button:focus-visible,
.open-search:focus-visible,
.source:focus-visible {
  outline: 4px solid #ffdd64;
  outline-offset: 2px;
}

.search svg {
  width: 23px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-width: 1.8;
}

.search-button.busy svg {
  animation: turn 1s linear infinite;
}

@keyframes turn { to { rotate: 360deg; } }

.results {
  display: none;
  max-height: min(280px, 40vh);
  margin: 8px 0 0;
  padding: 0;
  overflow-y: auto;
  border: 2px solid rgb(23 43 43 / .88);
  border-radius: 4px;
  background: #f3eddf;
  box-shadow: 5px 6px 0 rgb(23 43 43 / .24);
  list-style: none;
}

.results:not(:empty) {
  display: block;
}

.results button {
  display: block;
  width: 100%;
  padding: 13px 15px;
  border: 0;
  border-bottom: 1px solid rgb(23 43 43 / .22);
  color: var(--ink);
  background: transparent;
  text-align: left;
  cursor: pointer;
}

.results li:last-child button {
  border-bottom: 0;
}

.results button:hover,
.results button:focus-visible,
.results button[aria-selected="true"] {
  outline: 0;
  background: #ffdd64;
}

.results strong,
.results small {
  display: block;
  font-weight: 500;
}

.results small {
  margin-top: 2px;
  color: rgb(23 43 43 / .65);
  font-size: 12px;
}

.open-search {
  position: absolute;
  z-index: 4;
  right: max(22px, env(safe-area-inset-right));
  bottom: max(22px, env(safe-area-inset-bottom));
  width: 46px;
  height: 46px;
  border: 2px solid rgb(23 43 43 / .72);
  border-radius: 50%;
  color: var(--ink);
  background: rgb(243 237 223 / .82);
  box-shadow: 3px 4px 0 rgb(23 43 43 / .18);
  opacity: 0;
  pointer-events: none;
  translate: 0 8px;
  transition: opacity .2s ease, translate .2s ease;
}

.timeline {
  position: absolute;
  z-index: 4;
  left: 50%;
  bottom: max(18px, env(safe-area-inset-bottom));
  width: min(720px, calc(100% - 190px));
  height: 52px;
  color: var(--paper);
  opacity: .36;
  pointer-events: none;
  translate: -50% 0;
  transition: opacity .2s ease;
}

.timeline.ready {
  opacity: 1;
  pointer-events: auto;
}

.timeline-time {
  display: block;
  width: max-content;
  min-width: 54px;
  min-height: 22px;
  margin: 0 auto 4px;
  padding: 2px 7px 1px;
  border: 1px solid rgb(23 43 43 / .78);
  color: var(--ink);
  background: var(--paper);
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
  font-size: 12px;
  line-height: 17px;
  text-align: center;
  opacity: 0;
}

.timeline.ready .timeline-time {
  opacity: 1;
}

.timeline-scale {
  position: relative;
  height: 26px;
}

.timeline-scale::before {
  position: absolute;
  top: 12px;
  right: 0;
  left: 0;
  height: 2px;
  content: "";
  background: rgb(243 237 223 / .68);
}

.timeline-marks {
  position: absolute;
  top: 8px;
  right: 0;
  left: 0;
  display: grid;
  grid-template-columns: repeat(25, 1fr);
  align-items: center;
  pointer-events: none;
}

.timeline-marks i {
  justify-self: center;
  width: 2px;
  height: 9px;
  background: var(--paper);
}

.timeline-marks i.night {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #d7d5c9;
}

.timeline-marks i:nth-child(6n + 1) {
  height: 13px;
}

#forecast-slider {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 26px;
  margin: 0;
  padding: 0;
  border: 0;
  outline: 0;
  appearance: none;
  background: transparent;
  cursor: ew-resize;
}

#forecast-slider::-webkit-slider-runnable-track {
  height: 2px;
  background: transparent;
}

#forecast-slider::-webkit-slider-thumb {
  width: 20px;
  height: 20px;
  margin-top: -9px;
  border: 2px solid var(--ink);
  border-radius: 50%;
  appearance: none;
  background: var(--paper);
  box-shadow: 2px 3px 0 rgb(23 43 43 / .22);
}

#forecast-slider::-moz-range-track {
  height: 2px;
  background: transparent;
}

#forecast-slider::-moz-range-thumb {
  width: 17px;
  height: 17px;
  border: 2px solid var(--ink);
  border-radius: 50%;
  background: var(--paper);
  box-shadow: 2px 3px 0 rgb(23 43 43 / .22);
}

#forecast-slider:focus-visible::-webkit-slider-thumb {
  outline: 4px solid #ffdd64;
  outline-offset: 2px;
}

#forecast-slider:focus-visible::-moz-range-thumb {
  outline: 4px solid #ffdd64;
  outline-offset: 2px;
}

.open-search.visible {
  opacity: 1;
  pointer-events: auto;
  translate: 0 0;
}

.open-search svg,
.source svg {
  width: 22px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-width: 1.8;
}

.source {
  position: absolute;
  z-index: 4;
  left: max(18px, env(safe-area-inset-left));
  bottom: max(18px, env(safe-area-inset-bottom));
  width: 28px;
  height: 28px;
  color: rgb(243 237 223 / .72);
  opacity: .75;
  transition: opacity .2s ease;
}

.source:hover { opacity: 1; }
.source svg { width: 19px; }

.search-wrap.visible ~ .open-search {
  opacity: 0;
  pointer-events: none;
}

.search-wrap.visible ~ .timeline {
  opacity: .16;
  pointer-events: none;
}

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

@media (max-width: 520px) {
  .search-wrap {
    bottom: max(94px, calc(env(safe-area-inset-bottom) + 74px));
  }

  .open-search {
    top: max(16px, env(safe-area-inset-top));
    right: max(16px, env(safe-area-inset-right));
    bottom: auto;
  }

  .source {
    top: max(16px, env(safe-area-inset-top));
    bottom: auto;
  }

  .timeline {
    bottom: max(18px, env(safe-area-inset-bottom));
    width: calc(100% - 34px);
  }
}

@media (prefers-reduced-motion: reduce) {
  .loading i,
  .search-button.busy svg {
    animation: none;
  }

  .search-wrap,
  .open-search,
  .timeline {
    transition: opacity .01ms linear;
  }
}
