/* Countries of the World. Functional layout before the design pass; existing tokens only.
   Mobile: sticky bar (clock, counter, buttons, input), guessed list, map.
   900 px and up: map left (about two thirds), bar, input and list right. */

.q-countries { padding-block: var(--s5) var(--s7); }
.q-countries__intro { display: grid; gap: var(--s2); margin-bottom: var(--s5); max-width: 60ch; }
.q-countries__intro h1 { font-size: 28px; }

.q-countries__game { max-width: none; display: grid; gap: var(--s4); padding: var(--s3); }
.q-countries__game:focus { outline: none; }
.q-countries__side { display: grid; gap: var(--s3); align-content: start; min-width: 0; }

/* ---------- control bar ---------- */
.q-countries__bar {
  position: sticky; top: 0; z-index: 4;
  display: grid; gap: var(--s2);
  margin: calc(-1 * var(--s3)) calc(-1 * var(--s3)) 0; padding: var(--s3);
  background: var(--surface); border-radius: var(--r-card) var(--r-card) 0 0;
}
.q-countries__row { display: flex; align-items: center; gap: var(--s4); flex-wrap: wrap; }
.q-countries__actions { display: flex; gap: var(--s2); margin-left: auto; }
.q-countries__input {
  width: 100%; min-height: 48px; padding: 0 var(--s4);
  font-size: 18px; /* 16 px or more keeps iOS from zooming on focus */
  background: var(--surface); color: var(--ink);
  border: 1px solid var(--line-strong); border-radius: var(--r-pill);
}
.q-countries__input:disabled { opacity: .5; }

/* ---------- guessed list ---------- */
.q-countries__list {
  max-height: calc(4 * 36px + 32px); /* about four rows on mobile, own scroll */
  overflow-y: auto; overscroll-behavior: contain;
  border-top: 1px solid var(--line);
}
.q-countries__table { width: 100%; border-collapse: collapse; font-size: 15px; }
.q-countries__table thead th {
  position: sticky; top: 0; background: var(--surface);
  text-align: left; font-size: 12px; font-weight: 600; color: var(--ink-2); padding: var(--s2);
}
.q-countries__table td { padding: 6px var(--s2); border-bottom: 1px solid var(--line); height: 36px; }
.q-countries__table th:first-child, .q-countries__table td:first-child { width: 3.5em; color: var(--ink-2); }

.q-countries__result { display: grid; gap: var(--s3); padding-block: var(--s2); }
.q-countries__result .fig dd { font-size: 24px; }

/* ---------- map ---------- */
.q-countries__mapwrap { position: relative; min-width: 0; }
.q-countries__map {
  aspect-ratio: 1000 / 425; /* matches the world.svg viewBox, so nothing shifts on load */
  background: var(--surface);
}
.q-countries__map svg { width: 100%; height: 100%; }
.q-countries__map path { stroke: var(--surface); stroke-width: .6px; vector-effect: non-scaling-stroke; stroke-linejoin: round; }
.q-countries__map .na { fill: var(--surface-2); }           /* not an answer: muted, close to the sea */
.q-countries__map .c { fill: var(--line); }                  /* answer, not yet named */
.q-countries__map .tiny { fill: none; stroke: var(--line-strong); stroke-width: 1px; vector-effect: non-scaling-stroke; }
.q-countries__map .c.is-guessed { fill: var(--state-correct); }
.q-countries__map .tiny.is-guessed { stroke: var(--state-correct); }
.q-countries__map .c.is-missed { fill: var(--state-wrong); }
.q-countries__map .tiny.is-missed { stroke: var(--state-wrong); }

/* ---------- named and missed countries after the game (D8) ---------- */
.q-countries__endlist { display: grid; gap: var(--s3); padding-top: var(--s3); border-top: 1px solid var(--line); }
.q-countries__groups { display: grid; gap: var(--s4); }
.q-countries__group { display: grid; gap: var(--s2); }
.q-countries__group h3 { display: flex; gap: var(--s2); align-items: baseline; }
.q-countries__bubbles { display: flex; flex-wrap: wrap; gap: 6px; }
.q-countries__bubbles .state { padding: 2px 10px; border-radius: var(--r-pill); font-size: 14px; line-height: 1.5; }

/* ---------- after the game: names on hover or tap (D8) ---------- */
.q-countries__caption { min-height: 1.5em; margin-top: var(--s2); font-size: 15px; }
.q-countries__map svg.is-revealed .c { cursor: pointer; }
.q-countries__map svg.is-revealed .c:hover { opacity: .75; }

/* ---------- your stats ---------- */
.q-countries__stats { max-width: none; display: grid; gap: var(--s4); margin-top: var(--s5); padding: var(--s4); }
.q-countries__stats .figs { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.q-countries__stats .fig dd { font-size: 24px; }
.q-countries__recent { overflow-x: auto; }
.q-countries__recent caption { text-align: left; padding-bottom: var(--s2); }
.q-countries__recent th:first-child, .q-countries__recent td:first-child { width: auto; color: inherit; }

/* ---------- page text below the quiz ---------- */
.q-countries__about { display: grid; gap: var(--s3); max-width: 72ch; margin-top: var(--s7); }
.q-countries__about h2 { margin-top: var(--s4); }
.q-countries__about h3 { margin-top: var(--s2); }
.q-countries__about ol, .q-countries__about ul { margin: 0; padding-left: 1.4em; display: grid; gap: var(--s1); }
.q-countries__names th[scope="row"] { font-weight: 600; text-align: left; padding: 6px var(--s2); border-bottom: 1px solid var(--line); }
.q-countries__names th:first-child { width: 40%; color: inherit; } /* not the narrow "#" column of the guessed list */
.q-countries__names thead th { position: static; } /* not in a scroll box: don't stick to the viewport */

/* ---------- pause: cover map and list ---------- */
.q-countries__pause { inset: 0; padding: var(--s4); align-content: center; }
.q-countries__pause p { font-size: 18px; }
.q-countries.is-paused .q-countries__map,
.q-countries.is-paused .q-countries__list { visibility: hidden; }

@media (min-width: 900px) {
  .q-countries__game { grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr); padding: var(--s5); gap: var(--s5); }
  .q-countries__mapwrap { grid-column: 1; grid-row: 1; align-self: start; }
  .q-countries__side { grid-column: 2; grid-row: 1; }
  .q-countries__bar { margin: 0; padding: 0; position: static; }
  .q-countries__list { max-height: 420px; }
  .q-countries__endlist { grid-column: 1 / -1; }
}
