:root:not([data-theme="dark"]),
[data-theme="light"] {
  --background-color: #f0efeb; /* parchment */
  --color: #3f3a33; /* ink */
  --primary: #d98aa3; /* rose ink accent (slider) */
  --primary-hover: #c97a93;
  --primary-focus: rgba(217, 138, 163, 0.25);
}

html,
body {
  height: 100%;
}

body {
  height: 100dvh;
  margin: 0;
  overflow: hidden;
  font-family: Georgia, "Iowan Old Style", "Times New Roman", serif;
}

/* full-bleed map; everything else floats above it */
#map-wrap {
  position: fixed;
  inset: 0;
  padding: 0; /* undo Pico's main padding */
  margin: 0;
  overflow: hidden;
}

#globe {
  display: block;
  touch-action: none;
}

body > header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 5;
  padding: 0.7rem 1.5rem 0;
  text-align: center;
  pointer-events: none;
}

body > header hgroup {
  margin: 0 auto;
  max-width: 30rem;
  /* parchment halo so the words sit legibly on the map */
  text-shadow:
    0 0 3px #f0efeb,
    0 0 6px #f0efeb,
    0 0 12px #f0efeb,
    0 0 20px #f0efeb;
}

body > header h1 {
  margin-bottom: 0.15rem;
  font-family: Georgia, serif;
  font-size: 1.9rem;
  line-height: 1.15;
  color: #3f3a33;
}

body > header p {
  font-style: italic;
  color: #6d675e;
  font-size: 0.95rem;
  line-height: 1.35;
}

body > header a {
  pointer-events: auto; /* header itself is click-through */
  color: inherit;
  text-decoration: underline;
  text-decoration-style: dotted;
  text-underline-offset: 3px;
  text-decoration-color: #a89f92;
}

body > header a:hover {
  color: #3f3a33;
  text-decoration-style: solid;
}

#tooltip {
  position: fixed;
  pointer-events: none;
  z-index: 10;
  font-style: italic;
  font-size: 0.85rem;
  color: #6d675e;
  white-space: nowrap;
  /* parchment halo, like the header */
  text-shadow:
    0 0 3px #f0efeb,
    0 0 6px #f0efeb,
    0 0 12px #f0efeb;
}

[x-cloak] {
  display: none !important;
}

#history-panel {
  position: fixed;
  z-index: 8;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(720px, calc(100vw - 2rem));
  background: rgba(240, 239, 235, 0.97);
  border: 1px solid #3f3a33;
  border-radius: 0.3rem;
  box-shadow: 4px 4px 0 rgba(63, 58, 51, 0.12);
  padding: 1rem 1.2rem 0.8rem;
  color: #3f3a33;
}

#history-panel .close {
  position: absolute;
  top: 0.2rem;
  right: 0.2rem;
  width: 1.8rem;
  height: 1.8rem;
  padding: 0;
  margin: 0;
  border: none;
  background: none;
  color: #877f73;
  font-size: 1.2rem;
  line-height: 1;
  cursor: pointer;
}

#history-panel h3 {
  font-family: Georgia, serif;
  font-size: 1rem;
  margin-bottom: 0.2rem;
}

#history-panel .summary {
  font-style: italic;
  font-size: 0.86rem;
  line-height: 1.4;
  color: #565047;
  margin-bottom: 0.5rem;
}

#history-panel .detail {
  font-size: 0.78rem;
  color: #565047;
  margin-bottom: 0.5rem;
}

#history-panel .note {
  font-size: 0.7rem;
  color: #877f73;
  margin-bottom: 0;
  margin-top: 0.3rem;
}

#controls {
  position: fixed;
  left: 50%;
  bottom: 1rem;
  transform: translateX(-50%);
  z-index: 5;
  width: min(34rem, calc(100vw - 2rem));
  text-align: center;
  pointer-events: none;
}

#controls input[type="range"],
#controls output {
  pointer-events: auto;
}

#controls input[type="range"] {
  margin-bottom: 0.15rem;
}

#controls output {
  font-size: 0.9rem;
  color: #3f3a33;
}

#legend {
  display: flex;
  justify-content: center;
  gap: 1.1rem;
  flex-wrap: wrap;
  font-size: 0.82rem;
  margin-bottom: 0.45rem;
  color: #6d675e;
  font-style: italic;
}

.swatch {
  display: inline-block;
  width: 0.85em;
  height: 0.85em;
  border-radius: 2px;
  border: 1px solid rgba(63, 58, 51, 0.35);
  vertical-align: baseline;
  margin-right: 0.15rem;
}

.swatch.cold {
  background: #cddafd; /* periwinkle */
}

.swatch.jacket {
  background: #bee1e6; /* light blue */
}

.swatch.hot {
  background: #fad2e1; /* petal frost */
}

.swatch.unknown {
  background: repeating-linear-gradient(
    45deg,
    #eae4e9,
    #eae4e9 2px,
    #cfc7bc 2px,
    #cfc7bc 3px
  );
}

@media (max-width: 640px) {
  body > header {
    padding: 0.6rem 1rem 0;
  }

  body > header h1 {
    font-size: 1.35rem;
  }

  body > header p {
    font-size: 0.8rem;
  }

  #controls {
    bottom: 0.75rem;
  }

  #legend {
    gap: 0.7rem;
    font-size: 0.75rem;
    margin-bottom: 0.3rem;
  }
}
