/* ============================================================
   TeamManager — Design tokens & theming (Claude Design)
   Calm Light (default) + Operational Dark. Token-driven; most
   component styling is inline and references these CSS vars.
   All fonts are self-hosted (no third-party/Google CDN): Inter is
   the robust fallback for the display/ui fonts (Hanken Grotesk /
   Space Grotesk); JetBrains Mono is the monospace face. Variable
   woff2, latin subset; non-latin glyphs fall back per the stacks.
   ============================================================ */

@font-face {
  font-family: "Inter";
  src: url("/fonts/inter-var.woff2") format("woff2-variations");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Hanken Grotesk";
  src: url("/fonts/hanken-grotesk.woff2") format("woff2");
  font-weight: 400 700;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Space Grotesk";
  src: url("/fonts/space-grotesk.woff2") format("woff2");
  font-weight: 400 700;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "JetBrains Mono";
  src: url("/fonts/jetbrains-mono.woff2") format("woff2");
  font-weight: 400 700;
  font-style: normal;
  font-display: swap;
}

:root {
  /* Accent — indigo/violet scale (overridden at runtime by applyAccent) */
  --accent-50:  #efeafe;
  --accent-100: #ddd2fc;
  --accent-200: #c3b1f9;
  --accent-300: #a288f4;
  --accent-400: #8160ec;
  --accent-500: #5b3fd9;  /* primary */
  --accent-600: #4c31c2;
  --accent-700: #3e289d;
  --accent-800: #2f1f76;
  --accent-900: #221755;

  /* Semantic status */
  --ok:   #1f8a5b;
  --ok-soft: #d8f0e4;
  --warn: #c98a16;
  --warn-soft: #fbeecd;
  --bad:  #d04545;
  --bad-soft: #f7dede;
  --info: #2a6fdb;

  /* Fonts */
  --font-ui: "Hanken Grotesk", "Inter", system-ui, -apple-system, sans-serif;
  --font-display: "Space Grotesk", "Hanken Grotesk", "Inter", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", Consolas, monospace;

  /* Radius (md/lg/sm overridden by the corner-radius tweak) */
  --r-xs: 6px;
  --r-sm: 9px;
  --r-md: 13px;
  --r-lg: 18px;
  --r-xl: 26px;

  /* Density (overridden by the density tweak) */
  --gap: 20px;
  --row-h: 56px;
  --pad: 22px;

  /* Motion */
  --ease: cubic-bezier(.2,.7,.2,1);
}

/* ---------- LIGHT (default) ---------- */
:root, [data-theme="light"] {
  --bg:        #f5f6f9;
  --bg-tint:   #eef0f6;
  --surface:   #ffffff;
  --surface-2: #fafbfd;
  --surface-3: #f1f3f8;
  --elevated:  #ffffff;
  --line:      #e6e8ef;
  --line-2:    #d9dce6;
  --ink:       #14161c;
  --ink-2:     #434a59;
  --muted:     #757d8f;
  --faint:     #a3aab9;
  --accent:    var(--accent-500);
  --accent-ink: #ffffff;
  --accent-bg: var(--accent-50);
  --accent-line: var(--accent-200);
  --rail-bg:   #ffffff;
  --rail-line: #e6e8ef;
  --shadow-sm: 0 1px 2px rgba(20,22,28,.05), 0 1px 3px rgba(20,22,28,.04);
  --shadow-md: 0 2px 4px rgba(20,22,28,.04), 0 8px 24px rgba(20,22,28,.07);
  --shadow-lg: 0 12px 40px rgba(20,22,28,.13);
  --radar-grid: #e2e5ee;
  --radar-fill: rgba(91,63,217,.16);
  --scrim: rgba(22,24,32,.34);
}

/* ---------- DARK (operational) ---------- */
[data-theme="dark"] {
  --bg:        #0a0c11;
  --bg-tint:   #0e1118;
  --surface:   #141821;
  --surface-2: #181d28;
  --surface-3: #1f2533;
  --elevated:  #1a1f2b;
  --line:      #262d3b;
  --line-2:    #323a4c;
  --ink:       #eef1f7;
  --ink-2:     #b9c0cf;
  --muted:     #818aa0;
  --faint:     #5b6377;
  --accent:    #8160ec;
  --accent-ink: #ffffff;
  --accent-bg: rgba(129,96,236,.14);
  --accent-line: rgba(129,96,236,.4);
  --rail-bg:   #0e1118;
  --rail-line: #1d2431;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.4);
  --shadow-md: 0 2px 8px rgba(0,0,0,.45), 0 12px 32px rgba(0,0,0,.4);
  --shadow-lg: 0 18px 50px rgba(0,0,0,.6);
  --radar-grid: #2a3243;
  --radar-fill: rgba(129,96,236,.22);
  --scrim: rgba(0,0,0,.6);
  --ok-soft: rgba(31,138,91,.18);
  --warn-soft: rgba(201,138,22,.18);
  --bad-soft: rgba(208,69,69,.18);
}

/* Density variants applied on the root */
[data-density="compact"] { --gap: 13px; --row-h: 46px; --pad: 15px; }
[data-density="comfy"]   { --gap: 26px; --row-h: 64px; --pad: 28px; }

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font-ui);
  background: var(--bg);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  transition: background .35s var(--ease), color .35s var(--ease);
}
h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -.01em; }
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; }
a { color: var(--accent); }
::selection { background: var(--accent-200); color: var(--ink); }

.font-display { font-family: var(--font-display); }
.font-mono { font-family: var(--font-mono); }
.tnum { font-variant-numeric: tabular-nums; }

/* Utility scrollbars */
.scroll { overflow: auto; scrollbar-width: thin; scrollbar-color: var(--line-2) transparent; }
.scroll::-webkit-scrollbar { width: 9px; height: 9px; }
.scroll::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 99px; border: 2px solid transparent; background-clip: content-box; }
.scroll::-webkit-scrollbar-track { background: transparent; }

/* Visible keyboard focus — !important so it overrides the inline outline:none on inputs. */
:where(a, button, input, select, textarea, [tabindex]):focus-visible {
  outline: 2px solid var(--accent) !important;
  outline-offset: 2px;
}

/* Screen-reader-only content (live regions, hidden labels). */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  border: 0;
  clip-path: inset(50%);
  overflow: hidden;
  white-space: nowrap;
}

#root { height: 100%; }

/* Route enter animation */
@keyframes tm-screen-enter {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}
.screen-enter { animation: tm-screen-enter .28s var(--ease) both; }

/* Collapse the two-column screen grids on narrow viewports (overrides the inline
   grid-template-columns) and hide the sign-in art panel on small screens. */
@media (max-width: 860px) {
  .tm-cols { grid-template-columns: 1fr !important; }
  .auth-art { display: none !important; }
}

@media (prefers-reduced-motion: reduce) {
  *, .screen-enter { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ============================================================
   Coachpit Mobile — mobile-app UI (imported from the Coachpit
   Mobile design; phone-frame/status-bar mockup chrome dropped,
   real safe-area insets used instead). Same color tokens above.
   ============================================================ */
.m-app { display: flex; flex-direction: column; height: 100%; min-height: 0; background: var(--bg); }
.m-scroll { flex: 1; overflow-y: auto; overflow-x: hidden; -webkit-overflow-scrolling: touch; }
.m-scroll::-webkit-scrollbar { width: 0; }

.m-topbar {
  flex-shrink: 0; display: flex; align-items: center; gap: 12px;
  min-height: 54px; padding: calc(env(safe-area-inset-top) + 6px) 16px 6px;
  background: var(--surface); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 40;
}

.m-h1 { font-family: var(--font-display); font-size: 25px; letter-spacing: -.03em; font-weight: 700; }
.m-sub { font-size: 13.5px; color: var(--muted); margin-top: 2px; }

.m-tabbar {
  flex-shrink: 0; height: 76px; background: var(--surface); border-top: 1px solid var(--line);
  display: flex; align-items: flex-start; padding: 8px 6px calc(8px + env(safe-area-inset-bottom));
  position: relative; z-index: 50;
}
.m-tab { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; background: none; border: none; cursor: pointer; padding: 6px 0; color: var(--muted); }
.m-tab[data-active="true"] { color: var(--accent); }
.m-tab span { font-size: 10.5px; font-weight: 600; }

.m-fab {
  position: absolute; top: -22px; left: 50%; transform: translateX(-50%);
  width: 60px; height: 60px; border-radius: 20px; border: none; cursor: pointer;
  background: linear-gradient(150deg, var(--accent), var(--accent-600));
  color: #fff; display: grid; place-items: center;
  box-shadow: 0 10px 24px var(--accent-line), 0 4px 10px rgba(0,0,0,.18);
  transition: transform .15s var(--ease);
}
.m-fab:active { transform: translateX(-50%) scale(.93); }

.m-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow-sm); }

.m-footer {
  flex-shrink: 0; padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  background: var(--surface); border-top: 1px solid var(--line); box-shadow: 0 -6px 24px rgba(0,0,0,.06);
}

.m-sheet-scrim { position: fixed; inset: 0; background: var(--scrim); z-index: 80; opacity: 0; pointer-events: none; transition: opacity .26s var(--ease); }
.m-sheet-scrim[data-open="true"] { opacity: 1; pointer-events: auto; }
.m-sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 85;
  background: var(--elevated); border-radius: 26px 26px 0 0;
  box-shadow: 0 -16px 48px rgba(0,0,0,.3); padding: 8px 18px calc(84px + env(safe-area-inset-bottom));
  transform: translateY(102%); transition: transform .3s var(--ease); max-height: 84dvh; overflow-y: auto;
}
.m-sheet[data-open="true"] { transform: translateY(0); }
.m-sheet-grip { width: 38px; height: 4px; border-radius: 99px; background: var(--line-2); margin: 8px auto 14px; }

@keyframes m-fade-up { from { transform: translateY(10px); } to { transform: none; } }
.m-fade { animation: m-fade-up .3s var(--ease); }

.m-seg { display: flex; background: var(--surface-3); border-radius: var(--r-sm); padding: 3px; gap: 2px; border: 1px solid var(--line); }
.m-seg button { flex: 1; height: 36px; border: none; border-radius: 7px; font-size: 13px; font-weight: 600; background: transparent; color: var(--muted); cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.m-seg button[data-active="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-sm); }

.m-chip { height: 36px; padding: 0 15px; border-radius: 99px; font-size: 13px; font-weight: 600; cursor: pointer; background: var(--surface-2); color: var(--ink-2); border: 1px solid var(--line-2); display: inline-flex; align-items: center; gap: 7px; white-space: nowrap; }
.m-chip[data-on="true"] { background: var(--accent); color: #fff; border-color: var(--accent); }

.m-row { transition: background .12s; }
.m-row:active { background: var(--surface-3); }

.m-input { width: 100%; height: 48px; padding: 0 15px; font-size: 15px; background: var(--surface); border: 1px solid var(--line-2); border-radius: var(--r-sm); color: var(--ink); outline: none; }
.m-input:focus { border-color: var(--accent); }
