:root {
  --background: #f1f3f5;
  --panel: #e6e9ec;
  --paper: #ffffff;
  --navy: #243447;
  --navy-soft: #5d6874;
  --burgundy: #7c4040;
  --burgundy-dark: #613030;
  --warm-gray: #c8c5c1;
  --line: #d5d9dd;
  --shadow: rgba(36, 52, 71, 0.09);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  color: var(--navy);
  background: var(--background);
  font-family: "Source Sans 3", sans-serif;
}

button,
input {
  font: inherit;
}

.page {
  width: min(1200px, calc(100% - 40px));
  margin: 0 auto;
  padding: 72px 0 48px;
}

.intro {
  max-width: 980px;
  margin-bottom: 42px;
}

.eyebrow,
.section-label,
.control-label,
.result-count,
.detail-meta,
.tile-label {
  font-family: "IBM Plex Mono", monospace;
}

.eyebrow {
  margin: 0 0 17px;
  color: var(--burgundy);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.13em;
}

h1 {
  max-width: 900px;
  margin: 0;
  font-family: "Fraunces", serif;
  font-size: clamp(3rem, 7vw, 6rem);
  font-weight: 400;
  line-height: 0.98;
  letter-spacing: -0.045em;
}

.dek {
  max-width: 780px;
  margin: 25px 0 0;
  color: var(--navy-soft);
  font-size: clamp(1.05rem, 2vw, 1.25rem);
  line-height: 1.55;
}

.controls {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) auto;
  align-items: end;
  gap: 26px;
  margin-bottom: 28px;
  padding: 22px;
  background: white;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.search-wrap label,
.control-label {
  display: block;
  margin-bottom: 8px;
  color: #68717b;
  font-size: 0.67rem;
  font-weight: 600;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.search-wrap input {
  width: 100%;
  padding: 12px 13px;
  color: var(--navy);
  background: #fafbfc;
  border: 1px solid #cfd5db;
  border-radius: 5px;
  outline: none;
}

.search-wrap input:focus {
  border-color: var(--burgundy);
  box-shadow: 0 0 0 3px rgba(124, 64, 64, 0.12);
}

.sort-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.sort-button {
  padding: 10px 13px;
  color: #5f6871;
  background: #f5f6f7;
  border: 1px solid #d5d9dd;
  border-radius: 999px;
  cursor: pointer;
  transition:
    color 160ms ease,
    background 160ms ease,
    border-color 160ms ease;
}

.sort-button:hover {
  border-color: #aab2ba;
}

.sort-button.is-active {
  color: white;
  background: var(--navy);
  border-color: var(--navy);
}

.atlas-section {
  padding: 29px;
  background: var(--panel);
  border: 1px solid #d0d5d9;
  border-radius: 8px;
}

.section-heading-row {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 20px;
  margin-bottom: 18px;
}

.section-label {
  margin: 0 0 7px;
  color: #7c858e;
  font-size: 0.64rem;
  font-weight: 600;
  letter-spacing: 0.11em;
}

.section-heading-row h2,
.detail-copy h2,
.method h2 {
  margin: 0;
  font-family: "Fraunces", serif;
  font-weight: 600;
  letter-spacing: -0.025em;
}

.section-heading-row h2 {
  font-size: clamp(1.9rem, 3vw, 2.6rem);
}

.result-count {
  margin: 0;
  color: #747d86;
  font-size: 0.65rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.legend {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 23px;
  color: #68727c;
  font-size: 0.75rem;
}

.legend-scale {
  width: min(260px, 45vw);
  height: 10px;
  background: linear-gradient(
    to right,
    #eceff1,
    #d8d5d2,
    #c9aaa7,
    #ad7471,
    #89504f,
    #683638
  );
  border: 1px solid rgba(36, 52, 71, 0.1);
  border-radius: 999px;
}

.atlas-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(128px, 1fr));
  gap: 13px;
}

.atlas-tile {
  position: relative;
  min-height: 155px;
  padding: 21px 14px 14px;
  overflow: hidden;
  text-align: left;
  color: var(--navy);
  background: white;
  border: 1px solid #d6dade;
  border-radius: 5px;
  cursor: pointer;
  box-shadow: 0 5px 13px rgba(36, 52, 71, 0.05);
  transition:
    transform 160ms ease,
    box-shadow 160ms ease,
    border-color 160ms ease;
}

.atlas-tile:hover,
.atlas-tile:focus-visible {
  z-index: 2;
  transform: translateY(-3px);
  border-color: #9ca6af;
  box-shadow: 0 11px 21px rgba(36, 52, 71, 0.11);
  outline: none;
}

.atlas-tile.is-selected {
  border-color: var(--burgundy);
  box-shadow:
    0 0 0 2px rgba(124, 64, 64, 0.15),
    0 10px 20px rgba(36, 52, 71, 0.1);
}

.tile-rate-bar {
  position: absolute;
  top: 0;
  left: 0;
  height: 8px;
  min-width: 2px;
  background: var(--tile-color);
}

.tile-rate {
  margin: 0;
  color: var(--tile-color);
  font-family: "Fraunces", serif;
  font-size: 2rem;
  font-weight: 600;
  line-height: 1;
  letter-spacing: -0.04em;
}

.tile-country {
  margin: 17px 0 0;
  font-size: 0.96rem;
  font-weight: 700;
  line-height: 1.12;
}

.tile-label {
  margin: 13px 0 0;
  color: #90979e;
  font-size: 0.5rem;
  line-height: 1.35;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.detail-section {
  display: grid;
  grid-template-columns: minmax(230px, 0.72fr) minmax(0, 1.28fr);
  gap: 38px;
  margin-top: 42px;
  padding: 34px;
  background: white;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.detail-copy h2 {
  font-size: clamp(2rem, 4vw, 3.6rem);
  line-height: 1;
}

.detail-copy > p:not(.section-label) {
  max-width: 420px;
  margin: 20px 0 0;
  color: var(--navy-soft);
  line-height: 1.6;
}

.detail-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  margin-top: 26px;
  color: #858e96;
  font-size: 0.58rem;
  font-weight: 600;
  letter-spacing: 0.08em;
}

.detail-record {
  padding: 27px;
  background: #f7f8f9;
  border: 1px solid #dce0e3;
  border-radius: 5px;
}

.detail-rate-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 20px;
  padding-bottom: 18px;
  border-bottom: 1px solid #d3d8dc;
}

#detail-country {
  font-size: 1rem;
  font-weight: 700;
}

#detail-rate {
  color: var(--burgundy);
  font-family: "Fraunces", serif;
  font-size: clamp(2.2rem, 5vw, 4rem);
  line-height: 1;
  letter-spacing: -0.04em;
}

#detail-grid {
  display: block;
  width: 100%;
  height: auto;
  margin-top: 18px;
  overflow: visible;
}

.detail-mark rect {
  stroke-width: 0.8;
}

.mark-refused rect {
  fill: var(--burgundy);
  stroke: var(--burgundy-dark);
}

.mark-refused .mark-line {
  stroke: rgba(255, 255, 255, 0.48);
  stroke-width: 0.7;
}

.mark-other rect {
  fill: var(--warm-gray);
  stroke: rgba(36, 52, 71, 0.12);
}

.mark-other .mark-line {
  stroke: rgba(36, 52, 71, 0.16);
  stroke-width: 0.7;
}

.method {
  display: grid;
  grid-template-columns: 220px 1fr 1fr;
  gap: 30px;
  margin-top: 44px;
  padding: 32px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.method h2 {
  font-size: 1.6rem;
  line-height: 1.1;
}

.method p {
  margin: 0;
  color: #616b74;
  line-height: 1.65;
}

footer {
  max-width: 820px;
  margin-top: 24px;
  color: #747d85;
  font-size: 0.76rem;
  line-height: 1.55;
}

.tooltip {
  position: fixed;
  z-index: 20;
  width: 220px;
  padding: 16px 17px;
  pointer-events: none;
  color: white;
  background: var(--navy);
  border-radius: 4px;
  box-shadow: 0 15px 36px rgba(36, 52, 71, 0.25);
  opacity: 0;
  transform: translateY(6px);
  transition:
    opacity 120ms ease,
    transform 120ms ease;
}

.tooltip.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.tooltip p {
  margin: 0;
}

.tooltip-label {
  margin-bottom: 7px !important;
  color: #c8d0d7;
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.58rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.tooltip-country {
  font-family: "Fraunces", serif;
  font-size: 1.08rem;
}

.tooltip-rate {
  margin-top: 7px !important;
  color: #e4aaa7;
  font-family: "Fraunces", serif;
  font-size: 1.8rem;
  font-weight: 600;
}

.error-message {
  grid-column: 1 / -1;
  padding: 22px;
  background: white;
  border: 1px solid #d7dce0;
  border-radius: 5px;
}

@media (max-width: 860px) {
  .page {
    width: min(100% - 24px, 1200px);
    padding-top: 46px;
  }

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

  .detail-section {
    grid-template-columns: 1fr;
  }

  .method {
    grid-template-columns: 1fr;
    gap: 17px;
  }
}

@media (max-width: 560px) {
  .page {
    width: min(100% - 16px, 1200px);
  }

  h1 {
    font-size: clamp(3rem, 14vw, 4.6rem);
  }

  .atlas-section {
    padding: 20px 10px;
  }

  .section-heading-row {
    align-items: start;
    flex-direction: column;
    gap: 8px;
  }

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

  .atlas-tile {
    min-height: 145px;
    padding: 19px 11px 12px;
  }

  .tile-rate {
    font-size: 1.75rem;
  }

  .detail-section {
    padding: 24px 17px;
  }

  .detail-record {
    padding: 19px 12px;
  }

  .tooltip {
    display: none;
  }
}
