/* Puzzles: the hub, the player (stage, options, calm timer, acknowledgement) and the debug playground. */

/* ─── Hub ────────────────────────────────────────────────────────────────── */

.puzzles-home > .notice { margin-top: 1.5rem; } /* the signed-out stand-in for .tiles */
.tiles { margin-top: 1.5rem; display: grid; grid-template-columns: 1fr; gap: 0.75rem; }
.tiles + .settings-note { margin-top: 1.25rem; }
.tile { padding: 1rem 1.25rem; }
.tile-title { font-family: var(--font-serif); font-size: 1.125rem; line-height: 1.75rem; font-weight: 600; color: var(--ink); }
.tile-body { margin-top: 0.25rem; line-height: 1.55; color: var(--ink-2); }
.tile form { margin-top: 0.875rem; }
.tile-label { font-size: 0.875rem; color: var(--muted); }
.streak { margin-top: 0.25rem; display: flex; align-items: baseline; gap: 0.5rem; }
.streak-flame { font-size: 1.5rem; }
.streak-number { font-size: 2rem; line-height: 1; font-weight: 600; color: var(--ink); }
.tile-unit { font-size: 0.875rem; color: var(--muted); }
.tile-foot { margin-top: 0.5rem; font-size: 0.75rem; line-height: 1.625; color: var(--muted); }
.tile-foot:empty { display: none; }
.tile-value { margin-top: 0.25rem; display: flex; align-items: center; gap: 0.5rem; font-size: 1.0625rem; font-weight: 600; color: var(--ink); }
.tile-progress { margin-top: 0.625rem; }

.puzzle-card { margin-top: 0.75rem; border-radius: 1.5rem; padding: 1.5rem 1.25rem; }
.puzzle-card.is-dashed { border-style: dashed; border-color: var(--line-strong); }
.puzzle-card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; }
.puzzle-card h2 { margin-top: 0.25rem; font-family: var(--font-serif); font-size: 1.5rem; line-height: 2rem; font-weight: 600; letter-spacing: -0.025em; }
.puzzle-card .panel-note { max-width: 28rem; }
.puzzle-card-action { margin-top: 1.25rem; }
.kicker { font-size: 0.75rem; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.panel-note { margin-top: 0.25rem; font-size: 0.9375rem; color: var(--muted); }
.logged { display: inline-flex; align-items: center; gap: 0.5rem; border-radius: 9999px; background: var(--surface-2); padding: 0.5rem 1rem; font-size: 0.875rem; font-weight: 500; color: var(--ink-2); }
.dots { display: flex; gap: 0.375rem; }
.dot { height: 0.5rem; width: 0.5rem; border-radius: 9999px; background: var(--surface-3); }
.dot.is-on { background: var(--ink); }

.panel { border-radius: 1.5rem; padding: 1.75rem 1.25rem; }
* + .panel { margin-top: 1.5rem; }
.panel h2 { margin-top: 1rem; font-family: var(--font-serif); font-size: 1.25rem; line-height: 1.75rem; font-weight: 600; }
.panel .panel-note { margin-top: 0.375rem; line-height: 1.625; }
.panel .button-row { margin-top: 1.25rem; }
.panel-title { font-family: var(--font-serif); font-size: 1.5rem; line-height: 2rem; font-weight: 600; color: var(--ink); }

.welcome-banner { margin-bottom: 1.5rem; border-radius: 1.5rem; background: var(--ink); padding: 1.5rem 1.25rem; color: var(--surface); animation: bt-fade-up 260ms cubic-bezier(0.2, 0.7, 0.2, 1) both; }
.welcome-banner .kicker { color: inherit; opacity: 0.7; }
.welcome-banner h2 { margin-top: 0.5rem; font-family: var(--font-serif); font-size: 1.5rem; line-height: 1.375; font-weight: 600; }
.welcome-banner-body { margin-top: 0.5rem; max-width: 32rem; font-size: 0.9375rem; line-height: 1.625; opacity: 0.8; }
.welcome-banner .button-row { margin-top: 1.25rem; }
.welcome-later { display: inline-flex; height: 2.5rem; align-items: center; border-radius: 9999px; padding: 0 1rem; font-size: 0.9375rem; font-weight: 500; opacity: 0.8; }
.welcome-later:hover { background: color-mix(in oklab, var(--surface) 12%, transparent); opacity: 1; }

.debug-link {
  margin-top: 0.75rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-radius: 1rem;
  border: 1px dashed color-mix(in oklab, var(--amber) 70%, transparent);
  padding: 0.75rem 1rem;
  font-size: 0.875rem;
  color: var(--ink-2);
}
.debug-link:hover { background: color-mix(in oklab, var(--amber) 10%, transparent); }
.debug-link strong { color: var(--ink); }

/* ─── Player ─────────────────────────────────────────────────────────────── */

.question { display: flex; flex-direction: column; gap: 1.25rem; animation: bt-fade-up 260ms cubic-bezier(0.2, 0.7, 0.2, 1) both; }
.question-top { display: flex; align-items: center; gap: 1rem; }
.question-progress { min-width: 0; flex: 1; }
.question-where { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; }
.question-where p { font-size: 0.875rem; font-weight: 500; color: var(--ink-2); }
.exit { display: inline-flex; align-items: center; gap: 0.25rem; font-size: 0.875rem; color: var(--muted); }
.exit:hover { color: var(--ink); }
.question-bar { margin-top: 0.5rem; }

/* A calm countdown: a thin neutral ring that quietly empties. No urgency. */
.timer { position: relative; height: 2.75rem; width: 2.75rem; flex-shrink: 0; }
.timer-ring { height: 2.75rem; width: 2.75rem; transform: rotate(-90deg); }
.timer-clock { position: absolute; inset: 0; margin: auto; height: 1rem; width: 1rem; color: var(--muted); }

.stage { display: flex; flex-direction: column; gap: 1rem; }
.stage-title { font-family: var(--font-serif); font-size: 1.625rem; line-height: 1.25; font-weight: 600; letter-spacing: -0.025em; color: var(--ink); }
.stage-hint { margin-top: 0.25rem; font-size: 0.9375rem; color: var(--muted); }

.puzzle-canvas { display: block; height: 100%; width: 100%; }
.stem { aspect-ratio: 16 / 9; width: 100%; overflow: hidden; border-radius: 1rem; border: 1px solid var(--line); background: var(--surface); }
/* A worked example of the rule, never mistaken for the thing to match. */
.stem-example { display: flex; aspect-ratio: auto; align-items: center; gap: 0.75rem; border-radius: 0.75rem; border: 1px dashed var(--line); background: var(--surface-2); padding: 0.625rem; }
.stem-example-canvas { aspect-ratio: 36 / 11; width: 10rem; flex-shrink: 0; overflow: hidden; border-radius: 0.5rem; background: var(--surface); }
.stem-example figcaption { font-size: 0.8125rem; line-height: 1.375; color: var(--muted); }

.options { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.75rem; }
/* Selection is neutral: ink, never green or red (the ring is drawn above the canvas). */
.option {
  --ring-w: 1px;
  --ring-c: var(--line);
  position: relative;
  overflow: hidden;
  border-radius: 1rem;
  background: var(--surface);
  text-align: left;
  transition: transform 0.15s;
}
.option::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  box-shadow: inset 0 0 0 var(--ring-w) var(--ring-c);
  pointer-events: none;
  transition: box-shadow 0.15s;
}
.option:hover:not(:disabled) { --ring-c: var(--line-strong); }
.option:active:not(:disabled) { transform: scale(0.99); }
.option:disabled { cursor: default; }
.option.is-selected { --ring-w: 2px; --ring-c: var(--ink); }
.option.is-answer { --ring-w: 4px; --ring-c: var(--ok-ring); }
.option.is-wrong { --ring-w: 4px; --ring-c: var(--danger); }
.option.is-dim { opacity: 0.5; }
.option-canvas { aspect-ratio: 4 / 3; width: 100%; }
.option-letter {
  position: absolute;
  top: 0.625rem;
  left: 0.625rem;
  z-index: 10;
  display: flex;
  height: 1.75rem;
  width: 1.75rem;
  align-items: center;
  justify-content: center;
  border-radius: 9999px;
  background: var(--surface-2);
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--ink-2);
  transition: background-color 0.15s, color 0.15s;
}
.option-letter.is-selected { background: var(--ink); color: var(--surface); }
.option-badge { position: absolute; top: 0.625rem; right: 0.625rem; z-index: 10; border-radius: 9999px; padding: 0.125rem 0.5rem; font-size: 0.75rem; font-weight: 600; color: #fff; }
.option-badge.is-answer { background: var(--ok-strong); }
.option-badge.is-wrong { background: var(--danger-fill); }

.confirm-bar {
  position: sticky;
  bottom: 5rem;
  z-index: 10;
  margin: 0 -1rem;
  background: linear-gradient(to top, var(--page) 60%, transparent);
  padding: 1.5rem 1rem 0.5rem;
}
.confirm-tip { margin-top: 0.5rem; display: none; text-align: center; font-size: 0.75rem; color: var(--muted); }

/* The one acknowledgement every answer gets: right, wrong or late. */
.ack { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1rem; padding: 5rem 0; text-align: center; }
.ack-badge { animation: bt-pop 420ms cubic-bezier(0.2, 0.7, 0.2, 1) both; display: flex; height: 5rem; width: 5rem; align-items: center; justify-content: center; border-radius: 9999px; background: var(--surface); box-shadow: 0 0 0 1px var(--line); }
.ack-check { height: 2.25rem; width: 2.25rem; }
.ack-text { animation: bt-fade-up 260ms cubic-bezier(0.2, 0.7, 0.2, 1) both; font-family: var(--font-serif); font-size: 1.5rem; line-height: 2rem; font-weight: 600; color: var(--ink); }

.summary { display: flex; flex-direction: column; align-items: center; padding-top: 1.5rem; text-align: center; animation: bt-fade-up 260ms cubic-bezier(0.2, 0.7, 0.2, 1) both; }
.summary h1 { margin-top: 1.25rem; font-family: var(--font-serif); font-size: 2rem; line-height: 1.25; font-weight: 600; letter-spacing: -0.025em; }
.summary-line { margin-top: 0.5rem; max-width: 24rem; font-size: 1.0625rem; line-height: 1.625; color: var(--ink-2); }
.summary-tiles { margin-top: 1.75rem; display: grid; width: 100%; grid-template-columns: repeat(2, 1fr); gap: 0.75rem; text-align: left; }
.summary-number { font-size: 1.75rem; line-height: 1; font-weight: 600; }
.summary-cal-note { margin-top: 1rem; font-size: 0.875rem; }
.summary-cal-note.is-strong { color: var(--ink-2); font-weight: 400; }
.summary-actions { margin-top: 2rem; display: flex; width: 100%; flex-direction: column; gap: 0.75rem; }

.player-loading { display: flex; flex-direction: column; gap: 1.25rem; }
.player-loading-top { display: flex; align-items: center; gap: 1rem; }

/* ─── Levels that are played (push_block) ────────────────────────────────── */

.pb-board {
  position: relative;
  aspect-ratio: 4 / 3;
  max-height: min(68vh, 34rem);
  width: 100%;
  overflow: hidden;
  border-radius: 1.25rem;
  border: 1px solid var(--line);
  background: var(--surface-2);
}
.pb-canvas { display: block; height: 100%; width: 100%; touch-action: none; cursor: pointer; outline: none; }
.pb-board:has(.pb-canvas:focus-visible) { box-shadow: 0 0 0 3px var(--focus); }
.pb-tools { position: absolute; top: 0.625rem; right: 0.625rem; display: flex; gap: 0.375rem; }
.pb-tool {
  display: flex;
  height: 2.5rem;
  width: 2.5rem;
  align-items: center;
  justify-content: center;
  border-radius: 9999px;
  background: color-mix(in oklab, var(--surface) 82%, transparent);
  color: var(--ink);
  box-shadow: var(--shadow-sm);
  backdrop-filter: blur(6px);
  transition: transform 0.15s, background-color 0.15s;
}
.pb-tool:hover:not(:disabled) { background: var(--surface); }
.pb-tool:active:not(:disabled) { transform: scale(0.94); }
.pb-tool:disabled { opacity: 0.4; }
.pb-bar { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.pb-pad { display: grid; grid-template-columns: repeat(3, 3rem); grid-template-rows: repeat(2, 2.75rem); gap: 0.375rem; user-select: none; -webkit-user-select: none; }
.pb-pad button {
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 0.875rem;
  background: var(--surface-2);
  color: var(--ink);
  touch-action: none;
  transition: transform 0.1s, background-color 0.15s;
}
.pb-pad button:active:not(:disabled) { transform: scale(0.94); background: var(--surface-3); }
.pb-pad button:disabled { opacity: 0.4; }
.pb-pad-up { grid-column: 2; grid-row: 1; }
.pb-pad-left { grid-column: 1; grid-row: 2; }
.pb-pad-down { grid-column: 2; grid-row: 2; }
.pb-pad-right { grid-column: 3; grid-row: 2; }
.pb-giveup { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 0.25rem 0.75rem; font-size: 0.875rem; color: var(--muted); }
.pb-giveup-q { color: var(--ink-2); }
.pb-link { padding: 0.375rem 0.25rem; font-size: 0.875rem; color: var(--muted); text-decoration: underline; text-underline-offset: 0.2em; }
.pb-link:hover { color: var(--ink); }
.pb-link.is-strong { font-weight: 600; color: var(--ink); }
.pb-rules { border-radius: 1rem; background: var(--surface-2); padding: 0.75rem 1rem; font-size: 0.875rem; color: var(--ink-2); }
.pb-rules summary { cursor: pointer; font-weight: 600; color: var(--ink); }
.pb-rules ul { margin-top: 0.625rem; display: grid; gap: 0.5rem; }
.pb-rules li { display: flex; align-items: center; gap: 0.625rem; line-height: 1.4; }
.pb-rules svg { flex-shrink: 0; }

@media (hover: hover) and (pointer: fine) {
  /* With a keyboard and mouse the pad is a spare: smaller, to the side. */
  .pb-pad { grid-template-columns: repeat(3, 2.5rem); grid-template-rows: repeat(2, 2.25rem); }
}

/* ─── Debug playground ───────────────────────────────────────────────────── */

.debug { display: flex; flex-direction: column; gap: 1.25rem; }
.debug-loading { display: flex; flex-direction: column; gap: 0.75rem; }
.debug-banner {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  border-radius: 1rem;
  border: 1px dashed color-mix(in oklab, var(--amber) 70%, transparent);
  background: color-mix(in oklab, var(--amber) 10%, transparent);
  padding: 0.75rem 1rem;
  font-size: 0.875rem;
  color: var(--ink-2);
}
.debug-banner > .icon { margin-top: 0.125rem; color: var(--amber-strong); }
.debug-banner strong { color: var(--ink); }
.debug-controls { display: grid; gap: 0.75rem; padding: 1rem; }
.debug-field { display: flex; flex-direction: column; gap: 0.25rem; font-size: 0.875rem; color: var(--muted); }
.debug-field-head { display: flex; align-items: center; justify-content: space-between; }
.debug-inline { display: flex; align-items: center; gap: 0.375rem; }
.debug-range { display: flex; height: 2.5rem; align-items: center; gap: 0.75rem; }
.range { width: 100%; accent-color: var(--ink); }
.range:disabled { opacity: 0.4; }
.debug-b { width: 3rem; text-align: right; color: var(--ink); }
.debug-seed { display: flex; gap: 0.5rem; }
.debug .control { height: 2.5rem; border-radius: 0.5rem; background: var(--surface-2); padding: 0 0.5rem; font-size: 0.9375rem; }
.debug .debug-seed .control { min-width: 0; flex: 1; font-size: 0.875rem; }
.debug-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 0.75rem; }
.kbd-hint { margin-left: 0.25rem; font-size: 0.75rem; opacity: 0.6; }
.tally { font-size: 0.875rem; color: var(--ink-2); }
.tally strong { color: var(--ink); }
.link-reset { text-decoration: underline; color: var(--muted); }
.debug-time { margin-left: auto; font-size: 0.875rem; color: var(--ink-2); }
.debug-result { border-radius: 0.75rem; padding: 0.75rem 1rem; font-size: 0.9375rem; font-weight: 600; }
.debug-result.is-correct { background: color-mix(in oklab, var(--ok-strong) 15%, transparent); color: var(--ok); }
.debug-result.is-wrong { background: color-mix(in oklab, var(--danger) 15%, transparent); color: var(--danger); }
.debug-result-hint { margin-left: 0.5rem; font-size: 0.75rem; font-weight: 400; opacity: 0.7; }
.debug-details { display: grid; gap: 1rem; padding: 1rem; font-size: 0.875rem; }
.debug-details h2 { margin-bottom: 0.5rem; font-weight: 600; color: var(--ink); }
.dl { display: grid; grid-template-columns: auto 1fr; gap: 0.25rem 1rem; }
.dl dt { color: var(--muted); }
.dl dd { color: var(--ink); }
.dl-features { grid-template-columns: 1fr auto; }
.dl-features dt { font-family: var(--font-mono); }
.is-right { text-align: right; }
.debug-seed-cell { display: flex; align-items: center; gap: 0.5rem; }
.debug-seed-cell code { overflow-wrap: anywhere; color: var(--ink); }
.link-small { font-size: 0.75rem; color: var(--link); }
.debug-verifier summary { cursor: pointer; font-weight: 600; color: var(--ink); }
.debug-verifier pre { margin-top: 0.5rem; max-height: 24rem; overflow: auto; border-radius: 0.5rem; background: var(--surface-2); padding: 0.75rem; font-size: 0.75rem; line-height: 1.625; color: var(--ink-2); }

@media (min-width: 640px) {
  .tiles { grid-template-columns: repeat(2, 1fr); }
  .puzzle-card { padding-inline: 1.75rem; }
  .panel { padding-inline: 1.75rem; }
  .welcome-banner { padding-inline: 1.75rem; }
  .stem-example-canvas { width: 12rem; }
  .confirm-bar { bottom: 0; padding-bottom: 1rem; }
  .confirm-tip { display: block; }
  .summary-actions { flex-direction: row; justify-content: center; }
  .debug-controls { grid-template-columns: 1fr 1.4fr 1fr; }
}

@media (min-width: 1024px) {
  .debug-details { grid-template-columns: 1fr 1fr; }
  .debug-verifier { grid-column: 1 / -1; }
}
