/*
 * The shared frame for every Assist Network app (look E, Head record
 * 2026-11-21-home-and-navigation-look): the header with the app's name at the top left, and the
 * house button and the person's initial at the top right (house moved right, Justin 2026-11-22),
 * the work band, the menu that follows the screen (a bottom bar on phones, a side menu on wide
 * screens), and the layout containers every page is built from.
 * Needs tokens.css first. Widths and text are rem, so the whole frame grows with the person's own
 * text size; only hairlines and radii are px. Gaps come from containers (.an-stack, .an-cluster),
 * never from margins on single elements.
 */

/* ---- Containers -------------------------------------------------------------------------- */

.an-container {
  inline-size: 100%;
  max-inline-size: var(--an-container-content);
  margin-inline: auto;
  padding-inline: var(--an-space-4);
}
.an-container-narrow {
  max-inline-size: var(--an-container-narrow);
}
.an-container-wide {
  max-inline-size: var(--an-container-wide);
}

/* A column with even gaps. --an-gap changes the step for one stack. */
.an-stack {
  display: flex;
  flex-direction: column;
  gap: var(--an-gap, var(--an-space-4));
}
.an-stack-tight {
  --an-gap: var(--an-space-2);
}
.an-stack-loose {
  --an-gap: var(--an-space-8);
}

/* A row that wraps, with even gaps. */
.an-cluster {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--an-gap, var(--an-space-3));
}

/* Reading text never runs longer than the measure. */
.an-prose {
  max-inline-size: var(--an-measure);
  line-height: var(--an-leading-body);
}

/* ---- Type ---------------------------------------------------------------------------------- */

.an-text {
  font-family: var(--an-font);
  font-size: var(--an-size-body);
  line-height: var(--an-leading-body);
  color: var(--an-color-ink);
}
.an-small {
  font-size: var(--an-size-small);
  line-height: var(--an-leading-body);
  color: var(--an-color-ink-2);
}
.an-section-title {
  font-size: var(--an-size-section);
  font-weight: var(--an-font-weight-bold);
  line-height: var(--an-leading-heading);
  margin: 0;
}
.an-title {
  font-size: var(--an-size-title);
  font-weight: var(--an-font-weight-bold);
  line-height: var(--an-leading-heading);
  margin: 0;
}

/* ---- The frame ----------------------------------------------------------------------------- */

.an-frame {
  min-block-size: 100dvh;
  display: grid;
  grid-template-rows: auto auto 1fr auto;
  grid-template-areas: "header" "band" "main" "menu";
  background: var(--an-color-ground);
  color: var(--an-color-ink);
  font-family: var(--an-font);
  font-size: var(--an-size-body);
  line-height: var(--an-leading-body);
}

.an-header {
  grid-area: header;
  position: sticky;
  inset-block-start: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: var(--an-space-2);
  /* Slim: the touch targets plus a small margin. Both ends sit on the page's own gutter. */
  min-block-size: calc(var(--an-touch) + var(--an-space-1) * 2);
  padding-inline: var(--an-space-4);
  background: var(--an-theme-header);
  color: var(--an-theme-on-header);
  border-block-end: var(--an-border-hairline) solid var(--an-color-hairline);
}

/* The house button: always Assist Network Home, labelled so for screen readers. */
.an-house,
.an-initial {
  display: inline-grid;
  place-items: center;
  inline-size: var(--an-touch);
  block-size: var(--an-touch);
  flex: none;
  padding: 0;
  border: 0;
  border-radius: var(--an-radius-field);
  background: transparent;
  color: inherit;
  cursor: pointer;
  text-decoration: none;
}
/* At the bar's right end the initial sits on the gutter; its touch target reaches inward. */
.an-initial {
  justify-items: end;
}
/* Links and buttons in the header always take the header's readable text colour, even when an
   app colours its own links or a tap leaves :hover stuck on a phone. */
.an-header a,
.an-header a:visited,
.an-header a:hover,
.an-header button,
.an-header button:hover {
  color: inherit;
}
.an-house svg {
  inline-size: 1.5rem;
  block-size: 1.5rem;
}

/* The app's name and its mark: a small tile in the app's own colour, decorative. */
.an-app-name {
  display: inline-flex;
  align-items: center;
  gap: var(--an-space-2);
  min-block-size: var(--an-touch);
  font-size: var(--an-size-section);
  font-weight: var(--an-font-weight-bold);
  line-height: var(--an-leading-tight);
  color: inherit;
  text-decoration: none;
}
.an-mark {
  display: inline-grid;
  place-items: center;
  inline-size: 1.75rem;
  block-size: 1.75rem;
  border-radius: 0.5rem;
  /* The person's own colour when they picked one (--an-theme-mark, for them only), else the app's
     own mark colour. The letter keeps the app distinct either way. */
  background: var(--an-theme-mark, var(--an-mark, var(--an-color-ink)));
  color: var(--an-theme-on-mark, #ffffff);
  font-size: var(--an-size-small);
  font-weight: var(--an-font-weight-bold);
  /* A white ring keeps the mark apart from a themed header. */
  box-shadow: 0 0 0 2px #ffffff;
}

/* The network's mark, for the name "Assist Network" in a header: drawn as a mask in the text's own
   colour, decorative. The address is brand.js's markMaskUrl(); a test keeps them the same. */
.an-network-mark {
  display: inline-block;
  flex: none;
  inline-size: 1.75rem;
  block-size: 1.75rem;
  background: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Cpath fill-rule='evenodd' d='M93.9 57.2 94.0 56.4 93.8 55.5 93.4 54.6 92.8 53.9 89.0 51.4 84.5 48.9 81.0 47.3 77.4 46.1 74.1 45.5 71.1 45.4 68.4 45.6 65.8 46.1 63.3 46.9 60.3 48.0 55.5 50.4 45.9 56.2 41.6 58.5 37.4 60.5 35.3 61.2 32.8 62.0 30.2 62.4 27.7 62.6 25.5 62.6 22.6 62.2 20.6 61.8 18.2 61.1 15.5 60.0 12.3 58.6 11.2 58.3 9.7 58.5 8.8 59.0 8.2 59.5 7.8 60.1 7.4 61.1 7.3 62.1 7.4 62.8 9.1 67.5 11.0 71.5 13.3 75.2 15.6 78.2 18.5 81.5 21.8 84.4 24.8 86.7 28.1 88.7 32.0 90.7 35.5 92.1 38.6 93.0 42.9 93.9 47.3 94.4 51.1 94.5 54.9 94.2 58.7 93.7 62.4 92.7 66.0 91.5 69.5 90.0 72.9 88.2 76.1 86.1 79.1 83.7 81.9 81.1 84.4 78.2 86.7 75.2 88.7 71.9 90.4 68.6 91.9 65.0 93.0 61.4 Z M87.5 41.3 88.4 41.6 89.4 41.7 90.3 41.5 91.3 41.0 92.0 40.3 92.5 39.4 92.7 38.4 92.7 37.4 91.1 33.0 89.0 28.5 86.7 24.8 83.7 20.9 81.1 18.1 78.2 15.6 75.2 13.3 71.9 11.3 68.1 9.3 64.5 7.9 61.4 7.0 57.1 6.1 53.8 5.7 50.6 5.5 47.3 5.6 43.5 6.0 40.3 6.6 36.6 7.6 33.5 8.7 30.5 10.0 27.1 11.8 24.8 13.3 21.8 15.6 19.3 17.8 16.7 20.5 14.6 23.0 12.7 25.7 10.8 29.0 8.7 33.5 7.7 36.0 7.0 38.6 6.0 43.1 6.1 44.2 6.5 45.1 7.0 45.9 7.9 46.6 12.0 49.2 15.5 51.1 18.0 52.3 20.5 53.2 22.6 53.9 24.8 54.3 27.8 54.6 31.0 54.5 34.2 53.9 37.6 52.8 40.8 51.5 43.8 49.9 54.9 43.4 59.3 41.0 63.9 39.0 67.9 37.9 70.2 37.5 72.8 37.4 75.2 37.5 77.4 37.8 80.1 38.4 82.4 39.1 Z'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Cpath fill-rule='evenodd' d='M93.9 57.2 94.0 56.4 93.8 55.5 93.4 54.6 92.8 53.9 89.0 51.4 84.5 48.9 81.0 47.3 77.4 46.1 74.1 45.5 71.1 45.4 68.4 45.6 65.8 46.1 63.3 46.9 60.3 48.0 55.5 50.4 45.9 56.2 41.6 58.5 37.4 60.5 35.3 61.2 32.8 62.0 30.2 62.4 27.7 62.6 25.5 62.6 22.6 62.2 20.6 61.8 18.2 61.1 15.5 60.0 12.3 58.6 11.2 58.3 9.7 58.5 8.8 59.0 8.2 59.5 7.8 60.1 7.4 61.1 7.3 62.1 7.4 62.8 9.1 67.5 11.0 71.5 13.3 75.2 15.6 78.2 18.5 81.5 21.8 84.4 24.8 86.7 28.1 88.7 32.0 90.7 35.5 92.1 38.6 93.0 42.9 93.9 47.3 94.4 51.1 94.5 54.9 94.2 58.7 93.7 62.4 92.7 66.0 91.5 69.5 90.0 72.9 88.2 76.1 86.1 79.1 83.7 81.9 81.1 84.4 78.2 86.7 75.2 88.7 71.9 90.4 68.6 91.9 65.0 93.0 61.4 Z M87.5 41.3 88.4 41.6 89.4 41.7 90.3 41.5 91.3 41.0 92.0 40.3 92.5 39.4 92.7 38.4 92.7 37.4 91.1 33.0 89.0 28.5 86.7 24.8 83.7 20.9 81.1 18.1 78.2 15.6 75.2 13.3 71.9 11.3 68.1 9.3 64.5 7.9 61.4 7.0 57.1 6.1 53.8 5.7 50.6 5.5 47.3 5.6 43.5 6.0 40.3 6.6 36.6 7.6 33.5 8.7 30.5 10.0 27.1 11.8 24.8 13.3 21.8 15.6 19.3 17.8 16.7 20.5 14.6 23.0 12.7 25.7 10.8 29.0 8.7 33.5 7.7 36.0 7.0 38.6 6.0 43.1 6.1 44.2 6.5 45.1 7.0 45.9 7.9 46.6 12.0 49.2 15.5 51.1 18.0 52.3 20.5 53.2 22.6 53.9 24.8 54.3 27.8 54.6 31.0 54.5 34.2 53.9 37.6 52.8 40.8 51.5 43.8 49.9 54.9 43.4 59.3 41.0 63.9 39.0 67.9 37.9 70.2 37.5 72.8 37.4 75.2 37.5 77.4 37.8 80.1 38.4 82.4 39.1 Z'/%3E%3C/svg%3E") center / contain no-repeat;
}

/* The opening: the mark and the name play once while an app first loads (brand.js openingHtml(),
   which carries its own sizes). It sits upper middle, not dead centre and not at the top (Justin,
   2026-11-22), a little higher than a third (Justin, 2026-11-22, picking "Name 30% bigger, logo 2%
   higher": "The last one"): the space above it is four ninths of the space below, so the mark's
   centre lands about 31.5% of the way down a phone (was 33.5%). */
.an-opening {
  display: grid;
  grid-template-rows: 4fr auto 9fr;
  justify-items: center;
  min-block-size: 100dvh;
  color: var(--an-color-ink);
}
.an-opening > * {
  grid-row: 2;
}

/* The opening as a cover over the first screen, which loads beneath it unseen; when that screen is
   ready the cover fades away over 0.24 s, so the logo hands over to a finished page and never to a
   half-loaded one (Justin, 2026-11-22: "It loads for a sec in a strange place"). */
.an-opening-cover {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: var(--an-color-ground);
  transition: opacity var(--an-motion-move) var(--an-ease-glide);
}
.an-opening-cover.an-opening-leaving {
  opacity: 0;
  pointer-events: none;
}
@media (prefers-reduced-motion: reduce) {
  .an-opening-cover {
    transition: none;
  }
}

/* Waiting inside an app (brand.js waitingHtml()): the breathing mark in the content area, upper
   middle like the opening, on the page's own ground. */
.an-waiting {
  display: grid;
  grid-template-rows: 4fr auto 9fr;
  justify-items: center;
  min-block-size: 60dvh;
  color: var(--an-color-ink);
}
.an-waiting > * {
  grid-row: 2;
}

/* The right end: the house, then the initial, far enough apart that one isn't tapped for the
   other. */
.an-header-end {
  margin-inline-start: auto;
  display: flex;
  align-items: center;
  gap: var(--an-space-2);
}

/* The person's initial: in their own colour when they picked one, ringed in its text colour so it
   stays apart from a header of the same colour; otherwise ink on white, ringed in ink. */
.an-initial-face {
  display: inline-grid;
  place-items: center;
  inline-size: 2rem;
  block-size: 2rem;
  border-radius: var(--an-radius-round);
  background: var(--an-theme-mark, #ffffff);
  color: var(--an-theme-on-mark, #0a0a0a);
  box-shadow: 0 0 0 1.5px var(--an-theme-on-mark, #0a0a0a);
  font-size: var(--an-size-small);
  font-weight: var(--an-font-weight-bold);
  line-height: 1;
}

.an-house:focus-visible,
.an-initial:focus-visible,
.an-app-name:focus-visible,
.an-menu-item:focus-visible {
  outline: var(--an-border-focus) solid var(--an-color-focus);
  outline-offset: 2px;
  box-shadow: 0 0 0 calc(var(--an-border-focus) + 2px) #ffffff;
}

/* The work band: under the header on every work screen, in the business's colour (set by the
 * business, checked by theme.js), read first by screen readers. */
.an-band {
  grid-area: band;
  padding: var(--an-space-2) var(--an-space-4);
  background: var(--an-band, var(--an-color-ink));
  color: #ffffff;
  font-size: var(--an-size-small);
  font-weight: var(--an-font-weight-medium);
  line-height: var(--an-leading-heading);
}

.an-main {
  grid-area: main;
  min-inline-size: 0;
  padding-block: var(--an-space-6) var(--an-space-12);
}

/* ---- The menu: a bottom bar on phones -------------------------------------------------------- */

.an-menu {
  grid-area: menu;
  position: sticky;
  inset-block-end: 0;
  z-index: 10;
  display: flex;
  background: var(--an-color-surface);
  border-block-start: var(--an-border-hairline) solid var(--an-color-hairline);
  padding-block-end: env(safe-area-inset-bottom, 0);
}
.an-menu-item {
  position: relative;
  flex: 1 1 0;
  min-inline-size: 0;
  min-block-size: calc(var(--an-touch) + var(--an-space-4));
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--an-space-1);
  padding: var(--an-space-2) var(--an-space-1);
  color: var(--an-color-ink-2);
  font-size: var(--an-size-small);
  line-height: var(--an-leading-tight);
  text-decoration: none;
  text-align: center;
}
.an-menu-item svg {
  inline-size: 1.5rem;
  block-size: 1.5rem;
  flex: none;
}
.an-menu-item[aria-current="page"] {
  color: var(--an-color-ink);
  font-weight: var(--an-font-weight-bold);
}
/* The selected-tab bar: the theme's second surface (3:1 on the menu's ground). */
.an-menu-item[aria-current="page"]::before {
  content: "";
  position: absolute;
  inset-block-start: 0;
  inset-inline: 20%;
  block-size: 3px;
  border-radius: 0 0 3px 3px;
  background: var(--an-theme-bar);
}

/* ---- Wide screens: a side menu --------------------------------------------------------------- */

@media (min-width: 64rem) {
  .an-frame {
    grid-template-columns: var(--an-container-side-menu) 1fr;
    grid-template-rows: auto auto 1fr;
    grid-template-areas: "header header" "menu band" "menu main";
  }
  .an-header {
    padding-inline: var(--an-space-4);
  }
  .an-menu {
    position: sticky;
    inset-block-start: calc(var(--an-touch) + var(--an-space-4));
    align-self: start;
    flex-direction: column;
    gap: var(--an-space-1);
    padding: var(--an-space-4) var(--an-space-3);
    border-block-start: 0;
    border-inline-end: var(--an-border-hairline) solid var(--an-color-hairline);
    background: transparent;
    min-block-size: calc(100dvh - var(--an-touch) - var(--an-space-4));
  }
  .an-menu-item {
    flex: none;
    flex-direction: row;
    justify-content: flex-start;
    gap: var(--an-space-3);
    min-block-size: var(--an-touch);
    padding: var(--an-space-2) var(--an-space-3);
    border-radius: var(--an-radius-field);
    font-size: var(--an-size-body);
    text-align: start;
  }
  .an-menu-item[aria-current="page"] {
    background: var(--an-color-surface);
  }
  .an-menu-item[aria-current="page"]::before {
    inset-block: 20%;
    inset-inline: 0 auto;
    inline-size: 3px;
    block-size: auto;
    border-radius: 0 3px 3px 0;
  }
  .an-main {
    padding-block-start: var(--an-space-8);
  }
}

/* The skip link: the first thing Tab reaches, shown only while it has focus. */
.an-skip {
  position: absolute;
  inset-inline-start: var(--an-space-2);
  inset-block-start: var(--an-space-2);
  z-index: 20;
  padding: var(--an-space-2) var(--an-space-4);
  background: var(--an-color-ink);
  color: var(--an-color-surface);
  border-radius: var(--an-radius-field);
  transform: translateY(-200%);
}
.an-skip:focus {
  transform: none;
}

@media (prefers-reduced-motion: no-preference) {
  .an-skip {
    transition: transform var(--an-motion-quick) var(--an-ease-glide);
  }
}

/* Motion: settle (Justin, 2026-11-23: "I think the settling should just be the way it works as
   opposed to a quick version"; was snap and settle, 2026-11-22; tokens.json "motion"). Everything
   eases into its place and stops there: nothing passes its spot, bounces or snaps. Every app uses
   these four and nothing else.
   1. Tap: a press sinks at once (80 ms, glide, which shows on the first frame) and eases back to
      full size when let go (200 ms, settle). .an-press for buttons and small controls,
      .an-press-wide for full-width rows.
   2. Arrive: a screen, panel or menu comes in with a short rise and fade (280 ms, settle).
      .an-arrive. Leaving is faster (160 ms) and only fades: .an-leave.
   3. Confirm: a done mark or saved line grows from 90% into place (360 ms, settle). .an-confirm.
   4. The opening and waiting mark: brand.js.
   Under reduced motion every duration is 0 ms and nothing moves or scales (tokens.css). */
.an-press,
.an-press-wide,
.an-house,
.an-initial,
.an-menu-item {
  transition: transform var(--an-motion-release) var(--an-ease-settle);
  -webkit-tap-highlight-color: transparent;
}
.an-press:active:not(:disabled),
.an-house:active,
.an-initial:active,
.an-menu-item:active {
  transform: scale(var(--an-motion-press-scale));
  transition-duration: var(--an-motion-press);
  transition-timing-function: var(--an-ease-glide);
}
.an-press-wide:active:not(:disabled) {
  transform: scale(var(--an-motion-press-scale-wide));
  transition-duration: var(--an-motion-press);
  transition-timing-function: var(--an-ease-glide);
}
.an-arrive {
  animation:
    an-arrive-move var(--an-motion-move) var(--an-ease-settle) backwards,
    an-arrive-fade var(--an-motion-move) var(--an-ease-glide) backwards;
}
@keyframes an-arrive-move {
  from {
    transform: translateY(var(--an-motion-arrive-rise));
  }
}
@keyframes an-arrive-fade {
  from {
    opacity: 0;
  }
}
.an-leave {
  animation: an-leave var(--an-motion-exit) var(--an-ease-exit) forwards;
}
@keyframes an-leave {
  to {
    opacity: 0;
  }
}
.an-confirm {
  animation:
    an-confirm-move var(--an-motion-confirm) var(--an-ease-settle) backwards,
    an-arrive-fade var(--an-motion-quick) var(--an-ease-glide) backwards;
}
@keyframes an-confirm-move {
  from {
    transform: scale(var(--an-motion-confirm-from));
  }
}
