/* Red Table shared stylesheet (#974).
 *
 * Maps the semantic colours every page uses onto the Red Taverns brand tokens
 * (tokens.css, vendored, never edited). The next brand release is one edit
 * here. tests/server/app-css.test.ts resolves every text pair below against
 * tokens.css and fails under 4.5:1 in either theme.
 *
 * Load order: tokens.css, then this file, then the page's own <style>. The
 * selectors here have the same specificity as the pages' own blocks, so a page
 * that still defines its pre-brand palette keeps it until it migrates.
 *
 * Contrast rules the values follow (review 2.3):
 * - Brand red is a fill and a border, never text: on a dark card it is 4.2:1.
 * - White on --rt-red is 4.17:1, so a red button's label is ink (4.6:1). On
 *   hover the fill deepens to --rt-red-dk and the label turns light (7.9:1).
 * - --rt-ink-3 fails on paper (3.07:1), so light-theme secondary text is ink-2.
 * - Light text on --rt-bad is 4.4:1, so error banners fill with --rt-red-dk.
 */

:root {
  --font-family: var(--rt-font-body);

  /* Surfaces and text (dark, the default) */
  --bg-primary: var(--rt-bg);
  --bg-card: var(--rt-bg-2);
  --border-subtle: var(--rt-rule-on-dk);
  /* Form field edges: 3:1 against the surface (WCAG 1.4.11, #1082). */
  --border-input: var(--rt-ink-3);
  --text-primary: var(--rt-ink-on-dk);
  --text-secondary: var(--rt-ink-3);
  --text-muted: var(--rt-ink-3);
  --header-bg: rgba(15, 14, 13, 0.85);
  --surface-muted: rgba(244, 241, 235, 0.06);
  --surface-hover: rgba(244, 241, 235, 0.1);

  /* Brand red: fills and borders only */
  --accent: var(--rt-red);
  --accent-hover: var(--rt-red-dk);
  --on-accent: var(--rt-ink);
  --on-accent-hover: var(--rt-ink-on-dk);
  --accent-soft: rgba(230, 57, 70, 0.15);
  --accent-border: rgba(230, 57, 70, 0.45);
  --accent-wash: rgba(230, 57, 70, 0.08);

  /* Status */
  --good: var(--rt-good);
  --warn: var(--rt-warn);
  --bad: var(--rt-bad);
  --info: var(--rt-info);
  --good-soft: rgba(42, 143, 110, 0.15);
  --bad-fill: var(--rt-red-dk);
  --on-bad: var(--rt-ink-on-dk);
  --on-good: var(--rt-ink);
  --on-warn: var(--rt-ink);

  /* Shape */
  --radius-sm: var(--rt-radius-sm);
  --radius-md: var(--rt-radius-md);
  --radius-lg: var(--rt-radius-lg);
}

[data-theme="light"] {
  --bg-primary: var(--rt-paper);
  --bg-card: var(--rt-paper-2);
  --border-subtle: var(--rt-rule);
  --border-input: var(--rt-ink-2);
  --text-primary: var(--rt-ink);
  --text-secondary: var(--rt-ink-2);
  --text-muted: var(--rt-ink-2);
  --header-bg: rgba(244, 241, 235, 0.85);
  --surface-muted: rgba(15, 14, 13, 0.04);
  --surface-hover: rgba(15, 14, 13, 0.08);
  --accent-soft: var(--rt-red-soft);
  --accent-wash: rgba(230, 57, 70, 0.06);
  --good-soft: rgba(42, 143, 110, 0.12);
}

/* ── Components ──────────────────────────────────────────────
 * Class-scoped, so a page that has not migrated is untouched. */

.rt-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--rt-space-2);
  min-height: 44px;
  padding: var(--rt-space-2) var(--rt-space-5);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  background: var(--bg-card);
  color: var(--text-primary);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--rt-dur-fast) var(--rt-ease), color var(--rt-dur-fast) var(--rt-ease);
}
.rt-btn--primary {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--on-accent);
}
.rt-btn--primary:hover,
.rt-btn--primary:active {
  border-color: var(--accent-hover);
  background: var(--accent-hover);
  color: var(--on-accent-hover);
}
.rt-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.rt-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--rt-space-1);
  padding: 2px var(--rt-space-2);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  font-family: var(--rt-font-mono);
  font-size: var(--rt-text-xs);
  letter-spacing: var(--rt-track-loose);
  text-transform: uppercase;
  color: var(--text-primary);
}

.rt-alert--bad {
  background: var(--bad-fill);
  color: var(--on-bad);
}

/* Reduced motion (#976): nothing animates or transitions, on every page. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
}
