/* Three inks on paper: a cobalt sea, the paper itself for land, and vermilion
   for everything the player adds. The globe reads its colours from here, and it
   keeps the same colours in the dark theme so it is always the same object. */
@font-face {
  font-family: "Bricolage Grotesque";
  src: url("/fonts/bricolage-grotesque.woff2") format("woff2");
  font-weight: 200 800;
  font-display: block;
}

:root {
  color-scheme: light dark;
  --page: #F3F4F7;
  --ink: #0B1026;
  --muted: #666E89;
  --rule: #D8DCE6;

  --sea: #1437D2;
  --grid: #2B4CE2;
  --land: #FFFFFF;
  --shade: #0A2190;   /* the hard edge under the land, like cut paper */
  --border: #97A1C4;
  --pin: #FF4A26;
  --on-colour: #0B1026; /* text on the pin colour and on the score colours */

  --near: #19B870;
  --close: #F5B800;
  --off: #FA7A1E;
  --far: #EE4B4F;

  --edge: 20px;
  --spring: cubic-bezier(.2, .9, .25, 1.2);
  --glide: cubic-bezier(.2, .8, .2, 1);
  font-family: "Bricolage Grotesque", "Avenir Next", "Segoe UI", system-ui, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --page: #07090F;
    --ink: #F3F5FB;
    --muted: #8B94AE;
    --rule: #1E2435;
    --sea: #1F45F0;
    --grid: #3659F8;
    --land: #F3F5FB;
    --shade: #1230B5;
    --border: #949EC2;
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; overflow: hidden; overscroll-behavior: none; }
body {
  display: grid;
  grid-template: "top" auto "map" 1fr "bottom" auto / 100%;
  height: 100dvh;
  background: var(--page);
  color: var(--ink);
  font-size: 16px;
  line-height: 1.3;
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
h1, p, ol { margin: 0; padding: 0; }
ol { list-style: none; }

/* The map fills whatever the text blocks leave, and the globe sizes itself to it. */
.map { grid-area: map; position: relative; min-height: 0; overflow: hidden; }
canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
#marks { touch-action: none; cursor: grab; }
/* While guessing, the pointer is the pin's own ring: a click drops the pin at its centre.
   Over a placed pin it is the hand again, because the pin can be dragged. */
#marks[data-aim] { cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='28' height='28'%3E%3Cg fill='none'%3E%3Ccircle cx='14' cy='14' r='10' stroke='%23fff' stroke-width='1.5'/%3E%3Ccircle cx='14' cy='14' r='8' stroke='%23FF4A26' stroke-width='2.5'/%3E%3C/g%3E%3Ccircle cx='14' cy='14' r='2.5' fill='%23fff'/%3E%3Ccircle cx='14' cy='14' r='1.5' fill='%23FF4A26'/%3E%3C/svg%3E") 14 14, crosshair; }
#marks[data-over-pin] { cursor: grab; }
#marks:active { cursor: grabbing; }
#zoom { position: absolute; right: var(--edge); bottom: 8px; display: none; flex-direction: column; gap: 8px; }
@media (pointer: coarse) { #zoom { display: flex; } }
#zoom button { width: 44px; height: 44px; padding: 0; border: 0; border-radius: 50%; background: var(--page); color: var(--ink); box-shadow: inset 0 0 0 1.5px var(--ink); font: inherit; font-size: 24px; line-height: 1; cursor: pointer; }

.top, .bottom { padding-inline: var(--edge); }
.top { grid-area: top; padding-top: max(12px, env(safe-area-inset-top)); padding-bottom: 6px; }
.bottom { grid-area: bottom; padding-bottom: max(16px, env(safe-area-inset-bottom)); }

/* ---------- five rounds, as five strokes ---------- */
#progress { display: flex; gap: 4px; }
#progress li { position: relative; flex: 1; height: 3px; border-radius: 2px; background: var(--rule); overflow: hidden; }
#progress li::after {
  content: ""; position: absolute; inset: 0; border-radius: inherit;
  background: var(--mark, var(--ink));
  transform: scaleX(0); transform-origin: left;
  transition: transform .6s var(--glide), background-color .4s;
}
#progress li[data-state="now"]::after, #progress li[data-grade]::after { transform: none; }
[data-grade="0"] { --mark: var(--near); }
[data-grade="1"] { --mark: var(--close); }
[data-grade="2"] { --mark: var(--off); }
[data-grade="3"] { --mark: var(--far); }

.brand { display: flex; justify-content: space-between; align-items: baseline; margin-top: 12px; font-size: 14px; }
.wordmark { color: inherit; text-decoration: none; font-weight: 700; letter-spacing: -0.005em; }
#date { color: var(--muted); }

/* ---------- the question ---------- */
#title { margin-top: 18px; font-size: clamp(38px, 11.5vw, 50px); line-height: 1; font-weight: 650; letter-spacing: -0.03em; text-wrap: balance; }
#title small { font-size: 0.42em; font-weight: 500; letter-spacing: -0.01em; color: var(--muted); }
#subtitle { margin-top: 6px; font-size: 18px; color: var(--muted); text-wrap: balance; }
/* Two lines at line-height 1.3, so the map does not move when the fact replaces the country. */
#subtitle.two { min-height: 2.6em; }
.rise { animation: rise .45s var(--glide) both; }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } }

/* ---------- the answer ---------- */
#status { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 48px; font-size: 15px; color: var(--muted); }
#status .km { color: var(--ink); font-size: 16px; }
#status .km b { margin-right: 2px; font-size: 32px; font-weight: 650; letter-spacing: -0.02em; }
#status .points {
  padding: 5px 13px 6px; border-radius: 99px;
  background: var(--mark); color: var(--on-colour);
  font-size: 18px; font-weight: 700; letter-spacing: -0.01em;
  opacity: 0;
}
#status .points.in { opacity: 1; animation: pop .5s var(--spring) both; }
@keyframes pop { from { opacity: 0; transform: scale(.4); } }

.actions { display: flex; gap: 10px; }
#action, #more, #double {
  display: block; flex: 1; min-width: 0; height: 56px;
  border: 0; border-radius: 28px;
  background: var(--ink); color: var(--page);
  font: inherit; font-weight: 650; font-size: 17px; letter-spacing: -0.005em;
  cursor: pointer;
  transition: background-color .25s, color .25s, box-shadow .25s, transform .15s var(--glide);
}
#action[data-kind="lock"] { background: var(--pin); color: var(--on-colour); }
#more, #double { background: transparent; color: var(--ink); box-shadow: inset 0 0 0 1.5px var(--ink); }
/* Double: a narrow button to the left of Lock in, in the pin's colour once pressed. It follows Lock in for the keyboard. */
#double { order: -1; flex: none; width: 116px; padding: 0; } /* one width for both labels, so Lock in does not move */
#double[aria-pressed="true"] { background: var(--pin); color: var(--on-colour); box-shadow: none; }
@media (hover: hover) {
  #action:hover:not(:disabled) { box-shadow: 0 0 0 4px color-mix(in srgb, var(--ink) 14%, transparent); }
  #rows button.row:hover { background: color-mix(in srgb, var(--ink) 5%, transparent); }
}
#action:active:not(:disabled), #more:active, #double:active { transform: scale(0.97); }
#action:disabled { background: transparent; color: var(--muted); box-shadow: inset 0 0 0 1.5px var(--rule); cursor: default; }
#action[data-busy] { cursor: progress; }

#compare { display: block; margin: 2px 0 14px; color: var(--ink); font-size: 15px; font-weight: 500; text-underline-offset: 3px; }

/* ---------- results: each row's underline is its score ---------- */
#rows { margin: 0 -8px 14px; }
#rows .head { display: grid; grid-template-columns: 1fr 72px 52px; gap: 12px; padding: 0 8px 4px; font-size: 13px; color: var(--muted); text-align: right; white-space: nowrap; }
#rows .head span::before { content: ""; display: inline-block; width: 8px; height: 8px; margin-right: 6px; border-radius: 50%; }
#rows .head .them::before { background: #fff; box-shadow: inset 0 0 0 2.5px var(--pin); }
#rows .head .you::before { background: var(--pin); }
#rows .row {
  position: relative; display: grid; grid-template-columns: 1fr auto 3ch; align-items: baseline; gap: 12px;
  width: 100%; padding: 9px 8px 11px;
  border: 0; border-radius: 8px; background: none; color: inherit; font: inherit; font-size: 16px; text-align: left;
  animation: rise .5s var(--glide) both; animation-delay: calc(var(--i) * 55ms);
  transition: background-color .2s;
}
#rows.versus .row { grid-template-columns: 1fr 72px 52px; }
#rows button.row { cursor: pointer; }
#rows .row[aria-pressed="true"] { background: color-mix(in srgb, var(--ink) 8%, transparent); }
#rows .row::before, #rows .row::after { content: ""; position: absolute; left: 8px; bottom: 3px; height: 2px; border-radius: 1px; }
#rows .row::before { right: 8px; background: var(--rule); }
#rows .row::after {
  width: calc((100% - 16px) * var(--score) / 100); background: var(--mark);
  transform-origin: left; animation: draw .8s var(--glide) both; animation-delay: calc(var(--i) * 55ms + 250ms);
}
@keyframes draw { from { transform: scaleX(0); } }
#rows .city { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-weight: 600; letter-spacing: -0.01em; }
#rows .tick { display: inline-block; width: 6px; height: 10px; margin: 0 2px 1px 9px; border: solid var(--muted); border-width: 0 2px 2px 0; transform: rotate(45deg); }
#rows .km { color: var(--muted); font-size: 15px; text-align: right; }
#rows .score { text-align: right; font-weight: 650; }

#found { margin: -4px 0 14px; font-size: 15px; color: var(--muted); animation: rise .5s var(--glide) .3s both; }

:focus-visible { outline: 2px solid var(--pin); outline-offset: 2px; }
[hidden] { display: none !important; }
/* Read aloud by screen readers, not shown. */
.quiet { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* Short phones: tighter rows, so the globe keeps some room on the result screen. */
@media (max-height: 620px) {
  #title { margin-top: 12px; font-size: 34px; }
  #rows .row { padding-block: 5px 8px; }
  #rows { margin-bottom: 8px; }
  #status { min-height: 36px; }
  #action, #more, #double { height: 48px; }
}

/* Wide screens: the text takes a column on the left, the globe takes the rest. */
@media (min-width: 880px) {
  :root { --edge: 48px; }
  body { grid-template: "top map" auto "gap map" 1fr "bottom map" auto / calc(380px + 2 * var(--edge)) 1fr; }
  .top { padding-top: 44px; }
  .bottom { padding-bottom: 48px; }
  .brand { margin-top: 16px; font-size: 15px; }
  #title { margin-top: 64px; font-size: 68px; }
  #subtitle { margin-top: 10px; font-size: 21px; }
  #status { min-height: 60px; font-size: 16px; }
  #status .km b { font-size: 40px; }
  #rows { margin-bottom: 20px; }
  #rows .row { padding-block: 11px 13px; font-size: 17px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
  #status .points { opacity: 1; }
}
