/* The Link look over Pico: ink and white, Geist, pills and soft cards. Loaded last.
   Tokens follow the brand guide (agent-mail marketing/brand/backchannel-link). Mostly Pico's
   own variables, so the pages keep their plain HTML. Geist: SIL OFL, see fonts/OFL.txt. */

@font-face {
  font-family: "Geist";
  src: url("fonts/geist.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}
@font-face {
  font-family: "Geist Mono";
  src: url("fonts/geist-mono.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}

:root {
  --bg: #fff;
  --fg: #0a0a0a;
  --tint: #f2f2f2;
  --line: #e5e5e5;
  --muted: #6b6b6b;
  --error: #b91c1c;
  --success: #15803d;
  --mono: "Geist Mono", ui-monospace, "SF Mono", Menlo, monospace;
  --page: 64rem;
  --gutter: 1rem;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0a0a0a;
    --fg: #fff;
    --tint: #1a1a1a;
    --line: #262626;
    --muted: #a3a3a3;
    --error: #f87171;
    --success: #4ade80;
  }
}
@media (min-width: 768px) {
  :root { --gutter: 2rem; }
}

/* Same weight as Pico's theme selectors, so these win by coming later, in light and dark. */
:root:not([data-theme]) {
  --pico-font-family-sans-serif: "Geist", system-ui, -apple-system, "Segoe UI", sans-serif;
  --pico-font-family-monospace: var(--mono);
  --pico-font-size: 93.75%; /* 15 px at every width; Pico grows it to 21 px */
  --pico-line-height: 1.55;
  --pico-border-radius: 0.75rem;
  --pico-form-element-spacing-vertical: 0.625rem;
  --pico-form-element-spacing-horizontal: 0.875rem;
  --pico-transition: 0.15s ease-out;

  --pico-background-color: var(--bg);
  --pico-color: var(--fg);
  --pico-muted-color: var(--muted);
  --pico-muted-border-color: var(--line);
  --pico-h1-color: var(--fg);
  --pico-h2-color: var(--fg);
  --pico-h3-color: var(--fg);
  --pico-h4-color: var(--fg);
  --pico-h5-color: var(--fg);
  --pico-h6-color: var(--fg);

  --pico-primary: var(--fg);
  --pico-primary-background: var(--fg);
  --pico-primary-border: var(--fg);
  --pico-primary-underline: var(--muted);
  --pico-primary-hover: var(--fg);
  --pico-primary-hover-background: color-mix(in srgb, var(--fg) 82%, var(--bg));
  --pico-primary-hover-border: transparent;
  --pico-primary-hover-underline: var(--fg);
  --pico-primary-focus: color-mix(in srgb, var(--fg) 22%, transparent);
  --pico-primary-inverse: var(--bg);
  --pico-box-shadow: none;
  --pico-button-box-shadow: none;
  --pico-button-hover-box-shadow: none;

  --pico-card-background-color: var(--tint);
  --pico-card-border-color: var(--line);
  --pico-card-box-shadow: none;
  --pico-card-sectioning-background-color: transparent;
  --pico-code-background-color: var(--tint);
  --pico-code-color: var(--fg);
  --pico-table-border-color: var(--line);
  --pico-accordion-close-summary-color: var(--fg);
  --pico-accordion-open-summary-color: var(--fg);
  --pico-accordion-active-summary-color: var(--fg);

  --pico-form-element-background-color: var(--bg);
  --pico-form-element-border-color: color-mix(in srgb, var(--fg) 16%, var(--bg));
  --pico-form-element-color: var(--fg);
  --pico-form-element-placeholder-color: var(--muted);
  --pico-form-element-active-background-color: var(--bg);
  --pico-form-element-active-border-color: var(--fg);
  --pico-form-element-focus-color: var(--pico-primary-focus);
  --pico-form-element-invalid-border-color: var(--error);
  --pico-form-element-invalid-active-border-color: var(--error);
  --pico-form-element-invalid-focus-color: color-mix(in srgb, var(--error) 25%, transparent);
  --pico-del-color: var(--error);
}

::selection { background: var(--fg); color: var(--bg); }
body { -webkit-font-smoothing: antialiased; }
strong, b { font-weight: 600; }
small { color: var(--muted); }
[id$="-error"] { color: var(--error); } /* code-error, email-error, send-error */
main p { max-width: 72ch; }

/* Header: a full-width bar with a hairline; the page column is narrower than Pico's. */
body > header {
  max-width: none;
  padding: 0 var(--gutter);
  border-bottom: 1px solid var(--line);
}
nav { --pico-nav-element-spacing-vertical: 0.75rem; --pico-nav-element-spacing-horizontal: 0.125rem; }
body > header > nav,
body > main {
  max-width: var(--page);
  margin-inline: auto;
}
body > main { padding: 2.5rem var(--gutter) 4rem; }
body { display: flex; flex-direction: column; min-height: 100vh; }
body > main { flex: 1; }
/* The wordmark: the mark plus "Link" in Geist 500, as the brand guide sets for nav bars. */
.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 1.0625rem;
  font-weight: 500;
  letter-spacing: -0.02em;
}
.brand svg { width: 1.375rem; height: 1.375rem; }
nav li :where(a) {
  padding: 0.375rem 0.75rem;
  border-radius: 999px;
  color: var(--muted);
  font-size: 0.9375rem;
}
nav li a:hover { color: var(--fg); text-decoration: none; }
/* Senders waiting in Requests: an ink count that htmx keeps fresh; empty means none. The
   count alone says "waiting": the label stays muted, so an ink label with its underline
   still means only "current". */
.badge {
  margin-left: 0.375rem;
  padding: 0.0625rem 0.4375rem;
  border-radius: 999px;
  background: var(--fg);
  color: var(--bg);
  font: 500 0.6875rem/1.4 var(--mono);
  vertical-align: 0.1em;
}
.badge:empty { display: none; }
/* Sign out, on the bar: Pico's [type=submit] bottom margin and 1rem size beat console.css. */
nav [type="submit"] { margin: 0; padding: 0.375rem 0.875rem; font-size: 0.9375rem; }

/* The agent's light beside the wordmark: a status, so green and red only mean something
   (brand guide). Plain words with a dot, no box; empty until the first poll. */
nav li a.agent {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0 0 0 0.75rem;
  padding: 0;
  font-size: 0.8125rem;
}
nav li a.agent:empty { display: none; }
.dot { width: 0.5rem; height: 0.5rem; border-radius: 50%; background: var(--muted); }
.dot.off { background: var(--error); }
.dot.on { background: var(--success); animation: breathe 2.4s ease-out infinite; }
@keyframes breathe {
  0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--success) 60%, transparent); }
  70%, 100% { box-shadow: 0 0 0 0.4rem transparent; }
}

/* The pages: plain tabs on the header's hairline, the current one underlined in ink. The
   underline sits over the hairline, so each tab is a clear, separate box with no overlap.
   On a phone the row scrolls sideways, and console.js brings the current tab into view. */
nav.tabs { margin-bottom: -1px; }
nav.tabs ul { display: flex; flex-wrap: nowrap; gap: 1.5rem; margin: 0; padding: 0; overflow-x: auto; scrollbar-width: none; scroll-padding-inline: 2.5rem; }
@media (max-width: 767px) { nav.tabs ul { padding-inline-end: 2.5rem; } } /* room to scroll the last tab clear */
nav.tabs li { padding: 0; }
nav.tabs li a {
  display: block;
  margin: 0;
  padding: 0.5rem 0 0.625rem;
  border-radius: 0;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
}
nav.tabs li a:hover { border-bottom-color: var(--line); }
nav.tabs a[aria-current="page"] { color: var(--fg); font-weight: 500; border-bottom-color: var(--fg); }
@media (max-width: 575px) {
  nav.tabs ul { gap: 1.25rem; }
  nav.tabs li a { font-size: 0.875rem; }
}

/* Footer: the company, quietly, on tint below a hairline, like the site's. */
body > footer {
  max-width: none;
  padding: 1.25rem var(--gutter) 1.5rem;
  border-top: 1px solid var(--line);
  background: var(--tint);
}
body > footer > * { max-width: var(--page); margin-inline: auto; }
body > footer .brand { font-size: 0.9375rem; }
body > footer .brand svg { width: 1.125rem; height: 1.125rem; }
body > footer .brand small { font-weight: 400; }
body > footer p { margin-top: 0.25rem; margin-bottom: 0; }

/* Type: tight headings, like the site. */
h1, h2, h3 { --pico-font-weight: 600; }
h1 { --pico-font-size: 1.75rem; letter-spacing: -0.03em; }
h2 {
  --pico-font-size: 1.125rem;
  letter-spacing: -0.02em;
  margin-top: 2.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--line);
}
hgroup > h1 + p { margin-top: 0.375rem; }
code, kbd { padding: 0.125rem 0.375rem; border-radius: 0.375rem; font-size: 0.8125rem; }
pre { padding: 1rem; line-height: 1.6; }
pre > code { padding: 0; }

/* Buttons: ink pills; secondary is a hairline outline. Press to 96%, as on the site. */
button, [type="submit"], [type="button"] {
  border-radius: 999px;
  font-weight: 500;
  transition: background-color var(--pico-transition), border-color var(--pico-transition),
    color var(--pico-transition), transform 90ms ease-out;
}
button:not(.link):active { transform: scale(0.96); }
button[type="submit"] { width: auto; }
button.secondary { border-color: var(--line); color: var(--fg); }
button.secondary:hover { background: var(--tint); border-color: var(--line); }
/* On a tint card the hairline vanishes, so a secondary button there takes a stronger one. */
article button.secondary,
article button.secondary:hover { border-color: color-mix(in srgb, var(--fg) 30%, transparent); }
article button.secondary:hover { background: var(--bg); }
button[data-copy] { padding: 0.25rem 0.875rem; font-size: 0.8125rem; }
label { font-weight: 500; }

/* While htmx has a form's request in flight, its button says so. */
form.htmx-request [type="submit"], .htmx-request[type="submit"] { opacity: 0.55; cursor: progress; }

/* Cards: tint, 16 px, no border or shadow. */
article { border-radius: 1rem; }
article > header { border-top-left-radius: 1rem; border-top-right-radius: 1rem; }
article > footer { border-bottom-left-radius: 1rem; border-bottom-right-radius: 1rem; }
article code, article pre { background: var(--bg); }
/* Requests: each held message a row with a hairline, its body opened in place. */
article > details { margin: 0; padding: 0.75rem 0; border-bottom: 1px solid var(--line); }
article > details:last-of-type { margin-bottom: 1rem; }
article > details summary { line-height: 1.5; }
article > details pre { margin: 0.75rem 0 0; }
[id^="line-"] { /* the lines to paste, in the Setup checklist */
  display: block;
  padding: 0.75rem 1rem;
  border: 1px solid var(--line);
  border-radius: 0.75rem;
  line-height: 1.6;
}

/* The Setup steps: quiet numbers, the current one in ink. */
ol > li::marker { color: var(--muted); font-family: var(--mono); font-size: 0.8125rem; }
ol > li[aria-current="step"]::marker { color: var(--fg); }
ol > li + li { margin-top: 0.5rem; }

/* Status: a red dot and plain text, never a coloured block. */
mark { padding: 0; background: none; color: inherit; }
mark::before, [role="alert"]::before {
  content: "";
  display: inline-block;
  width: 0.5rem;
  height: 0.5rem;
  margin-right: 0.5rem;
  border-radius: 50%;
  background: var(--error);
  vertical-align: 0.1em;
}
[role="alert"], [role="status"] { padding: 0.625rem 1rem; border-radius: 0.75rem; background: var(--tint); }

/* Tables: mono labels, hairlines. */
th, td { --pico-border-width: 1px; }
thead th {
  font: 400 0.75rem/1.4 var(--mono);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

/* The inbox: a list with hairlines rather than stacked accordions. */
#messages > details { margin: 0; padding: 0.875rem 0; border-bottom: 1px solid var(--line); }
#messages > details:first-of-type { border-top: 1px solid var(--line); }
#messages summary { line-height: 1.5; }

/* A form htmx swaps in (email, then code) rises in. htmx drops .htmx-added once it has
   settled, so a page load never animates, and the polled inbox swaps no such form. */
form[hx-swap="outerHTML"] { transition: opacity 240ms ease-out, transform 240ms ease-out; }
form[hx-swap="outerHTML"].htmx-added { opacity: 0; transform: translateY(6px); }

/* The sign-in page: one centred card. */
.signin { max-width: 26rem; margin: 3rem auto; padding: 2rem; }
.signin h1 { margin-bottom: 1.25rem; }

@media (prefers-reduced-motion: reduce) {
  button:not(.link):active { transform: none; }
  .dot.on { animation: none; box-shadow: 0 0 0 0.2rem color-mix(in srgb, var(--success) 30%, transparent); }
  form[hx-swap="outerHTML"] { transition: none; }
}
