/*
 * Tab skeletons (owner, 2026-11-20): what a tapped phone tab shows while its
 * page loads (static/js/nav/tab-skeleton.js; the partials are in
 * templates/components/skeletons/, chosen by apps/ui/tab_skeletons.py).
 *
 * The skeleton takes the place of the page's .content inside main, in the tab
 * page's layout (no top bar, the title row at the top). Each partial mirrors
 * its page at phone width: the same title row, cards where the page has
 * cards, rows of the same heights at the same places (the sizes below are
 * the pages' own: components.css, student.css, subjects.css, board.css), so
 * the page replaces it with hardly a move. Only sk- classes: the pages' own
 * classes would be found by their scripts and by tests reading the HTML.
 *
 * Shapes are filled with the border token, which reads on the page ground
 * and inside a card in both themes; a transparent border outlines them when
 * the system forces its own colours. A gentle opacity pulse, and nothing
 * moves with reduced motion.
 *
 *   .tab-skeleton__header / __head / __title   the header and its title row (_title.html)
 *   .sk-l             a line of text: its line box, the bar in it (::before);
 *                     --small, --label, --chip, --course, --h2, --caps, --msg
 *                     set the line's height; --w15 ... --w100 its width
 *   .sk-list .sk-item a card of rows; --link (60px), --tall (72px of text), --row
 *   .sk-text          the text column of a row
 *   .sk-tile .sk-time .sk-ring .sk-avatar .sk-round .sk-glyph .sk-chip .sk-pill
 *                     an icon tile, a time tile, a ring, a photo, a round
 *                     button, an icon, a status chip, a button
 *   .sk-table .sk-tr .sk-td   a table drawn as cards (components.css .table--cards)
 *   .sk-split         a line with something at each end
 * The generic skeleton's shapes: .sk (--line, --heading, --round, --ring,
 * --chip, --block), .card.sk-card, .sk-stack, .sk-row.
 */

@layer components {
  .tab-skeleton {
    pointer-events: none;
  }

  /* No flow margin (app.css .content__body): each block below says its own. */
  :where(.tab-skeleton .content__body > *) {
    margin-block-start: 0;
  }

  /* ---- The header: components/page_header.html on a tab's own page. */
  .tab-skeleton__header {
    margin-block-end: var(--space-5);
  }

  .tab-skeleton__header--tight {
    margin-block-end: var(--space-3);
  }

  .tab-skeleton__header--after {
    margin-block-start: var(--space-4);
  }

  .tab-skeleton__head {
    display: flex;
    align-items: center;
    min-block-size: var(--topbar-h);
  }

  .tab-skeleton__title {
    flex: 0 1 auto;
    min-width: 0;
    margin: 0;
    overflow-wrap: break-word;
    color: var(--attend-text-strong);
    font-family: var(--font-display);
    font-optical-sizing: auto;
    font-size: var(--text-h1);
    font-weight: var(--weight-h1);
    letter-spacing: var(--tracking-h1);
    line-height: var(--leading-h1);
  }

  .tab-skeleton__product {
    font-weight: var(--weight-display);
    letter-spacing: -0.03em;
  }

  .tab-skeleton__refresh,
  .tab-skeleton__action {
    display: grid;
    flex: none;
    place-items: center;
    inline-size: var(--touch);
    block-size: var(--touch);
    color: var(--attend-brand-text);
  }

  .tab-skeleton__refresh {
    block-size: 48px;
    margin-inline-start: var(--space-2);
  }

  .tab-skeleton__action .icon {
    inline-size: 24px;
    block-size: 24px;
  }

  .tab-skeleton__end {
    display: flex;
    align-items: center;
    gap: var(--space-1);
    margin-inline: auto calc(-1 * var(--space-2)); /* the bell's circle meets the gutter */
  }

  /* The page's own sentence (components.css .page-header__sub), its text
     transparent on a bar per line, so the lines break where the page's do. */
  .tab-skeleton__sub {
    max-inline-size: var(--measure);
    margin: var(--space-1) 0 0;
    font-size: var(--text-small);
  }

  .tab-skeleton__sub > span {
    border-radius: var(--r-xs);
    background: var(--attend-border);
    color: transparent;
    -webkit-box-decoration-break: clone;
    box-decoration-break: clone;
  }

  .tab-skeleton__header .tab-skeleton__link {
    --sk-lh: var(--touch);
    margin-block-start: var(--space-3);
  }

  /* ---- Lines: the line box of the text they stand for, the bar inside. */
  .sk-l {
    --sk-lh: var(--leading-body);
    --sk-bar: var(--space-3);
    display: flex;
    flex: none;
    align-items: center;
    inline-size: 100%;
    block-size: var(--sk-lh);
  }

  .sk-l::before {
    content: "";
    inline-size: 100%;
    block-size: var(--sk-bar);
    border: 1px solid transparent;
    border-radius: var(--r-xs);
    background: var(--attend-border);
  }

  .sk-l--small {
    --sk-lh: var(--leading-small);
    --sk-bar: calc(var(--space-2) + var(--space-05));
  }

  .sk-l--line {
    --sk-lh: var(--leading-body); /* small text on a body-height line */
  }

  .sk-l--label {
    --sk-lh: var(--leading-label);
    --sk-bar: var(--space-2);
  }

  .sk-l--chip {
    --sk-lh: var(--space-8);
    --sk-bar: var(--space-5);
  }

  .sk-l--chip::before {
    border-radius: var(--r-pill);
  }

  .sk-l--course {
    --sk-lh: var(--leading-display);
    --sk-bar: var(--space-6);
  }

  .sk-l--h2 {
    --sk-lh: var(--leading-h2);
    --sk-bar: var(--space-4);
  }

  .sk-l--caps {
    --sk-lh: var(--leading-h2);
    --sk-bar: var(--space-2);
  }

  .sk-l--msg {
    --sk-lh: calc(var(--text-body) * 1.3);
    --sk-bar: var(--space-3);
  }

  .sk-l--text {
    --sk-lh: calc(var(--text-body) * 1.5); /* board.css .msg__text */
  }

  .sk-l--after {
    margin-block-start: var(--space-05);
  }

  .sk-l--w15 { inline-size: 15%; }
  .sk-l--w25 { inline-size: 25%; }
  .sk-l--w40 { inline-size: 40%; }
  .sk-l--w55 { inline-size: 55%; }
  .sk-l--w70 { inline-size: 70%; }
  .sk-l--w85 { inline-size: 85%; }
  .sk-l--w100 { inline-size: 100%; }

  /* ---- Shapes. */
  .sk-tile,
  .sk-time,
  .sk-ring,
  .sk-avatar,
  .sk-round,
  .sk-glyph,
  .sk-chip,
  .sk-pill,
  .sk-daychip {
    display: block;
    flex: none;
    border: 1px solid transparent;
    background: var(--attend-border);
  }

  .sk-tile {
    inline-size: 36px;
    block-size: 36px;
    border-radius: var(--r-sm);
  }

  .sk-time {
    inline-size: 48px;
    block-size: var(--touch);
    border-radius: var(--r-sm);
  }

  :lang(ar) .sk-time {
    inline-size: 4.5rem; /* student.css: the Arabic time tile */
  }

  .sk-ring {
    inline-size: 48px;
    block-size: 48px;
    border: var(--space-1) solid var(--attend-border);
    border-radius: 50%;
    background: none;
  }

  .sk-avatar {
    inline-size: var(--space-14);
    block-size: var(--space-14);
    border-radius: 50%;
  }

  .sk-round {
    inline-size: 48px;
    block-size: 48px;
    border-radius: 50%;
  }

  .sk-glyph {
    inline-size: var(--space-5);
    block-size: var(--space-5);
    border-radius: var(--r-xs);
  }

  .sk-chip {
    inline-size: 30%;
    block-size: 28px;
    border-radius: var(--r-pill);
  }

  .sk-chip--wide {
    inline-size: 60%;
  }

  .sk-pill {
    inline-size: 33%;
    block-size: 48px;
    border-radius: var(--r-pill);
  }

  .sk-pill--primary {
    inline-size: 56%;
    block-size: var(--space-14);
  }

  /* A plain button (lecturer Today's Cancel): its words on a 48px line, on a line of their own. */
  .sk-break {
    flex-basis: 100%;
  }

  .sk-l--button {
    --sk-lh: 48px;
  }

  /* ---- Cards of rows (.link-rows, .course-list, .agenda-list, .row-list). */
  .sk-list {
    display: flex;
    flex-direction: column;
    border: 1px solid var(--attend-border);
    border-radius: var(--r-lg);
    background: var(--attend-surface);
    box-shadow: var(--attend-shadow-card);
  }

  .sk-list > * + * {
    border-block-start: 1px solid var(--attend-border);
  }

  .sk-item {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-4);
  }

  .sk-item--link {
    min-block-size: 60px;
  }

  .sk-item--row {
    flex-wrap: wrap;
    justify-content: space-between;
  }

  .sk-text {
    display: flex;
    flex: 1 1 0;
    flex-direction: column;
    min-width: 0;
  }

  .sk-text--row {
    flex: 0 1 40%;
  }

  .sk-split {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
  }

  .sk-label {
    margin-block: var(--space-6) var(--space-2);
  }

  .sk-label--wide {
    margin-block-end: var(--space-3);
  }

  .sk-section-head {
    padding-block-end: var(--space-3);
    border-block-end: 1px solid var(--attend-border);
  }

  .sk-section-head--next {
    margin-block-start: var(--space-8);
  }

  /* ---- Student Today: "Recent attendance" under the day's rows. */
  .sk-recent {
    min-block-size: var(--touch);
    margin-block-start: var(--space-8);
  }

  /* ---- Subjects: the shortcuts card (subjects.css .subject-links). */
  .sk-list--links {
    margin-block-end: var(--space-5);
  }

  /* ---- Board: the channel (board.css .board-feed, .daychip, .msg). */
  .sk-feed {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
  }

  .sk-daychip {
    align-self: center;
    inline-size: 64px;
    block-size: calc(var(--leading-body) + 6px); /* a line, 2px padding and the border above and below */
    margin-block-start: var(--space-2);
    border-color: var(--attend-border);
    border-radius: var(--r-pill);
    background: var(--attend-surface);
  }

  .sk-msg {
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
    inline-size: min(90%, 34rem);
    padding: var(--space-2) var(--space-3) 6px;
    border: 1px solid var(--attend-border);
    border-radius: var(--r-sm);
    border-end-start-radius: var(--r-xs);
    background: var(--attend-surface);
  }

  /* ---- Timetable: groups, sections, next class, week (components.css, subjects.css, student.css). */
  .sk-groups {
    margin-block-end: var(--space-4); /* components.css .sheet-groups */
  }

  .sk-tabs {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: 1fr;
    border-block-end: 1px solid var(--attend-border);
  }

  .sk-tab {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--space-1);
    min-block-size: var(--space-14);
  }

  .sk-tab > .sk-l {
    inline-size: 25%;
  }

  .sk-next {
    margin-block-start: var(--space-3);
  }

  .sk-week {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    margin-block-start: var(--space-4);
  }

  .sk-week__label {
    display: flex;
    flex-direction: column;
    align-items: center;
    inline-size: 34%;
  }

  .sk-day {
    margin-block: var(--space-4) var(--space-2);
  }

  .sk-item--tall .sk-text {
    min-block-size: var(--space-18);
    justify-content: center;
  }

  /* ---- Account (student.css .account--rows, .account-who). */
  .sk-account {
    display: grid;
    gap: var(--space-5);
  }

  .sk-who {
    display: flex;
    align-items: center;
    gap: var(--space-3);
  }

  /* The groups chip (student.css .account-who__groups): its line and padding. */
  .sk-l--groups {
    --sk-lh: calc(var(--leading-body) + var(--space-1));
  }

  /* ---- Tables as cards (components.css .table--cards). */
  .sk-filters {
    display: flex;
    align-items: center;
    gap: var(--space-2);
  }

  /* The plain filter: its words, inside a button's padding (components.css .btn). */
  .sk-filters__plain {
    inline-size: 33%;
    padding-inline: var(--space-6);
  }

  .sk-filters + .sk-table {
    margin-block-start: var(--space-4);
  }

  .sk-table {
    border: 1px solid var(--attend-card-edge);
    border-radius: var(--r-md);
    background: var(--attend-surface);
  }

  .sk-tr {
    padding: var(--space-3) var(--space-4);
  }

  .sk-tr + .sk-tr {
    border-block-start: 1px solid var(--attend-border);
  }

  .sk-td {
    display: flex;
    align-items: center;
    padding-block: var(--space-1);
  }

  .sk-td--chip {
    min-block-size: 36px;
  }

  .sk-tr--roomy > .sk-td {
    padding-block: var(--space-3);
  }

  .sk-td--name {
    flex-direction: column;
    align-items: stretch;
  }

  /* ---- The generic skeleton's shapes (generic.html). */
  .sk {
    display: block;
    flex: none;
    inline-size: 100%;
    border: 1px solid transparent;
    border-radius: var(--r-xs);
    background: var(--attend-border);
  }

  .sk--line {
    block-size: var(--space-3);
  }

  .sk--heading {
    block-size: var(--space-5);
    inline-size: 50%;
  }

  .sk--short {
    inline-size: 40%;
  }

  .sk--mid {
    inline-size: 65%;
  }

  .sk--round,
  .sk--ring {
    inline-size: var(--touch);
    block-size: var(--touch);
    border-radius: var(--r-pill);
  }

  .sk--ring {
    inline-size: var(--space-14);
    block-size: var(--space-14);
  }

  .sk--chip {
    inline-size: var(--space-18);
    block-size: var(--space-8);
    border-radius: var(--r-pill);
  }

  .sk--block {
    block-size: var(--space-18);
    border-radius: var(--r-sm);
  }

  .sk-stack {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
  }

  .sk-row {
    display: flex;
    align-items: center;
    gap: var(--space-3);
  }

  .sk-row > .sk-stack {
    flex: 1 1 0;
    min-inline-size: 0;
  }

  .card.sk-card {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
  }

  @media (prefers-reduced-motion: no-preference) {
    .sk,
    .sk-l,
    .tab-skeleton__sub > span,
    .sk-tile,
    .sk-time,
    .sk-ring,
    .sk-avatar,
    .sk-round,
    .sk-glyph,
    .sk-chip,
    .sk-pill {
      animation: attend-skeleton-pulse 1.2s ease-in-out infinite alternate;
    }
  }

  @keyframes attend-skeleton-pulse {
    to {
      opacity: 0.55;
    }
  }
}
