/* Game timer (web/assets/js/games/timer.js): the 1/2/3-minute picker and the countdown. */

/* Picker: 1–10 minutes (5 × 2 big buttons) and "No timer", before the game starts */
.tm-pick { margin: 6px auto 16px; max-width: 460px; text-align: center; }
.tm-pick-title { margin: 0 0 8px; font: 700 18px var(--font-display); color: var(--ink); }
.tm-pick-row { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.tm-pick button { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-height: 72px; border: 3px solid var(--line); border-radius: 20px;
  background: var(--card); color: var(--ink); cursor: pointer; font-family: var(--font-display); box-shadow: 0 4px 0 var(--line); transition: transform .12s, border-color .12s, background .12s; }
.tm-pick button b { font-size: 30px; line-height: 1; }
.tm-pick button span { font-size: 13px; font-weight: 600; color: var(--muted); }
.tm-pick .tm-off { flex-direction: row; gap: 8px; width: 100%; min-height: 54px; margin-top: 8px; font-size: 18px; font-weight: 700; }
.tm-pick .tm-off span { font-size: 22px; color: inherit; }
.tm-pick button:hover { border-color: var(--edge-purple); }
.tm-pick button:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--line); }
.tm-pick button.on { border-color: var(--primary); background: var(--primary-soft); box-shadow: 0 4px 0 var(--primary); }
.tm-pick button.on span { color: var(--link-strong); }
.tm-pick button:focus-visible { outline: 3px solid var(--yellow); outline-offset: 2px; }

/* /play: the picker screen before a knowledge-pack game */
.tm-ready { padding: 18px 0 8px; text-align: center; }
.tm-ready #tm-go { min-width: 200px; min-height: 56px; font-size: 20px; }
/* KG corner menu */
#kg-timer .tm-pick { margin-top: 0; }

/* Countdown: a sticky pill above the game */
.tm-clock { position: sticky; top: 8px; z-index: 20; display: flex; align-items: center; gap: 10px; width: fit-content; margin: 0 auto 12px; padding: 6px 18px 6px 8px;
  border-radius: 999px; background: var(--card); border: 3px solid var(--edge-green); box-shadow: var(--shadow); color: var(--ink); overflow: hidden; }
[dir="rtl"] .tm-clock { padding: 6px 8px 6px 18px; }
.tm-ring { width: 46px; height: 46px; flex: none; rotate: -90deg; }
.tm-ring circle { fill: none; stroke-width: 6; }
.tm-ring-bg { stroke: var(--tint-green); }
.tm-ring-fg { stroke: var(--green); stroke-linecap: round; transition: stroke-dashoffset .2s linear, stroke .3s; }
.tm-icon { position: absolute; inset-inline-start: 8px; width: 46px; text-align: center; font-size: 20px; line-height: 46px; }
.tm-label { font: 600 15px var(--font-display); color: var(--muted); }
.tm-num { font: 700 32px/1 var(--font-display); font-variant-numeric: tabular-nums; min-width: 3ch; direction: ltr; unicode-bidi: isolate; }
.tm-bar { position: absolute; inset-inline: 0; bottom: 0; height: 4px; background: transparent; }
.tm-bar .tm-fill { display: block; height: 100%; background: var(--green); transition: width .2s linear; }
.tm-clock.warn { border-color: var(--edge-orange); }
.tm-clock.warn .tm-ring-fg, .tm-clock.warn .tm-bar .tm-fill { stroke: var(--orange); background: var(--orange); }
.tm-clock.warn .tm-num { color: #d9630f; }
.tm-clock.danger { border-color: var(--edge-red); background: var(--card); animation: tm-pulse 1s ease-in-out infinite; }
.tm-clock.danger .tm-ring-fg, .tm-clock.danger .tm-bar .tm-fill { stroke: var(--danger); background: var(--danger); }
.tm-clock.danger .tm-num { color: var(--danger-ink); }
.tm-clock.up { animation: none; opacity: .7; }
@keyframes tm-pulse { 50% { transform: scale(1.06); } }

/* KG: a friendly turtle walks to the flag (no red, no ticking) */
.tm-gentle { width: min(440px, 100%); padding: 8px 16px; gap: 12px; border-color: var(--edge-yellow); background: var(--card); }
[dir="rtl"] .tm-gentle { padding: 8px 16px; }
.tm-track { position: relative; flex: 1; height: 36px; border-radius: 999px; background: var(--tint-yellow); overflow: hidden; }
.tm-track .tm-fill { position: absolute; inset-inline-start: 0; top: 0; bottom: 0; background: #ffe39a; transition: width .2s linear; }
.tm-walker, .tm-flag { position: absolute; top: 0; z-index: 1; font-size: 26px; line-height: 36px; }
.tm-walker { inset-inline-start: 0; transition: inset-inline-start .2s linear; }
.tm-walker:dir(ltr) { transform: scaleX(-1); } /* the turtle emoji faces left; turn it to walk right */
.tm-flag { inset-inline-end: 4px; }
.tm-gentle .tm-num { font-size: 22px; min-width: 0; color: var(--yellow-ink); }

/* Time's up: the game stops taking taps while the result loads */
.tm-frozen { pointer-events: none; opacity: .55; transition: opacity .3s; }

/* Result screen */
.tm-up { display: flex; flex-direction: column; align-items: center; gap: 2px; margin: 0 auto 12px; padding: 10px 18px; max-width: 420px; border-radius: 20px; background: var(--tint-yellow); animation: kg-pop .4s ease; }
.tm-up b { font: 700 24px var(--font-display); }
.tm-up span { color: var(--muted); font-weight: 700; }
.tm-late { margin: 0 auto 12px; max-width: 460px; color: var(--danger-ink); font-weight: 700; }

@media (max-width: 480px) {
  .tm-pick-row { gap: 6px; }
  .tm-pick button { min-height: 64px; border-radius: 16px; border-width: 2px; }
  .tm-pick button b { font-size: 26px; }
  .tm-pick button span { font-size: 11px; }
  .tm-num { font-size: 28px; }
  .tm-label { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .tm-clock.danger, .tm-up { animation: none; }
}
