/* ============================================
   BASE.CSS — Global Base Styles
   Portfolio: Anibal Jhamil Huaman Verastein
   ============================================ */

html {
  scroll-behavior: auto; /* Lenis handles smooth scroll */
}

body {
  background-color: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
  position: relative;
}

/* ── Noise / Grain Overlay ── */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  /* z-index below cursor (9999) and modal (300) but above content */
  z-index: 250;
  pointer-events: none;
  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");
  opacity: var(--noise-opacity, 0.04);
  background-size: 200px 200px;
}

/* ── Text Selection ── */
::selection {
  background-color: rgba(88, 166, 255, 0.25);
  color: var(--text);
}

/* ── Custom Scrollbar ── */
::-webkit-scrollbar {
  width: 6px;
}

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

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

::-webkit-scrollbar-thumb:hover {
  background: var(--muted-2);
}

/* ── Focus Styles ── */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: var(--radius-sm);
}

/* ── Typography Base ── */
h1, h2, h3, h4, h5, h6 {
  font-weight: 700;
  line-height: 1.2;
  color: var(--text);
}

/* Don't override section-specific headings — just set cascade defaults */
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-md); }

p {
  color: var(--text-2);
  margin-bottom: 0;
}

/* Terminal-like code */
code {
  font-family: var(--font-mono);
  font-size: 0.875em;
  background: var(--surface-2);
  border: 1px solid var(--border-subtle);
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  color: var(--accent);
}

pre {
  font-family: var(--font-mono);
}

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

/* ── Layout Utilities ── */
.container {
  width: 100%;
  max-width: var(--container);
  margin-inline: auto;
  padding-inline: clamp(var(--space-5), 5vw, var(--space-8));
}

.container-sm {
  max-width: var(--container-sm);
  margin-inline: auto;
  padding-inline: clamp(var(--space-5), 5vw, var(--space-8));
}

.container-lg {
  max-width: var(--container-lg);
  margin-inline: auto;
  padding-inline: clamp(var(--space-4), 3vw, var(--space-6));
}

/* ── Accessibility Utilities ── */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

/* ── Text Utilities ── */
.text-muted  { color: var(--muted)  !important; }
.text-accent { color: var(--accent) !important; }
.text-xs     { font-size: var(--text-xs); }
.text-sm     { font-size: var(--text-sm); }

/* ── Font Utilities ── */
.font-mono { font-family: var(--font-mono); }

/* ── State Classes ── */
/* Applied by JS after loading screen */
body.portfolio-ready .hero-overline,
body.portfolio-ready .hero-title,
body.portfolio-ready .hero-role,
body.portfolio-ready .hero-tagline,
body.portfolio-ready .hero-ctas,
body.portfolio-ready .hero-indicators {
  /* GSAP will handle these, this is just a safety net */
}

/* Applied by JS when all modules ready */
body.js-ready {
  /* placeholder for post-init tweaks */
}
