/* ==========================================================================
   UPLIFTED — base.css
   Design tokens, reset, typography, keyframes.
   ========================================================================== */

/* ---- Reset ------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html, body, h1, h2, h3, h4, h5, h6, p, ul, ol, figure { margin: 0; padding: 0; }
ul, ol { list-style: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { background: none; border: none; cursor: pointer; }
a { color: inherit; text-decoration: none; }
img, svg { display: block; max-width: 100%; }

/* ---- Design tokens ------------------------------------------------------
   Colours live in the two theme blocks below (Release B, 2026-10-21): the
   shared calm system (/shared/zy-theme.css, --c-*) under Uplifted's own names,
   light by default (zy-theme.js sets <html data-theme> before the first paint).
   Uplifted keeps its identity: gold for the brand and premium, blue for AI,
   green for money in / on track, red for alerts.
     --accent-*          fills, rings, borders, chart lines
     --accent-*-soft     tinted backgrounds behind accent text
     --gold-t / --blue-t / --green-t / --red-t   the accent AS TEXT or icon (AA on every surface)
   Cards are solid (white on light); the frosted blur stays on the sticky
   chrome only, over a theme-aware translucent fill. */
html[data-theme="light"] {
  /* Surfaces */
  --bg-canvas: var(--c-bg);
  --bg-canvas-2: var(--c-bg2);
  --bg-surface: var(--c-surface);
  --bg-surface-2: var(--c-surface2);
  --bg-surface-hover: var(--c-surface3);
  --border-glass: var(--c-border);
  --border-glass-strong: var(--c-border2);
  --field-edge: var(--c-field);
  --card-bg: var(--c-surface);
  --chrome-bg: color-mix(in srgb, var(--c-bg) 88%, transparent);
  --side-bg: var(--c-side);
  --canvas-glow: none;
  --overlay-bg: var(--c-overlay);

  /* Accents: fills */
  --accent-gold: #C9A227;
  --accent-gold-bright: #E4C24C;
  --accent-gold-soft: rgba(201, 162, 39, 0.16);
  --accent-blue: #3D6EF0;
  --accent-blue-soft: rgba(61, 110, 240, 0.11);
  --accent-green: #1FAF78;
  --accent-green-soft: rgba(31, 175, 120, 0.13);
  --accent-red: #E5544A;
  --accent-red-soft: rgba(229, 84, 74, 0.11);
  /* Accents: as text */
  --gold-t: #7A5C00;
  --blue-t: #2A56C6;
  --green-t: var(--c-good-t);
  --red-t: #B83226;

  /* Text */
  --text-primary: var(--c-t1);
  --text-secondary: var(--c-t2);
  --text-muted: var(--c-t3);
  --text-on-accent: #0A0B0E;

  /* Charts (charts.js reads these at draw time) */
  --chart-grid: rgba(28, 22, 46, 0.08);
  --chart-track: var(--c-surface3);
  --chart-label: var(--c-t2);
  --chart-dot: series;

  --shadow-glass: var(--c-shadow-1);
  --shadow-pop: var(--c-shadow-2);
  color-scheme: light;
}
html[data-theme="dark"] {
  /* Surfaces */
  --bg-canvas: var(--c-bg);
  --bg-canvas-2: var(--c-bg2);
  --bg-surface: var(--c-surface);
  --bg-surface-2: var(--c-surface2);
  --bg-surface-hover: var(--c-surface3);
  --border-glass: var(--c-border);
  --border-glass-strong: var(--c-border2);
  --field-edge: var(--c-field);
  --card-bg: var(--c-surface);
  --chrome-bg: color-mix(in srgb, var(--c-bg) 84%, transparent);
  --side-bg: color-mix(in srgb, var(--c-side) 92%, transparent);
  --canvas-glow: radial-gradient(circle at 15% 0%, rgba(76, 126, 255, 0.05), transparent 40%), radial-gradient(circle at 85% 10%, rgba(201, 162, 39, 0.04), transparent 35%);
  --overlay-bg: var(--c-overlay);

  /* Accents: fills */
  --accent-gold: #C9A227;
  --accent-gold-bright: #E4C24C;
  --accent-gold-soft: rgba(201, 162, 39, 0.15);
  --accent-blue: #4C7EFF;
  --accent-blue-soft: rgba(76, 126, 255, 0.15);
  --accent-green: #2ECC8F;
  --accent-green-soft: rgba(46, 204, 143, 0.15);
  --accent-red: #FF6B5E;
  --accent-red-soft: rgba(255, 107, 94, 0.15);
  /* Accents: as text */
  --gold-t: #E4C24C;
  --blue-t: #8AA9FF;
  --green-t: #3DD69B;
  --red-t: #FF8A80;

  /* Text */
  --text-primary: var(--c-t1);
  --text-secondary: var(--c-t2);
  --text-muted: var(--c-t3);
  --text-on-accent: #0A0B0E;

  /* Charts */
  --chart-grid: rgba(255, 255, 255, 0.07);
  --chart-track: rgba(255, 255, 255, 0.08);
  --chart-label: var(--c-t2);
  --chart-dot: rgba(255, 255, 255, 0.9);

  --shadow-glass: var(--c-shadow-1);
  --shadow-pop: var(--c-shadow-2);
  color-scheme: dark;
}

:root {
  /* Typography */
  --font-display: Georgia, 'Iowan Old Style', 'Times New Roman', ui-serif, serif;
  --font-body: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --fs-2xs: 0.6875rem;
  --fs-xs: 0.75rem;
  --fs-sm: 0.8125rem;
  --fs-base: 0.9375rem;
  --fs-md: 1.0625rem;
  --fs-lg: 1.25rem;
  --fs-xl: 1.5rem;
  --fs-2xl: 2rem;
  --fs-hero: 2.75rem;

  /* Spacing */
  --space-1: 4px; --space-2: 8px; --space-3: 12px; --space-4: 16px;
  --space-5: 20px; --space-6: 24px; --space-7: 32px; --space-8: 48px; --space-9: 64px;

  /* Radius (cards: 18px, the shared calm system) */
  --radius-sm: 10px; --radius-md: 14px; --radius-lg: 18px; --radius-xl: 28px; --radius-full: 999px;

  /* Blur (the sticky chrome only; shadows are in the theme blocks) */
  --blur-glass: blur(20px);

  /* Motion */
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --dur-fast: 150ms;
  --dur-base: 240ms;
  --dur-slow: 420ms;

  /* Layout */
  --sidebar-w: 240px;
  --bottom-nav-h: 64px;
  --header-h: 64px;
  --container-max: 1180px;

  /* Z-index scale */
  --z-nav: 100;
  --z-header: 90;
  --z-overlay: 200;
  --z-sheet: 210;
  --z-toast: 300;
}

/* ---- Base element styles ------------------------------------------------ */
html {
  -webkit-text-size-adjust: 100%;
  overflow-x: hidden;
}

body {
  background: var(--bg-canvas);
  background-image: var(--canvas-glow);
  background-attachment: fixed;
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: var(--fs-base);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
}

h1, h2, h3, h4 { font-weight: 600; letter-spacing: -0.01em; }

::selection { background: var(--accent-gold-soft); color: var(--text-primary); }

/* Scrollbars */
* { scrollbar-width: thin; scrollbar-color: var(--border-glass-strong) transparent; }
*::-webkit-scrollbar { width: 8px; height: 8px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb { background: var(--border-glass-strong); border-radius: var(--radius-full); }
*::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* Focus visibility */
:focus-visible {
  outline: 2px solid var(--accent-blue);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* ---- Typography utilities ------------------------------------------------ */
.t-hero { font-family: var(--font-display); font-size: var(--fs-hero); font-weight: 500; letter-spacing: -0.02em; }
.t-display { font-family: var(--font-display); }
.t-2xs { font-size: var(--fs-2xs); }
.t-xs { font-size: var(--fs-xs); }
.t-sm { font-size: var(--fs-sm); }
.t-md { font-size: var(--fs-md); }
.t-lg { font-size: var(--fs-lg); font-weight: 600; }
.t-xl { font-size: var(--fs-xl); font-weight: 600; }
.t-muted { color: var(--text-muted); }
.t-secondary { color: var(--text-secondary); }
.t-gold { color: var(--gold-t); }
.t-blue { color: var(--blue-t); }
.t-green { color: var(--green-t); }
.t-red { color: var(--red-t); }
.t-mono-num { font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; }

/* ---- Layout utilities ------------------------------------------------ */
.flex { display: flex; }
.flex-col { display: flex; flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: var(--space-1); } .gap-2 { gap: var(--space-2); } .gap-3 { gap: var(--space-3); }
.gap-4 { gap: var(--space-4); } .gap-5 { gap: var(--space-5); }
.w-full { width: 100%; }
.hidden { display: none !important; }

/* ---- Keyframes ------------------------------------------------ */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
@keyframes slideUpSheet { from { transform: translateY(100%); } to { transform: translateY(0); } }
@keyframes slideDownSheet { from { transform: translateY(0); } to { transform: translateY(100%); } }
@keyframes scaleIn { from { opacity: 0; transform: scale(0.96); } to { opacity: 1; transform: scale(1); } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes shimmer { 0% { background-position: -200% 0; } 100% { background-position: 200% 0; } }
@keyframes pulseDot { 0%, 60%, 100% { opacity: 0.3; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-3px); } }
@keyframes ringIn { from { stroke-dashoffset: var(--ring-start, 283); } to { stroke-dashoffset: var(--ring-end, 0); } }
@keyframes toastIn { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }
@keyframes glow { 0%, 100% { opacity: 0.5; } 50% { opacity: 1; } }

.fade-in { animation: fadeIn var(--dur-base) var(--ease-out) both; }
.slide-up { animation: slideUp var(--dur-slow) var(--ease-out) both; }

/* Stagger helper — applied via inline style="--d: Nms" on list children */
[data-stagger] { animation: slideUp var(--dur-slow) var(--ease-out) both; animation-delay: var(--d, 0ms); }

@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;
  }
}

/* ---- Print base (report generation, §Reports page) ------------------------------------------------ */
@media print {
  body { background: #fff !important; color: #111 !important; }
  .no-print { display: none !important; }
}

/* ---- Auth gating -----------------------------------------------------------
   Set on <body> by default in index.html, removed by app.js the moment a
   signed-in user with synced data is ready to see the real app. Keeps a
   logged-out (or not-yet-determined) visitor from ever glimpsing sidebar/
   topbar/bottom-nav/FAB behind the login overlay, and avoids a flash of
   app chrome before the auth state resolves on first paint. */
body.auth-pending #app,
body.auth-pending .overlay,
body.auth-pending .sheet {
  display: none !important;
}

