/**
 * global.css
 * ─────────────────────────────────────────────────────────────
 * PURPOSE: Base resets, typography defaults, layout utilities,
 *          scroll behavior, and reusable component patterns
 *          shared across all sections.
 *
 * LOGIC: Uses modern CSS reset philosophy – preserves useful
 *        browser defaults while removing inconsistencies.
 *        All utility classes are prefixed with .u- to avoid
 *        conflicts with section-specific styles.
 * ─────────────────────────────────────────────────────────────
 */

/* ── MODERN CSS RESET ─────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
  scroll-padding-top: var(--navbar-h);
  -webkit-text-size-adjust: 100%;
  tab-size: 4;
}

body {
  font-family: var(--font-primary);
  font-size: var(--text-base);
  line-height: 1.6;
  color: var(--color-text);
  background-color: var(--color-bg);
  transition: background-color var(--transition-slow), color var(--transition-slow);
  overflow-x: hidden;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

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

input, button, textarea, select {
  font: inherit;
  color: inherit;
}

button { cursor: pointer; border: none; background: none; }
a { text-decoration: none; color: inherit; }
ul, ol { list-style: none; }

/* ── SCROLLBAR STYLING ─────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--color-bg); }
::-webkit-scrollbar-thumb {
  background: var(--color-primary);
  border-radius: var(--radius-full);
}
::-webkit-scrollbar-thumb:hover { background: var(--color-primary-dark); }

/* ── SELECTION ─────────────────────────────────────────────── */
::selection {
  background: rgba(139, 92, 246, 0.3);
  color: var(--color-text);
}

/* ── TYPOGRAPHY ────────────────────────────────────────────── */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-primary);
  font-weight: var(--weight-bold);
  line-height: 1.2;
  letter-spacing: -0.02em;
  color: var(--color-text);
}

h1 { font-size: var(--text-5xl); }
h2 { font-size: var(--text-4xl); }
h3 { font-size: var(--text-2xl); }
h4 { font-size: var(--text-xl); }
h5 { font-size: var(--text-lg); }
h6 { font-size: var(--text-base); }

p {
  color: var(--color-text-muted);
  line-height: 1.75;
}

code, kbd, pre, samp {
  font-family: var(--font-mono);
  font-size: 0.9em;
}

code {
  background: rgba(139, 92, 246, 0.1);
  color: var(--color-secondary);
  padding: 0.1em 0.4em;
  border-radius: var(--radius-sm);
}

/* ── LAYOUT CONTAINERS ─────────────────────────────────────── */
.container {
  width: 100%;
  max-width: var(--container-max);
  margin-inline: auto;
  padding-inline: var(--space-6);
}

.container--wide {
  max-width: var(--container-wide);
}

/* ── SECTION BASE ──────────────────────────────────────────── */
.section {
  padding-block: var(--section-py);
  position: relative;
  overflow: hidden;
}

/* Alternating subtle background */
.section--alt {
  background: var(--color-surface);
}

/* ── SECTION HEADER ────────────────────────────────────────── */
.section-header {
  text-align: center;
  margin-bottom: var(--space-16);
}

.section-header__label {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--color-primary);
  background: rgba(139, 92, 246, 0.1);
  border: 1px solid rgba(139, 92, 246, 0.25);
  padding: var(--space-1) var(--space-4);
  border-radius: var(--radius-full);
  margin-bottom: var(--space-4);
}

.section-header__label::before {
  content: '';
  width: 6px; height: 6px;
  background: var(--color-primary);
  border-radius: 50%;
  animation: pulse-dot 2s infinite;
}

.section-header__title {
  font-size: clamp(var(--text-3xl), 5vw, var(--text-5xl));
  font-weight: var(--weight-black);
  letter-spacing: -0.03em;
  margin-bottom: var(--space-4);
  background: var(--gradient-primary);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.section-header__subtitle {
  font-size: var(--text-lg);
  color: var(--color-text-muted);
  max-width: 560px;
  margin-inline: auto;
  font-family: var(--font-mono);
  line-height: 1.5;
}

/* ── CARD BASE ─────────────────────────────────────────────── */
.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  padding: var(--space-6);
  transition: transform var(--transition-base), box-shadow var(--transition-base), border-color var(--transition-base);
}

.card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-glow);
  border-color: rgba(139, 92, 246, 0.4);
}

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

/* ── BUTTONS ───────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-6);
  border-radius: var(--radius-lg);
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  letter-spacing: 0.01em;
  transition: all var(--transition-base);
  cursor: pointer;
  white-space: nowrap;
  position: relative;
  overflow: hidden;
}

.btn--primary {
  background: var(--gradient-primary);
  color: white;
  box-shadow: 0 4px 15px rgba(139, 92, 246, 0.4);
}

.btn--primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(139, 92, 246, 0.5);
}

.btn--outline {
  background: transparent;
  color: var(--color-primary);
  border: 1.5px solid var(--color-primary);
}

.btn--outline:hover {
  background: rgba(139, 92, 246, 0.08);
  transform: translateY(-2px);
}

.btn--ghost {
  background: rgba(139, 92, 246, 0.08);
  color: var(--color-primary);
  border: 1px solid rgba(139, 92, 246, 0.2);
}

.btn--ghost:hover {
  background: rgba(139, 92, 246, 0.15);
}

.btn--sm {
  padding: var(--space-2) var(--space-4);
  font-size: var(--text-xs);
  border-radius: var(--radius-md);
}

/* Shimmer effect on buttons */
.btn--primary::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.15), transparent);
  transform: translateX(-100%);
  transition: transform 0.5s;
}

.btn--primary:hover::after {
  transform: translateX(100%);
}

/* ── BADGE ─────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  padding: 2px var(--space-2);
  border-radius: var(--radius-sm);
  letter-spacing: 0.05em;
}

.badge--primary { background: rgba(139,92,246,0.15); color: var(--color-primary); }
.badge--success { background: rgba(16,185,129,0.12); color: var(--color-success); }
.badge--warning { background: rgba(245,158,11,0.12); color: var(--color-warning); }
.badge--error   { background: rgba(239,68,68,0.12);  color: var(--color-error);   }

/* ── GRID UTILITIES ────────────────────────────────────────── */
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--space-6); }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--space-6); }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--space-6); }

/* ── MODAL OVERLAY ─────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  z-index: var(--z-modal);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-6);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-base);
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: all;
}

.modal {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-2xl);
  padding: var(--space-8);
  max-width: 720px;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
  transform: scale(0.95) translateY(10px);
  transition: transform var(--transition-spring);
  position: relative;
}

.modal-overlay.active .modal {
  transform: scale(1) translateY(0);
}

.modal__close {
  position: absolute;
  top: var(--space-4);
  right: var(--space-4);
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-full);
  background: rgba(139, 92, 246, 0.1);
  color: var(--color-primary);
  font-size: var(--text-lg);
  transition: all var(--transition-fast);
}

.modal__close:hover {
  background: rgba(139, 92, 246, 0.2);
  transform: rotate(90deg);
}

/* ── PROGRESS BAR ─────────────────────────────────────────── */
.progress-track {
  width: 100%;
  height: 6px;
  background: rgba(139, 92, 246, 0.12);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--gradient-primary);
  border-radius: var(--radius-full);
  width: 0%;
  transition: width 1.2s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
}

.progress-fill::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3), transparent);
  animation: shimmer 2s infinite;
}

/* ── ANIMATIONS ────────────────────────────────────────────── */
@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%       { opacity: 0.5; transform: scale(0.8); }
}

@keyframes shimmer {
  0%   { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

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

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

@keyframes float {
  0%, 100% { transform: translateY(0px); }
  50%       { transform: translateY(-12px); }
}

@keyframes glow-pulse {
  0%, 100% { box-shadow: 0 0 20px rgba(139, 92, 246, 0.3); }
  50%       { box-shadow: 0 0 40px rgba(139, 92, 246, 0.6); }
}

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

@keyframes scanline {
  0%   { transform: translateY(-100%); }
  100% { transform: translateY(100vh); }
}

@keyframes blink {
  0%, 50%, 100% { opacity: 1; }
  25%, 75%      { opacity: 0; }
}

/* ── SCROLL REVEAL BASE ────────────────────────────────────── */
.reveal {
  opacity: 0;
  transform: translateY(30px);
  transition: opacity 0.7s ease, transform 0.7s ease;
}

.reveal.revealed {
  opacity: 1;
  transform: translateY(0);
}

.reveal--left  { transform: translateX(-30px); }
.reveal--right { transform: translateX(30px); }
.reveal--left.revealed, .reveal--right.revealed { transform: translateX(0); }
.reveal--scale { transform: scale(0.95); }
.reveal--scale.revealed { transform: scale(1); }

/* Stagger delays for child elements */
.stagger > *:nth-child(1)  { transition-delay: 0ms; }
.stagger > *:nth-child(2)  { transition-delay: 80ms; }
.stagger > *:nth-child(3)  { transition-delay: 160ms; }
.stagger > *:nth-child(4)  { transition-delay: 240ms; }
.stagger > *:nth-child(5)  { transition-delay: 320ms; }
.stagger > *:nth-child(6)  { transition-delay: 400ms; }
.stagger > *:nth-child(7)  { transition-delay: 480ms; }
.stagger > *:nth-child(8)  { transition-delay: 560ms; }

/* ── MONO LABEL STYLE ──────────────────────────────────────── */
.mono-label {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--color-primary);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-weight: var(--weight-semibold);
}

/* ── DIVIDER ───────────────────────────────────────────────── */
.divider {
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--color-border-solid), transparent);
  margin-block: var(--space-8);
}

/* ── GLOW DECORATION ───────────────────────────────────────── */
.glow-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.4;
  pointer-events: none;
  z-index: 0;
}

.glow-orb--purple {
  background: var(--color-primary);
}

.glow-orb--lavender {
  background: var(--color-accent);
}

/* ── FOCUS VISIBLE ─────────────────────────────────────────── */
*:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 3px;
  border-radius: var(--radius-sm);
}
