/*
 * Explore Data page styles. Colours match styles.css (same tokens, same dark mode).
 * Mobile first: one column under 900px, two columns from 900px.
 */

:root {
  color-scheme: light dark;
  --bg: #f6faf9;
  --surface: #ffffff;
  --surface-soft: #eef7f4;
  --text: #15221f;
  --muted: #5c6f6a;
  --line: #dce9e5;
  --teal: #0f9f8a;
  --teal-strong: #0b7f70;
  --teal-soft: #e8f6f2;
  --warn-bg: #fff6e0;
  --warn-text: #6b4a00;
  --shadow: 0 18px 45px rgba(8, 62, 54, 0.08);
  --radius: 14px;
  --focus: #0b5ed7;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #071014;
    --surface: #0c1a1e;
    --surface-soft: #102620;
    --text: #dce9e5;
    --muted: #91a5a0;
    --line: #1e3a36;
    --teal: #2dd4bf;
    --teal-strong: #5eead4;
    --teal-soft: #0d2421;
    --warn-bg: #2b2310;
    --warn-text: #f3d98b;
    --shadow: 0 18px 45px rgba(0, 0, 0, 0.3);
    --focus: #7db4ff;
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #071014;
  --surface: #0c1a1e;
  --surface-soft: #102620;
  --text: #dce9e5;
  --muted: #91a5a0;
  --line: #1e3a36;
  --teal: #2dd4bf;
  --teal-strong: #5eead4;
  --teal-soft: #0d2421;
  --warn-bg: #2b2310;
  --warn-text: #f3d98b;
  --shadow: 0 18px 45px rgba(0, 0, 0, 0.3);
  --focus: #7db4ff;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

a {
  color: var(--teal-strong);
}

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

[hidden] {
  display: none !important;
}

.wrap {
  max-width: 1200px;
  margin: 0 auto;
  padding-block: 20px 40px;
  padding-inline: 16px;
}

/* ---- Intro ------------------------------------------------------------- */

.eyebrow {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

h1 {
  margin: 4px 0 8px;
  font-size: clamp(1.6rem, 4vw, 2.2rem);
  line-height: 1.15;
}

h2 {
  font-size: 1.05rem;
  margin: 0 0 10px;
}

.intro p {
  margin: 0 0 8px;
  max-width: 70ch;
}

.note {
  display: inline-block;
  padding: 6px 10px;
  border-radius: 8px;
  background: var(--surface-soft);
  color: var(--muted);
}

/* ---- Layout ------------------------------------------------------------ */

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 16px;
  margin-top: 18px;
}

@media (min-width: 900px) {
  .layout {
    grid-template-columns: minmax(0, 360px) minmax(0, 1fr);
    align-items: start;
  }
  .panel {
    position: sticky;
    top: 12px;
    max-height: calc(100vh - 24px);
    overflow: auto;
  }
}

.panel,
.map-column > section,
.detail,
.credits {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px;
}

.panel {
  display: grid;
  gap: 12px;
  align-content: start;
}

.map-column {
  display: grid;
  gap: 16px;
  min-width: 0;
}

/* ---- Form controls ----------------------------------------------------- */

label {
  display: grid;
  gap: 4px;
  font-weight: 600;
}

select,
input[type="search"] {
  width: 100%;
  min-height: 44px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-weight: 400;
}

select:disabled {
  opacity: 0.55;
}

.check {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 400;
  min-height: 44px;
}

.check input {
  width: 20px;
  height: 20px;
  margin: 0;
}

fieldset {
  margin: 0;
  padding: 0;
  border: 0;
  display: grid;
  gap: 4px;
}

legend {
  font-weight: 600;
  padding: 0;
  margin-bottom: 4px;
}

.count {
  color: var(--muted);
  font-weight: 400;
}

.button,
button.button {
  min-height: 44px;
  padding: 8px 14px;
  border-radius: 10px;
  border: 1px solid var(--teal-strong);
  background: var(--teal-soft);
  color: var(--text);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.button.quiet {
  border-color: var(--line);
  background: transparent;
  font-weight: 400;
}

.status {
  margin: 0;
  color: var(--muted);
}

/* ---- Results list ------------------------------------------------------ */

.results {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 6px;
  max-height: 46vh;
  overflow: auto;
}

.results button {
  width: 100%;
  text-align: left;
  min-height: 44px;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--text);
  font: inherit;
  cursor: pointer;
}

.results button[aria-current="true"] {
  border-color: var(--teal-strong);
  background: var(--teal-soft);
}

.results .name {
  display: block;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.results .meta {
  display: block;
  color: var(--muted);
  font-size: 13px;
}

.tag {
  display: inline-block;
  padding: 0 6px;
  border-radius: 6px;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 12px;
}

/* ---- Map --------------------------------------------------------------- */

.map-wrap {
  position: relative;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface-soft);
  height: 62vh;
  min-height: 340px;
}

@media (min-width: 900px) {
  .map-wrap {
    height: 68vh;
  }
}

.map {
  width: 100%;
  height: 100%;
}

.map-message {
  position: absolute;
  inset: 0;
  margin: 0;
  padding: 24px;
  display: grid;
  place-content: center;
  text-align: center;
  background: var(--surface-soft);
  color: var(--muted);
}

.map-message[hidden] {
  display: none;
}

.hex-note {
  margin: -8px 0 0;
  color: var(--muted);
  font-size: 13px;
}

/* ---- Detail card ------------------------------------------------------- */

.detail h2 {
  font-size: 1.2rem;
  overflow-wrap: anywhere;
}

.detail dl {
  display: grid;
  grid-template-columns: minmax(90px, max-content) minmax(0, 1fr);
  gap: 6px 12px;
  margin: 10px 0 0;
}

.detail .pair {
  display: contents;
}

.detail dt {
  color: var(--muted);
}

.detail dd {
  margin: 0;
  overflow-wrap: anywhere;
}

.detail .badge-rule {
  margin: 10px 0 0;
  padding: 10px;
  border-radius: 10px;
  background: var(--teal-soft);
}

.detail .approx {
  color: var(--muted);
  font-size: 13px;
}

/* ---- Messages ---------------------------------------------------------- */

.banner {
  margin: 0;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--warn-bg);
  color: var(--warn-text);
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
}

.fallback {
  max-width: 70ch;
  margin: 40px auto;
  padding: 0 16px;
}

/* ---- Credits ----------------------------------------------------------- */

.credits h2 {
  font-size: 1.05rem;
}

.credits ul {
  margin: 0;
  padding-left: 18px;
}

.credits li {
  margin-bottom: 6px;
  overflow-wrap: anywhere;
}

.credits p {
  margin: 0 0 8px;
}

.muted {
  color: var(--muted);
}

.extra {
  display: block;
  margin-top: 4px;
}

/* Keep every grid and form child inside the screen on phones. */
.panel,
.panel > *,
.map-column,
.map-column > *,
label,
select,
input {
  min-width: 0;
  max-width: 100%;
}

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