/* ============================================================
 * APEX SALES OS · BASE RESET + TYPOGRAPHY + ANIMATIONS
 *
 * Owner: Worker W1 (foundation-css lane).
 * Loaded after 00-tokens.css; everything visual inherits the
 * tokens defined there. Page-local sheets MUST NOT redefine
 * the resets, scrollbar styling, or keyframes below.
 *
 * Stripe-tier baseline: Inter Tight body, JetBrains Mono for
 * .mono utility, subtle scrollbar, purple-tint selection, and
 * the canonical animation keyframes (tickPulse / livePulse /
 * dotPulse / shimmer / spin) referenced from primitives.
 * ============================================================ */

/* fonts (loaded from Google Fonts) */
@import url('https://fonts.googleapis.com/css2?family=Inter+Tight:wght@400;450;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

/* ------------------------------------------------------------
 * reset
 * ------------------------------------------------------------ */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

/* ------------------------------------------------------------
 * IRON LAW · NO PAGE SCROLL (1440x900)
 *
 * The viewport is locked at 100vh. The body NEVER scrolls. The
 * browser window NEVER shows a vertical scrollbar. Every page
 * that has list data (commission ledger, audit log, chat thread,
 * call history, notifications, etc.) wraps its rows in an inner
 * container with `flex: 1; min-height: 0; overflow-y: auto` so
 * the LIST scrolls internally and the page chrome stays fixed.
 *
 * See docs/IRON-LAW-NO-SCROLL.md for the full pattern + list of
 * surfaces that ALWAYS scroll internally.
 *
 * Layout chain:
 *   body  -> flex column, 100vh, overflow hidden
 *   header#apex-topbar -> flex-shrink: 0
 *   main#app-root      -> flex: 1, min-height: 0, overflow hidden
 *   .app-frame         -> flex: 1, min-height: 0, overflow hidden
 *
 * If you find yourself adding `overflow: visible` or `min-height:
 * 100vh` to any of these, STOP. Wrap the list in an internal-
 * scroll container instead.
 * ------------------------------------------------------------ */
html, body {
  height: 100%;
  overflow: hidden;
}

body {
  font-family: 'Inter Tight', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg-warm);
  color: var(--text);
  font-feature-settings: 'cv11', 'ss01', 'ss03';
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-size: 14px;
  line-height: 1.45;
  letter-spacing: -0.005em;
  /* IRON LAW lockdown: no horizontal AND no vertical body scroll */
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

/* topbar stays at top of the flex frame, sticky behaviour preserved */
#apex-topbar {
  flex-shrink: 0;
}

/* app-root owns the remaining viewport. Pages mount inside; their
 * internal flex chain takes over from here. */
#app-root {
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  background: var(--bg-warm);
}

/* the canonical page frame inherits the locked viewport so pages
 * with hero + list shells can rely on a real 100% height parent
 * instead of recomputing `calc(100vh - 56px)` everywhere. */
.app-frame,
.page-shell,
.stage,
.stage-inner {
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
}

/* ------------------------------------------------------------
 * CANONICAL 1440x900 FRAME-WRAP  (James-demo CRM design stage)
 *
 * Every screen in the F1 -> F10 client journey is authored against
 * a fixed 1440x900 design lock. `.frame-wrap` centers that stage
 * inside the locked viewport so the composition lays out against
 * the exact dimensions it was drawn at, with zero scroll and zero
 * reflow. On a 1440x900-or-larger window the frame fills the
 * viewport. On a smaller window the frame keeps its intrinsic
 * 1440x900 size and is letterboxed against --bg-warm so nothing
 * collapses. Internal lists still scroll via their own
 * `flex:1; min-height:0; overflow:auto` containers (see IRON LAW
 * above); the frame itself NEVER scrolls.
 *
 * Owned here as the single source of truth. The topbar / orb /
 * context-bar primitives (02) and the stage grids (03) all assume
 * this parent. Other terminals treat it READ-ONLY.
 * ------------------------------------------------------------ */
.frame-wrap {
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
  display: flex;
  align-items: stretch;
  justify-content: center;
  overflow: hidden;
  background: var(--bg-warm);
}

.frame-wrap > .frame,
.frame {
  position: relative;
  width: 1440px;
  max-width: 1440px;
  height: 900px;
  max-height: 100%;
  flex: 0 0 1440px;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
  background: var(--bg-warm);
}

/* fluid mode: the dark video stage wants the design surface to
 * stretch edge to edge on an oversized window instead of locking
 * to 1440px. Opt in with `.frame-wrap.fluid`. */
.frame-wrap.fluid > .frame,
.frame-wrap.fluid .frame {
  width: 100%;
  max-width: 100%;
  flex: 1 1 auto;
}

/* ------------------------------------------------------------
 * selection
 * ------------------------------------------------------------ */
::selection { background: rgba(99, 91, 255, 0.20); }

/* ------------------------------------------------------------
 * scrollbar (subtle)
 * ------------------------------------------------------------ */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 99px;
  border: 2px solid var(--bg-warm);
}
::-webkit-scrollbar-thumb:hover { background: var(--text-faint); }

/* ------------------------------------------------------------
 * utility families
 * ------------------------------------------------------------ */
.mono  { font-family: 'JetBrains Mono', ui-monospace, monospace; font-variant-numeric: tabular-nums; }
.num   { font-variant-numeric: tabular-nums; }
.muted { color: var(--text-muted); }
.faint { color: var(--text-faint); }
.soft  { color: var(--text-soft); }

/* gradient text helper (purple gradient on big hero numbers) */
.gnum {
  background: var(--grad);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
}

/* ------------------------------------------------------------
 * keyframes (animations)
 * ------------------------------------------------------------ */

/* tick animation (live numbers blip on update) */
@keyframes tickPulse {
  0%, 100% { transform: scale(1); }
  20%      { transform: scale(1.04); }
}
.tick { display: inline-block; animation: tickPulse 250ms ease-out; }

/* live pulse (recording / live data indicators) — purple, NEVER red */
@keyframes livePulse {
  0%, 100% { box-shadow: 0 0 0 3px rgba(99, 91, 255, 0.16); }
  50%      { box-shadow: 0 0 0 6px rgba(99, 91, 255, 0.06); }
}

/* dot pulse (trailing point on sparklines) */
@keyframes dotPulse {
  0%, 100% { r: 2.6; opacity: 1; }
  50%      { r: 4;   opacity: 0.5; }
}

/* shimmer (loading skeleton sweep) */
@keyframes shimmer {
  0%   { background-position: -200% 0; }
  100% { background-position:  200% 0; }
}

/* spin (loading spinner) */
@keyframes spin { to { transform: rotate(360deg); } }

/* ------------------------------------------------------------
 * default app root + boot fade-in
 * (sizing rules live in the IRON LAW block above; this block
 * only owns the boot fade-in.)
 * ------------------------------------------------------------ */

/* hide while booting to avoid flash of unstyled content */
html.app-booting #app-root { opacity: 0; }
html:not(.app-booting) #app-root {
  opacity: 1;
  transition: opacity 200ms ease;
}

/* ------------------------------------------------------------
 * form element baseline
 * ------------------------------------------------------------ */
button {
  cursor: pointer;
  border: 0;
  background: none;
  font: inherit;
  color: inherit;
}

input, select, textarea {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 9px 12px;
  color: var(--text);
  font: inherit;
  transition: border-color var(--t), box-shadow var(--t);
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 4px rgba(99, 91, 255, 0.12);
}
input::placeholder, textarea::placeholder { color: var(--text-faint); }

/* ------------------------------------------------------------
 * link reset
 * ------------------------------------------------------------ */
a { color: inherit; text-decoration: none; }
a.link {
  color: var(--primary);
  text-decoration: none;
  font-weight: 500;
}
a.link:hover { text-decoration: underline; }

/* ------------------------------------------------------------
 * keyboard hint chip
 * ------------------------------------------------------------ */
.kbd {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  padding: 1px 5px;
  border-radius: 4px;
  background: var(--bg-tint);
  border: 1px solid var(--border);
  color: var(--text-muted);
}

/* ------------------------------------------------------------
 * viewport guard (Apex Sales OS is desktop-only · 1280px+)
 * paired with the inline width-check script in index.html
 * ------------------------------------------------------------ */
html.viewport-too-small body > *:not(.viewport-warning) { display: none !important; }
html.viewport-too-small body::before {
  content: 'Apex Sales OS is desktop-only. Please open at 1280px+ width.';
  display: block;
  padding: 80px 40px;
  font-size: 18px;
  color: var(--text-muted);
  text-align: center;
}
