/* ═══════════════════════════════════════════════════════════════════════════
   AgroBridge brand tokens — single source of truth for agrobridgegroup.com.

   Values mirror agrobridge-io-web/tailwind.config.ts, the live brand for
   agrobridge.io. Change a colour HERE and nowhere else: every page links this
   file, and scripts/brand-audit.mjs fails the build if a colour literal shows
   up anywhere outside it.

   Light (cream paper) is the DEFAULT theme. Dark is opt-in via
   <html data-theme="dark">, set by the anti-FOUC script from the stored
   `agrobridge-theme` preference.

   Three layers, in order:
     1. Ramps      — raw scales. Never referenced by a component rule.
     2. Roles      — what a colour is FOR. This is what components read.
     3. Aliases    — the older Spanish names, re-pointed at roles so the
                     ~1,400 existing var() call sites keep working.

   ── The contrast contract ────────────────────────────────────────────────
   Enforced by scripts/brand-audit.mjs check 8. Every violation is a bug.

     · primary-500  #62732F  lightest text-grade olive on a light canvas
     · secondary-500 #B99539 and lighter are NEVER text on light, and NEVER
       a fill under white text. Gold TEXT on light is secondary-700 #6B5220.
       The white-label gold FILL is secondary-600 #846723.
     · On dark canvases use primary-400, secondary-400, and the dark
       semantic shades.
     · neutral-400 #A69F8B is muted text on DARK surfaces only.

   One exemption, nowhere else: the "AgroBridge" wordmark. WCAG 1.4.3 exempts
   logotype text, so "Bridge" carries the metallic gold gradient rather than a
   flat swatch — any flat gold dark enough to clear AA on paper reads brown,
   which is the wrong brand colour.
   ═══════════════════════════════════════════════════════════════════════ */

:root {
    /* ── 1. RAMPS — raw scales, never used directly by components ────────── */

    /* Primary — Verde Hoja: the olive/sage leaf green of the wreath */
    --primary-50: #F5F7EC;
    --primary-100: #E9EED6;
    --primary-200: #D3DDAE;
    --primary-300: #B5C47E;
    --primary-400: #98A958;
    --primary-500: #62732F;
    --primary-600: #4C5A24;
    --primary-700: #3A4520;
    --primary-800: #2E3719;
    --primary-900: #20260F;

    /* Secondary — Oro Antiguo: the antique gold of the AB monogram */
    --secondary-50: #FBF7EA;
    --secondary-100: #F5EBCB;
    --secondary-200: #EADA9F;
    --secondary-300: #DCC26E;
    --secondary-400: #CDAC4E;
    --secondary-500: #B99539;
    --secondary-600: #846723;
    --secondary-700: #6B5220;
    --secondary-800: #4F3D16;
    --secondary-900: #33270D;

    /* Neutral — Papel Greige: warm, olive-tinted paper grays */
    --neutral-50: #FAF8F2;
    --neutral-100: #F1EEE4;
    --neutral-200: #E3DFD0;
    --neutral-300: #CEC8B4;
    --neutral-400: #A69F8B;
    --neutral-500: #6F6857;
    --neutral-600: #665F4F;
    --neutral-700: #4E483A;
    --neutral-800: #37332A;
    --neutral-900: #23201A;
    --neutral-950: #141310;

    /* Canvases — the logo's own paper, and the deep botanical ink */
    --bone: #F3F0E7;
    --tinta: #171C0F;

    /* Berry accents from the wreath's fruit — badges, chips, icons */
    --mora: #5C4A85;
    --mora-rgb: 92 74 133;
    --arandano: #3E5379;
    --frambuesa: #96434B;
    --maracuya: #D89C3F;

    /* ── 2. ROLES — LIGHT / paper is the default theme ───────────────────── */

    --canvas: var(--bone);
    --surface: var(--neutral-50);
    --surface-card: #FFFFFF;
    --surface-strong: #FFFFFF;
    --surface-raised: rgb(35 32 26 / 0.03);
    --hairline: var(--neutral-200);
    --hairline-strong: var(--neutral-300);

    --text-primary: var(--neutral-900);
    --text-secondary: var(--neutral-700);
    --text-muted: var(--neutral-600);

    --brand-primary: var(--primary-700);        /* olive: decorative + fills */
    --brand-primary-fill: var(--primary-600);   /* olive under WHITE text (7.51) */
    --brand-primary-text: var(--primary-500);   /* lightest olive TEXT on light */
    --brand-primary-rgb: 58 69 32;              /* for rgb(var() / α) tints */

    --brand-gold: var(--secondary-500);         /* accent ONLY — never text here */
    --brand-gold-soft: var(--secondary-300);    /* gradient partner */
    --brand-gold-fill: var(--secondary-600);    /* gold under WHITE text (5.32) */
    --brand-gold-text: var(--secondary-700);    /* gold TEXT on light (7.36) */
    --brand-gold-rgb: 185 149 57;               /* for rgb(var() / α) tints */
    --on-gold: var(--neutral-900);              /* ink text on gold: 5.74 light, 7.43 dark */

    /* Bare triplets for translucent surfaces. A component that needs a
       see-through canvas writes rgb(var(--canvas-rgb) / 0.88) and gets the
       right colour in BOTH themes from one rule — which is what collapses the
       old [data-theme] override pairs down to single rules. */
    --canvas-rgb: 243 240 231;
    --surface-rgb: 250 248 242;
    --card-rgb: 255 255 255;
    --shadow-rgb: 35 32 26;   /* shadows on paper are warm ink, not black */

    /* A subtle step AWAY from the surface, for hover fills and hairlines.
       The direction flips with the theme: darker on paper, lighter on ink.
       On the old dark-only site every one of these was a white wash, which is
       why they had to be re-pointed rather than kept. */
    --tint-rgb: 35 32 26;

    /* A top-lit highlight for surfaces that are dark or gold in BOTH themes —
       the .impact band, the gold CTA. Stays white; it is not theme-dependent. */
    --highlight-rgb: 255 255 255;

    --success: #467322;
    --warning: #96620F;
    --error: #C0392F;
    --info: #2F4B8F;
    --success-rgb: 70 115 34;
    --error-rgb: 192 57 47;

    /* Gradients — the brand's two colours, nowhere else */
    --gradient-gold-cta: linear-gradient(135deg, #B99539 0%, #DCC26E 100%);
    --gradient-divider-gold: linear-gradient(90deg, transparent, #B99539, transparent);
    --gradient-hero: linear-gradient(180deg, #3A4520 0%, #4C5A24 50%, #B99539 100%);

    /* Depth — light surfaces need a softer, cooler shadow than ink does */
    --shadow-soft: 0 8px 24px rgb(35 32 26 / 0.08);
    --shadow-medium: 0 16px 36px rgb(35 32 26 / 0.14);
    --shadow-gold: 0 10px 26px rgb(var(--brand-gold-rgb) / 0.2);
    --focus-ring: 0 0 0 3px rgb(var(--brand-gold-rgb) / 0.32);

    /* ── 3. ALIASES — the older Spanish names, re-pointed at roles ────────
       These keep ~1,400 existing var() call sites working untouched. They are
       role-based already: the old light-mode block redefined every one of
       them, so a name means "the canvas" or "the primary text", not a literal
       colour.

       ⚠ --oro and --verde-profundo are each used today BOTH as a fill and as
       text. One alias cannot be right for both. Audit each call site and
       re-point it: color: → *-text, background: under light text → *-fill,
       borders and glows → the plain accent.

       ⚠ ALIASES DO NOT FOLLOW ELEMENT-SCOPED OVERRIDES. var() inside a custom
       property is substituted where that property is DECLARED, not on each
       descendant. Because these aliases are declared here on :root, they
       resolve against :root's role tokens and inherit already-resolved.

         [data-theme="dark"] works — it also matches <html>, so the alias sees
         the winning value. Verified in-browser.

         .some-section { --text-primary: … } does NOT reach var(--hueso)
         inside it. An always-dark band must set the ALIAS names directly.
         See .impact in styles.css for the worked example. */
    --negro: var(--canvas);
    --carbon: var(--surface);
    --grafito: var(--hairline);
    --slate: var(--text-muted);
    --ceniza: var(--text-muted);
    --niebla: var(--text-secondary);
    --hueso: var(--text-primary);
    --blanco: #FFFFFF;
    --background: var(--canvas);

    --verde-profundo: var(--brand-primary);
    --verde-medio: var(--brand-primary-fill);
    --verde-claro: var(--brand-primary-text);
    --oro: var(--brand-gold);
    --oro-claro: var(--brand-gold-soft);
    --oro-oscuro: var(--brand-gold-text);

    /* ── NON-COLOUR TOKENS — unchanged, moved here so they stop being
          duplicated across 14 pages ─────────────────────────────────────── */

    /* Type scale, 1.333x */
    --text-xs: 0.75rem;
    --text-sm: 0.875rem;
    --text-base: 1rem;
    --text-lg: 1.333rem;
    --text-xl: 1.777rem;
    --text-2xl: 2.369rem;
    --text-3xl: 3.157rem;
    --text-4xl: 4.209rem;
    --text-5xl: 5.61rem;

    /* Spacing, 8px grid */
    --space-1: 0.25rem;
    --space-2: 0.5rem;
    --space-3: 0.75rem;
    --space-4: 1rem;
    --space-5: 1.5rem;
    --space-6: 2rem;
    --space-7: 2.5rem;
    --space-8: 3rem;
    --space-10: 4rem;
    --space-12: 6rem;
    --space-16: 8rem;
    --space-20: 10rem;

    /* Motion */
    --ease-out-expo: cubic-bezier(0.16, 1, 0.3, 1);
    --ease-out-quart: cubic-bezier(0.25, 1, 0.5, 1);
    --ease-out: var(--ease-out-quart);
    --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);
    --duration-fast: 150ms;
    --duration-normal: 300ms;
    --duration-slow: 500ms;
    --duration-slower: 800ms;

    /* Layout */
    --max-width: 1200px;
    --max-width-narrow: 820px;
    --max-width-wide: 1320px;
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --radius-pill: 999px;
    --border-radius: var(--radius-md);

    /* Type faces. Playfair Display (display) and DM Sans (body) are applied by
       component rules; the mono face is a token because data and hashes read
       it by name. */
    --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;

    /* Theme transition — off until JS enables it, so the first paint does not
       animate from the wrong colour. */
    --theme-transition: none;
}

/* ═══ DARK THEME — verde tinta, never pure black ═══════════════════════════
   Opt-in. The anti-FOUC script sets data-theme="dark" before first paint when
   the stored preference is dark; with no stored preference the site stays on
   paper, matching agrobridge.io. */

[data-theme="dark"] {
    --canvas: var(--tinta);
    --surface: #222817;
    --surface-card: #222817;
    --surface-strong: #1C2213;
    --surface-raised: rgb(243 240 231 / 0.04);
    --hairline: #3A4128;
    --hairline-strong: #4A5236;

    --text-primary: var(--bone);
    --text-secondary: var(--neutral-300);
    --text-muted: #A3A18C;

    --brand-primary: var(--primary-400);        /* olive TEXT on ink (6.74) */
    --brand-primary-fill: var(--primary-600);
    --brand-primary-text: var(--primary-400);
    --brand-primary-rgb: 152 169 88;

    --brand-gold: var(--secondary-400);
    --brand-gold-soft: var(--secondary-300);
    --brand-gold-fill: var(--secondary-600);
    --brand-gold-text: var(--secondary-400);    /* gold TEXT on ink (7.94) */
    --brand-gold-rgb: 205 172 78;

    --canvas-rgb: 23 28 15;
    --surface-rgb: 34 40 23;
    --card-rgb: 34 40 23;
    --shadow-rgb: 0 0 0;
    --tint-rgb: 255 255 255;

    --success: #98A958;
    --warning: #D89C3F;
    --error: #E98A80;
    --info: #8FA8D8;
    --success-rgb: 152 169 88;
    --error-rgb: 233 138 128;

    --shadow-soft: 0 6px 24px rgb(0 0 0 / 0.22);
    --shadow-medium: 0 14px 38px rgb(0 0 0 / 0.3);
    --shadow-gold: 0 8px 24px rgb(var(--brand-gold-rgb) / 0.2);
    --focus-ring: 0 0 0 3px rgb(var(--brand-gold-rgb) / 0.28);
}

/* Respect a hard preference for less motion at the token level, so every rule
   that reads --duration-* settles instantly without needing its own query. */
@media (prefers-reduced-motion: reduce) {
    :root {
        --duration-fast: 0.01ms;
        --duration-normal: 0.01ms;
        --duration-slow: 0.01ms;
        --duration-slower: 0.01ms;
        --theme-transition: none;
    }
}
