/* Core styles — base reset, typography, utilities, and global patterns */
@import url("variables.css");

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

/* Smooth scroll (respects reduced-motion below) */
html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

/* Base styles */
body {
  font-family: var(--font-family);
  color: var(--light-color);
  background-color: var(--darker-bg);
  line-height: 1.6;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Skip-to-content link for keyboard navigation */
.skip-to-content {
  position: absolute;
  top: -100%;
  left: 50%;
  transform: translateX(-50%);
  padding: 0.75em 1.5em;
  background-color: var(--primary-color);
  color: #fff;
  font-weight: 600;
  border-radius: 0 0 8px 8px;
  z-index: calc(var(--z-modal) + 100);
  transition: top var(--transition-fast);
  text-decoration: none;
}

.skip-to-content:focus {
  top: 0;
  outline: none;
}

/* Links */
a {
  color: var(--primary-color);
  text-decoration: none;
  transition: color var(--transition-base);
}

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

/* Container */
.container {
  width: 90%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1rem;
}

/* ========================================
   Typography
   ======================================== */

h1, h2, h3, h4, h5, h6 {
  margin-bottom: 0.5em;
  line-height: 1.15;
  text-wrap: balance;
}

h1 {
  font-size: clamp(2.25rem, 5vw, 3.75rem);
  font-weight: 800;
  letter-spacing: -0.03em;
}

h2 {
  font-size: clamp(1.5rem, 4vw, 2.5rem);
  font-weight: 700;
  letter-spacing: -0.02em;
}

h3 {
  font-size: clamp(1.125rem, 3vw, 1.5rem);
  font-weight: 600;
  letter-spacing: -0.01em;
}

h4 {
  font-size: 1.125rem;
  font-weight: 600;
}

p {
  margin-bottom: 1em;
  max-width: 65ch;
  text-wrap: pretty;
}

/* Centered sections should center their paragraph max-width */
.text-center p {
  margin-left: auto;
  margin-right: auto;
}

/* Lists inside content */
ul, ol {
  padding-left: 1.5em;
  margin-bottom: 1em;
}

li {
  margin-bottom: 0.35em;
}

/* Placeholder text */
::placeholder {
  color: var(--muted-color);
  opacity: 0.6;
}

/* ========================================
   Buttons
   ======================================== */

.btn {
  display: inline-block;
  padding: 0.85em 1.75em;
  text-decoration: none;
  border-radius: 8px;
  font-weight: 600;
  font-size: 1rem;
  cursor: pointer;
  border: none;
  transition:
    background-color var(--transition-base),
    transform var(--transition-fast),
    box-shadow var(--transition-base);
}

.btn:active {
  transform: translateY(1px) scale(0.98);
}

.btn-primary {
  background-color: var(--primary-color);
  color: #fff;
  box-shadow: var(--shadow-md);
}

.btn-primary:hover {
  background-color: var(--primary-hover);
  color: #fff;
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg), var(--shadow-glow);
}

.btn-primary:active {
  transform: translateY(1px) scale(0.98);
  box-shadow: var(--shadow-sm);
}

/* Secondary / outline button */
.btn-secondary {
  background-color: transparent;
  color: var(--light-color);
  border: 1px solid var(--border-color);
}

.btn-secondary:hover {
  background-color: rgba(255, 255, 255, 0.05);
  color: var(--light-color);
  border-color: rgba(255, 255, 255, 0.15);
}

/* ========================================
   Grid system
   ======================================== */

.grid {
  display: grid;
  gap: 2em;
}

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

/* ========================================
   Utility classes
   ======================================== */

.text-center { text-align: center; }
.mt-2 { margin-top: 2rem; }
.mb-2 { margin-bottom: 2rem; }
.hidden { display: none; }

/* ========================================
   Media queries — Grid responsive
   ======================================== */

@media (width <= 1200px) {
  .grid-4 {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (width <= 992px) {
  .grid-3, .grid-4 {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (width <= 768px) {
  .grid-2, .grid-3, .grid-4 {
    grid-template-columns: 1fr;
  }
}

/* ========================================
   Animations
   ======================================== */

@keyframes fade-in {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.fade-in {
  animation: fade-in 0.5s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

/* Staggered entry for child elements */
.stagger-in > * {
  opacity: 0;
  animation: fade-in 0.5s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.stagger-in > *:nth-child(1) { animation-delay: 0ms; }
.stagger-in > *:nth-child(2) { animation-delay: 80ms; }
.stagger-in > *:nth-child(3) { animation-delay: 160ms; }
.stagger-in > *:nth-child(4) { animation-delay: 240ms; }
.stagger-in > *:nth-child(5) { animation-delay: 320ms; }
.stagger-in > *:nth-child(6) { animation-delay: 400ms; }

/* ========================================
   Focus styles
   ======================================== */

:focus-visible {
  outline: 2px solid var(--primary-color);
  outline-offset: 2px;
}

:focus:not(:focus-visible) {
  outline: none;
}

/* ========================================
   Noise overlay — adds texture to flat surfaces
   ======================================== */

body::after {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 1;
  opacity: 0.025;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)'/%3E%3C/svg%3E");
  background-repeat: repeat;
  background-size: 256px 256px;
}

/* ========================================
   Reduced motion — accessibility override
   ======================================== */

/* stylelint-disable declaration-no-important */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
/* stylelint-enable */
