/* WCAG 2.2 AA token fixes that Tailwind classes cannot carry (UI quick win QW-4; ADR-0069).
   An empty input's border is its only visible boundary: SC 1.4.11 needs 3:1, and border-neutral-300 gives
   1.48:1. The attribute selector out-ranks the Tailwind class, so no template changes. #737373 = 4.74:1. */
input[class*="border-neutral-300"],
select[class*="border-neutral-300"],
textarea[class*="border-neutral-300"] {
  border-color: #737373;
}

/* The sticky top bar (base.html header[data-app-header]; CEO feedback 15 Oct). Also here, not only as Tailwind
   classes, so the bar stays put even if the Tailwind script is slow. top: below a notch when the page is drawn
   under it (env() is 0 otherwise; a browser without env() keeps Tailwind's top-0). */
header[data-app-header] {
  position: sticky;
  top: env(safe-area-inset-top, 0px);
  z-index: 40;
  background-color: #ffffff;
}

/* A jump to an anchor (Users & access #person-...) lands below the bar, not under it. --app-header-h is the
   bar's live height, set by app/static/app-header.js; the fallback is the one-line desktop bar. */
html {
  scroll-padding-top: calc(var(--app-header-h, 3.5rem) + 0.75rem);
}

/* Users & access rows (access_admin/index.html [data-open-hint]): "Edit" (or "Open") while a row is closed,
   "Close" while it is open, also when the Tailwind script has not loaded (hidden and group-open: are Tailwind). */
details[open] [data-open-hint] > :first-child,
details:not([open]) [data-open-hint] > :last-child {
  display: none;
}

/* Person rows (access_admin/index.html [data-person-row]): the same four fixed columns on every row (who, status,
   level and areas, Edit), so each column starts at the same place down the list (lead engineer, 4 Nov); one column
   while the list is narrower than 44rem (a container query, so the sidebar's width counts). */
[data-people] {
  container: people / inline-size;
}
[data-person-row] {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0.25rem 1rem;
  align-items: center;
}
[data-person-row]::-webkit-details-marker {
  display: none;
}
[data-person-who] {
  overflow-wrap: anywhere;
}
[data-person-row] > [data-open-hint] {
  justify-self: start;
}
@container people (min-width: 44rem) {
  [data-person-row] {
    grid-template-columns: minmax(0, 16rem) 7rem minmax(0, 1fr) 5rem;
  }
  [data-person-row] > [data-open-hint] {
    justify-self: end;
  }
}

/* The invite form on /admin/access (access_admin/index.html [data-invite-form]) opens as a panel on the right, over
   a dimmed page, from "Invite someone" in the People heading (lead engineer, 4 Nov): it was a card as wide as nothing
   else on the page. A popover needs no script: the close button, Esc or a click outside closes it, and what was typed
   stays until the page reloads. A browser without popovers keeps the card in the page, without the open and close buttons. */
@supports selector(:popover-open) {
  [data-invite-form][popover] {
    position: fixed;
    inset: 0 0 0 auto;
    width: min(40rem, 100%);
    height: 100dvh;
    margin: 0;
    padding: 1.25rem;
    overflow-y: auto;
    overscroll-behavior: contain;
    border: 0;
    border-left: 1px solid var(--line);
    border-radius: 0;
    background: var(--surface);
    color: inherit;
    box-shadow: var(--sh-overlay);
  }
  [data-invite-form][popover]::backdrop {
    background: rgb(20 35 43 / 0.3);
  }
}
@supports not selector(:popover-open) {
  [data-invite-open],
  [data-invite-form] [popovertargetaction="hide"] {
    display: none;
  }
}

/* Design tokens (visual refresh step 1, docs: .workflows round2 UI brief section 3; brand kit of 15 Oct). Variables
   only: nothing here changes a page until a stylesheet uses them (the welcome page first). Contrast ratios are the
   brief's WCAG computations; brass is decorative only (2.92:1 on light grounds: use --brass-ink for text). */
:root {
  --ink: #14232b;
  --text: #1f2a30;
  --muted: #5e6b70;
  --teal: #2e5e63;
  --teal-hover: #244b4f;
  --teal-subtle: #dce8e7;
  --brass: #b8893b;
  --brass-ink: #7d5b20;
  --mist: #eef2f1;
  --ivory: #faf6ee;
  --surface: #ffffff;
  --surface-2: #f6f8f7;
  --selected: #e4ecea;
  --line: #dde4e3;
  --line-strong: #6f7c80;
  /* status, the 4 Oct vocabulary (#56 review: one home for the shell's status colours). Text at the 700/800 shades
     (amber at 800: Tailwind's 700 is 4.45:1 on Mist, review u4 of step 1; green at 800 for the same reason), a chip
     at 800 on its 50 tint with a 1 px line, and the 700 mark for a dot or a tile marker (non-text, 3:1) */
  --status-red-text: #b91c1c;
  --status-red-chip: #991b1b;
  --status-red-tint: #fef2f2;
  --status-red-line: #fca5a5;
  --status-amber-text: #92400e;
  --status-amber-mark: #b45309;
  --status-amber-tint: #fffbeb;
  --status-amber-line: #fcd34d;
  --status-green-text: #166534;
  --status-green-mark: #15803d;
  --status-green-tint: #f0fdf4;
  --status-green-line: #86efac;
  --font-serif: Georgia, Cambria, "Times New Roman", serif;
  --font-sans: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --r-chip: 6px;
  --r-input: 10px;
  --r-card: 12px;
  --r-pill: 9999px;
  --sh-card: 0 1px 2px rgba(20, 35, 43, 0.06);
  --sh-overlay: 0 8px 24px rgba(20, 35, 43, 0.14);
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-12: 48px;
}

/* htmx feedback (app/static/shell/htmx-feedback.js; design audit of 4 Nov): an element waiting for its answer shows
   the wait and the buttons it holds fade; the failure line stays in view below the sticky bar while the page scrolls. */
[aria-busy="true"] { cursor: progress; }
form[aria-busy="true"] button,
button[aria-busy="true"] { opacity: 0.6; }
[data-htmx-error] {
  position: sticky;
  top: calc(var(--app-header-h, 3.5rem) + 0.5rem);
  z-index: 30;
}

/* A wide table scrolls inside its .overflow-x-auto box. Positioned, the box also clips the screen-reader-only labels
   (sr-only is position: absolute) that otherwise escape it and make the whole page scroll sideways on a phone
   (the 4 Nov page audit, /obligations/owners at 375 px). */
.overflow-x-auto {
  position: relative;
}
