/* ==========================================================================
   NavRun Design Tokens
   "Field Guide x Campfire" v2 -- warm rust/cream/charcoal token ramp
   ========================================================================== */

/* -------------------------------------------------------------------------
   Display Typeface
   ------------------------------------------------------------------------- */
@font-face {
  font-family: 'Bazook';
  src: url("../fonts/Bazook.7504a8e030cb.otf") format('opentype');
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

:root {
  /* -------------------------------------------------------------------------
     Brand Palette
     ------------------------------------------------------------------------- */
  --brand-red: #A24336;
  --brand-red-dark: #8A3A2E;
  --brand-red-light: #C96A5C;
  --brand-peach: #D9986F;
  --brand-cream: #EAD9BC;
  --brand-pine: #202B2A;

  /* Text-on-pine / text-on-rust -- used by the left sidebar nav */
  --color-pine-ink: #F5EEDB;
  --color-on-rust: #FBF3E7;

  /* -------------------------------------------------------------------------
     Primary Palette
     ------------------------------------------------------------------------- */
  --color-primary: #A24336;
  --color-primary-light: #C96A5C;
  --color-primary-dark: #8A3A2E;
  --color-primary-subtle: rgba(162, 67, 54, 0.1);

  /* Accent - Achievement Green */
  --color-accent: #10b981;
  --color-accent-dark: #059669;
  --color-accent-subtle: rgba(16, 185, 129, 0.1);

  /* -------------------------------------------------------------------------
     Run Type Colors
     ------------------------------------------------------------------------- */
  --color-easy: #22c55e;
  --color-long: #3b82f6;
  --color-tempo: #f59e0b;
  --color-interval: #ef4444;
  --color-recovery: #8b5cf6;
  --color-rest: #64748b;

  /* -------------------------------------------------------------------------
     Neutral Colors -- warm paper/espresso ramp
     ------------------------------------------------------------------------- */
  --color-bg: #FBF9F5;
  --color-bg-subtle: #F5F1EA;
  --color-surface: #FEFDFB;
  --color-surface-raised: #FFFFFF;
  --color-border: #E7DFD3;
  --color-border-light: #F0EAE0;
  --color-text: #2E2E33;
  --color-text-muted: #7A6E63;
  --color-text-subtle: #A99E90;

  /* -------------------------------------------------------------------------
     Semantic Colors
     ------------------------------------------------------------------------- */
  --color-success: #22c55e;
  --color-success-subtle: rgba(34, 197, 94, 0.1);
  --color-warning: #f59e0b;
  --color-warning-subtle: rgba(245, 158, 11, 0.1);
  --color-danger: #ef4444;
  --color-danger-subtle: rgba(239, 68, 68, 0.1);
  --color-info: #3b82f6;
  --color-info-subtle: rgba(59, 130, 246, 0.1);

  /* -------------------------------------------------------------------------
     Shadows -- warm "specimen" shadows, brand-hue-tinted (rust, hsl 14)
     ------------------------------------------------------------------------- */
  --shadow-xs: 1px 2px 4px hsl(14 42% 30% / 0.10);
  --shadow-sm: 2px 3px 7px hsl(14 42% 28% / 0.12);
  --shadow-md: 3px 5px 14px hsl(14 42% 26% / 0.16), 0 1px 3px hsl(14 42% 26% / 0.09);
  --shadow-lg: 4px 7px 22px hsl(14 42% 24% / 0.20);
  --shadow-xl: 6px 10px 32px hsl(14 42% 22% / 0.24), 0 2px 6px hsl(14 42% 24% / 0.12);

  /* -------------------------------------------------------------------------
     Spacing Scale
     ------------------------------------------------------------------------- */
  --space-xs: 0.25rem;   /* 4px */
  --space-sm: 0.5rem;    /* 8px */
  --space-md: 1rem;      /* 16px */
  --space-lg: 1.5rem;    /* 24px */
  --space-xl: 2rem;      /* 32px */
  --space-2xl: 3rem;     /* 48px */
  --space-3xl: 4rem;     /* 64px */

  /* -------------------------------------------------------------------------
     Border Radius
     ------------------------------------------------------------------------- */
  --radius-sm: 0.5rem;    /* 8px */
  --radius-md: 0.75rem;   /* 12px */
  --radius-lg: 1.1rem;    /* ~17.6px */
  --radius-xl: 1.5rem;    /* 24px */
  --radius-full: 9999px;

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

  /* -------------------------------------------------------------------------
     Typography
     ------------------------------------------------------------------------- */
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "SF Mono", "Cascadia Code", "Roboto Mono", monospace;
  --font-display: 'Bazook', 'Arial Black', sans-serif;

  --text-xs: 0.75rem;    /* 12px */
  --text-sm: 0.875rem;   /* 14px */
  --text-base: 1rem;     /* 16px */
  --text-lg: 1.125rem;   /* 18px */
  --text-xl: 1.25rem;    /* 20px */
  --text-2xl: 1.5rem;    /* 24px */
  --text-3xl: 2rem;      /* 32px */
  --text-4xl: 2.5rem;    /* 40px */

  --font-normal: 400;
  --font-medium: 500;
  --font-semibold: 600;
  --font-bold: 700;

  --leading-tight: 1.25;
  --leading-normal: 1.5;
  --leading-relaxed: 1.625;

  /* -------------------------------------------------------------------------
     Bootstrap Bridge -- lets stock Bootstrap components (.card, .table,
     .list-group, .form-control, .modal, etc.) inherit the warm token ramp
     without touching any markup. (--bs-primary fill is Sass-compiled and
     is handled separately by the existing .btn-primary override.)
     ------------------------------------------------------------------------- */
  --bs-body-bg: var(--color-bg);
  --bs-body-color: var(--color-text);
  --bs-emphasis-color: var(--color-text);
  --bs-secondary-color: var(--color-text-muted);
  --bs-border-color: var(--color-border);
  --bs-border-radius: var(--radius-md);
  --bs-link-color: var(--color-primary);
  --bs-body-font-family: var(--font-sans);
}

/* -------------------------------------------------------------------------
   Display Surfaces -- headlines, hero numbers, section titles, wordmark.
   NOT applied to body copy, tables, or form controls (keep those scannable
   on the system sans).
   ------------------------------------------------------------------------- */
h1, h2, h3,
.display-1, .display-2, .display-3, .display-4, .display-5, .display-6,
.navbar-brand {
  font-family: var(--font-display);
}

/* -------------------------------------------------------------------------
   Paper Grain -- fixed, page-wide texture layer (pure CSS/SVG, no assets)
   ------------------------------------------------------------------------- */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 9999;
  pointer-events: none;
  opacity: 0.035;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='300' height='300'%3E%3Cfilter id='navrunGrain'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23navrunGrain)'/%3E%3C/svg%3E");
  background-repeat: repeat;
}

@media (prefers-reduced-motion: reduce) {
  body::before {
    opacity: 0.02;
  }
}

/* ==========================================================================
   Dark Mode Variables
   ========================================================================== */

/* Automatic dark mode based on system preference */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    /* -------------------------------------------------------------------------
       Neutral Colors - Dark Mode -- warm charcoal/campfire ramp
       ------------------------------------------------------------------------- */
    --color-bg: #1A1614;
    --color-bg-subtle: #1F1A17;
    --color-surface: #241F1C;
    --color-surface-raised: #2C2620;
    --color-border: #3D362D;
    --color-border-light: #4A4237;
    --color-text: #F2E9D8;
    --color-text-muted: #B3A890;
    --color-text-subtle: #8C8172;

    /* -------------------------------------------------------------------------
       Primary Palette - Dark Mode Adjustments
       ------------------------------------------------------------------------- */
    --color-primary: #C96A5C;
    --color-primary-light: #E0897A;
    --color-primary-dark: #A24336;
    --color-primary-subtle: rgba(201, 106, 92, 0.15);

    /* Accent - Achievement Green - Dark Mode */
    --color-accent: #10b981;
    --color-accent-dark: #059669;
    --color-accent-subtle: rgba(16, 185, 129, 0.15);

    /* -------------------------------------------------------------------------
       Run Type Colors - Dark Mode (slightly brighter)
       ------------------------------------------------------------------------- */
    --color-easy: #34d399;
    --color-long: #60a5fa;
    --color-tempo: #fbbf24;
    --color-interval: #f87171;
    --color-recovery: #a78bfa;
    --color-rest: #94a3b8;

    /* -------------------------------------------------------------------------
       Semantic Colors - Dark Mode
       ------------------------------------------------------------------------- */
    --color-success: #34d399;
    --color-success-subtle: rgba(52, 211, 153, 0.15);
    --color-warning: #fbbf24;
    --color-warning-subtle: rgba(251, 191, 36, 0.15);
    --color-danger: #f87171;
    --color-danger-subtle: rgba(248, 113, 113, 0.15);
    --color-info: #60a5fa;
    --color-info-subtle: rgba(96, 165, 250, 0.15);

    /* -------------------------------------------------------------------------
       Shadows - Dark Mode -- deeper, near-black warm-tinted for definition
       ------------------------------------------------------------------------- */
    --shadow-xs: 1px 2px 4px hsl(20 30% 4% / 0.35);
    --shadow-sm: 2px 3px 7px hsl(20 30% 4% / 0.40);
    --shadow-md: 3px 5px 14px hsl(20 30% 3% / 0.45), 0 1px 3px hsl(20 30% 3% / 0.25);
    --shadow-lg: 4px 7px 22px hsl(20 30% 2% / 0.50);
    --shadow-xl: 6px 10px 32px hsl(20 30% 2% / 0.55), 0 2px 6px hsl(20 30% 3% / 0.30);

    /* Sidebar goes even deeper pine at night; text-on-rust flips to dark ink
       since the active/rust chip lightens in dark mode */
    --brand-pine: #16130F;
    --color-pine-ink: #F2E9D8;
    --color-on-rust: #211D18;
  }
}

/* Manual dark mode override (when user explicitly selects dark mode) */
[data-theme="dark"] {
  /* -------------------------------------------------------------------------
     Neutral Colors - Dark Mode -- warm charcoal/campfire ramp
     ------------------------------------------------------------------------- */
  --color-bg: #1A1614;
  --color-bg-subtle: #1F1A17;
  --color-surface: #241F1C;
  --color-surface-raised: #2C2620;
  --color-border: #3D362D;
  --color-border-light: #4A4237;
  --color-text: #F2E9D8;
  --color-text-muted: #B3A890;
  --color-text-subtle: #8C8172;

  /* -------------------------------------------------------------------------
     Primary Palette - Dark Mode Adjustments
     ------------------------------------------------------------------------- */
  --color-primary: #C96A5C;
  --color-primary-light: #E0897A;
  --color-primary-dark: #A24336;
  --color-primary-subtle: rgba(201, 106, 92, 0.15);

  /* Accent - Achievement Green - Dark Mode */
  --color-accent: #10b981;
  --color-accent-dark: #059669;
  --color-accent-subtle: rgba(16, 185, 129, 0.15);

  /* -------------------------------------------------------------------------
     Run Type Colors - Dark Mode (slightly brighter)
     ------------------------------------------------------------------------- */
  --color-easy: #34d399;
  --color-long: #60a5fa;
  --color-tempo: #fbbf24;
  --color-interval: #f87171;
  --color-recovery: #a78bfa;
  --color-rest: #94a3b8;

  /* -------------------------------------------------------------------------
     Semantic Colors - Dark Mode
     ------------------------------------------------------------------------- */
  --color-success: #34d399;
  --color-success-subtle: rgba(52, 211, 153, 0.15);
  --color-warning: #fbbf24;
  --color-warning-subtle: rgba(251, 191, 36, 0.15);
  --color-danger: #f87171;
  --color-danger-subtle: rgba(248, 113, 113, 0.15);
  --color-info: #60a5fa;
  --color-info-subtle: rgba(96, 165, 250, 0.15);

  /* -------------------------------------------------------------------------
     Shadows - Dark Mode -- deeper, near-black warm-tinted for definition
     ------------------------------------------------------------------------- */
  --shadow-xs: 1px 2px 4px hsl(20 30% 4% / 0.35);
  --shadow-sm: 2px 3px 7px hsl(20 30% 4% / 0.40);
  --shadow-md: 3px 5px 14px hsl(20 30% 3% / 0.45), 0 1px 3px hsl(20 30% 3% / 0.25);
  --shadow-lg: 4px 7px 22px hsl(20 30% 2% / 0.50);
  --shadow-xl: 6px 10px 32px hsl(20 30% 2% / 0.55), 0 2px 6px hsl(20 30% 3% / 0.30);

  /* Sidebar goes even deeper pine at night; text-on-rust flips to dark ink
     since the active/rust chip lightens in dark mode */
  --brand-pine: #16130F;
  --color-pine-ink: #F2E9D8;
  --color-on-rust: #211D18;
}

/* Smooth color transitions for theme switching */
:root,
:root * {
  transition: background-color var(--transition-base),
              border-color var(--transition-base),
              color var(--transition-base);
}

/* Respect user's motion preferences */
@media (prefers-reduced-motion: reduce) {
  :root,
  :root * {
    transition-duration: 0.01ms !important;
  }
}
