/* Simple CARE's case page on a phone (board 11 of docs/care/README.md). The first half is for a page too narrow for two columns, measured on the page itself as 64a does: cards a
   thumb can use, in the page's own order. The second is for a narrow window: the bar of Add a note, Call and Email, pinned to the foot. Nothing here reaches a wide page. Numbered 64x so it follows the parts' own rules (64w is the close page). */

/* The microphone before "Dictate it", at the size of the words. */
.care-simple-row__icon {
  --icon-size: 1.125rem;
}

/* ── Cards below 56rem of the page ─────────────────────────────────────────
   The page keeps its source order on a phone (the side column follows the main one), so what is seen in order is what is read and tabbed to in order (WCAG 1.3.2, 2.4.3): no rule here moves a part. */
@container care-simple not (min-width: 56rem) {
  /* Why the student is here, in one box. */
  .care-simple-why {
    padding: var(--space-3);
    border: 1px solid var(--rule);
    border-radius: var(--radius-lg);
    background: var(--surface-raised);
  }

  /* The sender's words are the first thing read, so they take the page's own size and not the large one. */
  .care-simple-why__quote {
    font-size: var(--text-base);
  }

  /* The next step is the one thing to do: a strong border sets it apart from the plan below it. */
  .care-simple .panel.person-panel.care-simple-next {
    border: 2px solid var(--accent);
  }

  /* A step's buttons: on the next step the first, filled, takes the row, and the rest sit two to a row; on a line of the plan they all sit two to a row; a lone one fills its row. */
  .care-simple-row__actions {
    display: flex;
    flex-wrap: wrap;
    align-items: stretch;
    gap: var(--space-2);
  }

  .care-simple-row__actions > * {
    flex: 1 1 calc(50% - var(--space-1));
    min-inline-size: 0;
  }

  .care-simple-row--large .care-simple-row__actions > .care-simple-row__lead,
  .care-simple-row__actions > .care-simple-row__change {
    flex-basis: 100%;
  }

  .care-simple-row__no-show {
    display: flex;
  }

  .care-simple-row__no-show > .btn {
    flex: 1;
  }

  .care-simple-row__change > summary {
    display: flex;
  }

  .care-simple-row--large .care-simple-row__actions .btn,
  .care-simple-row--large .care-simple-row__actions summary {
    min-block-size: 3rem;
  }

  /* "Also on the plan" as rows to tap: the whole row does what its first button does, and the other buttons stay above it. */
  .care-simple-plan__item {
    position: relative;
  }

  .care-simple-plan__item .care-simple-row__lead::after {
    content: "";
    position: absolute;
    inset: 0;
  }

  .care-simple-plan__item .care-simple-row__actions > :not(.care-simple-row__lead) {
    position: relative;
    z-index: 1;
  }

  .care-simple-plan__item:has(.care-simple-row__lead:active) {
    background: color-mix(in srgb, var(--fg1) 6%, transparent);
  }

  .care-simple-plan__add > .btn {
    flex: 1 1 100%;
  }
}

/* ── The bar, below 48rem of the window ──────────────────────────────────── */
.care-simple-bar {
  display: none;
}

@media (max-width: 47.99rem) {
  /* The bar's height: a button of 3rem, the air over and under it and its hairline. */
  :root {
    --care-bar-h: calc(3rem + 2 * var(--space-2) + 1px);
  }

  .care-simple-bar {
    display: flex;
    position: fixed;
    inset-inline: 0;
    /* Above the shell's tab bar: the room it reserves is its height and its float, and a hand's breadth more that the bar does not need. In a browser there is no shell, and the bar sits on the edge. */
    inset-block-end: calc(var(--native-bar-room, var(--space-4)) - var(--space-4));
    z-index: 30;
    gap: var(--space-2);
    padding-block: var(--space-2) calc(var(--space-2) + var(--bar-safe, var(--safe-bottom)));
    padding-inline: calc(var(--page-gutter) + max(var(--safe-left), var(--safe-right)));
    border-block-start: 1px solid var(--rule);
    background: var(--surface-raised);
  }

  /* The shell's tab bar already clears the home indicator, and the bar sits above it. */
  [data-native] .care-simple-bar {
    --bar-safe: 0px;
  }

  /* Each takes the room its words need and shares out the rest, so a short word like Email is never broken at 320px. */
  .care-simple-bar > .btn {
    flex: 1 1 auto;
    min-inline-size: 0;
    min-block-size: 3rem;
    padding-inline: var(--space-2);
  }

  .care-simple-bar > .care-simple-bar__note {
    flex-grow: 2;
  }

  /* Room at the foot of the page for the bar (and a line more, for a label that wraps at a large text size), and for a focused control to scroll clear of it (WCAG 2.4.11). The shell has reserved the tab bar's own room already. */
  .care-simple--bar {
    padding-block-end: calc(var(--care-bar-h) + var(--space-5) + var(--bar-safe, var(--safe-bottom)));
  }

  [data-native] .care-simple--bar {
    --bar-safe: 0px;
  }

  .care-simple--bar :is(a, button, summary, input, select, textarea, [contenteditable]) {
    scroll-margin-block-end: calc(var(--care-bar-h) + var(--space-3) + var(--native-bar-room, var(--safe-bottom)));
  }

  /* The note row is the bar's Add a note (the sheet it opens chooses the kind). */
  .care-simple--bar .care-composer {
    display: none;
  }

  /* The assistant's round button floats over the tab bar's trailing end in a shell, which is where the bar's last button is: it rises above the bar. */
  [data-native]:has(.care-simple-bar) .assistant-fab {
    inset-block-end: calc(var(--native-tabs-h) + var(--native-tabs-offset) + var(--care-bar-h) + var(--space-3));
  }
}

@media print {
  .care-simple-bar {
    display: none;
  }
}
