/* ---- 12. Code & misc ------------------------------------------------------ */

code {
  padding: 0.1em 0.32em;
  border: 1px solid var(--ta-border);
  border-radius: 4px;
  background: var(--ta-surface-2);
  font-family: var(--ta-mono);
  font-size: 0.85em;
}

footer {
  margin-top: auto;
  margin-inline: calc(50% - 50vw);
  padding-inline: max(1.5rem, calc((100vw - var(--container-max)) / 2 + 1.5rem));
  padding-block: 1.5rem;
  border-top: 1px solid var(--ta-border);
  color: var(--ta-muted);
  text-align: center;
}

/* ---- 12a. Tones (shared by badges, status dots, alerts) ------------------ */

/* One semantic word drives colour everywhere. Each tone sets THREE values, the
   reference's soft/ink/base triple:
     --tone       the saturated base — borders, dots, rules
     --tone-soft  its tinted wash — fills
     --tone-ink   the darkened text colour for type ON that wash
   Two values were not enough: a wash light enough to sit behind body text and a
   colour saturated enough to read as a border cannot be the same colour, so
   text on a soft fill was previously tinted with the base and came out too
   light to meet contrast. Ink is contrast-engineered against soft, per tone.
   Components read the properties, so one word is one colour on a badge, a dot
   and an alert alike. Values are the reference's oklch scale. */
.tone-ok {
  --tone: oklch(0.62 0.15 155);
  --tone-soft: oklch(0.95 0.045 155);
  --tone-ink: oklch(0.44 0.11 155);
}

.tone-err {
  --tone: oklch(0.58 0.223 25);
  --tone-soft: oklch(0.95 0.04 25);
  --tone-ink: oklch(0.505 0.17 25);
}

.tone-warn {
  --tone: oklch(0.72 0.15 75);
  --tone-soft: oklch(0.95 0.05 85);
  --tone-ink: oklch(0.47 0.09 70);
}

.tone-info {
  --tone: oklch(0.6 0.13 236);
  --tone-soft: oklch(0.95 0.04 236);
  --tone-ink: oklch(0.46 0.13 240);
}

.tone-muted {
  --tone: var(--ta-muted);
  --tone-soft: var(--ta-surface-2);
  --tone-ink: var(--ta-muted);
}

.tone-default,
.tone-secondary {
  --tone: var(--ta-text);
  --tone-soft: var(--ta-surface-2);
  --tone-ink: var(--ta-text);
}

/* PARITY B10: the reference's `.state-dot` — a 6px live/status dot, coloured
   by whatever bg-* utility sits beside it (bg-success etc.). Shared by
   mail-pulse and the notice/status vocabulary. */
.state-dot {
  position: relative;
  display: inline-block;
  flex-shrink: 0;
  width: 6px;
  height: 6px;
  border-radius: 9999px;
}

.state-dot-live::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 9999px;
  background-color: inherit;
  pointer-events: none;
  animation: state-halo 2000ms ease-out infinite;
}

@keyframes state-halo {
  0% {
    transform: scale(1);
    opacity: 0.5;
  }
  70%,
  100% {
    transform: scale(2.75);
    opacity: 0;
  }
}

/* Dark: the wash darkens and the ink lightens — the same two roles, inverted,
   so contrast survives the flip instead of the light wash going muddy. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) .tone-ok {
    --tone: oklch(0.68 0.15 155);
    --tone-soft: oklch(0.28 0.045 155);
    --tone-ink: oklch(0.75 0.13 155);
  }

  :root:not([data-theme]) .tone-err {
    --tone: oklch(0.68 0.2 25);
    --tone-soft: oklch(0.3 0.06 25);
    --tone-ink: oklch(0.74 0.16 25);
  }

  :root:not([data-theme]) .tone-warn {
    --tone: oklch(0.76 0.15 75);
    --tone-soft: oklch(0.3 0.05 80);
    --tone-ink: oklch(0.82 0.13 82);
  }

  :root:not([data-theme]) .tone-info {
    --tone: oklch(0.68 0.13 236);
    --tone-soft: oklch(0.3 0.05 236);
    --tone-ink: oklch(0.76 0.12 236);
  }
}

:root[data-theme="dark"] .tone-ok {
  --tone: oklch(0.68 0.15 155);
  --tone-soft: oklch(0.28 0.045 155);
  --tone-ink: oklch(0.75 0.13 155);
}

:root[data-theme="dark"] .tone-err {
  --tone: oklch(0.68 0.2 25);
  --tone-soft: oklch(0.3 0.06 25);
  --tone-ink: oklch(0.74 0.16 25);
}

:root[data-theme="dark"] .tone-warn {
  --tone: oklch(0.76 0.15 75);
  --tone-soft: oklch(0.3 0.05 80);
  --tone-ink: oklch(0.82 0.13 82);
}

:root[data-theme="dark"] .tone-info {
  --tone: oklch(0.68 0.13 236);
  --tone-soft: oklch(0.3 0.05 236);
  --tone-ink: oklch(0.76 0.12 236);
}



/* ---- 12b. Stats (headline numbers, legacy StatGrid) ----------------------- */

/* One flat, hairline-gridded block rather than a scatter of shadowed cards:
   cells split by 1px gaps over a border-coloured backdrop stay crisp at any
   column count and wrap. */
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 170px), 1fr));
  gap: 1px;
  background: var(--ta-border);
  border: 1px solid var(--ta-border);
  border-radius: var(--ta-r);
  overflow: hidden;
  margin-bottom: 1.5rem;
}

.stat {
  position: relative;
  background: var(--ta-surface);
  padding: 1.1rem 1.35rem;
}

/* A stat cell can carry a lucide icon in an accent-soft tile, mirroring the
   kpi-row stat cards. */
.stat-icon {
  position: absolute;
  top: 1rem;
  right: 1rem;
  width: 2rem;
  height: 2rem;
  display: grid;
  place-items: center;
  border-radius: var(--ta-r-sm);
  background: var(--ta-accent-soft);
  color: var(--ta-accent-ink, var(--ta-accent));
}

.stat-icon svg {
  width: 1rem;
  height: 1rem;
}

/* Keep a labelled stat's title clear of its icon tile. */
.stat:has(.stat-icon) .stat-label {
  padding-right: 2.25rem;
}

.stat .stat-label {
  margin: 0 0 0.3rem;
  font-family: var(--ta-mono);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ta-faint);
}

.stat .stat-value {
  margin: 0;
  font-size: 1.9rem;
  font-weight: 650;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

.stat .stat-hint {
  margin: 0.2rem 0 0;
  font-size: 0.85rem;
  color: var(--ta-muted);
}

/* ---- 12c. Badges (tone chips, legacy Badge) ------------------------------- */

.badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 1.5rem;
}

/* A chip sized by its text: dot + label, tone-tinted ink on a hairline
   border. No width floor — an 80px minimum made "Paid" four times wider
   than its word and broke every table rhythm. */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.2rem 0.6rem;
  border: 1px solid var(--tone, var(--ta-border-strong));
  border-radius: var(--ta-r-sm);
  background: var(--ta-surface);
  color: var(--tone, var(--ta-text));
  font-size: 0.78rem;
  font-weight: 600;
  white-space: nowrap;
}

.badge::before {
  content: "";
  width: 0.42em;
  height: 0.42em;
  border-radius: 50%;
  background: var(--tone, var(--ta-faint));
  flex: none;
}

/* ---- 12d. Status (tone dot list, legacy StatusDot/StateTag) --------------- */

.status {
  margin-bottom: 1.5rem;
}

.status ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.35rem;
}

.status li {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  font-size: 0.95rem;
  color: var(--ta-text);
}

.status-dot {
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  background: var(--tone, var(--ta-faint));
  flex: none;
}

/* An expanding, fading halo for states still moving (queued, connecting).
   Opt-in via `pulse` so a dense list doesn't run dozens of haloes at once. */
.status-dot.pulse {
  animation: ta-pulse 1.6s ease-out infinite;
}

@keyframes ta-pulse {
  0% {
    box-shadow: 0 0 0 0 var(--tone-soft, rgba(0, 0, 0, 0.2));
  }

  70% {
    box-shadow: 0 0 0 6px transparent;
  }

  100% {
    box-shadow: 0 0 0 0 transparent;
  }
}

/* ---- 12e. Alerts (tone callouts, legacy Alert/confirm) -------------------- */

/* One line: glyph + sentence. `items-start` (not center) so a message that
   wraps to two lines keeps its glyph beside the FIRST line rather than floating
   to the vertical middle of the bar. */
.alert {
  display: flex;
  align-items: flex-start;
  gap: 0.625rem;
  margin-bottom: 0.5rem;
  padding: 0.625rem 0.875rem;
  /* The edge is the tone at ~30%: a full-strength border around a pale wash
     draws a hard ring that reads louder than the message inside it. */
  border: 1px solid color-mix(in oklab, var(--tone, var(--ta-border-strong)) 30%, transparent);
  border-radius: var(--ta-r-lg);
  background: var(--tone-soft, var(--ta-surface));
  /* Type ON the wash uses the tone's ink step, never the saturated base. */
  color: var(--tone-ink, var(--ta-text));
  font-size: 0.875rem;
  line-height: 1.25rem;
}

/* Stacked banners sit 0.5rem apart; the last one carries the block's own
   bottom margin so a following section isn't crowded. */
.alert:last-child {
  margin-bottom: 1.5rem;
}

.alert[hidden] {
  display: none;
}

.alert-icon {
  display: block;
  flex-shrink: 0;
}

.alert-icon svg {
  width: 1rem;
  height: 1rem;
  display: block;
  /* The optical nudge that lines a 16px glyph up with a 20px line box. */
  margin-top: 0.125rem;
}

.alert-msg {
  overflow-wrap: break-word;
  min-width: 0;
}

/* ---- 12f. Empty state (legacy EmptyState) --------------------------------- */

.empty {
  margin-bottom: 1.5rem;
  padding: 3rem 1.5rem;
  border: 1px dashed var(--ta-border-strong);
  border-radius: var(--ta-r);
  background: var(--ta-surface);
  text-align: center;
}

.empty h3 {
  margin: 0 0 0.4rem;
}

.empty p {
  max-width: 44ch;
  margin: 0 auto 1.25rem;
  color: var(--ta-muted);
}