@import url('https://fonts.googleapis.com/css2?family=Barlow+Condensed:wght@500;600;700&family=Public+Sans:wght@400;500;600&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
  --asphalt: #1b1d21;
  --surface: #24262b;
  --surface-raised: #2c2f35;
  --line: #3a3d44;
  --chalk: #edeae3;
  --chalk-dim: #a6a9b0;
  --lane-yellow: #f2c14e;
  --sign-blue: #3b6ea8;
  --bollard-red: #c1443c;
  --radius: 10px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--asphalt);
  color: var(--chalk);
  font-family: 'Public Sans', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

/* The lane-marking pinstripes gave way to the flight field below — two ambient
   background textures at once just read as noise. */
.flight-layer {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}

/* Everything real sits above the flight field. */
header.top, .shell, footer.foot { position: relative; z-index: 1; }

h1, h2, h3, .display {
  font-family: 'Barlow Condensed', sans-serif;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  font-weight: 700;
  margin: 0;
}

.mono { font-family: 'JetBrains Mono', monospace; }

a { color: inherit; }

button {
  font-family: inherit;
  cursor: pointer;
}

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

.shell {
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 24px 80px;
}

header.top {
  padding: 40px 24px 28px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 36px;
}

header.top .inner {
  max-width: 1180px;
  margin: 0 auto;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-mark {
  width: 40px;
  height: 40px;
  flex-shrink: 0;
}

.brand h1 {
  font-size: 34px;
  line-height: 1;
}

.brand .sub {
  font-family: 'Public Sans', sans-serif;
  text-transform: none;
  font-size: 13px;
  color: var(--chalk-dim);
  margin-top: 4px;
  letter-spacing: normal;
}

nav.tabs {
  display: flex;
  gap: 4px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px;
}

nav.tabs button {
  border: none;
  background: transparent;
  color: var(--chalk-dim);
  font-family: 'Barlow Condensed', sans-serif;
  text-transform: uppercase;
  font-weight: 600;
  font-size: 15px;
  letter-spacing: 0.03em;
  padding: 9px 20px;
  border-radius: 999px;
  transition: background 0.15s, color 0.15s;
}

nav.tabs button.active {
  background: var(--lane-yellow);
  color: var(--asphalt);
}

nav.tabs button:not(.active):hover {
  color: var(--chalk);
}

.view { display: none; }
.view.active { display: block; }

/* ---------- Browse view ---------- */

.browse-controls {
  display: flex;
  gap: 12px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.search-input {
  flex: 1;
  min-width: 220px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 16px;
  color: var(--chalk);
  font-size: 15px;
}

.search-input:focus { outline: 2px solid var(--lane-yellow); outline-offset: -1px; }

/* ---------- Globe ---------- */

.globe-wrap {
  position: relative;
  /* Kept near-square and centred: on a full-width panel the sphere strands a lot
     of empty space either side, and a selected country reads as tiny. */
  max-width: 860px;
  height: clamp(320px, 46vw, 500px);
  margin: 0 auto 26px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background:
    radial-gradient(120% 95% at 50% 0%, rgba(255,255,255,0.05), transparent 62%),
    #16181c;
  overflow: hidden;
}

#globeCanvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  cursor: grab;
  touch-action: none;   /* the canvas handles its own drag/pinch gestures */
}

#globeCanvas:active { cursor: grabbing; }
#globeCanvas:focus-visible { outline: 2px solid var(--lane-yellow); outline-offset: -3px; }

.globe-controls {
  position: absolute;
  top: 12px;
  right: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.globe-controls button {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: rgba(27,29,33,0.72);
  color: var(--chalk-dim);
  font-size: 16px;
  line-height: 1;
  backdrop-filter: blur(4px);
  transition: color 0.15s, border-color 0.15s;
}

.globe-controls button:hover { color: var(--chalk); border-color: var(--lane-yellow); }

.globe-tip {
  position: absolute;
  transform: translate(-50%, -170%);
  padding: 5px 10px;
  border-radius: 7px;
  background: rgba(27,29,33,0.92);
  border: 1px solid var(--line);
  font-size: 12.5px;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.12s;
}

.globe-tip.show { opacity: 1; }
.globe-tip.muted { color: var(--chalk-dim); border-style: dashed; }

.globe-hint {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  padding: 10px 18px;
  border-radius: 999px;
  background: rgba(27,29,33,0.88);
  border: 1px solid var(--line);
  font-size: 13px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s;
}

.globe-hint.show { opacity: 1; }

.globe-caption {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 26px 60px 11px 14px;
  font-size: 12.5px;
  color: var(--chalk-dim);
  pointer-events: none;
  /* The globe scrolls under this text, so it carries its own scrim. */
  background: linear-gradient(to top, rgba(20,22,26,0.82), rgba(20,22,26,0));
}

.globe-legend {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  padding: 11px 60px 22px 14px;
  background: linear-gradient(to bottom, rgba(20,22,26,0.82), rgba(20,22,26,0));
  display: flex;
  gap: 14px;
  font-size: 11.5px;
  color: var(--chalk-dim);
  pointer-events: none;
  flex-wrap: wrap;
}

.globe-legend span { display: inline-flex; align-items: center; gap: 6px; }

/* The swatches mirror the globe exactly: filled = in the guide, solid = selected,
   empty outline = not covered. */
.globe-legend i {
  width: 9px;
  height: 9px;
  border-radius: 2px;
  background: rgba(255,255,255,0.16);
  border: 1px solid rgba(255,255,255,0.5);
}

.globe-legend .is-selected-key {
  background: #fff;
  border-color: #fff;
  box-shadow: 0 0 7px rgba(255,255,255,0.7);
}

.globe-legend .is-empty-key {
  background: transparent;
  border-color: rgba(255,255,255,0.3);
}

.globe-legend .is-dot-key { border-radius: 50%; }

/* ---------- Browse layout ---------- */

.browse-body {
  display: grid;
  grid-template-columns: 1fr;
  gap: 22px;
  align-items: start;
}

/* Picking a country pushes the list into a narrow column and opens the panel
   beside it, so nothing navigates away from the globe. */
.browse-body.has-selection {
  grid-template-columns: minmax(230px, 0.8fr) minmax(0, 1.3fr);
}

.list-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.list-scope {
  font-family: 'Barlow Condensed', sans-serif;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 15px;
  color: var(--chalk-dim);
}

.list-scope .count {
  color: var(--lane-yellow);
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  letter-spacing: 0;
}

.clear-scope {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--chalk-dim);
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 12px;
}

.clear-scope:hover { color: var(--chalk); border-color: var(--lane-yellow); }

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

.plate-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  text-align: left;
  color: var(--chalk);
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: transform 0.12s, border-color 0.12s;
}

.plate-card:hover {
  border-color: var(--lane-yellow);
  transform: translateY(-2px);
}

.plate-card .name-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.plate-card h3 { font-size: 22px; }

.side-tag {
  font-size: 11px;
  color: var(--chalk-dim);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 2px 6px;
  font-family: 'JetBrains Mono', monospace;
  text-transform: none;
}

/* Bollard, flag and ccTLD spread across the full width of the card. */
.card-mid {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
}

.flag {
  display: block;
  flex-shrink: 0;
  border-radius: 3.5px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.45);
}

.tld {
  font-size: 12.5px;
  color: var(--lane-yellow);
  background: rgba(242,193,78,0.10);
  border: 1px solid rgba(242,193,78,0.28);
  border-radius: 5px;
  padding: 2px 7px;
}

.detail-title h2 .flag { display: inline-block; vertical-align: -4px; margin-right: 4px; }

.plate-card .tip {
  font-size: 13px;
  color: var(--chalk-dim);
  line-height: 1.45;
}

.plate-card.is-selected {
  border-color: var(--lane-yellow);
  background: rgba(242,193,78,0.09);
}

/* Compact rows once the detail panel is open — the column is much narrower. */
.has-selection .grid { grid-template-columns: 1fr; gap: 8px; }

.has-selection .plate-card {
  flex-direction: row;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
}

/* Compact rows keep the three packed together on the left instead of spread. */
.has-selection .plate-card .card-mid {
  order: -1;
  width: auto;
  flex-shrink: 0;
  justify-content: flex-start;
  gap: 9px;
}

.has-selection .plate-card .card-mid > svg:first-child { width: 26px; height: 26px; }
.has-selection .plate-card .flag { width: 30px; height: 20px; }
.has-selection .plate-card .tld { font-size: 11px; padding: 1px 5px; }
.has-selection .plate-card .name-row { flex: 1; min-width: 0; gap: 8px; }
.has-selection .plate-card .side-tag { flex-shrink: 0; }

/* Compact rows are single-line, so a long name is clipped rather than pushing the
   tag past the edge of the card. The full name is in the panel anyway. */
.has-selection .plate-card h3 {
  font-size: 18px;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.has-selection .plate-card .tip { display: none; }

/* ---------- Detail view ---------- */

.detail-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 22px;
}

.close-btn {
  background: var(--surface-raised);
  border: 1px solid var(--line);
  color: var(--chalk-dim);
  border-radius: 8px;
  width: 32px;
  height: 32px;
  font-size: 20px;
  line-height: 1;
  flex-shrink: 0;
}

.close-btn:hover { color: var(--chalk); border-color: var(--bollard-red); }

.detail-header h2 { font-size: 32px; }
.detail-title { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }

.detail-col {
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 3px solid var(--lane-yellow);
  border-radius: var(--radius);
  padding: 22px 24px 26px;
}

.detail-col .attr-card { background: var(--surface-raised); }
.detail-col .attr-grid { grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }

.attr-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 14px;
}

.attr-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 20px;
}

.attr-card .label {
  font-family: 'Barlow Condensed', sans-serif;
  text-transform: uppercase;
  font-size: 14px;
  letter-spacing: 0.06em;
  color: var(--lane-yellow);
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.attr-card p { margin: 0; font-size: 14px; line-height: 1.55; color: var(--chalk-dim); }

.key-tip-banner {
  background: linear-gradient(135deg, rgba(193,68,60,0.16), rgba(193,68,60,0.04));
  border: 1px solid rgba(193,68,60,0.4);
  border-radius: var(--radius);
  padding: 18px 20px;
  margin-bottom: 20px;
  font-size: 15px;
  line-height: 1.5;
}

.key-tip-banner .label {
  font-family: 'Barlow Condensed', sans-serif;
  text-transform: uppercase;
  color: var(--bollard-red);
  font-size: 13px;
  letter-spacing: 0.06em;
  margin-bottom: 6px;
}

.confused-with {
  margin-top: 24px;
}

.confused-with .label {
  font-size: 13px;
  color: var(--chalk-dim);
  margin-bottom: 10px;
  font-family: 'Barlow Condensed', sans-serif;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.chip-row { display: flex; gap: 8px; flex-wrap: wrap; }

.chip {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 14px;
  font-size: 13px;
  color: var(--chalk);
}

.chip:hover { border-color: var(--sign-blue); }

/* Left half swaps the panel to that country, right half goes to compare. */
.chip-pair { display: inline-flex; align-items: stretch; padding: 0; overflow: hidden; }

.chip-pair button {
  background: transparent;
  border: none;
  color: inherit;
  font-size: 13px;
  padding: 7px 12px;
}

.chip-pair .chip-compare {
  border-left: 1px solid var(--line);
  color: var(--chalk-dim);
  padding: 7px 10px;
}

.chip-pair button:hover { background: rgba(59,110,168,0.22); color: var(--chalk); }

/* confusedWith ids that have no entry in data.js yet — shown, but not clickable. */
.chip-missing {
  display: inline-block;
  opacity: 0.45;
  cursor: default;
  border-style: dashed;
}

.chip-missing:hover { border-color: var(--line); }

/* ---------- Compare view ---------- */

.compare-pickers {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 18px;
  align-items: center;
  margin-bottom: 30px;
}

.picker select {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--chalk);
  border-radius: var(--radius);
  padding: 14px 16px;
  font-size: 18px;
  font-family: 'Barlow Condensed', sans-serif;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  font-weight: 600;
  appearance: none;
}

.picker.left select { border-left: 3px solid var(--sign-blue); }
.picker.right select { border-left: 3px solid var(--bollard-red); }

.vs-mark {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 22px;
  color: var(--chalk-dim);
  font-weight: 700;
}

.compare-empty {
  text-align: center;
  padding: 60px 20px;
  color: var(--chalk-dim);
  border: 1px dashed var(--line);
  border-radius: var(--radius);
}

.diff-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2px;
  background: var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 10px;
  transition: box-shadow 0.2s;
}

.diff-row.is-diff {
  box-shadow: 0 0 0 1px var(--lane-yellow);
}

.diff-cell {
  background: var(--surface);
  padding: 16px 18px;
  transition: opacity 0.2s;
}

.diff-row.is-same .diff-cell { opacity: 0.45; }

.diff-cell .field-label {
  font-family: 'Barlow Condensed', sans-serif;
  text-transform: uppercase;
  font-size: 12px;
  letter-spacing: 0.06em;
  color: var(--chalk-dim);
  margin-bottom: 6px;
}

.diff-row.is-diff .field-label { color: var(--lane-yellow); }

.diff-cell .field-value { font-size: 14px; line-height: 1.5; }
.diff-cell .field-note { font-size: 12.5px; color: var(--chalk-dim); margin-top: 4px; line-height: 1.45; }

.diff-legend {
  display: flex;
  gap: 20px;
  font-size: 12.5px;
  color: var(--chalk-dim);
  margin: 4px 0 22px;
  align-items: center;
}

.legend-swatch { display: inline-flex; align-items: center; gap: 6px; }
.legend-dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }

footer.foot {
  text-align: center;
  color: var(--chalk-dim);
  font-size: 12.5px;
  padding: 40px 24px 20px;
}

@media (min-width: 901px) {
  .detail-col { position: sticky; top: 20px; }
}

@media (max-width: 900px) {
  .browse-body.has-selection { grid-template-columns: 1fr; }
  /* Stacked, the panel belongs above the list it filtered. */
  .browse-body.has-selection .detail-col { order: -1; }
  .has-selection .grid { grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); }
}

@media (max-width: 640px) {
  header.top .inner { flex-direction: column; align-items: flex-start; }
  .globe-caption { font-size: 11.5px; padding-right: 54px; }
  .globe-legend { display: none; }
  /* The panel's own padding leaves the region badge a hair too wide to fit. */
  .detail-col { padding: 18px 16px 22px; }
  .detail-header .side-tag { white-space: normal; }
  .detail-header h2 { font-size: 26px; }
  .compare-pickers { grid-template-columns: 1fr; }
  .vs-mark { justify-self: center; }
  .diff-row { grid-template-columns: 1fr; }
}

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