/* EX-19 Form, a DAT-style format (docs/dev/EXERCISE-GUIDE.md): every rule under .ex-form; tokens from css/base.css with
   fallbacks; shared pieces (.ex-stage, .ex-label, .ex-caption, .ex-verdict, .ex-tag, .ex-opt, .ex-focus,
   .px-fig-*) come from css/ex.css and css/base.css. Pattern and solids are SVG in units at one scale.
   A mark is a darker tone plus a hatch (a pattern of lines), never colour alone; fold lines are
   dashed, cut edges solid. */
.ex-form .fm-stem { width: 100%; }
.ex-form .fm-stage { width: 100%; height: clamp(11rem, min(40vh, 66vw), 20rem); }
.ex-form .fm-svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }

.ex-form .fm-face { fill: var(--stim-face, #ECEEF0); }
/* The mark's own tone, darker than every face tone (also the far-lit one), in both themes. */
.ex-form .fm-hatch-bg { fill: #6A7075; fill: color-mix(in srgb, var(--stim-face-3, #A4ABB2) 55%, var(--stim-edge, #22262A)); }
.ex-form .fm-hatch-line { stroke: var(--stim-edge, #22262A); stroke-opacity: 0.55; }
.ex-form .fm-cut { fill: none; stroke: var(--ink, #1A1D21); stroke-width: 2px; stroke-linejoin: round; stroke-linecap: round; vector-effect: non-scaling-stroke; }
.ex-form .fm-fold { fill: none; stroke: var(--ink-2, #454B52); stroke-width: 1.5px; stroke-dasharray: 5 4; vector-effect: non-scaling-stroke; }
.ex-form .fm-edge { fill: none; stroke: var(--stim-edge, #22262A); stroke-width: 1.6px; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
.ex-form .fm-netface.is-pointed .fm-face,
.ex-form .fm-solid .is-pointed .px-fig-face { stroke: var(--stim-target, #0B6A86); stroke-width: 3px; vector-effect: non-scaling-stroke; }

/* Show me: an edge that differs (thick dots in the "wrong" colour: a shape as well as a colour). */
.ex-form .fm-edge-hl {
  fill: none; stroke: var(--wrong, #B33A2F); stroke-width: 6px; stroke-dasharray: 1 7; stroke-linecap: round;
  vector-effect: non-scaling-stroke;
}
/* Show me: letters on faces (a ring and a letter; ✗ in the "wrong" colour and a dashed ring). */
.ex-form .fm-tag circle { fill: var(--surface, #FFFFFF); stroke: var(--stim-target, #0B6A86); stroke-width: 2px; vector-effect: non-scaling-stroke; }
.ex-form .fm-tag text {
  font-family: var(--font-mono, ui-monospace, Menlo, Consolas, monospace); font-weight: 700; fill: var(--ink, #1A1D21);
  text-anchor: middle; dominant-baseline: central;
}
.ex-form .fm-tag--bad circle { stroke: var(--wrong, #B33A2F); stroke-dasharray: 3 2; }
.ex-form .fm-tag--bad text { fill: var(--wrong, #B33A2F); }

.ex-form .fm-under {
  display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: var(--s2, 0.5rem) var(--s4, 1rem);
}
.ex-form .fm-under .ex-caption { flex: 1 1 14rem; min-width: 0; }
.ex-form .fm-verdict { margin-top: var(--s2, 0.5rem); margin-left: auto; }
.ex-form .fm-verdict[data-kind="key"],
.ex-form .ex-tag[data-kind="key"] { color: var(--right, #2A7239); border-color: var(--right, #2A7239); }
.ex-form .ex-tag[data-kind="foil"] { color: var(--ink-2, #454B52); border-style: dashed; }

/* Options: four in a row on wide screens, 2 × 2 on narrow ones; each solid at the pattern's scale
   (max-width set by the view). */
.ex-form .px-choice { padding: var(--s2, 0.5rem); }
.ex-form .fm-opt-cell { flex-direction: column; gap: var(--s1, 0.25rem); }
.ex-form .fm-opt-svg { display: block; width: 100%; height: auto; aspect-ratio: 1 / 1; max-height: 10rem; margin: 0 auto; overflow: visible; }

@media (max-width: 40rem) {
  .ex-form .px-choices[style*="--px-cols:4"] { --px-cols: 2 !important; }
  .ex-form .fm-stage { height: clamp(10rem, min(34vh, 62vw), 15rem); }
  .ex-form .fm-opt-svg { max-height: 6.5rem; }
  .ex-form .px-choice { padding: var(--s1, 0.25rem); }
}

/* Phones in the player (B2's contract; css/play.css sets --pl-avail, --pl-w, --pl-col): the pattern
   keeps at least 10rem, the 2 × 2 solids take the rest; sideways, pattern left, solids right. */
@media (max-width: 719px), (max-height: 500px) {
  .pl-trial.ex-form { --fm-cell: min(calc((var(--pl-w) - var(--s2)) / 2), calc((var(--pl-avail) - 10rem - 2.5rem - 2 * var(--s2)) / 2)); }
  .pl-trial.ex-form .px-choices { --px-cols: 2 !important; }
  .pl-trial.ex-form .fm-stage { height: min(16rem, calc(var(--pl-w) * 0.8), calc(var(--pl-avail) - 2 * var(--fm-cell) - 2.5rem - 2 * var(--s2))); }
  .pl-trial.ex-form .px-choice { height: var(--fm-cell); padding: var(--s1); }
  .pl-trial.ex-form .px-choice .ex-opt { position: relative; }
  .pl-trial.ex-form .fm-opt-svg { width: calc(var(--fm-cell) - 1.25rem); max-height: calc(var(--fm-cell) - 1.5rem); max-width: 100%; }
  .pl-trial.ex-form .px-choice .ex-tag { position: absolute; bottom: 0; left: 50%; transform: translateX(-50%); white-space: nowrap; }
}
@media (max-height: 500px) and (min-aspect-ratio: 1/1) {
  .pl-trial.ex-form { --fm-cell: min(calc((var(--pl-col) - var(--s2)) / 2), calc((var(--pl-avail) - var(--s2)) / 2)); }
  .pl-trial.ex-form .fm-stage { height: calc(var(--pl-avail) - 2.5rem); }
}

/* The key digit (1–5) stays above the drawing in its cell. */
.ex-form .px-choice-key { z-index: 1; }
