/**
 * Utilities
 * Kingshot Alliance Tools Design System
 *
 * Helper classes for common patterns.
 */

/* ========================================
   SCREEN READER ONLY
   ======================================== */

.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;
  left: -9999px;
  top: 0;
  padding: var(--space-2) var(--space-4);
  border-radius: var(--r8);
  background: #ffffff;
  color: #000000;
  text-decoration: none;
  z-index: var(--z-fixed);
  box-shadow: var(--shadow-md);
}

.skip-link:focus,
.skip-link:focus-visible {
  left: var(--space-4);
  top: var(--space-4);
}

/* ========================================
   FLEXBOX HELPERS
   ======================================== */

/* Row: horizontal flex container */
.row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.row.wrap {
  flex-wrap: wrap;
}

.row.start {
  justify-content: flex-start;
}

.row.center {
  justify-content: center;
}

.row.end {
  justify-content: flex-end;
}

.row.between {
  justify-content: space-between;
}

.row.stretch {
  align-items: stretch;
}

/* Gap modifiers */
.row.gap-1 { gap: var(--space-1); }
.row.gap-2 { gap: var(--space-2); }
.row.gap-4 { gap: var(--space-4); }
.row.gap-6 { gap: var(--space-6); }

/* Stack: vertical flex container */
.stack {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.stack.center {
  align-items: center;
}

.stack.stretch {
  align-items: stretch;
}

/* Gap modifiers */
.stack.gap-1 { gap: var(--space-1); }
.stack.gap-2 { gap: var(--space-2); }
.stack.gap-4 { gap: var(--space-4); }
.stack.gap-6 { gap: var(--space-6); }

/* ========================================
   SPACER
   ======================================== */

/* Flexible spacer that fills available space */
.spacer {
  flex: 1;
}

/* Fixed spacing utilities */
.mt-1 { margin-top: var(--space-1); }
.mt-2 { margin-top: var(--space-2); }
.mt-3 { margin-top: var(--space-3); }
.mt-4 { margin-top: var(--space-4); }
.mt-6 { margin-top: var(--space-6); }
.mt-8 { margin-top: var(--space-8); }

.mb-1 { margin-bottom: var(--space-1); }
.mb-2 { margin-bottom: var(--space-2); }
.mb-3 { margin-bottom: var(--space-3); }
.mb-4 { margin-bottom: var(--space-4); }
.mb-6 { margin-bottom: var(--space-6); }
.mb-8 { margin-bottom: var(--space-8); }

.ml-auto { margin-left: auto; }
.mr-auto { margin-right: auto; }
.mx-auto { margin-left: auto; margin-right: auto; }

.p-0 { padding: 0; }
.p-2 { padding: var(--space-2); }
.p-3 { padding: var(--space-3); }
.p-4 { padding: var(--space-4); }
.p-5 { padding: var(--space-5); }
.p-6 { padding: var(--space-6); }

/* ========================================
   DIVIDER
   ======================================== */

.divider {
  height: 1px;
  background: var(--stroke);
  border: none;
  margin: var(--space-4) 0;
}

.divider.vertical {
  width: 1px;
  height: auto;
  align-self: stretch;
  margin: 0 var(--space-4);
}

.divider.subtle {
  background: linear-gradient(
    90deg,
    transparent,
    var(--stroke),
    transparent
  );
}

/* ========================================
   DISPLAY UTILITIES
   ======================================== */

.hidden { display: none !important; }
.block { display: block; }
.inline { display: inline; }
.inline-block { display: inline-block; }
.flex { display: flex; }
.inline-flex { display: inline-flex; }
.grid { display: grid; }

/* Responsive visibility */
.hide-mobile {
  display: none;
}

@media (min-width: 860px) {
  .hide-mobile {
    display: block;
  }

  .hide-desktop {
    display: none !important;
  }
}

/* ========================================
   SIZING
   ======================================== */

.w-full { width: 100%; }
.h-full { height: 100%; }
.min-h-screen { min-height: 100vh; }

/* ========================================
   OVERFLOW
   ======================================== */

.overflow-hidden { overflow: hidden; }
.overflow-auto { overflow: auto; }
.overflow-x-auto { overflow-x: auto; }
.overflow-y-auto { overflow-y: auto; }

/* ========================================
   POSITION
   ======================================== */

.relative { position: relative; }
.absolute { position: absolute; }
.fixed { position: fixed; }
.sticky { position: sticky; }

/* ========================================
   BORDER UTILITIES
   ======================================== */

.rounded { border-radius: var(--r8); }
.rounded-lg { border-radius: var(--r12); }
.rounded-xl { border-radius: var(--r16); }
.rounded-full { border-radius: var(--r-full); }

.border { border: 1px solid var(--stroke); }
.border-0 { border: none; }

/* ========================================
   BACKGROUND UTILITIES
   ======================================== */

.bg-transparent { background-color: transparent; }
.bg-panel { background-color: var(--panel); }
.bg-surface { background-color: var(--surface); }
.bg-accent { background-color: var(--accent); }

/* ========================================
   OPACITY
   ======================================== */

.opacity-0 { opacity: 0; }
.opacity-50 { opacity: 0.5; }
.opacity-75 { opacity: 0.75; }
.opacity-100 { opacity: 1; }

/* ========================================
   CURSOR
   ======================================== */

.cursor-pointer { cursor: pointer; }
.cursor-not-allowed { cursor: not-allowed; }
.cursor-grab { cursor: grab; }

/* ========================================
   USER SELECT
   ======================================== */

.select-none { user-select: none; }
.select-text { user-select: text; }
.select-all { user-select: all; }

/* ========================================
   POINTER EVENTS
   ======================================== */

.pointer-events-none { pointer-events: none; }
.pointer-events-auto { pointer-events: auto; }

/* ========================================
   FOCUS VISIBLE OUTLINE
   ======================================== */

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

/* ========================================
   TRANSITION UTILITIES
   ======================================== */

.transition {
  transition-property: all;
  transition-duration: var(--duration-normal);
  transition-timing-function: var(--ease-out);
}

.transition-fast {
  transition-duration: var(--duration-fast);
}

.transition-slow {
  transition-duration: var(--duration-slow);
}

/* ========================================
   ANIMATION UTILITIES
   ======================================== */

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

.animate-fade-up {
  animation: fadeUp var(--duration-normal) var(--ease-out);
}

.animate-scale-in {
  animation: scaleIn var(--duration-normal) var(--ease-bounce);
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

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

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

/* ========================================
   LIST UTILITIES
   ======================================== */

/* Unstyled list */
.list-none {
  list-style: none;
  padding: 0;
  margin: 0;
}

/* ========================================
   EMPTY STATE
   ======================================== */

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-8);
  text-align: center;
  color: var(--muted);
}

.empty-state-icon {
  font-size: 3rem;
  margin-bottom: var(--space-4);
  opacity: 0.5;
}

.empty-state-title {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: var(--space-2);
}

.empty-state-text {
  font-size: 0.9375rem;
  max-width: 300px;
}
