/* EX-16 Angles (docs/dev/EXERCISE-GUIDE.md): every rule under .ex-angles; tokens from css/base.css
   with fallbacks; shared pieces (.ex-stage, .ex-label, .ex-caption, .ex-verdict, .ex-tag, .ex-answer,
   .ex-focus) come from css/ex.css. Cells are 1 × 1 user units; strokes keep their CSS width at any
   size (vector-effect: non-scaling-stroke). */
.ex-angles {
  --ang-ink: var(--ink, #1A1D21);
  --ang-mark: var(--signal, #0B6A86);
  --ang-wedge: rgba(11, 106, 134, 0.16);
  --ang-cell: var(--surface, #FFFFFF);
}
.ex-angles .ex-angles-stem { width: 100%; }
.ex-angles .ex-angles-stage { padding: var(--s2, 0.5rem); }
.ex-angles .ex-angles-cells {
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--s2, 0.5rem);
  max-width: 64rem; margin: 0 auto;
}
.ex-angles .ex-angles-cells[hidden], .ex-angles .ex-angles-big[hidden] { display: none; }
.ex-angles .ex-angles-cell {
  position: relative; min-width: 0; border: 1px solid var(--rule, #D5D9D6); border-radius: var(--r-plate, 2px);
  background: var(--ang-cell);
}
.ex-angles .ex-angles-cell.is-pointed { outline: 2px solid var(--ang-mark); outline-offset: 2px; }
/* The number sits in a corner the arms keep clear of (view.js labelCorners: top left when free). */
.ex-angles .ex-angles-n { position: absolute; top: 0.25rem; left: 0.25rem; z-index: 1; font-size: var(--fs-md, 1rem); font-weight: 600; }
.ex-angles .ex-angles-n[data-corner="tr"] { left: auto; right: 0.25rem; }
.ex-angles .ex-angles-n[data-corner="bl"] { top: auto; bottom: 0.25rem; }
.ex-angles .ex-angles-n[data-corner="br"] { top: auto; left: auto; right: 0.25rem; bottom: 0.25rem; }
.ex-angles .ex-angles-size {
  position: absolute; right: 0.3rem; bottom: 0.2rem; font-family: var(--font-mono, monospace); font-variant-numeric: tabular-nums;
  font-size: var(--fs-sm, 0.875rem); color: var(--ang-mark); background: var(--ang-cell); padding: 0 0.15rem;
}
.ex-angles .ex-angles-size[data-corner="bl"] { right: auto; left: 0.3rem; }
.ex-angles .ex-angles-size[data-corner="tr"] { bottom: auto; top: 0.2rem; }
.ex-angles .ex-angles-size[data-corner="tl"] { bottom: auto; right: auto; top: 0.2rem; left: 0.3rem; }
.ex-angles .ex-angles-size[hidden] { display: none; }
.ex-angles .ex-angles-svg { display: block; width: 100%; height: auto; aspect-ratio: 1 / 1; }
.ex-angles .ex-angles-arms {
  fill: none; stroke: var(--ang-ink); stroke-width: 2px; vector-effect: non-scaling-stroke;
  stroke-linecap: round; stroke-linejoin: round; shape-rendering: geometricPrecision;
}
.ex-angles .ex-angles-arms--large { stroke: var(--ang-mark); stroke-dasharray: 7 4; }
.ex-angles .ex-angles-wedge { fill: var(--ang-wedge); }
.ex-angles .ex-angles-arc { fill: none; stroke: var(--ang-mark); stroke-width: 1.5px; vector-effect: non-scaling-stroke; }
.ex-angles .ex-angles-num { font-size: 0.13px; font-weight: 600; fill: var(--ang-ink); text-anchor: middle; }
.ex-angles .ex-angles-num--large { fill: var(--ang-mark); }
.ex-angles .ex-angles-big { display: flex; justify-content: center; }
.ex-angles .ex-angles-big .ex-angles-svg { width: auto; max-width: 100%; height: min(18rem, 40vh); }
.ex-angles .ex-angles-under { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: var(--s2, 0.5rem) var(--s4, 1rem); }
.ex-angles .ex-angles-under .ex-caption { flex: 1 1 16rem; }
.ex-angles .ex-angles-verdict { margin-top: var(--s2, 0.5rem); margin-left: auto; }
.ex-angles .ex-verdict[data-kind="key"], .ex-angles .ex-tag[data-kind="key"] { color: var(--right, #2A7239); border-color: var(--right, #2A7239); }
.ex-angles .ex-tag[data-kind="foil"] { color: var(--ink, #1A1D21); border-style: dashed; }
/* Options: a list of four numbers, read left to right. Each dash is bound to the number before it
   (view.js), so at large text sizes a list breaks after a dash ("3 – 1 –" over "4 – 2") instead of
   overflowing the button. */
.ex-angles .ex-angles-opt { flex-direction: column; gap: 0.15rem; min-width: 0; max-width: 100%; }
.ex-angles .ex-angles-opt .ex-answer-text {
  font-family: var(--font-mono, monospace); font-variant-numeric: tabular-nums; letter-spacing: 0.02em;
  max-width: 100%; text-align: center; white-space: normal; overflow-wrap: anywhere; text-wrap: balance;
}

/* Phones: the cells in two rows of two, as large as the width allows. */
@media (max-width: 719px) {
  .ex-angles .ex-angles-stage { padding: var(--s1, 0.25rem); }
  .ex-angles .ex-angles-cells { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s1, 0.25rem); max-width: min(100%, 62vh); }
}
/* Phones held sideways: the cells in a row of four next to the answers. */
@media (max-height: 500px) and (min-aspect-ratio: 1/1) {
  .ex-angles .ex-angles-cells { grid-template-columns: repeat(2, minmax(0, 1fr)); max-width: min(100%, 80vh); }
}

/* In the player on phones (css/play.css sets --pl-avail, the height left for the item, --pl-w its
   width and, held sideways, --pl-col one of its two columns): the 2 × 2 cells (--ang-size each; the
   cells' colour is --ang-cell) take what the two rows of answers leave, so the item never scrolls. */
@media (max-width: 719px), (max-height: 500px) {
  .pl-trial.ex-angles {
    --ang-size: min(calc((var(--pl-w) - 3 * var(--s1, 0.25rem) - 2px) / 2), calc((var(--pl-avail) - 2 * 3.5rem - 3 * var(--s2, 0.5rem) - 3 * var(--s1, 0.25rem) - 4px) / 2));
  }
  .pl-trial.ex-angles .ex-angles-cells { grid-template-columns: repeat(2, var(--ang-size)); justify-content: center; max-width: none; }
  /* Narrow answer buttons: a smaller size (as Rotate's answers on phones) and tighter spaces, so a
     list stays on one line at the usual text size, takes two lines (not three) at 150 % text, and
     keeps clear of the answer's number in the corner. */
  .pl-trial.ex-angles .ex-angles-opt .ex-answer-text { margin-top: 0.25rem; font-size: var(--fs-md, 1rem); letter-spacing: 0; word-spacing: -0.12em; }
}
@media (max-height: 500px) and (min-aspect-ratio: 1/1) {
  .pl-trial.ex-angles { --ang-size: min(calc((var(--pl-col) - 3 * var(--s1, 0.25rem) - 2px) / 2), calc((var(--pl-avail) - 3 * var(--s1, 0.25rem) - 1rem) / 2)); }
}
