/* MBC Hub app styles, layered on brand/tokens/tokens.css and brand/tokens/components.css (brand
   system 5.0.1 "Evergreen"), which templates/base.html loads first. Only the brand's variables are
   used here: no hex values, no new colors, radii, shadows or fonts. Everything 5.0's components
   already do is left to them; patterns they don't cover are marked "New pattern, needs brand
   review" so they can be reviewed against the brand. */

/* ---------- Base text (the brand has no 700 weight and no unclassed heading styles) ---------- */
h1, h2, h3, h4 { font-weight: var(--weight-medium); margin: 0 0 var(--space-2); }
strong, b { font-weight: var(--weight-semibold); }
p { margin: 0 0 var(--space-3); }
a { color: var(--action); }
small { font-size: var(--text-small); line-height: var(--leading-small); }
.pre { white-space: pre-wrap; overflow-wrap: break-word; }
.break { overflow-wrap: anywhere; }
/* Words never break mid-word (brand/BRAND.md, "Layout rules"). A word breaks only when it can't
   fit on a line by itself ("break-word": unlike "anywhere", it never lets a column, a flex item or
   a table shrink below its longest word), so text wraps between words and a table too wide for
   its frame scrolls inside .mbc-table-wrap.is-scroll. UI-5 still holds: a single string wider
   than its column (a long email address, file name or link) breaks where it would otherwise run
   past its box, so it can't make the page wider than a phone; the page head's text column may
   shrink below its longest word for that. .break is only for such a string in a row beside its
   buttons (the share-link and Upload link addresses) and never on a table cell. */
.mbc-main, .signin, .public { overflow-wrap: break-word; }
.mbc-page-head > * { min-width: 0; }
@media (max-width: 639px) {
  /* 5.0's folded cells are white-space: normal; a note keeps its line breaks. */
  .mbc-table.is-stack td.pre { white-space: pre-wrap; }
}
.mono { font-family: var(--font-mono); font-size: var(--text-small); }
/* UI-1: the wrapper is the containing block for absolutely positioned descendants (the
   visually-hidden header labels), so it clips them instead of the page. */
.mbc-table-wrap { position: relative; }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

/* ---------- Icons (templates/_icon.html). New pattern, needs brand review. ----------
   Phosphor Regular, drawn inline at 16, 20 or 24px in the color of the text around them. In a
   line of text the space after the icon separates it from its label; in a flex row the gap does. */
.icon { display: inline-block; flex: none; width: 20px; height: 20px; vertical-align: -0.25em; }
.icon svg { display: block; width: 100%; height: 100%; }
.icon-16 { width: 16px; height: 16px; vertical-align: -0.15em; }
.icon-24 { width: 24px; height: 24px; vertical-align: -0.3em; }

/* ---------- Layout helpers ----------
   A row of buttons is 5.0's .mbc-row. .row stays for rows of record details (a title, a date, a
   pill and a button), which want the tighter 8px between lines and a .grow item that takes the
   space left; the share-link rows' checks find them by it (ui-checks/tests). */
.row { display: flex; flex-wrap: wrap; gap: var(--space-2) var(--space-3); align-items: center; }
.row .grow { flex: 1 1 auto; min-width: 0; }
.mbc-section-head h2 { margin: 0; }
.mbc-section > .mbc-h2 { margin-bottom: var(--space-4); }
.mbc-section > .mbc-card + .mbc-card { margin-top: var(--space-4); }
.mbc-table-wrap + .mbc-field-help { margin-top: var(--space-2); }
.messages { display: flex; flex-direction: column; gap: var(--space-2); margin-bottom: var(--space-6); }
.confirm-form { display: inline; }
.mbc-page-head .mbc-h1 .mbc-pill { vertical-align: middle; margin-left: var(--space-2); }

/* ---------- The logo lockup's width (5.0 sets it with --w; a style attribute would be refused by
   the Content-Security-Policy, hub/middleware.py). 160px, the brand's minimum. ---------- */
.logo-lockup { --w: 160px; }

/* ---------- Buttons ----------
   Long labels wrap instead of widening a phone screen: 5.0's .mbc-btn is one line at a fixed
   height. A tertiary button (text and an arrow, no fill) is a full tap high, as the earlier brand's were 40px,
   so a row of them, or one beside a toggle, never has tap areas that meet; it looks the same.
   New pattern, needs brand review. */
.mbc-btn { white-space: normal; height: auto; min-height: var(--h); padding-block: var(--space-1); line-height: 1.25; text-align: center; }
.mbc-btn-tertiary { min-height: var(--tap-min); }
/* Working state (static/js/app.js adds is-loading, aria-busy and 5.0's three pulsing bars on
   submit): the bars take the icon's place. */
.mbc-btn.is-loading .icon { display: none; }

/* ---------- Alerts (templates/_alert.html): each kind has its icon, which takes the place of
   5.0's dot. New pattern, needs brand review. ---------- */
.mbc-alert.with-icon::before { content: none; }
.mbc-alert .icon { margin-top: 1px; }

/* ---------- Forms: Django widgets get the brand field classes through the ui template tag ---------- */
.form-card { max-width: 560px; }
/* UI-5: a form control is never wider than its field, even where a browser gives a control (such
   as the date picker on an iPhone) a built-in minimum width. */
.mbc-input { min-width: 0; max-width: 100%; }
.mbc-field > p { margin: 0; }
/* ---------- Form actions (brand/BRAND.md, "Layout rules"). New pattern, needs brand review. ----------
   The row of buttons at the bottom of a form: full width and stacked below 640px, at the right from
   640px up. The primary button comes last in the HTML, never moved by CSS, so the order on screen is
   the keyboard's order. */
.form-actions { display: flex; flex-direction: column; gap: var(--space-3); }
@media (min-width: 640px) {
  .form-actions { flex-direction: row; flex-wrap: wrap; justify-content: flex-end; align-items: center; }
}
.search { align-items: flex-end; margin-bottom: var(--space-6); }
.search .mbc-field { flex: 1 1 280px; max-width: 480px; }

/* ---------- Lists of records inside a section or card ---------- */
.records { list-style: none; margin: 0; padding: 0; }
.records > li { padding: var(--space-3) 0; border-bottom: 1px solid var(--border); }
.records > li:last-child { border-bottom: 0; padding-bottom: 0; }
.records > li:first-child { padding-top: 0; }
.records--done { color: var(--text-muted); }
.records--done .title { text-decoration: line-through; }
.mbc-table .cell-action { text-align: right; white-space: nowrap; }
.mbc-table .cell-action form { display: inline; }
/* A status column that ends a table sits at the right, as dates and numbers do with 5.0's .is-num
   (brand/BRAND.md, "Layout rules"); folded on a phone it reads left, as 5.0's folded cells do.
   New pattern, needs brand review. */
.mbc-table .cell-status { text-align: right; }

/* ---------- Status filter row: small outlined buttons, the current one filled. New pattern, needs brand review. ---------- */
.filters { display: flex; flex-wrap: wrap; gap: var(--space-2); margin-bottom: var(--space-6); }
.filters a[aria-current="page"] { background: var(--action-soft); color: var(--on-action-soft); border-color: var(--action-soft); }

/* ---------- Engagement phase strip. New pattern, needs brand review. ----------
   Each label wraps between its words ("Needs / assessment") and never inside one; where the five
   don't fit side by side, the strip wraps onto a second line. On Home the engagement's phase name
   sits at the right of its pillar, above the strip's right end. */
.engagement { max-width: 480px; }
.engagement + .engagement { margin-top: var(--space-3); }
.phases { display: flex; flex-wrap: wrap; gap: 2px; margin-top: var(--space-2); max-width: 480px; }
.phases span { flex: 1; text-align: center; font: var(--weight-medium) 11px/16px var(--font-sans); padding: var(--space-1) 2px; background: var(--surface-sunken); color: var(--text-muted); border: 1px solid var(--border); border-radius: var(--radius-xs); }
.phases .done { background: var(--action-soft); color: var(--on-action-soft); border-color: transparent; }
.phases .current { background: var(--action); color: var(--on-action); border-color: transparent; }

/* ---------- Collapsible add-forms (session entry, file upload, upload instructions) ---------- */
details.add { margin-bottom: var(--space-4); }
details.add summary { cursor: pointer; color: var(--action); font: var(--weight-medium) var(--text-small)/1.43 var(--font-sans); min-height: 24px; }
details.add[open] summary { margin-bottom: var(--space-4); }
/* Room above a toggle that follows a row of buttons, so their 44px hit areas (below) never meet. */
.mbc-row + details.add { margin-top: var(--space-4); }
details.done-list summary { cursor: pointer; color: var(--text-muted); font: var(--weight-medium) var(--text-small)/1.43 var(--font-sans); margin: var(--space-4) 0; }

/* ---------- File picker (templates/_file_picker.html, static/js/app.js "File picker") ----------
   "Choose files" is full width: new pattern, needs brand review. The drop area appears only when
   the script marks the picker droppable (a computer with a mouse); dragging files over it changes
   its border style and text, not only its color. */
.file-picker [hidden] { display: none; }
.file-picker__area { display: flex; flex-direction: column; gap: var(--space-2); }
.file-picker[data-droppable] .file-picker__area { padding: var(--space-4); border: 2px dashed var(--border-strong); border-radius: var(--radius-md); background: var(--surface-raised); text-align: center; }
.file-picker[data-droppable] .file-picker__area.is-dragover { border-style: solid; border-color: var(--action); background: var(--action-soft); }
.file-picker__hint { margin: 0; color: var(--text); font: var(--weight-regular) 16px/24px var(--font-sans); }
.file-picker__choose { width: 100%; }
.file-picker__list { list-style: none; margin: 0; padding: 0; }
.file-picker__item { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-1) var(--space-3); padding: var(--space-2) 0; border-bottom: 1px solid var(--border); }
.file-picker__item:last-child { border-bottom: 0; }
.file-picker__name { flex: 1 1 12rem; min-width: 0; }

/* ---------- Share links under a file, and the upload-link box ----------
   The addresses are text that wraps (UI-5), not a text box that cuts them off; "Copy link" copies
   them (data-copy in static/js/app.js). */
.share-links { display: flex; flex-direction: column; gap: var(--space-2); margin: var(--space-3) 0 0; }
.share-links .row { gap: var(--space-2); }
/* An address as wide as it needs: beside its buttons when they fit, otherwise on a line of its own,
   where it breaks only if it is wider than that line (UI-5). */
.link-address { flex: 1 1 auto; min-width: 0; }
.linkbox { display: flex; flex-wrap: wrap; gap: var(--space-2); align-items: center; margin-bottom: var(--space-3); }
.select-inline { width: auto; min-width: 120px; }

/* ---------- Quick add (Action items on the client page) ----------
   UI-5: on a phone the fields stack one per line at full width, so no field is sized by its own
   content and nothing can sit on top of the Due date. Same breakpoint as .mbc-finding in
   brand/tokens/components.css. */
@media (max-width: 599px) {
  .quick-add .row { flex-direction: column; align-items: stretch; }
  .quick-add .row .mbc-btn { align-self: flex-start; }
}

/* ---------- Tap targets (UI-2). New pattern, needs brand review. ----------
   Buttons, navigation links, the logo link and the add, done and Menu toggles get an invisible hit
   area of at least 44 x 44px (--tap-min), centered on the control; the visible sizes stay the
   brand's (5.0's small and tertiary buttons are shorter). ::before is free on these: 5.0 draws the
   tertiary arrow with ::after. Inputs and selects are 48px tall in 5.0. */
.mbc-btn, .mbc-nav a, .mbc-sidebar-home, details > summary { position: relative; }
.mbc-btn::before, .mbc-nav a::before, .mbc-sidebar-home::before, details > summary::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 100%;
  height: 100%;
  min-width: var(--tap-min);
  min-height: var(--tap-min);
  transform: translate(-50%, -50%);
}

/* ---------- Phone menu (templates/base.html). New pattern, needs brand review. ----------
   Below 768px the sidebar is a top bar: the logo, and a Menu button (a <summary>) that opens the
   navigation, with Account and Log out under it, without any script. The button's words say
   whether the menu is open. From 768px up static/js/app.js opens the menu and the button is
   hidden, so the sidebar works as before. Where the browser can style a closed <details>
   (::details-content), the menu shows at once and the button is hidden even before the script
   runs; anywhere else, a closed menu keeps its button, so the navigation is never out of reach. */
.sidebar-menu > summary { list-style: none; }
.sidebar-menu > summary::-webkit-details-marker { display: none; }
.sidebar-menu[open] .when-closed, .sidebar-menu:not([open]) .when-open { display: none; }
@media (max-width: 767px) {
  .mbc-sidebar { position: relative; }
  .mbc-sidebar .sidebar-menu-toggle { position: absolute; top: var(--space-4); right: 20px; }
  .sidebar-menu[open] .mbc-nav { margin-top: var(--space-4); }
  .sidebar-menu:not([open]) ~ .mbc-sidebar-foot { display: none; }
}
@media (min-width: 768px) {
  .mbc-sidebar .sidebar-menu[open] > .sidebar-menu-toggle { display: none; }
}
@supports selector(::details-content) {
  @media (min-width: 768px) {
    .sidebar-menu::details-content { display: block; content-visibility: visible; }
    .mbc-sidebar .sidebar-menu-toggle { display: none; }
  }
}

/* ---------- Article body (Markdown): 5.0's .mbc-prose, plus what Markdown can produce that it
   doesn't style. New pattern, needs brand review. ---------- */
.mbc-prose h1 { font: var(--weight-medium) var(--text-h2)/var(--leading-h2) var(--font-sans); letter-spacing: var(--tracking-h2); margin-top: var(--space-10); }
.mbc-prose h4 { font: var(--weight-medium) var(--text-body)/var(--leading-body) var(--font-sans); margin-top: var(--space-6); }
.mbc-prose img { max-width: 100%; }

/* ---------- Public pages: client upload, expired link, error pages ---------- */
.public { max-width: 560px; margin: 0 auto; padding: var(--space-12) 20px var(--space-16); display: flex; flex-direction: column; gap: var(--space-6); box-sizing: border-box; }
.public .mbc-page-head { margin-bottom: 0; }

/* ---------- Centered moments (brand/BRAND.md, "Layout rules"): short, single-purpose screens and
   blocks are centered; working screens stay left. ----------
   .public--centered: the error pages, the share link that is no longer available, and the Send
   files page's three short states (too many attempts, link turned off, files received); the
   upload form itself stays left. New pattern, needs brand review. */
.public--centered { align-items: center; text-align: center; }
/* Centered, a block is only as wide as its words, so it is capped at the column's width: a client's
   name too long for a phone still wraps (UI-5) instead of widening the page. */
.public--centered > *, .public--centered .mbc-page-head > * { max-width: 100%; }
.public--centered .mbc-page-head { flex-direction: column; align-items: center; }

/* ---------- Sign-in pages (templates/registration/). New pattern, needs brand review. ----------
   An evergreen panel (templates/_signin_panel.html) with the white logo, the page head and the
   rise in its bottom right corner; the form sits on the page ground below it on phones and beside
   it on wide screens. The panel's bottom padding keeps the rise clear of the text: the rise is
   --rise-width wide and about 1.2 times as tall, with an eighth of its width below it, plus room to breathe. "Confirm
   it's you" (.in-app) keeps the sidebar, so its panel has no logo and no page inset. */
.signin { display: grid; gap: var(--space-8); padding: var(--panel-inset); min-height: 100vh; align-content: start; box-sizing: border-box; }
.signin.in-app { min-height: 0; padding: 0; gap: var(--space-6); }
.signin-panel { --rise-width: 24%; display: flex; flex-direction: column; gap: var(--space-8); padding-bottom: calc(var(--rise-width) * 1.45); }
.signin-panel > :not(.mbc-rise) { position: relative; z-index: 1; }
.signin-panel .mbc-lead { color: var(--text-muted); }
/* The panel's head is centered (brand/BRAND.md, "Layout rules"); the logo and the form are not. */
.signin-head { text-align: center; }
.signin-head .mbc-eyebrow { margin-bottom: var(--space-2); }
.signin-head .mbc-lead { margin-top: var(--space-3); }
.signin-body { width: 100%; max-width: 440px; margin: 0 auto; padding: 0 20px var(--space-12); display: flex; flex-direction: column; gap: var(--space-6); box-sizing: border-box; }
.signin.in-app .signin-body { max-width: 560px; margin: 0; padding: 0; }
@media (min-width: 1024px) {
  .signin { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-content: stretch; }
  .signin-panel { --rise-width: 34%; }
  .signin-body { align-self: center; padding: var(--space-12) var(--space-6); }
  .signin.in-app { align-items: start; }
  .signin.in-app .signin-body { padding: 0; }
}

/* ---------- The dashboard's evergreen lead tile, with the rise. New pattern, needs brand review. ----------
   The rise sits small in the tile's bottom right corner, behind the number and label, in 5.0's tonal
   colors (templates/_rise.html, tone="tonal"): darker than the tile's olive corner, so the label
   reads over it at about 8.5:1 and has the whole width of the tile, as the other tiles' labels do. */
.stat-lead { position: relative; overflow: hidden; --rise-width: 22%; --rise-right: 8%; }
.stat-lead > :not(.mbc-rise) { position: relative; z-index: 1; }

/* ---------- The dashboard's Next step (brand/BRAND.md, "Gold"). New pattern, needs brand review. ----------
   One soft card between the tiles and the action items: the one action item to do next, with 5.0's
   gold Next step pill on its name line, and how many open action items are on time. The bar is an
   SVG whose filled part is as wide as the on-time count in a viewBox as wide as the open count, so
   it needs no style attribute (the Content-Security-Policy refuses them, hub/middleware.py) and no
   script; 5.0's .mbc-stat-progress gives its track, and its fill is the color 5.0 gives the bar. The
   words beside it carry the meaning; the bar is hidden from screen readers. */
.next-step { display: grid; gap: var(--space-3); }
.next-step .mbc-card-title { margin: 0; }
.ontime { display: grid; gap: var(--space-2); max-width: 480px; }
.ontime .mbc-stat-progress { margin-top: 0; }
.ontime svg { display: block; width: 100%; height: 100%; }
.ontime rect { fill: var(--leaf); }

/* ---------- Motion (brand/BRAND.md, "Component rules", Motion). New pattern, needs brand review. ----------
   In MBC Hub only the rise moves as a screen opens: once each time a screen opens, and one rise per
   screen, on the sign-in panel or the dashboard's lead tile (templates/_rise.html; brand
   components.css draws it). Sections and alerts appear in place. Hover and press feedback stays:
   navigation icons move 3px on hover (5.0 moves the tertiary button's arrow and lifts linked cards
   itself). Under reduced motion nothing moves. */
.mbc-nav a .icon { transition: translate var(--duration-micro) var(--ease-settle); }
.mbc-nav a:hover .icon { translate: 3px 0; }
@media (prefers-reduced-motion: reduce) {
  .mbc-nav a .icon { transition: none; }
}

/* ---------- Authenticator setup and recovery codes (hub/mfa.py). New pattern, needs brand review. ----------
   The QR code is segno's SVG, drawn inside the page. Its modules and background use the two values
   that stay the same in the light and dark themes (dark olive on cream), so the code always scans
   as dark on light, with its quiet zone. The CSS stroke overrides the stroke color segno writes on
   the path. */
.mfa-qr-frame { align-self: flex-start; background: var(--mbc-cream); padding: var(--space-2); border: 1px solid var(--border); border-radius: var(--radius-sm); line-height: 0; }
.mfa-qr { display: block; width: calc(var(--space-16) * 4); max-width: 100%; height: auto; }
.mfa-qr__modules { stroke: var(--brand-olive); shape-rendering: crispEdges; }
.mfa-key p { margin: 0; }
.mfa-key__value { font-size: 16px; }
.mfa-codes { list-style: none; margin: 0; padding: var(--space-4); display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-2) var(--space-6); background: var(--surface-sunken); border-radius: var(--radius-sm); font-size: 16px; }
