@import url("https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;600&display=swap");

:root {
  --ink: #1b2430;
  --muted: #5c6a7d;
  --panel: #ffffff;
  --line: #d6dde7;
  --accent: #1e6b5e;
  --accent-strong: #175247;
  --shadow: 0 18px 40px rgba(24, 36, 50, 0.12);
  --bg-a: #f4f1ea;
  --bg-b: #dfe9f6;
  --bg-c: #f7e4c1;
  --canvas-max: 1400px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Space Grotesk", "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(1200px 600px at 8% -10%, var(--bg-b), rgba(223, 233, 246, 0) 60%),
    radial-gradient(900px 500px at 95% 5%, var(--bg-c), rgba(247, 228, 193, 0) 60%),
    var(--bg-a);
}

.app {
  max-width: 1720px;
  margin: 0 auto;
  padding: 32px;
  display: grid;
  gap: 22px;
}

.top {
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 22px 26px;
  display: grid;
  gap: 14px;
  box-shadow: var(--shadow);
  animation: rise 0.55s ease-out both;
}

.title {
  display: grid;
  gap: 6px;
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.2em;
  font-size: 12px;
  color: var(--muted);
}

h1 {
  margin: 0;
  font-size: 40px;
}

.title p {
  margin: 0;
  color: var(--muted);
  font-size: 18px;
}

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 16px;
  align-items: center;
}

.climate {
  display: grid;
  gap: 10px;
}

.climate-title {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--muted);
}

.climate-controls {
  gap: 10px 12px;
}

.control.control-wide {
  min-width: 220px;
  justify-content: space-between;
}

.control {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #f6f7fb;
  font-size: 16px;
}

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

.control .value {
  min-width: 18px;
  text-align: right;
  color: var(--ink);
  font-weight: 600;
}

input[type="range"] {
  width: 200px;
}

select,
button {
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #ffffff;
  color: var(--ink);
  padding: 10px 18px;
  font-size: 16px;
  font-family: inherit;
}

button {
  cursor: pointer;
}

button.primary {
  background: var(--accent);
  border-color: var(--accent-strong);
  color: #ffffff;
}

.buttons {
  display: inline-flex;
  gap: 8px;
  align-items: center;
}

.hint {
  font-size: 15px;
  color: var(--muted);
}

.canvas-shell {
  animation: rise 0.55s ease-out 0.08s both;
}

.map-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 420px);
  gap: 20px;
  align-items: start;
}

.canvas-wrap {
  position: relative;
  width: min(100%, var(--canvas-max));
  justify-self: center;
}

canvas {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 14px;
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  background: #0b1b2b;
  cursor: crosshair;
  touch-action: none;
}

.inspector {
  position: absolute;
  top: 12px;
  left: 12px;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(10, 20, 30, 0.86);
  border: 1px solid rgba(255, 255, 255, 0.16);
  color: #f2f5f8;
  box-shadow: 0 10px 24px rgba(10, 20, 30, 0.25);
  pointer-events: none;
  opacity: 0;
  transform: translate(0, 0);
  transition: opacity 0.12s ease;
}

.inspector.visible {
  opacity: 1;
}

.inspector-copy {
  display: grid;
  gap: 2px;
}

.inspector-label {
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: rgba(230, 237, 245, 0.7);
}

.inspector-name {
  font-size: 14px;
  font-weight: 600;
}

.inspector-swatch {
  width: 16px;
  height: 16px;
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.3);
}

.has-tip {
  position: relative;
}

.has-tip::before,
.has-tip::after {
  opacity: 0;
  transform: translateY(6px);
  pointer-events: none;
  transition: opacity 0.15s ease, transform 0.15s ease;
}

.has-tip::after {
  content: attr(data-tip);
  position: absolute;
  left: 12px;
  bottom: calc(100% + 10px);
  max-width: 240px;
  padding: 8px 10px;
  border-radius: 8px;
  background: rgba(12, 20, 30, 0.92);
  color: #f2f5f8;
  font-size: 12px;
  line-height: 1.35;
  box-shadow: 0 10px 24px rgba(10, 20, 30, 0.25);
  z-index: 2;
}

.has-tip::before {
  content: "";
  position: absolute;
  left: 28px;
  bottom: calc(100% + 4px);
  border-width: 6px 6px 0;
  border-style: solid;
  border-color: rgba(12, 20, 30, 0.92) transparent transparent;
  z-index: 2;
}

.has-tip:hover::before,
.has-tip:hover::after,
.has-tip:focus-within::before,
.has-tip:focus-within::after {
  opacity: 1;
  transform: translateY(0);
}

.legend-block {
  width: 100%;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 14px;
  box-shadow: var(--shadow);
}

.legend-title {
  font-size: 14px;
  color: var(--muted);
  margin-bottom: 6px;
}

.legend-hint {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 8px;
}

.legend {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.legend-group {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 10px;
  background: #f8f9fc;
}

.legend-group-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--muted);
  margin-bottom: 6px;
}

.legend-group-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.chip {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 6px 8px;
  border-radius: 6px;
  border: 1px solid transparent;
  background: transparent;
  text-align: left;
  cursor: pointer;
  font-size: 12px;
  line-height: 1.2;
  color: var(--ink);
}

.chip span:last-child {
  min-width: 0;
}

.sw {
  display: inline-block;
  flex: 0 0 1.2em;
  width: 1.2em;
  height: 1.2em;
  border-radius: 3px;
  border: 1px solid var(--line);
  background: var(--swatch, #8b93a1);
}

.chip.hover {
  border-color: rgba(30, 107, 94, 0.45);
  background: rgba(30, 107, 94, 0.08);
}

.chip.active {
  border-color: var(--accent);
  background: rgba(30, 107, 94, 0.12);
  box-shadow: inset 0 0 0 1px rgba(30, 107, 94, 0.25);
}

.legend.has-focus .chip:not(.active) {
  opacity: 0.45;
}

button:focus-visible,
select:focus-visible,
input[type="range"]:focus-visible {
  outline: 2px solid rgba(30, 107, 94, 0.35);
  outline-offset: 2px;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 720px) {
  .app {
    padding: 18px;
  }

  h1 {
    font-size: 30px;
  }

  .controls {
    flex-direction: column;
    align-items: flex-start;
  }

  .control {
    width: 100%;
    justify-content: space-between;
  }

  .control.control-wide {
    min-width: 0;
  }

  input[type="range"] {
    width: 160px;
  }

  .map-layout {
    grid-template-columns: 1fr;
  }

  .canvas-wrap {
    width: 100%;
  }

  .legend {
    grid-template-columns: 1fr;
  }

  .legend-group-grid {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation: none !important;
  }
}
