/* ==========================================================================
   fit · Design tokens — "Macedonia" theme (light only)
   --------------------------------------------------------------------------
   This file only defines variables (custom properties) and the tint classes
   `t-*`. It paints nothing by itself: the components live in
   `components.css` and only consume the semantic tokens (`--color-*`,
   `--accent-*`, `--space-*`…), never the fruits directly.

   Layers, bottom to top:
     1. Fruits    → the raw palette: 8 fruits × 8 steps (`--tangerine-500`).
     2. Neutrals  → "cream" (light surfaces) and "seed" (ink).
     3. Semantics → background, surface, text, border, states.
     4. Tints     → `t-*` classes that fill the `--accent-*` set with one
                    fruit. A component inherits the tint of its container.

   Naming: every identifier and comment is in English; only the text the
   user sees in the app is in Spanish.
   The hex values come from OKLCH (same lightness per step across all fruits)
   and are checked against WCAG AA; the contrast table is in README.md.
   ========================================================================== */

:root {
  color-scheme: light;   /* light theme only: keep the browser from darkening form controls */

  /* ------------------------------------------------------------------------
     1. FRUITS
     What each step is for (the same in every fruit):
        50  wash      barely tinted screen or card background
       100  pastel    background of icons, chips and stickers; pulp of the ring
       200  track     track of meters and rings, tinted borders, pressed state
       300  sorbet    gradients, selection, text on a dark background
       500  pulp      the "vivid" colour: fill of meters, rings and buttons.
                      NOT for text: text on top of it uses step 900.
       600  stroke    thin chart lines and icons (≥ 3:1 on white)
       700  ink       coloured text on white, 50, 100 and 200 (≥ 4.5:1)
       900  pit       text on step 500 and on 200/300 (≥ 4.5:1)
     ------------------------------------------------------------------------ */

  /* Watermelon — coral red · Activity */
  --watermelon-50: #FFF5F3;
  --watermelon-100: #FFE9E6;
  --watermelon-200: #FFD4CE;
  --watermelon-300: #FFB7AE;
  --watermelon-500: #FB7267;
  --watermelon-600: #EB4942;
  --watermelon-700: #B52B28;
  --watermelon-900: #5A1613;

  /* Tangerine — orange · Food (kcal eaten) */
  --tangerine-50: #FFF6EE;
  --tangerine-100: #FFEAD9;
  --tangerine-200: #FFD7B4;
  --tangerine-300: #FEC48F;
  --tangerine-500: #FC9926;
  --tangerine-600: #D47D0A;
  --tangerine-700: #8F5306;
  --tangerine-900: #532D00;

  /* Lemon — yellow · Carbs */
  --lemon-50: #FEFAE3;
  --lemon-100: #FCF3C1;
  --lemon-200: #F7E895;
  --lemon-300: #F2DC66;
  --lemon-500: #EACE21;
  --lemon-600: #AA960F;
  --lemon-700: #726305;
  --lemon-900: #413801;

  /* Avocado — green · Fat (and the "ok" state) */
  --avocado-50: #F1FBEF;
  --avocado-100: #E0F6DD;
  --avocado-200: #C7ECC1;
  --avocado-300: #A5E59A;
  --avocado-500: #68C859;
  --avocado-600: #44A135;
  --avocado-700: #2C7221;
  --avocado-900: #163D10;

  /* Mint — teal · Workouts */
  --mint-50: #EBFCFA;
  --mint-100: #D1F8F4;
  --mint-200: #A9EFEA;
  --mint-300: #83E1DB;
  --mint-500: #2AC3BB;
  --mint-600: #029A94;
  --mint-700: #036C68;
  --mint-900: #013C39;

  /* Blueberry — blue · Weight and body composition */
  --blueberry-50: #F3F8FF;
  --blueberry-100: #E5EFFF;
  --blueberry-200: #CEE1FF;
  --blueberry-300: #AFCEFE;
  --blueberry-500: #5794F3;
  --blueberry-600: #2D77E7;
  --blueberry-700: #0856C0;
  --blueberry-900: #002966;

  /* Plum — violet · Real expenditure */
  --plum-50: #FAF5FF;
  --plum-100: #F3EAFF;
  --plum-200: #E9D7FE;
  --plum-300: #DCBCFE;
  --plum-500: #BA88ED;
  --plum-600: #A160DB;
  --plum-700: #7739AA;
  --plum-900: #3E1C5B;

  /* Raspberry — pink · Protein */
  --raspberry-50: #FFF4F9;
  --raspberry-100: #FFE7F2;
  --raspberry-200: #FFD1E6;
  --raspberry-300: #FFB1D7;
  --raspberry-500: #E961AC;
  --raspberry-600: #D74098;
  --raspberry-700: #A71F72;
  --raspberry-900: #4F0D35;

  /* ------------------------------------------------------------------------
     2. NEUTRALS
     "Cream": warm whites for the background and surfaces.
     "Seed": near-black ink with a hint of plum, so text sits well next to
     the fruits (never pure black).
     ------------------------------------------------------------------------ */
  --cream-0: #FFFFFF;
  --cream-50: #FDFAF4;
  --cream-100: #F8F3EB;
  --cream-200: #EDE7DE;
  --cream-300: #E0D8CE;
  --seed-400: #B2A6B1;   /* decorative or disabled only: does not reach AA */
  --seed-500: #8E818E;   /* 3.7:1 — icons and marks only, not small text */
  --seed-600: #756877;   /* 5.3:1 on white */
  --seed-700: #584A5C;   /* 8.2:1 */
  --seed-900: #2B1C2F;   /* 16:1 */

  /* ------------------------------------------------------------------------
     3. SEMANTICS
     ------------------------------------------------------------------------ */
  --color-bg: var(--cream-50);                /* app background */
  --color-surface: var(--cream-0);            /* cards, sheets, tab bar */
  --color-surface-sunken: var(--cream-100);   /* fields, neutral tracks, sunken areas */
  --color-border: var(--cream-200);           /* soft hairline */
  --color-border-strong: var(--cream-300);    /* border of fields and secondary buttons */

  --color-text: var(--seed-900);          /* main text and figures */
  --color-text-2: var(--seed-700);        /* secondary text, units */
  --color-text-3: var(--seed-600);        /* notes, times, chart axes */
  --color-text-disabled: var(--seed-400);
  --color-text-inverse: var(--cream-0);   /* on dark ink (toasts) */

  --color-overlay: rgb(43 28 47 / 0.36);   /* veil behind sheets and dialogs */
  --color-focus: var(--blueberry-600);     /* keyboard focus ring */

  /* States. Always with an icon and text, never colour alone. */
  --color-ok: var(--avocado-600);
  --color-ok-soft: var(--avocado-100);
  --color-ok-ink: var(--avocado-700);
  --color-warn: var(--lemon-500);
  --color-warn-soft: var(--lemon-100);
  --color-warn-ink: var(--lemon-700);
  --color-danger: var(--watermelon-600);
  --color-danger-soft: var(--watermelon-100);
  --color-danger-ink: var(--watermelon-700);

  /* One accent per domain (direct aliases, handy in JS or Chart.js).
     In CSS prefer the tint class: `t-weight`, `t-food`… */
  --color-weight: var(--blueberry-500);
  --color-food: var(--tangerine-500);
  --color-activity: var(--watermelon-500);
  --color-workouts: var(--mint-500);
  --color-expenditure: var(--plum-500);
  --color-carbs: var(--lemon-500);
  --color-protein: var(--raspberry-500);
  --color-fat: var(--avocado-500);

  /* ------------------------------------------------------------------------
     TYPOGRAPHY
     Fraunces (soft): screen titles and large words. Never figures.
     Figtree: everything else, figures included.
     Google Fonts link in README.md.
     ------------------------------------------------------------------------ */
  --font-display: "Fraunces", "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  --font-sans: "Figtree", ui-rounded, "SF Pro Rounded", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-num: var(--font-sans);   /* figures: alias in case it ever changes */
  --font-display-settings: "SOFT" 100, "WONK" 0;

  /* Scale (rem; 1rem = 16 px). Form fields never go below 16 px:
     under that, iOS zooms in on focus. */
  --text-2xs: 0.6875rem;   /* 11 · tab labels, axes */
  --text-xs: 0.75rem;      /* 12 · notes, stickers */
  --text-sm: 0.8125rem;    /* 13 · row metadata */
  --text-md: 0.9375rem;    /* 15 · secondary text, buttons */
  --text-base: 1rem;       /* 16 · text and fields */
  --text-lg: 1.125rem;     /* 18 · card titles */
  --text-xl: 1.375rem;     /* 22 · sheet titles */
  --text-2xl: 1.75rem;     /* 28 */
  --text-3xl: 2.125rem;    /* 34 · screen title */

  /* Figures */
  --num-sm: 1.125rem;    /* 18 */
  --num-md: 1.5rem;      /* 24 */
  --num-lg: 2.125rem;    /* 34 */
  --num-xl: 3rem;        /* 48 · main figure of a card */
  --num-hero: 4.25rem;   /* 68 · live weight */

  --weight-regular: 400;
  --weight-medium: 500;
  --weight-semibold: 600;
  --weight-bold: 700;

  --leading-tight: 1.1;
  --leading-snug: 1.3;
  --leading-normal: 1.5;

  --tracking-tight: -0.02em;   /* large figures and titles */
  --tracking-wide: 0.06em;     /* small caps of stickers and eyebrows */

  /* ------------------------------------------------------------------------
     SPACING — 4 px base
     ------------------------------------------------------------------------ */
  --space-1: 0.25rem;   /*  4 */
  --space-2: 0.5rem;    /*  8 */
  --space-3: 0.75rem;   /* 12 */
  --space-4: 1rem;      /* 16 */
  --space-5: 1.25rem;   /* 20 */
  --space-6: 1.5rem;    /* 24 */
  --space-8: 2rem;      /* 32 */
  --space-10: 2.5rem;   /* 40 */
  --space-12: 3rem;     /* 48 */
  --space-16: 4rem;     /* 64 */

  /* ------------------------------------------------------------------------
     RADII — everything rounded, nothing pointed
     ------------------------------------------------------------------------ */
  --radius-xs: 8px;
  --radius-sm: 12px;
  --radius-md: 16px;      /* fields, rows */
  --radius-lg: 24px;      /* cards */
  --radius-xl: 32px;      /* sheets, hero card */
  --radius-pill: 999px;   /* buttons, chips, meters */
  /* "Fruit" shape: an imperfect circle for icons and illustrations. */
  --radius-blob: 46% 54% 52% 48% / 54% 46% 54% 46%;

  /* ------------------------------------------------------------------------
     SHADOWS — tinted with plum, never neutral grey
     ------------------------------------------------------------------------ */
  --shadow-1: 0 1px 2px rgb(64 38 70 / 0.05), 0 2px 8px rgb(64 38 70 / 0.04);
  --shadow-2: 0 2px 4px rgb(64 38 70 / 0.05), 0 10px 28px rgb(64 38 70 / 0.08);
  --shadow-3: 0 -2px 8px rgb(64 38 70 / 0.05), 0 -12px 48px rgb(64 38 70 / 0.16);
  /* The coloured glow under primary buttons is computed in the component
     itself from --accent-strong (a variable defined here would not follow
     the tint of the component). */

  /* ------------------------------------------------------------------------
     MOTION
     ------------------------------------------------------------------------ */
  --ease-out: cubic-bezier(0.2, 0.8, 0.2, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);   /* slight overshoot: "juicy" */
  --duration-1: 120ms;                                /* presses */
  --duration-2: 220ms;                                /* state changes */
  --duration-3: 360ms;                                /* sheets, toasts */
  --duration-4: 700ms;                                /* meters and rings filling up */

  /* ------------------------------------------------------------------------
     LAYOUT
     ------------------------------------------------------------------------ */
  --page-gutter: var(--space-4);   /* side margin on mobile */
  --page-max: 1120px;              /* maximum content width on desktop */
  --tabbar-height: 64px;
  --sidenav-width: 232px;
  --touch: 44px;                   /* minimum size of anything tappable */
  /* The iOS app sets --native-safe-* on <html> before the page is parsed (ios/…/SafeAreaWebView.swift):
     in its WebView env() settles late and the content would jump. Browsers fall back to env(). */
  --safe-top: var(--native-safe-top, env(safe-area-inset-top, 0px));
  --safe-bottom: var(--native-safe-bottom, env(safe-area-inset-bottom, 0px));

  --z-nav: 10;
  --z-fab: 20;
  --z-sheet: 30;
  --z-toast: 40;
}

/* ==========================================================================
   4. TINTS
   A `t-*` class fills the `--accent-*` set. Put it on any element (a whole
   screen, a card, the meter of one macro) and everything inside inherits
   it. Components only read `--accent-*`.

     --accent-wash    barely tinted background         (step 50)
     --accent-soft    pastel background                (step 100)
     --accent-track   track / tinted border            (step 200)
     --accent-light   sorbet                           (step 300)
     --accent         vivid fill                       (step 500)
     --accent-strong  thin strokes and icons           (step 600)
     --accent-ink     coloured text                    (step 700)
     --accent-on      text on top of --accent          (step 900)
     --glow-a/-b      the two flavours of the background glow of the screen
     --accent-dot     (optional) colour of the full stop after the screen title

   There are three families of classes, all used the same way:
     by meaning       t-weight · t-food · t-activity · t-workouts · t-expenditure
                      t-carbs · t-protein · t-fat          ← use whenever one exists
     by state         t-ok · t-warn · t-danger
     by fruit         t-blueberry · t-tangerine · …        ← only for series with no
                      meaning of their own (e.g. parts of body composition)
     and two neutrals t-neutral (ink) · t-muted (context grey)
   ========================================================================== */

/* Neutral: the default (Today has its own raspberry tint, below). */
:root,
.t-neutral {
  --accent-wash: var(--cream-50);
  --accent-soft: var(--cream-100);
  --accent-track: var(--cream-200);
  --accent-light: var(--cream-300);
  --accent: var(--seed-900);
  --accent-strong: var(--seed-700);
  --accent-ink: var(--seed-900);
  --accent-on: var(--cream-0);
  --glow-a: var(--cream-100);
  --glow-b: var(--cream-100);
}

/* Context grey: the series being compared against (e.g. "Apple"). */
.t-muted {
  --accent-wash: var(--cream-50);
  --accent-soft: var(--cream-100);
  --accent-track: var(--cream-200);
  --accent-light: var(--cream-300);
  --accent: var(--seed-400);
  --accent-strong: var(--seed-500);
  --accent-ink: var(--seed-700);
  --accent-on: var(--seed-900);
}

/* --- Fruits, with their meanings ---------------------------------------- */

/* Blueberry · Weight and body composition */
.t-blueberry,
.t-weight {
  --accent-wash: var(--blueberry-50);
  --accent-soft: var(--blueberry-100);
  --accent-track: var(--blueberry-200);
  --accent-light: var(--blueberry-300);
  --accent: var(--blueberry-500);
  --accent-strong: var(--blueberry-600);
  --accent-ink: var(--blueberry-700);
  --accent-on: var(--blueberry-900);
}

/* Tangerine · Food */
.t-tangerine,
.t-food {
  --accent-wash: var(--tangerine-50);
  --accent-soft: var(--tangerine-100);
  --accent-track: var(--tangerine-200);
  --accent-light: var(--tangerine-300);
  --accent: var(--tangerine-500);
  --accent-strong: var(--tangerine-600);
  --accent-ink: var(--tangerine-700);
  --accent-on: var(--tangerine-900);
}

/* Watermelon · Activity · error, limit exceeded, delete */
.t-watermelon,
.t-activity,
.t-danger {
  --accent-wash: var(--watermelon-50);
  --accent-soft: var(--watermelon-100);
  --accent-track: var(--watermelon-200);
  --accent-light: var(--watermelon-300);
  --accent: var(--watermelon-500);
  --accent-strong: var(--watermelon-600);
  --accent-ink: var(--watermelon-700);
  --accent-on: var(--watermelon-900);
}

/* Mint · Workouts */
.t-mint,
.t-workouts {
  --accent-wash: var(--mint-50);
  --accent-soft: var(--mint-100);
  --accent-track: var(--mint-200);
  --accent-light: var(--mint-300);
  --accent: var(--mint-500);
  --accent-strong: var(--mint-600);
  --accent-ink: var(--mint-700);
  --accent-on: var(--mint-900);
}

/* Plum · Real expenditure */
.t-plum,
.t-expenditure {
  --accent-wash: var(--plum-50);
  --accent-soft: var(--plum-100);
  --accent-track: var(--plum-200);
  --accent-light: var(--plum-300);
  --accent: var(--plum-500);
  --accent-strong: var(--plum-600);
  --accent-ink: var(--plum-700);
  --accent-on: var(--plum-900);
}

/* Lemon · Carbs · warning */
.t-lemon,
.t-carbs,
.t-warn {
  --accent-wash: var(--lemon-50);
  --accent-soft: var(--lemon-100);
  --accent-track: var(--lemon-200);
  --accent-light: var(--lemon-300);
  --accent: var(--lemon-500);
  --accent-strong: var(--lemon-600);
  --accent-ink: var(--lemon-700);
  --accent-on: var(--lemon-900);
}

/* Raspberry · Protein */
.t-raspberry,
.t-protein,
.t-today {   /* Hoy: raspberry, as its tab in the iOS app (it used to be neutral and read as Comida's orange) */
  --accent-wash: var(--raspberry-50);
  --accent-soft: var(--raspberry-100);
  --accent-track: var(--raspberry-200);
  --accent-light: var(--raspberry-300);
  --accent: var(--raspberry-500);
  --accent-strong: var(--raspberry-600);
  --accent-ink: var(--raspberry-700);
  --accent-on: var(--raspberry-900);
}

/* Avocado · Fat · ok, saved, stable */
.t-avocado,
.t-fat,
.t-ok {
  --accent-wash: var(--avocado-50);
  --accent-soft: var(--avocado-100);
  --accent-track: var(--avocado-200);
  --accent-light: var(--avocado-300);
  --accent: var(--avocado-500);
  --accent-strong: var(--avocado-600);
  --accent-ink: var(--avocado-700);
  --accent-on: var(--avocado-900);
}

/* Vivid yellow is very light: its track drops to step 100 so the meter
   stays easy to tell apart. */
.t-lemon,
.t-carbs,
.t-warn {
  --accent-track: var(--lemon-100);
}

/* --- Screen glow: two neighbouring fruits per section --------------------- */

.t-today       { --glow-a: var(--raspberry-100); --glow-b: var(--raspberry-50); --accent-dot: var(--raspberry-500); }
.t-weight      { --glow-a: var(--blueberry-100);  --glow-b: var(--plum-100); }
.t-food        { --glow-a: var(--tangerine-100); --glow-b: var(--lemon-100); }
.t-activity    { --glow-a: var(--watermelon-100);    --glow-b: var(--tangerine-100); }
.t-workouts    { --glow-a: var(--mint-100);     --glow-b: var(--avocado-100); }
.t-expenditure { --glow-a: var(--plum-100);   --glow-b: var(--raspberry-100); }

/* ==========================================================================
   Reduced motion: components use these durations, so zeroing them here is
   enough.
   ========================================================================== */
@media (prefers-reduced-motion: reduce) {
  :root {
    --duration-1: 1ms;
    --duration-2: 1ms;
    --duration-3: 1ms;
    --duration-4: 1ms;
  }
}
