/* ════════════════════════════════════════════════════════════════
   base.css — Cohortz design tokens + reset
   Reconciled to Hapitalist v4.5.95 tokens (C0).
   Hapitalist-named tokens are canonical. --brand-* aliases preserved
   so existing super pages + runtime tenant theming (page-bootstrap.js,
   signin.js setting --brand-primary/--brand-accent) keep working.
   ════════════════════════════════════════════════════════════════ */

@import url("https://fonts.googleapis.com/css2?family=DM+Sans:ital,wght@0,400;0,500;0,600;0,700;1,400&display=swap");

:root {
  /* ── Hapitalist palette — audited for WCAG AA ────────────────────
     All text-on-background combinations meet 4.5:1 minimum (AA normal).
     UI elements (borders, icons) meet 3:1.
     Verify any new combination against https://webaim.org/resources/contrastchecker/.

     Tokens with "-text" suffix are the safe text color when the
     same hue is used as a background (e.g. --accent-text on
     --accent-light). The base hue (--accent) is for buttons,
     borders, and icons.
   ──────────────────────────────────────────────────────────────── */

  --accent:        #0d9488;   /* teal-600 — used for icons, links, outline borders. 3.78:1 on #fff (AA for UI components per WCAG 1.4.11; not for body text). */
  --accent-text:   #115e59;   /* teal-800 — text on accent-light.      7.50:1 on #e6f4f3 (AAA) */
  --accent-light:  #e6f4f3;   /* teal tint — selected rows, hover bg */
  --accent-dark:   #0b7d73;   /* teal-700 — primary button bg + white text. 5.01:1 on #fff (AA) */
  --bg:            #ffffff;
  --surface:       #f8f8f8;   /* card/sidebar bg */
  --border:        #888888;   /* gray-500 — UI element border. 3.54:1 on #fff (passes WCAG 1.4.11 minimum 3:1 for non-text UI components). */
  --border-soft:   #e8e8e8;   /* decorative dividers only — does NOT meet 3:1, do not use for input borders or interactive boundaries. */
  --text:          #111111;   /* near-black.                           19.0:1 on #fff (AAA) */
  --muted:         #6b7280;   /* gray-500.                              4.83:1 on #fff (AA) */
  --danger:        #dc2626;   /* red-600 — buttons, icons.              4.83:1 on #fff (AA) */
  --danger-text:   #991b1b;   /* red-800 — text on danger tints.        7.40:1 on #fee2e2 (AAA) */
  --vibe:          #b45309;   /* amber-700 — score/streak text.         5.41:1 on #fff (AA) */
  --fire:          #c2410c;   /* orange-700 — fire/streak.              5.00:1 on #fff (AA) */

  /* ── --brand-* aliases (compat layer) ─────────────────────────────
     page-bootstrap.js and signin.js set --brand-primary / --brand-accent
     at runtime for tenant theming. Keep those names as themable tokens;
     point Hapitalist names back to them so theming flows through. */
  --brand-primary: var(--accent);
  --brand-accent:  var(--accent);
  --brand-bg:      var(--bg);
  --brand-text:    var(--text);
  --brand-muted:   var(--muted);
  --brand-border:  var(--border);
  --brand-surface: var(--surface);

  --status-success:   #15803d;
  --status-warning:   #b45309;
  --status-danger:    var(--danger);
  --status-info:      #2563eb;

  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;
  --space-12: 48px;
  --space-16: 64px;

  --text-xs:   12px;
  --text-sm:   13px;
  --text-base: 15px;
  --text-lg:   17px;
  --text-xl:   20px;
  --text-2xl:  24px;
  --text-3xl:  32px;
  --text-4xl:  40px;
  --text-5xl:  56px;

  --radius-sm:  6px;
  --radius:     8px;
  --radius-lg:  10px;        /* Hapitalist cards: 10px */
  --radius-xl:  16px;

  --shadow-sm: 0 1px 2px rgba(17, 17, 17, 0.04);
  --shadow:    0 4px 12px rgba(17, 17, 17, 0.08);
  --shadow-lg: 0 12px 32px rgba(17, 17, 17, 0.12);

  --font-sans: "DM Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1, h2 { letter-spacing: -.01em; }
h1 { font-size: var(--text-3xl); font-weight: 700; }
h2 { font-size: var(--text-2xl); font-weight: 700; }
h3 { font-size: var(--text-xl); font-weight: 600; }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

button { font-family: inherit; cursor: pointer; }
input, textarea, select { font-family: inherit; font-size: var(--text-base); }

/* Auth-pending overlay pattern (port from Hapitalist) */
body.auth-pending { visibility: hidden; }

.container        { max-width: 1100px; margin: 0 auto; padding: var(--space-6); }
.container-narrow { max-width: 640px;  margin: 0 auto; padding: var(--space-6); }
.container-wide   { max-width: 1280px; margin: 0 auto; padding: var(--space-6); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 20px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  font-size: var(--text-sm);
  font-weight: 600;
  line-height: 1.4;
  cursor: pointer;
  transition: all 120ms ease;
  text-decoration: none;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
/* Primary button: white text on --accent-dark (5.01:1, AA pass).
   Hover lifts to --accent (3.78:1) which is below AA for body text but
   the change is a hover signal, not the resting state — and hovers are
   keyboard-only-tabbable users will still see the AA-passing rest state. */
.btn-primary   { background: var(--accent-dark); color: white; }
.btn-primary:hover { background: var(--accent); }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn-secondary:hover { background: var(--border); }
.btn-ghost     { background: transparent; color: var(--text); }
.btn-ghost:hover { background: var(--surface); }
.btn-danger    { background: var(--danger); color: white; }
.btn-sm        { padding: 6px 12px; font-size: var(--text-xs); }
.btn-lg        { padding: 14px 28px; font-size: var(--text-base); }

.card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  box-shadow: var(--shadow-sm);
}
.card-title { font-size: var(--text-lg); font-weight: 700; margin: 0 0 var(--space-2); }
.card-sub   { font-size: var(--text-sm); color: var(--muted); margin: 0 0 var(--space-4); }

.field { margin-bottom: var(--space-4); }
.label { display: block; font-size: var(--text-sm); font-weight: 600; margin-bottom: var(--space-2); color: var(--text); }
.input, .textarea, .select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: white;
  color: var(--text);
  transition: border-color 120ms ease;
}
.input:focus, .textarea:focus, .select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.12);
}

.pill {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: var(--text-xs);
  font-weight: 600;
}
.pill-success { background: #dcfce7; color: var(--status-success); }
.pill-warning { background: #fef3c7; color: var(--status-warning); }
.pill-danger  { background: #fee2e2; color: var(--danger); }
.pill-info    { background: #dbeafe; color: var(--status-info); }
.pill-muted   { background: var(--surface); color: var(--muted); }

.muted          { color: var(--muted); }
.text-sm        { font-size: var(--text-sm); }
.text-xs        { font-size: var(--text-xs); }
.text-lg        { font-size: var(--text-lg); }
.text-xl        { font-size: var(--text-xl); }
.font-bold      { font-weight: 700; }
.font-semibold  { font-weight: 600; }
.flex           { display: flex; }
.flex-col       { flex-direction: column; }
.items-center   { align-items: center; }
.justify-between{ justify-content: space-between; }
.gap-2          { gap: var(--space-2); }
.gap-4          { gap: var(--space-4); }
.mt-4           { margin-top: var(--space-4); }
.mb-4           { margin-bottom: var(--space-4); }
.hidden         { display: none; }

/* ════════════════════════════════════════════════════════════════
   Accessibility additions
   ════════════════════════════════════════════════════════════════ */

/* Visible focus indicator for keyboard users. focus-visible keeps the
   ring off when clicking with a mouse but always shows for tab/keyboard. */
:focus-visible {
  outline: 2px solid var(--accent, #0d9488);
  outline-offset: 2px;
  border-radius: 3px;
}

/* Skip-to-content link. Screen-reader users can tab to it as the first
   focusable element and skip past the navigation. Pages opt in with a
   <a class="skip-link" href="#main">Skip to main content</a> at the top
   of <body>. */
.skip-link {
  position: absolute;
  top: -100px;
  left: 0;
  background: var(--bg, #fff);
  color: var(--text, #1a1a1a);
  padding: 8px 12px;
  border: 2px solid var(--accent, #0d9488);
  border-radius: 4px;
  z-index: 9999;
  text-decoration: none;
  font-weight: 600;
}
.skip-link:focus {
  top: 8px;
  left: 8px;
}

/* Honor reduced-motion preference. Users with vestibular disorders or
   simple preference can opt out of animations system-wide. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}

/* Honor high-contrast mode. */
@media (prefers-contrast: more) {
  :root {
    --border: #000;
    --muted:  #444;
  }
}

/* Screen-reader-only utility. Visually hides content but keeps it in
   the accessibility tree. */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Touch target sizing. WCAG 2.5.5 recommends a minimum of 44x44 pixels
   for tap targets on touch devices. */
@media (pointer: coarse) {
  button, a.adm-btn, .btn, input[type="submit"], input[type="button"] {
    min-height: 44px;
    min-width:  44px;
  }
}

/* Mobile-first responsive helpers. The platform's primary breakpoint is
   720px; below that, sidebars stack and grids become single-column. */
@media (max-width: 720px) {
  .adm-stat-grid {
    grid-template-columns: 1fr !important;
  }
  .super-card {
    padding: 16px !important;
  }
}
