/*
 * Kulliyati -- the lecturer's screens: the Today panel, the live session (round
 * strip, live card, roster) and the presenter (docs/design/visual-design.md,
 * boards A-lecturer-desktop, A-lecturer-phone, A3-lecturer-desktop, A-presenter).
 *
 * Linked after app.css and components.css (templates/base.html), so these rules
 * win over the shared components at equal specificity. Same rules as app.css
 * (tests/test_css_rules.py): colours only as var(--attend-*) tokens, no
 * gradients, blur or filters, shadows only as the light theme's elevation
 * tokens (each is `none` in the dark themes).
 */
@layer components {
  /* --- The lecture's meta line ("CE-301 · Lecture | Groups | Room | 08:30–10:00") */

  /* A thin rule before every segment; the line is pulled left by one rule and
     its gap and clipped there, so a wrapped line never starts with a rule. */
  .lecture-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-1) var(--space-3);
    margin-top: var(--space-3);
    margin-inline-start: calc(-1 * var(--space-3) - 1px);
    clip-path: inset(0 0 0 calc(var(--space-3) + 1px)); /* physical: mirrored below */
    color: var(--attend-text);
    font-size: var(--text-small);
    line-height: var(--leading-small);
  }

  /* clip-path has no logical inset: in Arabic the first separator is on the right. */
  :root[dir="rtl"] .lecture-meta {
    clip-path: inset(0 calc(var(--space-3) + 1px) 0 0); /* physical: the rtl mirror */
  }

  /* Segments only: a room's .nowrap code (|code) inside one gets no rule. */
  .lecture-meta > span {
    padding-inline-start: var(--space-3);
    border-inline-start: 1px solid var(--attend-border);
  }

  /* --- Live page header: breadcrumbs, the course in display type, the meta line */

  .live-header h1 {
    margin-top: var(--space-2);
    font-size: var(--text-display);
    line-height: var(--leading-display);
    font-weight: var(--weight-display);
    letter-spacing: var(--tracking-display);
    overflow-wrap: anywhere;
  }

  .page-header:has(.live-header) {
    align-items: flex-start;
  }

  /* --- Today: CurrentLecturePanel */

  .lecture-panel {
    display: flex;
    flex-direction: column;
  }

  .lecture-panel__eyebrow {
    margin-bottom: var(--space-1);
    color: var(--attend-text-muted);
    font-size: var(--text-label);
    font-weight: var(--weight-label);
    letter-spacing: var(--tracking-label);
    line-height: var(--leading-label);
  }

  .lecture-panel__title {
    color: var(--attend-text-strong);
    font-family: var(--font-display);
    font-optical-sizing: auto;
    font-size: var(--text-h1);
    line-height: var(--leading-h1);
    font-weight: var(--weight-h1);
    letter-spacing: var(--tracking-h1);
    overflow-wrap: anywhere;
  }

  .lecture-panel__note {
    display: flex;
    align-items: flex-start;
    gap: var(--space-2);
    color: var(--attend-text-muted);
    font-size: var(--text-small);
  }

  .lecture-panel__note .icon {
    flex: none;
    margin-top: 2px;
  }

  /* --- Round strip: a brand-tint pill, "Round N · started … · N-minute window" */

  .round-strip {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-2) var(--space-3);
    min-height: 52px;
    margin: var(--space-6) 0 var(--space-4);
    padding-block: var(--space-2);
    padding-inline: var(--space-5) var(--space-2);
    border: 0;
    border-radius: var(--r-lg);
    background: var(--attend-brand-tint);
    color: var(--attend-text);
    font-size: var(--text-small);
    line-height: var(--leading-small);
  }

  .lecture-panel__about + .round-strip {
    margin-top: var(--space-5);
  }

  .round-strip__icon {
    flex: none;
    inline-size: 18px;
    block-size: 18px;
    color: var(--attend-brand-text);
  }

  .round-strip__label {
    color: var(--attend-text-strong);
    font-family: var(--font-body);
    font-size: var(--text-small);
    line-height: var(--leading-small);
    font-weight: var(--weight-label);
    letter-spacing: 0;
  }

  .round-strip__when {
    flex: 1 1 12rem;
    color: var(--attend-text);
    text-align: start;
  }

  /* "5-minute window" never breaks at its hyphen ("5- / minute window"). */
  .round-window {
    white-space: nowrap;
  }

  @media (min-width: 768px) {
    .round-strip {
      border-radius: var(--r-pill);
    }
  }

  /* --- Live card: the count and its bar beside the round's actions */

  .round-card {
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
    padding: var(--space-5);
    border: 1px solid var(--attend-border);
    border-radius: var(--r-lg);
    background: var(--attend-surface);
    box-shadow: var(--attend-shadow-card);
  }

  .lecture-panel__about + .round-card {
    margin-top: var(--space-4);
  }

  .round-card__main {
    display: grid;
    gap: var(--space-5);
  }

  .round-card__head {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    min-width: 0;
  }

  .round-card__state {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-1) 0;
  }

  /* Countdowns keep their width, so the line never jitters. */
  .round-card__countdown {
    display: inline-block;
    min-inline-size: 4ch;
  }

  /* "41 / 57": the figure in display numerals, "/ 57" muted at the same size. */
  .round-panel__count {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-1);
    margin-top: var(--space-4);
  }

  .round-card__tally {
    color: var(--attend-text-strong);
    font-size: var(--text-num-xl);
    line-height: var(--leading-num-xl);
    font-weight: var(--weight-num-xl);
    letter-spacing: var(--tracking-num-xl);
    font-variant-numeric: tabular-nums;
  }

  .round-card__tally small {
    color: var(--attend-text-muted);
    font-size: inherit;
    font-weight: var(--weight-h2);
    letter-spacing: inherit;
  }

  .round-card__caption {
    color: var(--attend-text);
    font-family: var(--font-body);
    font-size: var(--text-body);
    line-height: var(--leading-body);
  }

  /* Progress bars (the live card, the presenter's code lifetime): a pill
     track in --attend-progress-track (the brand tint in light, the hero's navy
     in dark, where the indigo fill on the tint would be 2.72:1), the fill in
     --attend-accent (owner, 2026-11-11). Each engine's pseudo-element has its
     own rule: an unknown one would drop a whole selector list. */
  .round-progress,
  .presenter__progress {
    display: block;
    inline-size: 100%;
    block-size: 8px;
    border: 0;
    border-radius: var(--r-pill);
    background: var(--attend-progress-track);
    overflow: hidden;
    appearance: none;
  }

  .round-progress {
    max-inline-size: 440px;
    margin-top: var(--space-4);
  }

  .round-progress::-webkit-progress-bar,
  .presenter__progress::-webkit-progress-bar {
    border-radius: var(--r-pill);
    background: var(--attend-progress-track);
  }

  .round-progress::-webkit-progress-value,
  .presenter__progress::-webkit-progress-value {
    border-radius: var(--r-pill);
    background: var(--attend-accent);
  }

  .round-progress::-moz-progress-bar,
  .presenter__progress::-moz-progress-bar {
    border-radius: var(--r-pill);
    background: var(--attend-accent);
  }

  /* Close check-in (the one primary) full width; Extend and Add manually share
     the row under it. */
  .round-card__actions {
    display: flex;
    flex-wrap: wrap;
    align-content: flex-start;
    gap: var(--space-2);
  }

  .round-card__actions > * {
    flex: 1 1 0;
  }

  /* Present code: a full-size secondary under the primary (owner, 2026-11-09). */
  .round-card__actions > .btn--primary,
  .round-card__actions > .round-card__present,
  .round-card__actions > form,
  .round-card__actions > [data-dialog-open="round-new"] {
    flex-basis: 100%;
  }

  /* "New attendance round": who scans (finalize UX step 4). Each choice is a
     full-width button with what it means under it; Check everyone again first. */
  .round-purpose {
    display: grid;
    gap: var(--space-4);
    margin: 0;
    padding: 0;
    list-style: none;
  }

  .round-purpose__choice {
    display: grid;
    gap: var(--space-1);
  }

  .round-purpose__choice .btn {
    inline-size: 100%;
  }

  .round-purpose__choice p {
    margin: 0;
  }

  .round-card__actions .btn {
    width: 100%;
  }

  .round-card__note {
    color: var(--attend-text-muted);
    font-size: var(--text-small);
    line-height: var(--leading-small);
  }

  /* The round's details and the quiet tools row, under a rule. */
  .round-card__foot {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
    padding-top: var(--space-4);
    border-top: 1px solid var(--attend-border);
  }

  .round-card__details {
    gap: var(--space-1) var(--space-6);
    color: var(--attend-text-muted);
    font-size: var(--text-small);
  }

  .round-card__details dt {
    font-size: var(--text-small);
  }

  .round-card__more {
    gap: var(--space-1);
  }

  .round-card__more .btn {
    padding-inline: var(--space-3) var(--space-4);
    font-size: var(--text-small);
  }

  /* Explanations after the content (AL11): the round history's footnote. */
  .round-history__note {
    margin-top: var(--space-3);
  }

  /* The Close check-in dialog's cost line. */
  .close-cost {
    color: var(--attend-text-strong);
    font-weight: var(--weight-bold);
  }

  .close-cost:empty {
    display: none;
  }

  /* "More": the rarer tools in a small panel under the button. */
  .tools-more {
    position: relative;
  }

  .tools-more > summary {
    list-style: none;
    cursor: pointer;
  }

  .tools-more > summary::-webkit-details-marker {
    display: none;
  }

  .tools-more[open] > summary {
    background: var(--attend-row-hover);
  }

  .tools-more__panel {
    position: absolute;
    inset-block-end: calc(100% + var(--space-1));
    inset-inline-start: 0;
    z-index: 5;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    min-inline-size: 15rem;
    padding: var(--space-2);
    border: 1px solid var(--attend-border);
    border-radius: var(--r-md);
    background: var(--attend-raised);
    box-shadow: var(--attend-shadow-raised);
  }

  .tools-more__panel .btn {
    justify-content: flex-start;
    inline-size: 100%;
  }

  /* Phone: the round's details as label | value rows, like the history card. */
  @media (max-width: 767px) {
    .round-card__details {
      grid-template-columns: max-content minmax(0, 1fr);
      gap: var(--space-2) var(--space-4);
    }

    .round-card__details dd {
      text-align: end;
    }

    .round-card__details dd + dt {
      margin-top: 0;
    }
  }

  @media (min-width: 768px) {
    .round-card {
      padding: var(--space-6) 28px;
    }

    .round-card__main {
      grid-template-columns: minmax(0, 1fr) minmax(200px, 240px);
      align-items: center;
      gap: var(--space-6) var(--space-10);
    }

    .round-card__actions > * {
      flex-basis: 100%;
    }

    .round-card__actions .btn--primary {
      min-height: 48px;
    }
  }

  @media (min-width: 768px) and (pointer: fine) {
    .round-card__actions .btn {
      min-height: 40px;
    }

    .round-card__actions .btn--primary {
      min-height: 48px;
    }

    .round-card__more .btn {
      min-height: 36px;
    }
  }

  /* --- Roster: a card with the count tabs, the pill search and compact rows */

  .roster-card {
    padding: var(--space-5) var(--space-4) var(--space-4);
    border: 1px solid var(--attend-border);
    border-radius: var(--r-lg);
    background: var(--attend-surface);
    box-shadow: var(--attend-shadow-card);
  }

  .roster-tools {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3) var(--space-4);
    margin-bottom: var(--space-4);
  }

  .roster-tools__title {
    font-size: var(--text-h2);
    line-height: var(--leading-h2);
  }

  /* "Roster" and the one "Add manually" (the dialog for the round being taken). */
  .roster-tools__head {
    display: flex;
    flex: 1 1 100%;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
  }

  /* The tabs: the segmented track; the selected tab a surface pill. A label
     never breaks (it used to read "Presen / t" on a phone): the tabs keep
     their width and a track too wide for the row scrolls sideways. */
  .roster-tabs {
    display: inline-flex;
    flex-wrap: nowrap;
    gap: 2px;
    max-inline-size: 100%;
    padding: 3px;
    overflow-x: auto;
    border: 1px solid var(--attend-border);
    border-radius: var(--r-pill);
    background: var(--attend-ground);
    scrollbar-width: none;
  }

  .roster-tabs .btn--plain {
    flex: 1 0 auto;
    gap: var(--space-2);
    min-height: var(--touch);
    padding-block: 0;
    padding-inline: var(--space-4) var(--space-2);
    color: var(--attend-text-muted);
    font-size: var(--text-small);
    font-weight: var(--weight-bold);
    white-space: nowrap;
    overflow-wrap: normal;
  }

  .roster-tabs .count-pill {
    flex: none;
  }

  /* Inside the scrolling track the ring would be clipped: draw it inside. */
  .roster-tabs .btn--plain:focus-visible {
    outline-offset: -4px;
  }

  @media (hover: hover) and (pointer: fine) {
    .roster-tabs .btn--plain:hover {
      background: transparent;
      color: var(--attend-text-strong);
    }
  }

  .roster-tabs .btn--plain:active {
    color: var(--attend-text-strong);
  }

  .roster-tabs .btn--plain[aria-current="true"] {
    background: var(--attend-surface);
    color: var(--attend-text-strong);
    font-weight: var(--weight-strong);
    box-shadow: var(--attend-shadow-card);
    /* A 3:1 edge in every theme (dark has no shadows); a border, so the focus
       ring (an outline) stays the 2px one. */
    border-color: var(--attend-border-strong);
  }

  .roster-search {
    flex: 1 1 280px;
    max-width: 420px;
    align-items: center;
    gap: var(--space-2) var(--space-3);
    margin-bottom: 0;
  }

  .roster-search .field--search {
    flex: 1 1 220px;
    margin: 0;
  }

  .roster-search__submit {
    flex: none;
  }

  /* The live wall (SF15): a tile per student on the current round's roster,
     dashed until they check in, then filled -- shape and fill, not colour
     alone. Initials on a computer, dots on a phone (live-wall below). */
  .live-wall {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-block: var(--space-2) var(--space-2);
  }

  /* The tile itself is the shared one (static/css/components.css "Live wall"). */
  .live-wall__tile {
    inline-size: 32px;
    block-size: 32px;
  }

  .live-wall__legend {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-2);
    margin-bottom: var(--space-3);
    color: var(--attend-text-muted);
    font-size: var(--text-small);
  }

  .live-wall__key {
    inline-size: 12px;
    block-size: 12px;
    border: 1.5px dashed var(--attend-border-strong);
    border-radius: 50%;
  }

  .live-wall__key:not(:first-child) {
    margin-inline-start: var(--space-3);
  }

  .live-wall__key--in {
    border-style: solid;
    border-color: var(--attend-brand);
    background: var(--attend-brand);
  }

  /* Arrivals since the last refresh (live-round.js sets data-arrived): the
     tile pops, the row's tint fades out. Nothing moves under reduced motion. */
  @media (prefers-reduced-motion: no-preference) {
    .live-wall__tile[data-arrived] {
      animation: attend-lecturer-pop 420ms cubic-bezier(0.22, 1, 0.36, 1);
    }

    .roster-row[data-arrived] > td {
      animation: attend-lecturer-arrive 1200ms ease-out;
    }
  }

  @keyframes attend-lecturer-pop {
    0% {
      transform: scale(0.6);
    }

    100% {
      transform: scale(1);
    }
  }

  @keyframes attend-lecturer-arrive {
    from {
      background-color: var(--attend-brand-tint);
    }
  }

  .roster-compare {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-2) var(--space-3);
    margin: var(--space-3) 0;
    font-size: var(--text-small);
  }

  /* The student cell on every width: the initials circle, the name and
     "ID · group" under it (no ID or Group column: batch 3 review, item 1). */
  .roster-person {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
    gap: 0 10px;
  }

  .roster-person .initials {
    grid-row: 1 / span 2;
  }

  .roster-student {
    display: block;
    color: var(--attend-text-strong);
    font-weight: var(--weight-bold);
  }

  .roster-person__meta {
    display: block;
    color: var(--attend-text-muted);
    font-size: var(--text-small);
    font-weight: var(--weight-body);
  }

  /* Needs review: a thin plum marker on the row's left edge and the chip's
     review icon -- never a tinted row (owner, 2026-10-31). */
  .roster-row--review > td:first-child {
    position: relative;
  }

  .roster-row--review > td:first-child::before {
    content: "";
    position: absolute;
    inset-block: 0;
    inset-inline-start: 0;
    inline-size: 3px;
    background: var(--attend-warning-text);
  }

  .roster-actions {
    white-space: nowrap;
  }

  .roster-action {
    min-height: var(--touch);
    padding-inline: var(--space-3);
    font-size: var(--text-small);
  }

  /* The note after the rows ("8 of 24 students shown. …"): the card is left
     out of the page's flow spacing, so it keeps its own gap (design
     integration review, 2026-11-10). */
  .roster-note {
    margin-block-start: var(--space-3);
  }

  @media (min-width: 768px) {
    .roster-card {
      padding: var(--space-5) var(--space-6) var(--space-6);
    }

    /* One height for every row, with or without a row action, so a check-in
       never moves the rows under the pointer (AD7): the name and its meta
       line fill it. One round column keeps Final status and the actions in
       view whatever the number of rounds (batch 3 review, item 1). */
    .roster-table td {
      block-size: 52px;
    }

    .roster-actions {
      text-align: end;
    }
  }

  /* Compact for a mouse only (tests/test_css_touch.py): count tabs 36px as
     the design's segmented control (§7), row actions 36px ghost buttons. */
  @media (min-width: 768px) and (pointer: fine) {
    .roster-tabs .btn--plain {
      min-height: 36px;
    }

    .roster-action {
      min-height: 36px;
    }
  }

  /* Phone: the rows are cards (table--cards); the marker runs along the card. */
  @media (max-width: 767px) {
    .roster-card {
      padding-inline: 0;
      padding-bottom: 0;
      overflow: hidden;
    }

    .roster-tools,
    .roster-card > .region > :not(.table-wrap) {
      padding-inline: var(--space-4);
    }

    .roster-tabs {
      flex: 1 1 100%;
    }

    .roster-tabs .btn--plain {
      padding-inline: var(--space-3) var(--space-2);
    }

    .roster-search {
      max-width: none;
    }

    /* The card has no bottom padding on a phone: the note keeps off its edge. */
    .roster-card .roster-note {
      padding-block-end: var(--space-4);
    }
  }

  /* A phone: the four tabs don't fit one row, and a track that scrolled
     sideways hid Review with no sign of it (batch 3 review; a fade would be
     a gradient, banned decoration). Two rows of two, every tab in sight. */
  @media (max-width: 479px) {
    .roster-tabs {
      display: grid;
      grid-template-columns: repeat(2, minmax(0, 1fr));
      overflow-x: visible;
      border-radius: var(--r-lg);
    }

    .roster-tabs .btn--plain {
      justify-content: space-between;
    }
  }

  @media (max-width: 767px) {

    .roster-row--review {
      border-inline-start: 3px solid var(--attend-warning-text);
    }

    .roster-row--review > td:first-child::before {
      content: none;
    }

    .roster-person .initials {
      inline-size: 40px;
      block-size: 40px;
      font-size: var(--text-small);
    }

    /* A list row, not a label/value card (top 15 #13): initials, the name
       with "ID · group" under it, the round's chip under that and the action
       at the end. The comparison and the final status stay on a computer;
       every round's result per student is on Review. */
    .roster-table tr {
      display: grid;
      grid-template-columns: minmax(0, 1fr) auto;
      align-items: center;
      gap: var(--space-1) var(--space-2);
    }

    .roster-table td {
      display: block;
      padding: 0;
      text-align: start;
    }

    .roster-table td[data-label]:not(:first-child)::before {
      content: none;
    }

    .roster-table td:not(:first-child, .roster-cell--current, .roster-actions) {
      display: none;
    }

    .roster-table td.roster-cell--current {
      grid-column: 1;
      padding-inline-start: 50px;
    }

    .roster-table td.roster-actions {
      display: flex;
      flex-direction: column;
      align-items: flex-end;
      grid-column: 2;
      grid-row: 1 / span 2;
    }

    .roster-person {
      grid-template-columns: 40px minmax(0, 1fr);
    }

    /* The row action as an icon button; its words stay its accessible name. */
    .roster-action {
      inline-size: var(--touch);
      padding: 0;
    }

    .roster-action__label {
      position: absolute;
      inline-size: 1px;
      block-size: 1px;
      overflow: hidden;
      clip-path: inset(50%);
      white-space: nowrap;
    }

    /* The wall as dots: a class of 60 fits in four short lines. */
    .live-wall {
      gap: 4px;
    }

    .live-wall__tile {
      inline-size: 14px;
      block-size: 14px;
      font-size: 0;
    }

    .roster-actions {
      justify-content: flex-end;
    }

    /* A row with no action shows no empty "Actions" line. */
    .roster-actions:empty {
      display: none;
    }
  }

  /* --- Presenter (§11, projector mode: owner, design review 2026-11-09): the
     page starts light whatever the account theme ("Dark screen" switches this
     page only); the code's tile is always white with black modules (the canvas
     paints its own quiet zone). A billboard for the back row beside the tile
     (below it on a narrow screen): the wordmark, the headline "Open Kulliyati
     and tap Check in", the course and round, the checked-in count large, the
     time left, and "Code k" as a small label beside its bar. */

  html:has(body.presenter-page) {
    background: var(--attend-ground);
    color-scheme: revert-layer;
  }

  .presenter-page {
    background: var(--attend-ground);
    color: var(--attend-text);
  }

  /* Stacked (a narrow, portrait or nearly square screen): the page is the
     window's height; the tile takes the room the words leave (a size
     container, so the square follows the smaller side), never under 240px.
     Content that still does not fit scrolls; nothing is clipped. */
  .presenter {
    position: relative;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    gap: var(--space-4);
    min-height: 100vh;
    min-height: 100dvh;
    padding: var(--space-3) var(--space-4);
    padding-bottom: max(var(--space-4), env(safe-area-inset-bottom));
    overflow-x: clip;
    background: var(--attend-ground);
    color: var(--attend-text);
  }

  .presenter__tools {
    position: relative;
    z-index: 1;
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: var(--space-2);
  }

  /* Full screen, Dark screen and Live session: one tinted pill each. */
  .presenter .btn {
    border-color: transparent;
    background: var(--attend-brand-tint);
    color: var(--attend-brand-text);
  }

  .presenter .btn[aria-pressed="true"] {
    background: var(--attend-surface);
    border-color: var(--attend-border-strong);
  }

  /* The buttons stay 44px targets at every width. */
  .presenter .presenter__btn {
    min-height: var(--touch);
  }

  /* The screen-sleep note is the lecturer's: a small quiet note that takes
     its own room at the end of the billboard column, so it never covers the
     words (batch 3 review); gone in full screen (below). */
  .presenter__note {
    max-inline-size: 24rem;
    margin: var(--gap) 0 0;
    padding: var(--space-2) var(--space-3);
    border: 1px solid var(--attend-border);
    border-radius: var(--r-md);
    background: var(--attend-surface);
    color: var(--attend-text-muted);
    font-size: var(--text-small);
    line-height: var(--leading-small);
  }

  .presenter__layout {
    position: relative;
    z-index: 1;
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(240px, 1fr) auto;
    gap: var(--space-6) clamp(32px, 5vw, 80px);
    min-height: 0;
  }

  .presenter__frame {
    display: grid;
    place-items: center;
    min-height: 240px;
    container-type: size;
  }

  /* The white tile: rounded, with 16px of white padding so its corners never
     cut into the code (a 28px corner reaches 8.2px in). */
  .presenter__tile {
    box-sizing: border-box;
    inline-size: max(240px, min(100cqi, 100cqb));
    block-size: max(240px, min(100cqi, 100cqb));
    padding: var(--space-4);
    border-radius: var(--r-xl);
    background: var(--attend-projection-bg);
    box-shadow: var(--attend-shadow-raised);
  }

  .presenter__stage {
    display: grid;
    place-items: center;
    inline-size: 100%;
    block-size: 100%;
    overflow: hidden;
    background: var(--attend-projection-bg);
    color: var(--attend-projection-fg);
  }

  .presenter__code {
    display: block;
    image-rendering: pixelated;
  }

  /* Between two codes (presenter.js): the old code is wiped and out of sight,
     but the canvas keeps its box, so the tile and the page do not move. */
  .presenter__code[data-swap] {
    visibility: hidden;
  }

  /* The script's words come one language per line (static/js/lib/bilingual.js):
     each line keeps its own direction. */
  .presenter__message,
  .presenter__summary,
  .presenter__countdown,
  .presenter__code-number {
    white-space: pre-line;
    unicode-bidi: plaintext;
  }

  .presenter__message {
    max-width: 36rem;
    padding: var(--space-6);
    color: var(--attend-projection-fg);
    font-size: var(--text-h2);
    line-height: var(--leading-h2);
    text-align: center;
  }

  /* The closing card (SF idea 2): "N of M checked in" on the white tile for
     3 seconds when the round closes, in the tile's own black. */
  .presenter__summary {
    max-width: 14ch;
    padding: var(--space-6);
    color: var(--attend-projection-fg);
    font-family: var(--font-display);
    font-optical-sizing: auto;
    font-size: clamp(32px, 9cqi, 72px);
    font-weight: var(--weight-h1);
    line-height: 1.05;
    text-align: center;
    text-wrap: balance;
  }

  /* The billboard's sizes follow the screen (--u: a hundredth of the height,
     held back on a narrow screen); stacked, they are fixed clamps. */
  .presenter__info {
    --gap: clamp(12px, 2.4vw, 24px);

    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-self: center;
    min-width: 0;
    max-width: 46rem;
  }

  .presenter__brand {
    font-size: clamp(28px, 6vw, 48px);
    line-height: 1;
  }

  .presenter__brand .wordmark {
    font-size: inherit;
  }

  .presenter__hint {
    margin-top: var(--gap);
    color: var(--attend-text);
    font-size: clamp(24px, 5vw, 40px);
    line-height: 1.15;
    font-weight: var(--weight-button);
    text-wrap: balance;
  }

  .presenter__hint strong {
    color: var(--attend-text-strong);
    font-weight: var(--weight-h2);
  }

  .presenter__app {
    color: var(--attend-text-strong);
    font-family: var(--font-display);
    font-optical-sizing: auto;
    font-weight: var(--weight-display);
    letter-spacing: -0.03em;
  }

  .presenter__label {
    margin-top: var(--gap);
    color: var(--attend-text-strong);
    font-size: clamp(20px, 3.5vw, 32px);
    line-height: 1.15;
    font-weight: var(--weight-h2);
    letter-spacing: var(--tracking-h1);
    overflow-wrap: anywhere;
  }

  .presenter__sep {
    color: var(--attend-text-muted);
  }

  /* The checked-in count: the number large, "checked in" beside it, and a
     "+N" that pops when it rises (readout.js). */
  .presenter__count {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0 var(--space-3);
    margin-top: calc(var(--gap) * 1.5);
  }

  .presenter__count-number {
    color: var(--attend-text-strong);
    font-family: var(--font-display);
    font-optical-sizing: auto;
    font-size: clamp(48px, 12vw, 72px);
    line-height: 0.95;
    font-weight: var(--weight-display);
    letter-spacing: var(--tracking-num-xl);
    font-variant-numeric: tabular-nums;
  }

  .presenter__count-label {
    display: inline-flex;
    align-items: center;
    gap: 0.3em;
    color: var(--attend-text);
    font-size: clamp(18px, 3vw, 24px);
    font-weight: var(--weight-bold);
  }

  .presenter__count-label .icon {
    inline-size: 1em;
    block-size: 1em;
    color: var(--attend-positive-text);
  }

  .presenter__gain {
    color: var(--attend-positive-text);
    font-size: clamp(18px, 3vw, 24px);
    font-weight: var(--weight-display);
    font-variant-numeric: tabular-nums;
    opacity: 0;
  }

  @media (prefers-reduced-motion: no-preference) {
    .presenter__gain[data-pop="a"] {
      animation: attend-presenter-gain-a 1600ms ease-out forwards;
    }

    .presenter__gain[data-pop="b"] {
      animation: attend-presenter-gain-b 1600ms ease-out forwards;
    }
  }

  /* Two names for one motion: switching between them restarts it. */
  @keyframes attend-presenter-gain-a {
    0% {
      opacity: 0;
      transform: translateY(0.4em) scale(0.8);
    }

    15%,
    70% {
      opacity: 1;
      transform: none;
    }

    100% {
      opacity: 0;
      transform: translateY(-0.3em);
    }
  }

  @keyframes attend-presenter-gain-b {
    0% {
      opacity: 0;
      transform: translateY(0.4em) scale(0.8);
    }

    15%,
    70% {
      opacity: 1;
      transform: none;
    }

    100% {
      opacity: 0;
      transform: translateY(-0.3em);
    }
  }

  .presenter__countdown {
    margin-top: var(--gap);
    color: var(--attend-text-strong);
    font-size: clamp(22px, 4vw, 32px);
    line-height: 1.2;
    font-weight: var(--weight-h2);
    font-variant-numeric: tabular-nums;
  }

  .presenter__countdown:empty {
    display: none;
  }

  /* "Code k": a small muted label beside the code's bar -- students never
     type it, so it is no longer the loudest thing on the screen. */
  .presenter__code-row {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    inline-size: 100%;
    max-inline-size: 520px;
    margin-top: var(--gap);
  }

  .presenter__progress {
    flex: 1 1 auto;
    block-size: 10px;
  }

  .presenter__code-number {
    flex: none;
    color: var(--attend-text-muted);
    font-size: var(--text-small);
    font-weight: var(--weight-bold);
    font-variant-numeric: tabular-nums;
  }

  /* A landscape screen (a projector): the tile at about 80% of the height on
     the left, the billboard beside it, the tools in the top corner, and the one
     decorative shape, a brand-tint circle off the bottom-right corner, far from
     the tile. The page is exactly the window: overflow is clipped both ways,
     so a projector never shows a scrollbar (design review 2026-11-09). */
  @media (min-width: 900px) and (min-aspect-ratio: 1/1) {
    .presenter {
      grid-template-rows: minmax(0, 1fr);
      block-size: 100vh;
      block-size: 100dvh;
      min-height: 0;
      padding: 0;
      overflow: clip;
    }

    .presenter__tools {
      position: absolute;
      inset-block-start: var(--space-3);
      inset-inline-end: var(--space-4);
      z-index: 2;
      max-inline-size: 32rem;
    }

    .presenter__layout {
      --u: min(1dvh, 0.55vw);

      box-sizing: border-box;
      grid-template-columns: auto minmax(0, 1fr);
      grid-template-rows: none;
      align-content: center;
      align-items: center;
      gap: 0 clamp(32px, 4vw, 80px);
      block-size: 100%;
      padding: 10dvh clamp(24px, 4vw, 72px);
    }

    .presenter__frame {
      display: block;
      min-height: 0;
      container-type: normal;
    }

    /* About 80% of the height (owner: "QR ~80vh"), never more than half the width. */
    .presenter__tile {
      inline-size: min(80dvh, 52vw);
      block-size: min(80dvh, 52vw);
    }

    .presenter__info {
      --gap: calc(var(--u) * 3);

      justify-self: start;
      max-width: none;
    }

    .presenter__brand {
      font-size: clamp(32px, calc(var(--u) * 6), 64px);
    }

    .presenter__hint {
      font-size: calc(var(--u) * 6.4);
    }

    /* Both languages make the billboard twice as tall: the headline and the
       countdown step down so it still fits the screen under the tools. */
    .presenter__hint:has(.bilingual) {
      font-size: calc(var(--u) * 4.6);
    }

    .presenter__info:has(.bilingual) .presenter__countdown {
      font-size: calc(var(--u) * 3.6);
    }

    .presenter__label {
      font-size: calc(var(--u) * 3.6);
    }

    .presenter__count-number {
      font-size: calc(var(--u) * 11);
    }

    .presenter__count-label,
    .presenter__gain {
      font-size: calc(var(--u) * 3.2);
    }

    .presenter__countdown {
      font-size: calc(var(--u) * 4.6);
    }

    .presenter__code-number {
      font-size: max(var(--text-small), calc(var(--u) * 2.2));
    }

    /* Fixed to the window, not to the page: a fixed box never adds to the
       size of the page or of a scroller, so the circle running off the corner
       can't make the expanded fallback (which may scroll) scroll by its 96px
       (AL13). The billboard (z-index 1) paints over it. */
    .presenter::after {
      content: "";
      position: fixed;
      inset-inline-end: -84px;
      inset-block-end: -96px;
      inline-size: 240px;
      block-size: 240px;
      border-radius: 50%;
      background: var(--attend-brand-tint);
      opacity: 0.6;
      pointer-events: none;
    }
  }

  /* Full screen (ATTENDANCE_PROTOCOL §8): the navigation link and the notes go;
     the expanded fallback (no or refused Fullscreen API) fills the window.
     Separate rules per selector: an unknown prefixed pseudo-class would drop a
     whole selector list. */
  .presenter[data-expanded="true"] {
    position: fixed;
    inset: 0;
    z-index: 10;
    overflow-y: auto;
  }

  .presenter[data-expanded="true"] .presenter__back,
  .presenter[data-expanded="true"] .presenter__note {
    display: none;
  }

  :root:fullscreen .presenter__back,
  :root:fullscreen .presenter__note {
    display: none;
  }

  :root:-webkit-full-screen .presenter__back,
  :root:-webkit-full-screen .presenter__note {
    display: none;
  }

  /* --- Finalize attendance (finalize UX step 2; templates/attendance/_finalize_*.html) ---- */

  /* The errors of a refused post, at the top: each one a link to its field. */
  .error-summary {
    display: grid;
    gap: var(--space-2);
    padding: var(--space-3) var(--space-4);
    border: 1px solid var(--attend-danger);
    border-radius: var(--r-sm);
    background: var(--attend-danger-bg);
    color: var(--attend-danger-text);
  }

  .error-summary__title {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    font-weight: var(--weight-strong);
  }

  .error-summary__list {
    display: grid;
    gap: var(--space-1);
    padding-inline-start: var(--space-6);
  }

  .error-summary a {
    color: inherit;
  }

  /* The shared reason: wrapping chips, one radio each (the radio itself hidden
     as in .segmented; the chip shows the choice and the focus). */
  .reason-chips {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
  }

  .reason-chip {
    position: relative;
    display: inline-flex;
    align-items: center;
    min-block-size: var(--touch);
    padding-inline: var(--space-4);
    border: 1px solid var(--attend-border-strong);
    border-radius: var(--r-pill);
    background: var(--attend-surface);
    color: var(--attend-text);
    font-size: var(--text-small);
    font-weight: var(--weight-bold);
    cursor: pointer;
  }

  .reason-chip input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
  }

  /* The chosen chip (owner F4): a check mark and a 2px edge (the border and an
     outline just inside it, so nothing moves), in both themes. */
  .reason-chip:has(input:checked) {
    gap: var(--space-1);
    border-color: var(--attend-brand-text);
    outline: 1px solid var(--attend-brand-text);
    outline-offset: -2px;
    background: var(--attend-brand-tint);
    color: var(--attend-brand-text);
  }

  .reason-chip__check {
    display: none;
  }

  .reason-chip:has(input:checked) .reason-chip__check {
    display: inline-block;
  }

  .reason-chip:has(input:focus-visible) {
    outline: 2px solid var(--attend-focus);
    outline-offset: 1px;
  }

  /* Students who need a decision, by reason. */
  .decision-group {
    display: grid;
    gap: var(--space-2);
    margin-block-start: var(--space-4);
  }

  /* Owner F4: on a phone the first student sits higher. When the decisions open the
     page (nothing above them in the body), the page header's own space is enough. */
  .review-body > .finalize:first-child > [name="csrfmiddlewaretoken"]:first-child + .section {
    margin-block-start: 0;
  }

  .decision-group__title {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    font-size: var(--text-body);
  }

  /* Owner G1: "All N:" once, then the statuses, in one compact row of 44px targets;
     the row wraps whole buttons (a label never breaks inside its button). */
  .decision-group__all {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-1);
  }

  .decision-group__all-label {
    margin-inline-end: var(--space-1);
    color: var(--attend-text-muted);
    font-size: var(--text-small);
    font-weight: var(--weight-bold);
    white-space: nowrap;
  }

  .decision-group__all .btn {
    min-height: var(--touch);
    padding-block: 0;
    padding-inline: var(--space-3);
    white-space: nowrap;
    overflow-wrap: normal;
  }

  .decision-list {
    display: grid;
    border-block-start: 1px solid var(--attend-edge);
  }

  .decision {
    display: grid;
    gap: var(--space-2);
    padding-block: var(--space-3);
    border-block-end: 1px solid var(--attend-edge);
  }

  @media (min-width: 768px) {
    .decision {
      grid-template-columns: minmax(0, 1fr) auto;
      align-items: center;
      column-gap: var(--space-6);
    }

    .decision__own {
      grid-column: 1 / -1;
    }
  }

  /* Its rounds are a .dot-items list (components.css): no dot at a line's edge. */
  .decision__evidence {
    color: var(--attend-text-muted);
  }

  .decision__status {
    min-inline-size: 0;
    border: 0;
  }

  /* Up to five statuses: the track wraps instead of overflowing a phone. */
  .segmented.decision__statuses {
    display: flex;
    flex-wrap: wrap;
    max-inline-size: none;
    border-radius: var(--r-sm);
  }

  .decision__statuses .segmented__option {
    flex: 1 1 auto;
  }

  .decision__own > summary {
    color: var(--attend-text-muted);
    font-size: var(--text-small);
    cursor: pointer;
  }

  /* The action stays under the thumb at the foot of the page. */
  .finalize-bar {
    position: sticky;
    inset-block-end: 0;
    z-index: 4;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-2) var(--space-4);
    padding-block: var(--space-3) max(var(--space-3), env(safe-area-inset-bottom));
    border-block-start: 1px solid var(--attend-edge);
    background: var(--attend-ground);
  }

  /* Phones: the tab bar is fixed over the page's end (app.css, below 768px). Above
     the floating C1a bar (Board, 2026-11-18), 8px tighter than on a computer so
     the first student's name still shows whole above it (F4, G1). */
  @media (max-width: 767px) {
    .shell--bottom-nav .finalize-bar {
      inset-block-end: var(--bottom-nav-room);
      padding-block: var(--space-2);
    }
  }

  .finalize.htmx-request .finalize-bar .btn--primary {
    cursor: progress;
  }

  /* A blocker's own action beside its words. */
  .blocker-list li {
    flex-wrap: wrap;
  }

  .blocker-list__action {
    display: inline;
  }

  /* The full table and the rules, folded under their headings once decisions come first. */
  .review-more__summary {
    cursor: pointer;
    list-style-position: inside;
  }

  .review-more__summary h2 {
    display: inline;
  }
}
