/* EX-14 Openings, a DAT-style format (docs/dev/EXERCISE-GUIDE.md): every rule under .ex-openings; tokens from css/base.css
   with fallbacks; shared pieces (.ex-stage, .ex-label, .ex-caption, .ex-verdict, .ex-tag, .ex-opt,
   .ex-focus) come from css/ex.css. The stage holds the stage3d canvas (.op-3d) and the show-me
   tracing layer (.op-ink). Openings: a pale plate with the outline cut out, dark inside with a
   2 px rim, so the shape reads by contrast and by its edge, not by colour. */
.ex-openings .op-stem { width: 100%; }
.ex-openings .op-stage { width: 100%; }
.ex-openings .op-3d { position: absolute; inset: 0; z-index: 0; }
.ex-openings .op-ink { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 2; pointer-events: none; overflow: visible; }
.ex-openings .op-trace {
  fill: var(--stim-target, #0B6A86); fill-opacity: 0.16; stroke: var(--stim-target, #0B6A86); stroke-width: 3px;
  stroke-linejoin: round;
}

.ex-openings .op-plate { fill: var(--stim-face, #ECEEF0); stroke: var(--stim-face-3, #A4ABB2); stroke-width: 1px; vector-effect: non-scaling-stroke; }
.ex-openings .op-hole {
  fill: var(--stim-edge, #22262A); stroke: var(--ink, #1A1D21); stroke-width: 2px; stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
}
.ex-openings .op-ghost {
  fill: none; stroke: var(--stim-target, #0B6A86); stroke-width: 3px; stroke-dasharray: 7 4; stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
}
.ex-openings .op-true {
  fill: none; stroke: var(--wrong, #B33A2F); stroke-width: 3px; stroke-dasharray: 2 5; stroke-linecap: round; stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
}

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

/* One scale for the solid and the openings (view.js fitScale): --op-s is an opening's drawn size,
   a plate of at most 8.6 steps across. The solid's frame is at most 12.6 steps tall (the largest box,
   any pose, with its margin), so a stage of 1.465 × --op-s plus room for its label holds the solid at
   the openings' scale and the solid fills it. The key digit sits in a strip beside each drawing
   (left; on top when held sideways), never on a shape. */
.ex-openings { --op-s: 10rem; }
.ex-openings .op-stage { height: calc(var(--op-s) * 1.465 + 1.5rem); }
.ex-openings .px-choice { padding: 2px 2px 2px 1.25rem; }
.ex-openings .op-opt-cell { flex-direction: column; gap: var(--s1, 0.25rem); }
.ex-openings .op-opt-svg { display: block; width: var(--op-s); height: var(--op-s); max-width: 100%; margin: 0 auto; overflow: visible; }
.ex-openings .px-choice-key { z-index: 1; }

@media (max-width: 1000px) { .ex-openings { --op-s: 8rem; } }
/* Narrow pages outside the player (the dev harness): two columns, sized like the player's below
   with the viewport's height in place of --pl-avail. */
@media (max-width: 40rem) {
  .ex-openings .px-choices[style*="--px-cols:5"] { --px-cols: 2 !important; }
  .ex-openings { --op-s: min(9.5rem, calc((100vw - 2.5rem) / 2 - 1.25rem - 10px), calc((100vh - 11.5rem) / 4.47)); }
}

/* Phones in the player (B2's contract; css/play.css sets --pl-avail, --pl-w, --pl-col): two columns
   (2 + 2 + 1) under the solid, the drawings as large as the width and the height allow: the stage
   (1.465 s + 1.5rem), three rows of s + 6 px and the gaps fit --pl-avail, with room left for the
   "Your turn" strip that follows the Watch (fit.py, 360×640). Sideways: the solid left,
   the openings right in three columns, the digit on top. */
@media (max-width: 719px), (max-height: 500px) {
  .pl-trial.ex-openings { --op-s: min(calc((var(--pl-w) - var(--s2)) / 2 - 1.25rem - 6px), calc((var(--pl-avail) - 6.5rem) / 4.47)); }
  .pl-trial.ex-openings .px-choices { --px-cols: 2 !important; }
  .pl-trial.ex-openings .px-choice { height: calc(var(--op-s) + 6px); min-height: 0; }
  .pl-trial.ex-openings .px-choice .ex-opt { position: relative; }
  .pl-trial.ex-openings .px-choice .ex-tag { position: absolute; bottom: 0; left: 50%; transform: translateX(-50%); white-space: nowrap; font-size: 0.75rem; }
}
@media (max-height: 500px) and (min-aspect-ratio: 1/1) {
  .pl-trial.ex-openings { --op-s: min(calc((var(--pl-col) - 2 * var(--s2)) / 3 - 6px), calc((var(--pl-avail) - var(--s2)) / 2 - 1.25rem - 6px)); }
  .pl-trial.ex-openings .px-choices { --px-cols: 3 !important; }
  .pl-trial.ex-openings .op-stage { height: min(calc(var(--pl-avail) - 2.5rem), calc(var(--op-s) * 1.465 + 1.5rem)); }
  .pl-trial.ex-openings .px-choice { height: calc(var(--op-s) + 1.25rem + 6px); padding: 1.25rem 2px 2px 2px; }
}
