/* ============================================================================
   components.css — the reusable pieces from 00-design-system.html: buttons,
   reply-code pills, badges, cards, form fields, data tables, code blocks.

   Where the design system and a page prototype disagree, the design system
   wins. Two such disagreements exist and are resolved here rather than
   silently: 07-overview-populated.html draws .btn at 32px and .badge at
   10.5px, against 00's 34px and 11px. The pages were exported at different
   times; 00 is what spec 004 names as the source of truth, so 00's values are
   the ones below and the dashboard inherits them.

   Depends on tokens.css and base.css.
   ========================================================================= */

/* --------------------------------------------------------------- buttons --
   One element, four variants. `.primary` is the single affirmative action on
   a page; `.danger` is outline-only because a destructive action should not
   be the most eye-catching thing on screen — spec 004 R23 puts a confirm step
   in front of it regardless. */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 34px;
  padding: 0 14px;
  border-radius: var(--r);
  border: 1px solid var(--line-2);
  background: var(--bg-1);
  color: var(--ink);
  font: 500 13px var(--sans);
  text-decoration: none;
  cursor: pointer;
  transition: border-color .12s, background .12s;
}

.btn:hover {
  border-color: var(--ink-3);
}

.btn.primary {
  background: var(--green);
  border-color: var(--green);
  color: var(--green-ink);
  font-weight: 600;
}

.btn.primary:hover {
  filter: brightness(1.08);
}

.btn.ghost {
  background: transparent;
  border-color: transparent;
  color: var(--ink-2);
}

.btn.ghost:hover {
  color: var(--ink);
}

.btn.danger {
  border-color: var(--red);
  color: var(--red);
  background: transparent;
}

.btn.lg {
  height: 42px;
  padding: 0 20px;
  font-size: 14px;
}

/* A disabled control has to look disabled without relying on colour alone,
   since --ink-3 is already the de-emphasised text colour. Not in the
   prototype; every form in the app has a submit button that can be busy. */
.btn:disabled,
.btn[aria-disabled='true'] {
  opacity: .5;
  cursor: not-allowed;
}

/* ---------------------------------------------------------- reply pills --
   The brand motif: the system speaks in SMTP reply codes. The code itself is
   the emphasised part, the gloss beside it is not. Colour follows the class
   of the reply — 2xx green, 4xx amber, 5xx red — so the pill is readable as a
   status at a glance and as a code on inspection. */

.reply {
  display: inline-flex;
  gap: 10px;
  align-items: baseline;
  font-family: var(--mono);
  font-size: 12px;
  padding: 5px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--bg-1);
}

.reply b {
  color: var(--green);
  font-weight: 600;
}

.reply.warn b {
  color: var(--amber);
}

.reply.err b {
  color: var(--red);
}

/* ------------------------------------------------------- htmx indicator --
   htmx would inject exactly these three rules as an inline <style> on boot;
   the layout sets `includeIndicatorStyles: false` and they live here instead,
   because an injected inline style is refused under `style-src 'self'` and the
   alternative — nonce-ing it — would make every response uncacheable.

   Kept byte-for-byte equivalent to htmx's own defaults, so upgrading htmx does
   not silently change indicator behaviour. base.css already removes the
   transition under prefers-reduced-motion. */

.htmx-indicator {
  opacity: 0;
  transition: opacity 200ms ease-in;
}

.htmx-request .htmx-indicator,
.htmx-request.htmx-indicator {
  opacity: 1;
}

/* --------------------------------------------------------------- badges --
   The ::before dot is what makes a badge legible to someone who cannot
   distinguish the colours: the text ("verified", "pending", "failed") always
   states the status, and the dot only reinforces it. Never a badge whose
   meaning is carried by hue alone. */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font: 500 11px var(--mono);
  letter-spacing: .08em;
  text-transform: uppercase;
  padding: 3px 9px;
  border-radius: 999px;
  border: 1px solid var(--line-2);
  color: var(--ink-2);
}

.badge::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--ink-3);
}

.badge.ok {
  color: var(--green);
  border-color: oklch(80% .19 152 / .35);
  background: var(--green-soft);
}

.badge.ok::before {
  background: var(--green);
}

.badge.warn {
  color: var(--amber);
  border-color: oklch(80% .13 82 / .35);
  background: var(--amber-soft);
}

.badge.warn::before {
  background: var(--amber);
}

.badge.err {
  color: var(--red);
  border-color: oklch(68% .19 25 / .35);
  background: var(--red-soft);
}

.badge.err::before {
  background: var(--red);
}

/* ---------------------------------------------------------------- cards -- */

.card {
  background: var(--bg-1);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
}

.card .hd {
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  font-weight: 600;
  font-size: 14px;
}

/* Header with something pushed to the right — a link, a count, a filter. */
.card .hd-row {
  display: flex;
  align-items: center;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  font-weight: 600;
  font-size: 14px;
}

.card .hd-row .r {
  margin-left: auto;
  font: 400 12px var(--mono);
  color: var(--ink-3);
}

.card .hd-row a:hover {
  color: var(--green);
}

.card .bd {
  padding: 18px;
}

/* ---------------------------------------------------------------- forms --
   Inputs are mono: everything this app asks for is a value rather than prose
   — a domain, a hostname, an email address — and mono makes a transposed
   character visible. */

.field {
  margin-bottom: 16px;
}

.field-label {
  display: block;
  font: 500 11px var(--mono);
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin-bottom: 6px;
}

.input {
  width: 100%;
  height: 38px;
  padding: 0 12px;
  border-radius: var(--r);
  border: 1px solid var(--line-2);
  background: var(--bg);
  color: var(--ink);
  font: 400 14px var(--mono);
}

.input::placeholder {
  color: var(--ink-3);
}

.input:focus {
  outline: 2px solid var(--green);
  outline-offset: -1px;
  border-color: transparent;
}

/* aria-invalid rather than a class: the attribute is what a screen reader
   announces, so styling off it makes the two impossible to disagree. */
.input[aria-invalid='true'] {
  border-color: var(--red);
}

.field-error {
  font: 400 12px var(--mono);
  color: var(--red);
  margin-top: 6px;
}

/* Shorter than .input, because a select sits in a filter bar rather than in a
   form column, and sized to the buttons beside it. `appearance` is left alone:
   the native arrow is the only affordance saying this opens a list, and drawing
   a replacement would need a background image the CSP would have to allow. */
.select {
  height: 32px;
  padding: 0 8px;
  border-radius: var(--r);
  border: 1px solid var(--line-2);
  background: var(--bg);
  color: var(--ink);
  font: 400 12.5px var(--mono);
}

.select:focus {
  outline: 2px solid var(--green);
  outline-offset: -1px;
  border-color: transparent;
}

/* Small print under a field — the format expected, or where to find a value. */
.field-hint {
  font: 400 12px var(--mono);
  color: var(--ink-3);
  margin-top: 6px;
}

/* ----------------------------------------------------------- data tables --
   Column headers are uppercase mono at 10.5px, small enough that they read as
   labels rather than content. `td.num` opts a cell into mono: counts, sizes,
   timestamps and addresses, never subjects or names. */

table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

table.data th {
  font: 500 10.5px var(--mono);
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--ink-3);
  text-align: left;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
}

table.data td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

table.data tr:last-child td {
  border-bottom: 0;
}

table.data td.num {
  font-family: var(--mono);
  font-size: 12.5px;
}

/* ----------------------------------------------------------- code block --
   The three dots in the bar are decorative chrome, so they are generated
   content on empty <i> elements and never reach the accessibility tree. */

.code {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  overflow: hidden;
}

.code .bar {
  display: flex;
  gap: 6px;
  align-items: center;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  font: 400 11px var(--mono);
  color: var(--ink-3);
}

.code .bar i {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--line-2);
  font-style: normal;
}

.code pre {
  padding: 18px;
  font: 400 12.5px/1.7 var(--mono);
  overflow-x: auto;
  color: var(--ink-2);
}

/* Syntax roles, applied server-side. Not a highlighter: three classes, hand
   applied to the few code samples the docs page carries. */
.code .k { color: var(--ink); }
.code .s { color: var(--green); }
.code .c { color: var(--ink-3); }
