/* feat-w6-mobile.css - wave 6: phone shell (slim top bar, bottom tab bar, sheets) + Theme sheet. Phone = max-width 640px.
   Tokens live in app.css (:root): --dms-density-*, --dms-bottom-offset. html[data-text-size|data-density|data-theme] set by index.html. */

/* ---------- sheets + avatar menu (all widths) ---------- */
.w6-back { position: fixed; inset: 0; z-index: 8800; background: rgba(10, 15, 22, .45); }
.w6-back.clear { background: transparent; }
.w6-sheet, .w6-menu {
  position: fixed; z-index: 8810; background: var(--surface); color: var(--text); border: 1px solid var(--border);
  box-shadow: 0 10px 32px rgba(0, 0, 0, .28); overflow: auto; overscroll-behavior: contain;
}
.w6-sheet {
  left: 0; right: 0; bottom: 0; max-height: 80vh; border-radius: 16px 16px 0 0; border-width: 1px 0 0 0;
  padding: .25rem .5rem calc(.75rem + env(safe-area-inset-bottom, 0px)); animation: w6-up .2s ease-out;
}
@media (min-width: 641px) {
  .w6-sheet { left: 50%; right: auto; bottom: auto; top: 20vh; width: min(26rem, 94vw); transform: translateX(-50%); border-radius: var(--radius); border-width: 1px; padding-bottom: .75rem; animation: none; }
}
.w6-menu { top: 56px; right: .5rem; width: min(20rem, calc(100vw - 1rem)); max-height: calc(100vh - 72px); border-radius: var(--radius); padding: .3rem; }
@keyframes w6-up { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .w6-sheet { animation: none; } }
.w6-sheethead { display: flex; align-items: center; gap: .5rem; padding: .5rem .5rem .1rem; }
.w6-sheethead h2 { margin: 0; flex: 1; }
.w6-x { min-height: 36px; min-width: 36px; padding: 0; border-radius: 50%; font-size: 1.3rem; line-height: 1; }
.w6-note { margin: 0 .5rem .4rem; }
.w6-who { display: flex; align-items: center; gap: .7rem; padding: .55rem .6rem .65rem; border-bottom: 1px solid var(--border); margin-bottom: .2rem; }
.w6-who b { display: block; line-height: 1.2; }
.w6-av {
  display: inline-flex; align-items: center; justify-content: center; border-radius: 50%; flex: none;
  background: var(--accent-soft); color: var(--accent); font-weight: 700; width: 34px; height: 34px; font-size: .85rem;
}
.w6-av.big { width: 42px; height: 42px; font-size: 1rem; }
.w6-mi {
  display: flex; align-items: center; gap: .7rem; width: 100%; min-height: var(--dms-density-row); padding: 0 .7rem; border: 0;
  border-radius: 10px; background: transparent; color: var(--text); font-weight: 600; text-align: left; justify-content: flex-start;
}
.w6-mi:hover, .w6-mi:focus-visible { background: var(--surface-2); text-decoration: none; }
.w6-mi .ico { color: var(--muted); width: 20px; height: 20px; flex: none; }
.w6-mi > span:not(.w6-noico) { flex: 1; display: flex; align-items: center; gap: .4rem; min-width: 0; }
.w6-sep { height: 1px; background: var(--border); margin: .3rem .6rem; }
.w6-noico { width: 20px; height: 20px; flex: none; }
.w6-sheet:focus, .w6-menu:focus { outline: none; }
.w6-mi.active { background: var(--accent-soft); color: var(--accent); }
.w6-mi.active .ico { color: var(--accent); }
.w6-mi.danger { color: var(--bad); }
.w6-mi.danger .ico { color: var(--bad); }
.w6-setting { padding: .35rem .5rem .55rem; }
.w6-setlbl { font-weight: 600; font-size: .9rem; margin-bottom: .3rem; }
.w6-seg { display: flex; gap: 0; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; background: var(--surface-2); }
.w6-seg button { flex: 1; border: 0; border-radius: 0; background: transparent; min-height: var(--dms-density-tap); padding: 0 .4rem; font-weight: 600; color: var(--muted); }
.w6-seg button + button { border-left: 1px solid var(--border); }
.w6-seg button.on { background: var(--accent); color: var(--accent-fg); }
/* colour theme swatches: two per row on a phone, four on a wide screen */
.w6-swnote { margin: 0 0 .45rem; }
.w6-swgrid { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; }
@media (min-width: 641px) { .w6-swgrid { grid-template-columns: repeat(4, 1fr); } }
.w6-sw {
  display: flex; flex-direction: column; align-items: stretch; justify-content: flex-start; gap: .3rem; min-width: 0; height: auto; min-height: 44px;
  padding: .3rem .3rem .4rem; border: 2px solid var(--border); border-radius: 12px; background: var(--surface); color: var(--text); font-weight: 600; font-size: .82rem; text-align: left;
}
.w6-sw.on { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.w6-sw:hover { background: var(--surface-2); }
.w6-swprev { display: block; height: 44px; border-radius: 8px; border: 1px solid; padding: 6px 8px; overflow: hidden; }
.w6-swcard { display: block; position: relative; height: 100%; border-radius: 5px; padding: 5px 6px; }
.w6-swcard i { display: block; height: 4px; width: 70%; border-radius: 2px; opacity: .85; margin-bottom: 3px; }
.w6-swcard i.s { width: 42%; opacity: .5; }
.w6-swcard b { position: absolute; right: 5px; bottom: 4px; width: 16px; height: 8px; border-radius: 4px; }
.w6-swlbl { display: block; line-height: 1.15; overflow-wrap: anywhere; }
.w6-sw.on .w6-swlbl::after { content: " \2713"; color: var(--accent); }
html.w6-overlay body { overflow: hidden; }

/* ---------- hidden on wide screens: desktop keeps the header it always had ---------- */
.w6-searchbtn, .tabbar { display: none; }
.w6-avatar { display: none; }
.w6-avatar.w6-wide { display: inline-flex; }
.w6-iconbtn { width: 44px; min-width: 44px; height: 44px; min-height: 44px; padding: 0; border-radius: 50%; border: 0; background: transparent; color: var(--text); }
.w6-avatar { background: var(--accent-soft); color: var(--accent); font-weight: 700; font-size: .85rem; box-shadow: inset 0 0 0 5px var(--surface); }
.w6-avatar:hover { background: var(--accent-soft); }

/* ---------- phone ---------- */
@media (max-width: 640px) {
  html.has-tabbar { --w6-tabbar-h: 58px; --dms-bottom-offset: calc(var(--w6-tabbar-h) + env(safe-area-inset-bottom, 0px)); }

  /* 1. one slim top bar (52px): icon, company, spacer, search, bell, avatar */
  .topbar-inner { position: relative; flex-wrap: nowrap; height: 52px; padding: 0 .35rem 0 .6rem; gap: .1rem; }
  .navstrip { display: none; }
  .brand { order: 1; margin-right: .2rem; }
  .brand > span:last-child { display: none; }
  .brand svg { width: 32px; height: 32px; }
  .topbar-inner > select, .topbar-inner > .chip { order: 2; max-width: 6.4rem; min-height: 36px; font-size: .9rem; padding: .2rem .45rem; flex: 0 1 auto; }
  .spacer { order: 3; }
  .w6-searchbtn { order: 4; display: inline-flex; }
  .topbar-inner .pwa-bell { order: 5; width: 44px; min-width: 44px; height: 44px; min-height: 44px; padding: 0; border-radius: 50%; border-color: transparent; background: transparent; }
  .w6-avatar { order: 6; display: inline-flex; }
  .topbar-inner .pwa-install, .topbar-inner button.signout, .topbar-inner .gsearch { display: none; }
  .topbar-inner .w5-badge { top: 4px; right: 2px; }
  /* the "?" button stays in the DOM as the anchor of the tour help menu but is not shown; its entry is in the avatar menu */
  .topbar-inner .ux-help { position: absolute; right: .5rem; top: 100%; width: 44px; height: 2px; min-height: 0; padding: 0; opacity: 0; pointer-events: none; overflow: hidden; border: 0; }
  /* search icon -> the box opens in place of the bar contents */
  .topbar-inner.w6-search-open .gsearch { display: flex; align-items: center; gap: .3rem; position: absolute; inset: 0; z-index: 3; max-width: none; padding: 0 .5rem; background: var(--surface); }
  .topbar-inner.w6-search-open .gsearch input { flex: 1; min-width: 0; min-height: 40px; }
  .topbar-inner.w6-search-open .gsearch .pop { left: .5rem; right: .5rem; top: calc(100% + 2px); }
  .w6-search-x { width: 40px; min-width: 40px; height: 40px; min-height: 40px; padding: 0; border-radius: 50%; font-size: 1.4rem; line-height: 1; border: 0; background: transparent; }

  /* 2. hide on scroll down, back on scroll up */
  .topbar { transition: transform .2s ease; }
  .topbar.w6-hidden { transform: translateY(-100%); }
  @media (prefers-reduced-motion: reduce) { .topbar { transition: none; } }

  /* 3. bottom tab bar */
  .tabbar {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 60; background: var(--surface); border-top: 1px solid var(--border);
    padding: 0 env(safe-area-inset-right, 0px) env(safe-area-inset-bottom, 0px) env(safe-area-inset-left, 0px);
  }
  .tabbar a, .tabbar button {
    position: relative; flex: 1 1 0; min-width: 0; height: var(--w6-tabbar-h, 58px); min-height: 44px; padding: 4px 2px 3px; border: 0; border-radius: 0;
    background: transparent; color: var(--muted); font-weight: 600; font-size: .72rem; line-height: 1.1;
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; text-decoration: none;
  }
  .tabbar .ico { width: 1.5rem; height: 1.5rem; vertical-align: baseline; }
  .tabbar .w6-tl { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .tabbar a.active, .tabbar button.active { color: var(--accent); }
  .tabbar a.active::before, .tabbar button.active::before { content: ""; position: absolute; top: 0; left: 22%; right: 22%; height: 3px; border-radius: 0 0 3px 3px; background: var(--accent); }
  .tabbar .badge { position: absolute; top: 3px; left: calc(50% + 4px); min-width: 1.1rem; padding: 0 .3rem; line-height: 1.1rem; font-size: .68rem; }
  /* floating things sit above the tab bar (anything new: bottom: calc(var(--dms-bottom-offset) + 1rem)) */
  html.has-tabbar #dms-widgets { bottom: calc(var(--dms-bottom-offset) + .75rem); }
  html.has-tabbar .ux-prompt { bottom: calc(var(--dms-bottom-offset) + .75rem); }
  html.has-tabbar .w5-next { bottom: calc(var(--dms-bottom-offset) + .75rem); }
  html.has-tabbar .pwa-card { bottom: calc(var(--dms-bottom-offset) + 1rem); }
  html.has-tabbar .pwa-toast { bottom: calc(var(--dms-bottom-offset) + 5rem); }
  html.has-tabbar #toasts { bottom: calc(var(--dms-bottom-offset) + .75rem); }
  .w6-sheet, .w6-menu { z-index: 8810; }

  /* 4. type: 15px body (html font-size), 20px titles, 44px tap targets; inputs stay 16px or iOS zooms the page on focus */
  h1 { font-size: 1.35rem; }
  h2 { font-size: 1.08rem; }
  h3 { font-size: .98rem; }
  input, select, textarea { font-size: max(16px, 1rem); }
  .topbar select { font-size: max(16px, .9rem); }
  .nav a, .chips a, .chips button { min-height: 44px; }
  .tabs { gap: 0 .1rem; margin-bottom: .6rem; }
  .tabs a { min-height: 44px; display: inline-flex; align-items: center; padding: 0 .6rem; font-size: .95rem; }
  .check { min-height: 44px; }

  /* 5. page title area */
  main { padding: .6rem .7rem; }
  .crumbs { margin-bottom: .15rem; font-size: .8rem; }
  .pagehead { gap: .3rem .6rem; }
  .pagehead .row, .cardhead .row { gap: .4rem; }
  .pagehead > .row { flex-wrap: wrap; flex: 1 1 100%; } /* document actions: one wrapping row under the title */
  button, .btn { padding: 0 .9rem; }
  .tile .n { font-size: 1.6rem; }
  /* filter rows made only of drop-downs (documents list): two per row instead of one per row */
  .form-grid.two:not(:has(input, textarea)) { grid-template-columns: 1fr 1fr; }
  .form-grid.two > * { min-width: 0; }
}
@media print { .tabbar, .w6-back, .w6-sheet, .w6-menu { display: none !important; } }

/* ---------- Documents list: folded filters (phones) ---------- */
.filt-toggle { display: none; }
.filt-wrap .filt-body { display: block; }
@media (max-width: 640px) {
  .filt-card { gap: .5rem; }
  .filt-toggle {
    display: flex; align-items: center; gap: .5rem; width: 100%; min-height: 44px; padding: 0 .75rem; text-align: left; justify-content: flex-start;
    border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2); color: var(--text); font-weight: 600;
  }
  .filt-lbl { flex: none; }
  .filt-badge { flex: none; min-width: 1.4rem; height: 1.4rem; padding: 0 .4rem; border-radius: 999px; background: var(--accent); color: var(--accent-fg); font-size: .8rem; line-height: 1.4rem; text-align: center; }
  .filt-badge[hidden] { display: none; }
  .filt-sum { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-weight: 500; font-size: .9rem; }
  .filt-chev { flex: none; transition: transform .2s ease; color: var(--muted); }
  .filt-wrap.open .filt-chev { transform: rotate(180deg); }
  /* smooth height change without measuring: a grid row that animates between 0fr and 1fr */
  .filt-wrap .filt-body { display: grid; grid-template-rows: 0fr; visibility: hidden; transition: grid-template-rows .22s ease, visibility 0s linear .22s; }
  .filt-wrap.open .filt-body { grid-template-rows: 1fr; visibility: visible; transition: grid-template-rows .22s ease, visibility 0s; }
  .filt-wrap, .filt-body { min-width: 0; max-width: 100%; }
  .filt-inner { min-height: 0; min-width: 0; overflow: hidden; }
  .filt-wrap.open .filt-inner { overflow: visible; }
  @media (prefers-reduced-motion: reduce) { .filt-wrap .filt-body, .filt-chev { transition: none; } }
}
/* Compact density: document rows a little tighter */
html[data-density="compact"] .doccard { padding: calc(var(--dms-density-card) * .65) var(--dms-density-card); }
html[data-density="compact"] .doccard + .doccard { margin-top: calc(var(--dms-density-gap) * .45); }
html[data-density="compact"] .doccard .t { margin: .05rem 0 .2rem; line-height: 1.25; }
html[data-density="compact"] .doccard .row { gap: .3rem .5rem; }
html[data-density="compact"] .tablewrap td { padding-top: calc(var(--dms-density-cell) * .75); padding-bottom: calc(var(--dms-density-cell) * .75); }

/* link cue (Kae Shyong 2026-10-17: tappable text must look clickable): content links are underlined; breadcrumb, file and
   document-number links get a small arrow. Buttons, tabs, nav, tiles and whole-card links are left alone. */
main a:not(.btn):not(.tile):not(.tab):not([class*="card"]):not(.nav a):not(.tabs a):not(.chips a) { text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 2px; }
main .crumbs a::after, main td a::after, main .timeline a::after { content: " \203A"; text-decoration: none; display: inline-block; }

/* file drop zone: long-pressing its text must not start text selection (iPhone showed Copy / Look Up instead of the picker,
   Kae Shyong video 2026-10-17 23:13); the whole zone is one big tap target */
.ux-dz, .ux-dz * { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.ux-dz { cursor: pointer; -webkit-tap-highlight-color: transparent; }
