/* Subjects: the student's Subjects list and subject page, the staff Subjects
   list, and the row of sections every subject page shares (owner, 2026-11-13;
   boards Main, F2-TabsIcons, F2-SubjectAttendance, F2-LecturerFiles).

   Loaded after admin.css (templates/base.html). Only rules in the declared
   layers, only tokens, only logical properties (tests/test_css_stylesheets.py,
   tests/test_css_rules.py, tests/ui/test_css_logical.py). The files of a
   subject have their own sheet (materials.css). */

@layer components {
  /* ------------------------------------------------- The row of sections
     One slim row styled like the tab bar: an icon over its word, the current
     section in the brand colour with its filled icon; no underline, no 2x2
     block. Each section keeps its word whole (max-content) and the row scrolls
     sideways before a word would break. Also the Timetable's Lectures | Exams. */
  .subject-nav {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: minmax(max-content, 1fr);
    border-block-end: 1px solid var(--attend-border);
    overflow-x: auto;
    white-space: nowrap;
    scrollbar-width: none;
  }

  .subject-nav__link {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--space-1);
    min-block-size: 56px;
    min-inline-size: var(--touch);
    padding-inline: var(--space-1);
    color: var(--attend-text-muted);
    font-size: var(--text-label);
    font-weight: var(--weight-button);
    line-height: var(--leading-label);
    text-decoration: none;
  }

  .subject-nav__link[aria-current="page"] {
    color: var(--attend-brand-text);
  }

  .subject-nav__link:focus-visible {
    outline-offset: -2px;
  }

  .subject-nav__icon {
    position: relative;
    display: grid;
    place-items: center;
    inline-size: 20px;
    block-size: 20px;
  }

  .subject-nav__icon .icon {
    inline-size: 20px;
    block-size: 20px;
  }

  /* New things in a section: the count on its icon's corner (the words say
     it too, for a screen reader). */
  .subject-nav__count {
    position: absolute;
    inset-block-start: -7px;
    inset-inline-start: 13px;
    min-inline-size: 20px;
    block-size: 20px;
    padding: 0 3px;
    border: 2px solid var(--attend-ground);
  }

  /* The staff row: the icon beside the word, no count. */
  .subject-nav--inline {
    display: flex;
    gap: var(--space-6);
    border-block-end: 1px solid var(--attend-border);
  }

  .subject-nav--inline .subject-nav__link {
    display: inline-flex;
    flex-direction: row;
    align-items: center;
    gap: var(--space-2);
    min-block-size: var(--touch);
    padding-inline: 0;
    color: var(--attend-text-muted);
    font-size: var(--text-body);
    font-weight: var(--weight-semi);
    line-height: var(--leading-body);
    text-decoration: none;
    white-space: nowrap;
  }

  .subject-nav--inline .subject-nav__link[aria-current="page"] {
    color: var(--attend-brand-text);
    font-weight: var(--weight-strong);
  }

  .subject-nav--inline .subject-nav__link .icon {
    flex: none;
    inline-size: 20px;
    block-size: 20px;
  }

  /* The row under a subject's header; a section that starts with its own
     list heads leaves the space out. */
  .subject-nav--spaced {
    margin-block: 0 var(--space-4);
  }

  .subject-header {
    margin-block-end: var(--space-2);
  }

  /* ------------------------------------------------- The Subjects list
     A course row (student.css) whose whole surface opens the subject. The
     page's header is the shared one (a tab's top row on a phone); the class is
     the What's New scene's (scenes/subjects_tab.html). */
  .subjects-header {
    gap: var(--space-1) var(--space-6);
    margin-block-end: var(--space-3);
  }

  .page-header:has(+ .subject-links, + .course-list) {
    margin-block-end: var(--space-3);
  }

  /* Results and "Excuses and corrections" over the subjects (owner, 2026-11-18,
     design A): the shared rows (.link-rows, components.css), then the list. */
  .subject-links {
    margin-block-end: var(--space-5);
  }

  /* The whole row is one link (owner, 2026-11-18): the card's padding moves onto
     it, so a press lights the full width between the card's dividers. */
  .subject-row {
    display: block;
    min-height: 0;
    padding-block: 0;
  }

  .subject-row__link {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    min-block-size: 72px;
    margin-inline: calc(-1 * var(--space-4));
    padding: var(--space-3) var(--space-4);
    color: inherit;
    text-decoration: none;
    -webkit-tap-highlight-color: transparent;
  }

  .subject-row:first-child .subject-row__link {
    border-start-start-radius: var(--r-lg);
    border-start-end-radius: var(--r-lg);
  }

  .subject-row:last-child .subject-row__link {
    border-end-start-radius: var(--r-lg);
    border-end-end-radius: var(--r-lg);
  }

  @media (hover: hover) and (pointer: fine) {
    .subject-row__link:hover {
      background: var(--attend-row-hover);
    }
  }

  /* row-hover, not surface-hover: in light the latter is the empty ring's track. */
  .subject-row__link:active {
    background: var(--attend-row-hover);
  }

  .subject-row__link:focus-visible {
    outline-offset: -2px;
  }

  .subject-row__chevron {
    flex: none;
    color: var(--attend-text-muted);
  }

  /* What is new in a subject: chips in the information tint, one line each. */
  .course-row__body .subject-badges {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-1) var(--space-2);
    margin-block-start: var(--space-2);
  }

  .subject-badge {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    min-block-size: 24px;
    padding-inline: var(--space-2);
    border-radius: var(--r-pill);
    background: var(--attend-info-bg);
    color: var(--attend-info-text);
    font-size: var(--text-label);
    font-weight: var(--weight-strong);
    line-height: var(--leading-label);
    white-space: nowrap;
  }

  .subject-badge .icon {
    inline-size: 14px;
    block-size: 14px;
  }

  /* ------------------------------------------- A subject's Attendance
     The numbers lead the row ("92% · 11 of 12 lectures"), whole on one line. */
  .subject-total {
    flex-basis: 100%;
  }

  .subject-total .course-row__title {
    white-space: nowrap;
  }

  .subject-lectures {
    margin-block-start: var(--space-6);
  }

  .subject-lectures__list {
    margin-block-start: 0;
  }

  .subject-lectures .history-more {
    margin-block-start: var(--space-2);
  }

  /* ------------------------------------------- The staff Subjects list */
  .subjects-table td {
    padding-block: var(--space-3);
  }

  .subjects-table__name {
    color: var(--attend-text-strong);
    font-weight: var(--weight-strong);
  }

  /* ------------------------------------------- A lecture's tools
     "Add files", "Start quiz" (apps/ui/lecture_tools.py) join the row of the
     page's own buttons: beside Attendance on the lecture page, beside Refresh
     in the live page's header (owner answer 16, 2026-11-14). */
  .actions > .lecture-tools {
    display: contents;
  }
}
