/**
 * SekiUI Design Tokens - Index
 * Aggregates all design token files into a single entry point
 *
 * Import this file to get access to all design tokens:
 * @import '../tokens/index.css';
 */

/**
 * SekiUI Design Tokens - Colors
 * Based on shadcn/ui color system
 */

/* =============================================================================
   PRIMITIVE COLOR TOKENS (Layer 1: Raw Values)
   ============================================================================= */

:host {
  /* Neutral Scale (50-950) - shadcn/ui inspired */
  --seki-neutral-50: hsl(0, 0%, 98%);
  --seki-neutral-100: hsl(0, 0%, 96.1%);
  --seki-neutral-200: hsl(0, 0%, 89.8%);
  --seki-neutral-300: hsl(0, 0%, 83.1%);
  --seki-neutral-400: hsl(0, 0%, 63.9%);
  --seki-neutral-500: hsl(0, 0%, 45.1%);
  --seki-neutral-600: hsl(0, 0%, 32.2%);
  --seki-neutral-700: hsl(0, 0%, 25.1%);
  --seki-neutral-800: hsl(0, 0%, 14.9%);
  --seki-neutral-900: hsl(0, 0%, 9%);
  --seki-neutral-950: hsl(0, 0%, 3.9%);

  /* Primary/Accent Scale (50-950) */
  --seki-primary-50: hsl(210, 100%, 97%);
  --seki-primary-100: hsl(210, 95%, 93%);
  --seki-primary-200: hsl(210, 95%, 85%);
  --seki-primary-300: hsl(210, 90%, 73%);
  --seki-primary-400: hsl(210, 85%, 58%);
  --seki-primary-500: hsl(210, 80%, 48%);
  --seki-primary-600: hsl(210, 75%, 40%);
  --seki-primary-700: hsl(210, 70%, 32%);
  --seki-primary-800: hsl(210, 65%, 25%);
  --seki-primary-900: hsl(210, 60%, 18%);
  --seki-primary-950: hsl(210, 55%, 10%);

  /* Semantic Color Primitives */
  --seki-success-500: hsl(142, 71%, 45%);
  --seki-success-600: hsl(142, 71%, 35%);
  --seki-warning-500: hsl(38, 92%, 50%);
  --seki-warning-600: hsl(38, 92%, 40%);
  --seki-destructive-500: hsl(0, 84.2%, 60.2%);
  --seki-destructive-600: hsl(0, 72%, 41%);

  /* Chart Colors (shadcn/ui data visualization) */
  --seki-chart-1: hsl(12, 76%, 61%);
  --seki-chart-2: hsl(173, 58%, 39%);
  --seki-chart-3: hsl(197, 37%, 24%);
  --seki-chart-4: hsl(43, 74%, 66%);
  --seki-chart-5: hsl(27, 87%, 67%);
}

/* =============================================================================
   SEMANTIC TOKENS (Layer 2: shadcn/ui Style)
   ============================================================================= */

/* Dark mode: every themed token below is a light-dark() pair. The branch is
   chosen by the element's inherited `color-scheme`, which crosses shadow
   boundaries, so the document-level switch (`[data-theme='dark']
   { color-scheme: dark }`, injected once by src/global/theme.ts) themes every
   component with no attribute mirroring. These two rules let a data-theme
   attribute placed directly on a host win over the document, including for
   hosts rendered inside another component's shadow tree. */
:host([data-theme='dark']) {
  color-scheme: dark;
}

:host([data-theme='light']) {
  color-scheme: light;
}

:host {
  /* Base */
  --seki-background: light-dark(hsl(0, 0%, 100%), hsl(0, 0%, 3.9%));
  --seki-foreground: light-dark(hsl(0, 0%, 3.9%), hsl(0, 0%, 98%));

  /* Muted */
  --seki-muted: light-dark(hsl(0, 0%, 96.1%), hsl(0, 0%, 14.9%));
  /* 42% (not shadcn's 45.1%) so --seki-muted-foreground on --seki-muted reaches
     4.89:1, clearing WCAG AA's 4.5:1 for normal text. See issue #293. */
  --seki-muted-foreground: light-dark(hsl(0, 0%, 42%), hsl(0, 0%, 63.9%));

  /* Card */
  --seki-card: light-dark(hsl(0, 0%, 100%), hsl(0, 0%, 3.9%));
  --seki-card-foreground: light-dark(hsl(0, 0%, 3.9%), hsl(0, 0%, 98%));

  /* Popover */
  --seki-popover: light-dark(hsl(0, 0%, 100%), hsl(0, 0%, 3.9%));
  --seki-popover-foreground: light-dark(hsl(0, 0%, 3.9%), hsl(0, 0%, 98%));

  /* Border */
  --seki-border: light-dark(hsl(0, 0%, 89.8%), hsl(0, 0%, 14.9%));
  --seki-input: light-dark(hsl(0, 0%, 89.8%), hsl(0, 0%, 14.9%));

  /* Primary */
  --seki-primary: light-dark(hsl(0, 0%, 9%), hsl(0, 0%, 98%));
  --seki-primary-foreground: light-dark(hsl(0, 0%, 98%), hsl(0, 0%, 9%));

  /* Primary tint (soft, low-opacity primary surface — e.g. tinted bubbles) */
  --seki-primary-tint: light-dark(hsl(0, 0%, 9%, 0.06), hsl(0, 0%, 98%, 0.1));
  --seki-primary-tint-foreground: var(--seki-foreground);

  /* Secondary */
  --seki-secondary: light-dark(hsl(0, 0%, 96.1%), hsl(0, 0%, 14.9%));
  --seki-secondary-foreground: light-dark(hsl(0, 0%, 9%), hsl(0, 0%, 98%));

  /* Accent */
  --seki-accent: light-dark(hsl(0, 0%, 96.1%), hsl(0, 0%, 14.9%));
  --seki-accent-foreground: light-dark(hsl(0, 0%, 9%), hsl(0, 0%, 98%));

  /* Destructive */
  --seki-destructive: light-dark(hsl(0, 84.2%, 60.2%), hsl(0, 62.8%, 30.6%));
  --seki-destructive-foreground: hsl(0, 0%, 98%);
  --seki-destructive-bg: light-dark(hsl(0, 86%, 97%), rgba(239, 68, 68, 0.1));
  --seki-destructive-soft-foreground: light-dark(hsl(0, 63%, 31%), hsl(0, 91%, 71%));

  /* Success (semantic status - toast, alert, badge) */
  --seki-success: light-dark(hsl(142, 71%, 45%), hsl(142, 69%, 58%));
  --seki-success-foreground: light-dark(hsl(142, 64%, 24%), hsl(142, 69%, 58%));
  --seki-success-bg: light-dark(hsl(142, 76%, 97%), rgba(34, 197, 94, 0.1));

  /* Warning (semantic status - toast, alert, badge) */
  --seki-warning: light-dark(hsl(38, 92%, 50%), hsl(43, 96%, 56%));
  --seki-warning-foreground: light-dark(hsl(21, 77%, 27%), hsl(43, 96%, 56%));
  --seki-warning-bg: light-dark(hsl(48, 96%, 96%), rgba(245, 158, 11, 0.1));

  /* Info (semantic status - toast, alert, badge) */
  --seki-info: light-dark(hsl(217, 91%, 60%), hsl(217, 92%, 68%));
  --seki-info-foreground: light-dark(hsl(224, 64%, 33%), hsl(217, 92%, 68%));
  --seki-info-bg: light-dark(hsl(214, 100%, 97%), rgba(59, 130, 246, 0.1));

  /* Ring */
  --seki-ring: light-dark(hsl(0, 0%, 3.9%), hsl(0, 0%, 83.1%));
  --seki-ring-shadow: hsl(0, 0%, 3.9%, 0.1);

  /* Legacy aliases for backward compatibility */
  --seki-bg-primary: var(--seki-background);
  --seki-bg-secondary: var(--seki-muted);
  --seki-bg-tertiary: var(--seki-accent);
  --seki-text-primary: var(--seki-foreground);
  --seki-text-secondary: var(--seki-muted-foreground);
  --seki-text-tertiary: light-dark(var(--seki-neutral-400), var(--seki-neutral-600));
  --seki-border-default: var(--seki-border);
  --seki-border-emphasis: light-dark(var(--seki-neutral-300), var(--seki-neutral-700));
}

/* =============================================================================
   COMPONENT TOKENS (Layer 3: Button-Specific - shadcn/ui Style)
   ============================================================================= */

:host {
  /* Button Variant: Primary (default in shadcn/ui) */
  --seki-button-primary-bg: var(--seki-primary);
  --seki-button-primary-text: var(--seki-primary-foreground);
  --seki-button-primary-border: transparent;
  --seki-button-primary-hover-bg: light-dark(hsl(0, 0%, 9%, 0.9), hsl(0, 0%, 98%, 0.9));
  --seki-button-primary-hover-text: var(--seki-primary-foreground);
  --seki-button-primary-hover-border: transparent;

  /* Button Variant: Secondary */
  --seki-button-secondary-bg: var(--seki-secondary);
  --seki-button-secondary-text: var(--seki-secondary-foreground);
  --seki-button-secondary-border: transparent;
  --seki-button-secondary-hover-bg: light-dark(hsl(0, 0%, 96.1%, 0.8), hsl(0, 0%, 14.9%, 0.8));
  --seki-button-secondary-hover-text: var(--seki-secondary-foreground);
  --seki-button-secondary-hover-border: transparent;

  /* Button Variant: Outline */
  --seki-button-outline-bg: transparent;
  --seki-button-outline-text: var(--seki-foreground);
  --seki-button-outline-border: var(--seki-input);
  --seki-button-outline-hover-bg: var(--seki-accent);
  --seki-button-outline-hover-text: var(--seki-accent-foreground);
  --seki-button-outline-hover-border: var(--seki-input);

  /* Button Variant: Ghost */
  --seki-button-ghost-bg: transparent;
  --seki-button-ghost-text: var(--seki-foreground);
  --seki-button-ghost-border: transparent;
  --seki-button-ghost-hover-bg: var(--seki-accent);
  --seki-button-ghost-hover-text: var(--seki-accent-foreground);
  --seki-button-ghost-hover-border: transparent;

  /* Button Variant: Destructive */
  --seki-button-destructive-bg: var(--seki-destructive);
  --seki-button-destructive-text: var(--seki-destructive-foreground);
  --seki-button-destructive-border: transparent;
  --seki-button-destructive-hover-bg: hsl(0, 84.2%, 60.2%, 0.9);
  --seki-button-destructive-hover-border: transparent;

  /* Button Sizing: Small */
  --seki-button-sm-padding-x: var(--seki-spacing-3, 0.75rem);
  --seki-button-sm-padding-y: 0.375rem;
  --seki-button-sm-font-size: var(--seki-text-sm, 0.875rem);
  --seki-button-sm-height: 2.25rem; /* Updated from 2rem to match shadcn (36px) */

  /* Button Sizing: Medium (default) */
  --seki-button-md-padding-x: var(--seki-spacing-4, 1rem);
  --seki-button-md-padding-y: var(--seki-spacing-2, 0.5rem);
  --seki-button-md-font-size: var(--seki-text-base, 1rem);
  --seki-button-md-height: 2.5rem;

  /* Button Sizing: Large */
  --seki-button-lg-padding-x: 2rem; /* Updated from 1.25rem to match shadcn */
  --seki-button-lg-padding-y: 0.5rem;
  --seki-button-lg-font-size: 1rem; /* Updated from 1.125rem to match shadcn */
  --seki-button-lg-height: 2.75rem; /* Updated from 3rem to match shadcn (44px) */

  /* Button Sizing: Icon-only (NEW - shadcn compatibility) */
  --seki-button-icon-sm-size: 2rem; /* 32x32px square */
  --seki-button-icon-size: 2.5rem; /* 40x40px square */
  --seki-button-icon-lg-size: 3rem; /* 48x48px square */
  --seki-button-icon-gap: 0.5rem; /* 8px gap between icon and text */

  /* Button Variant: Link (NEW - shadcn compatibility) */
  --seki-button-link-bg: transparent;
  --seki-button-link-text: var(--seki-primary);
  --seki-button-link-border: transparent;
  --seki-button-link-hover-bg: transparent;
  --seki-button-link-hover-text: var(--seki-primary);
  --seki-button-link-hover-border: transparent;

  /* Button Common */
  --seki-button-radius: var(--seki-radius-md, 0.375rem);
  --seki-button-font-weight: var(--seki-font-medium, 500);
  --seki-button-transition-duration: 150ms;
  --seki-button-transition-timing: ease-in-out;
  --seki-button-shadow: var(--seki-shadow-sm, 0 1px 2px 0 rgb(0 0 0 / 0.05));
  --seki-button-shadow-hover: var(--seki-shadow-md, 0 4px 6px -1px rgb(0 0 0 / 0.1));
  --seki-button-disabled-opacity: 0.5;

  /* Input Component Colors */
  --seki-input-bg: var(--seki-background);
  --seki-input-border: var(--seki-border);
  --seki-input-text: var(--seki-foreground);
  --seki-input-placeholder: var(--seki-muted-foreground);
  --seki-input-ring: var(--seki-ring);
  --seki-input-invalid-border: var(--seki-destructive);
  --seki-input-invalid-ring: var(--seki-destructive);
  --seki-input-disabled-opacity: 0.5;
  --seki-input-radius: var(--seki-radius-md);
  --seki-input-ring-offset: 2px;

  /* Select Component Colors */
  --seki-select-trigger-bg: var(--seki-background);
  --seki-select-trigger-border: 1px solid var(--seki-border);
  --seki-select-trigger-bg-hover: var(--seki-muted);
  --seki-select-trigger-radius: var(--seki-radius-md);
  --seki-select-trigger-min-height: 2.5rem;
  --seki-select-trigger-padding: 0.5rem 0.75rem;
  --seki-select-trigger-gap: 0.5rem;

  /* Select Content/Dropdown */
  --seki-select-content-bg: var(--seki-popover);
  --seki-select-content-border: 1px solid var(--seki-border);
  --seki-select-content-shadow: 0 10px 15px -3px rgb(0 0 0 / 0.1);
  --seki-select-content-radius: var(--seki-radius-md);
  --seki-select-content-padding: 0.5rem 0;

  /* Select Option */
  --seki-select-option-padding: 0.5rem 0.75rem;
  --seki-select-option-gap: 0.5rem;
  --seki-select-option-radius: var(--seki-radius-sm);
  --seki-select-option-bg-hover: var(--seki-muted);
  --seki-select-option-bg-selected: var(--seki-muted);

  /* Select Group */
  --seki-select-group-label-padding: 0.5rem 0.75rem;
  --seki-select-group-label-font-size: var(--seki-font-size-xs);
  --seki-select-group-label-font-weight: var(--seki-font-semibold);
  --seki-select-group-label-color: var(--seki-muted-foreground);
  --seki-select-group-separator: 1px solid var(--seki-border);
}

/**
 * SekiUI Design Tokens - Spacing
 * 4px base unit, rem-based scale
 */

:host {
  /* Spacing Scale (4px base unit) */
  --seki-spacing-0: 0;
  --seki-spacing-0-5: 0.125rem;  /* 2px */
  --seki-spacing-1: 0.25rem;     /* 4px */
  --seki-spacing-1-5: 0.375rem;  /* 6px */
  --seki-spacing-2: 0.5rem;      /* 8px */
  --seki-spacing-2-5: 0.625rem;  /* 10px */
  --seki-spacing-3: 0.75rem;     /* 12px */
  --seki-spacing-3-5: 0.875rem;  /* 14px */
  --seki-spacing-4: 1rem;        /* 16px */
  --seki-spacing-5: 1.25rem;     /* 20px */
  --seki-spacing-6: 1.5rem;      /* 24px */
  --seki-spacing-8: 2rem;        /* 32px */
  --seki-spacing-10: 2.5rem;     /* 40px */
  --seki-spacing-12: 3rem;       /* 48px */
  --seki-spacing-16: 4rem;       /* 64px */
  --seki-spacing-20: 5rem;       /* 80px */
  --seki-spacing-24: 6rem;       /* 96px */

  /* Input Component Tokens */
  --seki-input-height-sm: 2rem;       /* 32px */
  --seki-input-height-md: 2.5rem;     /* 40px - default */
  --seki-input-height-lg: 3rem;       /* 48px */
  --seki-input-padding-x: 0.75rem;    /* 12px */
  --seki-input-padding-y: 0.5rem;     /* 8px */
  --seki-input-font-size: 0.875rem;   /* 14px */
  --seki-input-ring-offset: 2px;
}

/**
 * SekiUI Design Tokens - Shadows
 * Subtle elevation system
 */

:host {
  /* Shadow Levels */
  --seki-shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --seki-shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --seki-shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.15), 0 4px 6px -4px rgb(0 0 0 / 0.1);
  --seki-shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
}

/*
 * Component-specific elevations. Values are the shadows the components shipped
 * with before they were tokenised, so rendering is unchanged. Components must
 * reference these (with a fallback) instead of writing rgb(0 0 0 / x) literals;
 * tests/integration/dark-mode-compliance.spec.ts enforces that.
 */
:host {
  /* Tabs active trigger (Tailwind "shadow") */
  --seki-shadow-xs-plus: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
  /* Card resting / hover, slider thumb */
  --seki-shadow-card: 0 1px 3px 0 rgb(0 0 0 / 0.1);
  --seki-shadow-card-hover: 0 4px 6px 0 rgb(0 0 0 / 0.1);
  --seki-shadow-thumb-hover: 0 2px 6px 0 rgb(0 0 0 / 0.15);
  /* Floating surfaces: toast, carousel buttons */
  --seki-shadow-floating: 0 4px 12px 0 rgb(0 0 0 / 0.15);
  --seki-shadow-floating-sm: 0 2px 8px 0 rgb(0 0 0 / 0.1);
  /* Modal surfaces: dialog, alert-dialog, sheet; drawer rises from the bottom */
  --seki-shadow-overlay: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
  --seki-shadow-overlay-top: 0 -10px 15px -3px rgb(0 0 0 / 0.1), 0 -4px 6px -4px rgb(0 0 0 / 0.1);
  /* Argument of filter: drop-shadow() (navigation-menu viewport arrow) */
  --seki-drop-shadow-up: 0 -2px 2px rgb(0 0 0 / 0.05);

  /* Scrims behind modal surfaces */
  --seki-overlay: light-dark(rgb(0 0 0 / 0.5), rgb(0 0 0 / 0.7));
  --seki-overlay-strong: rgb(0 0 0 / 0.8);
}

/**
 * SekiUI Design Tokens - Typography
 * System font stacks, sizes, weights, line heights
 */

:host {
  /* Font Families */
  --seki-font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue',
    Arial, sans-serif;
  --seki-font-mono: ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, monospace;

  /* Font Sizes (rem-based) */
  --seki-text-xs: 0.75rem;    /* 12px */
  --seki-text-sm: 0.875rem;   /* 14px */
  --seki-text-base: 1rem;     /* 16px */
  --seki-text-lg: 1.125rem;   /* 18px */
  --seki-text-xl: 1.25rem;    /* 20px */
  --seki-text-2xl: 1.5rem;    /* 24px */
  --seki-text-3xl: 1.875rem;  /* 30px */
  --seki-text-4xl: 2.25rem;   /* 36px */

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

  /* Line Heights */
  --seki-leading-none: 1;
  --seki-leading-tight: 1.25;
  --seki-leading-normal: 1.5;
  --seki-leading-relaxed: 1.75;
}

/**
 * SekiUI Design Tokens - Border Radius
 * Four-level radius system
 */

:host {
  /* Border Radius Levels */
  --seki-radius-sm: 0.25rem;   /* 4px */
  --seki-radius-md: 0.375rem;  /* 6px */
  --seki-radius-lg: 0.5rem;    /* 8px */
  --seki-radius-xl: 1rem;      /* 16px */
  --seki-radius-full: 9999px;  /* pills, dots, circular thumbs */
}

/**
 * SekiUI Design Tokens - Sidebar
 * Based on shadcn/ui sidebar component
 */

/* =============================================================================
   SIDEBAR TOKENS (Layer 3: Component-Specific)
   ============================================================================= */

:host {
  /* Sidebar Sizing */
  --seki-sidebar-width: 16rem;
  --seki-sidebar-width-icon: 3rem;
  --seki-sidebar-width-mobile: 18rem;

  /* Sidebar Colors - Light Mode (shadcn/ui exact values) */
  --seki-sidebar-background: light-dark(hsl(0, 0%, 98%), hsl(240, 5.9%, 10%));
  --seki-sidebar-foreground: light-dark(hsl(240, 5.3%, 26.1%), hsl(240, 4.8%, 95.9%));
  --seki-sidebar-primary: light-dark(hsl(240, 5.9%, 10%), hsl(0, 0%, 98%));
  --seki-sidebar-primary-foreground: light-dark(hsl(0, 0%, 98%), hsl(240, 5.9%, 10%));
  --seki-sidebar-accent: light-dark(hsl(240, 4.8%, 95.9%), hsl(240, 3.7%, 15.9%));
  --seki-sidebar-accent-foreground: light-dark(hsl(240, 5.9%, 10%), hsl(240, 4.8%, 95.9%));
  --seki-sidebar-border: light-dark(hsl(220, 13%, 91%), hsl(240, 3.7%, 15.9%));
  --seki-sidebar-ring: hsl(217.2, 91.2%, 59.8%);
  --seki-sidebar-muted-foreground: light-dark(hsl(240, 3.8%, 46.1%), hsl(240, 5%, 64.9%));

  /* Menu Button Sizing */
  --seki-sidebar-menu-button-height: 2rem;
  --seki-sidebar-menu-button-height-lg: 3rem;
  --seki-sidebar-menu-button-padding: 0.5rem;
  --seki-sidebar-menu-button-gap: 0.5rem;
  --seki-sidebar-menu-button-radius: var(--seki-radius-md, 0.375rem);

  /* Menu Sub */
  --seki-sidebar-menu-sub-padding-left: 1.75rem;
  --seki-sidebar-menu-sub-border-width: 1px;

  /* Group */
  --seki-sidebar-group-padding: 0.5rem;
  --seki-sidebar-group-label-height: 2rem;
  --seki-sidebar-group-label-padding: 0.5rem;

  /* Header/Footer */
  --seki-sidebar-header-height: auto;
  --seki-sidebar-footer-height: auto;
  --seki-sidebar-header-padding: 0.5rem;
  --seki-sidebar-footer-padding: 0.5rem;

  /* Content */
  --seki-sidebar-content-padding: 0.5rem;

  /* Rail */
  --seki-sidebar-rail-width: 1rem;

  /* Transitions */
  --seki-sidebar-transition-duration: 200ms;
  --seki-sidebar-transition-timing: ease-in-out;

  /* Mobile */
  --seki-sidebar-mobile-breakpoint: 768px;
  --seki-sidebar-overlay-bg: hsla(0, 0%, 0%, 0.8);
}

/**
 * SekiUI Design Tokens - Animations
 * Based on Radix UI animation patterns for shadcn/ui compatibility
 */

:host {
  /* Animation Durations */
  --seki-animation-fast: 150ms;
  --seki-animation-normal: 200ms;
  --seki-animation-slow: 300ms;

  /* Easing Functions (Radix UI defaults) */
  --seki-ease-in: cubic-bezier(0.4, 0, 1, 1);
  --seki-ease-out: cubic-bezier(0, 0, 0.2, 1);
  --seki-ease-in-out: cubic-bezier(0.4, 0, 0.2, 1);

  /* Content Height Variable (for accordion-like animations) */
  --seki-accordion-content-height: auto;
}

/* =============================================================================
   FADE ANIMATIONS
   ============================================================================= */

@keyframes seki-fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes seki-fade-out {
  from { opacity: 1; }
  to { opacity: 0; }
}

/* =============================================================================
   SCALE ANIMATIONS (Dialogs, Popovers, Dropdowns)
   ============================================================================= */

@keyframes seki-scale-in {
  from {
    opacity: 0;
    transform: scale(0.95);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes seki-scale-out {
  from {
    opacity: 1;
    transform: scale(1);
  }
  to {
    opacity: 0;
    transform: scale(0.95);
  }
}

/* =============================================================================
   SLIDE ANIMATIONS (Sheets, Sidebars, Drawers)
   ============================================================================= */

@keyframes seki-slide-in-from-top {
  from { transform: translateY(-100%); }
  to { transform: translateY(0); }
}

@keyframes seki-slide-out-to-top {
  from { transform: translateY(0); }
  to { transform: translateY(-100%); }
}

@keyframes seki-slide-in-from-bottom {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

@keyframes seki-slide-out-to-bottom {
  from { transform: translateY(0); }
  to { transform: translateY(100%); }
}

@keyframes seki-slide-in-from-left {
  from { transform: translateX(-100%); }
  to { transform: translateX(0); }
}

@keyframes seki-slide-out-to-left {
  from { transform: translateX(0); }
  to { transform: translateX(-100%); }
}

@keyframes seki-slide-in-from-right {
  from { transform: translateX(100%); }
  to { transform: translateX(0); }
}

@keyframes seki-slide-out-to-right {
  from { transform: translateX(0); }
  to { transform: translateX(100%); }
}

/* =============================================================================
   ACCORDION ANIMATIONS
   ============================================================================= */

@keyframes seki-accordion-down {
  from {
    height: 0;
    opacity: 0;
  }
  to {
    height: var(--seki-accordion-content-height);
    opacity: 1;
  }
}

@keyframes seki-accordion-up {
  from {
    height: var(--seki-accordion-content-height);
    opacity: 1;
  }
  to {
    height: 0;
    opacity: 0;
  }
}

/* =============================================================================
   ZOOM ANIMATIONS (Tooltips, Menus)
   ============================================================================= */

@keyframes seki-zoom-in {
  from {
    opacity: 0;
    transform: scale(0.96);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes seki-zoom-out {
  from {
    opacity: 1;
    transform: scale(1);
  }
  to {
    opacity: 0;
    transform: scale(0.96);
  }
}

/* =============================================================================
   SPIN ANIMATION (Loading indicators)
   ============================================================================= */

@keyframes seki-spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* =============================================================================
   PULSE ANIMATION (Skeleton loaders)
   ============================================================================= */

@keyframes seki-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* =============================================================================
   BOUNCE ANIMATION (Attention-grabbing)
   ============================================================================= */

@keyframes seki-bounce {
  0%, 100% {
    transform: translateY(-25%);
    animation-timing-function: cubic-bezier(0.8, 0, 1, 1);
  }
  50% {
    transform: translateY(0);
    animation-timing-function: cubic-bezier(0, 0, 0.2, 1);
  }
}

/* =============================================================================
   COLLAPSIBLE ANIMATIONS
   ============================================================================= */

@keyframes seki-collapsible-open {
  from {
    height: 0;
    overflow: hidden;
  }
  to {
    height: var(--seki-collapsible-content-height, auto);
  }
}

@keyframes seki-collapsible-close {
  from {
    height: var(--seki-collapsible-content-height, auto);
  }
  to {
    height: 0;
    overflow: hidden;
  }
}

/* =============================================================================
   TOAST/NOTIFICATION ANIMATIONS
   ============================================================================= */

@keyframes seki-toast-slide-in-right {
  from {
    transform: translateX(calc(100% + 1rem));
  }
  to {
    transform: translateX(0);
  }
}

@keyframes seki-toast-slide-out-right {
  from {
    transform: translateX(0);
  }
  to {
    transform: translateX(calc(100% + 1rem));
  }
}

@keyframes seki-toast-swipe-out {
  from {
    transform: translateX(var(--seki-toast-swipe-end-x, 0));
  }
  to {
    transform: translateX(calc(100% + 1rem));
  }
}

/* =============================================================================
   UTILITY ANIMATION CLASSES
   ============================================================================= */

.seki-animate-fade-in {
  animation: seki-fade-in var(--seki-animation-normal) var(--seki-ease-out);
}

.seki-animate-fade-out {
  animation: seki-fade-out var(--seki-animation-normal) var(--seki-ease-in);
}

.seki-animate-scale-in {
  animation: seki-scale-in var(--seki-animation-normal) var(--seki-ease-out);
}

.seki-animate-scale-out {
  animation: seki-scale-out var(--seki-animation-normal) var(--seki-ease-in);
}

.seki-animate-spin {
  animation: seki-spin 1s linear infinite;
}

.seki-animate-pulse {
  animation: seki-pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

.seki-animate-bounce {
  animation: seki-bounce 1s infinite;
}

/* =============================================================================
   REDUCED MOTION SUPPORT
   ============================================================================= */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}


/* Document-level theme switch. Components read it through the inherited
   `color-scheme` property (see colors.css). src/global/theme.ts injects the
   same rule at runtime, so this copy only matters for consumers who load the
   global stylesheet without JavaScript. Keep both in sync. */
[data-theme='dark'] {
  color-scheme: dark;
}

[data-theme='light'] {
  color-scheme: light;
}

:host {
  /* Ensure minimum touch target (WCAG 2.1 Level AAA) */
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  min-height: 44px;

  /* Component override hooks. Referenced throughout this file but never
     declared, so they always fell through to their nested fallback. Declared
     here they resolve to semantic tokens that already carry dark values. */
  --seki-switch-bg-unchecked: var(--seki-muted, hsl(240 4.8% 95.9%));
  --seki-switch-bg-checked: var(--seki-primary, hsl(240 5.9% 10%));
  --seki-switch-focus-ring: var(--seki-ring, hsl(240 5% 64.9%));
  --seki-switch-thumb-bg: var(--seki-background, hsl(0 0% 100%));
}

.switch {
  /* Dimensions with CSS custom properties */
  width: var(--seki-switch-width, 2.75rem);
  height: var(--seki-switch-height, 1.5rem);

  /* Layout */
  position: relative;
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;

  /* Background colors */
  background-color: var(--seki-switch-bg-unchecked);

  /* Border radius */
  border-radius: 9999px;

  /* Cursor */
  cursor: pointer;

  /* Transition */
  transition: background-color var(--seki-switch-transition-duration, 150ms) ease-out;

  /* Outline for focus */
  outline: none;
}

.switch:focus-visible {
  outline: 2px solid var(--seki-switch-focus-ring);
  outline-offset: 2px;
}

/* Checked state */
:host([data-state="checked"]) .switch {
  background-color: var(--seki-switch-bg-checked);
}

/* Disabled state */
:host([data-disabled]) .switch {
  background-color: var(--seki-switch-bg-disabled, var(--seki-muted, hsl(240 4.8% 95.9%)));
  cursor: not-allowed;
  opacity: 0.5;
}

/* Thumb element */
.thumb {
  /* Dimensions */
  width: var(--seki-switch-thumb-size, 1.25rem);
  height: var(--seki-switch-thumb-size, 1.25rem);

  /* Background */
  background-color: var(--seki-switch-thumb-bg);
  
  /* Position */
  position: absolute;
  left: 0.125rem;
  
  /* Shape */
  border-radius: 50%;
  
  /* Shadow for depth */
  box-shadow: var(--seki-shadow-sm, 0 1px 2px 0 rgb(0 0 0 / 0.05));
  
  /* Transition */
  transition: transform var(--seki-switch-transition-duration, 150ms) ease-out;
  
  /* Pointer events */
  pointer-events: none;
}

/* Thumb position when checked */
:host([data-state="checked"]) .thumb {
  transform: translateX(calc(var(--seki-switch-width, 2.75rem) - var(--seki-switch-thumb-size, 1.25rem) - 0.25rem));
}

/* The checked thumb sits on --seki-primary, so it needs the paired foreground
   rather than the page background. Not redundant with the :host hook above. */
:host([data-state="checked"]) .thumb {
  --seki-switch-thumb-bg: var(--seki-primary-foreground, hsl(0 0% 98%));
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
  .switch,
  .thumb {
    transition: none;
  }
}
