/* zera's tokens and shell. Colours are CSS variables that UnoCSS utilities map to in uno.config.ts,
   so templates carry no hex colours. Three themes define the same token names; the dark block is
   written twice, once for the device's preference and once for an explicit choice. The values are
   the plan's own :root blocks, renamed: --bg is paper, --surface is card, --surface-2 is panel,
   --line is rule, --accent is leaf, --gold is wheat. Oat paper, soil ink, leaf green for actions
   and the desk's turn, clay for the client's turn, wheat for money. Motion is theoboard's tokens:
   short, on opacity and transform only. */

@font-face { font-family: "Libre Caslon Text"; src: url("/fonts/libre-caslon-text-latin-400-normal.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Libre Caslon Text"; src: url("/fonts/libre-caslon-text-latin-700-normal.woff2") format("woff2"); font-weight: 700; font-display: swap; }
@font-face { font-family: "Libre Caslon Text"; src: url("/fonts/libre-caslon-text-latin-400-italic.woff2") format("woff2"); font-weight: 400; font-style: italic; font-display: swap; }
@font-face { font-family: "IBM Plex Sans"; src: url("/fonts/ibm-plex-sans-latin-400-normal.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "IBM Plex Sans"; src: url("/fonts/ibm-plex-sans-latin-500-normal.woff2") format("woff2"); font-weight: 500; font-display: swap; }
@font-face { font-family: "IBM Plex Sans"; src: url("/fonts/ibm-plex-sans-latin-600-normal.woff2") format("woff2"); font-weight: 600; font-display: swap; }
@font-face { font-family: "IBM Plex Sans"; src: url("/fonts/ibm-plex-sans-latin-700-normal.woff2") format("woff2"); font-weight: 700; font-display: swap; }
@font-face { font-family: "IBM Plex Sans"; src: url("/fonts/ibm-plex-sans-latin-400-italic.woff2") format("woff2"); font-weight: 400; font-style: italic; font-display: swap; }
@font-face { font-family: "IBM Plex Mono"; src: url("/fonts/ibm-plex-mono-latin-400-normal.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "IBM Plex Mono"; src: url("/fonts/ibm-plex-mono-latin-500-normal.woff2") format("woff2"); font-weight: 500; font-display: swap; }

:root {
  --c-paper: #f3efe6; --c-card: #faf7f0; --c-panel: #e9e3d5; --c-ink: #231f1a; --c-muted: #655d51; --c-rule: #d5ccba;
  --c-leaf: #2f6b3f; --c-leaf-soft: #d8e8d6; --c-clay: #a8551b; --c-clay-soft: #f3e0cd; --c-wheat: #7d5c00;
  --c-ok: #2f7d4f; --c-warn: #9a5b00;
  --d-fast: 120ms; --d-med: 240ms; --d-slow: 480ms; --ease: cubic-bezier(.2, .8, .2, 1);
  --serif: "Libre Caslon Text", "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --sans: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --shadow: 0 1px 2px rgba(35, 31, 26, .06), 0 4px 16px rgba(35, 31, 26, .06);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --c-paper: #14120f; --c-card: #1b1814; --c-panel: #24201a; --c-ink: #ebe5d8; --c-muted: #a59c8c; --c-rule: #332d24;
    --c-leaf: #7fc98f; --c-leaf-soft: #1f3a27; --c-clay: #f0975a; --c-clay-soft: #3b2415; --c-wheat: #e3bd4e;
    --c-ok: #6cc28f; --c-warn: #e0a85a;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 16px rgba(0, 0, 0, .25);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --c-paper: #14120f; --c-card: #1b1814; --c-panel: #24201a; --c-ink: #ebe5d8; --c-muted: #a59c8c; --c-rule: #332d24;
  --c-leaf: #7fc98f; --c-leaf-soft: #1f3a27; --c-clay: #f0975a; --c-clay-soft: #3b2415; --c-wheat: #e3bd4e;
  --c-ok: #6cc28f; --c-warn: #e0a85a;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 16px rgba(0, 0, 0, .25);
  color-scheme: dark;
}

html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
body { margin: 0; min-height: 100vh; background: var(--c-paper); color: var(--c-ink); font: 1rem/1.6 var(--sans); -webkit-font-smoothing: antialiased; }
a { color: var(--c-leaf); text-underline-offset: 2px; }
:focus-visible { outline: 2px solid var(--c-leaf); outline-offset: 2px; border-radius: 4px; }
main:focus { outline: none; }
code, kbd, .mono { font-family: var(--mono); font-size: .86em; }
/* The plain-text blocks (the agreement, a stored event): the lines stand, but a narrow screen
   may not hold them, so they wrap where the box ends. */
pre { white-space: pre-wrap; overflow-wrap: anywhere; }
code { background: var(--c-panel); padding: .1em .35em; border-radius: 4px; }
kbd { background: var(--c-panel); border: 1px solid var(--c-rule); border-bottom-width: 2px; border-radius: 5px; padding: 0 .4em; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.skip-link { position: absolute; left: .5rem; top: -4rem; z-index: 50; background: var(--c-card); border: 1px solid var(--c-rule); border-radius: 8px; padding: .5rem .9rem; }
.skip-link:focus { top: .5rem; }
.js-only { display: none; }
.js .js-only { display: revert; }

/* ---------- the shell: the nav on the left, the work in the middle, the details on the right
   (plan §13). Under 1240 px the aside becomes a drawer, under 880 px the nav does, and the topbar
   carries the buttons that open them. 8 px radius on controls, 12 px on cards, 44 px tall controls. */
.shell { display: grid; grid-template-columns: 264px minmax(0, 1fr) 288px; min-height: 100vh; }
.nav, .aside { position: sticky; top: 0; height: 100vh; overflow-y: auto; padding: 24px 18px 40px; background: var(--c-card); box-sizing: border-box; }
.nav { border-right: 1px solid var(--c-rule); }
.aside { border-left: 1px solid var(--c-rule); }
main { min-width: 0; padding: 40px 48px 120px; }
.brand { display: inline-flex; align-items: center; gap: .6rem; margin: 0 0 1.25rem; color: var(--c-ink); text-decoration: none; }
.brand img { display: block; }
.brand-name { font: 400 1.375rem/1 var(--serif); }
.nav-links { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.nav-links a { display: flex; align-items: center; padding: .5rem .75rem; border-radius: 8px; color: var(--c-muted); text-decoration: none; font-weight: 600; font-size: .9375rem; min-height: 2.75rem; box-sizing: border-box; }
.nav-links a[aria-current="page"] { background: var(--c-leaf-soft); color: var(--c-leaf); }
.nav-foot { margin-top: auto; padding-top: 1rem; border-top: 1px solid var(--c-rule); font-size: .8125rem; color: var(--c-muted); display: grid; gap: .5rem; }
.who { font-weight: 600; color: var(--c-ink); overflow-wrap: anywhere; }
.link-btn { font: inherit; font-size: .8125rem; color: var(--c-muted); background: none; border: 0; padding: .25rem; min-height: 2.75rem; cursor: pointer; text-align: left; text-decoration: underline; }
/* A flash after a redirect that carries ?flash=<key>: the words are fixed in the server (pages.rs). */
.flash { padding: .75rem 1rem; margin: .75rem 0 0; border: 1px solid var(--c-rule); border-radius: 8px; background: var(--c-panel); font-size: .9375rem; }
.field-error { color: var(--c-clay); font-size: .875rem; margin: .25rem 0 0; }
.theme-form { display: flex; gap: .375rem; margin: 0; }
.theme-btn { font: inherit; font-size: .8125rem; color: var(--c-ink); background: var(--c-panel); border: 1px solid var(--c-rule); border-radius: 8px; padding: 0 .5rem; min-height: 2.75rem; cursor: pointer; flex: 1; }
.theme-btn.on { background: var(--c-leaf-soft); border-color: var(--c-leaf); color: var(--c-leaf); font-weight: 600; }
.topbar { display: none; }
.topbar .title { font: 400 1.0625rem var(--serif); }
.scrim { display: none; }
.icon-btn { font: inherit; font-size: .8125rem; color: var(--c-ink); background: var(--c-panel); border: 1px solid var(--c-rule); border-radius: 8px; padding: 0 .6rem; min-height: 2.75rem; cursor: pointer; }

@media (max-width: 1240px) {
  .shell { grid-template-columns: 248px minmax(0, 1fr); }
  .aside { position: fixed; right: 0; top: 0; width: 300px; z-index: 30; transform: translateX(100%); transition: transform var(--d-med) var(--ease); box-shadow: var(--shadow); }
  body.aside-open .aside { transform: none; }
  .topbar { display: flex; position: sticky; top: 0; z-index: 20; align-items: center; justify-content: space-between; gap: .5rem; padding: .625rem 1rem; background: color-mix(in srgb, var(--c-paper) 88%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--c-rule); }
  body.nav-open .scrim, body.aside-open .scrim { display: block; position: fixed; inset: 0; background: rgba(0, 0, 0, .35); z-index: 25; }
}
@media (max-width: 880px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .nav { position: fixed; left: 0; top: 0; width: 280px; z-index: 30; transform: translateX(-100%); transition: transform var(--d-med) var(--ease); box-shadow: var(--shadow); }
  body.nav-open .nav { transform: none; }
  main { padding: 20px 16px 100px; }
  /* A fixed topbar height for the banner to pin under, and the request page's bar of its
     sections (plan §13): the side panes are drawers, so the page carries its own. */
  .topbar { height: 3.5rem; padding: 0 .75rem; box-sizing: border-box; }
  #turn-banner { position: sticky; top: 3.5rem; z-index: 15; }
  .bottom-bar {
    display: flex; gap: .25rem; position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
    background: color-mix(in srgb, var(--c-card) 92%, transparent); backdrop-filter: blur(8px);
    border-top: 1px solid var(--c-rule); padding: .375rem .5rem calc(.375rem + env(safe-area-inset-bottom, 0px));
  }
  .bottom-bar a {
    flex: 1; display: flex; align-items: center; justify-content: center; min-height: 2.75rem; box-sizing: border-box;
    border-radius: 8px; color: var(--c-muted); text-decoration: none; font-weight: 600; font-size: .8125rem;
  }
}
@media (min-width: 881px) {
  .topbar [data-open="nav"] { visibility: hidden; }
  .bottom-bar { display: none; }
}

/* Hover effects only where a pointer can hover (plan §13). The buttons' hover lives here rather
   than in the UnoCSS shortcuts, so the one media query holds every effect of it. */
@media (hover: hover) {
  .nav-links a:hover { background: var(--c-panel); color: var(--c-ink); }
  .theme-btn:hover, .icon-btn:hover { border-color: var(--c-muted); }
  .link-btn:hover { color: var(--c-ink); }
  .btn:hover { border-color: var(--c-leaf); }
  .btn-primary:hover { filter: brightness(1.1); }
  .bottom-bar a:hover { background: var(--c-panel); color: var(--c-ink); }
}

/* Where a finger does the pointing, the targets are bigger: the plan's 44 px floor with a bump,
   and a label that carries a checkbox or a radio takes the finger's place of the small control. */
@media (pointer: coarse) {
  .field, .btn, .btn-primary { min-height: 3rem; }
  label:has(> input[type=checkbox]), label:has(> input[type=radio]) { min-height: 2.75rem; }
}

/* ---------- feedback while the server works (web/app.ts) ---------- */
/* The rule along the top: shown once a wait outlasts 150 ms, creeps toward 85%, finishes. */
#progress {
  position: fixed; inset: 0 0 auto; z-index: 1000; height: 2px; pointer-events: none;
  background: var(--c-leaf); transform-origin: left; transform: scaleX(0); opacity: 0;
}
#progress.is-active { opacity: 1; transform: scaleX(0.1); }
#progress.is-waiting { transform: scaleX(0.85); transition: transform 8s cubic-bezier(0.1, 0.6, 0.3, 1); }
#progress.is-done { transform: scaleX(1); opacity: 0; transition: transform 200ms ease-out, opacity 200ms ease 150ms; }
@media (prefers-reduced-motion: reduce) {
  #progress.is-waiting { transition: none; }
}

/* The form while it saves, and the button that asked: busy while the swap is in flight (web/app.ts
   sets aria-busy on both; the state lives in ARIA, the styling follows it, plan §13). */
form[aria-busy="true"] { opacity: .85; }
button[aria-busy="true"] { cursor: progress; opacity: .85; }

/* The upload's bar (web/upload.ts): the track and the fill; the fill's progress is its
   transform, set by the script, on the plan's motion law of opacity and transform only. */
.upload-bar { height: 4px; border-radius: 2px; background: var(--c-panel); overflow: hidden; margin: .375rem 0 0; }
.upload-bar-fill { height: 100%; background: var(--c-leaf); transform: scaleX(0); transform-origin: left; transition: transform var(--d-fast) var(--ease); }

/* A request that never arrived, or was refused whole: a toast at the bottom of the page. */
.toast {
  position: fixed; left: 50%; bottom: 1rem; z-index: 1000; transform: translateX(-50%);
  width: max-content; max-width: min(480px, calc(100vw - 2rem));
  background: var(--c-card); color: var(--c-ink); border: 1px solid var(--c-rule);
  border-radius: 8px; box-shadow: var(--shadow); padding: .625rem 1rem; font-size: .9375rem;
}

/* ---------- type ---------- */
.eyebrow { font: 600 .75rem var(--sans); letter-spacing: .1em; text-transform: uppercase; color: var(--c-clay); margin: 0 0 .25rem; }
.display { font: 500 clamp(2.25rem, 6vw, 3.5rem)/1.05 var(--serif); margin: .25rem 0 .75rem; text-wrap: balance; }
.page-h { font: 500 2rem/1.15 var(--serif); margin: 0 0 .5rem; text-wrap: balance; }
.section-h { font: 500 1.4rem/1.25 var(--serif); margin: 0 0 .25rem; }
.lede { font-size: 1.125rem; color: var(--c-muted); max-width: 44rem; margin: 0; }
.hint { font-size: .875rem; color: var(--c-muted); }
.landing { text-align: center; padding-top: 2rem; max-width: 44rem; margin: 0 auto; }
.landing .lede { margin-left: auto; margin-right: auto; }

@media print {
  .topbar, .nav, .aside, .scrim { display: none !important; }
  .shell { display: block; }
  body { background: #fff; color: #000; }
}

/* ---------- the admin's pages (A9): the users' table, a callout, a dialog, the styleguide ---------- */

/* One line's worth of form in a table cell: a select and its button. */
.inline-form { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin: 0; }
.inline-form .field { width: auto; min-width: 0; }

/* A table kept in one card-wide box: the users' list, the styleguide. */
.tbl { overflow-x: auto; border: 1px solid var(--c-rule); border-radius: 12px; background: var(--c-card); margin: .75rem 0 1.25rem; }
.tbl table { width: 100%; border-collapse: collapse; font-size: .9375rem; }
.tbl th, .tbl td { text-align: left; padding: .6rem .8rem; border-bottom: 1px solid var(--c-rule); vertical-align: top; }
.tbl th { font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; color: var(--c-muted); background: var(--c-panel); white-space: nowrap; }
.tbl tr:last-child td { border-bottom: 0; }

/* One thing a page wants read: a refusal's reason, the desk's note. */
.callout { margin: .75rem 0; padding: .75rem 1rem; border: 1px solid var(--c-leaf); border-left-width: 4px; border-radius: 8px; background: var(--c-leaf-soft); }

/* A dialog: the server renders it into #dialog, or .dialog-static on a plain page load (web/app.ts).
   The backdrop or a button[data-close-dialog] closes it, and focus returns to what opened it. */
.dialog-backdrop { position: fixed; inset: 0; z-index: 900; display: flex; align-items: center; justify-content: center; padding: 1rem; background: rgba(0, 0, 0, .35); }
.dialog { width: min(480px, 100%); border: 1px solid var(--c-rule); border-radius: 12px; background: var(--c-card); box-shadow: var(--shadow); overflow: hidden; }
.dialog-h { margin: 0; padding: 1rem 1.25rem; font: 500 1.25rem/1.25 var(--serif); border-bottom: 1px solid var(--c-rule); }
.dialog-body { padding: 1rem 1.25rem; }
.dialog-foot { display: flex; justify-content: flex-end; gap: .5rem; padding: .75rem 1rem; border-top: 1px solid var(--c-rule); background: var(--c-panel); }

/* ---------- the proof's viewer (E2) ----------
   The pins sit on the media at the comment's data-x and data-y, fractions of the file they
   are on, placed by web/proof.ts; without the script the comments stand as the numbered
   list. The markers sit on the line under a video or an audio, one per comment that carries
   a time, at the playhead's place once the duration is known. */
.proof-stage { position: relative; }
.proof-pin {
  position: absolute; z-index: 10; transform: translate(-50%, -50%);
  width: 1.75rem; height: 1.75rem; padding: 0; border-radius: 9999px;
  border: 1px solid var(--c-card); background: var(--c-clay); color: var(--c-card);
  font: 700 .8125rem var(--sans); display: flex; align-items: center; justify-content: center;
  cursor: pointer; box-shadow: var(--shadow);
}
.proof-pin.mine { background: var(--c-wheat); }
.proof-pin.resolved { background: var(--c-muted); }
.proof-timeline { position: relative; height: 1.5rem; margin-top: .5rem; border-top: 2px solid var(--c-rule); }
.proof-marker {
  position: absolute; top: 0; transform: translate(-50%, -50%);
  font: 600 .6875rem var(--mono); color: var(--c-ink); background: var(--c-card);
  border: 1px solid var(--c-rule); border-radius: 9999px; padding: 0 .375rem; cursor: pointer;
  white-space: nowrap;
}
.proof-marker.on { border-color: var(--c-clay); color: var(--c-clay); }

/* The styleguide shows every component in each theme on one page: the tokens are re-applied to a
   panel, so its children read light or dark whichever theme the page itself wears. The :root blocks
   at the top are the themes; these are the styleguide's copies (plan §13). */
.sg-theme { border: 1px solid var(--c-rule); border-radius: 12px; background: var(--c-paper); padding: 1.5rem; margin: 1rem 0 1.5rem; }
.sg-theme[data-theme="light"] {
  --c-paper: #f3efe6; --c-card: #faf7f0; --c-panel: #e9e3d5; --c-ink: #231f1a; --c-muted: #655d51; --c-rule: #d5ccba;
  --c-leaf: #2f6b3f; --c-leaf-soft: #d8e8d6; --c-clay: #a8551b; --c-clay-soft: #f3e0cd; --c-wheat: #7d5c00;
  --c-ok: #2f7d4f; --c-warn: #9a5b00;
  --shadow: 0 1px 2px rgba(35, 31, 26, .06), 0 4px 16px rgba(35, 31, 26, .06);
  color-scheme: light;
}
.sg-theme[data-theme="dark"] {
  --c-paper: #14120f; --c-card: #1b1814; --c-panel: #24201a; --c-ink: #ebe5d8; --c-muted: #a59c8c; --c-rule: #332d24;
  --c-leaf: #7fc98f; --c-leaf-soft: #1f3a27; --c-clay: #f0975a; --c-clay-soft: #3b2415; --c-wheat: #e3bd4e;
  --c-ok: #6cc28f; --c-warn: #e0a85a;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 16px rgba(0, 0, 0, .25);
  color-scheme: dark;
}
