/* Illinois Policy brand tokens (illinois-policy-style references/brand.md).
   Fonts: Tofino (text) and Geared Slab Thin (display) are the brand fonts.
   They are licensed and not loaded here, so Rubik and Rokkitt stand in as the
   guide's approved unofficial fallbacks. A designer should swap in the real
   fonts for production. */
:root {
  --ip-navy: #23323f;
  --ip-gray: #97a4af;
  --ip-white: #ffffff;
  /* Light gray for panels and bar tracks; same value the chart helper uses for gridlines */
  --ip-gray-light: #e3e7ea;
  --font-text: "Tofino", "Rubik", "Inter", Arial, sans-serif;
  --font-display: "Geared Slab", "Rokkitt", Georgia, serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  font-family: var(--font-text);
  color: var(--ip-navy);
  background: var(--ip-white);
}

/* Column capped at 650px, the width of the paragraph text on the WordPress page */
#app {
  position: relative;
  display: grid;
  grid-template-rows: auto auto 1fr auto;
  width: 100%;
  max-width: 650px;
  margin: 0 auto;
  height: 100vh;
  height: 100dvh;
  background: var(--ip-white);
}
@media (min-width: 651px) {
  #app { border-left: 1px solid var(--ip-gray); border-right: 1px solid var(--ip-gray); }
}

/* Title bar */
#titlebar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: calc(8px + env(safe-area-inset-top)) 12px 8px;
  background: var(--ip-navy);
  color: var(--ip-white);
}
#titlebar .logo { height: 28px; width: auto; flex: 0 0 auto; }
#titlebar h1 {
  margin: 0;
  flex: 1;
  text-align: right;
  font-family: var(--font-display);
  font-weight: 300;
  font-size: 19px;
  line-height: 1.1;
}

/* Status strip */
#statusbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 12px;
  background: var(--ip-white);
  border-bottom: 1px solid var(--ip-gray);
  font-size: 13px;
}
#count { font-weight: 700; font-variant-numeric: tabular-nums; }
#hint { flex: 1; text-align: center; }
#reset {
  border: 1px solid var(--ip-gray); background: var(--ip-white); color: var(--ip-navy);
  border-radius: 8px; padding: 5px 10px; font: inherit; font-size: 13px;
}

#stage { position: relative; min-height: 0; }
#map { position: absolute; inset: 0; }

#toast {
  position: absolute; left: 50%; top: 12px; transform: translateX(-50%);
  background: var(--ip-navy); color: var(--ip-white);
  padding: 8px 14px; border-radius: 999px; font-size: 13px;
  z-index: 7; pointer-events: none; white-space: nowrap;
}

#submit {
  position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%);
  z-index: 6;
  min-height: 48px; padding: 0 26px;
  border: 0; border-radius: 24px;
  background: var(--ip-navy); color: var(--ip-white);
  font: inherit; font-size: 16px; font-weight: 700;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

/* Tray */
#tray {
  display: flex; gap: 8px;
  overflow-x: auto; overflow-y: hidden;
  padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
  background: var(--ip-white); border-top: 2px solid var(--ip-navy);
  -webkit-overflow-scrolling: touch;
  user-select: none; -webkit-user-select: none;
}
/* Shown while a piece is held over the tray: releasing here puts it back */
#tray.drop-target { outline: 3px dashed var(--ip-navy); outline-offset: -3px; }

.tile {
  flex: 0 0 auto;
  width: 74px; height: 80px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  background: var(--ip-white); border: 2px solid var(--ip-gray); border-radius: 12px;
  position: relative;
  touch-action: pan-x;
  user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
  transition: transform 0.35s ease, opacity 0.15s;
}
.tile svg { width: 52px; height: 48px; pointer-events: none; }
.tile .name { font-size: 11px; font-weight: 600; color: var(--ip-navy); pointer-events: none; }

/* Slight shrink while the long-press timer runs */
.tile.pressing { transform: scale(0.92); }
.tile.carried { opacity: 0.3; border-style: dashed; }
/* Placed: gray panel plus a border in the piece's own color */
.tile.placed { background: var(--ip-gray-light); border-color: var(--c); }
.tile.placed::after {
  content: "\2713"; position: absolute; top: 2px; right: 5px;
  font-size: 12px; font-weight: 700; color: var(--ip-navy);
}

/* Thumbnail that follows the finger until the piece is over the map */
#dragghost {
  position: fixed; left: 0; top: 0;
  width: 64px; height: 64px;
  pointer-events: none; z-index: 20;
  filter: drop-shadow(0 6px 8px rgba(0, 0, 0, 0.35));
  will-change: transform;
}
#dragghost svg { width: 100%; height: 100%; }

/* Results */
#results {
  position: absolute; inset: 0; z-index: 30;
  display: flex; align-items: flex-end;
  background: rgba(35, 50, 63, 0.65);
}
#results .card {
  width: 100%; max-height: 94%;
  overflow-y: auto;
  background: var(--ip-white);
  border-radius: 16px 16px 0 0;
  padding: 20px 16px calc(16px + env(safe-area-inset-bottom));
}
#results .score-line {
  margin: 0;
  text-align: center;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 26px;
  line-height: 1.2;
}
#results .score-line strong { font-weight: 700; }
#results .score-line .wrong {
  font-weight: 700;
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 4px;
}
#results .sub { margin: 6px 0 14px; text-align: center; font-size: 14px; }
#results .busy { text-align: center; padding: 28px 0; font-size: 15px; }
#results .table-wrap {
  max-height: 290px; overflow-y: auto;
  border-top: 1px solid var(--ip-gray); border-bottom: 1px solid var(--ip-gray);
}
#results table { width: 100%; border-collapse: collapse; font-size: 13px; }
#results th {
  position: sticky; top: 0; background: var(--ip-white);
  text-align: left; font-weight: 700; padding: 6px 4px;
  border-bottom: 1px solid var(--ip-gray);
}
#results td { padding: 5px 4px; border-bottom: 1px solid var(--ip-gray-light); }
#results td.num { font-variant-numeric: tabular-nums; }
#results .bar {
  display: inline-block; width: 64px; height: 8px; margin-right: 6px;
  background: var(--ip-gray-light); border-radius: 4px; overflow: hidden;
  vertical-align: middle;
}
#results .bar span { display: block; height: 100%; }
#results .actions { display: flex; gap: 10px; margin-top: 16px; }
#results .actions button {
  flex: 1; min-height: 46px; border-radius: 23px;
  font: inherit; font-size: 15px; font-weight: 700;
  border: 2px solid var(--ip-navy);
}
#results .actions .primary { background: var(--ip-navy); color: var(--ip-white); }
#results .actions .secondary { background: var(--ip-white); color: var(--ip-navy); }

.maplibregl-ctrl-attrib { font-size: 10px; }
