/*
 * Birch's shared look: the colour tokens, the base, buttons, cards, notices and the account pages. One file for
 * both the SPA and the server-rendered account pages (Pages/Shared/_Layout.cshtml links it), served unhashed
 * from wwwroot with Cache-Control: no-cache. System fonts only, nothing from another origin (CSP
 * default-src 'self').
 *
 * Themes: without data-theme on <html> the system's preference applies; data-theme="light" or "dark" (the
 * SPA sets it from the user's setting) overrides it. The account pages run no JavaScript, so they follow the
 * system.
 */

:root {
  color-scheme: light;
  --bg: #f5f6f3;
  --surface: #ffffff;
  --surface-2: #eef1ec;
  --text: #1d2320;
  --text-muted: #5a645e;
  --border: #dce1da;
  --border-strong: #c4cbc3;
  --accent: #2f6b4f;
  --accent-hover: #275a42;
  --accent-text: #ffffff;
  --accent-soft: #e3eee7;
  --accent-border: #b9d6c5;
  --focus: #2f6b4f;
  --danger: #a4231b;
  --danger-soft: #fbeceb;
  --danger-border: #efc4c0;
  --danger-fill: #a4231b;
  --danger-fill-hover: #8a1c15;
  --danger-on: #ffffff;
  --warning: #7a5000;
  --warning-soft: #fdf4de;
  --warning-border: #ecd49a;
  --shadow: 0 1px 2px rgb(16 24 20 / 0.05), 0 1px 3px rgb(16 24 20 / 0.04);
  --radius: 10px;
  --radius-lg: 14px;
  --font: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    color-scheme: dark;
    --bg: #111412;
    --surface: #191d1a;
    --surface-2: #222724;
    --text: #e5e9e6;
    --text-muted: #9fa9a2;
    --border: #2c322e;
    --border-strong: #3d4540;
    --accent: #63b38a;
    --accent-hover: #78c39c;
    --accent-text: #0c1a12;
    --accent-soft: #1d3327;
    --accent-border: #2e5641;
    --focus: #7cc8a1;
    --danger: #f0aca7;
    --danger-soft: #3a1d1b;
    --danger-border: #5b2a27;
    --danger-fill: #e2847c;
    --danger-fill-hover: #eb9d96;
    --danger-on: #220b09;
    --warning: #efc775;
    --warning-soft: #352a13;
    --warning-border: #5a4619;
    --shadow: none;
  }
}

:root[data-theme='dark'] {
  color-scheme: dark;
  --bg: #111412;
  --surface: #191d1a;
  --surface-2: #222724;
  --text: #e5e9e6;
  --text-muted: #9fa9a2;
  --border: #2c322e;
  --border-strong: #3d4540;
  --accent: #63b38a;
  --accent-hover: #78c39c;
  --accent-text: #0c1a12;
  --accent-soft: #1d3327;
  --accent-border: #2e5641;
  --focus: #7cc8a1;
  --danger: #f0aca7;
  --danger-soft: #3a1d1b;
  --danger-border: #5b2a27;
  --danger-fill: #e2847c;
  --danger-fill-hover: #eb9d96;
  --danger-on: #220b09;
  --warning: #efc775;
  --warning-soft: #352a13;
  --warning-border: #5a4619;
  --shadow: none;
}

/* --- Base --------------------------------------------------------------------------------------- */

*,
*::before,
*::after {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  min-height: 100svh;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3 {
  margin: 0 0 0.5rem;
  line-height: 1.25;
  color: var(--text);
}

h1 {
  font-size: 1.75rem;
  font-weight: 650;
  letter-spacing: -0.01em;
}

h2 {
  font-size: 1.0625rem;
  font-weight: 600;
}

p {
  margin: 0 0 1rem;
}

a {
  color: var(--accent);
  text-underline-offset: 0.15em;
}

a:hover {
  color: var(--accent-hover);
}

code {
  font-family: var(--mono);
  font-size: 0.9em;
  overflow-wrap: anywhere;
}

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.muted {
  color: var(--text-muted);
}

.small {
  font-size: 0.875rem;
}

.lead {
  font-size: 1.0625rem;
  color: var(--text-muted);
}

/* --- Buttons ------------------------------------------------------------------------------------ */

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: 44px;
  padding: 0 1.125rem;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: var(--accent);
  color: var(--accent-text);
  font: inherit;
  font-weight: 600;
  line-height: 1.2;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
}

.button:hover {
  background: var(--accent-hover);
  color: var(--accent-text);
}

.button:disabled {
  cursor: default;
  opacity: 0.6;
}

.button--secondary {
  background: var(--surface);
  border-color: var(--border-strong);
  color: var(--text);
}

.button--secondary:hover {
  background: var(--surface-2);
  color: var(--text);
}

.button--danger {
  background: var(--danger-fill);
  color: var(--danger-on);
}

.button--danger:hover {
  background: var(--danger-fill-hover);
  color: var(--danger-on);
}

.button--block {
  width: 100%;
}

.button--small {
  min-height: 36px;
  padding: 0 0.875rem;
  font-size: 0.9375rem;
}

/* --- Surfaces ----------------------------------------------------------------------------------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 1.25rem;
}

.notice {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  margin: 0 0 1rem;
}

.notice > :last-child {
  margin-bottom: 0;
}

.notice--warning {
  background: var(--warning-soft);
  border-color: var(--warning-border);
}

.notice--error {
  background: var(--danger-soft);
  border-color: var(--danger-border);
}

.notice--success {
  background: var(--accent-soft);
  border-color: var(--accent-border);
}

.notice--error strong,
.notice--warning strong {
  color: var(--text);
}

/* --- Account pages (server-rendered: sign-in, interstitial, link-required, errors, signed out) -------- */

.account {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100svh;
  padding: 32px 16px;
}

.account__card {
  width: 100%;
  max-width: 420px;
}

.account__brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0 0 1.5rem;
  font-weight: 650;
  font-size: 1.0625rem;
}

.account__brand img {
  display: block;
  border-radius: 7px;
}

.account__host {
  font-weight: 600;
  color: var(--text);
  overflow-wrap: anywhere;
}

.account__actions {
  display: grid;
  gap: 0.75rem;
  margin: 1.5rem 0;
  padding: 0;
  list-style: none;
}

.account__actions form {
  margin: 0;
}

.account__provider-icon {
  width: 20px;
  height: 20px;
}

.account__fine-print {
  margin: 0;
  font-size: 0.875rem;
  color: var(--text-muted);
}

.account__code {
  margin-top: 1.5rem;
  font-size: 0.8125rem;
  color: var(--text-muted);
}
