/* FlowFund — main.css
   Global resets, design tokens, base typography, utility classes. */

:root {
  /* Spacing scale */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;

  /* Radii */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --radius-full: 9999px;

  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(139,129,124,0.08), 0 1px 2px rgba(139,129,124,0.05);
  --shadow-md: 0 4px 12px rgba(139,129,124,0.10), 0 2px 6px rgba(139,129,124,0.06);
  --shadow-lg: 0 8px 24px rgba(139,129,124,0.12), 0 4px 12px rgba(139,129,124,0.08);

  /* Transitions */
  --transition-fast: 150ms cubic-bezier(0.4,0,0.2,1);
  --transition-normal: 250ms cubic-bezier(0.4,0,0.2,1);
  --transition-slow: 400ms cubic-bezier(0.4,0,0.2,1);

  /* Typography scale */
  --font-display: 'DM Serif Display', Georgia, serif;
  --font-body: 'DM Sans', system-ui, sans-serif;
  /* Number font: DM Sans (no slashed/crossed zero) with tabular-nums via .ff-mono */
  --font-mono: 'DM Sans', system-ui, sans-serif;

  --font-size-base: 15px;

  /* Layout */
  --nav-mobile-height: 64px;
  --nav-desktop-width: 240px;
  --nav-desktop-collapsed: 64px;
  --header-height: 64px;
  --max-content-width: 1280px;
}

/* Density modifiers */
[data-density="compact"] { --space-4: 12px; --space-6: 16px; }
[data-density="spacious"] { --space-4: 20px; --space-6: 32px; }

/* Font size modifier — applied on <html> so rem-based sizes scale too */
[data-font-size="large"] { --font-size-base: 17px; }
[data-font-size="x-large"] { --font-size-base: 19px; }

/* Reset */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html {
  -webkit-text-size-adjust: 100%;
  font-size: var(--font-size-base);
}
body {
  font-family: var(--font-body);
  font-size: var(--font-size-base);
  font-weight: 400;
  line-height: 1.5;
  background-color: var(--color-bg);
  color: var(--color-text-primary);
  min-height: 100vh;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background-color var(--transition-normal), color var(--transition-normal);
}

button, input, select, textarea {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

button { background: none; border: none; cursor: pointer; padding: 0; }

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

img { max-width: 100%; height: auto; display: block; }

/* Typography */
.ff-display {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 2rem;
  line-height: 1.2;
  letter-spacing: -0.01em;
}
.ff-h1 {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 1.5rem;
  line-height: 1.3;
}
.ff-h2 {
  font-family: var(--font-body);
  font-weight: 500;
  font-size: 1.125rem;
  line-height: 1.4;
}
.ff-h3 {
  font-family: var(--font-body);
  font-weight: 500;
  font-size: 1rem;
}
.ff-body { font-size: 0.9375rem; }
.ff-caption {
  font-size: 0.8125rem;
  color: var(--color-text-secondary);
  font-weight: 300;
}
.ff-mono {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}

/* Skip link */
.ff-skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--btn-primary-bg);
  color: var(--btn-primary-text);
  padding: 8px 16px;
  border-radius: 0 0 8px 0;
  z-index: 9999;
}
.ff-skip-link:focus {
  left: 0;
  outline: 2px solid var(--focus-ring);
}

/* Focus rings */
:focus { outline: none; }
:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
  border-radius: 4px;
}

/* Boot screen */
.ff-boot {
  display: grid;
  place-items: center;
  height: 100vh;
  height: 100dvh;
  text-align: center;
  gap: 8px;
}
.ff-boot__mark {
  font-family: var(--font-display);
  font-size: 2rem;
  color: var(--color-text-primary);
}
.ff-boot__sub {
  font-family: var(--font-body);
  font-size: 0.9375rem;
  color: var(--color-text-secondary);
}

/* App layout shell */
.ff-app {
  display: grid;
  min-height: 100vh;
  min-height: 100dvh;
  grid-template-rows: auto 1fr auto;
}
@media (min-width: 1024px) {
  .ff-app {
    grid-template-columns: var(--nav-desktop-width) 1fr;
    grid-template-rows: auto 1fr;
    grid-template-areas:
      "sidebar header"
      "sidebar main";
  }
  .ff-app__sidebar { grid-area: sidebar; }
  .ff-app__header { grid-area: header; }
  .ff-app__main { grid-area: main; }
  .ff-app__nav-mobile,
  .ff-nav-mobile.ff-app__nav-mobile { display: none !important; }
}

.ff-app__main {
  padding: var(--space-4);
  padding-bottom: calc(var(--nav-mobile-height) + var(--space-6) + env(safe-area-inset-bottom));
  max-width: var(--max-content-width);
  width: 100%;
  margin: 0 auto;
  min-width: 0;
  overflow-x: hidden;
}
@media (min-width: 1024px) {
  .ff-app__main { padding-bottom: var(--space-8); }
}

/* Page wrapper — adds a comfortable buffer at the bottom of every page */
.ff-page { padding-bottom: var(--space-8); }
@media (min-width: 1024px) {
  .ff-page { padding-bottom: var(--space-10); }
}

/* Utility */
.ff-stack { display: flex; flex-direction: column; gap: var(--space-4); min-width: 0; }
.ff-stack > * { min-width: 0; max-width: 100%; }
.ff-stack-sm { display: flex; flex-direction: column; gap: var(--space-2); min-width: 0; }
.ff-stack-sm > * { min-width: 0; max-width: 100%; }
.ff-row { display: flex; align-items: center; gap: var(--space-3); }
.ff-row-between { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); }
.ff-grid-widgets {
  display: grid;
  gap: var(--space-4);
  grid-template-columns: minmax(0, 1fr);
}
.ff-grid-widgets > * { min-width: 0; }
@media (min-width: 768px) {
  .ff-grid-widgets { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (min-width: 1280px) {
  .ff-grid-widgets { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

.ff-visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}

/* Status pill colors */
.ff-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-size: 0.8125rem;
  font-weight: 500;
  background: var(--chip-3-bg);
  color: var(--chip-3-text);
}
/* Pastel fill + deep same-hue text */
.ff-pill--success { background: var(--success-bg); color: var(--success-text); }
.ff-pill--warning { background: var(--warning-bg); color: var(--warning-text); }
.ff-pill--danger { background: var(--danger-bg); color: var(--danger-text); }
.ff-pill--accent { background: var(--chip-1-bg); color: var(--chip-1-text); }

/* Locked body scroll when modal open */
body.ff-lock-scroll { overflow: hidden; }

/* PWA install banner */
.ff-install-banner {
  position: fixed;
  bottom: calc(var(--nav-mobile-height) + 12px + env(safe-area-inset-bottom));
  left: 12px;
  right: 12px;
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: var(--space-4);
  display: flex;
  align-items: center;
  gap: var(--space-3);
  z-index: 80;
  border: 1px solid var(--color-border);
}
@media (min-width: 1024px) {
  .ff-install-banner { bottom: 24px; right: 24px; left: auto; max-width: 360px; }
}
