/* PatchMap control plane — paper palette + self-hosted fonts.
 *
 * Palette extracted from marketing/src/styles/global.css (the canonical
 * surface for the PatchMap visual identity — see CLAUDE.md "Marketing-only
 * quality bars"). Phase 21 keeps it hand-written (no Tailwind on the
 * control plane in this phase per 21-RESEARCH §Alternatives Considered)
 * but mirrors the same colour tokens + self-hosted-WOFF2 typography so the
 * eventual "Sign in with PatchMap" button (Phase 22) has palette continuity.
 *
 * Self-hosted fonts only (CLAUDE.md "Self-hosted fonts only" rule — extends
 * to the control plane). WOFF2 subsets live under /static/fonts/ and are
 * preloaded in the base template's <head>.
 */

/* ── 1. @font-face — Space Grotesk Variable (display) ────────────── */
@font-face {
  font-family: "Space Grotesk Variable";
  src: url("/static/fonts/SpaceGrotesk-latin.woff2") format("woff2 supports variations"),
       url("/static/fonts/SpaceGrotesk-latin.woff2") format("woff2");
  font-weight:   300 700;
  font-display:  swap;
  unicode-range: U+0020-00FF;
}

/* Fallback with metric overrides to prevent CLS on font swap. */
@font-face {
  font-family:       "Space Grotesk Fallback";
  src:               local("Arial"), local("Helvetica Neue"), local("system-ui");
  font-display:      swap;
  size-adjust:       105%;
  ascent-override:   90%;
  descent-override:  25%;
  line-gap-override: 0%;
}

/* ── 2. @font-face — JetBrains Mono Variable (code) ──────────────── */
@font-face {
  font-family: "JetBrains Mono Variable";
  src: url("/static/fonts/JetBrainsMono-latin.woff2") format("woff2 supports variations"),
       url("/static/fonts/JetBrainsMono-latin.woff2") format("woff2");
  font-weight:   100 800;
  font-display:  swap;
  unicode-range: U+0020-00FF;
}

@font-face {
  font-family:       "JetBrains Mono Fallback";
  src:               local("Courier New"), local("ui-monospace"), local("monospace");
  font-display:      swap;
  size-adjust:       108%;
  ascent-override:   88%;
  descent-override:  22%;
  line-gap-override: 0%;
}

/* ── 3. Design tokens (palette + scale) ──────────────────────────── */
:root {
  /* Paper palette — mirrors marketing/src/styles/global.css @theme block.
   * Where marketing uses --color-* tokens (Tailwind v4 @theme), the control
   * plane uses plain CSS custom properties (no Tailwind here). Hex codes
   * are kept identical so the two surfaces render the same shade. */
  --paper:           #F5F1E8;   /* warm paper background */
  --paper-2:         #ECE9E2;   /* secondary paper surface */
  --ink:             #1A1A1A;   /* primary text */
  --ink-2:           #2D323A;   /* secondary text */
  --muted:           #6B7280;   /* tertiary text / hints */
  --line:            #D9D5CC;   /* hairline rules + borders */
  --accent-ink:      #007028;   /* AA-passing accent for text/focus (5.51:1 on paper) */
  --accent-deco:     #00C950;   /* mint — decorative fills only */
  --accent-hover:    #00B040;   /* mint hover state */
  --accent-bg:       #DFFAE8;   /* accent surface tint */
  --danger:          #B91C1C;
  --danger-bg:       #FEE2E2;
  --success-fg:      #065F46;
  --success-bg:      #E6F4EA;

  --max-w:           480px;
  --radius:          8px;
  --font-sans:       "Space Grotesk Variable", "Space Grotesk Fallback", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --font-mono:       "JetBrains Mono Variable", "JetBrains Mono Fallback", ui-monospace, monospace;
}

/* ── 4. Base reset + body ────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

html {
  background:              var(--paper);
  color:                   var(--ink);
  font-family:             var(--font-sans);
  font-feature-settings:   'ss01', 'cv11';
  -webkit-font-smoothing:  antialiased;
  text-rendering:          optimizeLegibility;
}

body.paper {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-sans);
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── 5. A11y — universal focus-visible (mirrors marketing rule) ──── */
:focus-visible {
  outline:        2px solid var(--accent-ink);
  outline-offset: 2px;
  border-radius:  4px;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration:        0.001ms !important;
    animation-iteration-count: 1       !important;
    transition-duration:       0.001ms !important;
  }
}

/* ── 6. Layout — single-column auth shell ────────────────────────── */
.container {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 48px 24px;
  flex: 1;
  width: 100%;
}

.auth-card { padding: 32px 24px; }
.auth-card h1 { font-size: 28px; margin: 0 0 8px; letter-spacing: -0.02em; font-weight: 600; }
.auth-card .lede { color: var(--muted); margin: 0 0 24px; font-size: 15px; }

/* ── 7. Forms ────────────────────────────────────────────────────── */
.auth-card label { display: block; margin-bottom: 16px; }
.auth-card label span { display: block; font-weight: 600; margin-bottom: 4px; font-size: 14px; }
.auth-card label small { font-weight: 400; color: var(--muted); font-size: 12px; }
.auth-card input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: white;
  color: var(--ink);
  font: inherit;
}
.auth-card input:focus {
  outline: 2px solid var(--accent-ink);
  outline-offset: 1px;
  border-color: var(--accent-ink);
}

/* ── 8. Buttons ──────────────────────────────────────────────────── */
.btn {
  display: inline-block;
  padding: 10px 20px;
  border-radius: var(--radius);
  border: none;
  cursor: pointer;
  font: inherit;
  font-weight: 600;
  text-decoration: none;
  line-height: 1.5;
}
.btn--primary { background: var(--accent-deco); color: var(--ink); }
.btn--primary:hover { background: var(--accent-hover); }
.btn--ghost { background: transparent; color: var(--ink); text-decoration: underline; }
.btn--full { width: 100%; }

/* ── 9. Auth footer link row ─────────────────────────────────────── */
.auth-foot { margin-top: 24px; color: var(--muted); font-size: 14px; }
.auth-foot a { color: var(--ink); }

/* ── 10. Form errors + flash ─────────────────────────────────────── */
.form-error {
  color: var(--danger);
  margin: 0 0 16px;
  font-size: 14px;
  padding: 8px 12px;
  background: var(--danger-bg);
  border-radius: var(--radius);
}
.flash { padding: 12px 16px; border-radius: var(--radius); margin-bottom: 24px; font-size: 14px; }
.flash--info    { background: var(--success-bg); color: var(--success-fg); }
.flash--error   { background: var(--danger-bg);  color: var(--danger); }
.flash--success { background: var(--accent-bg);  color: var(--accent-ink); }

/* ── 11. Misc ────────────────────────────────────────────────────── */
.foot { padding: 24px; text-align: center; color: var(--muted); font-size: 12px; }
.foot a { color: var(--muted); }
.hint { color: var(--muted); font-size: 12px; display: block; margin-top: 4px; }
code, .mono { font-family: var(--font-mono); }

/* ── 12. Dashboard + org-settings layouts (Plan 21-08) ───────────── */
/* These two layouts are wider than the auth shell — bump the container
 * max-width via a modifier class.
 */
.dash, .settings { max-width: 720px; margin: 0 auto; }

.dash-head, .settings-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
}
.dash-head h1, .settings-head h1 {
  margin: 0;
  font-size: 24px;
  letter-spacing: -0.02em;
  font-weight: 600;
}
.dash-head .signout { margin: 0; }
.settings-head .crumb { margin: 0 0 4px; font-size: 13px; }
.settings-head .crumb a { color: var(--muted); text-decoration: none; }
.settings-head .crumb a:hover { color: var(--ink); text-decoration: underline; }
.settings-head .lede { margin: 4px 0 0; color: var(--muted); font-size: 14px; }
.settings-head .lede code { font-size: 13px; }

/* Org list on the dashboard. */
.org-list { list-style: none; padding: 0; margin: 0 0 24px; }
.org-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 20px;
  background: white;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-bottom: 12px;
}
.org-row__main { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.org-row__name { font-size: 16px; }
.org-row__role { color: var(--muted); font-size: 13px; }
.org-row__actions { display: flex; gap: 8px; flex-shrink: 0; }

/* Settings sections. */
.section { margin-bottom: 40px; padding-top: 8px; }
.section h2 {
  margin: 0 0 12px;
  font-size: 16px;
  font-weight: 600;
  color: var(--ink-2);
}

/* Inline forms — rename, invite, per-row member actions. */
.inline-form {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 12px;
  background: white;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
}
.inline-form label { margin-bottom: 0; flex: 1 1 180px; min-width: 0; }
.inline-form label span { display: block; font-weight: 600; margin-bottom: 4px; font-size: 13px; }
.inline-form input, .inline-form select {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: white;
  color: var(--ink);
  font: inherit;
}
.inline-form input:focus, .inline-form select:focus {
  outline: 2px solid var(--accent-ink);
  outline-offset: 1px;
  border-color: var(--accent-ink);
}
.inline-form button { flex: 0 0 auto; }
.inline-form--row {
  display: inline-flex;
  padding: 0;
  border: none;
  background: transparent;
  margin: 0;
}

/* Members table. */
table.members {
  width: 100%;
  border-collapse: collapse;
  background: white;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
table.members th, table.members td {
  text-align: left;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
}
table.members thead th {
  background: var(--paper-2);
  font-weight: 600;
  font-size: 13px;
  color: var(--ink-2);
}
table.members tbody tr:last-child td { border-bottom: none; }
table.members td .muted { color: var(--muted); margin-left: 6px; }
table.members td.actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* Invite list. */
.invite-list { list-style: none; padding: 0; margin: 0; }
.invite-row {
  padding: 10px 14px;
  background: white;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-bottom: 8px;
  font-size: 14px;
}
.invite-row .muted { color: var(--muted); margin-left: 6px; }

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

.btn--danger {
  color: var(--danger);
}
.btn--danger:hover {
  background: var(--danger-bg);
}
