/**
 * Agenuit Console — Shared Design Tokens
 * 
 * This file defines the canonical spacing, type scale, motion, and signature
 * tokens for the Agenuit console. All dashboard and onboarding components should
 * import these tokens rather than defining their own values.
 * 
 * Usage:
 *   1. Include this file in your HTML: <link rel="stylesheet" href="v4/design-tokens.css" />
 *   2. Reference tokens via CSS custom properties: var(--space-4), var(--motion-panel-duration), etc.
 *   3. For JS/TS consumers, import from design-tokens.ts for programmatic access.
 * 
 * Motion tokens respect `prefers-reduced-motion: reduce` automatically.
 * Non-essential motion is disabled when the user has reduced motion enabled.
 * 
 * ## Signature Visual Identity (Phase B, #702)
 * 
 * The Agenuit signature is "calm authority with sharp moments":
 * - Surfaces: Clean, uncluttered with subtle depth through elevation
 * - Accents: Teal (#5fe3bc / --sig-live) for action states, derived from Situation hero
 * - Typography: Serif for identity/headings, sans for body, mono for data
 * - Motion: Purposeful micro-feedback (≤300ms), never decorative
 * 
 * Signature tokens (--sig-*) provide the core identity that harmonizes
 * shell and non-Situation screens without flattening Situation's hero register.
 * 
 * @see https://github.com/aajibad1/agenuit/issues/650 (AC-4, AC-X2)
 * @see https://github.com/aajibad1/agenuit/issues/702 (Phase B signature)
 */

:root {
  /* =========================================================================
   * SIGNATURE PALETTE (Phase B, #702)
   * Core identity colors extracted from Situation hero language.
   * These provide calm authority in light contexts, sharp accents everywhere.
   * ========================================================================= */
  
  /* Live accent — the signature teal, used for interactive/active states */
  --sig-live: #5fe3bc;
  --sig-live-deep: #2dc89a;
  --sig-live-soft: rgba(95, 227, 188, 0.12);
  --sig-live-ring: rgba(95, 227, 188, 0.25);
  
  /* Accessible ink variant — text-safe teal for links/buttons on light surfaces.
   * Meets WCAG AA ≥4.5:1 on both --sig-ground (#f4f6f9) and --sig-surface (#fff).
   * Use --sig-live-ink for text; keep --sig-live for decorative accents. */
  --sig-live-ink: #0d7a63;
  
  /* Semantic accents — status communication */
  --sig-warn: #efc06a;
  --sig-hot: #f08674;
  --sig-ok: #5fe3bc;
  
  /* Ink scale — text hierarchy with calm authority */
  --sig-ink: #0f1419;
  --sig-ink-1: #3a424d;
  --sig-ink-2: #5b6672;
  --sig-ink-muted: #8e9bab;
  
  /* Surface scale — light mode elevation */
  --sig-ground: #f4f6f9;
  --sig-surface: #ffffff;
  --sig-surface-raised: #f9fafb;
  --sig-border: #e8ecf1;
  --sig-border-subtle: #f0f2f5;
  
  /* Elevation — shadows that convey depth without drama */
  --sig-shadow-sm: 0 1px 3px rgba(15, 20, 25, 0.04), 0 1px 2px rgba(15, 20, 25, 0.03);
  --sig-shadow-md: 0 2px 8px -2px rgba(15, 20, 25, 0.08), 0 4px 16px -4px rgba(15, 20, 25, 0.12);
  --sig-shadow-lg: 0 8px 24px -6px rgba(15, 20, 25, 0.12), 0 16px 48px -12px rgba(15, 20, 25, 0.18);
  /* =========================================================================
   * SPACING SCALE
   * Base unit: 4px. Use these for margins, padding, gaps.
   * ========================================================================= */
  --space-0: 0;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;
  --space-12: 48px;
  --space-16: 64px;
  --space-20: 80px;
  --space-24: 96px;

  /* Semantic spacing aliases */
  --space-xs: var(--space-1);   /* 4px - tight spacing */
  --space-sm: var(--space-2);   /* 8px - small spacing */
  --space-md: var(--space-4);   /* 16px - medium/default spacing */
  --space-lg: var(--space-6);   /* 24px - large spacing */
  --space-xl: var(--space-8);   /* 32px - extra large spacing */
  --space-2xl: var(--space-12); /* 48px - section spacing */

  /* =========================================================================
   * TYPE SCALE
   * Modular scale based on 1.2 ratio (minor third).
   * ========================================================================= */
  --text-xs: 11px;
  --text-sm: 12.5px;
  --text-base: 15px;
  --text-md: 16.5px;
  --text-lg: 18px;
  --text-xl: 22px;
  --text-2xl: 26px;
  --text-3xl: 32px;
  --text-4xl: 42px;

  /* Line heights */
  --leading-tight: 1.1;
  --leading-snug: 1.3;
  --leading-normal: 1.6;
  --leading-relaxed: 1.75;

  /* Font weights */
  --font-normal: 400;
  --font-medium: 500;
  --font-semibold: 600;
  --font-bold: 700;

  /* =========================================================================
   * MOTION TOKENS
   * Durations and easing functions for consistent animations.
   * 
   * Categories:
   * - Micro feedback: ≤300ms (required by AC-4)
   * - Standard: 300-500ms
   * - Narrative: >500ms (used sparingly for intentional storytelling)
   * ========================================================================= */

  /* Durations - Micro feedback (≤300ms, required by AC-4) */
  --motion-instant: 0ms;
  --motion-micro: 100ms;
  --motion-fast: 150ms;
  --motion-feedback: 200ms;
  --motion-snappy: 250ms;
  --motion-quick: 300ms;

  /* Durations - Standard */
  --motion-normal: 350ms;
  --motion-moderate: 400ms;

  /* Durations - Narrative (>500ms, used sparingly) */
  --motion-slow: 500ms;
  --motion-narrative: 600ms;

  /* Easing functions */
  --ease-default: cubic-bezier(0.2, 0.8, 0.2, 1);
  --ease-in: cubic-bezier(0.4, 0, 1, 1);
  --ease-out: cubic-bezier(0, 0, 0.2, 1);
  --ease-in-out: cubic-bezier(0.4, 0, 0.2, 1);
  --ease-bounce: cubic-bezier(0.34, 1.56, 0.64, 1);
  --ease-spring: cubic-bezier(0.175, 0.885, 0.32, 1.275);

  /* =========================================================================
   * SEMANTIC MOTION TOKENS
   * Named tokens for specific UI patterns. These map to the duration scale.
   * All micro-feedback tokens are ≤300ms per AC-4.
   * ========================================================================= */

  /* Panel open/close - standard interaction */
  --motion-panel-duration: var(--motion-quick);      /* 300ms */
  --motion-panel-ease: var(--ease-out);

  /* List enter - items appearing in a list */
  --motion-list-enter-duration: var(--motion-feedback); /* 200ms */
  --motion-list-enter-ease: var(--ease-out);
  --motion-list-stagger: 50ms;                       /* Delay between items */

  /* Toast/feedback - user action confirmation */
  --motion-toast-duration: var(--motion-quick);      /* 300ms */
  --motion-toast-ease: var(--ease-out);

  /* Step transition - wizard/onboarding flow steps */
  --motion-step-duration: var(--motion-quick);       /* 300ms */
  --motion-step-ease: var(--ease-in-out);

  /* Hover/focus states - micro feedback */
  --motion-hover-duration: var(--motion-fast);       /* 150ms */
  --motion-hover-ease: var(--ease-default);

  /* Button press - immediate feedback */
  --motion-press-duration: var(--motion-micro);      /* 100ms */
  --motion-press-ease: var(--ease-out);

  /* Modal/dialog - overlay appearance */
  --motion-modal-duration: var(--motion-feedback);   /* 200ms */
  --motion-modal-ease: var(--ease-out);

  /* Collapse/expand - accordion-style */
  --motion-collapse-duration: var(--motion-snappy);  /* 250ms */
  --motion-collapse-ease: var(--ease-in-out);

  /* Skeleton loading pulse */
  --motion-skeleton-duration: 1500ms;
  --motion-skeleton-ease: ease-in-out;
}

/* ===========================================================================
 * REDUCED MOTION
 * 
 * When the user prefers reduced motion, non-essential animations are disabled
 * via token overrides. Components using these tokens will automatically respect
 * the user's preference.
 * 
 * Note: Skeleton/loading animations are also disabled here. Slice 2 should
 * implement a static loading indicator fallback for reduced-motion users.
 * 
 * Per AC-4: `prefers-reduced-motion` disables non-essential motion.
 * =========================================================================== */
@media (prefers-reduced-motion: reduce) {
  :root {
    /* Collapse all non-essential durations to instant */
    --motion-micro: 0ms;
    --motion-fast: 0ms;
    --motion-feedback: 0ms;
    --motion-snappy: 0ms;
    --motion-quick: 0ms;
    --motion-normal: 0ms;
    --motion-moderate: 0ms;
    --motion-slow: 0ms;
    --motion-narrative: 0ms;

    /* Semantic tokens inherit the collapsed values */
    --motion-panel-duration: 0ms;
    --motion-list-enter-duration: 0ms;
    --motion-list-stagger: 0ms;
    --motion-toast-duration: 0ms;
    --motion-step-duration: 0ms;
    --motion-hover-duration: 0ms;
    --motion-press-duration: 0ms;
    --motion-modal-duration: 0ms;
    --motion-collapse-duration: 0ms;

    /* Skeleton also disabled; slice 2 should add a static loading fallback */
    --motion-skeleton-duration: 0ms;

    /* Flatten easing to linear for any residual motion */
    --ease-default: linear;
    --ease-bounce: linear;
    --ease-spring: linear;
  }
}

/* ===========================================================================
 * UTILITY CLASSES
 * Optional utility classes for common motion patterns.
 * =========================================================================== */

/* Panel animations */
.anim-panel-enter {
  animation: panel-enter var(--motion-panel-duration) var(--motion-panel-ease) forwards;
}

.anim-panel-exit {
  animation: panel-exit var(--motion-panel-duration) var(--motion-panel-ease) forwards;
}

@keyframes panel-enter {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes panel-exit {
  from {
    opacity: 1;
    transform: translateY(0);
  }
  to {
    opacity: 0;
    transform: translateY(8px);
  }
}

/* List item enter animation */
.anim-list-enter {
  animation: list-enter var(--motion-list-enter-duration) var(--motion-list-enter-ease) forwards;
}

@keyframes list-enter {
  from {
    opacity: 0;
    transform: translateX(-8px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* Toast animation */
.anim-toast-enter {
  animation: toast-enter var(--motion-toast-duration) var(--motion-toast-ease) forwards;
}

.anim-toast-exit {
  animation: toast-exit var(--motion-toast-duration) var(--motion-toast-ease) forwards;
}

@keyframes toast-enter {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes toast-exit {
  from {
    opacity: 1;
    transform: translateY(0);
  }
  to {
    opacity: 0;
    transform: translateY(10px);
  }
}

/* Step transition animation */
.anim-step-enter {
  animation: step-enter var(--motion-step-duration) var(--motion-step-ease) forwards;
}

.anim-step-exit {
  animation: step-exit var(--motion-step-duration) var(--motion-step-ease) forwards;
}

@keyframes step-enter {
  from {
    opacity: 0;
    transform: translateX(20px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes step-exit {
  from {
    opacity: 1;
    transform: translateX(0);
  }
  to {
    opacity: 0;
    transform: translateX(-20px);
  }
}

/* Hover/focus transition helper */
.transition-hover {
  transition-property: background-color, border-color, color, box-shadow;
  transition-duration: var(--motion-hover-duration);
  transition-timing-function: var(--motion-hover-ease);
}

/* Press feedback */
.transition-press {
  transition-property: transform, box-shadow;
  transition-duration: var(--motion-press-duration);
  transition-timing-function: var(--motion-press-ease);
}

.transition-press:active {
  transform: scale(0.98);
}
