/* Beach's design system: the tokens, and the components every screen is built
 * from. The palette and the type scale are read out of `design/beach.pen` — the
 * eight frames Jonathan approved on 13 August — rather than out of a written
 * description of them, which is what the first pass had to work from.
 *
 * Split from `screens.css` because this file crossed CLAUDE.md's 500-line limit,
 * and the boundary is a real one rather than a cut at the halfway mark: this is
 * what a component *is* (a card, a row, a tag, a button, the chrome), and
 * `screens.css` is what a particular screen *does* with them.
 *
 * Phone first, at 393. Both files are loaded on every page, in this order.
 *
 * No build step and no framework: custom properties at the top, and the cascade
 * doing the work it is good at. */

:root {
  --bg: #F6F3EE;
  --surface: #FFFFFF;
  --ink: #151918;
  --muted: #6E7671;
  --faint: #9AA19C;
  --line: #E4DFD6;
  --accent: #0F6F63;
  --accent-soft: #E0EFEA;
  --warn: #A8701B;
  --warn-soft: #FAEFDC;
  --danger: #9E3E2A;
  --ok: #3D7A4C;

  /* Inter where it exists, the platform's own face where it does not. Self-
   * hosting the woff2 would be two more files in the wheel and a dependency
   * decision; on iOS, SF sits close enough that the drawings still read. */
  --face: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue",
    system-ui, sans-serif;

  /* The type scale, straight off the frames. The gap the first pass left — a
   * 40px title and then 13px body with nothing between — is what `--t-lead` and
   * `--t-title` fill: a page title, a thing that leads a card, a row, a sub. */
  --t-mark: 9.5px;      /* BEACH, and every section label */
  --t-title: 25px;      /* "Wednesday, 12 Aug", "Queue", "Log" */
  --t-lead: 16.5px;     /* what leads a card: the quote, the read-back task */
  --t-head: 15px;       /* an attention headline, a card heading */
  --t-subject: 14px;    /* a mail subject in a list */
  --t-body: 13px;       /* the body size of every row */
  --t-sub: 12.5px;      /* a page subtitle, a chip */
  --t-small: 11px;      /* a row's second line */
  --t-tiny: 10.5px;     /* a timestamp, a business label */

  --pad: 20px;          /* the phone frames' content inset */
  --gap: 16px;
  --radius: 14px;
  --radius-sm: 10px;
  --tabs-h: 54px;
  --side-w: 236px;
  --tap: 44px;          /* the phone minimum, and it is not negotiable */

  /* The one effect in the whole file, and it is the tab bar's, from the frame:
   * #1519181F at 0 6 18 -4. Cards in the design carry a hairline and no
   * elevation — depth is what separates the floating chrome from the page. */
  --lift: 0 6px 18px -4px rgba(21, 25, 24, 0.12);
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--face);
  font-size: var(--t-body);
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
h1, h2, h3, p, ul, ol, dl, dd, figure { margin: 0; }
ul, ol { list-style: none; padding: 0; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.85em; }
svg.ic { flex: none; display: block; }

/* Keyboard is how the always-on view gets driven, so every interactive element
 * says where it is. One rule, applied to what the browser already knows is
 * focusable, rather than a class somebody has to remember to add. */
:is(a, button, summary, input, textarea, select, [tabindex]):focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 6px;
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 8px;
  z-index: 40;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  border: 1px solid var(--line);
  font-weight: 600;
}
.skip-link:focus { left: 8px; }

/* --- the shell ---------------------------------------------------------- */

.shell {
  /* The tab bar floats over the page, so the page has to end above it. */
  padding-bottom: calc(var(--tabs-h) + env(safe-area-inset-bottom) + 26px);
}

.page { display: grid; gap: 24px; padding: 0 var(--pad) 24px; }
/* Every level of the page is a grid, and a grid item's default `min-width: auto`
 * refuses to shrink below its content's minimum — so one long line anywhere
 * inside widened the whole document past 393 and pushed the tab bar off the
 * right of the screen. The chain has to be broken at every level, not the last
 * one. */
.page > *, .cols > *, .col-side > *, .section, .section > * { min-width: 0; }

/* --- the top of a screen ------------------------------------------------ */

.top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  /* The frames give the status bar 56px and then start the content at 4px.
   * On a real phone that band is the operating system's, so it is a safe-area
   * inset here rather than a drawing of a battery. */
  padding: calc(env(safe-area-inset-top) + 18px) var(--pad) 4px;
}

.top-line { display: grid; gap: 4px; min-width: 0; }

.eyebrow {
  color: var(--muted);
  font-size: var(--t-sub);
  font-weight: 400;
}

.top h1 {
  font-size: var(--t-title);
  font-weight: 600;
  letter-spacing: -0.028em;
  line-height: 1.15;
}

.mark {
  color: var(--accent);
  font-size: var(--t-mark);
  font-weight: 700;
  letter-spacing: 0.23em;
}
.mark-sub { color: var(--faint); font-size: 11.5px; }

/* The 36px circle the frames put beside a page title. */
.icon-button {
  display: grid;
  place-items: center;
  width: var(--tap);
  height: var(--tap);
  flex: none;
  border: 0;
  background: none;
  color: var(--muted);
  cursor: pointer;
}
.icon-button > svg {
  padding: 9px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--line);
  box-sizing: content-box;
  width: 16px;
  height: 16px;
}

/* --- the tab bar, `C · Tabs` -------------------------------------------- */

.tabs {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: calc(env(safe-area-inset-bottom) + 10px);
  height: var(--tabs-h);
  padding: 5px;
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  border-radius: 27px;
  background: rgba(255, 255, 255, 0.86);
  backdrop-filter: saturate(180%) blur(14px);
  border: 1px solid var(--line);
  box-shadow: var(--lift);
  z-index: 20;
}

.tab {
  display: grid;
  place-items: center;
  align-content: center;
  gap: 2px;
  border-radius: 22px;
  color: var(--muted);
  font-size: var(--t-mark);
  font-weight: 500;
}
.tab.is-on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }

/* --- the sidebar, `C · Side` -------------------------------------------- */

/* Off screen on a phone and not merely invisible: a hidden nav that a screen
 * reader still walks is two navigations for one set of four links. */
.side { display: none; }

/* --- sections and cards ------------------------------------------------- */

/* A section is a label and a group of rows, with no box around it. That is the
 * rhythm the frames use on the phone and it is what the first pass was missing:
 * six identical white cards in a column, so nothing led. */
.section { display: grid; gap: 11px; }

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.section-label {
  color: var(--faint);
  font-size: var(--t-mark);
  font-weight: 700;
  letter-spacing: 0.147em;
  text-transform: uppercase;
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px var(--pad) 0;
}
.card-head h2 { font-size: var(--t-head); font-weight: 600; letter-spacing: -0.013em; }
.card-pad { padding: 14px 15px; display: grid; gap: 10px; }

.more { font-size: var(--t-small); color: var(--faint); font-weight: 400; }
a.more { color: var(--accent); font-weight: 600; }

/* --- rows --------------------------------------------------------------- */

.rows { display: grid; gap: 12px; }
.rows > li, .rows a { min-width: 0; }
.rows a { display: grid; gap: 2px; }

/* `min-width: 0` on every one of these, because a grid item's default
 * `min-width: auto` refuses to shrink below its content — and `.row-title`
 * is deliberately `nowrap`, so one long subject widened the whole page past
 * 393 and put the tab bar half off the screen. */
.row { display: grid; gap: 2px; min-width: 0; }
.row > * { min-width: 0; }
.row-top { display: flex; align-items: center; gap: 8px; min-width: 0; }
.row-title {
  font-size: var(--t-body);
  font-weight: 500;
  min-width: 0;
  flex: 1;
  /* Wraps to two lines and then stops. The frames draw these as fixed-width
   * text that wraps (`textGrowth: fixed-width`), and `nowrap` here was not only
   * wrong against the design — a grid item's min-content is the whole
   * unbreakable line, so one long commitment pushed the page past 393 and took
   * the tab bar half off the screen with it. */
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.row-sub { font-size: var(--t-small); color: var(--muted); }
.row-body {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.45;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.row-time {
  font-variant-numeric: tabular-nums;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink);
  flex: none;
  width: 42px;
}
.row-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 4px; }
.count { font-variant-numeric: tabular-nums; font-weight: 600; color: var(--accent); }
.stamp { font-size: var(--t-tiny); color: var(--faint); font-variant-numeric: tabular-nums; }
.reasons { font-size: var(--t-small); color: var(--warn); }

/* A row carried by a coloured bar rather than a box — `Owed` in the frames. */
.row-barred { display: grid; grid-template-columns: 3px 1fr; gap: 10px; align-items: stretch; }
.row-barred > .bar { border-radius: 2px; background: var(--warn); }
.row-barred > .row { min-width: 0; }
.row-barred.is-accent > .bar { background: var(--accent); }

.dot { width: 6px; height: 6px; border-radius: 50%; background: var(--faint); flex: none; }
.dot-ok { background: var(--ok); }
.dot-warn { background: var(--warn); }
.dot-danger { background: var(--danger); }
.dot-accent { background: var(--accent); }

/* --- states: empty, loading, error -------------------------------------- */

/* A quiet day is not a broken page. An empty section says what would be here
 * and when it next gets a chance to be, rather than leaving a gap. */
.is-empty {
  display: grid;
  justify-items: start;
  gap: 3px;
  padding: 16px 0;
  color: var(--faint);
}
.is-empty .empty-head { font-size: var(--t-body); font-weight: 500; color: var(--muted); }
.is-empty .empty-note { font-size: var(--t-small); }
.card > .is-empty { padding: 18px 15px; }

/* What a control looks like between the tap and the answer. HTMX flips
 * `.htmx-request` on the element carrying `hx-*`, so this needs no script. */
.htmx-request .button, .button.is-busy { opacity: 0.55; pointer-events: none; }
.htmx-request .button::after, .button.is-busy::after {
  content: "";
  width: 13px;
  height: 13px;
  margin-left: 8px;
  border-radius: 50%;
  border: 2px solid currentColor;
  border-right-color: transparent;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* A skeleton, for the moment before the stream has said anything. */
.skeleton { display: grid; gap: 12px; padding: 4px 0; }
.skeleton[hidden] { display: none; }
.skeleton span {
  height: 11px;
  border-radius: 6px;
  background: var(--line);
  animation: breathe 1.6s ease-in-out infinite;
}
.skeleton span:nth-child(2) { width: 72%; }
.skeleton span:nth-child(3) { width: 55%; }
@keyframes breathe { 50% { opacity: 0.45; } }

/* --- tags, banners, buttons --------------------------------------------- */

.tag {
  flex: none;
  padding: 3px 8px;
  border-radius: 6px;
  background: var(--bg);
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: var(--t-tiny);
  font-weight: 600;
  white-space: nowrap;
}

.tag-warn { background: var(--warn-soft); border-color: #EEDCBC; color: var(--warn); }
.tag-ours { background: var(--accent-soft); border-color: #C9E2DA; color: var(--accent); }
.tag-theirs { background: var(--bg); }

.chip {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 7px 13px;
  border-radius: 15px;
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}
.chip.is-on { background: var(--ink); border-color: var(--ink); color: #fff; }

/* The one block on a screen that leads. Accent fill, white type, and it is the
 * thing the eye lands on first — the frames use it for "4 drafts waiting on
 * you" and nothing else on the page competes with it. */
.attention {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 16px;
  border-radius: var(--radius);
  background: var(--accent);
  color: #fff;
}
.attention > span { min-width: 0; }
.attention-head { display: block; font-size: var(--t-head); font-weight: 600; }
.attention-sub {
  display: block;
  font-size: var(--t-small);
  color: rgba(255, 255, 255, 0.72);
  margin-top: 3px;
}
.attention .ic { flex: none; }

.banner {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  padding: 12px 13px;
  border-radius: 11px;
  font-size: var(--t-sub);
  line-height: 1.4;
}
.banner .ic { margin-top: 1px; }
.banner strong { display: block; font-weight: 600; }
.banner-warn { background: var(--warn-soft); color: #6F4A10; }
.banner-ok { background: var(--accent-soft); color: #0B4B43; }
.banner-danger { background: #F7E4DF; color: var(--danger); }
.banner .reasons { display: block; margin-top: 3px; color: inherit; opacity: 0.85; }

.note { font-size: var(--t-small); color: var(--faint); }

.button {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: var(--tap);
  border: 1px solid var(--line);
  background: none;
  color: var(--muted);
  font: inherit;
  font-size: var(--t-sub);
  font-weight: 600;
  padding: 9px 14px;
  border-radius: 9px;
  cursor: pointer;
  transition: transform 0.12s ease;
}
.button:active { transform: scale(0.985); }
.button-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.button-danger { color: var(--danger); border-color: var(--line); }
.button:disabled { opacity: 0.42; cursor: not-allowed; }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--accent);
  font-size: var(--t-small);
  font-weight: 600;
}

.avatar {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  flex: none;
  border-radius: 9px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: var(--t-small);
  font-weight: 700;
  letter-spacing: 0.02em;
}

/* Approve and reject sit next to each other and one of them is irreversible,
 * so they are never the same size, the same colour, or adjacent by accident. */
.actions { display: flex; align-items: center; gap: 9px; }
.actions .button { flex: 1; }
.actions .button-icon { flex: none; width: 46px; min-width: 46px; padding: 0; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  /* The page transition is not covered by the selector above: it animates a
   * pseudo-element tree the document does not contain. */
  ::view-transition-group(*), ::view-transition-old(*), ::view-transition-new(*) {
    animation: none !important;
  }
}
