/* ==========================================================================
   BASE RESET, ACCESSIBILITY UTILITIES & ATMOSPHERIC LAYERS
   ========================================================================== */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  scroll-padding-top: 88px;
  background-color: var(--bg-deep);
}

body {
  background-color: var(--bg-deep);
  color: var(--text-main);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.65;
  overflow-x: hidden;
  position: relative;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

::selection {
  background: var(--cyber-emerald);
  color: #04120a;
}

/* Accessible 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;
}

/* Skip to Main Content Link */
.skip-link {
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 2000;
  background: var(--cyber-emerald);
  color: #04120a;
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 700;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  text-decoration: none;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.7);
}

/* High-Contrast Keyboard Focus Indicators (WCAG 2.4.7 & 1.4.11) */
:where(a, button, input, textarea, select, summary, [tabindex]):focus-visible {
  outline: 2.5px solid var(--cyber-emerald);
  outline-offset: 3px;
}

section[tabindex="-1"]:focus {
  outline: none;
}

/* ==========================================================================
   3D CANVAS & ATMOSPHERIC EFFECTS
   ========================================================================== */
#webgl-container {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  opacity: 0.9;
  transition: opacity 0.35s ease;
}

#webgl-container.webgl-paused {
  opacity: 0.25;
}

.cyber-grid-overlay {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 2;
  background-image:
    linear-gradient(rgba(0, 255, 136, 0.032) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0, 255, 136, 0.032) 1px, transparent 1px);
  background-size: 40px 40px;
  mask-image: radial-gradient(ellipse at 50% 50%, black 40%, transparent 86%);
  -webkit-mask-image: radial-gradient(ellipse at 50% 50%, black 40%, transparent 86%);
}

.scanlines-overlay {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 3;
  background: repeating-linear-gradient(0deg, transparent 0 2px, rgba(0, 0, 0, 0.16) 2px 4px);
  opacity: 0.38;
}

.vignette-overlay {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 4;
  background: radial-gradient(circle at center, transparent 42%, rgba(3, 6, 10, 0.84) 96%);
}

/* ==========================================================================
   SCROLL PROGRESS INDICATOR (COMPOSITOR-ONLY SCALE-X)
   ========================================================================== */
#scroll-progress {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 3px;
  background: linear-gradient(90deg, var(--cyber-emerald), var(--cyber-cyan));
  box-shadow: 0 0 10px var(--cyber-emerald-glow);
  z-index: 999;
  transform-origin: 0 50%;
  transform: scaleX(0);
  pointer-events: none;
}

@media (prefers-reduced-motion: no-preference) {
  @supports (animation-timeline: scroll()) {
    @keyframes grow-progress {
      from {
        transform: scaleX(0);
      }
      to {
        transform: scaleX(1);
      }
    }

    #scroll-progress {
      animation: grow-progress auto linear;
      animation-timeline: scroll(root);
    }
  }
}

/* ==========================================================================
   LAYOUT CONTAINERS & CONTENT-VISIBILITY CONTAINMENT
   ========================================================================== */
main {
  position: relative;
  z-index: 10;
}

.container {
  max-width: 1280px;
  margin-inline: auto;
  padding-inline: 24px;
}

.section-wrapper {
  padding-block: 96px;
  position: relative;
  content-visibility: auto;
  contain-intrinsic-block-size: auto 46rem;
}

.section-hud-header {
  margin-bottom: 40px;
}

.section-tag {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--cyber-emerald);
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.4px;
  margin-bottom: 12px;
  background: rgba(0, 255, 136, 0.08);
  padding: 5px 12px;
  border-radius: 4px;
  border-left: 3px solid var(--cyber-emerald);
}

.section-tag.purple-tag {
  color: var(--cyber-purple-light);
  border-left-color: var(--cyber-purple);
  background: rgba(168, 85, 247, 0.1);
}

.section-title {
  font-family: var(--font-display);
  font-size: clamp(28px, 4vw, 44px);
  font-weight: 700;
  color: #ffffff;
  letter-spacing: -0.025em;
  line-height: 1.15;
}

.section-title span {
  background: linear-gradient(135deg, #ffffff 25%, var(--cyber-cyan) 85%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: var(--cyber-cyan);
}

.section-desc {
  color: var(--text-dim);
  font-size: 16px;
  max-width: 68ch;
  margin-top: 12px;
  line-height: 1.65;
}

/* ==========================================================================
   FORCED COLORS & REDUCED MOTION ACCESSIBILITY
   ========================================================================== */
@media (forced-colors: active) {
  .surface-card,
  .terminal-hud,
  .btn,
  .filter-btn,
  .form-control {
    border: 1px solid CanvasText;
  }

  .section-title span,
  .hero-title .glow-name {
    -webkit-text-fill-color: CanvasText;
    color: CanvasText;
    background: none;
  }
}

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

  html {
    scroll-behavior: auto;
  }
}
