/* ============================================================
   FocusFlow — base.css
   Design tokens, reset, layout primitives.
   Theme-specific color values live in styles/themes/*.css and
   are applied via [data-theme] on <html>. Pastel is the default
   and its tokens are defined here so the app renders before any
   theme stylesheet loads.
   ============================================================ */

:root {
  /* --- Spacing scale --- */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.5rem;
  --space-6: 2rem;
  --space-8: 3rem;

  /* --- Radius --- */
  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 22px;
  --radius-xl: 28px;
  --radius-full: 999px;

  /* --- Shadows (soft, never harsh) --- */
  --shadow-sm: 0 1px 2px rgba(44, 44, 44, 0.04), 0 1px 3px rgba(44, 44, 44, 0.06);
  --shadow-md: 0 4px 12px rgba(44, 44, 44, 0.06), 0 2px 4px rgba(44, 44, 44, 0.04);
  --shadow-lg: 0 12px 32px rgba(44, 44, 44, 0.10), 0 4px 8px rgba(44, 44, 44, 0.05);

  /* --- Motion --- */
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --dur-fast: 120ms;
  --dur-base: 200ms;
  --dur-slow: 320ms;

  /* --- Layout --- */
  --bottom-nav-h: 64px;
  --side-rail-w: 72px;
  --sidebar-w: 240px;
  --header-h: 64px;
  --content-max: 1100px;

  /* --- Type scale --- */
  --text-xs: 0.75rem;
  --text-sm: 0.875rem;
  --text-base: 1rem;
  --text-lg: 1.125rem;
  --text-xl: 1.25rem;
  --text-2xl: 1.5rem;
  --text-3xl: 1.875rem;
  --text-4xl: 2.25rem;

  --font-display: "Nunito", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-body: "Plus Jakarta Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  /* Plus Jakarta Sans has no slashed zero and supports tabular figures —
     used everywhere digits appear (clocks, counts, money, time labels). */
  --font-mono: "Plus Jakarta Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-tnum: "Plus Jakarta Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

/* ============================================================
   PASTEL THEME (default) — also the :root fallback
   ============================================================ */
:root,
[data-theme="pastel"] {
  --color-base: #FBFAF8;
  --color-surface: #FFFFFF;
  --color-surface-alt: #F7F5F2;
  --color-peach: #F6D1C1;
  --color-apricot: #F3D8B5;
  --color-butter: #F1E4B3;
  --color-sage: #CFE3D6;
  --color-sky: #C9DDF2;
  --color-lavender: #D8D4F2;
  --color-mauve: #E6CFE0;
  /* Buttons, progress bars and chart marks. Pastel keeps these PALE — only
     a hair deeper than the tint itself — so it reads as soft and clearly
     lighter than Clarity. Derived in OKLCH; never mixed toward grey/black
     (that's what made the first v20.4 pass muddy). */
  --color-peach-deep: #F2C9B8;
  --color-apricot-deep: #EFD1AA;
  --color-butter-deep: #ECDDA6;
  --color-sage-deep: #C7DDCF;
  --color-sky-deep: #C0D7EE;
  --color-lavender-deep: #D2CDEE;
  --color-mauve-deep: #E1C8DB;
  /* A fine same-hue outline for those pale fills (Pastel only — see
     components.css). Without it a pale butter bar on its pale track measured
     1.19:1 and all but disappeared. */
  --color-peach-edge: #E8B49E;
  --color-apricot-edge: #E4BD8A;
  --color-butter-edge: #DECB83;
  --color-sage-edge: #B0CDBB;
  --color-sky-edge: #A9C6E3;
  --color-lavender-edge: #C0BAE4;
  --color-mauve-edge: #D4B3CC;
  --color-text: #5F6368;
  --color-text-dark: #2C2C2C;
  /* Was #9AA0A6, which measured 2.5–2.6:1 on every surface — well under AA,
     on the class used for nearly every hint, subtitle and metadata line in
     the app. Still reads as muted, now actually readable. */
  --color-text-muted: #6B7075;
  --color-border: #EBEBEB;

  --color-success: #7FB89A;
  --color-warning: #E8A87C;
  --color-danger: #D98B8B;

  /* Status badge pairs — measured for AA as small text. */
  --badge-danger-bg: #FBE4E4;   --badge-danger-fg: #7A2E2E;
  --badge-warning-bg: #FBEADB;  --badge-warning-fg: #7A4818;
  --badge-success-bg: #DDEFE5;  --badge-success-fg: #1F5740;

  /* The router sets --accent (pale tint) and --accent-deep (its soft deeper
     partner) per section. Derived weights:
       --accent-strong  button / FAB fills
       --accent-mark    progress bars, chart bars, heatmap cells
       --accent-text    accent-coloured words on a surface (dark, 4.5:1+)
     --on-accent is the ink on an accent fill: dark ink on a soft pastel
     reads at 7.6–10:1. Never #fff — white on pastel measured 1.6–3.1:1.

     Pastel stays PASTEL. v20.4 darkened these by mixing with near-black to
     hit WCAG's 3:1 for graphics, which turned them grey-brown (and olive in
     Clarity). Joanne rejected that. Marks are soft now; every bar shows its
     value as text alongside, so nothing depends on the colour alone. */
  --accent: var(--color-sky);
  --accent-deep: var(--color-sky-deep);
  --accent-edge: var(--color-sky-edge);
  --accent-strong: var(--accent-deep);
  --accent-mark: var(--accent-deep);
  --accent-text: color-mix(in srgb, var(--accent-deep) 30%, var(--color-text-dark));
  --on-accent: #1E1F22;

  /* Pastel tint strengths for coloured cells (meal grid, dashboard meal
     tiles) and planner time blocks. Dark theme turns these down — at 45% a
     dark-mode block is a mid-tone that no text colour reads on. Labels on a
     tint use .tint-label (body-text colour), never .text-muted. */
  --tint-cell: 30%;
  --tint-block: 45%;
  --widget-tint: 24%;   /* dashboard widget cards (components.css) */
}

/* ============================================================
   Reset
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: 1.6;
  color: var(--color-text);
  background: var(--color-base);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overscroll-behavior-y: contain;
}

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

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

ul, ol { list-style: none; margin: 0; padding: 0; }

a { color: inherit; text-decoration: none; }

img, svg { display: block; max-width: 100%; }

:focus-visible {
  outline: 2px solid var(--accent-strong);
  outline-offset: 2px;
  border-radius: 4px;
}

/* Subtle noise/gradient wash on app background */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(1200px 600px at 80% -10%, color-mix(in srgb, var(--accent) 22%, transparent), transparent 60%),
    radial-gradient(900px 500px at -10% 110%, color-mix(in srgb, var(--color-mauve) 18%, transparent), transparent 60%);
  opacity: 0.7;
  transition: background var(--dur-slow) var(--ease-out);
}

/* ============================================================
   App shell layout
   ============================================================ */
#app {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.app-shell {
  display: flex;
  min-height: 100dvh;
}

.app-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  padding-bottom: calc(var(--bottom-nav-h) + env(safe-area-inset-bottom, 0px));
}

.app-content {
  flex: 1;
  width: 100%;
  max-width: var(--content-max);
  margin: 0 auto;
  padding: var(--space-4);
  padding-top: var(--space-3);
}

/* Desktop only: sidebar replaces bottom nav, so the bottom-nav padding
   reservation is unnecessary. Below 1024px (incl. iPad portrait), the
   bottom nav stays visible and content needs to clear it. */
@media (min-width: 1024px) {
  .app-main { padding-bottom: var(--space-6); }
}

/* Utility */
.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;
}

.skip-link {
  position: absolute;
  left: -999px;
  top: var(--space-2);
  z-index: 200;
  background: var(--color-surface);
  color: var(--color-text-dark);
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
}
.skip-link:focus { left: var(--space-2); }

.hidden { display: none !important; }
