/* ============================================================================
   styles/course/bridge.css  --  the app's side of the course stylesheets.

   tokens.css, kit.css and asm86.css are the course site's own files, copied
   unchanged (styles/course/README.md). They were written for Quarto pages and
   read three things a Quarto page provides:

     --bs-body-bg, --bs-body-color      the page colors every neutral is mixed from
     --bs-font-monospace, --bs-font-sans-serif
     body.quarto-light / body.quarto-dark   which theme the page shows

   This file supplies the first two from the app's own tokens (styles.css),
   which already swap with the theme, so nothing here needs a dark rule.
   The body classes are set from script (src/ui/theme.ts), because the app's
   theme can be "system" and a class cannot be chosen by CSS alone.

   Load order: styles.css, bridge.css, tokens.css, kit.css, asm86.css.
   ==========================================================================*/

:root {
    --bs-body-bg: var(--paper-2);
    --bs-body-color: var(--ink);
    --bs-font-monospace: var(--mono);
    --bs-font-sans-serif: var(--sans);
}

/* ---------------------------------------------------------------------------
   The Hardware area's machine board (src/ui/hw/board.ts) puts the course's
   views in the app's dock. Adjustments for that home, never in the course files.
   ------------------------------------------------------------------------ */

/* A register card that also shows its narrower names needs room for the
   name, sixteen hex digits, and the width on one line. */
.board-a86 .a86-regs {
    grid-template-columns: repeat(auto-fill, minmax(calc(var(--w-fs) * 17), 1fr));
}

.board-a86 .a86-width-row {
    grid-template-columns: calc(var(--w-fs) * 2.83) minmax(0, 1fr) auto;
}
.board-a86 .a86-regs { align-items: start; }

/* The "was ..." line under a register's value is empty until the register
   changes. asm86.css gives it a min-height (0.8rem) shorter than its own line
   box, so a card grew a few pixels the step it changed and shrank on the next,
   moving every card below it. Reserve the whole line, filled or not. */
.board-a86 .a86-reg-prev {
    line-height: 1.35;
    min-height: 1.35em;
}

.board-a86.a86 {
    margin: 0;
}

/* The board's own "Cache lines" view (src/ui/hw/lines.ts): a line as a row of
   byte cells, in the course's load, store and match colors. */
.hw-line + .hw-line {
    margin-top: 0.6rem;
    padding-top: 0.6rem;
    border-top: 1px dashed var(--w-rule);
}

.hw-line-head,
.hw-line-use {
    margin: 0.2rem 0;
}

.hw-line-cells {
    display: grid;
    grid-template-columns: repeat(var(--hw-line, 16), minmax(0, 1fr));
    gap: 2px;
    max-width: calc(var(--hw-line, 16) * 1.9rem);
}

.hw-line-cell {
    display: block;
    min-height: 1.6rem;
    border: 1px solid var(--w-rule);
    border-radius: 2px;
    background: var(--w-surface);
    color: var(--w-dim);
    font-family: var(--w-mono);
    font-size: 0.7rem;
    line-height: 1.6rem;
    text-align: center;
    overflow: hidden;
}

.hw-line-cell.is-read { background: var(--w-read-bg); border-color: var(--w-read); color: var(--w-read); }
.hw-line-cell.is-write { background: var(--w-write-bg); border-color: var(--w-write); color: var(--w-write); }
.hw-line-cell.is-used { background: var(--w-match-bg); }
.hw-line-cell.is-later { background: var(--w-surface-2); border-style: dashed; }

.hw-swatch {
    display: inline-block;
    width: 1rem;
    min-height: 0.9rem;
    height: 0.9rem;
    vertical-align: middle;
    margin-right: 0.3rem;
}

.hw-hit { color: var(--w-match); font-weight: 600; }
.hw-miss { color: var(--w-miss); font-weight: 600; }

/* The whole core (machineView in hwviews.js): a lit edge's arrowhead takes the
   edge's color, so the head shows which way that instruction's data moved. */
.a86-chip-svg marker.is-active path { fill: var(--w-change); }
.a86-chip-svg marker.is-load path { fill: var(--w-read); }
.a86-chip-svg marker.is-store path { fill: var(--w-write); }
.a86-chip-edge.is-active { stroke-width: 2.2; }

/* The sentence under the core is one line for some instructions and two for
   others; hold two, so the legend under it stays put while stepping. */
.board-a86 .a86-chip-caption {
    line-height: 1.45;
    min-height: 4.35em;
}

/* A port's box is 29 units wide; at 9px "alu mul" fits only in a narrow face,
   and spills into the next port in the wider fallback fonts. */
.a86-chip-node.is-port .a86-chip-sub { font-size: 7px; }

/* Address arithmetic is one line ("named no memory address") on most steps and
   a two-row sum with a note on the others. Hold the taller shape, so the card
   and everything below it keep their place. */
.board-a86 .a86-addr { min-height: calc(var(--w-fs) * 14.5); }

/* The cache-line view lists the lines the last access touched: none before the
   first access, one or two after. Hold two, so the legend under it stays put. */
.board-a86 .hw-lines { min-height: 78px; }

/* A listing row's trailing comment takes what width is left. In a narrow card
   that is nothing, and a wrapping comment then stood one character per line,
   leaving tall blank rows. Cut it with an ellipsis instead (a comment on its
   own line still wraps). */
.board-a86 .a86-code-row:not(.is-note) > .a86-code-comment {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
