/* ==========================================================================
   OpenMode Design System — Semantic Tokens & Base Primitives
   Direction: Dark Premium + Subtle Cyber Aesthetic
   ========================================================================== */

:root {
  color-scheme: dark;

  /* Core Surfaces */
  --om-bg: #070C11;
  --om-sidebar: #090F15;
  --om-surface-1: #0D171F;
  --om-surface-2: #14232D;
  --om-surface-3: #1A2C37;

  /* Borders */
  --om-border: #20313B;
  --om-border-strong: #314651;

  /* Brand & Accents */
  --om-accent: #00DCC2;
  --om-accent-hover: #20E8D0;
  --om-accent-pressed: #00BFA9;
  --om-accent-soft: rgba(0, 220, 194, 0.12);
  --om-accent-ink: #041316;
  --om-blue: #36BDF8;
  --om-blue-soft: rgba(54, 189, 248, 0.12);

  /* Typography Colors */
  --om-text: #F1F5F9;
  --om-text-secondary: #B1C0CA;
  --om-text-muted: #81939F;

  /* Semantic Status Colors */
  --om-success: #32D583;
  --om-success-soft: rgba(50, 213, 131, 0.12);
  --om-warning: #FBBF24;
  --om-warning-soft: rgba(251, 191, 36, 0.12);
  --om-danger: #F97066;
  --om-danger-soft: rgba(249, 112, 102, 0.12);
  --om-info: #36BDF8;
  --om-info-soft: rgba(54, 189, 248, 0.12);

  /* Font Families */
  --om-font-sans: "Inter", "IBM Plex Sans Arabic", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --om-font-arabic: "IBM Plex Sans Arabic", "Inter", system-ui, -apple-system, sans-serif;
  --om-font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;

  /* Spacing Scale (4px base) */
  --om-space-1: 4px;
  --om-space-2: 8px;
  --om-space-3: 12px;
  --om-space-4: 16px;
  --om-space-5: 20px;
  --om-space-6: 24px;
  --om-space-8: 32px;
  --om-space-10: 40px;
  --om-space-12: 48px;
  --om-space-16: 64px;

  /* Radius Scale */
  --om-radius-sm: 6px;
  --om-radius-md: 8px;
  --om-radius-lg: 12px;
  --om-radius-xl: 16px;
  --om-radius-2xl: 20px;
  --om-radius-full: 999px;

  /* Shadows & Focus */
  --om-shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.35);
  --om-shadow-md: 0 8px 24px rgba(0, 0, 0, 0.42);
  --om-shadow-lg: 0 18px 48px rgba(0, 0, 0, 0.56);
  --om-glow-accent: 0 0 0 1px rgba(0, 220, 194, 0.28), 0 8px 28px rgba(0, 220, 194, 0.08);
  --om-focus-ring: 2px solid var(--om-accent);

  /* Layout Dimensions */
  --om-sidebar-w: 264px;
  --om-sidebar-collapsed-w: 72px;
  --om-topbar-h: 64px;

  /* Motion */
  --om-ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --om-ease-in: cubic-bezier(0.7, 0, 0.84, 0);
  --om-dur-fast: 150ms;
  --om-dur-base: 200ms;
  --om-dur-overlay: 220ms;
}

/* Arabic RTL font priority */
:root[dir="rtl"],
[lang="ar"] {
  --om-font-sans: var(--om-font-arabic);
}

/* Base Reset & Accessibility Utilities */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background-color: var(--om-bg);
  color: var(--om-text);
  font-family: var(--om-font-sans);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: clip;
}

/* Tabular numerals for metrics, credits, prices, dates */
.om-tabular,
.tabular-nums {
  font-variant-numeric: tabular-nums;
}

/* Visible Focus Indicators */
:where(a, button, input, select, textarea, summary, [tabindex]):focus-visible {
  outline: var(--om-focus-ring);
  outline-offset: 2px;
}

/* Skip link */
.om-skip-link {
  position: fixed;
  inset-block-start: -120px;
  inset-inline-start: var(--om-space-4);
  z-index: 10000;
  background: var(--om-accent);
  color: var(--om-accent-ink);
  font-weight: 600;
  padding: var(--om-space-2) var(--om-space-4);
  border-radius: var(--om-radius-md);
  text-decoration: none;
  transition: inset-block-start var(--om-dur-fast) var(--om-ease-out);
}

.om-skip-link:focus {
  inset-block-start: var(--om-space-4);
}

/* Canonical Visually Hidden Utility */
.visually-hidden:where(:not(:focus-within, :active)) {
  position: absolute !important;
  clip-path: inset(50%) !important;
  overflow: hidden !important;
  width: 1px !important;
  height: 1px !important;
  margin: -1px !important;
  padding: 0 !important;
  border: 0 !important;
  white-space: nowrap !important;
}

/* Lucide Icon Base */
.om-icon {
  display: inline-block;
  flex-shrink: 0;
  vertical-align: middle;
  color: currentColor;
}

.om-icon-spin {
  animation: om-spin 0.9s linear infinite;
}

@keyframes om-spin {
  to {
    transform: rotate(360deg);
  }
}

/* Native Modal Dialog Scroll Containment */
dialog:modal {
  overscroll-behavior: contain;
}

dialog::backdrop {
  overflow: hidden;
  overscroll-behavior: contain;
  background-color: rgba(4, 8, 12, 0.72);
  backdrop-filter: blur(4px);
}

/* Scrollbar styling */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--om-border);
  border-radius: var(--om-radius-full);
}

::-webkit-scrollbar-thumb:hover {
  background: var(--om-border-strong);
}

/* Respect Reduced Motion */
@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
