/* OpenFlow v2: the shared page templates. Report 204.

   SOURCE: `planning/design/openflow-v2-handoff/` (the round-3 handoff:
   "Adealia Templates.dc.html" for the templates, widths, behaviour and
   rules; "Adealia App.dc.html" for the drawn sizes). The markup is the
   macros in `templates/_of.html`; how to use each is in BUILD-NOTES.md.

   Loaded after openflow.css and before the five page sheets (of-people,
   of-events, of-queue, of-settings, of-progress), which hold a page's own
   rules. Page agents do not edit this file; they report what it lacks.

     1. Widths          .t-list .t-detail .t-settings .t-progress .t-form
     2. Page header     .of-head
     3. List toolbar    .of-toolbar .of-search .of-select .of-chips .of-seg
     4. List card       .of-list .of-list__head .of-row .of-group-label
     5. States          .of-state --empty --filtered --loading --error
     6. Pill, section card, facts column, detail layout
     7. Form bar        .of-formbar
     8. Settings        .of-settings
     9. Progress        .of-progress .of-meter
    10. Toasts, the side panel's back and wide variant, page arrival */

:root {
  --of-head-bg:   #FBFAF6;   /* a list's header row */
  --of-head-ink:  #55677D;   /* its labels, a group label */
  --of-muted:     #616B78;   /* a row's second line */
  --of-field:     #918D86;   /* a field's edge, 3:1 */
  --of-cols:      minmax(0, 1fr) 20px;
}

/* ── 1. Widths ─────────────────────────────────────────────────────────
   Centered in the space right of the 64px rail; 32px at the sides, 16 on a
   phone. The 1200px cap in design-system.css leaves these alone. */
.of-t {
  width: 100%;
  margin-inline: auto;
  box-sizing: border-box;
  padding: 32px 32px 48px;
}
.t-list, .t-detail, .t-settings { max-width: calc(1240px + 64px); }
.t-progress { max-width: calc(880px + 64px); }
.t-form { max-width: calc(760px + 64px); }
@media (max-width: 759.98px) {
  .of-t { padding: 20px 16px 32px; }
}

/* ── 2. Page header ────────────────────────────────────────────────────
   Back link if any, the title (30/600, 26 on a phone), one line, actions on
   the right. Nothing above it. Header buttons are 40 high. */
.of-head {
  display: flex; flex-wrap: wrap; align-items: flex-end;
  gap: 16px; margin: 0 0 20px;
}
.of-head__text { flex: 1 1 300px; min-width: 0; }
.of-head__back {
  display: inline-flex; align-items: center; gap: 6px;
  margin: 0 0 10px; color: var(--of-head-ink); font-size: 15px;
  text-decoration: none;
}
.of-head__back .ms { font-size: 18px; }
.of-head__back:hover { color: var(--ink-1); }
.of-head__title {
  margin: 0; font-size: 30px; font-weight: 600; line-height: 1.15;
  letter-spacing: -0.02em; color: var(--ink-1);
}
.of-head__title:focus { outline: none; }
.of-head__line { margin: 6px 0 0; color: var(--of-muted); font-size: 16px; }
.of-head__actions { display: flex; flex-wrap: wrap; gap: 8px; }
.of-head__actions .ui-btn { min-height: 40px; height: 40px; padding-block: 0; white-space: nowrap; }
@media (max-width: 759.98px) {
  .of-head__title { font-size: 26px; }
  .of-head__actions { width: 100%; }
}

/* ── 3. The list toolbar ───────────────────────────────────────────────
   Search, filters as selects, a count, "Clear" when any is set; chips and
   the view switch on their own row. Fields are 42 high, chips 34. */
.of-toolbar {
  display: flex; flex-wrap: wrap; align-items: center;
  gap: 8px; margin: 0 0 16px;
}
.of-search, .of-select {
  height: 42px; box-sizing: border-box;
  border: 1px solid var(--of-field); border-radius: 10px;
  background: var(--card-bg); color: var(--ink-1);
  font: inherit; font-size: 15px;
}
.of-search { flex: 1 1 240px; min-width: 0; padding: 0 12px; }
.of-select { flex: 0 1 180px; min-width: 0; padding: 0 10px; }
.of-search:focus-visible, .of-select:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.of-toolbar__count { margin-left: auto; font-size: 14px; color: var(--of-muted); white-space: nowrap; }
.of-clear {
  display: inline-flex; align-items: center; height: 42px; padding: 0 10px;
  color: var(--accent); font-size: 15px; text-decoration: none; white-space: nowrap;
}
.of-clear:hover { text-decoration: underline; }
/* Without script the toolbar sends itself with this; with it, on change. */
.of-toolbar__go { height: 42px; min-height: 42px; padding-block: 0; }
html[data-nav="on"] .of-toolbar__go { display: none; }

.of-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.of-chip {
  display: inline-flex; align-items: center; gap: 6px;
  height: 34px; padding: 0 14px; box-sizing: border-box;
  border: 1px solid var(--line); border-radius: 999px;
  background: var(--card-bg); color: var(--ink-1);
  font-size: 14px; text-decoration: none; white-space: nowrap;
}
.of-chip:hover { border-color: var(--line-3, #C9C1B2); color: var(--ink-1); }
.of-chip__n { font-weight: 600; }
.of-chip[aria-current], .of-chip.is-on {
  background: var(--ink-1); border-color: var(--ink-1); color: #fff;
}

.of-seg {
  display: inline-flex; gap: 0; padding: 4px;
  background: var(--chip-bg); border-radius: 10px;
}
.of-seg__opt {
  display: inline-flex; align-items: center;
  height: 34px; padding: 0 14px; box-sizing: border-box;
  border-radius: 8px; color: var(--ink-1); font-size: 15px;
  text-decoration: none; white-space: nowrap;
}
.of-seg__opt:hover { color: var(--ink-1); background: color-mix(in srgb, #fff 50%, transparent); }
.of-seg__opt[aria-current] { background: var(--card-bg); font-weight: 600; }

/* ── 4. The list card ──────────────────────────────────────────────────
   One white card of rows split by hairlines. The whole row opens the item
   (the row's link stretches over it); a chevron shows that it does. A page
   sets its columns once: `style="--of-cols: minmax(200px,2fr) … 20px"`. */
.of-list {
  position: relative;
  background: var(--card-bg);
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
  margin: 0 0 16px;
}
.of-list__head, .of-row {
  display: grid; grid-template-columns: var(--of-cols);
  align-items: center; gap: 6px 16px;
}
.of-list__head {
  padding: 10px 20px;
  background: var(--of-head-bg);
  border-bottom: 1px solid var(--line-2);
  font-size: 13px; font-weight: 600; color: var(--of-head-ink);
}
.of-row {
  position: relative;
  padding: 14px 20px;
  border-top: 1px solid var(--line-2);
  font-size: 15px;
}
.of-list__head + .of-row, .of-list > .of-row:first-child { border-top: 0; }
.of-row--opens { cursor: pointer; }
.of-row--opens:hover { background: var(--of-head-bg); }
.of-row__main { display: flex; align-items: center; gap: 12px; min-width: 0; }
.of-row__avatar {
  width: 36px; height: 36px; flex: none; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--chip-bg); color: var(--ink-1);
  font-size: 13px; font-weight: 600;
}
.of-row__text { min-width: 0; }
.of-row__title { font-weight: 500; color: var(--ink-1); }
a.of-row__title { text-decoration: none; }
a.of-row__title:hover { color: var(--ink-1); text-decoration: underline; }
/* The row's link covers the row; other controls in it sit above. */
a.of-row__title::after { content: ""; position: absolute; inset: 0; }
.of-row a:not(.of-row__title), .of-row button, .of-row input, .of-row select { position: relative; z-index: 1; }
.of-row__sub { font-size: 14px; color: var(--of-muted); overflow-wrap: anywhere; }
.of-row__cell { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.of-row__chev { width: 20px; font-size: 20px; color: var(--of-muted); }
.of-row .ui-btn { min-height: 36px; height: 36px; padding-block: 0; }
.of-row:focus-within { box-shadow: inset 3px 0 0 var(--accent); }

.of-group-label {
  margin: 24px 0 8px 4px;
  font-size: 13px; font-weight: 600; color: var(--of-head-ink);
}
.of-group-label:first-child { margin-top: 0; }

/* Phone and tablet: the header row drops and each row stacks: the title,
   then the cells as one line of words ("Broker · Quinn Ortega · Santa Fe"),
   then the pill. Below 1024 a row of five columns cuts its words off. */
@media (max-width: 1023.98px) {
  .of-list__head { display: none; }
  .of-row { display: block; padding: 14px 36px 14px 16px; }
  .of-row__main { margin-bottom: 6px; }
  /* The rest of the row lines up under the name, not under the avatar. */
  .of-row:has(> .of-row__main .of-row__avatar) { padding-left: 64px; }
  .of-row:has(> .of-row__main .of-row__avatar) > .of-row__main { margin-left: -48px; }
  .of-row__cell { display: inline; font-size: 14px; color: var(--of-head-ink); white-space: normal; overflow: visible; }
  .of-row__cell:not(.of-row__cell--pill):not(.of-row__cell--blank):has(~ .of-row__cell:not(.of-row__cell--pill):not(.of-row__cell--blank))::after { content: "\00a0· "; }
  .of-row__cell--pill { display: inline-block; margin: 4px 0 0 4px; vertical-align: middle; }
  .of-row__cell--blank, .of-row__cell--wide-only { display: none; }
  .of-row__chev { position: absolute; right: 12px; top: 22px; }
}

/* Waiting on the next filter: the rows dim and a line moves (nav.js). */
.of-list.is-loading > .of-row { opacity: .45; transition: opacity .12s; }

/* ── 5. States, inside the card ────────────────────────────────────── */
.of-state { padding: 40px 20px; text-align: center; color: var(--of-muted); }
.of-state__title { margin: 0; font-weight: 600; font-size: 16px; color: var(--ink-1); }
.of-state__text { margin: 4px auto 0; max-width: 520px; font-size: 14px; }
.of-state__actions { margin: 14px 0 0; display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.of-state .ms { font-size: 28px; color: var(--done-ink, #0F6B4F); }
.of-state--error {
  display: flex; flex-wrap: wrap; align-items: center; gap: 12px;
  padding: 28px 20px; text-align: left;
}
.of-state--error .ms { font-size: 24px; color: var(--alert-fg); }
.of-state--error .of-state__words { flex: 1 1 240px; }
.of-state--error .of-state__text { margin: 2px 0 0; }
.of-state--error .of-state__actions { margin: 0; }
.of-state--loading { display: flex; flex-direction: column; gap: 14px; padding: 16px 20px; text-align: left; }
.of-skel {
  display: block; height: 16px; border-radius: 6px; background: var(--chip-bg);
  animation: of-skel 1.2s infinite;
}
@keyframes of-skel { 0%, 100% { opacity: .55; } 50% { opacity: 1; } }

/* ── 6. Pill, section card, facts, detail ──────────────────────────────
   Status is a pill with a word: green done or active, amber waiting or
   short, red sent back or overdue, grey for everything else. */
.of-pill {
  display: inline-flex; align-items: center; flex: none;
  height: 24px; padding: 0 10px; box-sizing: border-box;
  border-radius: 999px; font-size: 13px; font-weight: 500; white-space: nowrap;
  background: var(--chip-bg); color: var(--of-head-ink);
}
.of-pill--ok    { background: #E3F2EA; color: var(--green-deep, #0F6B4F); }
.of-pill--warn  { background: var(--warn-bg); color: var(--warn-fg); }
.of-pill--alert { background: var(--alert-bg); color: var(--alert-fg); }

.of-card {
  background: var(--card-bg); border: 1px solid var(--line); border-radius: 14px;
}
.of-section { padding: 20px 22px; display: flex; flex-direction: column; gap: 14px; margin: 0 0 16px; }
.of-section__head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; }
.of-section__title { margin: 0; font-size: 18px; font-weight: 600; color: var(--ink-1); flex: 1 1 auto; }
.of-section__line { margin: 0; flex-basis: 100%; font-size: 15px; color: var(--of-muted); }
/* `.ui-page p` caps prose at 72ch; capped, the line fits beside the title. */
.ui-page p.of-section__line { max-width: none; }
.of-section__body > :first-child { margin-top: 0; }
.of-section__body > :last-child { margin-bottom: 0; }
.of-section--flush { padding: 0; gap: 0; overflow: hidden; }
.of-section--flush > .of-section__head { padding: 18px 20px 12px; }
.of-section__foot { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

.of-facts { margin: 0; padding: 16px 20px; display: flex; flex-direction: column; gap: 12px; }
.of-facts__row { display: flex; flex-direction: column; gap: 2px; }
.of-facts dt { font-size: 13px; font-weight: 600; color: var(--of-head-ink); }
.of-facts dd { margin: 0; font-size: 15px; color: var(--ink-1); overflow-wrap: anywhere; }

.of-detail { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 24px; align-items: start; }
.of-detail__main { min-width: 0; }
.of-detail__aside { min-width: 0; position: sticky; top: 84px; }
@media (max-width: 1023.98px) {
  .of-detail { grid-template-columns: minmax(0, 1fr); }
  /* On a phone the facts come first, under the header. */
  .of-detail__aside { order: -1; position: static; }
}

/* Danger actions are red text buttons set apart from the main ones. */
.of-danger {
  margin-left: auto; background: none; border: 0; padding: 0 4px; height: 44px;
  color: var(--alert-fg); font: inherit; font-size: 15px; font-weight: 500; cursor: pointer;
  text-decoration: none;
}
.of-danger:hover { text-decoration: underline; color: var(--alert-fg); }

/* ── 7. The form bar ───────────────────────────────────────────────────
   Pinned to the bottom of a Form page: the copper button saying what
   happens, Cancel, one line of consequence. The page keeps room under it. */
.of-formbar {
  position: sticky; bottom: 0; z-index: 5;
  margin: 20px -12px 0; padding: 12px;
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px;
  background: color-mix(in srgb, var(--page-bg) 94%, transparent);
  backdrop-filter: blur(6px);
  border-top: 1px solid var(--line);
}
.of-formbar .ui-btn { min-height: 44px; white-space: nowrap; }
.of-formbar__note { margin: 0; flex: 1 1 240px; font-size: 14px; color: var(--of-muted); }
.of-formbar__fix { color: var(--alert-fg); font-weight: 600; }
@media (max-width: 759.98px) {
  /* The page scrolls above the tab bar (components.css pads the column), so
     bottom: 0 already clears it. */
  .of-formbar .ui-btn--primary { flex: 1 1 100%; }
}

/* ── 8. Settings ───────────────────────────────────────────────────────
   A left list of sections (sticky, 220) and the chosen section as cards.
   On a phone the list is the page; a chosen section drills in with
   "← Settings" above it. */
.of-settings { display: flex; flex-wrap: wrap; gap: 24px; align-items: flex-start; }
.of-settings__nav {
  flex: 0 0 220px; position: sticky; top: 84px;
  display: flex; flex-direction: column; gap: 2px;
}
.of-settings__link {
  display: flex; align-items: center; gap: 12px;
  min-height: 44px; padding: 0 12px; border-radius: 10px;
  color: var(--ink-1); font-size: 15px; text-decoration: none;
}
.of-settings__link .ms { font-size: 20px; color: var(--of-head-ink); }
.of-settings__link:hover { background: var(--hover-bg); color: var(--ink-1); }
.of-settings__link[aria-current] { background: var(--card-bg); font-weight: 600; box-shadow: 0 0 0 1px var(--line); }
.of-settings__link .of-settings__chev { display: none; margin-left: auto; }
.of-settings__body { flex: 1 1 480px; min-width: 0; display: flex; flex-direction: column; gap: 16px; }
.of-settings__back { display: none; }
@media (max-width: 759.98px) {
  .of-settings__nav {
    flex: 1 1 100%; position: static;
    background: var(--card-bg); border: 1px solid var(--line); border-radius: 14px; padding: 6px;
  }
  .of-settings__link[aria-current] { box-shadow: none; background: transparent; font-weight: 500; }
  .of-settings__link .of-settings__chev { display: inline; color: var(--of-muted); }
  .of-settings[data-chosen] .of-settings__nav { display: none; }
  .of-settings:not([data-chosen]) .of-settings__body { display: none; }
  .of-settings[data-chosen] .of-settings__back { display: inline-flex; }
}

/* ── 9. Progress ───────────────────────────────────────────────────────
   The big number, a meter, one line of what is left. */
.of-progress { padding: 22px 24px; margin: 0 0 16px; }
.of-progress__top { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 8px 16px; }
.of-progress__num { font-size: 34px; font-weight: 600; letter-spacing: -0.02em; color: var(--ink-1); }
.of-progress__of { font-size: 18px; color: var(--of-head-ink); }
.of-progress__aside { font-size: 15px; color: var(--of-head-ink); }
.of-progress__line { margin: 0; font-size: 14px; color: var(--of-muted); }
.of-progress--done .of-progress__line { color: var(--green-deep, #0F6B4F); font-weight: 600; }
.of-meter {
  height: 10px; margin: 12px 0 10px; overflow: hidden;
  background: var(--chip-bg); border-radius: 999px;
}
.of-meter__fill { display: block; height: 100%; border-radius: 999px; background: var(--copper-cta); }
.of-progress--done .of-meter__fill { background: var(--green-deep, #0F6B4F); }

/* ── 10. Toasts, the panel, page arrival ───────────────────────────────── */
.shell-top__status { display: contents; }
@media (max-width: 759.98px) {
  .shell-top__status > .conn-badge, .shell-top__status > .status { display: none; }
}

/* A toast at the bottom says what happened. It carries `flash` too, so
   app.css's flash rules are undone here. */
.of-toasts.flashes {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  z-index: 400; padding: 0;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  width: max-content; max-width: calc(100% - 32px);
  pointer-events: none;
}
.of-toasts .of-toast.flash {
  pointer-events: auto;
  display: flex; align-items: center; gap: 12px;
  padding: 10px 10px 10px 16px; border: 0; border-radius: 10px;
  background: var(--ink-1); color: #fff;
  font-size: 15px; font-weight: 400;
  box-shadow: 0 8px 24px rgba(17, 23, 58, .25);
  animation: of-toast .16s ease;
}
.of-toasts .of-toast--error.flash, .of-toasts .of-toast--warning.flash { background: var(--alert-fg); }
.of-toasts .of-toast__x.flash-x { color: #fff; opacity: .8; font-size: 20px; padding: 0 6px; }
.of-toasts .of-toast__x.flash-x:hover { opacity: 1; color: #fff; }
@keyframes of-toast { from { opacity: 0; transform: translateY(6px); } }
@media (max-width: 719.98px) {
  .of-toasts.flashes { bottom: 80px; }
}

/* The side panel: ← from the second level up; 640 for a long form. */
.ui-panel__back {
  width: 36px; height: 36px; flex: none; margin: -2px 0 0 -8px;
  display: flex; align-items: center; justify-content: center;
  border: 0; border-radius: 10px; background: transparent; color: var(--ink-1); cursor: pointer;
}
.ui-panel__back:hover { background: var(--hover-bg); }
.ui-panel__back:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.ui-panel.is-wide .ui-panel__sheet { width: min(640px, 100%); }

/* A page arriving: the body fades in over 160ms with a 6px rise. */
.of-arrive { animation: of-arrive .16s ease both; }
@keyframes of-arrive { from { opacity: 0; transform: translateY(6px); } }
/* Waiting more than 150ms: a thin copper line under the top bar. */
html.is-arriving .shell-top::after {
  content: ""; position: absolute; left: 0; bottom: -1px; height: 2px; width: 40%;
  background: var(--copper-cta);
  animation: of-arriving 1s ease-in-out infinite;
}
@keyframes of-arriving { from { transform: translateX(-100%); } to { transform: translateX(250%); } }
@media (prefers-reduced-motion: reduce) {
  .of-arrive, .of-toasts .of-toast.flash { animation: none; }
  html.is-arriving .shell-top::after { animation: none; width: 100%; opacity: .6; }
}
