auth

Main authentication module for my projects
git clone git://git.finwo.net/app/auth
Log | Files | Refs

commit 52e82c6ab208309ba422f2a133509696c87f0ae5
parent 981d3a348f7fab13bd4cf3d442fe58e5a847dd90
Author: finwo <finwo@pm.me>
Date:   Tue, 10 Nov 2026 00:35:13 +0100

css: drop-in framework, verify:css harness, email-domains port (T1)

Diffstat:
Mapp/account/package.json | 3++-
Mapp/account/src/screen/account.tsx | 4++--
Mapp/account/src/screen/overview.tsx | 4++--
Mapp/account/src/screen/security.tsx | 2+-
Mapp/admin/package.json | 3++-
Mapp/admin/src/assets/admin.css | 60------------------------------------------------------------
Mapp/admin/src/main.ts | 6+++---
Mapp/admin/src/screen/email-domains.tsx | 142++++++++++++++++++++++++++++++++++++++-----------------------------------------
Mapp/admin/src/screen/sessions.tsx | 4++--
Mapp/login/package.json | 3++-
Mapp/shared/component/modal.tsx | 2+-
Aapp/shared/component/select-menu.css | 152+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mapp/shared/component/select-menu.tsx | 2+-
Mapp/shared/style/global.css | 2145++++++++++++++++++++++++++++++++-----------------------------------------------
Dapp/shared/style/select-menu.css | 150-------------------------------------------------------------------------------
Mmockup/plain/account.html | 6+++---
Mmockup/plain/error-pages.html | 2+-
Amockup/plain/mockups.css | 64++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Atools/css-check/align.mjs | 319+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Atools/css-check/check.mjs | 526+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Atools/css-check/fixtures/email-domains.html | 83+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
21 files changed, 2089 insertions(+), 1593 deletions(-)

diff --git a/app/account/package.json b/app/account/package.json @@ -3,7 +3,8 @@ "private": true, "type": "module", "scripts": { - "build": "node esbuild.cjs" + "build": "node esbuild.cjs", + "verify:css": "node ../../tools/css-check/check.mjs --scope app --app account" }, "dependencies": { "lucide": "^1.61.0", diff --git a/app/account/src/screen/account.tsx b/app/account/src/screen/account.tsx @@ -180,9 +180,9 @@ export const Account: m.Component = { } document.title = page === 'security' - ? 'Security · Account' + ? 'Security \u00B7 Account' : page === 'apps' - ? 'Apps · Account' + ? 'Apps \u00B7 Account' : 'Account'; }, diff --git a/app/account/src/screen/overview.tsx b/app/account/src/screen/overview.tsx @@ -97,7 +97,7 @@ export const OverviewPage: m.Component<OverviewAttrs> = { </span> </span> <span class="summary-arrow" aria-hidden="true"> - › + {'\u203A'} </span> </a> </li> @@ -118,7 +118,7 @@ export const OverviewPage: m.Component<OverviewAttrs> = { </span> </span> <span class="summary-arrow" aria-hidden="true"> - › + {'\u203A'} </span> </a> </li> diff --git a/app/account/src/screen/security.tsx b/app/account/src/screen/security.tsx @@ -48,7 +48,7 @@ export const SecurityPage: m.Component = { {Icon(Monitor)} <span> <strong>Current session</strong> - <span>account · This device · Active</span> + <span>account {'\u00B7'} This device {'\u00B7'} Active</span> </span> <span class="status">Read-only</span> </div> diff --git a/app/admin/package.json b/app/admin/package.json @@ -3,7 +3,8 @@ "private": true, "type": "module", "scripts": { - "build": "node esbuild.cjs" + "build": "node esbuild.cjs", + "verify:css": "node ../../tools/css-check/check.mjs --scope app --app admin" }, "dependencies": { "lucide": "^1.61.0", diff --git a/app/admin/src/assets/admin.css b/app/admin/src/assets/admin.css @@ -107,43 +107,6 @@ padding-bottom: 0.75rem; } -.domain-name { - font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace; - font-size: 0.8125rem; - overflow-wrap: anywhere; -} - -.domain-status { - display: inline-flex; - align-items: center; - gap: 0.4rem; - color: var(--muted); - font-size: 0.8125rem; -} - -.domain-status-dot { - width: 0.4375rem; - height: 0.4375rem; - flex: none; - border-radius: 50%; - background: var(--muted); -} - -.domain-status.is-pending { - color: var(--warn); -} - -.domain-status.is-pending .domain-status-dot { - background: var(--warn); -} - -.domain-row-action { - display: flex; - align-items: center; - flex-wrap: wrap; - gap: 0.125rem; -} - .verify-record-name, .verify-record-value { font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace; @@ -156,29 +119,6 @@ margin-top: 0.5rem; } -@media (min-width: 40em) { - .domain-table { - table-layout: fixed; - } - - .domain-table .domain-status-column { - width: 12rem; - } - - .domain-table .domain-action-column { - width: 14rem; - } - - .domain-table td.domain-action-column:not(:empty) { - padding-bottom: 0.75rem; - } - - .domain-row-action { - flex-wrap: nowrap; - justify-content: flex-start; - } -} - .realm-display { color: inherit; text-decoration: none; diff --git a/app/admin/src/main.ts b/app/admin/src/main.ts @@ -1,11 +1,11 @@ +import '@style/global.css'; +import './assets/admin.css'; + import m from 'mithril'; import { applyTheme, getTheme } from '@util/theme'; import { Admin, AdminCallback } from './screen/admin'; import { getBasePath } from './util/api'; -import '@style/global.css'; -import './assets/admin.css'; - const routes: m.RouteDefs = { '/': { render: () => m(Admin, {}), diff --git a/app/admin/src/screen/email-domains.tsx b/app/admin/src/screen/email-domains.tsx @@ -393,7 +393,7 @@ export const EmailDomainsPage: m.Component<EmailDomainsAttrs> = { <div class="alert" role="alert"> <p>{this.error.message}</p> <button - class="button-secondary" + class="button button-secondary" type="button" onclick={() => { if (realmSlug) { @@ -425,9 +425,9 @@ export const EmailDomainsPage: m.Component<EmailDomainsAttrs> = { <div class="skeleton skeleton-short"></div> </div> ) : ( - <section class="table-panel domain-table-panel" aria-label="Realm email domains"> - <div class="table-toolbar"> - <div class="table-search"> + <section class="card" aria-label="Realm email domains"> + <div class="toolbar toolbar-panel"> + <div class="toolbar-search"> <input type="search" value={this.search} @@ -439,77 +439,73 @@ export const EmailDomainsPage: m.Component<EmailDomainsAttrs> = { /> </div> {canManage ? ( - <div class="table-actions"> - <button class="button" type="button" onclick={() => this.openAdd()}> + <div class="toolbar-actions"> + <button class="button button-primary" type="button" onclick={() => this.openAdd()}> Add email domain </button> </div> ) : null} </div> - <div class="data-table-wrap"> - <table class="data-table data-table-static domain-table"> - <thead> + <table class="table table-fixed"> + <thead> + <tr> + <th scope="col">Domain</th> + <th scope="col" style="--col-w: 14rem">Status</th> + {canManage ? <th scope="col" style="--col-w: 14rem">Actions</th> : null} + </tr> + </thead> + <tbody> + {visible.map((entry: AdminRealmEmailDomain) => ( <tr> - <th class="data-table-primary domain-name-column" scope="col">Domain</th> - <th class="domain-status-column" scope="col">Status</th> - {canManage ? <th class="domain-action-column" scope="col">Actions</th> : null} - </tr> - </thead> - <tbody> - {visible.map((entry: AdminRealmEmailDomain) => ( - <tr> - <td class="data-table-primary domain-name-column" data-label="Domain"> - <span class="domain-name">{entry.domain}</span> - </td> - <td class="domain-status-column" data-label="Status"> - <span - class={ - entry.status === 'pending' - ? 'domain-status is-pending' - : 'domain-status' - } + <td data-label="Domain"> + <span class="table-mono">{entry.domain}</span> + </td> + <td data-label="Status"> + <span + class={ + entry.status === 'pending' + ? 'status status-warn' + : 'status' + } + > + <span class="status-dot" aria-hidden="true"></span> + {statusLabel(entry.status)} + </span> + </td> + {canManage ? ( + <td data-label="Actions"> + {entry.status === 'pending' ? ( + <button + class="button-inline" + type="button" + onclick={() => this.openVerify(entry)} + > + Verify + </button> + ) : null} + <button + class="button-inline button-inline-danger" + type="button" + onclick={() => this.openRemove(entry.domain)} > - <span class="domain-status-dot" aria-hidden="true"></span> - {statusLabel(entry.status)} - </span> + Remove + </button> </td> - {canManage ? ( - <td class="domain-action-column" data-label="Actions"> - <div class="domain-row-action"> - {entry.status === 'pending' ? ( - <button - class="action-button is-primary" - type="button" - onclick={() => this.openVerify(entry)} - > - Verify - </button> - ) : null} - <button - class="action-button is-danger" - type="button" - onclick={() => this.openRemove(entry.domain)} - > - Remove - </button> - </div> - </td> - ) : null} - </tr> - ))} - </tbody> - </table> - {domains.length > 0 && visible.length === 0 ? ( - <div class="empty"> - <p>No email domains match this search.</p> - </div> - ) : domains.length === 0 ? ( - <div class="empty"> - <p>No email domains are assigned to this realm.</p> - </div> - ) : null} - </div> + ) : null} + </tr> + ))} + </tbody> + </table> + {domains.length > 0 && visible.length === 0 ? ( + <div class="empty"> + <p>No email domains match this search.</p> + </div> + ) : domains.length === 0 ? ( + <div class="empty"> + <p>No email domains are assigned to this realm.</p> + </div> + ) : null} </section> )} @@ -554,14 +550,14 @@ export const EmailDomainsPage: m.Component<EmailDomainsAttrs> = { <div class="modal-actions"> <button - class="button-secondary" + class="button button-secondary" type="button" disabled={this.creating} onclick={() => this.resetAdd()} > Cancel </button> - <button class="button" type="submit" disabled={this.creating}> + <button class="button button-primary" type="submit" disabled={this.creating}> {this.creating ? 'Adding' : 'Add domain'} </button> </div> @@ -601,7 +597,7 @@ export const EmailDomainsPage: m.Component<EmailDomainsAttrs> = { /> <div class="verify-copy-row"> <button - class="button-secondary" + class="button button-secondary" type="button" onclick={() => this.copyToken()} > @@ -617,7 +613,7 @@ export const EmailDomainsPage: m.Component<EmailDomainsAttrs> = { <div class="modal-actions"> <button - class="button-secondary" + class="button button-secondary" type="button" disabled={this.verifying} onclick={() => this.resetVerify()} @@ -625,7 +621,7 @@ export const EmailDomainsPage: m.Component<EmailDomainsAttrs> = { Close </button> <button - class="button" + class="button button-primary" type="button" disabled={this.verifying} onclick={() => this.submitVerify()} @@ -671,7 +667,7 @@ export const EmailDomainsPage: m.Component<EmailDomainsAttrs> = { <div class="modal-actions"> <button - class="button-secondary" + class="button button-secondary" type="button" disabled={this.removing} onclick={() => this.resetRemove()} @@ -679,7 +675,7 @@ export const EmailDomainsPage: m.Component<EmailDomainsAttrs> = { Cancel </button> <button - class="button-danger" + class="button button-danger" type="button" disabled={ this.removing || diff --git a/app/admin/src/screen/sessions.tsx b/app/admin/src/screen/sessions.tsx @@ -220,7 +220,7 @@ export const SessionsPage: m.Component<SessionsAttrs> = { <p class="session-user"> {session.user.username} {session.user.status !== 'active' - ? ` · ${session.user.status}` + ? ` \u00B7 ${session.user.status}` : ''} </p> </div> @@ -265,7 +265,7 @@ export const SessionsPage: m.Component<SessionsAttrs> = { <div class="session-actions"> {session.revoked_at ? null : this.confirmKey === realmKey ? ( <div class="confirm"> - <span>Revoke this realm’s access?</span> + <span>Revoke this realm's access?</span> <button class="button" type="button" diff --git a/app/login/package.json b/app/login/package.json @@ -4,7 +4,8 @@ "type": "module", "scripts": { "build": "node esbuild.cjs", - "assets:hex": "node scripts/generate-hex-grid.js" + "assets:hex": "node scripts/generate-hex-grid.js", + "verify:css": "node ../../tools/css-check/check.mjs --scope app --app login" }, "dependencies": { "lucide": "^1.61.0", diff --git a/app/shared/component/modal.tsx b/app/shared/component/modal.tsx @@ -38,7 +38,7 @@ export const Modal: m.Component<ModalAttrs> = { view({ attrs, children }) { return ( <div - class="modal-overlay" + class="overlay" onmousedown={(event: MouseEvent) => { if (event.target === event.currentTarget) attrs.onClose(); }} diff --git a/app/shared/component/select-menu.css b/app/shared/component/select-menu.css @@ -0,0 +1,152 @@ +@layer components { + .select { + min-width: 0; + max-width: 100%; + display: block; + } + + .select-trigger { + width: 100%; + min-width: 0; + max-width: 100%; + display: flex; + align-items: center; + justify-content: space-between; + gap: 0.75rem; + padding: 0.5rem 0.75rem; + border: 0; + border-bottom: 1pt solid var(--field-line); + border-radius: 0; + background: var(--surface); + color: inherit; + font: inherit; + font-size: 0.875rem; + line-height: 1.5; + text-align: left; + cursor: pointer; + } + + .select-trigger:focus, + .select-trigger:focus-visible, + .select-trigger[aria-expanded="true"], + .select-trigger[aria-expanded="true"]:focus-visible { + outline: 0; + border-bottom-color: var(--accent); + } + + .select-trigger:disabled { + color: var(--muted); + cursor: default; + opacity: 1; + } + + .select-trigger svg { + flex: none; + width: 1.125rem; + height: 1.125rem; + } + + .select-value { + min-width: 0; + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; + } + + .select-list { + position: fixed; + top: 0; + left: 0; + z-index: 120; + width: 10rem; + max-width: calc(100vw - 1rem); + max-height: min(18rem, 45vh); + padding: 0.25rem 0; + overflow-y: auto; + overscroll-behavior: contain; + background: var(--surface); + box-shadow: var(--shadow); + color: var(--text); + } + + .select-list.is-measuring { + visibility: hidden; + top: 0; + right: auto; + bottom: auto; + left: 0; + width: auto; + max-height: none; + } + + .select-option { + width: 100%; + min-height: 2.25rem; + display: flex; + align-items: center; + gap: 0; + padding: 0.5rem 0.75rem; + color: inherit; + font-size: 0.875rem; + line-height: 1.5; + cursor: pointer; + } + + .select-option-mark { + width: 1.25rem; + height: 1.25rem; + flex: none; + display: flex; + align-items: center; + justify-content: center; + order: 2; + } + + .select-option svg { + width: 1.125rem; + height: 1.125rem; + } + + .select-option:not(.is-selected) .select-option-mark svg { + visibility: hidden; + } + + .select-option-label { + min-width: 0; + flex: 1; + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; + } + + .select-option:hover { + background: var(--line-strong); + } + + .select-option.is-active { + background: var(--line-strong); + } + + .select-option.is-selected { + color: var(--accent-text); + } + + @media (pointer: coarse) { + .select-trigger, + .select-option { + min-height: 2.75rem; + padding-block: 0.5rem; + touch-action: manipulation; + } + + .select-trigger { + font-size: 1rem; + } + } + + @media (min-width: 40em) { + .select.select-auto { + width: auto; + } + } +} diff --git a/app/shared/component/select-menu.tsx b/app/shared/component/select-menu.tsx @@ -1,7 +1,7 @@ import { Check, ChevronDown } from 'lucide'; import m from 'mithril'; import { Icon } from '@component/icon'; -import '@style/select-menu.css'; +import './select-menu.css'; let nextSelectId = 0; diff --git a/app/shared/style/global.css b/app/shared/style/global.css @@ -1,1284 +1,430 @@ -:root { - font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif; - --canvas: #f3f3f3; - --page: #fff; - --surface: #fff; - --sidebar: #000; - --sidebar-active: #333; - --topbar: #000; - --text: #1b1b1b; - --muted: #656a70; - --accent: #25a; - --accent-hover: color-mix(in oklch, var(--accent), white 16%); - --accent-active: color-mix(in oklch, var(--accent), black 18%); - --accent-text: var(--accent); - --accent-text-hover: var(--accent-hover); - --accent-text-active: var(--accent-active); - --on-accent: #fff; - --menu-hover: #8884; - --row: #00000008; - --row-hover: #0000000d; - --skeleton: #00000012; - --danger: #c9190b; - --danger-text: #c9190b; - --warn: #9a6700; - --field-line: rgba(0, 0, 0, 0.42); - --shadow: 0 0.125em 0.25em #0008; - --hex: url('./assets/hex-grid-light.svg'); - --topbar-height: 3.5rem; -} - -*, -*::before, -*::after { - box-sizing: border-box; -} - -html { - -webkit-text-size-adjust: 100%; - text-size-adjust: 100%; -} - -html, -body { - margin: 0; - padding: 0; -} - -body { - background: var(--canvas); - color: var(--text); - -webkit-font-smoothing: antialiased; -} - -html.modal-open body, -html.mobile-nav-open body { - overflow: hidden; -} - -button, -input, -select, -textarea { - font: inherit; -} - -.app-shell { - min-height: 100vh; - min-height: 100svh; -} - -.topbar { - position: sticky; - top: 0; - z-index: 40; - display: flex; - align-items: center; - justify-content: space-between; - gap: 1rem; - min-height: var(--topbar-height); - padding: env(safe-area-inset-top) max(1.5rem, env(safe-area-inset-right)) 0 - max(1.5rem, env(safe-area-inset-left)); - background: var(--topbar); - color: rgba(255, 255, 255, 0.76); - font-size: 0.875rem; -} - -.brand { - display: flex; - align-items: center; - gap: 0.75rem; - color: #fff; - text-decoration: none; -} - -.brand-icon { - flex: none; - width: 1.125rem; - height: 1.125rem; -} - -.brand-name { - font-size: 1.125rem; - font-weight: 500; - line-height: 1.3; -} - -.topbar-actions { - display: flex; - align-items: center; - gap: 0.75rem; -} - -.topbar .user-menu { - display: none; -} - -.app { - display: grid; - grid-template-columns: minmax(0, 1fr); - grid-template-rows: minmax(0, 1fr); - min-height: calc(100vh - var(--topbar-height)); - min-height: calc(100svh - var(--topbar-height)); -} - -.sidebar { - min-width: 0; - display: none; - flex-direction: column; - background: var(--sidebar); - color: #fff; -} - -.nav { - min-width: 0; - display: flex; - flex-direction: row; - flex-wrap: nowrap; - overflow-x: auto; - padding: 0.75rem 0; - scrollbar-width: none; -} - -.nav::-webkit-scrollbar { - display: none; -} - -.nav-label { - display: none; - margin: 0; - padding: 0.5rem 1.5rem; - color: rgba(255, 255, 255, 0.46); - font-size: 0.6875rem; - font-weight: 600; - letter-spacing: 0.08em; - text-transform: uppercase; -} - -.nav-item { - min-width: 0; - display: flex; - align-items: center; - justify-content: center; - gap: 0.75rem; - flex: 1 1 0; - padding: 0.6875rem 0.5rem; - color: rgba(255, 255, 255, 0.82); - font-size: 0.875rem; - line-height: 1.4; - text-align: center; - text-decoration: none; - cursor: pointer; - touch-action: manipulation; - user-select: none; - -webkit-tap-highlight-color: transparent; -} - -.nav-item span { - position: absolute; - width: 1pt; - height: 1pt; - padding: 0; - margin: -1pt; - overflow: hidden; - clip-path: inset(50%); - white-space: nowrap; - border: 0; -} - -.nav-item svg { - flex: none; - width: 1.125rem; - height: 1.125rem; -} - -.nav-item:hover, -.nav-item:active { - background: var(--menu-hover); - color: #fff; -} - -.nav-item.is-active { - background: var(--sidebar-active); - box-shadow: inset 0 0.25rem 0 var(--accent); - color: #fff; -} - -.mobile-nav-toggle { - position: relative; - display: grid; - place-items: center; - width: 2.5rem; - height: 2.5rem; - padding: 0; - border: 0; - background: transparent; - color: rgba(255, 255, 255, 0.86); - cursor: pointer; - touch-action: manipulation; - user-select: none; - -webkit-tap-highlight-color: transparent; -} - -.mobile-nav-toggle:hover, -.mobile-nav-toggle.is-open { - color: #fff; -} - -.mobile-nav-toggle-bars, -.mobile-nav-toggle-bars::before, -.mobile-nav-toggle-bars::after { - position: absolute; - width: 1.25rem; - height: 1pt; - background: currentColor; - transition: transform 0.3s ease; -} - -.mobile-nav-toggle-bars::before, -.mobile-nav-toggle-bars::after { - content: ''; - left: 0; -} - -.mobile-nav-toggle-bars::before { - top: -0.5rem; -} - -.mobile-nav-toggle-bars::after { - top: 0.5rem; -} - -.mobile-nav-toggle.is-open .mobile-nav-toggle-bars { - background: transparent; -} - -.mobile-nav-toggle.is-open .mobile-nav-toggle-bars::before { - transform: translateY(0.5rem) rotate(45deg); -} - -.mobile-nav-toggle.is-open .mobile-nav-toggle-bars::after { - transform: translateY(-0.5rem) rotate(-45deg); -} - -.mobile-nav { - position: fixed; - top: calc(var(--topbar-height) + env(safe-area-inset-top)); - right: max(0rem, env(safe-area-inset-right)); - bottom: 0; - left: max(0rem, env(safe-area-inset-left)); - z-index: 30; - overflow-y: auto; - overscroll-behavior: contain; - background: var(--sidebar); - color: #fff; - visibility: hidden; - opacity: 0; - transform: translateX(100%); - pointer-events: none; - transition: - transform 0.3s ease, - opacity 0.2s ease, - visibility 0.3s; -} - -html.mobile-nav-open .mobile-nav { - visibility: visible; - opacity: 1; - transform: none; - pointer-events: auto; -} - -.mobile-nav .nav { - min-width: 0; - min-height: 0; - flex-direction: column; - flex-wrap: nowrap; - overflow: visible; - padding: 1rem max(1.5rem, env(safe-area-inset-right)) - calc(1rem + env(safe-area-inset-bottom)) - max(1.5rem, env(safe-area-inset-left)); - gap: 0.25rem; -} - -.mobile-nav .nav-label { - display: block; - padding: 0.5rem 0; -} - -.mobile-nav .nav-item { - width: 100%; - flex: none; - justify-content: flex-start; - padding-inline: 1rem; - text-align: left; - opacity: 0; - transform: translateX(2rem); - transition: - opacity 0.2s ease 0.2s, - transform 0.3s ease 0.2s; -} - -html.mobile-nav-open .mobile-nav .nav-item { - opacity: 1; - transform: none; -} - -.mobile-nav .nav-item span { - position: static; - width: auto; - height: auto; - margin: 0; - overflow: visible; - clip-path: none; - display: inline; - white-space: normal; -} - -.mobile-nav-divider { - height: 1pt; - margin: 1rem 1.5rem; - background: rgba(255, 255, 255, 0.18); -} - -.mobile-nav-account { - margin: 0 1.5rem calc(1rem + env(safe-area-inset-bottom)); -} - -.mobile-nav-account .user-summary { - padding-inline: 0; -} - -.mobile-nav-account .user-menu-list { - padding: 0; -} - -.main { - display: flex; - flex-direction: column; - min-width: 0; -} - -.content { - width: 100%; - max-width: 72rem; - margin: 0 auto; - padding: 1.75rem clamp(1rem, 4vw, 2rem) calc(3rem + env(safe-area-inset-bottom)); -} - -.page-header { - margin-bottom: 1.5rem; -} - -.page-header h1 { - margin: 0; - font-size: 1.5rem; - font-weight: 400; - line-height: 1.3; -} - -.page-header p { - margin: 0.25rem 0 0; - color: var(--muted); - font-size: 0.875rem; - line-height: 1.5; -} - -.page-header-row { - display: grid; - grid-template-columns: minmax(0, 1fr); - align-items: start; - gap: 1rem; -} - -.grid { - display: grid; - grid-template-columns: minmax(0, 1fr); - gap: 1rem; -} - -.panel { - min-width: 0; - max-width: 100%; - padding: 1.5rem; - background: var(--surface); - box-shadow: var(--shadow); -} - -.panel-wide { - grid-column: 1 / -1; - margin-top: 1rem; -} - -.panel h2 { - margin: 0 0 1.25rem; - font-size: 1.0625rem; - font-weight: 500; - line-height: 1.4; -} - -.details { - display: grid; - gap: 0.875rem; - margin: 0; -} - -.details > div { - display: grid; - grid-template-columns: minmax(0, 1fr); - gap: 1rem; -} - -.details dt { - color: var(--muted); - font-size: 0.875rem; - line-height: 1.5; -} - -.details dd { - margin: 0; - overflow-wrap: anywhere; - font-size: 0.875rem; - line-height: 1.5; -} - -.note { - margin: 0; - color: var(--muted); - font-size: 0.875rem; - line-height: 1.6; -} - -.panel-header { - display: flex; - align-items: flex-start; - justify-content: space-between; - gap: 1rem; - margin-bottom: 1rem; -} - -.panel-header h2 { - margin: 0; -} - -.panel-header .note { - margin-top: 0.25rem; -} - -.button, -.button-secondary, -.button-danger { - display: inline-block; - padding: 0.625rem 1.25rem; - border: 0; - border-radius: 0; - background: var(--accent); - color: var(--on-accent); - font: inherit; - font-size: 0.8125rem; - font-weight: 500; - letter-spacing: 0.05em; - line-height: 1.4; - text-align: center; - text-decoration: none; - text-transform: uppercase; - cursor: pointer; -} - -.button:hover { - background: var(--accent-hover); -} - -.button:active { - background: var(--accent-active); -} - -.button-secondary { - background: transparent; - color: var(--accent-text); -} - -.button-secondary:hover { - background: var(--row-hover); - color: var(--accent-text-hover); -} - -.button-secondary:active { - background: var(--row); - color: var(--accent-text-active); -} - -.button-danger { - background: var(--danger); - color: #fff; -} - -.button-danger:hover { - background: var(--danger); - filter: brightness(1.08); -} - -.button:disabled, -.button-secondary:disabled, -.button-danger:disabled { - cursor: default; - opacity: 0.55; -} - -.alert { - margin: 0 0 1rem; - color: var(--danger-text); - font-size: 0.875rem; - line-height: 1.5; -} - -.alert p { - margin: 0 0 0.5rem; -} - -.notice { - margin: 0 0 1rem; - padding: 0.75rem 1rem; - background: var(--row); - color: var(--text); - font-size: 0.875rem; - line-height: 1.5; -} - -.loading { - color: var(--muted); - font-size: 0.875rem; -} - -.empty { - padding: 1.5rem; - background: var(--surface); - box-shadow: var(--shadow); -} - -.empty p { - margin: 0; - color: var(--muted); - font-size: 0.875rem; - line-height: 1.6; -} - -.skeleton { - height: 0.75rem; - background: var(--skeleton); -} - -.skeleton + .skeleton { - margin-top: 0.75rem; -} - -.skeleton-title { - width: 8rem; - height: 1rem; -} - -.skeleton-short { - width: 35%; -} - -.user-menu { - position: relative; -} - -.user-menu summary { - display: grid; - place-items: center; - width: 2.25rem; - height: 2.25rem; - color: rgba(255, 255, 255, 0.86); - list-style: none; - cursor: pointer; - user-select: none; -} - -.user-menu summary::-webkit-details-marker { - display: none; -} - -.user-menu summary::marker { - content: ''; -} - -.user-menu summary:hover, -.user-menu[open] summary { - color: #fff; -} - -.user-menu summary svg { - width: 1.5rem; - height: 1.5rem; -} - -.user-panel { - position: absolute; - top: 2.75rem; - right: 0; - z-index: 10; - width: min(15rem, calc(100vw - 2rem)); - max-width: calc(100vw - 2rem); - background: var(--sidebar); - color: #fff; - box-shadow: var(--shadow); -} - -.user-summary { - display: grid; - gap: 0.125rem; - padding: 0.875rem 1rem; -} - -.user-name { - font-size: 0.875rem; - font-weight: 500; - line-height: 1.4; -} - -.user-meta { - color: rgba(255, 255, 255, 0.56); - font-size: 0.75rem; - line-height: 1.4; -} - -.user-menu-list { - display: flex; - flex-direction: column; - padding: 0.5rem 0; -} - -.user-menu-item { - display: flex; - align-items: center; - gap: 0.75rem; - width: 100%; - padding: 0.625rem 1rem; - border: 0; - background: transparent; - color: rgba(255, 255, 255, 0.82); - font: inherit; - font-size: 0.875rem; - line-height: 1.4; - text-align: left; - text-decoration: none; - cursor: pointer; - user-select: none; -} - -.user-menu-item svg { - flex: none; - width: 1.125rem; - height: 1.125rem; -} - -.user-menu-item:hover, -.user-menu-item:active { - background: var(--menu-hover); - color: #fff; -} - -.user-menu-value { - margin-left: auto; - color: rgba(255, 255, 255, 0.56); - font-size: 0.75rem; -} - -.status-page { - display: grid; - place-items: center; - min-height: 100vh; - min-height: 100svh; - padding: env(safe-area-inset-top) env(safe-area-inset-right) - calc(1rem + env(safe-area-inset-bottom)) env(safe-area-inset-left); - background: var(--surface); - color: var(--text); -} - -.status-panel { - position: relative; - width: min(calc(100% - 2rem), 28rem); - padding: 2rem; - background: var(--surface); -} - -.status-panel h1 { - margin: 0 0 1rem; - padding-right: 3rem; - font-size: 1.5rem; - font-weight: 400; - line-height: 1.3; -} - -.status-icon { - position: absolute; - top: 2rem; - right: 2rem; - width: 2rem; - height: 2rem; - color: currentColor; -} - -.spinner { - position: absolute; - top: 2rem; - right: 2rem; - width: 2rem; - height: 2rem; - border: 0.1875rem solid var(--skeleton); - border-top-color: var(--text); - border-radius: 50%; - animation: spin 1s linear infinite; -} - -@keyframes spin { - to { - transform: rotate(360deg); +@layer tokens, base, primitives, components, themes, apps, mockups; + +/* ========================================================================== + tokens: the only layer (besides themes) allowed to carry literal colors. + ========================================================================== */ +@layer tokens { + :root { + /* color: surfaces and ink */ + --canvas: #f3f3f3; + --surface: #fff; + --text: #1b1b1b; + --muted: #656a70; + --line: #00000008; /* hairline separators */ + --line-strong: #0000000d; /* hover fills / raised */ + --field-line: rgba(0,0,0,.42); + + /* color: brand */ + --accent: #2555aa; + --accent-hover: color-mix(in oklch, var(--accent), white 16%); + --accent-active: color-mix(in oklch, var(--accent), black 18%); + --accent-text: var(--accent); + --accent-text-hover: var(--accent-hover); + --on-accent: #fff; + --accent-tint: color-mix(in oklch, var(--accent) 12%, transparent); + + /* color: semantic */ + --danger: #c9190b; + --danger-text: var(--danger); + --danger-tint: color-mix(in oklch, var(--danger) 12%, transparent); + --warn: #9a6700; + + /* color: shell chrome */ + --sidebar: #000; + --sidebar-active: #333; + --topbar: #000; + --on-chrome: #fff; + --chrome-text: rgba(255,255,255,.76); + --chrome-item: rgba(255,255,255,.82); + --chrome-label: rgba(255,255,255,.46); + --chrome-toggle: rgba(255,255,255,.86); + --chrome-divider: rgba(255,255,255,.18); + --menu-hover: #8884; + + /* color: scrim and fills */ + --overlay: rgba(0,0,0,.58); + --skeleton: #00000012; + + /* assets */ + --hex: url("./assets/hex-grid-light.svg"); + + /* font stack */ + --font-sans: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, + Oxygen, Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif; + + /* type scale */ + --font-xs: .75rem; /* labels, table column headers */ + --font-sm: .8125rem; /* secondary/meta, inline action buttons */ + --font-base: .875rem; /* body copy, table cell text (DEFAULT) */ + --font-md: 1rem; /* toolbar search, emphasized body */ + --font-lg: 1.0625rem; /* panel headings */ + --font-xl: 1.125rem; /* brand wordmark */ + --font-2xl: 1.5rem; /* page title (h1) */ + --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace; + + --lh-tight: 1.3; + --lh-snug: 1.4; + --lh-base: 1.5; + --lh-loose: 1.6; + --lh-body: var(--lh-base); /* the one line-height every table cell uses */ + + /* spacing scale (0.25rem step) */ + --space-1: .25rem; + --space-2: .5rem; + --space-3: .75rem; + --space-4: 1rem; + --space-5: 1.25rem; + --space-6: 1.5rem; + --space-8: 2rem; + + /* radius */ + --radius-0: 0; /* buttons are square by design */ + --radius-sm: .25rem; /* small interactive surfaces */ + --radius-pill: 999px; /* reserved: avatars/dots, NOT chips */ + + /* control + table metrics */ + --topbar-height: 3.5rem; + --control-h: 2.75rem; /* touch/primary form control height */ + --cell-y: var(--space-3); /* .75rem desktop cell padding */ + --cell-x: var(--space-6); /* 1.5rem desktop cell padding */ + + /* elevation */ + --shadow: 0 .125em .25em #0008; + + /* motion */ + --dur-1: 120ms; + --dur-2: 180ms; + --ease: cubic-bezier(.2,0,0,1); + } +} + +/* ========================================================================== + base: reset, typography, app shell, focus, motion, touch. + ========================================================================== */ +@layer base { + *, + *::before, + *::after { + box-sizing: border-box; + } + + html { + font-family: var(--font-sans); + -webkit-text-size-adjust: 100%; + text-size-adjust: 100%; + } + + html, + body { + margin: 0; + padding: 0; } -} - -.status-note { - margin: 0; - color: var(--muted); - font-size: 0.875rem; - line-height: 1.6; -} - -.status-error { - margin: 0; - color: var(--danger-text); - font-size: 0.875rem; - line-height: 1.6; -} - -.status-actions { - display: grid; - gap: 1rem; - margin-top: 1.5rem; -} - -.status-actions > .button, -.status-actions > .button-secondary, -.status-actions > .button-danger { - justify-content: center; - text-align: center; -} - -.sr-only { - position: absolute; - width: 1pt; - height: 1pt; - padding: 0; - margin: -1pt; - overflow: hidden; - clip: rect(0, 0, 0, 0); - white-space: nowrap; - border: 0; -} - -.table-panel { - color: var(--text); -} - -.table-toolbar { - display: flex; - flex-direction: column; - gap: 1rem; - margin-bottom: 1rem; - padding: 1rem; - background: var(--surface); - box-shadow: var(--shadow); -} - -.table-search { - flex: 1; - min-width: 0; -} - -.table-search input { - width: 100%; - padding: 0.5rem 0; - border: 0; - border-bottom: 1pt solid var(--field-line); - border-radius: 0; - background: transparent; - color: inherit; - font: inherit; - font-size: 1rem; - line-height: 1.5; - outline: none; -} - -.table-search input:focus { - border-bottom-color: var(--accent); -} - -.table-actions { - display: flex; - justify-content: flex-end; - flex-wrap: wrap; - gap: 1rem; -} - -.data-table-wrap { - overflow: visible; -} - -.data-table { - display: block; - min-width: 0; - width: 100%; - border-collapse: collapse; - font-size: 0.875rem; -} - -.data-table thead { - display: none; -} - -.data-table tbody, -.data-table tbody tr, -.data-table td { - display: block; - width: 100%; -} - -.data-table tbody tr, -.data-table-static tbody tr { - min-height: 2.75rem; - margin-bottom: 1rem; - padding: 1rem; - background: var(--surface); - box-shadow: var(--shadow); -} - -.data-table tbody tr:last-child, -.data-table-static tbody tr:last-child { - margin-bottom: 0; -} - -.data-table th, -.data-table td { - display: block; - padding: 0.5rem 0; - border: 0; - text-align: left; - vertical-align: middle; -} - -.data-table td[data-label]::before { - content: attr(data-label); - display: block; - margin-bottom: 0.25rem; - color: var(--muted); - font-size: 0.75rem; - font-weight: 500; - letter-spacing: 0.08em; - text-transform: uppercase; -} - -.data-table td:last-child { - padding-bottom: 0; -} - -.data-table th { - color: var(--muted); - font-size: 0.75rem; - font-weight: 500; - letter-spacing: 0.08em; - text-transform: uppercase; -} - -.data-table tbody tr { - cursor: pointer; -} - -.data-table tbody tr:hover { - background: var(--row-hover); -} - -.data-table tbody tr:focus-visible { - outline: 2pt solid var(--accent); - outline-offset: -2pt; -} - -.data-table-static tbody tr { - cursor: default; -} - -.data-table tbody tr:last-child td { - border-bottom: 0; -} - -.data-table .table-icon-column { - display: none; -} - -.data-table-primary { - min-width: 0; - margin-bottom: 0.75rem; - padding-bottom: 0.75rem; - border-bottom: 1pt solid var(--row); -} - -.data-table-sub { - display: block; - margin-top: 0.125rem; - color: var(--muted); - font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace; - font-size: 0.8125rem; - overflow-wrap: anywhere; -} - -.data-table-status { - display: block; - margin-top: 0.125rem; - color: var(--muted); - font-size: 0.8125rem; -} - -.table-icon { - display: grid; - place-items: center; - width: 2rem; - height: 2rem; - flex: none; - overflow: hidden; - background: var(--row); - color: var(--muted); -} - -.table-icon img { - width: 100%; - height: 100%; - object-fit: contain; -} - -.table-icon svg { - width: 1.125rem; - height: 1.125rem; -} - -/* Data tables embedded inside a panel: align to panel content, use row rules */ -.panel .table-toolbar { - padding: 0; - margin: 1.25rem 0 1rem; - background: transparent; - box-shadow: none; - border-bottom: 0; -} - -.panel .data-table tbody tr { - padding: 0; - background: transparent; - box-shadow: none; -} -.panel .data-table th, -.panel .data-table td { - padding-right: 0; - padding-left: 0; -} - -.panel .data-table tbody tr:last-child td { - border-bottom: 0; -} - -.modal-overlay { - position: fixed; - inset: 0; - z-index: 100; - display: grid; - place-items: end center; - padding: 0; - background: rgba(0, 0, 0, 0.58); - touch-action: manipulation; -} - -.modal { - width: 100%; - max-height: 100vh; - max-height: calc(100dvh - env(safe-area-inset-top)); - overflow: auto; - overscroll-behavior: contain; - border-top: 0.25rem solid var(--accent); - background: var(--surface); - color: var(--text); - box-shadow: var(--shadow); -} - -.modal-header { - display: flex; - align-items: flex-start; - justify-content: space-between; - gap: 1rem; - padding: 1rem 1rem 0; -} - -.modal-header h2 { - margin: 0; - font-size: 1.25rem; - font-weight: 400; - line-height: 1.3; -} - -.modal-close { - display: grid; - place-items: center; - width: 2rem; - height: 2rem; - padding: 0; - border: 0; - border-radius: 0; - background: transparent; - color: var(--muted); - cursor: pointer; -} - -.modal-close:hover { - color: var(--text); -} - -.modal-close svg { - width: 1.25rem; - height: 1.25rem; -} + body { + background: var(--canvas); + color: var(--text); + -webkit-font-smoothing: antialiased; + } -.modal-body { - padding: 1rem 1rem calc(1rem + env(safe-area-inset-bottom)); -} + html.modal-open body, + html.mobile-nav-open body { + overflow: hidden; + } -.modal-note { - margin: 0; - color: var(--muted); - font-size: 0.875rem; - line-height: 1.6; -} + button, + input, + select, + textarea { + font: inherit; + } -.modal-actions { - position: sticky; - bottom: 0; - display: flex; - flex-wrap: wrap; - justify-content: flex-end; - gap: 0.5rem; - margin: 1rem -1rem calc(-1rem - env(safe-area-inset-bottom)); - padding: 1rem 1rem calc(1rem + env(safe-area-inset-bottom)); - background: var(--surface); - border-top: 1pt solid var(--row); -} + img, + svg { + display: block; + } -.modal-actions > .button, -.modal-actions > .button-secondary, -.modal-actions > .button-danger { - flex: 1; - justify-content: center; - text-align: center; -} + h1 { margin: 0 0 var(--space-4); font-size: var(--font-2xl); } + h2 { margin: 0 0 var(--space-4); font-size: var(--font-lg); } + h3 { margin: 0 0 var(--space-4); font-size: var(--font-md); } + h4 { margin: 0 0 var(--space-4); font-size: var(--font-base); } + h1, h2, h3, h4 { font-weight: 500; line-height: var(--lh-tight); } -a:focus-visible, -button:focus-visible, -summary:focus-visible, -select:focus-visible { - outline: 2pt solid var(--accent); - outline-offset: 2pt; -} + :focus-visible { + outline: 2pt solid var(--accent); + outline-offset: 2px; + } -@media (min-width: 35em) { - .status-page { - background-color: var(--page); - background-image: var(--hex); - background-position: center; - background-repeat: no-repeat; - background-size: cover; + .sr-only { + position: absolute; + width: 1pt; + height: 1pt; + padding: 0; + margin: -1pt; + overflow: hidden; + clip: rect(0, 0, 0, 0); + white-space: nowrap; + border: 0; } - .status-panel { - box-shadow: var(--shadow); + /* app shell: the stable frame every surface builds on */ + .app-shell { + min-height: 100vh; + min-height: 100svh; } - .status-actions { + .topbar { + position: sticky; + top: 0; + z-index: 40; display: flex; - justify-content: flex-end; align-items: center; + justify-content: space-between; + gap: var(--space-4); + min-height: var(--topbar-height); + padding: env(safe-area-inset-top) max(var(--space-6), env(safe-area-inset-right)) 0 + max(var(--space-6), env(safe-area-inset-left)); + background: var(--topbar); + color: var(--chrome-text); + font-size: var(--font-base); } - .status-actions > .button, - .status-actions > .button-secondary, - .status-actions > .button-danger { - flex: 0 auto; - } -} - -@media (min-width: 40em) { - .table-panel { - background: var(--surface); - box-shadow: var(--shadow); - } - - .table-toolbar { - flex-direction: row; + .brand { + display: flex; align-items: center; - margin-bottom: 0; - padding: 1rem 1.5rem; - background: transparent; - box-shadow: none; - border-bottom: 1pt solid var(--row); + gap: var(--space-3); + color: var(--on-chrome); + text-decoration: none; } - .data-table-wrap { - overflow-x: auto; + .brand-icon { + flex: none; + width: var(--font-xl); + height: var(--font-xl); } - .data-table { - display: table; - font-size: 0.875rem; + .brand-name { + font-size: var(--font-xl); + font-weight: 500; + line-height: var(--lh-tight); } - .data-table thead { - display: table-header-group; + .topbar-actions { + display: flex; + align-items: center; + gap: var(--space-3); } - .data-table tbody { - display: table-row-group; + .app { + display: grid; + grid-template-columns: minmax(0, 1fr); + grid-template-rows: minmax(0, 1fr); + min-height: calc(100vh - var(--topbar-height)); + min-height: calc(100svh - var(--topbar-height)); } - .data-table tbody tr, - .data-table-static tbody tr { - display: table-row; - min-height: 0; - margin-bottom: 0; - padding: 0; - background: transparent; - box-shadow: none; + .sidebar { + min-width: 0; + display: none; + flex-direction: column; + background: var(--sidebar); + color: var(--on-chrome); } - .data-table tbody tr:hover { - background: var(--row-hover); + .nav { + min-width: 0; + display: flex; + flex-direction: row; + flex-wrap: nowrap; + overflow-x: auto; + padding: var(--space-3) 0; + scrollbar-width: none; } - .data-table-static tbody tr:hover { - background: transparent; + .nav::-webkit-scrollbar { + display: none; } - .data-table th, - .data-table td { - display: table-cell; - padding: 0.75rem 1.5rem; - border-bottom: 1pt solid var(--row); + .nav-label { + display: none; + margin: 0; + padding: var(--space-2) var(--space-6); + color: var(--chrome-label); + font-size: .6875rem; + font-weight: 600; + letter-spacing: .08em; + text-transform: uppercase; } - .data-table td[data-label]::before { - content: none; + .nav-item { + min-width: 0; + display: flex; + align-items: center; + justify-content: center; + gap: var(--space-3); + flex: 1 1 0; + padding: .6875rem var(--space-2); + color: var(--chrome-item); + font-size: var(--font-base); + line-height: var(--lh-snug); + text-align: center; + text-decoration: none; + cursor: pointer; + touch-action: manipulation; + user-select: none; + -webkit-tap-highlight-color: transparent; } - .data-table-primary { - min-width: 16rem; - margin-bottom: 0; - padding-bottom: 0; - border-bottom: 0; + .nav-item span { + position: absolute; + width: 1pt; + height: 1pt; + padding: 0; + margin: -1pt; + overflow: hidden; + clip-path: inset(50%); + white-space: nowrap; + border: 0; } - .data-table .table-icon-column { - display: table-cell; - width: 1%; + .nav-item svg { + flex: none; + width: var(--font-xl); + height: var(--font-xl); } - .details > div { - grid-template-columns: 8.5rem minmax(0, 1fr); + .nav-item:hover, + .nav-item:active { + background: var(--menu-hover); + color: var(--on-chrome); } - .page-header-row { - grid-template-columns: minmax(0, 1fr) auto; + .nav-item.is-active { + background: var(--sidebar-active); + box-shadow: inset 0 var(--space-1) 0 var(--accent); + color: var(--on-chrome); } - .modal-overlay { + .mobile-nav-toggle { + position: relative; + display: grid; place-items: center; - padding: 1rem; + width: 2.5rem; + height: 2.5rem; + padding: 0; + border: 0; + background: transparent; + color: var(--chrome-toggle); + cursor: pointer; + touch-action: manipulation; + user-select: none; + -webkit-tap-highlight-color: transparent; } - .modal { - width: min(100%, 32rem); - max-height: calc(100vh - 2rem); - max-height: calc(100dvh - 2rem); - border-top: 0; + .mobile-nav-toggle:hover, + .mobile-nav-toggle.is-open { + color: var(--on-chrome); } - .modal-header { - padding: 1.5rem 1.5rem 0; + .mobile-nav-toggle-bars, + .mobile-nav-toggle-bars::before, + .mobile-nav-toggle-bars::after { + position: absolute; + width: var(--space-5); + height: 1pt; + background: currentColor; + transition: transform var(--dur-2) var(--ease); } - .modal-body { - padding: 1.5rem; + .mobile-nav-toggle-bars::before, + .mobile-nav-toggle-bars::after { + content: ''; + left: 0; } - .modal-actions { - position: static; - flex-wrap: nowrap; - gap: 1rem; - margin: 1.5rem 0 0; - padding: 0; - background: transparent; - border-top: 0; + .mobile-nav-toggle-bars::before { + top: calc(var(--space-2) * -1); } - .modal-actions > .button, - .modal-actions > .button-secondary, - .modal-actions > .button-danger { - flex: 0 auto; + .mobile-nav-toggle-bars::after { + top: var(--space-2); } -} -@media (min-width: 60em) { - .app { - grid-template-columns: 15rem minmax(0, 1fr); - grid-template-rows: minmax(0, 1fr); + .mobile-nav-toggle.is-open .mobile-nav-toggle-bars { + background: transparent; } - .sidebar { - display: flex; - min-height: calc(100vh - var(--topbar-height)); - min-height: calc(100svh - var(--topbar-height)); + .mobile-nav-toggle.is-open .mobile-nav-toggle-bars::before { + transform: translateY(var(--space-2)) rotate(45deg); } - .mobile-nav-toggle, - .mobile-nav { - display: none; + .mobile-nav-toggle.is-open .mobile-nav-toggle-bars::after { + transform: translateY(calc(var(--space-2) * -1)) rotate(-45deg); } - .topbar .user-menu { - display: block; + .mobile-nav { + position: fixed; + top: calc(var(--topbar-height) + env(safe-area-inset-top)); + right: max(0rem, env(safe-area-inset-right)); + bottom: 0; + left: max(0rem, env(safe-area-inset-left)); + z-index: 30; + overflow-y: auto; + overscroll-behavior: contain; + background: var(--sidebar); + color: var(--on-chrome); + visibility: hidden; + opacity: 0; + transform: translateX(100%); + pointer-events: none; + transition: + transform var(--dur-2) var(--ease), + opacity var(--dur-1) var(--ease), + visibility var(--dur-2); + } + + html.mobile-nav-open .mobile-nav { + visibility: visible; + opacity: 1; + transform: none; + pointer-events: auto; } - .nav { - flex: 1; - overflow: visible; + .mobile-nav .nav { + min-width: 0; + min-height: 0; flex-direction: column; flex-wrap: nowrap; - padding: 0.75rem 0; - gap: 0; + overflow: visible; + padding: var(--space-4) max(var(--space-6), env(safe-area-inset-right)) + calc(var(--space-4) + env(safe-area-inset-bottom)) + max(var(--space-6), env(safe-area-inset-left)); + gap: var(--space-1); } - .nav-label { + .mobile-nav .nav-label { display: block; - padding: 0.5rem 1.5rem; + padding: var(--space-2) 0; } - .nav-item { - min-width: 0; + .mobile-nav .nav-item { width: 100%; flex: none; - padding-inline: 1.5rem; justify-content: flex-start; + padding-inline: var(--space-4); text-align: left; + opacity: 0; + transform: translateX(var(--space-8)); + transition: + opacity var(--dur-1) var(--ease) var(--dur-2), + transform var(--dur-2) var(--ease) var(--dur-2); + } + + html.mobile-nav-open .mobile-nav .nav-item { opacity: 1; transform: none; - transition: none; } - .nav-item span { + .mobile-nav .nav-item span { position: static; width: auto; height: auto; @@ -1289,118 +435,535 @@ select:focus-visible { white-space: normal; } - .grid { - grid-template-columns: repeat(2, minmax(0, 1fr)); + .mobile-nav-divider { + height: 1pt; + margin: var(--space-4) var(--space-6); + background: var(--chrome-divider); } -} -@media (pointer: coarse) { - .button, - .button-secondary, - .button-danger, - .auth-button, - .auth-link, - .nav-item, - .summary-row, - .surface-row, - .user-menu-item { - min-height: 2.75rem; - touch-action: manipulation; + .main { + display: flex; + flex-direction: column; + min-width: 0; } - .mobile-nav-toggle, - .user-menu summary, - .modal-close { - min-width: 2.75rem; - width: 2.75rem; - height: 2.75rem; - touch-action: manipulation; + .content { + width: min(100%, 72rem); + margin: 0 auto; + padding: 1.75rem clamp(var(--space-4), 4vw, var(--space-8)) + calc(var(--space-8) + env(safe-area-inset-bottom)); + } + + .page-header { + margin-block-end: var(--space-6); + } + + .page-header h1 { + margin: 0; + font-size: var(--font-2xl); + font-weight: 400; + line-height: var(--lh-tight); } - .table-search input, + .page-header p { + margin: var(--space-1) 0 0; + color: var(--muted); + font-size: var(--font-base); + line-height: var(--lh-base); + } + + .page-header-row { + display: grid; + grid-template-columns: minmax(0, 1fr); + align-items: start; + gap: var(--space-4); + } + + @media (min-width: 40em) { + .page-header-row { + grid-template-columns: minmax(0, 1fr) auto; + } + } + + @media (min-width: 60em) { + .app { + grid-template-columns: 15rem minmax(0, 1fr); + grid-template-rows: minmax(0, 1fr); + } + + .sidebar { + display: flex; + min-height: calc(100vh - var(--topbar-height)); + min-height: calc(100svh - var(--topbar-height)); + } + + .mobile-nav-toggle, + .mobile-nav { + display: none; + } + + .nav { + flex: 1; + overflow: visible; + flex-direction: column; + flex-wrap: nowrap; + padding: var(--space-3) 0; + gap: 0; + } + + .nav-label { + display: block; + padding: var(--space-2) var(--space-6); + } + + .nav-item { + min-width: 0; + width: 100%; + flex: none; + padding-inline: var(--space-6); + justify-content: flex-start; + text-align: left; + opacity: 1; + transform: none; + transition: none; + } + + .nav-item span { + position: static; + width: auto; + height: auto; + margin: 0; + overflow: visible; + clip-path: none; + display: inline; + white-space: normal; + } + } + + @media (pointer: coarse) { + .button, + .field-control, + .checkbox input, + .select-trigger { + min-height: var(--control-h); + } + } + + @media (prefers-reduced-motion: reduce) { + .spinner { + animation: none; + } + + .mobile-nav, + .mobile-nav .nav-item, + .mobile-nav-toggle-bars, + .mobile-nav-toggle-bars::before, + .mobile-nav-toggle-bars::after { + transition: none; + } + + .mobile-nav, + .mobile-nav .nav-item { + transform: none; + } + } +} + +/* ========================================================================== + primitives: small, composable, token-driven building blocks. + ========================================================================== */ +@layer primitives { + .button { + display: inline-flex; + align-items: center; + justify-content: center; + gap: var(--space-2); + min-height: var(--control-h); + padding: var(--space-2) var(--space-4); + border: 0; + border-radius: var(--radius-0); + color: var(--on-accent); + font: inherit; + font-size: var(--font-base); + font-weight: 500; + text-transform: uppercase; + letter-spacing: .02em; + text-align: center; + cursor: pointer; + transition: background var(--dur-1) var(--ease), color var(--dur-1) var(--ease); + } + .button:disabled { opacity: .55; cursor: default; } + + /* filled: primary form/modal action */ + .button-primary { background: var(--accent); } + .button-primary:hover:not(:disabled) { background: var(--accent-hover); } + .button-primary:active:not(:disabled) { background: var(--accent-active); } + + /* outline: secondary form/modal action */ + .button-secondary { background: transparent; color: var(--accent-text); + box-shadow: inset 0 0 0 1pt var(--accent); } + .button-secondary:hover:not(:disabled) { background: var(--accent-tint); } + + /* filled danger */ + .button-danger { background: var(--danger); } + .button-danger:hover:not(:disabled) { filter: brightness(1.08); } + + /* plain-text: IN-ROW table actions ONLY. No box, baseline-aligned. */ + .button-inline { + display: inline-block; + min-height: 0; + padding: 0; + border: 0; + background: none; + color: var(--accent-text); + text-transform: none; + letter-spacing: normal; + line-height: var(--lh-body); + vertical-align: baseline; /* default: sits on the text baseline */ + white-space: nowrap; + cursor: pointer; + } + .button-inline:disabled { cursor: default; } + .button-inline:hover { color: var(--accent-text-hover); text-decoration: underline; } + .button-inline-danger { color: var(--danger-text); } + .button-inline-danger:hover { color: var(--danger-text); } + + .button-inline + .button-inline { margin-inline-start: var(--space-4); } + + .field { display: grid; gap: var(--space-1); margin-block-end: var(--space-4); min-width: 0; } + .field-label { color: var(--muted); font-size: var(--font-xs); line-height: var(--lh-snug); } .field-control, - .field-textarea, - .checkbox-row, - .auth-choice { - min-height: 2.75rem; - padding-block: 0.5rem; + .field-textarea { + width: 100%; min-width: 0; padding: var(--space-2) var(--space-3); + border: 0; border-bottom: 1pt solid var(--field-line); border-radius: var(--radius-0); + background: var(--surface); color: inherit; font: inherit; + font-size: var(--font-base); line-height: var(--lh-base); + } + .field-control:focus, .field-textarea:focus { border-bottom-color: var(--accent); outline: none; } + .field-hint { color: var(--muted); font-size: var(--font-sm); line-height: var(--lh-base); margin: var(--space-1) 0 0; } + + .checkbox { display: flex; align-items: center; gap: var(--space-2); + font-size: var(--font-base); line-height: var(--lh-base); } + .checkbox input { width: 1rem; height: 1rem; flex: none; } + .checkbox + .checkbox, + .field + .checkbox { margin-block-start: var(--space-4); } + + .status { display: inline; color: var(--muted); font-size: var(--font-base); + white-space: nowrap; } + .status-warn { color: var(--warn); } + .status-muted { color: var(--muted); } + .status-dot { + display: inline-block; width: .4375rem; height: .4375rem; border-radius: 50%; + background: currentColor; vertical-align: -.125em; margin-inline-end: var(--space-2); + } + + .spinner { width: 1.25rem; height: 1.25rem; border-radius: 50%; + border: 2pt solid var(--line-strong); border-top-color: var(--accent); + animation: spin var(--dur-2) linear infinite; } + @keyframes spin { to { transform: rotate(1turn); } } + + /* feedback text */ + .alert { margin: 0 0 var(--space-4); color: var(--danger-text); + font-size: var(--font-base); line-height: var(--lh-base); } + .alert p { margin: 0 0 var(--space-2); } + .notice { margin: 0 0 var(--space-4); padding: var(--space-3) var(--space-4); + background: var(--line); color: var(--text); + font-size: var(--font-base); line-height: var(--lh-base); } + .note { margin: 0; color: var(--muted); font-size: var(--font-base); line-height: var(--lh-loose); } + .empty { margin: 0; color: var(--muted); font-size: var(--font-base); line-height: var(--lh-loose); } + + /* text-styled action (anchor or button) */ + .link { + padding: 0; border: 0; background: none; + color: var(--accent-text); font: inherit; font-size: var(--font-base); + text-decoration: none; cursor: pointer; + } + .link:hover { color: var(--accent-text-hover); text-decoration: underline; } + + /* skeleton shimmer blocks */ + .skeleton { height: var(--space-3); background: var(--skeleton); } + .skeleton + .skeleton { margin-block-start: var(--space-3); } + .skeleton-title { width: 8rem; } + .skeleton-short { width: 35%; } + .skeleton-medium { width: 62%; } + + /* utilities (closed set) */ + .u-mono { font-family: var(--font-mono); } + .u-muted { color: var(--muted); } + .u-full { width: 100%; } + .u-nowrap { white-space: nowrap; } + .u-truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } + .u-center { text-align: center; } + .u-stack { display: flex; flex-direction: column; gap: var(--stack-gap, var(--space-4)); } + .u-cluster { display: flex; flex-wrap: wrap; align-items: center; gap: var(--cluster-gap, var(--space-4)); } +} + +/* ========================================================================== + components: the shared blocks. The table is the default model; cells hold + inline content or a block title pair, never flex or forced heights. + ========================================================================== */ +@layer components { + .table { width: 100%; font-size: var(--font-base); } + + /* DEFAULT (mobile): stacked cards. */ + .table, .table tbody, .table tr, .table th, .table td { display: block; } + .table thead { display: none; } + .table tbody tr { margin-block-end: var(--space-4); padding: var(--space-4); + background: var(--surface); box-shadow: var(--shadow); } + .table td { padding: var(--space-1) 0; text-align: left; } + .table td[data-label]::before { + content: attr(data-label); display: block; margin-block-end: var(--space-1); + color: var(--muted); font-size: var(--font-xs); font-weight: 500; + letter-spacing: .08em; text-transform: uppercase; } + .table td:last-child { padding-block-end: 0; } + + /* Cell content -- the invariant the harness enforces: a cell holds inline + content (text, .status, .button-inline) or a block (.table-title over + .table-sub for a 2-line primary). No flex, no min-height inside a cell. */ + .table-title { font-weight: 500; } + .table-sub { display: block; margin-block-start: var(--space-1); + color: var(--muted); font-size: var(--font-sm); font-family: var(--font-mono); } + .table-meta { color: var(--muted); font-size: var(--font-sm); } + .table-mono { font-family: var(--font-mono); font-size: var(--font-sm); overflow-wrap: anywhere; } + + /* Cursor/interaction states apply at every size. */ + .table tbody tr { cursor: default; } + .table-linkable tbody tr { cursor: pointer; } + .table-linkable tbody tr:hover { background: var(--line-strong); } + + .table tbody tr:focus-visible { + outline: 2pt solid var(--accent); + outline-offset: -2pt; + } + + /* GROW >= 40em: the real table. */ + @media (min-width: 40em) { + .table { display: table; border-collapse: collapse; } + .table thead { display: table-header-group; } + .table tbody { display: table-row-group; } + .table tr { display: table-row; } + .table th, + .table td { display: table-cell; } + .table th, + .table td { + /* vertical-align: middle is the HTML default for table-cell; restated once + for clarity. NEVER overridden to top. */ + vertical-align: middle; + text-align: left; + padding: var(--cell-y) var(--cell-x); + border-bottom: 1pt solid var(--line); + } + .table thead th { color: var(--muted); font-size: var(--font-xs); font-weight: 500; + letter-spacing: .08em; text-transform: uppercase; } + .table td[data-label]::before { content: none; } /* labels are the <th> now */ + /* Undo the stacked-mode card trim. The :last-child longhand (0-2-1) + outranks the padding shorthand above (0-1-1) regardless of order, so it + must be cancelled at equal-or-higher specificity in this layer. */ + .table td:last-child { padding-block-end: var(--cell-y); } + .table tbody tr { margin-block-end: 0; padding: 0; background: transparent; box-shadow: none; } + + /* Opt-in fixed columns -- ONLY when a screen needs stable gutters. */ + .table-fixed { table-layout: fixed; } + .table-fixed th { width: var(--col-w, auto); } + } + + /* toolbar: column by default, row at 40em+ */ + .toolbar { + display: flex; flex-direction: column; gap: var(--space-4); + margin-block-end: var(--space-4); padding: var(--space-4); + background: var(--surface); box-shadow: var(--shadow); + } + .toolbar-search { flex: 1; min-width: 0; } + .toolbar-search input { + width: 100%; padding: var(--space-2) 0; + border: 0; border-bottom: 1pt solid var(--field-line); border-radius: var(--radius-0); + background: transparent; color: inherit; font: inherit; + font-size: var(--font-md); line-height: var(--lh-base); outline: none; + } + .toolbar-search input:focus { border-bottom-color: var(--accent); } + .toolbar-actions { + display: flex; justify-content: flex-end; flex-wrap: wrap; gap: var(--space-4); + } + .toolbar-panel { padding: 0; background: transparent; box-shadow: none; } + + @media (min-width: 40em) { + .toolbar { flex-direction: row; align-items: center; } + .toolbar-actions { margin-inline-start: auto; } + } + + /* panel and card */ + .panel { + min-width: 0; padding: var(--space-6); + background: var(--surface); box-shadow: var(--shadow); + } + .panel-wide { grid-column: 1 / -1; margin-block-start: var(--space-4); } + .panel h2 { margin: 0 0 var(--space-5); font-size: var(--font-lg); + font-weight: 500; line-height: var(--lh-snug); } + .card { padding: var(--space-6); background: var(--surface); box-shadow: var(--shadow); } + + /* modal: bottom sheet by default, centered dialog at 40em+ */ + .overlay { + position: fixed; + inset: 0; + z-index: 100; + display: grid; + place-items: end center; + padding: 0; + background: var(--overlay); touch-action: manipulation; } - .user-menu summary:hover, - .user-menu summary:active, - .user-menu-item:hover, - .user-menu-item:active { - background: var(--menu-hover); - color: #fff; + .modal { + width: 100%; + max-height: 100vh; + max-height: calc(100dvh - env(safe-area-inset-top)); + overflow: auto; + overscroll-behavior: contain; + border-top: var(--space-1) solid var(--accent); + background: var(--surface); + color: var(--text); + box-shadow: var(--shadow); } -} -@media (prefers-reduced-motion: reduce) { - .spinner { - animation: none; + .modal-header { + display: flex; + align-items: flex-start; + justify-content: space-between; + gap: var(--space-4); + padding: var(--space-4) var(--space-4) 0; } - .mobile-nav, - .mobile-nav .nav-item, - .mobile-nav-toggle-bars, - .mobile-nav-toggle-bars::before, - .mobile-nav-toggle-bars::after { - transition: none; + .modal-header h2 { + margin: 0; + font-size: 1.25rem; + font-weight: 400; + line-height: var(--lh-tight); } - .mobile-nav, - .mobile-nav .nav-item { - transform: none; + .modal-close { + display: grid; + place-items: center; + width: var(--space-8); + height: var(--space-8); + padding: 0; + border: 0; + border-radius: var(--radius-0); + background: transparent; + color: var(--muted); + cursor: pointer; } -} + .modal-close:hover { color: var(--text); } + .modal-close svg { width: var(--space-5); height: var(--space-5); } + + .modal-body { padding: var(--space-4) var(--space-4) calc(var(--space-4) + env(safe-area-inset-bottom)); } + .modal-note { margin: 0; color: var(--muted); font-size: var(--font-base); line-height: var(--lh-loose); } -@media (prefers-color-scheme: dark) { - :root:not([data-theme]) { - --canvas: #181818; - --page: #000; - --surface: #282828; - --sidebar: #000; - --sidebar-active: #333; - --topbar: #000; - --text: #e7e7e7; - --muted: #a0a4a8; - --accent-text: color-mix(in oklch, var(--accent), white 45%); + .modal-actions { + position: sticky; + bottom: 0; + display: flex; + flex-wrap: wrap; + justify-content: flex-end; + gap: var(--space-2); + margin: var(--space-4) calc(var(--space-4) * -1) calc((var(--space-4) + env(safe-area-inset-bottom)) * -1); + padding: var(--space-4) var(--space-4) calc(var(--space-4) + env(safe-area-inset-bottom)); + background: var(--surface); + border-top: 1pt solid var(--line); + } + .modal-actions > .button { flex: 1; justify-content: center; text-align: center; } + + @media (min-width: 40em) { + .overlay { place-items: center; padding: var(--space-4); } + .modal { + width: min(100%, 32rem); + max-height: calc(100vh - var(--space-8)); + max-height: calc(100dvh - var(--space-8)); + border-top: 0; + } + .modal-header { padding: var(--space-6) var(--space-6) 0; } + .modal-body { padding: var(--space-6); } + .modal-actions { + position: static; + flex-wrap: nowrap; + gap: var(--space-4); + margin: var(--space-6) 0 0; + padding: 0; + background: transparent; + border-top: 0; + } + .modal-actions > .button { flex: 0 auto; } + } + + /* misc shared blocks */ + .breadcrumb { + display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); + margin-block-end: var(--space-4); color: var(--muted); + font-size: var(--font-sm); line-height: var(--lh-snug); + } + .breadcrumb a { color: var(--accent-text); text-decoration: none; } + + .stack { display: grid; gap: var(--stack-gap, var(--space-4)); min-width: 0; } + + .section-header { + display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; + gap: var(--space-4); margin-block-end: var(--space-5); + } + .section-header h2 { margin: 0; } + + .details { display: grid; gap: .875rem; margin: 0; } + .details > div { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--space-4); } + .details dt { color: var(--muted); font-size: var(--font-base); line-height: var(--lh-base); } + .details dd { margin: 0; overflow-wrap: anywhere; font-size: var(--font-base); line-height: var(--lh-base); } + + @media (min-width: 40em) { + .details > div { grid-template-columns: 8.5rem minmax(0, 1fr); } + } +} + +/* ========================================================================== + themes: token overrides only. + ========================================================================== */ +@layer themes { + @media (prefers-color-scheme: dark) { + :root:not([data-theme]) { + --canvas: #181818; + --surface: #282828; + --text: #e7e7e7; + --muted: #a0a4a8; + --line: #ffffff0d; + --line-strong: #ffffff14; + --field-line: rgba(255,255,255,.42); + --accent-text: color-mix(in oklch, var(--accent), white 45%); + --accent-text-hover: color-mix(in oklch, var(--accent), white 58%); + --danger-text: #f28b82; + --warn: #e3b341; + --skeleton: #ffffff14; + --hex: url("./assets/hex-grid-dark.svg"); + color-scheme: dark; + } + } + + :root[data-theme="dark"] { + --canvas: #181818; + --surface: #282828; + --text: #e7e7e7; + --muted: #a0a4a8; + --line: #ffffff0d; + --line-strong: #ffffff14; + --field-line: rgba(255,255,255,.42); + --accent-text: color-mix(in oklch, var(--accent), white 45%); --accent-text-hover: color-mix(in oklch, var(--accent), white 58%); - --accent-text-active: color-mix(in oklch, var(--accent), white 35%); - --row: #ffffff0d; - --row-hover: #ffffff14; - --skeleton: #ffffff14; - --danger-text: #f28b82; - --warn: #e3b341; - --field-line: rgba(255, 255, 255, 0.42); - --hex: url('./assets/hex-grid-dark.svg'); + --danger-text: #f28b82; + --warn: #e3b341; + --skeleton: #ffffff14; + --hex: url("./assets/hex-grid-dark.svg"); color-scheme: dark; } -} -:root[data-theme="light"] { - color-scheme: light; + :root[data-theme="light"] { + color-scheme: light; + } } -:root[data-theme="dark"] { - --canvas: #181818; - --page: #000; - --surface: #282828; - --sidebar: #000; - --sidebar-active: #333; - --topbar: #000; - --text: #e7e7e7; - --muted: #a0a4a8; - --accent-text: color-mix(in oklch, var(--accent), white 45%); - --accent-text-hover: color-mix(in oklch, var(--accent), white 58%); - --accent-text-active: color-mix(in oklch, var(--accent), white 35%); - --row: #ffffff0d; - --row-hover: #ffffff14; - --skeleton: #ffffff14; - --danger-text: #f28b82; - --warn: #e3b341; - --field-line: rgba(255, 255, 255, 0.42); - --hex: url('./assets/hex-grid-dark.svg'); - color-scheme: dark; -} +/* Unlayered: beats every layer's display rules. The one allowed !important. */ +[hidden] { display: none !important; } diff --git a/app/shared/style/select-menu.css b/app/shared/style/select-menu.css @@ -1,150 +0,0 @@ -.select { - min-width: 0; - max-width: 100%; - display: block; -} - -.select-trigger { - width: 100%; - min-width: 0; - max-width: 100%; - display: flex; - align-items: center; - justify-content: space-between; - gap: 0.75rem; - padding: 0.5rem 0.75rem; - border: 0; - border-bottom: 1pt solid var(--field-line); - border-radius: 0; - background: var(--surface); - color: inherit; - font: inherit; - font-size: 0.875rem; - line-height: 1.5; - text-align: left; - cursor: pointer; -} - -.select-trigger:focus, -.select-trigger:focus-visible, -.select-trigger[aria-expanded="true"], -.select-trigger[aria-expanded="true"]:focus-visible { - outline: 0; - border-bottom-color: var(--accent); -} - -.select-trigger:disabled { - color: var(--muted); - cursor: default; - opacity: 1; -} - -.select-trigger svg { - flex: none; - width: 1.125rem; - height: 1.125rem; -} - -.select-value { - min-width: 0; - overflow: hidden; - text-overflow: ellipsis; - white-space: nowrap; -} - -.select-list { - position: fixed; - top: 0; - left: 0; - z-index: 120; - width: 10rem; - max-width: calc(100vw - 1rem); - max-height: min(18rem, 45vh); - padding: 0.25rem 0; - overflow-y: auto; - overscroll-behavior: contain; - background: var(--surface); - box-shadow: var(--shadow); - color: var(--text); -} - -.select-list.is-measuring { - visibility: hidden; - top: 0; - right: auto; - bottom: auto; - left: 0; - width: auto; - max-height: none; -} - -.select-option { - width: 100%; - min-height: 2.25rem; - display: flex; - align-items: center; - gap: 0; - padding: 0.5rem 0.75rem; - color: inherit; - font-size: 0.875rem; - line-height: 1.5; - cursor: pointer; -} - -.select-option-mark { - width: 1.25rem; - height: 1.25rem; - flex: none; - display: flex; - align-items: center; - justify-content: center; - order: 2; -} - -.select-option svg { - width: 1.125rem; - height: 1.125rem; -} - -.select-option:not(.is-selected) .select-option-mark svg { - visibility: hidden; -} - -.select-option-label { - min-width: 0; - flex: 1; - overflow: hidden; - text-overflow: ellipsis; - white-space: nowrap; -} - -.select-option:hover { - background: var(--row-hover); -} - -.select-option.is-active { - background: var(--row-hover); -} - -.select-option.is-selected { - color: var(--accent-text); -} - -@media (pointer: coarse) { - .select-trigger, - .select-option { - min-height: 2.75rem; - padding-block: 0.5rem; - touch-action: manipulation; - } - - .select-trigger { - font-size: 1rem; - } -} - -@media (min-width: 40em) { - .select.select-auto { - width: auto; - } -} diff --git a/mockup/plain/account.html b/mockup/plain/account.html @@ -414,7 +414,7 @@ <span class="summary-title">Security</span> <span class="summary-meta">Password, multi-factor authentication and sessions.</span> </span> - <span class="summary-arrow" aria-hidden="true">›</span> + <span class="summary-arrow" aria-hidden="true">&rsaquo;</span> </a> </li> <li> @@ -430,7 +430,7 @@ <span class="summary-title">Apps</span> <span class="summary-meta">Applications with access to this account.</span> </span> - <span class="summary-arrow" aria-hidden="true">›</span> + <span class="summary-arrow" aria-hidden="true">&rsaquo;</span> </a> </li> </ul> @@ -507,7 +507,7 @@ </svg> <span> <strong>Current session</strong> - <span>account · This device · Active</span> + <span>account &middot; This device &middot; Active</span> </span> <span class="status">Read-only</span> </div> diff --git a/mockup/plain/error-pages.html b/mockup/plain/error-pages.html @@ -198,7 +198,7 @@ </div> <div class="field"> <span class="field-label">Password</span> - <span class="field-value">••••••••</span> + <span class="field-value">&bull;&bull;&bull;&bull;&bull;&bull;&bull;&bull;</span> </div> <p class="status-error" role="alert">The username or password is incorrect.</p> <div class="status-actions"> diff --git a/mockup/plain/mockups.css b/mockup/plain/mockups.css @@ -0,0 +1,64 @@ +@layer mockups { + /* demo chrome: the floating theme/state bar every mockup page shares */ + .mockup-controls { + position: fixed; + right: max(var(--space-4), env(safe-area-inset-right)); + bottom: max(var(--space-4), env(safe-area-inset-bottom)); + z-index: 100; + display: flex; + flex-wrap: wrap; + align-items: center; + gap: var(--space-1); + width: min(calc(100vw - var(--space-8)), fit-content); + padding: 0.375rem; + background: var(--sidebar); + color: var(--on-chrome); + box-shadow: var(--shadow); + font-size: var(--font-xs); + } + + .mockup-label { + padding: 0 var(--space-2); + color: var(--chrome-label); + font-size: 0.6875rem; + font-weight: 600; + letter-spacing: 0.08em; + text-transform: uppercase; + } + + .mockup-button { + padding: 0.375rem 0.625rem; + border: 0; + background: transparent; + color: var(--chrome-text); + font: inherit; + font-size: var(--font-xs); + cursor: pointer; + } + + .mockup-button:hover { + background: var(--menu-hover); + color: var(--on-chrome); + } + + .mockup-button.is-active { + background: var(--sidebar-active); + color: var(--on-chrome); + } + + .mockup-separator { + width: 1pt; + height: var(--space-5); + margin: 0 var(--space-1); + background: var(--chrome-divider); + } + + /* demo scaffolding: a section showing component states side by side */ + .state-preview { + margin-block-start: var(--space-8); + } + + .state-preview > h2 { + margin-block-end: var(--space-3); + } +} diff --git a/tools/css-check/align.mjs b/tools/css-check/align.mjs @@ -0,0 +1,319 @@ +#!/usr/bin/env node +// Tier B table-alignment proof. Renders a page in system Google Chrome +// (headless, driven over CDP with built-in fetch + WebSocket, no npm deps), +// then measures the vertical center of each table cell's first inline content +// per row. In real-table mode the spread of centers within a row must stay +// under the threshold; in stacked mode every cell must be a single full-width +// column, where centering is trivially correct. +// +// node tools/css-check/align.mjs +// node tools/css-check/align.mjs --url http://127.0.0.1:8080/index.html +// +// Options: --url, --widths 390,1440, --themes auto,light,dark, +// --threshold 0.5, --chrome <binary> + +import { spawn } from 'node:child_process'; +import fs from 'node:fs'; +import os from 'node:os'; +import path from 'node:path'; +import process from 'node:process'; + +const REPO = path.resolve(import.meta.dirname, '..', '..'); + +function flagValue(name, dflt) { + const i = process.argv.indexOf(name); + return i >= 0 && process.argv[i + 1] ? process.argv[i + 1] : dflt; +} + +const CHROME = flagValue( + '--chrome', + process.env.CHROME_PATH || '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome', +); +const TARGET_URL = flagValue( + '--url', + new URL('./fixtures/email-domains.html', import.meta.url).href, +); +const WIDTHS = flagValue('--widths', '390,1440').split(',').map(Number); +const THEMES = flagValue('--themes', 'auto,light,dark').split(','); +const THRESHOLD = Number(flagValue('--threshold', '0.5')); + +const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms)); + +async function waitForPort(userDir, timeoutMs = 25000) { + const file = path.join(userDir, 'DevToolsActivePort'); + const deadline = Date.now() + timeoutMs; + while (Date.now() < deadline) { + if (fs.existsSync(file)) { + const text = fs.readFileSync(file, 'utf8').trim(); + if (text) return text.split('\n')[0].trim(); + } + await sleep(100); + } + throw new Error('chrome did not write DevToolsActivePort'); +} + +function connectCdp(wsUrl) { + const ws = new WebSocket(wsUrl); + const pending = new Map(); + const eventWaiters = []; + let nextId = 1; + + ws.addEventListener('message', (event) => { + const msg = JSON.parse(event.data); + if (msg.id && pending.has(msg.id)) { + const { resolve, reject } = pending.get(msg.id); + pending.delete(msg.id); + if (msg.error) reject(new Error(`${msg.error.message} (${msg.method})`)); + else resolve(msg.result); + } else if (msg.method) { + for (let i = eventWaiters.length - 1; i >= 0; i -= 1) { + const w = eventWaiters[i]; + if (w.method === msg.method) { + eventWaiters.splice(i, 1); + w.resolve(msg); + } + } + } + }); + + return new Promise((resolveInit, rejectInit) => { + ws.addEventListener('error', () => rejectInit(new Error(`cdp websocket failed: ${wsUrl}`))); + ws.addEventListener('open', () => { + resolveInit({ + send(method, params = {}) { + const id = nextId; + nextId += 1; + ws.send(JSON.stringify({ id, method, params })); + return new Promise((resolve, reject) => pending.set(id, { resolve, reject })); + }, + waitEvent(method, timeoutMs = 20000) { + return new Promise((resolve, reject) => { + const timer = setTimeout(() => reject(new Error(`timeout waiting for ${method}`)), timeoutMs); + eventWaiters.push({ + method, + resolve: (msg) => { + clearTimeout(timer); + resolve(msg); + }, + }); + }); + }, + close() { + ws.close(); + }, + }); + }); + }); +} + +// evaluated inside the page: applies the theme and measures every table.table +const MEASURE = (theme) => ` +(function () { + var theme = ${JSON.stringify(theme)}; + if (theme === 'auto') { + document.documentElement.removeAttribute('data-theme'); + } else { + document.documentElement.setAttribute('data-theme', theme); + } + + function baselineOf(cell) { + // a zero-size inline-block with vertical-align baseline places its border + // box top exactly on the line's baseline without affecting layout + var probe = document.createElement('span'); + probe.style.display = 'inline-block'; + probe.style.width = '0px'; + probe.style.height = '0px'; + probe.style.verticalAlign = 'baseline'; + cell.appendChild(probe); + var y = probe.getBoundingClientRect().top; + cell.removeChild(probe); + return y; + } + + function contentHeight(cell) { + var range = document.createRange(); + range.selectNodeContents(cell); + var rects = range.getClientRects(); + var top = Infinity; + var bottom = -Infinity; + for (var q = 0; q < rects.length; q += 1) { + if (rects[q].height === 0) continue; + if (rects[q].top < top) top = rects[q].top; + if (rects[q].bottom > bottom) bottom = rects[q].bottom; + } + return bottom === -Infinity ? 0 : bottom - top; + } + + var result = { tables: 0, mode: 'none', rows: 0, maxSpread: 0, stackedOk: true, wrapped: 0 }; + var tables = document.querySelectorAll('table.table'); + result.tables = tables.length; + // one-line invariant: a .status or .button-inline that wraps onto two line + // fragments splits into multiple client rects; centering math cannot see it, + // so flag every wrapped chip in table mode + var firstCell = document.querySelector('table.table td'); + if (firstCell && window.getComputedStyle(firstCell).display === 'table-cell') { + var chips = document.querySelectorAll('table.table .status, table.table .button-inline'); + for (var z = 0; z < chips.length; z += 1) { + var chipRects = chips[z].getClientRects(); + var fragments = 0; + for (var y = 0; y < chipRects.length; y += 1) { + if (chipRects[y].height > 0) fragments += 1; + } + if (fragments > 1) result.wrapped += 1; + } + } + for (var t = 0; t < tables.length; t += 1) { + var rows = tables[t].querySelectorAll('tbody tr'); + for (var r = 0; r < rows.length; r += 1) { + var cells = rows[r].querySelectorAll('td'); + if (!cells.length) continue; + result.rows += 1; + var display = window.getComputedStyle(cells[0]).display; + if (display === 'table-cell') { + result.mode = 'table'; + var centers = []; + for (var c = 0; c < cells.length; c += 1) { + if (!cells[c].getBoundingClientRect().height) continue; + var lh = parseFloat(window.getComputedStyle(cells[c]).lineHeight) || 0; + var h = contentHeight(cells[c]); + // single-line cells must share one baseline; multi-line cells center + // their content box on the row centerline instead + if (lh > 0 && h <= lh * 1.5) { + centers.push(baselineOf(cells[c])); + } else { + centers.push(cells[c].getBoundingClientRect().top + cells[c].getBoundingClientRect().height / 2); + } + } + if (centers.length > 1) { + var spread = Math.max.apply(null, centers) - Math.min.apply(null, centers); + if (spread > result.maxSpread) result.maxSpread = spread; + } + } else { + if (result.mode !== 'table') result.mode = 'stacked'; + var widest = 0; + for (var k = 0; k < cells.length; k += 1) { + var cs = window.getComputedStyle(cells[k]); + if (cs.display !== 'block') result.stackedOk = false; + var w = cells[k].getBoundingClientRect().width; + if (w > widest) widest = w; + } + for (var j = 0; j < cells.length; j += 1) { + if (cells[j].getBoundingClientRect().width < widest - 2) result.stackedOk = false; + } + } + } + } + return JSON.stringify(result); +})() +`; + +async function main() { + if (!fs.existsSync(CHROME)) { + console.error(`align: chrome binary not found: ${CHROME}`); + process.exit(1); + } + const userDir = fs.mkdtempSync(path.join(os.tmpdir(), 'css-check-chrome-')); + const chrome = spawn( + CHROME, + [ + '--headless=new', + '--disable-gpu', + '--hide-scrollbars', + '--no-first-run', + '--no-default-browser-check', + '--remote-debugging-port=0', + `--user-data-dir=${userDir}`, + 'about:blank', + ], + { stdio: 'ignore' }, + ); + + let exitCode = 1; + try { + const port = await waitForPort(userDir); + const targets = await ( + await fetch(`http://127.0.0.1:${port}/json/list`) + ).json(); + const page = targets.find((t) => t.type === 'page'); + if (!page) throw new Error('no page target'); + const cdp = await connectCdp(page.webSocketDebuggerUrl); + + await cdp.send('Page.enable'); + await cdp.send('Runtime.enable'); + + console.log(`align: target ${TARGET_URL}`); + console.log(`align: threshold ${THRESHOLD}px widths=${WIDTHS.join(',')} themes=${THEMES.join(',')}`); + + let failures = 0; + for (const width of WIDTHS) { + for (const theme of THEMES) { + const scheme = theme === 'dark' ? 'dark' : theme === 'light' ? 'light' : 'no-preference'; + await cdp.send('Emulation.setDeviceMetricsOverride', { + width, + height: 900, + deviceScaleFactor: 1, + mobile: width < 500, + }); + await cdp.send('Emulation.setEmulatedMedia', { + features: [{ name: 'prefers-color-scheme', value: scheme }], + }); + const loaded = cdp.waitEvent('Page.loadEventFired'); + await cdp.send('Page.navigate', { url: TARGET_URL }); + await loaded; + await sleep(150); + const evaluated = await cdp.send('Runtime.evaluate', { + expression: MEASURE(theme), + returnByValue: true, + }); + if (evaluated.exceptionDetails) { + throw new Error(`page evaluation failed at ${width}/${theme}`); + } + const m = JSON.parse(evaluated.result.value); + + let ok = m.tables > 0 && m.rows > 0; + let detail = ''; + if (m.mode === 'table') { + ok = ok && m.maxSpread < THRESHOLD && m.wrapped === 0; + detail = `mode=table rows=${m.rows} max-center-spread=${m.maxSpread.toFixed(3)}px (limit ${THRESHOLD}px) wrapped-chips=${m.wrapped}`; + } else if (m.mode === 'stacked') { + ok = ok && m.stackedOk; + detail = `mode=stacked rows=${m.rows} single-column=${m.stackedOk ? 'yes' : 'NO'}`; + } else { + ok = false; + detail = 'no table.table rendered'; + } + if (!ok) failures += 1; + console.log(` ${String(width).padStart(4)}px ${theme.padEnd(4)} ${ok ? 'PASS' : 'FAIL'} ${detail}`); + } + } + + if (failures) { + console.log(`align: FAIL (${failures} combination(s) over threshold)`); + exitCode = 1; + } else { + console.log('align: PASS (all widths x themes)'); + exitCode = 0; + } + cdp.close(); + } catch (err) { + console.error(`align: ${err && err.message ? err.message : err}`); + exitCode = 1; + } finally { + chrome.kill('SIGKILL'); + await new Promise((resolve) => { + const timer = setTimeout(resolve, 3000); + chrome.once('exit', () => { + clearTimeout(timer); + resolve(null); + }); + }); + try { + fs.rmSync(userDir, { recursive: true, force: true, maxRetries: 10, retryDelay: 200 }); + } catch { + // leftover temp profile is disposable + } + } + process.exit(exitCode); +} + +main(); diff --git a/tools/css-check/check.mjs b/tools/css-check/check.mjs @@ -0,0 +1,526 @@ +#!/usr/bin/env node +// Tier A static CSS verification for the shared framework and its consumers. +// Dependency-free plain Node. Run from anywhere: +// node tools/css-check/check.mjs --scope repo +// node tools/css-check/check.mjs --scope app --app admin +// Exit code 0 = green (warnings allowed while the transition allow-list is +// populated), 1 = red. + +import fs from 'node:fs'; +import path from 'node:path'; +import process from 'node:process'; + +const REPO = path.resolve(import.meta.dirname, '..', '..'); + +// --------------------------------------------------------------------------- +// transition allow-list: files that are being phased out by the migration. +// While any of these exist, the no-copy guard runs warn-only, and token +// violations inside them are warnings. Empty the list to make both hard. +// --------------------------------------------------------------------------- +const TRANSITION_ALLOW = [ + 'mockup/plain/global.css', + 'mockup/plain/select-menu.css', +]; + +const FRAMEWORK_CSS = 'app/shared/style/global.css'; +const COMPONENT_CSS_DIR = 'app/shared/component'; +const MOCKUP_DIR = 'mockup/plain'; + +// files the framework contract governs: the shared framework, its consumer +// stylesheets, the mockup pages, and this harness +const MIGRATION_PREFIXES = ['app/', `${MOCKUP_DIR}/`, 'tools/']; +// every source tree checked for plain-ASCII and code-comment hygiene +const SCAN_ROOTS = ['app', 'mockup', 'tools']; +const CSS_EXT = ['.css']; +const CODE_EXT = ['.css', '.js', '.cjs', '.mjs', '.ts', '.tsx', '.html']; +const SKIP_DIRS = new Set(['node_modules', 'dist', '.git']); + +// selectors from the old naming that must not gain new homes in mockup page +// style blocks; the rename targets are defined by the framework instead. +const OLD_NAME_PATTERNS = [ + /\.(?:data-table(?:-primary|-sub|-status|-static|-wrap)?|table-panel|table-toolbar|table-search|table-actions|action-button|modal-overlay|form-field|checkbox-row|client-breadcrumb|auth-link|link-button|consent-account-link|realm-select|domain-status(?:-dot)?|provider-status|session-badge|client-badge|host-name|host-added|table-icon(?:-column)?)(?![\w-])/g, + /\.[\w-]+-row-action(?![\w-])/g, + /\.[\w-]+-stack(?![\w-])/g, +]; + +// register of surfaces whose source still carries non-ASCII characters: +// any byte above 0x7F outside this list fails the build, entries that are +// already pure ASCII are reported obsolete, and the register must stay empty +const PREEXISTING_NON_ASCII = []; + +// --------------------------------------------------------------------------- +// helpers +// --------------------------------------------------------------------------- + +function rel(file) { + return path.relative(REPO, file).split(path.sep).join('/'); +} + +function walk(dir, out) { + for (const entry of fs.readdirSync(dir, { withFileTypes: true })) { + if (SKIP_DIRS.has(entry.name)) continue; + const full = path.join(dir, entry.name); + if (entry.isDirectory()) walk(full, out); + else out.push(full); + } + return out; +} + +function listFiles(exts) { + const out = []; + for (const root of SCAN_ROOTS) { + const dir = path.join(REPO, root); + if (!fs.existsSync(dir)) continue; + for (const file of walk(dir, [])) { + if (exts.includes(path.extname(file))) out.push(file); + } + } + return out.sort(); +} + +function scoped(files) { + const base = files.filter((f) => MIGRATION_PREFIXES.some((p) => rel(f).startsWith(p))); + if (SCOPE === 'repo') return base; + const prefix = `app/${APP_NAME}/`; + return base.filter((f) => { + const r = rel(f); + return r.startsWith(prefix) || r.startsWith('app/shared/'); + }); +} + +function allowed(r) { + return TRANSITION_ALLOW.includes(r); +} + +function stripComments(text) { + return text.replace(/\/\*[\s\S]*?\*\//g, ' ').replace(/<!--[\s\S]*?-->/g, ' '); +} + +// Minimal block parser: yields { selector, body, chain } for every style +// rule, where chain is the list of enclosing at-rule preludes. +function parseRules(text) { + const clean = stripComments(text); + const rules = []; + const stack = []; + let buf = ''; + let i = 0; + while (i < clean.length) { + const ch = clean[i]; + if (ch === '{') { + const prelude = buf.trim(); + buf = ''; + i += 1; + let depth = 1; + const start = i; + while (i < clean.length && depth > 0) { + if (clean[i] === '{') depth += 1; + else if (clean[i] === '}') depth -= 1; + i += 1; + } + const body = clean.slice(start, i - 1); + if (prelude.startsWith('@')) { + stack.push(prelude); + rules.push(...parseRules(body).map((r) => ({ ...r, chain: [...stack, ...r.chain] }))); + stack.pop(); + } else { + rules.push({ selector: prelude, body, chain: [...stack] }); + } + continue; + } + if (ch === ';') { + // an at-rule statement such as an @layer order declaration + buf = ''; + i += 1; + continue; + } + buf += ch; + i += 1; + } + return rules; +} + +function classTokens(selector) { + const names = []; + const re = /\.([A-Za-z][A-Za-z0-9_-]*)/g; + // ignore attribute-selector contents to avoid false class hits + const plain = selector.replace(/\[[^\]]*\]/g, ''); + let m; + while ((m = re.exec(plain))) names.push(m[1]); + return names; +} + +function hasTableClass(selector) { + return /(^|[^-\w.])\.table(?![\w-])/.test(selector.replace(/\[[^\]]*\]/g, '')); +} + +function hasCellCompound(selector) { + // a compound selector mentioning a td/th element, or a table part class + return /(^|[\s>+~])t[hd](?![\w-])/.test(selector) || hasTableClass(selector); +} + +function decls(body) { + return body + .split(';') + .map((d) => d.trim()) + .filter(Boolean) + .map((d) => { + const idx = d.indexOf(':'); + return { prop: d.slice(0, idx).trim(), value: d.slice(idx + 1).trim() }; + }); +} + +// comments and string literals only; regex literals are not inspected +function htmlExtract(text) { + const found = []; + found.push(...text.match(/<!--[\s\S]*?-->/g) || []); + found.push(...text.match(/<script[\s\S]*?<\/script>/gi) || []); + return found; +} + +function jsExtract(text) { + return text.match( + /\/\/[^\n]*|\/\*[\s\S]*?\*\/|"(?:[^"\\\n]|\\.)*"|'(?:[^'\\\n]|\\.)*'|`(?:[^`\\]|\\.)*`/g, + ) || []; +} + +function cssExtract(text) { + return [...(text.match(/\/\*[\s\S]*?\*\//g) || []), ...(text.match(/"(?:[^"\\\n]|\\.)*"|'(?:[^'\\\n]|\\.)*'/g) || [])]; +} + +// --------------------------------------------------------------------------- +// guards +// --------------------------------------------------------------------------- + +const errors = []; +const warningGroups = new Map(); + +function addError(line) { + errors.push(line); +} + +function addWarning(key, detail) { + if (!warningGroups.has(key)) warningGroups.set(key, { count: 0, examples: [] }); + const g = warningGroups.get(key); + g.count += 1; + if (detail && g.examples.length < 3 && !g.examples.includes(detail)) g.examples.push(detail); +} + +function report(file, guard, msg, hard) { + const line = `${rel(file)} [${guard}] ${msg}`; + if (hard) addError(line); + else addWarning(line, ''); +} + +const args = process.argv.slice(2); +function flagValue(name, dflt) { + const i = args.indexOf(name); + return i >= 0 && args[i + 1] ? args[i + 1] : dflt; +} +const SCOPE = flagValue('--scope', 'repo'); +const APP_NAME = flagValue('--app', SCOPE === 'repo' ? null : 'admin'); + +function main() { + const cssFiles = scoped(listFiles(CSS_EXT)); + const allCode = listFiles(CODE_EXT); + const codeFiles = + SCOPE === 'repo' + ? allCode + : allCode.filter((f) => { + const r = rel(f); + return r.startsWith(`app/${APP_NAME}/`) || r.startsWith('app/shared/'); + }); + + // ---- guard 1: static alignment rules ----------------------------------- + for (const file of cssFiles) { + const r = rel(file); + const hard = !allowed(r); + for (const rule of parseRules(fs.readFileSync(file, 'utf8'))) { + if (!hasCellCompound(rule.selector)) continue; + const mentionsTable = hasTableClass(rule.selector); + for (const d of decls(rule.body)) { + const prop = d.prop.toLowerCase(); + const value = d.value.toLowerCase(); + const badDisplay = prop === 'display' && /flex|grid|inline-flex|inline-grid/.test(value); + if (badDisplay || prop === 'min-height') { + if (mentionsTable) { + report(file, 'align', `cell rule "${rule.selector}" declares ${d.prop}: ${d.value}`, hard); + } + } + if (prop === 'vertical-align' && value.replace(/!important/, '').trim() !== 'middle') { + if (mentionsTable || /(^|[\s>+~])t[hd](?![\w-])/.test(rule.selector)) { + report(file, 'align', `table cell rule "${rule.selector}" sets vertical-align: ${d.value} (only middle allowed)`, hard); + } + } + } + } + } + + // ---- framework class inventory (for the no-copy guard) ------------------ + const frameworkClasses = new Set(); + const frameworkFiles = [path.join(REPO, FRAMEWORK_CSS), path.join(REPO, COMPONENT_CSS_DIR)]; + const collectFrom = (file) => { + for (const rule of parseRules(fs.readFileSync(file, 'utf8'))) { + for (const name of classTokens(rule.selector)) { + // CUBE state classes are shared vocabulary, not redefinable blocks + if (/^(?:is|has)-/.test(name)) continue; + frameworkClasses.add(name); + } + } + }; + const collectDir = (dir) => { + for (const f of walk(dir, [])) if (f.endsWith('.css')) collectFrom(f); + }; + if (fs.existsSync(frameworkFiles[0])) collectFrom(frameworkFiles[0]); + if (fs.existsSync(frameworkFiles[1])) collectDir(frameworkFiles[1]); + + // consumers = css files that are not the framework files themselves + const frameworkSet = new Set([ + rel(path.join(REPO, FRAMEWORK_CSS)), + ...listIn(path.join(REPO, COMPONENT_CSS_DIR)), + ]); + function listIn(dir) { + if (!fs.existsSync(dir)) return []; + return walk(dir, []).filter((f) => f.endsWith('.css')).map(rel); + } + const consumers = cssFiles.filter((f) => !frameworkSet.has(rel(f))); + + // no-copy guard runs warn-only repo-wide while the allow-list is populated + const allowAlive = TRANSITION_ALLOW.some((f) => fs.existsSync(path.join(REPO, f))); + const noCopyHard = !allowAlive; + for (const f of TRANSITION_ALLOW) { + if (fs.existsSync(path.join(REPO, f))) { + addWarning(`${f} [no-copy] transition allow-list entry still present`, noCopyHard ? 'must be deleted' : 'warn-only until deleted'); + } + } + + // ---- guard 2: no-copy ---------------------------------------------------- + for (const file of consumers) { + const r = rel(file); + const text = fs.readFileSync(file, 'utf8'); + const selectors = []; + for (const block of extractStyleBlocks(text, file)) { + selectors.push(...parseRules(block).map((x) => x.selector)); + } + if (r.endsWith('.css')) { + for (const rule of parseRules(text)) selectors.push(rule.selector); + } + const redefined = new Set(); + for (const selector of selectors) { + for (const name of classTokens(selector)) { + if (frameworkClasses.has(name)) redefined.add(`.${name}`); + } + } + if (redefined.size) { + report(file, 'no-copy', `redefines framework class(es): ${[...redefined].sort().join(', ')}`, noCopyHard); + } + } + + // mockup page style blocks must not carry old-name selectors + if (SCOPE === 'repo') { + const htmlFiles = listFiles(['.html']).filter((f) => rel(f).startsWith(`${MOCKUP_DIR}/`)); + for (const file of htmlFiles) { + const text = fs.readFileSync(file, 'utf8'); + const hits = new Set(); + for (const block of extractStyleBlocks(text, file)) { + for (const re of OLD_NAME_PATTERNS) { + re.lastIndex = 0; + let m; + while ((m = re.exec(block))) hits.add(m[0]); + } + } + if (hits.size) { + report(file, 'no-copy', `page style block targets old class(es): ${[...hits].sort().join(', ')}`, noCopyHard); + } + } + } + + // ---- guard 3: tokens ----------------------------------------------------- + for (const file of cssFiles) { + const r = rel(file); + const isFramework = r === FRAMEWORK_CSS; + const hard = !allowed(r); + const text = fs.readFileSync(file, 'utf8'); + const rules = parseRules(stripComments(text)); + const hexHits = []; + const mixHits = []; + const impHits = []; + for (const rule of rules) { + const layerNames = new Set( + rule.chain + .filter((c) => /^@layer\s+[A-Za-z]/.test(c) && !c.includes(',')) + .map((c) => c.replace('@layer', '').replace('{', '').trim()), + ); + const inTokenLayer = isFramework && (layerNames.has('tokens') || layerNames.has('themes')); + const isHiddenTail = isFramework && rule.chain.length === 0 && rule.selector.replace(/\s/g, '') === '[hidden]'; + const oneLine = rule.selector.replace(/\s+/g, ' '); + for (const d of decls(rule.body)) { + const prop = d.prop; + const value = d.value.replace(/\s+/g, ' '); + if (prop.startsWith('--')) { + // custom property definitions are the token channel: literal colors + // are allowed there until the consumer sheets move into the layers + } else if (/(^|[\s,;(])#[0-9a-fA-F]{3,8}\b/.test(value)) { + if (!inTokenLayer) hexHits.push(`${prop}: ${value} (${oneLine})`); + } + if (/color-mix\(/i.test(value) && !/color-mix\(\s*in\s+oklch/i.test(value)) { + mixHits.push(`${prop}: ${value} (${oneLine})`); + } + if (/!important/i.test(value) && !isHiddenTail) { + impHits.push(`${prop}: ${value} (${oneLine})`); + } + } + } + for (const hit of dedupe(hexHits)) report(file, 'token', `hex literal outside the token layers: ${hit}`, hard); + for (const hit of dedupe(mixHits)) report(file, 'token', `color-mix must mix in oklch: ${hit}`, hard); + for (const hit of dedupe(impHits)) report(file, 'token', `!important outside the unlayered [hidden] tail: ${hit}`, hard); + } + + // ---- guard 4: layers ----------------------------------------------------- + // order-statement uniqueness is checked across every stylesheet in the repo + const orderStatements = []; + for (const file of listFiles(CSS_EXT)) { + const text = stripComments(fs.readFileSync(file, 'utf8')); + const re = /@layer\s+[^{;]+;/g; + let m; + while ((m = re.exec(text))) { + const line = text.slice(0, m.index).split('\n').length; + orderStatements.push({ file, line, text: m[0] }); + } + } + if (SCOPE === 'repo') { + if (orderStatements.length !== 1) { + errors.push(`layer: expected exactly 1 @layer order statement repo-wide, found ${orderStatements.length}`); + } + const fw = path.join(REPO, FRAMEWORK_CSS); + const fwLine = orderStatements.find((s) => s.file === fw); + if (orderStatements.length === 1 && fwLine && fwLine.line !== 1) { + errors.push(`layer: the @layer order statement must be the first line of ${FRAMEWORK_CSS}, found on line ${fwLine.line}`); + } + } else if (orderStatements.some((s) => rel(s.file) !== FRAMEWORK_CSS)) { + for (const s of orderStatements) { + if (rel(s.file) !== FRAMEWORK_CSS) { + errors.push(`${rel(s.file)} [layer] duplicate @layer order statement: ${s.text}`); + } + } + } + for (const file of cssFiles) { + const r = rel(file); + if (allowed(r) || r === FRAMEWORK_CSS) continue; + const text = stripComments(fs.readFileSync(file, 'utf8')); + const re = /@layer\s+([\w-]+(?:\s*,\s*[\w-]+)*)\s*\{/g; + let m; + while ((m = re.exec(text))) { + const names = m[1].split(',').map((n) => n.trim()); + const isComponent = r.startsWith(`${COMPONENT_CSS_DIR}/`); + const permitted = isComponent ? ['components'] : ['apps', 'mockups']; + for (const n of names) { + if (!permitted.includes(n)) { + errors.push(`${r} [layer] consumer stylesheet uses @layer ${n} (permitted: ${permitted.join('/')})`); + } + } + } + } + // consumers without a layer wrapper: warn until the app sheets are moved + if (allowAlive) { + for (const file of consumers) { + const r = rel(file); + if (allowed(r)) continue; + if (!r.startsWith('app/') && !r.startsWith(`${MOCKUP_DIR}/`)) continue; + const text = stripComments(fs.readFileSync(file, 'utf8')); + if (!/@layer\s+[\w-]+\s*\{/.test(text)) { + addWarning(`${r} [layer] consumer stylesheet is unlayered`, 'transition: app sheets move into @layer apps'); + } + } + } + + // ---- guard 5: source hygiene -------------------------------------------- + const nonAscii = (buf) => { + const hits = []; + for (let i = 0; i < buf.length; i += 1) { + if (buf[i] > 0x7f) hits.push({ i, b: buf[i] }); + } + return hits; + }; + for (const file of codeFiles) { + const r = rel(file); + const buf = fs.readFileSync(file); + const hits = nonAscii(buf); + if (hits.length) { + const detail = `${hits.length} byte(s), first 0x${hits[0].b.toString(16)} at offset ${hits[0].i}`; + if (PREEXISTING_NON_ASCII.includes(r)) { + addWarning(`${r} [hygiene] preexisting non-ASCII characters in user copy`, `transition: fix when this surface migrates (${detail})`); + } else { + addError(`${r} [hygiene] non-ASCII: ${detail}`); + } + } else if (PREEXISTING_NON_ASCII.includes(r)) { + addWarning(`${r} [hygiene] register entry obsolete`, 'file is pure ASCII now; remove it from the register'); + } + const text = buf.toString('latin1'); + const ext = path.extname(file); + let snippets = []; + if (ext === '.css') snippets = cssExtract(text); + else if (ext === '.html') snippets = htmlExtract(text); + else snippets = jsExtract(text); + for (const s of snippets) { + if (/\.(md|rst)\b/i.test(s) || /\bsection\s+\d/i.test(s) || /CSS[-_]FRAMEWORK/i.test(s) || + /\b(?:see|per|according to|follow(?:s|ing)?)\s+the\s+spec(?:ification)?\b/i.test(s)) { + errors.push(`${r} [hygiene] document or spec reference inside code: ${s.slice(0, 60)}`); + break; + } + } + // class-name tokens + const bad = []; + if (ext === '.css') { + for (const rule of parseRules(text)) { + for (const name of classTokens(rule.selector)) { + if (name.includes('__') || name.includes('--')) bad.push(`.${name}`); + } + } + } else { + const attr = /class(?:Name)?\s*[:=]\s*["']([^"']+)["']/g; + let m; + while ((m = attr.exec(text))) { + for (const tok of m[1].split(/\s+/)) { + if (tok.includes('__') || tok.includes('--')) bad.push(tok); + } + } + const cl = /classList\.(?:add|remove|toggle)\(\s*["']([^"']+)["']/g; + while ((m = cl.exec(text))) { + for (const tok of m[1].split(/\s+/)) { + if (tok.includes('__') || tok.includes('--')) bad.push(tok); + } + } + } + if (bad.length) { + errors.push(`${r} [hygiene] class names with double-underscore or double-hyphen: ${[...new Set(bad)].join(', ')}`); + } + } + + // ---- summary -------------------------------------------------------------- + console.log(`css-check: scope=${SCOPE === 'repo' ? 'repo' : `app/${APP_NAME}`} files(css)=${cssFiles.length} files(code)=${codeFiles.length}`); + let warnCount = 0; + for (const [key, g] of warningGroups) { + warnCount += g.count; + const extra = g.examples.length ? `: ${g.examples.join('; ')}` : ''; + console.log(` warn: ${key}${g.count > 1 ? ` (x${g.count})` : ''}${extra}`); + } + for (const e of errors) console.log(` FAIL: ${e}`); + console.log(`css-check: ${errors.length} error(s), ${warnCount} warning(s)`); + console.log(`css-check: no-copy guard runs ${noCopyHard ? 'HARD (allow-list empty)' : 'warn-only (transition allow-list active)'}`); + process.exit(errors.length ? 1 : 0); +} + +function dedupe(list) { + return [...new Set(list)]; +} + +function extractStyleBlocks(text, file) { + if (!file.endsWith('.html')) return []; + const blocks = []; + const re = /<style[^>]*>([\s\S]*?)<\/style>/gi; + let m; + while ((m = re.exec(text))) blocks.push(m[1]); + return blocks; +} + +main(); diff --git a/tools/css-check/fixtures/email-domains.html b/tools/css-check/fixtures/email-domains.html @@ -0,0 +1,83 @@ +<!DOCTYPE html> +<html lang="en"> + <head> + <meta charset="utf-8"> + <meta name="viewport" content="width=device-width,initial-scale=1"> + <title>email domains table fixture</title> + <link rel="stylesheet" href="../../../app/shared/style/global.css"> + </head> + <body> + <main class="content"> + <section class="card" aria-label="Realm email domains"> + <div class="toolbar toolbar-panel"> + <div class="toolbar-search"> + <input + type="search" + aria-label="Search email domains" + placeholder="Search email domains" + > + </div> + <div class="toolbar-actions"> + <button class="button button-primary" type="button">Add email domain</button> + </div> + </div> + + <table class="table table-fixed"> + <thead> + <tr> + <th scope="col">Domain</th> + <th scope="col" style="--col-w: 14rem">Status</th> + <th scope="col" style="--col-w: 14rem">Actions</th> + </tr> + </thead> + <tbody> + <tr> + <td data-label="Domain"> + <span class="table-mono">acme.test</span> + </td> + <td data-label="Status"> + <span class="status status-warn"> + <span class="status-dot" aria-hidden="true"></span> + Pending verification + </span> + </td> + <td data-label="Actions"> + <button class="button-inline" type="button">Verify</button> + <button class="button-inline button-inline-danger" type="button">Remove</button> + </td> + </tr> + <tr> + <td data-label="Domain"> + <span class="table-mono">widgets.example.org</span> + </td> + <td data-label="Status"> + <span class="status"> + <span class="status-dot" aria-hidden="true"></span> + Verified + </span> + </td> + <td data-label="Actions"> + <button class="button-inline button-inline-danger" type="button">Remove</button> + </td> + </tr> + <tr> + <td data-label="Domain"> + <span class="table-mono">a-really-long-domain-name-for-boundary-checking.enterprise.test</span> + </td> + <td data-label="Status"> + <span class="status status-warn"> + <span class="status-dot" aria-hidden="true"></span> + Pending verification + </span> + </td> + <td data-label="Actions"> + <button class="button-inline" type="button">Verify</button> + <button class="button-inline button-inline-danger" type="button">Remove</button> + </td> + </tr> + </tbody> + </table> + </section> + </main> + </body> +</html>