/**
 * ConcreteInfo Design Tokens
 * Single source of truth for all design values
 * Based on HSL color system for semantic theming
 *
 * @author Amit Haridas, ConcreteInfo
 * @version 2.0.0
 */

:root {
  /* ============================================
     COLOR SYSTEM (HSL-based for semantic theming)
     ============================================ */

  /* Brand Colors - ConcreteInfo Palette */
  --color-brand-h: 14;
  --color-brand-s: 77%;
  --color-brand-l: 45%; /* WCAG AA: was 51% (#e24e21, 3.93:1); 45% gives #cb431a (4.82:1) */

  --color-brand: hsl(var(--color-brand-h), var(--color-brand-s), var(--color-brand-l));
  --color-brand-dark: hsl(var(--color-brand-h), var(--color-brand-s), 40%);
  --color-brand-light: hsl(var(--color-brand-h), var(--color-brand-s), 60%);
  --color-brand-50: hsl(var(--color-brand-h), var(--color-brand-s), 98%);
  --color-brand-100: hsl(var(--color-brand-h), var(--color-brand-s), 95%);
  --color-brand-200: hsl(var(--color-brand-h), var(--color-brand-s), 90%);

  /* Neutral Scale - matches concreteinfo.in warm gray palette */
  --color-gray-50: #fafbfc;
  --color-gray-100: #f5f5f5;
  --color-gray-200: #e3e3e3;
  --color-gray-300: #d1d1d1;
  --color-gray-400: #787374; /* WCAG AA: was #b0b0b0 → 4.66:1 on white */
  --color-gray-500: #6b6767; /* WCAG AA: was #9a9696 → 5.58:1 on white */
  --color-gray-600: #5f5b5b; /* WCAG AA: was #7a7878 → 6.70:1 on white */
  --color-gray-700: #5a5858;
  --color-gray-800: #4e4e4e;
  --color-gray-850: #4a4a4a;
  --color-gray-900: #464646;
  --color-gray-950: #0d0b09;

  /* Semantic Colors */
  --color-primary: var(--color-brand);
  --color-primary-hover: var(--color-brand-dark);
  --color-primary-light: var(--color-brand-100);

  --color-secondary: var(--color-gray-700);
  --color-secondary-hover: var(--color-gray-800);

  --color-success: #1a7a56;
  --color-success-light: hsl(159, 64%, 95%);

  --color-warning: hsl(45, 93%, 47%);
  --color-warning-light: hsl(45, 93%, 95%);

  --color-danger: hsl(0, 84%, 60%);
  --color-danger-light: hsl(0, 84%, 95%);

  --color-info: hsl(199, 89%, 48%);
  --color-info-light: hsl(199, 89%, 95%);

  /* ============================================
     LIGHT MODE TOKENS
     ============================================ */
  --bg-primary: var(--color-gray-50);
  --bg-secondary: #ffffff;
  --bg-tertiary: var(--color-gray-100);
  --bg-elevated: #ffffff;
  --bg-overlay: hsl(210, 10%, 10%, 0.5);

  --text-primary: var(--color-gray-900);
  /* Decoupled from --color-gray-600/500 so darkening body TEXT to WCAG AA
     (>=4.5:1 on white) does NOT also darken borders/dividers/icons that use
     the gray scale directly. gray-600 #7a7878 was ~4.1:1 (borderline) and
     gray-500 #9a9696 ~3:1 (fail) — secondary/tertiary/muted text was the
     root cause of the low-contrast-on-cards complaint. Dark mode overrides
     --text-secondary/tertiary separately (lighter, for dark bg). */
  --text-secondary: #4b5563;    /* slate-700, ~7:1 on white (AAA) */
  --text-tertiary:   #6b7280;   /* ~4.6:1 on white (AA) */
  --muted: var(--text-tertiary);/* canonical muted alias used across components */
  --text-inverse: #ffffff;
  --text-link: var(--color-brand);

  /* Semantic text-strength aliases (Phase 0/1) — same 4-stop ramp as
     text-primary/secondary/tertiary/inverse, named by role instead of order
     so component CSS reads intent. Both names stay live; migrate on touch. */
  --color-text-strong: var(--text-primary);
  --color-text-default: var(--text-secondary);
  --color-text-muted: var(--text-tertiary);
  --color-text-disabled: var(--color-gray-400);

  --border-subtle: var(--color-gray-200);
  --border-default: var(--color-gray-300);
  --border-strong: var(--color-gray-400);

  --shadow-xs: 0 1px 2px rgba(13, 11, 9, 0.04);
  --shadow-sm: 0 1px 3px rgba(13, 11, 9, 0.06), 0 1px 2px rgba(13, 11, 9, 0.04);
  --shadow-md: 0 4px 6px -1px rgba(13, 11, 9, 0.08), 0 2px 4px -2px rgba(13, 11, 9, 0.04);
  --shadow-lg: 0 10px 15px -3px rgba(13, 11, 9, 0.1), 0 4px 6px -4px rgba(13, 11, 9, 0.05);
  --shadow-xl: 0 20px 25px -5px rgba(13, 11, 9, 0.12), 0 8px 10px -6px rgba(13, 11, 9, 0.05);
  --shadow-2xl: 0 25px 50px -12px rgba(13, 11, 9, 0.25);
  --shadow-primary: 0 10px 25px -5px hsl(14, 77%, 51%, 0.3);
  /* Soft / blur shadows — large diffuse radius for floating, ambient depth */
  --shadow-soft: 0 8px 24px -6px rgba(13, 11, 9, 0.10), 0 2px 6px -2px rgba(13, 11, 9, 0.06);
  --shadow-glow: 0 10px 30px -8px hsl(var(--color-brand-h), 77%, 51%, 0.35);
  --shadow-float: 0 18px 40px -12px rgba(13, 11, 9, 0.18);

  /* Semantic 4-level shadow scale (Phase 0/1 refinement). Existing xs/sm/md/lg/
     xl/2xl/soft/float stay defined above as deprecated aliases — components
     migrate to shadow-1..4 on touch, nothing breaks if they don't yet. */
  --shadow-1: var(--shadow-sm);   /* cards at rest */
  --shadow-2: var(--shadow-md);   /* hover / active elevation */
  --shadow-3: var(--shadow-lg);   /* modals, popovers */
  --shadow-4: var(--shadow-float); /* dramatic — drawer overlays, rare */

  /* Card Header Theme Tokens (overridden by card-theme-engine) */
  --card-header-bg: var(--bg-tertiary);
  --card-header-fg: var(--text-primary);
  --card-header-border: var(--border-subtle);
  --card-header-accent-color: transparent;
  --card-header-accent-height: 0px;
  /* Card header layout + effects (height, glass blur, depth highlight) */
  --card-header-py: 0.875rem;   /* 14px — slightly reduced from 20px */
  --card-header-px: var(--spacing-6);    /* 24px — aligned with card__body, was 1.25rem/20px */
  --card-header-blur: 0px;      /* backdrop blur for glass themes */
  --card-header-saturate: 1;    /* backdrop saturation boost for glass */
  --card-header-highlight: inset 0 1px 0 rgba(255, 255, 255, 0.06); /* top depth line */
  /* Card-level shadow (outer; not clipped by overflow:hidden) */
  --card-shadow: var(--shadow-sm);

  /* Focus ring */
  --focus-ring: 0 0 0 3px var(--color-brand-100);
  --focus-ring-dark: 0 0 0 3px hsl(var(--color-brand-h), 50%, 20%);

  /* ============================================
     TYPOGRAPHY SCALE (Reduced by one size for compact UI)
     ============================================ */
  --font-family-sans: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, 'Helvetica Neue', Arial, sans-serif;
  --font-family-heading: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, 'Helvetica Neue', Arial, sans-serif;
  --font-family-display: 'IBM Plex Sans Condensed', 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-family-mono: 'SF Mono', 'Fira Code', 'Consolas', 'Liberation Mono', monospace;

  /* Font sizes - slightly reduced from standard for compact UI */
  --font-size-xs: 0.6875rem;    /* 11px */
  --font-size-sm: 0.8125rem;    /* 13px */
  --font-size-base: 0.9375rem;  /* 15px - new base */
  --font-size-lg: 1.0625rem;    /* 17px */
  --font-size-xl: 1.1875rem;    /* 19px */
  --font-size-2xl: 1.375rem;    /* 22px */
  --font-size-3xl: 1.625rem;    /* 26px */
  --font-size-4xl: 2rem;        /* 32px */
  --font-size-5xl: 2.5rem;      /* 40px */
  --font-size-2xs: 0.625rem;    /* 10px — tabular numerics, dense table cells */

  --font-weight-normal: 400;
  --font-weight-medium: 500;
  --font-weight-semibold: 600;
  --font-weight-bold: 700;

  --line-height-tight: 1.25;
  --line-height-normal: 1.5;
  --line-height-relaxed: 1.75;
  --line-height-dense: 1.4;     /* dense table rows */

  --letter-spacing-tight: -0.025em;
  --letter-spacing-normal: 0;
  --letter-spacing-wide: 0.025em;
  --letter-spacing-wider: 0.05em;

  /* ============================================
     SPACING SCALE (4px base unit)
     ============================================ */
  --spacing-0: 0;
  --spacing-px: 1px;
  --spacing-0-5: 0.125rem;   /* 2px */
  --spacing-half: 0.125rem;  /* 2px — icon-in-button optical alignment, alias of spacing-0-5 */
  --spacing-1: 0.25rem;      /* 4px */
  --spacing-1-5: 0.375rem;   /* 6px */
  --spacing-2: 0.5rem;       /* 8px */
  --spacing-2-5: 0.625rem;   /* 10px */
  --spacing-3: 0.75rem;      /* 12px */
  --spacing-3-5: 0.875rem;   /* 14px */
  --spacing-4: 1rem;         /* 16px */
  --spacing-5: 1.25rem;      /* 20px */
  --spacing-6: 1.5rem;       /* 24px */
  --spacing-7: 1.75rem;      /* 28px */
  --spacing-8: 2rem;         /* 32px */
  --spacing-9: 2.25rem;      /* 36px */
  --spacing-10: 2.5rem;      /* 40px */
  --spacing-12: 3rem;        /* 48px */
  --spacing-16: 4rem;        /* 64px */
  --spacing-20: 5rem;        /* 80px */
  --spacing-24: 6rem;        /* 96px */

  /* ============================================
     BORDER RADIUS
     ============================================ */
  --radius-none: 0;
  --radius-sm: 0.25rem;      /* 4px */
  --radius-md: 0.5rem;       /* 8px */
  --radius-lg: 0.75rem;      /* 12px */
  --radius-xl: 1rem;         /* 16px */
  --radius-2xl: 1.5rem;      /* 24px */
  --radius-full: 9999px;

  /* Semantic radius (Phase 0/1). card/modal alias the existing scale exactly
     (lg=12px, xl=16px) so they already ride the sharp/round personality in
     theme-studio.css. control is a new value (6px, between sm/md) — extended
     into theme-studio.css's data-radius overrides in Step 5 below so it also
     responds to the sharp/round toggle instead of staying fixed. */
  --radius-control: 0.375rem;   /* 6px — buttons, inputs, badges */
  --radius-card: var(--radius-lg);   /* 12px — cards, panels */
  --radius-modal: var(--radius-xl);  /* 16px — modals, drawers */

  /* ============================================
     TRANSITIONS
     ============================================ */
  --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-normal: 250ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 350ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slower: 500ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-bounce: 500ms cubic-bezier(0.34, 1.56, 0.64, 1);

  /* ============================================
     ANIMATION KEYFRAMES
     ============================================ */
  --keyframes-fadeIn: fadeIn 200ms ease-out;
  --keyframes-slideUp: slideUp 250ms ease-out;
  --keyframes-slideDown: slideDown 250ms ease-out;
  --keyframes-scaleIn: scaleIn 200ms cubic-bezier(0.34, 1.56, 0.64, 1);
  --keyframes-spin: spin 0.6s linear infinite;

  /* ============================================
     Z-INDEX SCALE
     ============================================ */
  --z-dropdown: 1000;
  --z-sticky: 1020;
  --z-fixed: 1030;
  --z-modal-backdrop: 1040;
  --z-modal: 1050;
  --z-popover: 1060;
  --z-tooltip: 1070;

  /* ============================================
     LAYOUT
     ============================================ */
  --sidebar-width: 16.5rem;    /* 264px */
  --sidebar-collapsed-width: 4.5rem;
  --header-height: 4rem;       /* 64px */
  --container-max-width: 80rem; /* 1280px */
  --content-max-width: 72rem;   /* 1152px */
}

/* ============================================
   DARK MODE TOKENS
   ============================================ */
.dark {
  --bg-primary: var(--color-gray-950);
  --bg-secondary: var(--color-gray-900);
  --bg-tertiary: var(--color-gray-800);
  --bg-elevated: var(--color-gray-850, hsl(210, 8%, 14%));
  --bg-overlay: hsl(210, 10%, 5%, 0.7);

  --text-primary: var(--color-gray-50);
  /* Secondary/tertiary text bumped for WCAG-AA contrast on dark surfaces.
     Old values (gray-400 #b0b0b0 / gray-500 #9a9696) measured 4.35:1 and
     3.23:1 against the #464646 dark input/card surface — both below the 4.5
     AA threshold, so secondary/tertiary text, helper hints, and ghost-button
     labels read as dim gray-on-gray in dark mode. gray-200 (#e3e3e3) ≈ 7.5:1
     and gray-300 (#d1d1d1) ≈ 6.2:1 on #464646 — both AAA. There is no gray
     token between 400 and 300, so secondary jumps two stops; the 50→200→300
     hierarchy is preserved. */
  --text-secondary: var(--color-gray-200);
  --text-tertiary: var(--color-gray-300);
  --text-inverse: #ffffff;
  --text-link: hsl(var(--color-brand-h), 80%, 60%);

  --color-text-strong: var(--text-primary);
  --color-text-default: var(--text-secondary);
  --color-text-muted: var(--text-tertiary);
  --color-text-disabled: var(--color-gray-600);

  --border-subtle: var(--color-gray-800);
  --border-default: var(--color-gray-700);
  --border-strong: var(--color-gray-600);

  --shadow-xs: 0 1px 2px rgba(13, 11, 9, 0.2);
  --shadow-sm: 0 1px 3px rgba(13, 11, 9, 0.3), 0 1px 2px rgba(13, 11, 9, 0.2);
  --shadow-md: 0 4px 6px -1px rgba(13, 11, 9, 0.4), 0 2px 4px -2px rgba(13, 11, 9, 0.3);
  --shadow-lg: 0 10px 15px -3px rgba(13, 11, 9, 0.5), 0 4px 6px -4px rgba(13, 11, 9, 0.4);
  --shadow-xl: 0 20px 25px -5px rgba(13, 11, 9, 0.6), 0 8px 10px -6px rgba(13, 11, 9, 0.5);
  --shadow-2xl: 0 25px 50px -12px rgba(13, 11, 9, 0.7);
  --shadow-primary: 0 10px 25px -5px hsl(14, 77%, 51%, 0.25);
  /* Soft / blur shadows — stronger in dark mode */
  --shadow-soft: 0 8px 24px -6px rgba(0, 0, 0, 0.45), 0 2px 6px -2px rgba(0, 0, 0, 0.3);
  --shadow-glow: 0 10px 30px -8px hsl(var(--color-brand-h), 77%, 51%, 0.3);
  --shadow-float: 0 18px 40px -12px rgba(0, 0, 0, 0.6);

  --shadow-1: var(--shadow-sm);
  --shadow-2: var(--shadow-md);
  --shadow-3: var(--shadow-lg);
  --shadow-4: var(--shadow-float);

  /* Card Header Theme — dark mode defaults (overridden by user theme) */
  --card-header-bg: var(--color-gray-800);
  --card-header-fg: var(--color-gray-100);
  --card-header-border: var(--color-gray-700);
  --card-header-highlight: inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

/* Theme transition - smooth color changes */
.theme-transitioning,
.theme-transitioning *,
.theme-transitioning *::before,
.theme-transitioning *::after {
  transition: background-color 300ms ease,
              border-color 300ms ease,
              color 300ms ease,
              box-shadow 300ms ease,
              fill 300ms ease,
              stroke 300ms ease !important;
}

/* ============================================================================
   v6 UI-refresh utilities — additive, opt-in classes (approved 2026-07-12).
   Spec: docs/superpowers/specs/2026-07-12-ui-refresh-design.md
   Apply by adding the class to an element; no existing rules are changed.
   ============================================================================ */

/* Frosted-glass surface — translucent white + blur, over a tinted backdrop.
   Use on cards, panels, sticky header, modals, toasts. */
.frosted {
  background: rgba(255, 255, 255, 0.42);
  -webkit-backdrop-filter: saturate(1.5) blur(26px);
  backdrop-filter: saturate(1.5) blur(26px);
  border: 1px solid rgba(255, 255, 255, 0.6);
}
/* Dark variant — sidebar / dark drawers. */
.frosted--dark {
  background: rgba(13, 16, 26, 0.72);
  -webkit-backdrop-filter: saturate(1.3) blur(20px);
  backdrop-filter: saturate(1.3) blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

/* Gentle lift on hover — the approved middle ground (NOT the rejected -8px pop).
   -3px translate + shadow-lg + a soft, restrained brand glow + brand-100 border. */
.lift {
  transition: transform 0.3s cubic-bezier(0.22, 1, 0.36, 1),
              box-shadow 0.3s ease,
              border-color 0.3s ease;
  will-change: transform;
}
.lift:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-lg),
              0 12px 28px -10px hsla(var(--color-brand-h), var(--color-brand-s), var(--color-brand-l), 0.16);
  border-color: var(--color-brand-100);
}

/* Note: monochrome-icon enforcement (FA icons inherit color, brand on active/primary)
   is intentionally NOT global here — it lands in the surface-adoption task so each
   icon is reviewed (avoids shifting existing icon colors). */
