/* The top app bar, small variant — Material 3 exactly
   (m3.material.io/components/top-app-bar/specs and /guidelines).
   Material Web has no top app bar, so the kit draws it to the spec.
   Rafa, 2026-10-13: no full-colour bar; the page's state is a subtitle
   under the title (« 6 notes à traiter » in --slow-overdue, « Rien à
   traiter » in --slow-rest, « Relecture… » in on-surface-variant). No state
   icon at the trailing edge, no badge beside the title.

   <header class="top-app-bar">
     <md-icon-button aria-label="Back"><md-icon>arrow_back</md-icon></md-icon-button>
     <div class="title-wrap">
       <h1 class="title">Ma routine</h1>
       <p class="subtitle overdue">6 notes à traiter</p>   (optional; .overdue, .rest, or none)
     </div>
     <div class="actions">…one or two md-icon-button…</div>
   </header>

   .scrolled once the page scrolls; .contextual
   in selection mode. Load after slow-material.css.

   Refresh (Rafa, 2026-10-14, « Ma routine », proposition 1 of « Actualiser
   dans la barre du haut »): one refresh icon button in the bar re-reads
   everything the page depends on; the subtitle says the summary, then the
   time it is up to date. The summary is cut with « … », never the time.
   While a re-read the person asked for runs, the header carries
   aria-busy="true": the button shows a circular indicator instead of its
   icon, and a linear indicator runs along the bar's bottom edge
   (m3.material.io/components/progress-indicators/guidelines › Placement,
   Progress indicators in buttons). The automatic re-reads stay silent.

   <header class="top-app-bar" aria-busy="false">
     …
     <div class="title-wrap">
       <h1 class="title">Email</h1>
       <p class="subtitle overdue"><span class="bilan">2 mails à traiter</span><span class="when"> · à jour à 13:18</span></p>
     </div>
     <div class="actions">
       <md-icon-button class="refresh" aria-label="Actualiser">
         <md-icon>refresh</md-icon>
         <md-circular-progress indeterminate></md-circular-progress>
       </md-icon-button>
     </div>
     <md-linear-progress class="refresh-progress" indeterminate aria-label="Relecture"></md-linear-progress>
   </header>

   While reading: aria-busy="true", the subtitle « Relecture… » without a
   state class; the page ignores a click on .refresh meanwhile. Down (a tool
   the page depends on is disconnected): the subtitle in .overdue,
   « Commission déconnectée · lu à 13:12 », and the page's first block says
   it, with « Se connecter » (page-list.css, .page-health). The refresh
   button may be md-filled-tonal-icon-button when the page has not been read
   yet or its read failed: the one prominent action of the bar
   (app-bars/guidelines › Trailing icon buttons). */
.top-app-bar {
  display: flex;
  align-items: center;
  gap: 4px;
  height: 64px;
  /* The leading glyph falls on the page margin, like the cards' edge:
     md-icon-button is 40 dp with its glyph 8 dp in, so the bar starts at
     margin − 8 (Compose AppBar: button at 4, glyph at 16, title at 56). */
  padding-inline: calc(var(--slow-page-margin, 16px) - 8px);
  box-sizing: border-box;
  background: var(--md-sys-color-surface);
  color: var(--md-sys-color-on-surface);
  transition: background-color 200ms;
  position: relative;
}
.top-app-bar.fixed { position: fixed; top: 0; left: 0; right: 0; z-index: 10; }
.top-app-bar.scrolled { background: var(--md-sys-color-surface-container); }
.top-app-bar.contextual { background: var(--md-sys-color-surface-container-high); }
.top-app-bar .title-wrap { flex: 1; min-width: 0; padding: 0 4px; }
.top-app-bar > .title { flex: 1; padding: 0 4px; }
/* Page margin (m3 breakpoints): 16 dp compact, 24 dp from 600 dp. A page with
   a centred column sets --slow-page-margin to that column's edge. */
:root { --slow-page-margin: 16px; }
@media (min-width: 600px) { :root { --slow-page-margin: 24px; } }
.top-app-bar .title {
  min-width: 0;
  margin: 0;
  font: 400 22px/28px var(--md-ref-typeface-brand);
  letter-spacing: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
/* Subtitle of the small app bar: Label medium (m3.material.io/components/app-bars/guidelines). */
.top-app-bar .subtitle {
  margin: 0;
  font: 500 12px/16px var(--md-ref-typeface-plain);
  letter-spacing: 0.5px;
  color: var(--md-sys-color-on-surface-variant);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
/* The summary is cut, never the time: <span class="bilan"> shrinks with
   « … », <span class="when"> (« · à jour à 13:18 ») keeps its width. */
.top-app-bar .subtitle:not([hidden]):has(> .when) { display: flex; }
/* .bilan never grows (flex: 0 1 auto): the time follows it at once; cut, it
   keeps at most the width of the letter that did not fit. */
.top-app-bar .subtitle > .bilan { flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.top-app-bar .subtitle > .when { flex: none; white-space: pre; }
.top-app-bar .subtitle.rest { color: var(--slow-rest); }
.top-app-bar .subtitle.overdue { color: var(--slow-overdue); }
.top-app-bar .actions { display: flex; align-items: center; gap: 4px; }
.top-app-bar md-icon-button {
  color: inherit;
  --md-icon-button-icon-color: currentColor;
  --md-icon-button-hover-icon-color: currentColor;
  --md-icon-button-focus-icon-color: currentColor;
  --md-icon-button-pressed-icon-color: currentColor;
}
/* Refresh: the circular indicator takes the icon's place in the same
   button, in the icon's colour, without a track
   (progress-indicators/guidelines › Progress indicators in buttons: « change
   the active indicator color to be the same color as the button's icon […]
   and remove the track »); 24 dp, the smallest circular size. */
.top-app-bar .refresh md-circular-progress {
  display: none;
  --md-circular-progress-size: 24px;
  --md-circular-progress-active-indicator-color: currentColor;
}
.top-app-bar[aria-busy="true"] .refresh md-icon { display: none; }
.top-app-bar[aria-busy="true"] .refresh md-circular-progress { display: inline-flex; }
/* One linear indicator along the bar's bottom edge: the whole page is
   loading (progress-indicators/guidelines › Placement: « a single progress
   indicator at the top of a page »). Material's own colours. */
.top-app-bar > .refresh-progress {
  display: none;
  position: absolute;
  inset-inline: 0;
  bottom: 0;
  width: auto;
}
.top-app-bar[aria-busy="true"] > .refresh-progress { display: block; }
@media (prefers-reduced-motion: reduce) { .top-app-bar { transition: none; } }
