/**
 * BUA Design System - Runtime Theme Handler (Canonical)
 * DV8 Technology Group - Sovereign Series
 *
 * Canonical source aligned from DV8-SS-BUA-SPEAK
 * Handles theme switching and runtime behavior
 * WHITE THEME is DEFAULT
 */

/* ===========================================
   BASE STYLES
   =========================================== */
* {
  box-sizing: border-box;
}

html {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

body {
  margin: 0;
  padding: 0;
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: 1.5;
  color: var(--text);
  background-color: var(--page-bg);
  transition: background-color var(--transition-base), color var(--transition-base);
}

/* ===========================================
   THEME TRANSITION HANDLING
   =========================================== */
body.theme-transitioning,
body.theme-transitioning *,
body.theme-transitioning *::before,
body.theme-transitioning *::after {
  transition: none !important;
}

/* ===========================================
   FOCUS VISIBLE STYLES
   =========================================== */
:focus-visible {
  outline: 3px solid var(--focus-ring);
  outline-offset: 2px;
}

:focus:not(:focus-visible) {
  outline: none;
}

/* ===========================================
   SELECTION STYLES
   =========================================== */
::selection {
  background-color: var(--dv8-red);
  color: var(--text-inverse);
}

::-moz-selection {
  background-color: var(--dv8-red);
  color: var(--text-inverse);
}

/* ===========================================
   SCROLLBAR STYLES (Webkit)
   =========================================== */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--surface-bg);
}

::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: var(--radius-md);
  border: 2px solid var(--surface-bg);
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-tertiary);
}

/* ===========================================
   UTILITY CLASSES
   =========================================== */
.surface {
  background-color: var(--surface-bg);
}

.surface-elevated {
  background-color: var(--surface-elevated);
}

.glass {
  background: var(--glass-bg);
  backdrop-filter: var(--glass-backdrop);
  -webkit-backdrop-filter: var(--glass-backdrop);
  border: 1px solid var(--glass-border);
  box-shadow: var(--glass-shadow);
}

.text-primary { color: var(--text); }
.text-secondary { color: var(--text-secondary); }
.text-tertiary { color: var(--text-tertiary); }
.text-brand { color: var(--dv8-red); }
.text-success { color: var(--success); }
.text-warning { color: var(--warning); }
.text-danger { color: var(--danger); }
.text-info { color: var(--info); }

/* ===========================================
   ANIMATION UTILITIES
   =========================================== */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes slideIn {
  from { transform: translateY(-10px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.fade-in { animation: fadeIn var(--transition-base); }
.slide-in { animation: slideIn var(--transition-base); }

/* ===========================================
   ACCESSIBILITY
   =========================================== */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  top: -40px;
  left: 0;
  background: var(--dv8-red);
  color: var(--text-inverse);
  padding: var(--space-2) var(--space-4);
  text-decoration: none;
  z-index: var(--z-tooltip);
}

.skip-link:focus { top: 0; }

/* ===========================================
   THEME TOGGLE STYLES
   =========================================== */
.theme-toggle {
  position: relative;
  width: 48px;
  height: 24px;
  background: var(--border-strong);
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: background-color var(--transition-base);
  border: none;
  padding: 0;
}

.theme-toggle:hover { background: var(--text-tertiary); }

.theme-toggle::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  background: var(--text-inverse);
  border-radius: var(--radius-full);
  transition: transform var(--transition-base);
}

[data-theme="dark"] .theme-toggle::after {
  transform: translateX(24px);
}

/* ===========================================
   PRINT STYLES
   =========================================== */
@media print {
  body {
    background: white;
    color: black;
  }

  .no-print {
    display: none !important;
  }
}

h1,
h2,
h3 {
  font-family: var(--font-display);
}
