/* Components: header + beans, analogy frame, board tiles, pills, solved cards, status.
   Every color and duration comes from tokens.css. Tier colors appear ONLY inside
   .solved-card — the live board must never hint at them. */

/* ---------- Header ---------- */

.header {
  display: flex;
  align-items: baseline;
  gap: 10px;
}

/* Also the way home. It stays visually a wordmark — no pill, no underline — because a
   logo that goes to the title screen is a convention players already know. */
.header .wordmark {
  position: relative;
  font-family: var(--font-display);
  font-size: 28px;
  letter-spacing: 0.02em;
  transition: opacity var(--motion-fast) var(--ease);
}

/* Grows the tap target to 44px WITHOUT changing the box, so the header's baseline
   alignment is exactly what it was when this was a span. */
.header .wordmark::after {
  content: '';
  position: absolute;
  inset: -8px -8px;
}

.header .wordmark:active {
  opacity: 0.6;
}

.header .puzzle-title {
  color: var(--soft-ink);
  font-size: 15px;
  flex: 1;
}

.beans {
  display: flex;
  gap: 6px;
  align-self: center;
}

.bean {
  width: 18px;
  height: 18px;
  transition: fill var(--motion-slow) var(--ease);
}

.bean .bean-body {
  fill: var(--bean-empty);
}

.bean.used .bean-body {
  fill: var(--bean-filled);
}

.bean .bean-crease {
  stroke: var(--cream);
  stroke-width: 1.4;
  fill: none;
}

/* ---------- Status strip ---------- */

.status {
  min-height: 24px;
  text-align: center;
  color: var(--soft-ink);
  font-size: 15px;
  transition: opacity var(--motion-slow) var(--ease);
}

.status.is-empty {
  opacity: 0;
}

.status .status-strong {
  font-weight: 800;
  color: var(--ink);
}

/* ---------- Analogy frame ---------- */

.frame {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  touch-action: none; /* pointer-event drag owns gestures here */
  user-select: none;
  -webkit-user-select: none;
}

.frame .sep {
  font-family: var(--font-display);
  color: var(--faint-ink);
  font-size: 18px;
  flex: none;
}

.frame-slot {
  flex: 1 1 0;
  min-width: 0;
  height: var(--tap-target);
  border-radius: var(--radius-tile);
  background: var(--oat);
  border: 1px solid transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  padding: 0 4px;
  transition:
    background var(--motion-fast) var(--ease),
    box-shadow var(--motion-slow) var(--ease),
    transform var(--motion-fast) var(--ease);
}

.frame-slot.filled {
  background: var(--milk);
  border-color: var(--taupe);
  cursor: pointer;
}

.frame-slot.next {
  box-shadow: 0 0 0 2px var(--honey-glow), inset 0 0 0 1px var(--honey-glow);
}

.frame-slot.dragging {
  opacity: 0.85;
  box-shadow: 0 4px 10px rgba(64, 52, 42, 0.18);
  z-index: 2;
  position: relative;
  transition: none; /* mid-drag offset is transient view state; keep it 1:1 with the finger */
}

.frame-slot.drop-target {
  background: var(--oat);
  border-color: var(--faint-ink);
  border-style: dashed;
}

/* ---------- Board ---------- */

.board {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--gap);
}

.tile {
  position: relative;
  min-height: 56px;
  border-radius: var(--radius-tile);
  background: var(--milk);
  border: 1px solid var(--taupe);
  isolation: isolate;
  font-weight: 700;
  font-size: 14px;
  padding: 4px 2px;
  overflow-wrap: anywhere;
  transition:
    background var(--motion-fast) var(--ease),
    color var(--motion-fast) var(--ease),
    transform var(--motion-fast) var(--ease),
    opacity var(--motion-slow) var(--ease);
}

/* Paper grain lives on tiles and cards, and nowhere else. */
.tile::after,
.solved-card::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background-image: var(--grain);
  opacity: var(--grain-strength);
  pointer-events: none;
  z-index: -1;
}

@media (hover: hover) {
  .tile:hover:not(.selected) {
    background: var(--oat);
  }
}

.tile:active {
  transform: translateY(1px); /* 1px press, per Appendix E */
}

/* A hinted set wears its solved-card colours early — the same three tokens the reveal
   cards use, so the tint IS the reveal colouring (sanctioned tier reveal, 2026-08-11). */
.tile.hinted[data-tier='green']  { --card-main: var(--tier-green-main);  --card-tint: var(--tier-green-tint);  --card-deep: var(--tier-green-deep); }
.tile.hinted[data-tier='yellow'] { --card-main: var(--tier-yellow-main); --card-tint: var(--tier-yellow-tint); --card-deep: var(--tier-yellow-deep); }
.tile.hinted[data-tier='red']    { --card-main: var(--tier-red-main);    --card-tint: var(--tier-red-tint);    --card-deep: var(--tier-red-deep); }
.tile.hinted[data-tier='black']  { --card-main: var(--tier-black-main);  --card-tint: var(--tier-black-tint);  --card-deep: var(--tier-black-deep); }

.tile.hinted {
  background: var(--card-tint);
  border-color: var(--card-main);
  color: var(--card-deep);
}

/* Selection stays the louder voice: ink fill wins over the hint tint. */
.tile.selected {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--milk);
}

/* ---------- Controls ---------- */

.controls {
  display: flex;
  gap: 10px;
  justify-content: center;
  /* Five pills since D-18 (Vocabulary joined). Compress first (the narrow query
     below), and wrap as the last resort rather than ever clipping an edge. */
  flex-wrap: wrap;
}

.pill {
  border-radius: var(--radius-pill);
  padding: 10px 22px;
  min-height: var(--tap-target);
  font-weight: 800;
  font-size: 15px;
  border: 1.5px solid var(--ink);
  color: var(--ink);
  background: transparent;
  transition:
    background var(--motion-fast) var(--ease),
    color var(--motion-fast) var(--ease),
    opacity var(--motion-fast) var(--ease),
    transform var(--motion-fast) var(--ease);
}

.pill:active:not(:disabled) {
  transform: translateY(1px);
}

/* Ink fill is reserved for the one primary action on screen. */
.pill.primary {
  background: var(--ink);
  color: var(--milk);
}

.pill:disabled {
  opacity: 0.35;
  cursor: default;
}

/* Four pills (Hint joined the row, 2026-08-11) need a gentler footprint on phones —
   compress before wrapping, so the row stays one thumb-height tall. */
@media (max-width: 430px) {
  .controls {
    gap: 6px;
  }

  .pill {
    padding: 10px 13px;
    font-size: 14px;
  }
}

/* ---------- Vocabulary line (D-18) ---------- */

/* A footnote to the board, not a card: the revealed definition sits quietly under
   the tiles until its word's set is solved. Oat well, no grain — it is chrome,
   not content. */
.vocab-line {
  font-size: 14px;
  color: var(--ink);
  background: var(--oat);
  border-radius: var(--radius-tile);
  padding: 8px 14px;
  text-align: center;
}

/* ---------- Solved set cards ---------- */

.solved-sets {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.solved-card {
  position: relative;
  isolation: isolate;
  border-radius: var(--radius-card);
  border: 1px solid var(--card-main);
  background: var(--card-tint);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.solved-card[data-tier='green']  { --card-main: var(--tier-green-main);  --card-tint: var(--tier-green-tint);  --card-deep: var(--tier-green-deep); }
.solved-card[data-tier='yellow'] { --card-main: var(--tier-yellow-main); --card-tint: var(--tier-yellow-tint); --card-deep: var(--tier-yellow-deep); }
.solved-card[data-tier='red']    { --card-main: var(--tier-red-main);    --card-tint: var(--tier-red-tint);    --card-deep: var(--tier-red-deep); }
.solved-card[data-tier='black']  { --card-main: var(--tier-black-main);  --card-tint: var(--tier-black-tint);  --card-deep: var(--tier-black-deep); }

.solved-card .tier-badge {
  align-self: flex-start;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--card-deep);
  border: 1px solid var(--card-main);
  border-radius: var(--radius-pill);
  padding: 1px 10px;
}

.solved-card .analogy {
  font-family: var(--font-display);
  font-size: 17px;
  color: var(--card-deep);
}

.solved-card .relationship {
  font-style: italic;
  font-size: 13px;
  color: var(--soft-ink);
}

/* ---------- End screens (win / loss) ---------- */

.end-title {
  font-family: var(--font-display);
  font-size: 30px;
  text-align: center;
  margin-top: 8px;
}

.end-score {
  text-align: center;
  color: var(--soft-ink);
  font-size: 15px;
  margin-top: -6px;
}

.end-sets {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Three pills do not fit across a 375px phone, so they wrap rather than overflow. */
.end-actions {
  margin-top: 4px;
  flex-wrap: wrap;
}

.share-feedback {
  text-align: center;
  min-height: 20px;
  font-size: 14px;
  color: var(--soft-ink);
}

.badge-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Not a scold — the same calm voice as the tier badge, just outlined in soft ink. */
.revealed-badge {
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--soft-ink);
  border: 1px dashed var(--faint-ink);
  border-radius: var(--radius-pill);
  padding: 1px 10px;
}

.solved-card .explanation {
  font-size: 13.5px;
  color: var(--ink);
  opacity: 0.82;
  margin-top: 2px;
}

/* A quiet way out that doesn't compete with Share and Play again for the eye. */
.text-action {
  align-self: center;
  font-size: 14px;
  font-weight: 700;
  color: var(--soft-ink);
  text-decoration: underline;
  text-underline-offset: 3px;
  min-height: var(--tap-target);
  padding: 0 12px;
}

/* ---------- Title screen ---------- */

.title-block {
  margin: auto;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.title-wordmark {
  font-family: var(--font-display);
  font-size: 54px;
  letter-spacing: 0.03em;
}

.title-tagline {
  color: var(--soft-ink);
  font-size: 15px;
  margin-bottom: 14px;
}

/* ---------- First-run coach card ---------- */

.coach {
  display: flex;
  flex-direction: column;
  gap: 10px;
  border-radius: var(--radius-card);
  border: 1px solid var(--taupe);
  background: var(--milk);
  padding: 12px 14px;
}

/* `display: flex` above outranks the UA stylesheet's [hidden] { display: none } — the
   same trap that left every screen stacked in Phase 2. Say it explicitly. */
.coach[hidden] {
  display: none;
}

.coach-body {
  font-size: 14.5px;
  line-height: 1.45;
  color: var(--ink);
}

/* The "nothing lost" aside — said once, and quieter than the diagnosis above it. */
.coach-note {
  font-size: 13px;
  font-style: italic;
  color: var(--soft-ink);
  margin-top: -4px;
}

.coach-actions {
  display: flex;
  justify-content: flex-end;
}

/* Smaller than a board control: the coach guides, it doesn't compete with Confirm.
   Skip is a text action, not a pill — leaving the tutorial shouldn't look like the
   recommended move on the very first screen a new player sees. */
.coach-action.pill {
  padding: 6px 18px;
  min-height: 36px;
  font-size: 14px;
}

.coach-action[hidden] {
  display: none;
}

/* ---------- Puzzle select (GDD Screen 6) ---------- */

.select-head {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 6px 2px 0;
}

/* Also the way home, exactly as the play screen's wordmark is. Still visually a wordmark —
   no pill, no underline — because a logo that goes to the title screen is a convention
   players already know. */
.select-head .wordmark {
  position: relative;
  display: block;
  font-family: var(--font-display);
  font-size: 32px;
  letter-spacing: 0.03em;
  text-align: left;
  transition: opacity var(--motion-fast) var(--ease);
}

/* 44px tap target without changing the box, so the heading's spacing is what it was when
   this was a plain h1. Same trick as .header .wordmark. */
.select-head .wordmark::after {
  content: '';
  position: absolute;
  inset: -8px -10px;
}

.select-head .wordmark:active {
  opacity: 0.6;
}

.select-count {
  color: var(--soft-ink);
  font-size: 14px;
}

.puzzle-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* Wells on the page, cards under the finger. Each row is a real <button>, so keyboard
   focus, Enter and the 44px tap target all come from the platform. */
.puzzle-row {
  position: relative;
  isolation: isolate;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 62px;
  padding: 12px 14px;
  text-align: left;
  border: 1px solid var(--taupe);
  border-radius: var(--radius-card);
  background: var(--milk);
  transition: transform var(--motion-fast) var(--ease);
}

/* A finished board sits a shade back — read, not pending. */
.puzzle-row[data-played] {
  background: var(--oat);
  border-color: var(--taupe);
}

.puzzle-row::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  border-radius: inherit;
  background-image: var(--grain);
  opacity: var(--grain-strength);
  pointer-events: none;
}

.puzzle-row:active {
  transform: translateY(1px);
}

.puzzle-row-title {
  font-family: var(--font-display);
  font-size: 18px;
  line-height: 1.2;
}

.puzzle-row-status {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.puzzle-row-status.is-unplayed {
  color: var(--faint-ink);
  font-size: 20px;
  padding-right: 4px;
}

/* How the board went, as a coffee cup — steaming on a solve, spilled on a loss. Coffee is
   already the game's vocabulary for this: mistakes are beans, a loss is "Out of beans". */
.result-cup-slot {
  display: flex;
  align-items: center;
}

.result-cup {
  width: 24px;
  height: 24px;
  flex-shrink: 0;
}

/* The pose says how the board ENDED; the colour says how it was PLAYED (D-16 addendum).
   White is the everyday cup — a clean, unhinted board — and needs the hairline outline
   because it sits on the milk-coloured row. Brown, the old default, now marks a board
   where the player took the hint: they needed a coffee. */
.cup-rim,
.cup-body {
  fill: var(--cup-clean);
  stroke: var(--faint-ink);
  stroke-width: 0.9;
}

.is-hinted .cup-rim,
.is-hinted .cup-body {
  fill: var(--bean-filled);
  stroke: none;
}

.cup-steam {
  fill: none;
  stroke: var(--faint-ink);
  stroke-width: 1.5;
  stroke-linecap: round;
}

/* Two puddles, two problems. The white puddle keeps near-full opacity plus the outline —
   dropped to half it vanishes into the row. The brown puddle keeps the original halved
   opacity so it reads as spread liquid rather than a second solid object; a puddle
   LIGHTER than a brown cup read as a shadow, which is why it is not simply taupe. Never
   red: the game does not scold you for losing, it just shows you the answers. */
.cup-spill {
  fill: var(--cup-clean);
  stroke: var(--faint-ink);
  stroke-width: 0.7;
  opacity: 0.9;
}

.is-hinted .cup-spill {
  fill: var(--bean-filled);
  stroke: none;
  opacity: 0.5;
}

/* One dot per set, in tier order — lit for a set the player solved, hollow for one that
   got away. These are TIER colours (the same four the solved cards use), not mistake
   pips: beans are the mistake vocabulary and beans are never red. */
.tier-dots {
  display: flex;
  gap: 4px;
}

.tier-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  border: 1px solid var(--taupe);
  background: transparent;
}

.tier-dot[data-solved][data-tier='green']  { background: var(--tier-green-main);  border-color: var(--tier-green-main); }
.tier-dot[data-solved][data-tier='yellow'] { background: var(--tier-yellow-main); border-color: var(--tier-yellow-main); }
.tier-dot[data-solved][data-tier='red']    { background: var(--tier-red-main);    border-color: var(--tier-red-main); }
.tier-dot[data-solved][data-tier='black']  { background: var(--tier-black-main);  border-color: var(--tier-black-main); }

/* Room to breathe below the last row before the Back action. */
.puzzle-list + .text-action {
  margin-top: 2px;
  margin-bottom: 8px;
}
