/*
 * Author: Jeremiah Buttler
 * Emporania stylesheet, "Transit": the tokens (light and dark), the base rules, and the long-standing page parts that the
 * admin, settings, account and text pages still use (grid, tile, row, chart, table, toolbar, alert, badge, modal, pager,
 * doc, footer, public shell, error pages). The frame (top bar, tabs, buttons, chips, segmented switches, popovers,
 * palette, toasts, theme switch) is static/css/shell.css; the route line is line.css; design tiles and queue cards are
 * parts.css. Colours are tokens only; the light theme is the default and data-theme="dark" on <html> is the dark one
 * (static/js/theme.js reads the saved choice before the page paints).
 * Author: Jeremiah Buttler
 *
 * Class names kept for the pages nobody changed (do not rename; add new ones to this list):
 *   content      the page body inside the frame (centred, --wrap wide)       page-head   page title row
 *   card         boxed section; card-wide = fills the content width          grid, grid-5, tile (h2 label, p value, tile-note)
 *   row, row-wide   two-column row of cards                                  chart, legend, swatch   chart card parts
 *   table        every data table (data-sortable); num = right-aligned       table-tools, search, toolbar, actions, pager
 *   alert        message box (alert-error, alert-ok)                          badge, chip-st-*, chip-k-*, st, k-*   small status labels
 *   modal        full-page overlay (modal-box, modal-head, modal-actions)    doc          readable text page
 *   shell-public signed-out frame; public-mark, login-mark                    error-code, error-card   error pages
 *   caps-warn    Caps Lock warning (capslock.js)                              sort-asc, sort-desc   set by app.js on a sorted header
 * Removed in T-143: the left sidebar, the rail mode, the background drawing, the old Admin button (shell-wide, shell-rail,
 * sidebar*, menu-toggle, nav-ico, nav-label, signout, user-link, has-admin, admin-tools, admin-btn).
 */

:root {
  /* surfaces and ink */
  --bg: #ffffff;
  --surface: #f2f3f5;
  --surface-2: #e9ebef;
  --card: #ffffff;
  --ink: #111111;
  --ink-2: #2b2e33;
  --muted: #5c6066;
  --line: #dcdfe4;
  --line-strong: #c5c9d0;
  --focus: #0a84ff;

  /* the stops of the line, and their readable ink */
  --st-live: #1d1d1f;
  --st-concepts: #8e8e93;
  --st-working: #ff5a1f;
  --st-waiting: #ffb000;
  --st-building: #0a84ff;
  --st-completed: #12a150;
  --st-red: #d92d20;
  --st-working-ink: #c2410c;
  --st-waiting-ink: #8a5a00;
  --st-building-ink: #0064d2;
  --st-completed-ink: #0b7a3b;
  --st-red-ink: #b42318;

  /* the departure-board slab */
  --slab: #16181c;
  --slab-2: #22252b;
  --slab-ink: #ffd60a;
  --slab-dim: #8f939b;

  --shadow-1: 0 1px 2px rgba(17, 17, 17, .06), 0 1px 1px rgba(17, 17, 17, .04);
  --shadow-2: 0 6px 18px rgba(17, 17, 17, .08), 0 2px 6px rgba(17, 17, 17, .05);
  --shadow-3: 0 18px 48px rgba(17, 17, 17, .16), 0 6px 14px rgba(17, 17, 17, .08);

  --r: 6px;
  --r-lg: 10px;
  --route: 8px;

  --font-sign: Bahnschrift, "DIN Alternate", "DIN Condensed", "Roboto Condensed", "Arial Narrow", sans-serif;
  --font-body: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: "Cascadia Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  --ease-spring: cubic-bezier(.2, 1.3, .35, 1);
  --ease-out: cubic-bezier(.16, 1, .3, 1);
  --dur: 280ms;

  --bar-h: 64px;
  --wrap: 1360px;
  --gutter: 24px;
  color-scheme: light;

  /* legacy names, kept so the pages nobody changed still read */
  --paper: var(--bg);
  --soft: var(--muted);
  --acc: var(--st-working);
  --acc-ink: #ffffff;
  --acc2: var(--st-waiting);
  --acc2-ink: #111111;
  --tb-bg: var(--st-live);
  --tb-ink: var(--bg);
  --radius: var(--r);
  --font: var(--font-body);
  --st-new: #3b6ea5;
  --st-in_review: #c58a1e;
  --st-changes_requested: #b4532a;
  --st-approved: #2f5d3a;
  --dec-approved: var(--st-completed-ink);
  --dec-rejected: var(--st-red-ink);
  --dec-none: var(--st-concepts);
  --k-comment: var(--ink-2);
  --k-change: var(--st-working-ink);
  --k-question: var(--st-waiting-ink);
  --k-approval: var(--st-building-ink);
  --k-idea: #7a4f9a;
  --assist-bg: var(--surface);
  --assist-line: var(--line);
}

:root[data-theme="dark"] {
  --bg: #0a0a0b;
  --surface: #18181b;
  --surface-2: #222226;
  --card: #131316;
  --ink: #f4f4f5;
  --ink-2: #d4d4d8;
  --muted: #a1a1aa;
  --line: #2e2e33;
  --line-strong: #3f3f46;
  --focus: #3b9cff;
  --st-live: #e5e5ea;
  --st-concepts: #8e8e93;
  --st-working: #ff7a45;
  --st-waiting: #ffc233;
  --st-building: #3b9cff;
  --st-completed: #30c46e;
  --st-red: #ff5449;
  --st-working-ink: #ff8f5e;
  --st-waiting-ink: #ffc233;
  --st-building-ink: #6cb4ff;
  --st-completed-ink: #4fd88a;
  --st-red-ink: #ff7a71;
  --slab: #000000;
  --slab-2: #141416;
  --shadow-1: 0 1px 2px rgba(0, 0, 0, .5);
  --shadow-2: 0 8px 22px rgba(0, 0, 0, .5);
  --shadow-3: 0 22px 60px rgba(0, 0, 0, .7);
  --k-idea: #b28ad6;
  --st-new: #6aa0d8;
  --st-in_review: #e0a83a;
  --st-changes_requested: #e07a50;
  --st-approved: #5fb078;
  color-scheme: dark;
}

* , *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 var(--font-body);
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

img, svg { max-width: 100%; }
[hidden] { display: none !important; }

a { color: var(--st-building-ink); }
a:hover { color: var(--ink); }

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }

h1, h2, h3 { font-family: var(--font-sign); font-weight: 700; color: var(--ink); }
h1 { font-size: 1.9rem; line-height: 1.1; margin: 0 0 1rem; }
h2 { font-size: 1.2rem; line-height: 1.2; margin: 0 0 .75rem; }
h3 { font-size: 1.02rem; margin: 0 0 .5rem; }
p { margin: 0 0 .9rem; }

:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 4px; }

/* ------------------------------------------------------------------ frame body */

.shell { min-height: 100vh; background: var(--bg); }
.main { position: relative; min-width: 0; min-height: 100vh; display: flex; flex-direction: column; }
.content { flex: 1; min-width: 0; width: 100%; max-width: var(--wrap); margin: 0 auto; padding: 22px var(--gutter) 40px; overflow-x: clip; }  /* a closed help bubble near the edge never widens the page */
.content > h1 { font-size: 2.1rem; margin-bottom: 18px; }

/* ----------------------------------------------------------- page heading */

.page-head { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 18px; }
.page-head h1 { margin: 0 auto 0 0; font-size: 1.9rem; }

/* ------------------------------------------------------------- cards etc. */

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-1);
}
:where(.card) { padding: 18px 20px; }
.content > .card, .adm-main > .card, .row > .card { margin-bottom: 18px; }
.content > .card[class="card"] { max-width: 680px; }  /* the long-standing narrow form card; a card with a second class (card-wide, netmap, ...) is its own width */
.content > .card[class="card"]:has(.table) { max-width: none; }
.card:has(> .table) { overflow-x: auto; }  /* a wide table scrolls inside its card on a phone */
.card > form[action="/admin/website-log"] { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px; }
.card > form[action="/admin/website-log"] .field { margin-bottom: 0; flex: 1 1 170px; }
.card > form[action="/admin/website-log"] .field:first-child { flex-basis: 260px; }
@media (max-width: 640px) { .card > form[action="/admin/website-log"] .field { flex-basis: 100%; } }
.card > h2 { font-size: 1.25rem; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  grid-auto-rows: 1fr;
  gap: 10px;
  margin-bottom: 18px;
}
.grid-5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }

.tile {
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 14px 16px 12px;
  box-shadow: inset 0 4px 0 var(--st-working), var(--shadow-1);
}
.tile h2 { margin: 0; color: var(--muted); font: 700 12px/1.3 var(--font-sign); letter-spacing: .08em; text-transform: uppercase; }
.tile p { margin: 6px 0 4px; color: var(--ink); font: 700 2rem/1.2 var(--font-sign); font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.tile .badge { align-self: flex-start; }
.tile .tile-note {
  margin: auto 0 0;
  padding-top: 10px;
  border-top: 1px dashed var(--line);
  color: var(--muted);
  font: 400 12px/1.3 var(--font-body);
}

.row { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin-bottom: 18px; align-items: stretch; }
.row-wide { grid-template-columns: 1.85fr 1fr; }
.row > .card { margin-bottom: 0; }

/* chart */
.legend { display: flex; flex-wrap: wrap; gap: 6px 18px; margin: 0 0 6px; padding: 0; list-style: none; font-size: 13px; }
.swatch { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 8px; vertical-align: baseline; }
.swatch-c1 { background: var(--st-working); }
.swatch-c2 { background: var(--k-change); }
.swatch-c3 { background: var(--st-building); }
.swatch-c4 { background: var(--st-waiting); }
.swatch-c5 { background: var(--st-concepts); }
.chart svg { display: block; width: 100%; height: auto; }
.chart-empty { stroke: var(--line); stroke-width: 1; fill: none; }
.chart-axis { stroke: var(--line); stroke-width: 1.2; }
.chart-label { fill: var(--muted); font: 600 14px var(--font-body); text-anchor: middle; }

/* ----------------------------------------------------------------- tables */

.table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background: var(--card);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}
.table th {
  padding: 9px 10px;
  background: var(--surface);
  color: var(--muted);
  font: 700 12px/1.15 var(--font-sign);
  letter-spacing: .05em;
  text-transform: uppercase;
  text-align: left;
  vertical-align: bottom;
  white-space: nowrap;
}
.table th:first-child { border-top-left-radius: var(--r-lg); }
.table th:last-child { border-top-right-radius: var(--r-lg); }
.table td { padding: 7px 10px; border-top: 1px solid var(--line); text-align: left; vertical-align: middle; }
.table tbody tr:last-child td:first-child { border-bottom-left-radius: var(--r-lg); }
.table tbody tr:last-child td:last-child { border-bottom-right-radius: var(--r-lg); }
.table th.num, .table td.num { text-align: right; }
.table[data-sortable] th { cursor: pointer; user-select: none; }
.table[data-sortable] th::after { content: "\2195"; margin-left: 5px; color: var(--muted); font-size: 10px; opacity: .6; }
.table th.sort-asc, .table th.sort-desc { color: var(--ink); }
.table th.sort-asc::after { content: "\25B2"; color: var(--st-working); font-size: 9px; opacity: 1; }
.table th.sort-desc::after { content: "\25BC"; color: var(--st-working); font-size: 9px; opacity: 1; }
.table tbody tr:hover td { background: var(--surface); }
.table .empty-row td { color: var(--muted); text-align: center; padding: 26px 10px; }
.table .empty-row:hover td { background: none; }
.table a { font-weight: 700; text-decoration: none; }
.table a:hover { text-decoration: underline; }

.table-tools { overflow-x: auto; }
.search { display: block; width: 100%; max-width: 320px; margin: 0 0 12px; }
.toolbar { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px; margin: 0 0 14px; }
.toolbar .field { margin-bottom: 0; }
.toolbar .actions { margin: 0; }
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin: 16px 0 0; }
.actions form { margin: 0; }

input.search, .feature-search, .toolbar input[type="search"], .toolbar select,
.toolbar .field input, .toolbar .field select {
  min-height: 38px;
  padding: 6px 14px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--bg);
  color: var(--ink);
}
.feature-search { display: block; width: 100%; max-width: 420px; margin-bottom: 20px; }

.pager { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 12px; font-size: 13px; color: var(--muted); }
.pager a, .pager button {
  min-height: 34px;
  padding: 4px 12px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--bg);
  color: var(--ink);
  text-decoration: none;
}
.pager:has(+ .card) { margin: 0 0 14px; }
.pager a:hover, .pager button:hover:not([disabled]) { border-color: var(--ink); }
.pager button[disabled] { opacity: .45; cursor: default; }
.pager [aria-current="page"] { background: var(--ink); border-color: var(--ink); color: var(--bg); }

/* ------------------------------------------------------------ forms, etc. */

.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.field-error { margin-top: 4px; color: var(--st-red-ink); font-size: 13px; font-weight: 600; }
.field-note { margin: 6px 0 0; }
.ai-form { margin: 0 0 14px; }
.card > .page-head > h2 { margin: 0; }

.alert { padding: 10px 14px; margin-bottom: 14px; border: 1px solid var(--line); border-left-width: 5px; border-radius: var(--r); background: var(--card); }
.alert-error { border-color: var(--st-red); background: color-mix(in srgb, var(--st-red) 9%, var(--card)); color: var(--st-red-ink); }
.alert-ok { border-color: var(--st-completed); background: color-mix(in srgb, var(--st-completed) 9%, var(--card)); color: var(--st-completed-ink); }

/* small status labels (the long-standing names; chips that act are in shell.css) */
.badge {
  display: inline-block;
  padding: 2px 11px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--card);
  color: var(--ink);
  font-size: 12px;
  line-height: 1.4;
  white-space: nowrap;
}
.chip-st-new, .badge-new { --cc: var(--st-new); }
.chip-st-in_review, .badge-in-review { --cc: var(--st-in_review); }
.chip-st-changes_requested, .badge-changes { --cc: var(--st-changes_requested); }
.chip-st-approved, .badge-approved { --cc: var(--st-approved); }
.chip-k-comment { --cc: var(--k-comment); }
.chip-k-change { --cc: var(--k-change); }
.chip-k-question { --cc: var(--k-question); }
.chip-k-approval { --cc: var(--k-approval); }
.chip-k-idea { --cc: var(--k-idea); }
.chip-st-new, .chip-st-in_review, .chip-st-changes_requested, .chip-st-approved,
.chip-k-comment, .chip-k-change, .chip-k-question, .chip-k-approval, .chip-k-idea,
.badge-new, .badge-in-review, .badge-changes, .badge-approved {
  border-color: var(--cc);
  background: color-mix(in srgb, var(--cc) 12%, var(--card));
  color: var(--cc);
  font-weight: 600;
}
.chip-st-new, .chip-st-in_review, .chip-st-changes_requested, .chip-st-approved,
.chip-k-comment, .chip-k-change, .chip-k-question, .chip-k-approval, .chip-k-idea {
  min-height: 0; padding: 2px 11px; font-size: 12px; cursor: default;
}

.st { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; font-size: 12.5px; }
.st::before { content: ""; flex: none; width: 10px; height: 10px; border-radius: 50%; background: var(--sc, var(--muted)); }
.st-new { --sc: var(--st-new); }
.st-in_review { --sc: var(--st-in_review); }
.st-changes_requested { --sc: var(--st-changes_requested); }
.st-approved { --sc: var(--st-approved); }
.k-comment { --kc: var(--k-comment); }
.k-change { --kc: var(--k-change); }
.k-question { --kc: var(--k-question); }
.k-approval { --kc: var(--k-approval); }
.k-idea { --kc: var(--k-idea); }

.caps-warn { display: flex; align-items: center; gap: 8px; margin-top: 8px; color: var(--st-red-ink); font-size: 13.5px; font-weight: 700; }

/* modal (the long-standing overlay; the new layers are .dialog and .sheet in shell.css) */
.modal {
  position: fixed;
  inset: 0;
  z-index: 160;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(10, 10, 12, .45);
}
.modal-box {
  width: 100%;
  max-width: 520px;
  max-height: calc(100vh - 32px);
  overflow: auto;
  padding: 20px 22px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-3);
}
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.modal-head h2 { margin: 0; }
.modal-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 10px; margin-top: 16px; }

/* -------------------------------------------------------------- text page */

.doc { max-width: 820px; }
.doc-meta { color: var(--muted); font-size: 13px; }
.doc-section { margin-bottom: 22px; }
.doc ul, .doc ol { margin: 0 0 .9rem; padding-left: 1.4rem; }
.doc li { margin-bottom: 6px; }
.doc li[hidden], .doc-section[hidden] { display: none; }
.doc h1 { font-size: 2.1rem; }

/* ----------------------------------------------------------------- footer */

.footer {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 18px;
  max-width: var(--wrap);
  width: 100%;
  margin: 0 auto;
  padding: 14px var(--gutter);
  color: var(--muted);
  font-size: 12px;
}
.footer a { color: var(--muted); }
.footer a:hover { color: var(--ink); }
.footer-copyright { color: var(--muted); font-size: 12px; }

/* ----------------------------------------------------------- public shell */

.shell-public { display: block; }
.shell-public .main { min-height: 100vh; }
.shell-public .content {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  max-width: none;
  padding: 40px 16px 24px;
}
.public-mark, .login-mark { display: flex; justify-content: center; margin-bottom: 14px; color: var(--ink); }
.public-mark .logo-mark-large, .login-mark .logo-mark-large { width: 96px; height: 96px; }
.shell-public .content > .card { width: 100%; max-width: 420px; padding: 30px 34px 26px; }
.shell-public .content > .card.card-wide { max-width: 820px; }
.shell-public .content > .card h1 { margin: 0 0 18px; font-size: 1.5rem; text-align: center; }
.shell-public .content > .card.card-wide h1 { text-align: left; font-size: 2rem; }
.shell-public .btn--primary, .shell-public .btn-primary { width: 100%; }
.shell-public .footer { justify-content: center; }

/* ------------------------------------------------------------ error pages */

.error-code { margin: 0 0 4px; color: var(--st-working-ink); font: 700 3.6rem/1 var(--font-sign); text-align: center; }
.error-card { text-align: center; }
.error-card h1 { text-align: center; }
.error-ask { margin: 22px auto 0; padding-top: 18px; border-top: 1px dashed var(--line); max-width: 420px; text-align: center; }
.error-ask p { color: var(--muted); }

/* ------------------------------------------------------------------ narrow */

@media (max-width: 1100px) {
  .grid-5 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .row, .row-wide { grid-template-columns: 1fr; }
}

@media (max-width: 1023px) {
  :root { --gutter: 16px; --bar-h: 56px; }
  .content { padding-top: 16px; }
  .shell-public .content { padding: 28px 16px 16px; }
  .shell-public .content > .card { padding: 24px 20px; }
}

@media (max-width: 560px) {
  .grid-5 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  h1, .page-head h1, .content > h1 { font-size: 1.55rem; }
  .tile p { font-size: 1.6rem; }
  :where(.card) { padding: 14px; }
  .conn-table th, .conn-table td { padding-left: 5px; padding-right: 5px; }
}

@media (max-width: 400px) {
  .grid-5 { grid-template-columns: minmax(0, 1fr); }
}

/* T-019 concepts: the Items heading on a project page (table view) */
.lib-items-head { margin: 22px 0 10px; font-size: 16px; line-height: 1.2; }
.lib-items-n { font-weight: 400; color: var(--muted); }
.lib-items-head + .table { margin-top: 0; }

@media print {
  .topbar, .tabbar, .theme-switch, .toasts, .scrim { display: none !important; }
}
