/* ==========================================================================
   BASE.CSS — Global Foundation
   Ulises Paiz Portfolio — Blueprint Theme
   ========================================================================== */

/* --------------------------------------------------------------------------
   Custom Properties
   -------------------------------------------------------------------------- */
:root {
  --accent: #00d4ff;
  --accent-glow: rgba(0, 212, 255, 0.08);
  --bg-primary: #08080a;
  --bg-secondary: #111113;
  --bg-elevated: #161618;
  --text-primary: #e8e8ec;
  --text-secondary: #9a9aa0;
  --text-muted: #6b6b75;
  --danger: #ff3b3b;
  --success: #00ff88;
  --grid-color: rgba(0, 212, 255, 0.04);
  --font-display: 'Bebas Neue', 'Oswald', sans-serif;
  --font-heading: 'Oswald', sans-serif;
  --font-body: 'Crimson Pro', Georgia, serif;
  --font-mono: 'JetBrains Mono', monospace;
  --ease-out-expo: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-out-quart: cubic-bezier(0.25, 1, 0.5, 1);
}

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

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  /* NO scroll-behavior: smooth — Lenis handles scrolling */
}

body {
  font-family: var(--font-body);
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.7;
  overflow-x: hidden;
  min-height: 100vh;
}

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

img {
  height: auto;
  object-fit: cover;
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  font: inherit;
  color: inherit;
  background: none;
  border: none;
  cursor: pointer;
}

ul, ol {
  list-style: none;
}

input, textarea {
  font: inherit;
  color: inherit;
  background: none;
  border: none;
  outline: none;
}

h1, h2, h3, h4, h5, h6 {
  line-height: 1.1;
  font-weight: 600;
}

/* --------------------------------------------------------------------------
   Scrollbar
   -------------------------------------------------------------------------- */
::-webkit-scrollbar {
  width: 3px;
}

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

::-webkit-scrollbar-thumb {
  background: var(--text-muted);
  border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-secondary);
}

/* Firefox */
html {
  scrollbar-width: thin;
  scrollbar-color: var(--text-muted) var(--bg-primary);
}

/* --------------------------------------------------------------------------
   Selection
   -------------------------------------------------------------------------- */
::selection {
  background: rgba(0, 212, 255, 0.15);
  color: var(--text-primary);
}

::-moz-selection {
  background: rgba(0, 212, 255, 0.15);
  color: var(--text-primary);
}

/* --------------------------------------------------------------------------
   Skip Link & Focus
   -------------------------------------------------------------------------- */
.skip-link {
  position: fixed;
  top: -100%;
  left: 1rem;
  z-index: 10000;
  padding: 0.75rem 1.5rem;
  background: var(--accent);
  color: var(--bg-primary);
  font-family: var(--font-mono);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  border-radius: 0 0 6px 6px;
  transition: top 0.3s var(--ease-out-expo);
}

.skip-link:focus {
  top: 0;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 2px;
}

/* --------------------------------------------------------------------------
   Loader
   -------------------------------------------------------------------------- */
.loader {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: var(--bg-primary);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  transition: opacity 0.6s var(--ease-out-expo),
              visibility 0.6s;
}

.loader.is-hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.loader-counter {
  font-family: var(--font-mono);
  font-size: clamp(3rem, 8vw, 6rem);
  color: var(--accent);
  letter-spacing: 0.05em;
  line-height: 1;
  margin-bottom: 2rem;
}

.loader-bar {
  width: min(280px, 60vw);
  height: 2px;
  background: rgba(0, 212, 255, 0.1);
  position: relative;
  overflow: hidden;
  border-radius: 1px;
}

.loader-bar-fill {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  width: 0%;
  background: var(--accent);
  border-radius: 1px;
  transition: width 0.1s linear;
  box-shadow: 0 0 10px var(--accent-glow);
}

.loader-text {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.25em;
  color: var(--text-muted);
  margin-top: 1.5rem;
}

/* --------------------------------------------------------------------------
   Grain Overlay
   -------------------------------------------------------------------------- */
.grain-overlay {
  position: fixed;
  inset: 0;
  z-index: 9998;
  pointer-events: none;
  opacity: 0.015;
  mix-blend-mode: overlay;
}
.grain-overlay::before {
  content: '';
  position: absolute;
  inset: -200%;
  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-size: 128px 128px;
  animation: grain 0.5s steps(6) infinite;
}

@keyframes grain {
  0%, 100% { transform: translate(0, 0); }
  10% { transform: translate(-5%, -10%); }
  20% { transform: translate(-15%, 5%); }
  30% { transform: translate(7%, -25%); }
  40% { transform: translate(-5%, 25%); }
  50% { transform: translate(-15%, 10%); }
  60% { transform: translate(15%, 0); }
  70% { transform: translate(0, 15%); }
  80% { transform: translate(3%, 35%); }
  90% { transform: translate(-10%, 10%); }
}

/* --------------------------------------------------------------------------
   Blueprint Grid Overlay
   -------------------------------------------------------------------------- */
.blueprint-grid {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-image:
    linear-gradient(var(--grid-color) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-color) 1px, transparent 1px);
  background-size: 60px 60px;
  mask-image: radial-gradient(ellipse 80% 80% at 50% 50%, rgba(0,0,0,0.35) 0%, transparent 75%);
  -webkit-mask-image: radial-gradient(ellipse 80% 80% at 50% 50%, rgba(0,0,0,0.35) 0%, transparent 75%);
}

/* Mobile — kill heavy overlays and enable native scroll */
@media (max-width: 900px) {
  .grain-overlay {
    display: none;
  }
  .blueprint-grid {
    display: none;
  }
  .ambient-glow {
    display: none;
  }
  .hero-particles {
    display: none;
  }
  .hero-grid-bg {
    opacity: 0.3;
  }
  /* Enable native smooth scrolling when Lenis is disabled */
  html {
    scroll-behavior: smooth;
  }
  /* Make all reveals visible by default so content isn't hidden if JS is slow */
  .reveal-up,
  .reveal-scale {
    opacity: 1 !important;
    transform: none !important;
  }
}

/* --------------------------------------------------------------------------
   Ambient Glow
   -------------------------------------------------------------------------- */
.ambient-glow {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}
.ambient-glow::before {
  content: '';
  position: absolute;
  width: 60vw;
  height: 60vw;
  max-width: 700px;
  max-height: 700px;
  border-radius: 50%;
  top: 40%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: radial-gradient(circle, var(--accent-glow) 0%, transparent 70%);
  filter: blur(100px);
  transition: background 0.8s;
}

/* --------------------------------------------------------------------------
   Progress Bar
   -------------------------------------------------------------------------- */
.progress-bar {
  position: fixed;
  top: 0;
  left: 0;
  width: 0%;
  height: 2px;
  background: var(--accent);
  z-index: 9998;
  transform-origin: left;
  will-change: width;
  transition: none;
  box-shadow: 0 0 8px var(--accent-glow);
}

/* --------------------------------------------------------------------------
   Reveal Helpers — GSAP toggles .is-visible
   -------------------------------------------------------------------------- */
.reveal-up {
  opacity: 0;
  transform: translateY(40px);
  transition: opacity 0.8s var(--ease-out-expo),
              transform 0.8s var(--ease-out-expo);
}

.reveal-up.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.reveal-scale {
  opacity: 0;
  transform: scale(0.92);
  transition: opacity 0.8s var(--ease-out-expo),
              transform 0.8s var(--ease-out-expo);
}

.reveal-scale.is-visible {
  opacity: 1;
  transform: scale(1);
}

/* Word accent — individual character reveal */
.word-accent .char {
  display: inline-block;
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.4s var(--ease-out-expo),
              transform 0.4s var(--ease-out-expo);
}

.word-accent.is-visible .char {
  opacity: 1;
  transform: translateY(0);
}

/* Staggered delay via GSAP or nth-child */
.word-accent .char:nth-child(1)  { transition-delay: 0.02s; }
.word-accent .char:nth-child(2)  { transition-delay: 0.04s; }
.word-accent .char:nth-child(3)  { transition-delay: 0.06s; }
.word-accent .char:nth-child(4)  { transition-delay: 0.08s; }
.word-accent .char:nth-child(5)  { transition-delay: 0.10s; }
.word-accent .char:nth-child(6)  { transition-delay: 0.12s; }
.word-accent .char:nth-child(7)  { transition-delay: 0.14s; }
.word-accent .char:nth-child(8)  { transition-delay: 0.16s; }
.word-accent .char:nth-child(9)  { transition-delay: 0.18s; }
.word-accent .char:nth-child(10) { transition-delay: 0.20s; }

/* --------------------------------------------------------------------------
   Smooth Themed Transitions
   -------------------------------------------------------------------------- */
.themed-transition {
  transition: background-color 0.6s var(--ease-out-expo),
              color 0.6s var(--ease-out-expo),
              border-color 0.6s var(--ease-out-expo),
              box-shadow 0.6s var(--ease-out-expo);
}

/* Clip-path image reveal */
.reveal-clip {
  clip-path: inset(100% 0 0 0);
  transition: clip-path 1s var(--ease-out-expo);
}

.reveal-clip.is-visible {
  clip-path: inset(0 0 0 0);
}
