/* Globe Guesser — page styles (uses the tokens from style.css) */

:root {
  --hot: #b3271e;
  --cold: #1d7a33;
  --overlay: rgba(20, 30, 45, 0.88);
  --arrow: #35507a;
}

@media (prefers-color-scheme: dark) {
  :root {
    --hot: #f0705f;
    --cold: #5cc479;
    --arrow: #9bb8e6;
  }
}

.lede { max-width: var(--measure); }

/* Wide: globe left, guessing + history stacked on the right.
   Narrow: guess box first so it's reachable without scrolling past the globe. */
#gg-app {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-areas: "guess" "globe" "history";
  gap: 1rem 2rem;
  margin-top: 1.5rem;
}

@media (min-width: 820px) {
  #gg-app {
    grid-template-columns: minmax(0, 1.35fr) minmax(18rem, 1fr);
    grid-template-rows: auto 1fr;
    grid-template-areas: "globe guess" "globe history";
  }
}

#guess-area { grid-area: guess; }
#globe-wrap { grid-area: globe; }
#history    { grid-area: history; }

/* ---------- globe ---------- */

#globe-wrap {
  position: relative;
  width: 100%;
  max-width: min(40rem, 85svh); /* keep the whole globe on screen on short laptops */
  justify-self: center;
}

#globe {
  width: 100%;
  aspect-ratio: 1;
  cursor: grab;
  touch-action: none;
}
#globe:active { cursor: grabbing; }
#globe canvas { display: block; }

#globe-msg, #banner {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  max-width: calc(100% - 1.5rem);
  width: max-content;
  text-align: center;
  background: var(--overlay);
  color: #f4f1ea;
  padding: 0.45rem 0.9rem;
  border-radius: 6px;
  font-size: 0.95rem;
  line-height: 1.35;
  pointer-events: none;
}
#globe-msg { top: 50%; transform: translate(-50%, -50%); }
#globe-msg:empty { display: none; }
#banner { top: 0.75rem; font-size: 1.05rem; }

/* Labels pinned to guessed countries; positioned every frame by the JS.
   Each .gg-label sits at its country's point: a dot marks the spot, the
   name tag floats just above it. */
#labels {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.gg-label {
  position: absolute;
  left: 0;
  top: 0;
  opacity: 0;
  will-change: transform, opacity;
}

.gg-dot {
  position: absolute;
  width: 8px;
  height: 8px;
  margin: -4px 0 0 -4px;
  border-radius: 50%;
  background: var(--c);
  box-shadow: 0 0 0 1.5px #fff, 0 1px 3px rgba(0, 0, 0, 0.6);
}

.gg-tag {
  position: absolute;
  left: 0;
  bottom: 9px;
  transform: translateX(-50%);
  white-space: nowrap;
  font-family: var(--sans);
  font-size: 0.72rem;
  line-height: 1.3;
  color: #f4f1ea;
  background: var(--overlay);
  border-bottom: 2px solid var(--c);
  padding: 0.1rem 0.4rem;
  border-radius: 3px;
  transition: opacity 0.15s;
}

.gg-label.tucked .gg-tag { opacity: 0; }

/* the most recent guess sits on top and reads a little louder */
.gg-label.latest { z-index: 1; }
.gg-label.latest .gg-tag { font-size: 0.8rem; font-weight: 600; }
.gg-label.latest .gg-dot { width: 10px; height: 10px; margin: -5px 0 0 -5px; }

#zoom-btns {
  position: absolute;
  right: 0.5rem;
  bottom: 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

/* ---------- controls ---------- */

#gg-app button,
#guess-input {
  font: inherit;
  color: var(--ink);
  border: 1px solid var(--button-border);
  border-radius: 4px;
}

#gg-app button {
  background: var(--button);
  padding: 0.45rem 0.9rem;
  cursor: pointer;
  touch-action: manipulation;
}
#gg-app button:hover:not(:disabled) { background: var(--button-hover); }
#gg-app button:disabled { opacity: 0.5; cursor: default; }

#zoom-btns button {
  width: 2.75rem;
  height: 2.75rem;
  padding: 0;
  font-size: 1.5rem;
  line-height: 1;
  border-radius: 8px;
  background: color-mix(in srgb, var(--button) 92%, transparent);
}

#guess-form { display: flex; gap: 0.5rem; }

#guess-input {
  flex: 1;
  min-width: 0;
  padding: 0.45rem 0.6rem;
  background: var(--field);
  font-size: max(16px, 1rem); /* below 16px, iOS zooms the page on focus */
}

#feedback { min-height: 1.5em; font-weight: 600; margin: 0.6rem 0 0.2rem; }
#stats { color: var(--ink-soft); font-size: 0.9rem; margin: 0; }
#stats:empty { display: none; }

/* ---------- results ---------- */

#results {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
  font-variant-numeric: lining-nums tabular-nums;
  margin-bottom: 1rem;
}
#results th, #results td {
  padding: 0.35rem 0.4rem;
  border-bottom: 1px solid var(--rule);
  text-align: left;
  vertical-align: middle;
}
#results th:first-child, #results td:first-child { padding-left: 0; }
#results th {
  font-weight: normal;
  font-variant: small-caps;
  letter-spacing: 0.05em;
  color: var(--ink-soft);
  border-bottom-color: var(--ink);
}
#results tbody:empty { display: none; }
#results td.num { white-space: nowrap; text-align: right; }
#results td.dir { text-align: center; width: 2.2em; }
#results td.trend { white-space: nowrap; font-size: 0.85rem; }

.swatch {
  display: inline-block;
  width: 0.85em;
  height: 0.85em;
  margin-right: 0.45em;
  border-radius: 2px;
  border: 1px solid rgba(0, 0, 0, 0.25);
  vertical-align: -0.05em;
}

.arrow {
  width: 1.35em;
  height: 1.35em;
  display: inline-block;
  vertical-align: middle;
  transition: transform 0.3s ease;
}
.arrow path { fill: var(--arrow); }

.actions { display: flex; flex-wrap: wrap; gap: 0.5rem; }

.hint { color: var(--ink-soft); font-size: 0.85rem; margin-top: 0.8rem; }

.hot { color: var(--hot); }
.cold { color: var(--cold); }

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
