/* The arch's components, drawn in the theme's custom properties (theme.css) and the house's face.
   The metrics are one set with render-flutter's (screen.dart), held to it by the suite: text in
   lines of 1.25, a control at least 48px high, a button padded space by twice the space, a field
   space by radius, a field's label a caption half a space above it. */

@font-face {
  font-family: "Roboto";
  src: url("/dom/roboto.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

html,
body {
  margin: 0;
  background: var(--az-background);
}

az-screen {
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
  height: 100dvh;
  overflow: auto;
  padding: var(--az-space);
  background: var(--az-background);
  color: var(--az-text);
  font-family: "Roboto", system-ui, sans-serif;
  font-size: var(--az-body-size);
  font-weight: var(--az-body-weight);
  line-height: 1.25;
}
az-screen[hidden] {
  display: none;
}
az-screen > * {
  flex: 1 1 auto;
}

az-stack {
  display: flex;
  flex-direction: column;
  gap: var(--az-space);
  min-height: 0;
}
/* A row wraps: a growing child and a field claim half the row less half the space, any other child
   its natural width; what does not fit beside the children before it opens the next line, and on
   each line the growing children and fields share what the others leave (render-flutter's
   row.dart). */
az-row {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--az-space);
  min-width: 0;
}
/* A stack with a height of its own — the screen's, a growing child of one that has — shares it among
   its growing children; any other stack is as tall as its children, a growing one among them as tall
   as its content (render-flutter's bounded). */
az-stack > [data-grow] {
  min-width: 0;
}
az-stack[data-room] > [data-grow] {
  flex: 1 1 0;
  min-height: 0;
}
/* A stack's other children keep their heights: what does not fit runs on, never squeezed. */
az-stack > :not([data-grow]) {
  flex-shrink: 0;
}
/* The screen's own growing child keeps a quarter of the screen inside its padding; where that does
   not fit, the stack grows past the screen and the screen scrolls (render-flutter's column.dart). */
az-screen > az-stack[data-room] > [data-grow] {
  min-height: calc(25dvh - var(--az-space) / 2);
}
az-row > [data-grow],
az-row > az-input,
az-row > az-meter {
  flex: 1 1 0;
  min-width: calc(50% - var(--az-space) / 2);
  min-height: 0;
}
/* A tiled row: its children in equal columns at least its tile wide, as many to a line as fit, the
   empty columns collapsed so they fill the row — one under the other where no two fit — each from
   the top of its line, every line as tall as its tallest. */
az-row[data-tile] {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(var(--az-tile), 100%), 1fr));
  grid-auto-rows: max-content;
  align-items: start;
}
az-row[data-tile] > * {
  min-width: 0;
}

/* A text is drawn in its tone (theme.css's --az-tone, set only on a toned node), else in its role's
   colour. */
az-text {
  display: block;
  overflow-wrap: anywhere;
  color: var(--az-tone, var(--az-text));
}
az-text[data-role="title"] {
  font-size: var(--az-title-size);
  font-weight: var(--az-title-weight);
}
az-text[data-role="body"] {
  font-size: var(--az-body-size);
  font-weight: var(--az-body-weight);
}
az-text[data-role="caption"] {
  font-size: var(--az-caption-size);
  font-weight: var(--az-caption-weight);
  color: var(--az-tone, var(--az-muted));
}

/* A tone is the node's own: a card's outline never colours the texts inside it. */
@property --az-tone {
  syntax: "*";
  inherits: false;
}

/* A stack drawn as a card: on the surface, in the outline — its tone's where it names one — its
   corners the radius, a space inside. */
az-stack[data-surface] {
  background: var(--az-surface);
  border: 1px solid var(--az-tone, var(--az-outline));
  border-radius: var(--az-radius);
  padding: var(--az-space);
}

/* A stack naming a handler is a button: the pointer over it, the primary's ring while it holds the
   keyboard's focus. */
az-stack[data-does] {
  cursor: pointer;
}
az-stack[data-does]:focus-visible {
  outline: 2px solid var(--az-primary);
  outline-offset: 2px;
}

/* A tapped stack naming its opening keeps room at its inline end for its marker: a chevron in the
   muted colour, centred, pointing across while closed and turned down while open. */
az-stack[data-open] {
  position: relative;
  padding-inline-end: calc(var(--az-space) * 3);
}
az-stack[data-open]::after {
  content: "";
  position: absolute;
  inset-inline-end: var(--az-space);
  top: 50%;
  width: 0.5em;
  height: 0.5em;
  border-inline-end: 2px solid var(--az-muted);
  border-block-end: 2px solid var(--az-muted);
  transform: translateY(-50%) rotate(-45deg);
}
az-stack[data-open="true"]::after {
  transform: translateY(-75%) rotate(45deg);
}

/* A meter: a track of the outline, its shares filled from the left, each in its tone — the primary
   untoned — and its mark a tick across it in the text's colour. In a row it claims half the row, as
   a field does. */
az-meter {
  display: flex;
  position: relative;
  height: var(--az-space);
  border-radius: calc(var(--az-space) / 2);
  overflow: hidden;
  background: var(--az-outline);
}
az-meter > .share {
  flex: none;
  height: 100%;
  background: var(--az-tone, var(--az-primary));
}
az-meter > .mark {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 2px;
  margin-left: -1px;
  background: var(--az-text);
}

/* The house's brand: its lockup whole at a control's height, as wide as its proportions make it,
   never stretched or shrunk by its stack or its row — the letters in the brand's gray on the light
   ground and white on the dark (Agilezip AZE-57). */
az-brand {
  display: block;
  flex: none;
  width: fit-content;
  height: 48px;
}
az-brand svg {
  display: block;
  width: auto;
  height: 100%;
}
az-brand .word {
  fill: #3d3d3d;
}
@media (prefers-color-scheme: dark) {
  az-brand .word {
    fill: #ffffff;
  }
}

/* A scene: its picture as wide as its parent and as tall as the scene composes it, each word pinned
   on it — its left edge and its middle at the scene's pin — the page's clicks passing through. Until
   it is composed, and where it is said in words alone, the words stand one under the other and the
   picture takes no room. A word is as wide as what it says, so the scene composes on its true size. */
az-scene {
  display: block;
  position: relative;
  min-width: 0;
}
az-scene > canvas {
  display: block;
  width: 100%;
}
az-scene > .words {
  display: flex;
  flex-direction: column;
  gap: var(--az-space);
}
az-scene > .words > * {
  width: fit-content;
}
az-scene:not([data-composed]) > canvas,
az-scene[data-said] > canvas {
  display: none;
}
az-scene[data-composed]:not([data-said]) > .words {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
az-scene[data-composed]:not([data-said]) > .words > * {
  position: absolute;
  transform: translateY(-50%);
  white-space: nowrap;
}

/* An image fills its box, cropped; a video and a growing image show their whole picture in it, the
   surface around (render-flutter's screen.dart). */
az-image,
az-video {
  display: block;
  height: 160px;
  border-radius: var(--az-radius);
  overflow: hidden;
  background: var(--az-surface);
}
az-row > az-image,
az-row > az-video {
  flex: none;
  width: 48px;
  height: 48px;
}
az-image img,
az-video video {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
az-image[data-grow] img,
az-video video {
  object-fit: contain;
}
/* An image waiting to come into view holds its box, the surface showing; one that did not load
   gives its place to its alt. */
az-image img:not([src]) {
  visibility: hidden;
}
az-image img[hidden],
az-video video[hidden] {
  display: none;
}
az-image .alt,
az-video .alt,
az-list > .empty {
  font-size: var(--az-caption-size);
  color: var(--az-muted);
}
az-image .alt,
az-video .alt {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  text-align: center;
}

az-list {
  display: flex;
  flex-direction: column;
  gap: var(--az-space);
}
/* A growing list with a height of its own scrolls in it; any other is as tall as its items. Either
   way each item is as tall as its content, never squeezed to fit (render-flutter's ListView). */
az-list[data-room] {
  overflow-y: auto;
}
az-list > * {
  flex-shrink: 0;
}
/* A tiled list: as many columns at least its tile wide as fit, filling the width — one where none
   fits — each item as tall as its content, each line as tall as its tallest, never shrunk to a
   room. */
az-list[data-tile] {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(var(--az-tile), 100%), 1fr));
  grid-auto-rows: max-content;
  align-items: start;
}
az-list[data-tile] > .empty {
  grid-column: 1 / -1;
}

az-action {
  display: block;
}
az-action button {
  font: inherit;
  box-sizing: border-box;
  min-height: 48px;
  border: 0;
  border-radius: var(--az-radius);
  padding: var(--az-space) calc(2 * var(--az-space));
  cursor: pointer;
}
az-stack > az-action button {
  width: 100%;
}
az-action[data-emphasis="primary"] button {
  background: var(--az-primary);
  color: var(--az-on-primary);
}
az-action[data-emphasis="plain"] button {
  background: transparent;
  color: var(--az-primary);
}

az-input {
  display: block;
}
az-input label {
  display: flex;
  flex-direction: column;
  gap: calc(var(--az-space) / 2);
}
az-input span {
  font-size: var(--az-caption-size);
  font-weight: var(--az-caption-weight);
  color: var(--az-muted);
}
az-input input {
  font: inherit;
  box-sizing: border-box;
  min-height: 48px;
  color: var(--az-text);
  background: var(--az-surface);
  border: 1px solid var(--az-outline);
  border-radius: var(--az-radius);
  padding: var(--az-space) var(--az-radius);
}
az-input input:focus {
  outline: 2px solid var(--az-primary);
  outline-offset: -1px;
}

/* A stepper: one outlined control, its number centred in its digits between a − and a +. */
az-stepper {
  display: inline-flex;
  align-items: stretch;
  flex-shrink: 0;
  box-sizing: border-box;
  min-height: 48px;
  color: var(--az-text);
  background: var(--az-surface);
  border: 1px solid var(--az-outline);
  border-radius: var(--az-radius);
  overflow: hidden;
}
az-stepper:focus-within {
  outline: 2px solid var(--az-primary);
  outline-offset: -1px;
}
az-stepper button {
  font: inherit;
  font-size: 1.25em;
  line-height: 1;
  min-width: 44px;
  padding: 0;
  border: 0;
  color: var(--az-primary);
  background: transparent;
  cursor: pointer;
}
az-stepper input {
  font: inherit;
  font-variant-numeric: tabular-nums;
  box-sizing: content-box;
  width: calc(var(--az-digits) * 1ch);
  min-width: 0;
  padding: 0 calc(var(--az-space) / 2);
  text-align: center;
  color: var(--az-text);
  background: transparent;
  border: 0;
  outline: none;
}
