/* ─────────────────────────────────────────────────────────────────────────
   AUDAX — page and component layouts for Audax's own screens.

   Apps own their layouts; the system owns the vocabulary
   (docs/dev/web/design-system.md §4.5). Everything here consumes tokens — Audax's
   own --au-* tier for brand metrics, the platform's for shape and spacing —
   and nothing here is a literal.

   The split against audax/css/theme.css: the theme is what happens to
   *shared* components inside an Audax screen (accent, surfaces, type, the
   wash, the mark). This file is the layout of Audax's *own* pages, loaded per
   template rather than on every Audax route.

   Translated from the brand package's style/patterns.css. That file is a
   marketing-site vocabulary — hero, chapter band, feature cards, matrix, CTA
   band, footer — and only the parts an operational screen actually needs came
   across. A `.cta-band` on a mission list would be the brand wearing the
   product rather than the other way round.

   Everything is scoped under [data-app="audax"] so a page that somehow loads
   this stylesheet outside an Audax route still cannot restyle the platform.
   ───────────────────────────────────────────────────────────────────────── */

@layer components {
  /* ── Page frame ────────────────────────────────────────────────────
     A reading measure rather than the full width. Whitespace is part of the
     brand and a 2000px-wide row of body copy is not (style.md §2 rule 7). */
  [data-app="audax"] .au-page {
    max-width: var(--au-container);
    margin: 0 auto;
    padding: var(--space-8) var(--space-8) var(--space-16);
  }

  [data-app="audax"] {
    /* The brand's base container, expressed once. Its own token rather than a
       platform one: the platform has no opinion about reading measure. */
    --au-container: 1080px;
  }

  /* ── Page opener ───────────────────────────────────────────────────
     Eyebrow, display heading with at most one italic word, lede. This is the
     brand's standard section head; every Audax page starts with one. */
  [data-app="audax"] .au-head {
    display: flex;
    align-items: flex-start;
    gap: var(--space-4);
    margin-bottom: var(--space-8);
  }

  [data-app="audax"] .au-head__titles { min-width: 0; }

  [data-app="audax"] .au-head h1 {
    margin: var(--space-1) 0 0;
    font-size: var(--au-t-h2);
  }

  [data-app="audax"] .au-head .au-lede { margin-top: var(--space-2); }

  /* Actions sit opposite the title rather than under it, so the heading keeps
     its whitespace and the primary action stays where the eye lands last. */
  [data-app="audax"] .au-head__actions {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    margin-left: auto;
    flex-shrink: 0;
  }

  /* ── Sections ──────────────────────────────────────────────────────
     The brand breathes at 128px between sections on a marketing page. An
     operational screen cannot afford that and stay usable, so Audax's screens
     take the tightest step of the brand's own rhythm rather than inventing a
     smaller one. */
  [data-app="audax"] .au-section + .au-section { margin-top: var(--space-16); }

  [data-app="audax"] .au-section__head {
    display: flex;
    align-items: baseline;
    gap: var(--space-3);
    margin-bottom: var(--space-4);
    padding-bottom: var(--space-2);
    border-bottom: 1px solid var(--au-ink-100);
  }

  [data-app="audax"] .au-section__head h2 { font-size: var(--au-t-h4); }

  [data-app="audax"] .au-count {
    font-family: var(--font-mono);
    font-size: var(--au-t-caption);
    color: var(--au-ink-500);
  }

  /* ── Key list ──────────────────────────────────────────────────────
     The brand's `.key` row: hairline-separated lines with a small sage
     marker, used where a table would be heavier than the content deserves.
     This is what an Audax holon-detail section renders as. */
  [data-app="audax"] .au-keys {
    display: flex;
    flex-direction: column;
  }

  [data-app="audax"] .au-key {
    display: flex;
    align-items: baseline;
    gap: var(--space-3);
    padding: var(--space-3) 0;
    border-bottom: 1px solid var(--au-ink-100);
  }

  [data-app="audax"] .au-key:last-child { border-bottom: 0; }

  [data-app="audax"] .au-key::before {
    content: "";
    flex-shrink: 0;
    width: var(--space-2);
    height: var(--space-2);
    margin-top: var(--space-1);
    border-radius: var(--au-radius-chip);
    background: var(--au-forest-400);
  }

  [data-app="audax"] .au-key__name {
    font-weight: var(--au-w-medium);
    color: var(--au-ink-900);
  }

  [data-app="audax"] .au-key__desc {
    flex: 1;
    min-width: 0;
    font-size: var(--au-t-body-sm);
    color: var(--au-ink-600);
  }

  [data-app="audax"] .au-key__links {
    display: flex;
    gap: var(--space-3);
    margin-left: auto;
    flex-shrink: 0;
    font-size: var(--au-t-body-sm);
  }

  /* ── Empty state ───────────────────────────────────────────────────
     One sentence, no illustration, no call to action shouting at an empty
     screen (voice.md). */
  [data-app="audax"] .au-empty {
    padding: var(--space-12) 0;
    font-size: var(--au-t-body-lg);
    font-weight: var(--au-w-light);
    color: var(--au-ink-500);
    text-align: center;
  }

  /* ── Forms ─────────────────────────────────────────────────────────
     Narrow measure, generous rhythm, no boxed panel — whitespace does the
     grouping a border would otherwise do. */
  [data-app="audax"] .au-form {
    max-width: var(--au-container-narrow);
    margin: 0 auto;
  }

  [data-app="audax"] { --au-container-narrow: 720px; }

  [data-app="audax"] .au-field {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    margin-bottom: var(--space-6);
  }

  [data-app="audax"] .au-field > label {
    font-size: var(--au-t-body-sm);
    font-weight: var(--au-w-medium);
    color: var(--au-ink-700);
  }

  [data-app="audax"] .au-field .au-required { color: var(--au-danger); }

  [data-app="audax"] .au-field__hint {
    font-size: var(--au-t-caption);
    color: var(--au-ink-500);
  }

  [data-app="audax"] .au-field input,
  [data-app="audax"] .au-field select,
  [data-app="audax"] .au-field textarea {
    width: 100%;
    padding: var(--space-3) var(--space-4);
    font-family: inherit;
    font-size: var(--au-t-body);
    font-weight: var(--au-w-light);
    color: var(--au-ink-900);
    background: var(--white);
    border: 1px solid var(--au-ink-200);
    border-radius: var(--au-radius-input);
    transition: border-color var(--au-dur-2) var(--au-ease-soft),
                box-shadow var(--au-dur-2) var(--au-ease-soft);
  }

  [data-app="audax"] .au-field textarea {
    resize: vertical;
    line-height: var(--au-lh-relaxed);
  }

  [data-app="audax"] .au-field input::placeholder,
  [data-app="audax"] .au-field textarea::placeholder { color: var(--au-ink-400); }

  /* The focus ring is never removed — 3px forest at 35%, every interactive
     element, keyboard focus included (style.md §6). */
  [data-app="audax"] .au-field input:focus-visible,
  [data-app="audax"] .au-field select:focus-visible,
  [data-app="audax"] .au-field textarea:focus-visible {
    outline: none;
    border-color: var(--au-forest-500);
    box-shadow: var(--au-ring-focus);
  }

  [data-app="audax"] { --au-ring-focus: 0 0 0 3px color-mix(in oklab, var(--au-forest-500) 35%, transparent); }

  /* A read-only value shown where a field would be — the mission form's
     parent quest, which is fixed by the route rather than chosen. */
  [data-app="audax"] .au-field__value {
    font-size: var(--au-t-body);
    color: var(--au-ink-700);
  }

  [data-app="audax"] .au-actions {
    display: flex;
    justify-content: flex-end;
    gap: var(--space-2);
    margin-top: var(--space-8);
    padding-top: var(--space-6);
    border-top: 1px solid var(--au-ink-100);
  }

  /* ── Error ─────────────────────────────────────────────────────────
     Iron-oxide, not pure red: a signal colour still has to be earthy. Errors
     are the one place the brand permits an exclamation, and these do not
     need one (voice.md). */
  [data-app="audax"] .au-error {
    margin-bottom: var(--space-6);
    padding: var(--space-3) var(--space-4);
    font-size: var(--au-t-body-sm);
    color: var(--au-danger);
    background: color-mix(in oklab, var(--au-danger) 7%, var(--white));
    border: 1px solid color-mix(in oklab, var(--au-danger) 25%, var(--white));
    border-radius: var(--au-radius-input);
  }

  @media (max-width: 640px) {
    [data-app="audax"] .au-page { padding: var(--space-6) var(--space-4) var(--space-12); }
    [data-app="audax"] .au-head { flex-wrap: wrap; }
    [data-app="audax"] .au-head__actions { margin-left: 0; }
  }
}
