/* The Duality Square: tool-specific styles (shared look is in ../shared/style.css). */
/* Two columns: the controls, then the figure with the square and, under it, the table of all arrows. */
.layout { grid-template-columns: 300px minmax(0, 1fr); grid-template-rows: auto 1fr; grid-template-areas: "controls main" "controls arrows"; }
.layout > .arrows-panel { grid-area: arrows; }
/* six buttons on a grid; the 1px gaps show the ink colour as separators */
.seg-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1px; background: var(--ink); }
.seg-3 button { padding: 8px 2px; background: var(--panel); font-weight: 400; font-size: 13px; white-space: nowrap; overflow: hidden; }
.seg-3 button + button { border-left: 0; }

.trip button { font-size: 13px; }
.trip-status { min-height: 1.5em; margin: 0 0 4px; font-size: 14px; }

/* the figure on the left, the square on the right, as on the lecture's slides */
.duo { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 18px; align-items: start; }
.fig { margin: 0; min-width: 0; }
.plot-fig { aspect-ratio: 1 / 1; height: auto; max-height: 520px; }
.sq-wrap { min-width: 0; }
#square { display: block; width: 100%; height: auto; max-height: 420px; }
#square .node { font: 700 30px var(--font); }
#square .node-D, #square .node-V { fill: var(--l2-red); }
#square .node-H, #square .node-C { fill: var(--l2-blue); }
#square .side-lab { font: 12px var(--font); fill: var(--muted); letter-spacing: 0.06em; }
#square .arrow { cursor: pointer; outline: none; }
#square .hit { fill: none; stroke: transparent; stroke-width: 20; }
#square .stem { fill: none; stroke: var(--l2-grey); stroke-width: 1.6; }
#square .alab { font: 15px var(--font); fill: var(--muted); }
#square .ah path { fill: var(--l2-grey); }
#square .ah-sel path { fill: var(--ink); }
#square .arrow:hover .stem, #square .arrow:focus-visible .stem { stroke: var(--ink); }
#square .arrow:hover .alab, #square .arrow:focus-visible .alab { fill: var(--ink); }
#square .arrow.sel .stem { stroke: var(--ink); stroke-width: 3; }
#square .arrow.sel .alab { fill: var(--ink); font-weight: 700; }

/* formulas are drawn smaller when too wide (app.js), so they never need a scroll bar */
#formula, #card-step, .arrow-grid .cell .cell-tex { overflow: hidden; }
.arrow-grid .cell-tex .katex { white-space: nowrap; }   /* one line, never broken at an operator */
.step-card { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line); }
.card-rule { margin: 0; font-size: 15px; }
.card-step { font-size: 16px; }
.card-num { margin: 4px 0 0; font-size: 15px; line-height: 1.7; }

/* the eight arrows: four in a row, as in the lecture's table */
.arrow-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1px; margin-top: 10px; background: var(--line); border: 1px solid var(--line); }
.arrow-grid .cell { padding: 10px 10px 8px; background: var(--panel); text-align: center; cursor: pointer; min-width: 0; }
.arrow-grid .cell:hover { outline: 2px solid var(--line); outline-offset: -2px; }
.arrow-grid .cell.sel { outline: 3px solid var(--ink); outline-offset: -3px; }
.arrow-grid .cell-head { font-size: 14px; }
.arrow-grid .cell-rule { margin-top: 4px; font-size: 13px; color: var(--muted); }
.arrow-grid .cell-tex { margin: 6px 0 2px; font-size: 14px; }
.arrow-grid .cell-val { font-size: 13px; color: var(--muted); }

@media (max-width: 1100px) {
  .duo { grid-template-columns: minmax(0, 1fr); }
  .sq-wrap { max-width: 460px; margin: 0 auto; width: 100%; }
  .arrow-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
/* On a phone the figure and the square come first, the controls follow. */
@media (max-width: 800px) {
  .layout { grid-template-columns: minmax(0, 1fr); grid-template-rows: none; grid-template-areas: "main" "controls" "arrows"; }
}
@media (max-width: 480px) {
  .seg-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .arrow-grid { grid-template-columns: minmax(0, 1fr); }
  #square .alab { font-size: 18px; }
  #square .side-lab { font-size: 15px; }
}
