/* Nexus Design System - Base Styles
 * Phase 2: Design System
 * Builds on tokens.css - must be loaded after tokens
 */

/* ============================================
 * CSS RESET / NORMALIZE
 * ============================================ */

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  font-family: var(--font-primary);
  font-size: var(--text-base);
  line-height: var(--leading-normal);
  color: var(--text-primary);
  background-color: var(--bg-primary);
  background-image: var(--network-bg);
  background-attachment: fixed;
  overflow-x: hidden;
}

/* ============================================
 * TYPOGRAPHY
 * ============================================ */

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-display);
  font-weight: var(--font-bold);
  line-height: var(--leading-tight);
  color: var(--text-primary);
  letter-spacing: var(--tracking-tight);
}

h1 {
  font-size: var(--h1-size);
  font-weight: var(--h1-weight);
  letter-spacing: var(--h1-tracking);
}

h2 {
  font-size: var(--h2-size);
  font-weight: var(--h2-weight);
  letter-spacing: var(--h2-tracking);
}

h3 {
  font-size: var(--h3-size);
  font-weight: var(--h3-weight);
  line-height: var(--h3-leading);
}

h4 {
  font-size: var(--h4-size);
  font-weight: var(--h4-weight);
  line-height: var(--h4-leading);
}

h5 {
  font-size: var(--h5-size);
  font-weight: var(--h5-weight);
}

h6 {
  font-size: var(--h6-size);
  font-weight: var(--h6-weight);
}

p {
  margin-bottom: var(--space-4);
  color: var(--text-secondary);
}

a {
  color: var(--color-purple);
  text-decoration: none;
  transition: color var(--transition-fast);
}

a:hover {
  color: var(--color-lavender);
}

/* Text utilities */
.text-primary { color: var(--text-primary); }
.text-secondary { color: var(--text-secondary); }
.text-tertiary { color: var(--text-tertiary); }
.text-purple { color: var(--color-purple); }
.text-gold { color: var(--color-gold); }
.text-green { color: var(--color-green); }
.text-red { color: var(--color-red); }
.text-pink { color: var(--color-pink); }

/* ============================================
 * LAYOUT
 * ============================================ */

.container {
  width: 100%;
  max-width: var(--container-max);
  margin: 0 auto;
  padding: 0 var(--container-padding);
}

.section {
  padding: var(--space-24) 0;
}

.section-header {
  text-align: center;
  margin-bottom: var(--space-16);
}

.section-title {
  margin-bottom: var(--space-4);
}

.section-subtitle {
  font-size: var(--text-xl);
  color: var(--text-secondary);
  max-width: 600px;
  margin: 0 auto;
}

/* ============================================
 * FLEX & GRID UTILITIES
 * ============================================ */

.flex {
  display: flex;
}

.flex-col {
  flex-direction: column;
}

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

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

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

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

.gap-0 { gap: var(--space-0); }
.gap-1 { gap: var(--space-1); }
.gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); }
.gap-4 { gap: var(--space-4); }
.gap-6 { gap: var(--space-6); }
.gap-8 { gap: var(--space-8); }
.gap-12 { gap: var(--space-12); }

.grid {
  display: grid;
}

.grid-cols-1 { grid-template-columns: repeat(1, 1fr); }
.grid-cols-2 { grid-template-columns: repeat(2, 1fr); }
.grid-cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid-cols-4 { grid-template-columns: repeat(4, 1fr); }

/* ============================================
 * SPACING UTILITIES
 * ============================================ */

.m-0 { margin: var(--space-0); }
.m-1 { margin: var(--space-1); }
.m-2 { margin: var(--space-2); }
.m-3 { margin: var(--space-3); }
.m-4 { margin: var(--space-4); }
.m-6 { margin: var(--space-6); }
.m-8 { margin: var(--space-8); }
.m-12 { margin: var(--space-12); }
.m-16 { margin: var(--space-16); }
.m-24 { margin: var(--space-24); }

.mt-0 { margin-top: var(--space-0); }
.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); }
.mt-12 { margin-top: var(--space-12); }
.mt-16 { margin-top: var(--space-16); }
.mt-24 { margin-top: var(--space-24); }

.mb-0 { margin-bottom: var(--space-0); }
.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); }
.mb-12 { margin-bottom: var(--space-12); }
.mb-16 { margin-bottom: var(--space-16); }
.mb-24 { margin-bottom: var(--space-24); }

.p-0 { padding: var(--space-0); }
.p-1 { padding: var(--space-1); }
.p-2 { padding: var(--space-2); }
.p-3 { padding: var(--space-3); }
.p-4 { padding: var(--space-4); }
.p-6 { padding: var(--space-6); }
.p-8 { padding: var(--space-8); }
.p-12 { padding: var(--space-12); }
.p-16 { padding: var(--space-16); }
.p-24 { padding: var(--space-24); }

/* ============================================
 * BORDER & RADIUS UTILITIES
 * ============================================ */

.border-0 { border-width: var(--border-0); }
.border-1 { border-width: var(--border-1); }
.border-2 { border-width: var(--border-2); }

.border-solid { border-style: solid; }
.border-transparent { border-color: transparent; }
.border-primary { border-color: var(--border-primary); }
.border-purple { border-color: var(--color-purple); }

.radius-none { border-radius: var(--radius-none); }
.radius-sm { border-radius: var(--radius-sm); }
.radius-md { border-radius: var(--radius-md); }
.radius-lg { border-radius: var(--radius-lg); }
.radius-xl { border-radius: var(--radius-xl); }
.radius-2xl { border-radius: var(--radius-2xl); }
.radius-full { border-radius: var(--radius-full); }

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

.bg-primary { background-color: var(--bg-primary); }
.bg-secondary { background-color: var(--bg-secondary); }
.bg-tertiary { background-color: var(--bg-tertiary); }
.bg-elevated { background-color: var(--bg-elevated); }
.bg-glass { background-color: var(--bg-glass); }
.bg-purple { background-color: var(--color-purple); }
.bg-gold { background-color: var(--color-gold); }
.bg-green { background-color: var(--color-green); }

/* Gradient backgrounds */
.bg-gradient-primary { background: var(--gradient-primary); }
.bg-gradient-dark { background: var(--gradient-dark); }
.bg-gradient-elevated { background: var(--gradient-elevated); }

/* ============================================
 * SHADOW UTILITIES
 * ============================================ */

.shadow-none { box-shadow: none; }
.shadow-sm { box-shadow: var(--shadow-sm); }
.shadow-md { box-shadow: var(--shadow-md); }
.shadow-lg { box-shadow: var(--shadow-lg); }
.shadow-xl { box-shadow: var(--shadow-xl); }
.shadow-2xl { box-shadow: var(--shadow-2xl); }
.shadow-glow-purple { box-shadow: var(--shadow-glow-purple); }
.shadow-glow-gold { box-shadow: var(--shadow-glow-gold); }
.shadow-glow-green { box-shadow: var(--shadow-glow-green); }
.shadow-inner { box-shadow: var(--shadow-inner); }

/* ============================================
 * TEXT ALIGNMENT & WRAPPING
 * ============================================ */

.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }
.text-justify { text-align: justify; }

.truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.break-words {
  overflow-wrap: break-word;
  word-wrap: break-word;
}

/* ============================================
 * POSITIONING
 * ============================================ */

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

.top-0 { top: 0; }
.right-0 { right: 0; }
.bottom-0 { bottom: 0; }
.left-0 { left: 0; }

.inset-0 { top: 0; right: 0; bottom: 0; left: 0; }

/* ============================================
 * VISIBILITY & OPACITY
 * ============================================ */

.hidden { display: none; }
.invisible { visibility: hidden; }

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

/* ============================================
 * FLEX CHILD UTILITIES
 * ============================================ */

.flex-1 { flex: 1; }
.flex-none { flex: none; }
.flex-grow { flex-grow: 1; }
.flex-shrink-0 { flex-shrink: 0; }

/* ============================================
 * Z-INDEX
 * ============================================ */

.z-dropdown { z-index: var(--z-dropdown); }
.z-sticky { z-index: var(--z-sticky); }
.z-fixed { z-index: var(--z-fixed); }
.z-modal-backdrop { z-index: var(--z-modal-backdrop); }
.z-modal { z-index: var(--z-modal); }
.z-popover { z-index: var(--z-popover); }
.z-tooltip { z-index: var(--z-tooltip); }
.z-max { z-index: var(--z-max); }

/* ============================================
 * TRANSITIONS
 * ============================================ */

.transition-none { transition: none; }
.transition-fast { transition: all var(--transition-fast); }
.transition-normal { transition: all var(--transition-normal); }
.transition-slow { transition: all var(--transition-slow); }
.transition-spring { transition: all var(--transition-spring); }

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

.animate-none { animation: none; }
.animate-fade-in { animation: var(--animation-fade-in); }
.animate-slide-up { animation: var(--animation-slide-up); }
.animate-pulse { animation: var(--animation-pulse); }
.animate-float { animation: var(--animation-float); }
.animate-glow { animation: var(--animation-glow); }

/* ============================================
 * GLASS EFFECT
 * ============================================ */

.glass {
  background: var(--bg-glass);
  backdrop-filter: var(--glass-blur) var(--glass-saturation);
  -webkit-backdrop-filter: var(--glass-blur) var(--glass-saturation);
  border: var(--border-1) solid var(--glass-border);
}

/* ============================================
 * METAL EFFECT
 * ============================================ */

.metal {
  background: var(--metal-gradient);
  position: relative;
}

.metal::after {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--metal-reflect);
  pointer-events: none;
}

/* ============================================
 * FOCUS STATES (Accessibility)
 * ============================================ */

:focus-visible {
  outline: var(--focus-outline);
  outline-offset: var(--focus-outline-offset);
}

/* Custom focus for interactive elements */
.btn:focus-visible,
.link:focus-visible,
.input:focus-visible {
  outline: var(--focus-outline);
  outline-offset: var(--focus-outline-offset);
}

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

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

/* ============================================
 * SELECTION
 * ============================================ */

::selection {
  background-color: var(--color-purple);
  color: var(--text-inverse);
}

/* ============================================
 * SCROLLBAR STYLING
 * ============================================ */

::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--bg-secondary);
}

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

::-webkit-scrollbar-thumb:hover {
  background: var(--color-purple);
}

/* ============================================
 * FORM ELEMENTS BASE
 * ============================================ */

input,
textarea,
select {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
  background-color: var(--bg-elevated);
  border: var(--border-1) solid var(--border-primary);
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-4);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

input:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: var(--color-purple);
  box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.2);
}

input::placeholder,
textarea::placeholder {
  color: var(--text-tertiary);
}

/* ============================================
 * IMAGE RESPONSIVENESS
 * ============================================ */

img,
picture,
video,
canvas,
svg {
  display: block;
  max-width: 100%;
  height: auto;
}

/* ============================================
 * LIST STYLES
 * ============================================ */

ul,
ol {
  list-style: none;
}

/* ============================================
 * TABLE BASE
 * ============================================ */

table {
  border-collapse: collapse;
  border-spacing: 0;
}

th,
td {
  padding: var(--space-3) var(--space-4);
  text-align: left;
  border-bottom: var(--border-1) solid var(--border-primary);
}

/* ============================================
 * QUOTE STYLES
 * ============================================ */

blockquote {
  margin-left: 0;
  padding-left: var(--space-4);
  border-left: var(--border-2) solid var(--color-purple);
  color: var(--text-secondary);
  font-style: italic;
}

/* ============================================
 * CODE STYLES
 * ============================================ */

code,
pre {
  font-family: var(--font-secondary);
  font-size: var(--text-sm);
}

code {
  background-color: var(--bg-elevated);
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-sm);
}

pre {
  background-color: var(--bg-elevated);
  padding: var(--space-4);
  border-radius: var(--radius-md);
  overflow-x: auto;
}

/* ============================================
 * UTILITY: 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;
}

/* ============================================
 * UTILITY: Visually Hidden but Accessible
 * ============================================ */

.visually-hidden:not(:focus):not(:active) {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
