/* Forms and phone layouts shared by every layout (UAT 14 Oct 2026: L2W2-13, -15..-20). Tokens only (design.md §3); no motion.
   Behaviour: js/l2w-forms.js (messages, UK dates) and js/l2w-responsive.js (cards, "Show more", filters, tab rows). */

/* ---------- In-app validation messages (l2w-forms.js) ---------- */
.l2w-field-msg { display: flex; align-items: flex-start; gap: var(--l2w-space-1); margin: var(--l2w-space-1) 0 0; font-weight: var(--l2w-weight-medium);
    overflow-wrap: anywhere; }
.l2w-field-msg > .l2w-icon { flex: none; margin-top: .15em; }
:is(.form-control, .form-select, .l2w-field)[aria-invalid="true"] { border-color: var(--l2w-danger); }
:is(.form-control, .form-select)[aria-invalid="true"]:focus { box-shadow: 0 0 0 .2rem var(--l2w-danger-tint); }
input[type="checkbox"][aria-invalid="true"], input[type="radio"][aria-invalid="true"] { outline: 2px solid var(--l2w-danger); outline-offset: 2px; }

/* ---------- UK date box: dd/mm/yyyy text + calendar button over the real (hidden) date field ---------- */
.l2w-date { position: relative; display: block; min-width: 9.5rem; }
.l2w-date > .l2w-date__text { width: 100%; padding-right: 2.5rem; font-variant-numeric: tabular-nums; }
.l2w-date__pick { position: absolute; top: 0; right: 0; bottom: 0; display: inline-grid; place-items: center; width: 2.25rem; padding: 0; border: 0;
    border-radius: 0 var(--l2w-radius-control) var(--l2w-radius-control) 0; background: transparent; color: var(--l2w-text-muted); cursor: pointer; }
.l2w-date__pick:hover { color: var(--l2w-action-strong); background: var(--l2w-action-tint); }
.l2w-date__pick:focus-visible { outline: var(--l2w-focus-outline); outline-offset: -2px; }
.l2w-date__pick[hidden] { display: none; }
/* the real field: present and rendered (so its picker opens beside the button) but invisible and out of the way */
.l2w-date > .l2w-date__native { position: absolute; top: 0; right: 0; bottom: 0; width: 2.25rem; min-width: 0; height: auto; min-height: 0; margin: 0;
    padding: 0; border: 0; opacity: 0; pointer-events: none; }
/* no showPicker() (older Safari): the transparent field itself sits on the button, so a tap opens the browser's picker */
.l2w-date > .l2w-date__native--tap { pointer-events: auto; z-index: 1; cursor: pointer; }
.l2w-date.is-readonly > .l2w-date__text { padding-right: var(--l2w-control-pad-x, 12px); }
/* a reading/working page: the calendar button is a full tap target */
:where([data-density="reading"], [data-density="working"]) .l2w-date__pick { width: var(--l2w-target-min); }
:where([data-density="reading"], [data-density="working"]) .l2w-date > .l2w-date__text { padding-right: calc(var(--l2w-target-min) + 4px); }

/* ---------- Long text in tables (L2W2-16, L2W2-18) ---------- */
/* A cell with a very long unbroken word (a 500-character note, a pasted link) wraps inside its cell instead of pushing the
   table and the page sideways (l2w-responsive.js marks it); it keeps a readable width. */
.l2w-cell--wrap { overflow-wrap: anywhere; word-break: break-word; min-width: 10rem; }
/* "Show more": long notes and messages show 3 lines (data-l2w-clamp="N" for another number); the button opens the whole text. */
.l2w-clamp__body { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: var(--l2w-clamp-lines, 3); line-clamp: var(--l2w-clamp-lines, 3);
    overflow: hidden; overflow-wrap: anywhere; max-width: 40rem; }
.l2w-clamp__more { display: inline-flex; align-items: center; gap: var(--l2w-space-1); margin-top: 2px; padding: 0; border: 0; background: none;
    color: var(--l2w-action-strong); font: inherit; font-size: var(--l2w-text-13); font-weight: var(--l2w-weight-semibold); text-decoration: underline;
    text-underline-offset: 2px; cursor: pointer; }
.l2w-clamp__more[hidden] { display: none; }
.l2w-clamp__more:focus-visible { outline: var(--l2w-focus-outline); outline-offset: 2px; border-radius: 2px; }
:where([data-density="reading"], [data-density="working"]) .l2w-clamp__more { min-height: var(--l2w-target-min); }
.l2w-clamp-dialog { width: min(40rem, calc(100vw - 32px)); max-width: none; }
.l2w-clamp-dialog__text { max-height: 60vh; overflow: auto; overflow-wrap: anywhere; }
.l2w-wrap-anywhere { overflow-wrap: anywhere; word-break: break-word; }

/* ---------- Tables become cards on a phone (table.l2w-table--cards; labels from the header, l2w-responsive.js) ---------- */
@media (max-width: 599.98px) {
    .l2w-table-wrap:has(> table.l2w-table--cards) { overflow-x: visible; }
    table.l2w-table--cards, table.l2w-table--cards > tbody, table.l2w-table--cards > tbody > tr,
    table.l2w-table--cards > tbody > tr > td, table.l2w-table--cards > tbody > tr > th { display: block; width: auto; }
    table.l2w-table--cards > thead { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
    table.l2w-table--cards > tbody > tr { padding: var(--l2w-space-3) var(--l2w-space-4); border-bottom: 1px solid var(--l2w-border); }
    table.l2w-table--cards > tbody > tr:last-child { border-bottom: 0; }
    table.l2w-table--cards > tbody > tr > :is(td, th) { position: relative; height: auto; min-height: 0; padding: var(--l2w-space-1) 0 !important;
        border: 0 !important; box-shadow: none !important; background: transparent; text-align: left !important; white-space: normal !important;
        overflow-wrap: anywhere; min-width: 0; }
    table.l2w-table--cards > tbody > tr > :is(td, th)[data-label]:not([data-label=""]) { padding-left: calc(36% + var(--l2w-space-3)) !important; min-height: 1.6em; }
    table.l2w-table--cards > tbody > tr > :is(td, th)[data-label]:not([data-label=""])::before { content: attr(data-label); position: absolute; left: 0;
        top: var(--l2w-space-1); width: 36%; color: var(--l2w-text-muted); font-size: var(--l2w-text-13); font-weight: var(--l2w-weight-semibold);
        line-height: 1.5; overflow-wrap: anywhere; }
    table.l2w-table--cards > tbody > tr > :is(td, th):empty { display: none; }
    /* the first cell reads as the card's title; row actions sit at the left under it */
    table.l2w-table--cards > tbody > tr > :is(td, th):first-child { font-weight: var(--l2w-weight-semibold); }
    table.l2w-table--cards :is(.l2w-desk__row-actions, .lt-feedback) { justify-content: flex-start; }
    table.l2w-table--cards .l2w-clamp__body { max-width: none; }
}

/* Staging review 29 Oct (PA-17): a family's billing tables (table.l2w-table--cards.l2w-table--cards-md) are cards up to 820 px —
   at 768 the 6-column order table was clipped. The same rules as above, at the wider breakpoint; other tables keep 600 px. */
@media (max-width: 820px) {
    .l2w-table-wrap:has(> table.l2w-table--cards.l2w-table--cards-md) { overflow-x: visible; }
    table.l2w-table--cards.l2w-table--cards-md, table.l2w-table--cards.l2w-table--cards-md > tbody, table.l2w-table--cards.l2w-table--cards-md > tbody > tr,
    table.l2w-table--cards.l2w-table--cards-md > tbody > tr > td, table.l2w-table--cards.l2w-table--cards-md > tbody > tr > th { display: block; width: auto; }
    table.l2w-table--cards.l2w-table--cards-md > thead { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
    table.l2w-table--cards.l2w-table--cards-md > tbody > tr { padding: var(--l2w-space-3) var(--l2w-space-4); border-bottom: 1px solid var(--l2w-border); }
    table.l2w-table--cards.l2w-table--cards-md > tbody > tr:last-child { border-bottom: 0; }
    table.l2w-table--cards.l2w-table--cards-md > tbody > tr > :is(td, th) { position: relative; height: auto; min-height: 0; padding: var(--l2w-space-1) 0 !important;
        border: 0 !important; box-shadow: none !important; background: transparent; text-align: left !important; white-space: normal !important;
        overflow-wrap: anywhere; min-width: 0; }
    table.l2w-table--cards.l2w-table--cards-md > tbody > tr > :is(td, th)[data-label]:not([data-label=""]) { padding-left: calc(36% + var(--l2w-space-3)) !important; min-height: 1.6em; }
    table.l2w-table--cards.l2w-table--cards-md > tbody > tr > :is(td, th)[data-label]:not([data-label=""])::before { content: attr(data-label); position: absolute; left: 0;
        top: var(--l2w-space-1); width: 36%; color: var(--l2w-text-muted); font-size: var(--l2w-text-13); font-weight: var(--l2w-weight-semibold);
        line-height: 1.5; overflow-wrap: anywhere; }
    table.l2w-table--cards.l2w-table--cards-md > tbody > tr > :is(td, th):empty { display: none; }
    /* the first cell reads as the card's title; row actions sit at the left under it */
    table.l2w-table--cards.l2w-table--cards-md > tbody > tr > :is(td, th):first-child { font-weight: var(--l2w-weight-semibold); }
    table.l2w-table--cards.l2w-table--cards-md :is(.l2w-desk__row-actions, .lt-feedback) { justify-content: flex-start; }
    table.l2w-table--cards.l2w-table--cards-md .l2w-clamp__body { max-width: none; }
}

/* ---------- Filter panels fold behind a "Filters" button on a phone (L2W2-19, L2W2-20; l2w-responsive.js) ---------- */
.l2w-btn.l2w-filters-toggle { display: none; }
@media (max-width: 767.98px) {
    .l2w-btn.l2w-filters-toggle { display: inline-flex; margin-bottom: var(--l2w-space-3); }
    .l2w-filters-toggle[aria-expanded="true"] .l2w-filters-toggle__chev { transform: rotate(180deg); }
    .l2w-filters.is-collapsed { display: none !important; }
}
.l2w-filters-toggle__count { padding: 0 6px; border-radius: 999px; background: var(--l2w-action-tint); color: var(--l2w-action-strong); font-size: var(--l2w-text-12); }

/* ---------- Tab rows: one line that scrolls sideways on a phone, with the far edge faded (L2W2-20) ---------- */
@media (max-width: 767.98px) {
    .l2w-tabrow { flex-wrap: nowrap !important; overflow-x: auto; overflow-y: hidden; scrollbar-width: none; overscroll-behavior-x: contain; }
    .l2w-tabrow::-webkit-scrollbar { display: none; }
    .l2w-tabrow > *, .l2w-tabrow .nav-link { flex: none; white-space: nowrap; }
}
/* "There is more this way" (UAT 20 Oct, L2W3-26 again): drawn on the wrapper that does not scroll (.l2w-scrollcue, made by l2w.js
   around every [data-l2w-scroll-hint] row), never as a mask on the scrolling row itself — iPhone WebKit did not paint that mask,
   and a fade over pill text read as a hard cut. Each edge with more beyond it gets a fade into the colour behind the row
   (--l2w-cue-bg, read by l2w.js) and a small chevron; the cue never takes a tap (pointer-events: none). */
.l2w-scrollcue { position: relative; }
.l2w-scrollcue::before, .l2w-scrollcue::after { content: ""; position: absolute; z-index: 1; top: var(--l2w-cue-top, 0); height: var(--l2w-cue-h, 100%);
    width: 2.75rem; pointer-events: none; visibility: hidden; background-repeat: no-repeat; background-size: 16px 16px, 100% 100%; }
.l2w-scrollcue::after { right: 0; background-position: right 2px center, 0 0;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2340586f' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m9 18 6-6-6-6'/%3E%3C/svg%3E"),
        linear-gradient(to right, transparent, var(--l2w-cue-bg, var(--l2w-surface)) 55%); }
.l2w-scrollcue::before { left: 0; background-position: left 2px center, 0 0;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2340586f' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m15 18-6-6 6-6'/%3E%3C/svg%3E"),
        linear-gradient(to left, transparent, var(--l2w-cue-bg, var(--l2w-surface)) 55%); }
.l2w-scrollcue.is-more-end::after, .l2w-scrollcue.is-more-start::before { visibility: visible; }
