/* Block Adder. Existing tokens and values only; listed for design review in docs/follow-ups.md.
   The board follows Double Drop's: dark grey in both themes, one lighter cell under each block
   face, the current block in a chute above the board, blocks placed with the translate property
   from --c and --r (row 7 is the chute) so they scale around their own center. Every number block
   is the saffron light tone with deep digits (spec D7: one color family; the digit carries the
   value). Dots draw the value as a five- or ten-frame under the digit. Question blocks (Sums) are
   neutral: the board's light ink on white-grey, no dots. The hint outlines one column. The adder
   above the board is jade; its body is a row of blocks, one per bond. */

.k-adder { padding-block: var(--s3) var(--s7); }
.k-adder__intro { margin-bottom: var(--s3); }
.k-adder__intro h1 { font-size: 24px; }
.k-adder__intro p { margin-top: var(--s1); max-width: 60ch; }
.k-adder__note { margin-bottom: var(--s3); }

/* ---------- the games: one page each (Phase 3), the current one filled ---------- */
.k-adder__nav { max-width: 460px; margin-top: var(--s4); } /* under the game: the board comes first at 360 px */
.k-adder__nav ul { display: flex; flex-wrap: wrap; gap: var(--s2); padding: 0; margin: 0; list-style: none; }
.k-adder__nav a {
  display: inline-flex; align-items: center; min-height: 44px; padding: 0 var(--s4); border-radius: var(--r-pill);
  border: 1px solid var(--line-strong); color: var(--ink); font-weight: 600; text-decoration: none;
}
.k-adder__nav a:hover { background: var(--surface-2); }
.k-adder__nav a[aria-current="page"] { background: var(--ink); border-color: var(--ink); color: var(--on-ink); }

/* ---------- game card ---------- */
.k-adder__game { max-width: 460px; display: grid; gap: var(--s3); padding: var(--s3); }
@media (min-width: 400px) { .k-adder__game { padding: var(--s4); } }
.k-adder__game:focus { outline: none; }
.k-adder__bar { display: flex; flex-wrap: wrap; align-items: end; gap: var(--s2) var(--s4); }
.k-adder__bar .stat { min-width: 48px; }
.k-adder__bar-actions { margin-left: auto; display: flex; gap: var(--s2); }
.k-adder__bar-actions .btn { touch-action: manipulation; }

/* ---------- the mode's rule and the adder ---------- */
.k-adder__mode { font-size: 15px; line-height: 1.35; }
.k-adder__mode strong { font-weight: 800; margin-right: var(--s1); }
.k-adder__adder { display: flex; align-items: center; height: 46px; min-width: 0; }
.k-adder__tail { flex: none; width: 18px; height: 24px; }
.k-adder__tail-curl, .k-adder__adder.is-curled .k-adder__tail-flat { display: none; }
.k-adder__adder.is-curled .k-adder__tail-curl { display: inline; }
.k-adder__body { display: flex; align-items: center; gap: 2px; min-width: 0; margin-right: -4px; }
.k-adder__seg { flex: none; width: 22px; height: 22px; border-radius: 6px; background: var(--light); }
.k-adder__seg:nth-child(even) { background: var(--field); }
/* full: the body curls into a wave */
.k-adder__adder.is-curled .k-adder__seg:nth-child(4n + 1) { translate: 0 -5px; }
.k-adder__adder.is-curled .k-adder__seg:nth-child(4n + 3) { translate: 0 5px; }
.k-adder__head { flex: none; width: 58px; height: 40px; overflow: visible; }
.k-adder__brows, .k-adder__worry, .k-adder__open, .k-adder__sweat { display: none; }
.is-worried .k-adder__brows, .is-worried .k-adder__worry, .is-worried .k-adder__sweat { display: inline; }
.is-worried .k-adder__smile { display: none; }
.k-adder__head.is-eating .k-adder__open { display: inline; }
.k-adder__head.is-eating .k-adder__smile, .k-adder__head.is-eating .k-adder__worry { display: none; }
/* a bond's token, flying from the board into the mouth (position: fixed, from viewport rects) */
.k-adder__token {
  position: fixed; z-index: 50; pointer-events: none; display: grid; place-items: center; border-radius: 6px;
  background: #FFE7A8; color: #402A00; font-weight: 800; font-size: 13px; font-variant-numeric: tabular-nums;
}

/* ---------- board ---------- */
.k-adder__stage { position: relative; }
.k-adder__board {
  --gap: clamp(4px, 1.6cqi, 8px);
  --board: #0E1014; /* dark theme --wall */
  --cell: #20242B; /* dark theme --surface-2 */
  --board-ink: #F2F3F5; /* dark theme --ink */
  container-type: inline-size; position: relative; width: 100%; aspect-ratio: 5 / 8;
  user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
}
.k-adder__cells {
  position: absolute; inset: 12.5% 0 0; border-radius: 12px; background: var(--board);
  display: grid; grid-template-columns: repeat(5, 1fr); grid-template-rows: repeat(7, 1fr);
}
.k-adder__cells span { margin: var(--gap); border-radius: 8px; background: var(--cell); }
.k-adder__blocks, .k-adder__floats { position: absolute; inset: 0; pointer-events: none; }
.k-adder__floats { z-index: 2; }

.k-adder__block {
  position: absolute; left: 0; top: 0; width: 20%; height: 12.5%; padding: var(--gap); z-index: 1;
  translate: calc(var(--c) * 100%) calc((7 - var(--r)) * 100%);
}
.k-adder__face {
  display: grid; place-items: center; width: 100%; height: 100%; border-radius: 8px;
  background: var(--light); color: var(--deep);
  font-weight: 800; font-stretch: 100%; line-height: 1; font-variant-numeric: tabular-nums;
}
.k-adder__num { font-size: calc(20cqi * 0.46); }
/* D7: a question is neutral, never the number blocks' color */
.k-adder__block.is-question .k-adder__face { background: var(--board-ink); color: var(--board); }
.k-adder__block.is-question .k-adder__num { font-size: calc(20cqi * 0.25); font-stretch: 75%; white-space: nowrap; letter-spacing: -0.02em; }
.k-adder__current[hidden] { display: none; }

/* D7: a ten-frame, two rows of five; filled dots are the value, empty ones what's left to 10 */
.k-adder__dots { display: none; grid-template-columns: repeat(5, auto); gap: calc(20cqi * 0.03); }
.k-adder__dots i { width: calc(20cqi * 0.085); aspect-ratio: 1; border-radius: 50%; box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--deep) 45%, transparent); }
.k-adder__dots i.is-on { background: var(--deep); box-shadow: none; }
.has-dots .k-adder__face { grid-template-rows: 1fr auto; padding-bottom: calc(20cqi * 0.08); }
.has-dots .k-adder__num { font-size: calc(20cqi * 0.34); align-self: end; }
.has-dots .k-adder__dots:not([hidden]) { display: grid; }
.is-frame-5 .k-adder__dots i:nth-child(n + 6) { display: none; }
.is-frame-5 .k-adder__dots i { width: calc(20cqi * 0.11); }

.k-adder__float {
  position: absolute; left: 0; top: 0; width: 20%; height: 12.5%;
  translate: calc(var(--c) * 100%) calc((7 - var(--r)) * 100%);
  display: grid; place-items: center; opacity: 0; white-space: nowrap;
  font-weight: 800; font-size: calc(20cqi * 0.3); color: var(--board-ink);
}

/* D10: the hinted column, outlined over the board in the saffron field tone */
.k-adder__hint {
  position: absolute; z-index: 2; top: 12.5%; bottom: 0; left: 0; width: 20%; pointer-events: none;
  translate: calc(var(--c) * 100%) 0; border-radius: 10px; box-shadow: inset 0 0 0 3px var(--field);
}
.k-adder__hint[hidden] { display: none; }
@media (prefers-reduced-motion: no-preference) {
  .k-adder__hint { animation: k-adder-pulse 1.2s ease-in-out infinite alternate; }
}
@keyframes k-adder-pulse { from { opacity: 1; } to { opacity: 0.45; } }

/* Column buttons over the whole height: tap to drop. Keyboard focus rings the current block. */
.k-adder__cols { position: absolute; inset: 0; z-index: 3; display: grid; grid-template-columns: repeat(5, 1fr); }
.k-adder__col {
  appearance: none; border: 0; margin: 0; padding: 0; background: transparent; border-radius: 10px;
  cursor: pointer; touch-action: manipulation; -webkit-tap-highlight-color: transparent;
}
.k-adder__col:focus, .k-adder__col:focus-visible { outline: none; box-shadow: none; }
.k-adder__board:has(.k-adder__col:focus-visible) .k-adder__current .k-adder__face { outline: 3px solid var(--ink); outline-offset: 3px; }

/* ---------- the gentle end (D9), over the board ---------- */
.k-adder__over { inset: 0; align-content: center; justify-items: stretch; text-align: center; padding: var(--s5); }
.k-adder__over[hidden] { display: none; }
.k-adder__over .figs { grid-template-columns: repeat(2, minmax(0, 1fr)); margin-top: var(--s3); }
.k-adder__over .fig dd { font-size: 28px; }
.k-adder__over h2:focus { outline: none; }
.k-adder__over p { font-size: 18px; font-weight: 600; font-stretch: 100%; margin-top: var(--s3); }
.k-adder__over .dlg__actions { justify-content: center; }
.k-adder__again { min-height: 56px; padding-inline: var(--s6); font-size: 18px; }

/* ---------- below the board: hint text, level, dots ---------- */
.k-adder__tip { min-height: 1.4em; text-align: center; font-size: 16px; font-weight: 600; }
.k-adder__controls { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: var(--s2) var(--s4); }
.k-adder__controls form { margin: 0; }
.k-adder__check { display: inline-flex; align-items: center; gap: var(--s2); min-height: 44px; font-weight: 600; cursor: pointer; }
.k-adder__check input { width: 20px; height: 20px; margin: 0; accent-color: var(--ink); }
.k-adder__check[hidden] { display: none; }

/* ---------- statistics dialog ---------- */
.k-adder__stats { width: 100%; border-collapse: collapse; font-size: 15px; font-variant-numeric: tabular-nums; }
.k-adder__stats th, .k-adder__stats td { padding: 8px 4px; border-bottom: 1px solid var(--line); text-align: right; }
.k-adder__stats th:first-child { text-align: left; white-space: nowrap; }
.k-adder__stats thead th { font-size: 12px; font-weight: 600; color: var(--ink-2); }
.k-adder__reset { margin-top: var(--s5); }
.k-adder__reset p { font-weight: 600; }

/* ---------- text below the game ---------- */
.k-adder__about { max-width: 62ch; margin-top: var(--s6); }
.k-adder__about h2 { margin: var(--s6) 0 var(--s3); }
.k-adder__about h2:first-child { margin-top: 0; }
.k-adder__about ol { padding-left: 1.25em; margin: var(--s3) 0; }
.k-adder__about li + li { margin-top: 6px; }
.k-adder__about h3 { margin: var(--s4) 0 var(--s1); }
.k-adder__games { padding-left: 1.25em; margin: var(--s3) 0; }
.k-adder__keys { border-collapse: collapse; font-size: 15px; }
.k-adder__keys th, .k-adder__keys td { text-align: left; padding: 6px var(--s4) 6px 0; border-bottom: 1px solid var(--line); vertical-align: top; }
.k-adder__keys th { font-weight: 600; white-space: nowrap; }
