/* ==========================================================================
   JOTL — tokens.css
   Design tokens for Jacimar Organics Therapy Limited.
   Source of truth: PHASE-0-AUDIT.md §1.1 (light), §1.2 (dark), §1.4 (type),
   §1.5 (spacing/radius/elevation). Values are the rendered values from
   Design A's tailwind.config, not the values in Design A's own DESIGN.md.

   Load order: tokens.css → base.css → components.css → pages.css

   Theme resolution: the theme is driven by the `data-theme` attribute on
   <html> ("light" or "dark"), set by an inline blocking script in each page
   head so there is no flash. When the attribute is absent — no JS, or first
   paint — the OS preference applies via prefers-color-scheme. There is no
   "auto" value: the toggle has two states, light and dark.

   CONTRAST — every pair below was computed with the WCAG relative-luminance
   formula and meets AA. Do not introduce a new colour pair without running
   the same check.

     LIGHT  on-surface/surface 16.27 · on-surface-variant/surface 8.92
            on-surface-variant/container 7.42 · gold #735C00/surface 6.13
            gold #8E6C18/surface 4.64 · white/primary-container 14.78
            #ADCEC0/primary-container 8.70 · error/surface 6.14
            outline/surface 4.24 (non-text only, 3:1 threshold)
     DARK   on-surface/surface 15.44 · on-surface/container-low 13.86
            on-surface/container 12.27 · on-surface-variant/surface 8.69
            on-surface-variant/container 6.90 · gold/surface 8.76
            on-primary/primary 8.76 · secondary/surface 14.56
            error/surface 10.85 · error/container 8.62
            outline/surface 5.25 · outline/container 4.18 (non-text only)

   RULE: --outline is never a text colour. It clears 3:1 for borders and
   controls, not 4.5:1 for body copy, in either theme.
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. LIGHT THEME (default)
   -------------------------------------------------------------------------- */
:root {
  color-scheme: light;

  /* --- Surfaces --- */
  --surface:                    #FBF9F5;
  --surface-container-lowest:   #FFFFFF;
  --surface-container-low:      #F5F3EF;
  --surface-container:          #EFEEEA;
  --surface-container-high:     #EAE8E4;
  --surface-container-highest:  #E4E2DE;

  /* --- Content on surfaces --- */
  --on-surface:                 #1B1C1A;
  --on-surface-variant:         #414845;

  /* --- Primary: deep emerald --- */
  --primary:                    #001710;
  --on-primary:                 #FFFFFF;
  --primary-container:          #0F2D24;
  --on-primary-container:       #ADCEC0;
  --primary-fixed-dim:          #ADCEC0;

  /* --- Secondary: metallic gold --- */
  --secondary:                  #735C00;
  --on-secondary:               #FFFFFF;
  --secondary-container:        #FED65B;
  --on-secondary-container:     #231B00;
  --secondary-fixed:            #FFE088;
  --secondary-fixed-dim:        #E9C349;

  /* --- Tertiary --- */
  --tertiary:                   #02170F;
  --tertiary-container:         #162C23;
  --on-tertiary-container:      #ADCEC0;

  /* --- Lines --- */
  --surface-tint:               #476459;
  --outline:                    #727975;   /* NON-TEXT ONLY */
  --outline-variant:            #C1C8C4;

  /* --- Status --- */
  --error:                      #BA1A1A;
  --on-error:                   #FFFFFF;
  --error-container:            #FFDAD6;
  --on-error-container:         #410002;
  --success:                    #1E5F3E;
  --on-success:                 #FFFFFF;
  --warning:                    #8E6C18;
  --on-warning:                 #FFFFFF;

  /* --- Brand accents (aliases with contrast-safe intent) --- */
  --gold-text:                  #735C00;   /* 6.13:1 on surface — use for text */
  --gold-muted-text:            #8E6C18;   /* 4.64:1 on surface — small accents only */
  --gold-decor:                 #C9A227;   /* decorative rules, icons, never text */
  --gold-rim:                   rgba(115, 92, 0, 0.28);
  --emerald-decor:              #0F2D24;

  /* --- Cosmic / botanical motifs --- */
  --star:                       rgba(0, 23, 16, 0.55);
  --star-dim:                   rgba(0, 23, 16, 0.18);
  --orbit-line:                 rgba(15, 45, 36, 0.22);
  --constellation:              rgba(115, 92, 0, 0.42);
  --botanical-line:             rgba(71, 100, 89, 0.20);
  --glow:                       rgba(233, 195, 73, 0.30);
  --scrim:                      rgba(0, 23, 16, 0.48);
  --scrim-strong:               rgba(0, 23, 16, 0.72);

  /* --- Gradients --- */
  --gradient-cosmic:            linear-gradient(160deg, #FBF9F5 0%, #F5F3EF 46%, #EFEEEA 100%);
  --gradient-cosmic-deep:       linear-gradient(158deg, #0F2D24 0%, #02170F 100%);
  --gradient-gold-sheen:        linear-gradient(96deg, #735C00 0%, #E9C349 48%, #FFE088 72%, #735C00 100%);
  --gradient-veil:              linear-gradient(180deg, rgba(251,249,245,0) 0%, rgba(251,249,245,0.92) 74%, #FBF9F5 100%);

  /* --- Semantic aliases — components reference these, not the raw scales --- */
  --bg:                         var(--surface);
  --bg-raised:                  var(--surface-container-lowest);
  --bg-sunken:                  var(--surface-container-low);
  --bg-inset:                   var(--surface-container);
  --bg-inverse:                 var(--primary-container);
  --text:                       var(--on-surface);
  --text-muted:                 var(--on-surface-variant);
  --text-inverse:               var(--on-primary);
  --accent:                     var(--primary);
  --on-accent:                  var(--on-primary);
  --border:                     var(--outline-variant);
  --border-strong:              var(--outline);
  --hairline:                   rgba(27, 28, 26, 0.10);
  --focus-ring:                 #735C00;
  --focus-ring-offset:          var(--surface);
  --link:                       var(--primary);
  --link-hover:                 var(--gold-text);
  --selection-bg:               #ADCEC0;
  --selection-text:             #02170F;

  /* --- Typography --- */
  --font-display: "Playfair Display", "Iowan Old Style", "Palatino Linotype",
                  Palatino, Georgia, "Times New Roman", serif;
  --font-body:    "Plus Jakarta Sans", -apple-system, BlinkMacSystemFont,
                  "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono:    ui-monospace, "SFMono-Regular", "SF Mono", Menlo, Consolas,
                  "Liberation Mono", monospace;

  /* Type scale — size / line-height / tracking / weight */
  --type-display-hero:          64px;
  --type-display-hero-lh:       72px;
  --type-display-hero-ls:       -0.02em;
  --type-display-hero-mobile:   40px;
  --type-display-hero-mobile-lh: 48px;

  --type-headline-lg:           44px;
  --type-headline-lg-lh:        52px;
  --type-headline-lg-ls:        -0.015em;
  --type-headline-lg-mobile:    32px;
  --type-headline-lg-mobile-lh: 40px;

  --type-headline-md:           28px;
  --type-headline-md-lh:        36px;
  --type-headline-sm:           22px;
  --type-headline-sm-lh:        30px;
  --type-headline-sm-weight:    600;

  --type-body-lg:               18px;
  --type-body-lg-lh:            28px;
  --type-body-md:               15px;
  --type-body-md-lh:            24px;
  --type-body-sm:               13px;
  --type-body-sm-lh:            20px;

  --type-label-md:              14px;
  --type-label-md-lh:           18px;
  --type-label-md-weight:       500;
  --type-label-sm:              12px;
  --type-label-sm-lh:           16px;
  --type-label-sm-weight:       600;
  --type-label-sm-ls:           0.08em;
  --type-label-apothecary:      11px;
  --type-label-apothecary-lh:   14px;
  --type-label-apothecary-weight: 600;
  --type-label-apothecary-ls:   0.12em;

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

  /* --- Spacing — 4px base --- */
  --space-0:                    0px;
  --space-1:                    4px;    /* 0.25rem */
  --space-2:                    8px;    /* 0.5rem  */
  --space-3:                    16px;   /* 1rem    */
  --space-4:                    24px;   /* 1.5rem  */
  --space-5:                    40px;   /* 2.5rem  */
  --space-6:                    64px;   /* 4rem    */
  --space-7:                    96px;   /* 6rem    */

  --margin-desktop:             64px;   /* 4rem */
  --margin-mobile:              20px;   /* 1.25rem */
  --gutter-lg:                  40px;
  --gutter-md:                  24px;
  --gutter-sm:                  16px;

  /* --- Layout --- */
  --container-sm:               640px;
  --container-md:               880px;
  --container-lg:               1200px;
  --container-xl:               1440px;
  --measure:                    68ch;
  --header-height:              72px;
  --header-height-mobile:       64px;

  /* --- Radius --- */
  --radius-xs:                  4px;
  --radius-sm:                  8px;
  --radius-md:                  12px;
  --radius-lg:                  16px;
  --radius-pill:                9999px;
  --radius-circle:              50%;

  /* --- Elevation --- */
  --elev-0:                     none;
  --elev-1:                     0 1px 2px rgba(27, 28, 26, 0.06),
                                0 1px 3px rgba(27, 28, 26, 0.04);
  --elev-2:                     0 2px 6px rgba(27, 28, 26, 0.07),
                                0 8px 20px -8px rgba(27, 28, 26, 0.10);
  --elev-3:                     0 4px 12px rgba(27, 28, 26, 0.08),
                                0 20px 40px -16px rgba(27, 28, 26, 0.16);
  --elev-4:                     0 8px 24px rgba(27, 28, 26, 0.10),
                                0 32px 64px -24px rgba(27, 28, 26, 0.22);
  --elev-gold:                  0 0 0 1px var(--gold-rim),
                                0 18px 40px -20px rgba(115, 92, 0, 0.35);

  /* --- Motion --- */
  --dur-instant:                80ms;
  --dur-fast:                   160ms;
  --dur-base:                   240ms;
  --dur-slow:                   400ms;
  --dur-reveal:                 720ms;
  --ease-standard:              cubic-bezier(0.2, 0, 0.2, 1);
  --ease-enter:                 cubic-bezier(0.16, 0.84, 0.24, 1);
  --ease-exit:                  cubic-bezier(0.4, 0, 1, 1);
  --ease-out-soft:              cubic-bezier(0.22, 1, 0.36, 1);
  --reveal-distance:            24px;

  /* --- Controls --- */
  --control-height-sm:          36px;
  --control-height-md:          44px;
  --control-height-lg:          52px;
  --focus-width:                2px;
  --focus-offset:               3px;
  --border-width:               1px;
  --border-width-strong:        2px;

  /* --- Z-index scale --- */
  --z-base:                     0;
  --z-raised:                   10;
  --z-sticky:                   40;
  --z-header:                   100;
  --z-drawer:                   200;
  --z-overlay:                  300;
  --z-modal:                    400;
  --z-cookie-banner:            500;
  --z-chatbot:                  550;
  --z-toast:                    600;
  --z-skip-link:                700;
}

/* --------------------------------------------------------------------------
   2. DARK THEME — applied by [data-theme="dark"]
   -------------------------------------------------------------------------- */
:root[data-theme="dark"] {
  color-scheme: dark;

  /* --- Surfaces --- */
  --surface:                    #071712;
  --surface-container-lowest:   #050F0C;
  --surface-container-low:      #0B231B;
  --surface-container:          #0E2E24;
  --surface-container-high:     #13342A;
  --surface-container-highest:  #183D31;

  /* --- Content on surfaces --- */
  --on-surface:                 #E8ECE9;
  --on-surface-variant:         #A9B5AE;

  /* --- Primary: metallic gold becomes the primary in dark --- */
  --primary:                    #D4AF37;
  --on-primary:                 #071712;
  --primary-container:          #0F2D24;
  --on-primary-container:       #ADCEC0;
  --primary-fixed-dim:          #ADCEC0;

  /* --- Secondary --- */
  --secondary:                  #F3E5AB;
  --on-secondary:               #071712;
  --secondary-container:        #3A3110;
  --on-secondary-container:     #F3E5AB;
  --secondary-fixed:            #FFE088;
  --secondary-fixed-dim:        #E9C349;

  /* --- Tertiary --- */
  --tertiary:                   #E8ECE9;
  --tertiary-container:         #162C23;
  --on-tertiary-container:      #ADCEC0;

  /* --- Lines --- */
  --surface-tint:               #A9B5AE;
  --outline:                    #7F8C85;   /* NON-TEXT ONLY */
  --outline-variant:            #33463C;

  /* --- Status --- */
  --error:                      #FFB4AB;
  --on-error:                   #370001;
  --error-container:            #5C1410;
  --on-error-container:         #FFDAD6;
  --success:                    #7FD1A6;
  --on-success:                 #052314;
  --warning:                    #F3E5AB;
  --on-warning:                 #071712;

  /* --- Brand accents --- */
  --gold-text:                  #D4AF37;   /* 8.76:1 on surface */
  --gold-muted-text:            #C0A673;
  --gold-decor:                 #D4AF37;
  --gold-rim:                   rgba(212, 175, 55, 0.25);
  --emerald-decor:              #ADCEC0;

  /* --- Cosmic / botanical motifs --- */
  --star:                       rgba(232, 236, 233, 0.72);
  --star-dim:                   rgba(232, 236, 233, 0.22);
  --orbit-line:                 rgba(232, 236, 233, 0.12);
  --constellation:              rgba(212, 175, 55, 0.48);
  --botanical-line:             rgba(169, 181, 174, 0.16);
  --glow:                       rgba(212, 175, 55, 0.34);
  --scrim:                      rgba(3, 10, 8, 0.62);
  --scrim-strong:               rgba(3, 10, 8, 0.84);

  /* --- Gradients --- */
  --gradient-cosmic:            linear-gradient(160deg, #0B231B 0%, #071712 52%, #050F0C 100%);
  --gradient-cosmic-deep:       linear-gradient(158deg, #0E2E24 0%, #050F0C 100%);
  --gradient-gold-sheen:        linear-gradient(96deg, #8A6D1F 0%, #D4AF37 44%, #FFE088 68%, #8A6D1F 100%);
  --gradient-veil:              linear-gradient(180deg, rgba(7,23,18,0) 0%, rgba(7,23,18,0.92) 74%, #071712 100%);

  /* --- Semantic aliases --- */
  --bg:                         var(--surface);
  --bg-raised:                  var(--surface-container-low);
  --bg-sunken:                  var(--surface-container-lowest);
  --bg-inset:                   var(--surface-container);
  --bg-inverse:                 #E8ECE9;
  --text:                       var(--on-surface);
  --text-muted:                 var(--on-surface-variant);
  --text-inverse:               #071712;
  --accent:                     var(--primary);
  --on-accent:                  var(--on-primary);
  --border:                     var(--outline-variant);
  --border-strong:              var(--outline);
  --hairline:                   rgba(232, 236, 233, 0.08);
  --focus-ring:                 #D4AF37;
  --focus-ring-offset:          var(--surface);
  --link:                       #D4AF37;
  --link-hover:                 #FFE088;
  --selection-bg:               #D4AF37;
  --selection-text:             #071712;

  /* --- Elevation — light reads as shadow, dark reads as lift + rim --- */
  --elev-1:                     0 1px 2px rgba(0, 0, 0, 0.40),
                                0 0 0 1px rgba(232, 236, 233, 0.04);
  --elev-2:                     0 4px 12px rgba(0, 0, 0, 0.44),
                                0 0 0 1px rgba(232, 236, 233, 0.06);
  --elev-3:                     0 12px 28px rgba(0, 0, 0, 0.50),
                                0 0 0 1px rgba(232, 236, 233, 0.07);
  --elev-4:                     0 24px 56px rgba(0, 0, 0, 0.58),
                                0 0 0 1px rgba(232, 236, 233, 0.08);
  --elev-gold:                  0 0 0 1px var(--gold-rim),
                                0 18px 44px -18px rgba(212, 175, 55, 0.30);
}

/* --------------------------------------------------------------------------
   3. OS-preference fallback — only when no explicit theme has been applied.
   This is the no-JS and pre-paint path. Values mirror [data-theme="dark"]
   exactly; keep the two blocks in step if either changes.
   -------------------------------------------------------------------------- */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;

    --surface:                    #071712;
    --surface-container-lowest:   #050F0C;
    --surface-container-low:      #0B231B;
    --surface-container:          #0E2E24;
    --surface-container-high:     #13342A;
    --surface-container-highest:  #183D31;

    --on-surface:                 #E8ECE9;
    --on-surface-variant:         #A9B5AE;

    --primary:                    #D4AF37;
    --on-primary:                 #071712;
    --primary-container:          #0F2D24;
    --on-primary-container:       #ADCEC0;
    --primary-fixed-dim:          #ADCEC0;

    --secondary:                  #F3E5AB;
    --on-secondary:               #071712;
    --secondary-container:        #3A3110;
    --on-secondary-container:     #F3E5AB;
    --secondary-fixed:            #FFE088;
    --secondary-fixed-dim:        #E9C349;

    --tertiary:                   #E8ECE9;
    --tertiary-container:         #162C23;
    --on-tertiary-container:      #ADCEC0;

    --surface-tint:               #A9B5AE;
    --outline:                    #7F8C85;
    --outline-variant:            #33463C;

    --error:                      #FFB4AB;
    --on-error:                   #370001;
    --error-container:            #5C1410;
    --on-error-container:         #FFDAD6;
    --success:                    #7FD1A6;
    --on-success:                 #052314;
    --warning:                    #F3E5AB;
    --on-warning:                 #071712;

    --gold-text:                  #D4AF37;
    --gold-muted-text:            #C0A673;
    --gold-decor:                 #D4AF37;
    --gold-rim:                   rgba(212, 175, 55, 0.25);
    --emerald-decor:              #ADCEC0;

    --star:                       rgba(232, 236, 233, 0.72);
    --star-dim:                   rgba(232, 236, 233, 0.22);
    --orbit-line:                 rgba(232, 236, 233, 0.12);
    --constellation:              rgba(212, 175, 55, 0.48);
    --botanical-line:             rgba(169, 181, 174, 0.16);
    --glow:                       rgba(212, 175, 55, 0.34);
    --scrim:                      rgba(3, 10, 8, 0.62);
    --scrim-strong:               rgba(3, 10, 8, 0.84);

    --gradient-cosmic:            linear-gradient(160deg, #0B231B 0%, #071712 52%, #050F0C 100%);
    --gradient-cosmic-deep:       linear-gradient(158deg, #0E2E24 0%, #050F0C 100%);
    --gradient-gold-sheen:        linear-gradient(96deg, #8A6D1F 0%, #D4AF37 44%, #FFE088 68%, #8A6D1F 100%);
    --gradient-veil:              linear-gradient(180deg, rgba(7,23,18,0) 0%, rgba(7,23,18,0.92) 74%, #071712 100%);

    --bg:                         var(--surface);
    --bg-raised:                  var(--surface-container-low);
    --bg-sunken:                  var(--surface-container-lowest);
    --bg-inset:                   var(--surface-container);
    --bg-inverse:                 #E8ECE9;
    --text:                       var(--on-surface);
    --text-muted:                 var(--on-surface-variant);
    --text-inverse:               #071712;
    --accent:                     var(--primary);
    --on-accent:                  var(--on-primary);
    --border:                     var(--outline-variant);
    --border-strong:              var(--outline);
    --hairline:                   rgba(232, 236, 233, 0.08);
    --focus-ring:                 #D4AF37;
    --focus-ring-offset:          var(--surface);
    --link:                       #D4AF37;
    --link-hover:                 #FFE088;
    --selection-bg:               #D4AF37;
    --selection-text:             #071712;

    --elev-1:                     0 1px 2px rgba(0, 0, 0, 0.40),
                                  0 0 0 1px rgba(232, 236, 233, 0.04);
    --elev-2:                     0 4px 12px rgba(0, 0, 0, 0.44),
                                  0 0 0 1px rgba(232, 236, 233, 0.06);
    --elev-3:                     0 12px 28px rgba(0, 0, 0, 0.50),
                                  0 0 0 1px rgba(232, 236, 233, 0.07);
    --elev-4:                     0 24px 56px rgba(0, 0, 0, 0.58),
                                  0 0 0 1px rgba(232, 236, 233, 0.08);
    --elev-gold:                  0 0 0 1px var(--gold-rim),
                                  0 18px 44px -18px rgba(212, 175, 55, 0.30);
  }
}

/* --------------------------------------------------------------------------
   4. Reduced motion — collapse durations so nothing animates, while keeping
   transitions present so state changes still announce themselves.
   Individual components must also gate parallax and auto-playing motion on
   `prefers-reduced-motion: no-preference`.
   -------------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  :root {
    --dur-instant:              1ms;
    --dur-fast:                 1ms;
    --dur-base:                 1ms;
    --dur-slow:                 1ms;
    --dur-reveal:               1ms;
    --reveal-distance:          0px;
    --ease-standard:            linear;
    --ease-enter:               linear;
    --ease-exit:                linear;
    --ease-out-soft:            linear;
  }
}

/* --------------------------------------------------------------------------
   5. Print — force the light palette regardless of the active theme.
   -------------------------------------------------------------------------- */
@media print {
  :root,
  :root[data-theme="dark"] {
    color-scheme: light;
    --bg:                       #FFFFFF;
    --bg-raised:                #FFFFFF;
    --bg-sunken:                #FFFFFF;
    --bg-inset:                 #FFFFFF;
    --text:                     #000000;
    --text-muted:               #333333;
    --border:                   #999999;
    --hairline:                 #DDDDDD;
    --elev-1:                   none;
    --elev-2:                   none;
    --elev-3:                   none;
    --elev-4:                   none;
    --elev-gold:                none;
  }
}
