/* Token game on the AI playground page (js/token-game.js). Same layout as stop 01 in the
   Developed by Me project: the idea on the left (title and claim), the game card on the right
   (the challenge and preview with its pass/fail, then the sliders and save, then the details
   of how the colour changes, collapsed). Reads this site's tokens, so the section re-colours with everything else. */

.tg {
  --tg-border: var(--line);
  --tg-border-strong: var(--muted);
  --tg-ok: #16683a;
  --tg-bad: #b42318;
  padding: calc(var(--header-clear) + 24px) 0 clamp(40px, 5vw, 64px);
}
.tg-grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: clamp(28px, 3vw, 48px); align-items: start; }
.tg-concept { grid-column: span 5; display: grid; gap: 16px; align-content: center; }
.tg-work { grid-column: span 7; display: grid; gap: 12px; min-width: 0; }

/* ---------- concept ---------- */
.tg-display {
  font-family: var(--font-display); font-weight: 400; font-size: clamp(30px, 3.3vw, 48px);
  line-height: 1.05; letter-spacing: -.04em; margin: 0; color: var(--ink); text-wrap: balance;
}
.tg-claim { max-width: 44ch; margin: 0; font-size: 18px; line-height: 1.55; color: var(--muted); text-wrap: pretty; }
.tg-claim strong { color: var(--ink); font-weight: 600; }
/* ---------- work ---------- */
.tg-dare { margin: 0 0 20px; font-family: var(--font-display); font-size: clamp(19px, 1.8vw, 22px); font-weight: 400; line-height: 1.3; letter-spacing: -.02em; color: var(--ink); text-wrap: balance; }
.tg-stage { position: relative; padding: 24px; border: 1.5px solid var(--tg-border-strong); border-radius: var(--r-box); background: var(--card); }


/* Hierarchy inside the stage: 1. preview + pass/fail, 2. controls + save, 3. details (collapsed) */
.tg-preview { display: grid; gap: 12px; min-width: 0; }
.tg-checks { display: flex; flex-wrap: wrap; gap: 8px; }
.tg-chip {
  display: inline-flex; align-items: center; gap: 6px; min-height: 28px; padding: 0 12px;
  border-radius: 999px; border: 1px solid currentColor; background: var(--bg);
  font-size: 13px; font-weight: 600; white-space: nowrap;
}
.tg-controls { display: grid; gap: 8px; margin-top: 24px; }
.tg-pick-value { font-weight: 400; color: var(--muted); font-variant-numeric: tabular-nums; }

.tg-bar { display: grid; gap: 6px; }
.tg-bar-label { font-size: 13px; font-weight: 600; color: var(--ink); }

/* the bars: each track shows the colours that bar gives, at the other two settings */
.tg-range { -webkit-appearance: none; appearance: none; width: 100%; height: 26px; margin: 0; background: none; cursor: pointer; }
.tg-range::-webkit-slider-runnable-track { height: 14px; border-radius: 999px; background: var(--tg-track, var(--line)); box-shadow: inset 0 0 0 1px rgb(var(--ink-rgb) / .12); }
.tg-range::-moz-range-track { height: 14px; border-radius: 999px; background: var(--tg-track, var(--line)); box-shadow: inset 0 0 0 1px rgb(var(--ink-rgb) / .12); }
.tg-range::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none; width: 22px; height: 22px; margin-top: -4px; border-radius: 50%;
  background: var(--tg-draft); border: 3px solid #fff; box-shadow: 0 0 0 1px rgb(var(--ink-rgb) / .4), 0 3px 8px -3px rgb(var(--ink-rgb) / .45);
}
.tg-range::-moz-range-thumb {
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--tg-draft); border: 3px solid #fff; box-shadow: 0 0 0 1px rgb(var(--ink-rgb) / .4), 0 3px 8px -3px rgb(var(--ink-rgb) / .45);
}
.tg-range:focus-visible { outline: none; }
.tg-range:focus-visible::-webkit-slider-thumb { box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--focus); }
.tg-range:focus-visible::-moz-range-thumb { box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--focus); }
.tg-range:disabled { cursor: not-allowed; opacity: .6; }

.tg-actions { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-top: 16px; }
.tg-actions .tg-btn { flex: 1 1 auto; max-width: 320px; }
.tg-rule:not([hidden]) { margin-top: 14px; }

/* the details: how the colour changes, one level down */
.tg-details { margin-top: 20px; border-top: 1px solid var(--tg-border); }
.tg-details summary {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 0 0; cursor: pointer; list-style: none;
  font-family: var(--font-sans); font-size: 15px; font-weight: 600; color: var(--ink);
}
.tg-details summary::-webkit-details-marker { display: none; }
.tg-details summary::after {
  content: ""; flex: none; width: 8px; height: 8px; margin-right: 4px;
  border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor;
  transform: translateY(-2px) rotate(45deg); transition: transform .2s var(--ease);
}
.tg-details[open] summary::after { transform: translateY(2px) rotate(-135deg); }
.tg-details summary:hover { color: var(--primary); }
.tg-details summary:focus-visible { outline: 2px solid var(--focus); outline-offset: 4px; border-radius: 4px; }
.tg-details-body { display: grid; gap: 20px; padding-top: 18px; }
.tg-detail { display: grid; gap: 8px; min-width: 0; }
.tg-detail + .tg-detail { padding-top: 18px; border-top: 1px solid var(--tg-border); }
.tg-detail-title { margin: 0; font-size: 14px; font-weight: 600; color: var(--ink); }
.tg-detail-text { margin: 0; font-size: 14px; line-height: 1.5; color: var(--muted); }
.tg-detail-text .is-ok, .tg-detail-text .is-bad { font-weight: 600; }

/* the preview card: a case-study card drawn in the draft colour */
.tg-card { overflow: hidden; border: 1px solid var(--tg-border); border-radius: var(--r-card); background: var(--bg); }
.tg-card-band { padding: 22px 16px; background: var(--tg-draft); color: #fff; transition: background-color .2s var(--ease); }
.tg-card-kicker { margin: 0; font-family: var(--font-mono); font-size: 12px; font-weight: 500; letter-spacing: .1em; text-transform: uppercase; }
.tg-card-title { margin: 2px 0 0; font-family: var(--font-display); font-size: 24px; font-weight: 400; line-height: 1.1; letter-spacing: -.03em; }
.tg-card-body { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px; font-size: 14px; color: var(--tg-draft-body, var(--body)); background: var(--tg-draft-sage, var(--bg-sage)); transition: background-color .2s var(--ease), color .2s var(--ease); }
.tg-card-body b { color: var(--tg-draft); font-weight: 600; }

.tg-field { margin: 0; font-size: 14px; font-weight: 600; color: var(--ink); }
.tg-rule {
  margin: 0; padding: 12px; border-left: 4px solid var(--primary); border-radius: 6px;
  background: var(--bg-sage); font-size: 14px; line-height: 1.5; color: var(--ink-2);
}
.tg-rule[hidden] { display: none; }

/* token tiers (inside the details) */
.tg-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.tg-table th, .tg-table td { padding: 6px 8px; border-bottom: 1px solid var(--tg-border); text-align: left; vertical-align: middle; }
.tg-table th { font-family: var(--font-mono); font-size: 12px; font-weight: 500; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.tg-table code { font-family: var(--font-mono); font-size: 12px; color: var(--ink); overflow-wrap: anywhere; }
.tg-swatch { display: inline-block; width: 12px; height: 12px; margin-right: 6px; border-radius: 4px; background: var(--primary); vertical-align: middle; }

/* colour-blind check */
.tg-vision { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.tg-vision-set { display: flex; height: 22px; border-radius: 6px; overflow: hidden; box-shadow: inset 0 0 0 1px rgb(var(--ink-rgb) / .1); }
.tg-vision-set i { flex: 1 1 0; }
.tg-vision-set i:first-child { flex-grow: 2; }
.tg-vision-name { display: block; margin-top: 4px; font-family: var(--font-mono); font-size: 11px; color: var(--muted); text-align: center; }

.is-ok { color: var(--tg-ok); }
.is-bad { color: var(--tg-bad); }

/* ---------- buttons (pill, as in Developed by Me) ---------- */
.tg-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 24px; border-radius: 999px;
  border: 1.5px solid var(--tg-border-strong); background: var(--card); color: var(--ink);
  font-family: var(--font-sans); font-size: 16px; font-weight: 600; white-space: nowrap; cursor: pointer; text-decoration: none;
  transition: transform .14s var(--ease), background-color .14s var(--ease), filter .14s var(--ease);
}
.tg-btn:hover:not(:disabled) { background: var(--bg-sage); }
.tg-btn:active:not(:disabled) { transform: translateY(1px); }
.tg-btn:disabled { cursor: not-allowed; opacity: .55; }
.tg-btn:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; }
.tg-btn-primary { border-color: var(--primary); background: var(--primary); color: var(--on-primary); }
.tg-btn-primary:hover:not(:disabled) { background: var(--primary); filter: brightness(1.12); }
.tg-btn-ghost { border-color: transparent; background: transparent; }

/* ---------- a quiet reset beside Save ---------- */
.tg-reset {
  font-family: var(--font-sans); font-size: 13px; font-weight: 500; color: var(--muted);
  padding: 4px 6px; margin: 0 -6px 0 0; border: 0; border-radius: 6px; background: none; cursor: pointer;
  text-decoration: underline; text-decoration-color: var(--line); text-underline-offset: 3px;
  transition: color .14s var(--ease), text-decoration-color .14s var(--ease);
}
.tg-reset:hover:not(:disabled) { color: var(--ink); text-decoration-color: currentColor; }
.tg-reset:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.tg-reset:disabled { opacity: .5; cursor: default; text-decoration: none; }
/* the game underneath gets its own short label */
.tg-next { margin: 0 0 16px; font-family: var(--font-mono); font-size: 12px; font-weight: 500; letter-spacing: .1em; text-transform: uppercase; color: var(--ink); }

/* ---------- responsive ---------- */
@media (max-width: 1100px) {
  .tg-concept, .tg-work { grid-column: 1 / -1; }
}
@media (max-width: 640px) {
  .tg-stage { padding: 16px; }
}
@media (prefers-reduced-motion: reduce) {
  .tg-card-band, .tg-btn, .tg-details summary::after { transition: none; }
}
.tg-table td:nth-child(2) code { white-space: nowrap; overflow-wrap: normal; }

/* Once a visitor has saved a colour (html.tg-played, set by js/token-game.js), this page's
   headings take that colour. Before that they keep the default ink. */
html.tg-played .tg-display, html.tg-played .tg-next, html.tg-played .tg-dare { color: var(--primary); }
