/* Global CSS for Space Phoenix portfolio
   Purpose: central design tokens, resets, base typography, layout helpers,
   accessible focus states, form/button base styles, and reduced-motion fallbacks.

   Generated from docs/*.md guidance (color system, breakpoints, motion/accessibility).
*/

:root {
  /* Color system (from docs) */
  --bg: #030305;
  --panel: #0a0c14;
  --text: #f0f0f8;
  --muted: #a0a6b2;
  --flame: #ff4d1c;
  --glow: #ffd56b;
  --accent: #7b6fff;

  /* Semantic tokens */
  --surface-elev-1: rgba(255,255,255,0.02);
  --surface-elev-2: rgba(255,255,255,0.03);
  --glass: rgba(255,255,255,0.03);

  /* Typography scale */
  --font-sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial;
  --font-mono: "Fira Code", SFMono-Regular, Menlo, Monaco, monospace;

  /* Sizing */
  --container-max: 1200px;
  --gutter: 1.25rem;

  /* Breakpoints */
  --bp-xs: 480px;
  --bp-sm: 768px;
  --bp-md: 1024px;
  --bp-lg: 1200px;
  --bp-xl: 1440px;

  /* Motion */
  --ease-out-quick: cubic-bezier(.2,.9,.3,1);
  --ease-smooth: cubic-bezier(.22,.8,.18,1);

  /* Elevation shadows */
  --shadow-1: 0 6px 18px rgba(11,12,20,0.45);
  --shadow-2: 0 12px 30px rgba(11,12,20,0.55);
  --header-height: 82px;

  /* Account for fixed header when using anchor links */
  scroll-padding-top: calc(var(--header-height) + 16px);
}

/* Box sizing and a tiny normalize */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
html { -webkit-font-smoothing:antialiased; -moz-osx-font-smoothing:grayscale; }

html.lenis {
  height: auto;
}

.lenis.lenis-smooth {
  scroll-behavior: auto !important;
}

.lenis.lenis-smooth body {
  overflow: hidden;
}

.lenis.lenis-smooth [data-lenis-prevent] {
  overscroll-behavior: contain;
}

body {
  margin: 0;
  font-family: var(--font-sans);
  color: var(--text);
  background: linear-gradient(180deg, var(--bg) 0%, #04040a 100%);
  line-height: 1.45;
  -webkit-tap-highlight-color: transparent;
  text-rendering: optimizeLegibility;
  font-size: clamp(15px, 1.7vw, 18px); /* fluid base size */
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background:
    radial-gradient(45% 45% at 20% 20%, rgba(255, 77, 28, 0.18), transparent 60%),
    radial-gradient(35% 35% at 80% 20%, rgba(123, 111, 255, 0.16), transparent 65%),
    radial-gradient(50% 50% at 50% 80%, rgba(255, 213, 107, 0.12), transparent 70%);
  mix-blend-mode: screen;
  pointer-events: none;
  z-index: -1;
  animation: phoenixPulse 18s ease-in-out infinite alternate;
  transform: translate3d(0, 0, 0);
}

.reveal-enabled [data-reveal] {
  --reveal-translate-x: 0px;
  --reveal-translate-y: 32px;
  --reveal-scale: 1;
  --reveal-rotate-x: 0deg;
  --reveal-rotate-y: 0deg;
  --reveal-rotate-z: 0deg;
  --reveal-skew-x: 0deg;
  --reveal-skew-y: 0deg;
  opacity: 0;
  transform:
    translate3d(var(--reveal-translate-x), var(--reveal-translate-y), 0)
    scale(var(--reveal-scale))
    rotateX(var(--reveal-rotate-x))
    rotateY(var(--reveal-rotate-y))
    rotate(var(--reveal-rotate-z))
    skewX(var(--reveal-skew-x))
    skewY(var(--reveal-skew-y));
  transition:
    opacity 360ms var(--ease-out-quick),
    transform 420ms var(--ease-out-quick);
  will-change: opacity, transform;
}

.reveal-enabled [data-reveal][data-reveal-axis="x"] {
  --reveal-translate-x: 32px;
  --reveal-translate-y: 0px;
}

.reveal-enabled [data-reveal].is-visible {
  opacity: 1;
  --reveal-translate-x: 0px;
  --reveal-translate-y: 0px;
}

.reveal-enabled [data-reveal][data-reveal-spring="true"].is-visible {
  transition-timing-function: var(--ease-smooth);
}

@media (prefers-reduced-motion: reduce) {
  .reveal-enabled [data-reveal] {
    opacity: 1;
    transform: none;
    transition-duration: 0ms;
  }
}

@keyframes phoenixPulse {
  0% {
    filter: blur(0px);
    opacity: 0.65;
    transform: scale(1) translate3d(0, 0, 0);
  }
  50% {
    filter: blur(6px);
    opacity: 0.85;
    transform: scale(1.05) translate3d(-1.5%, -1%, 0);
  }
  100% {
    filter: blur(8px);
    opacity: 0.6;
    transform: scale(1.1) translate3d(2%, 1.5%, 0);
  }
}

/* Skip link for accessibility */
.skip-link {
  position: absolute;
  left: 1rem;
  top: -40px;
  background: var(--panel);
  color: var(--text);
  padding: 0.5rem 0.75rem;
  border-radius: 6px;
  z-index: 1000;
  transition: top 180ms var(--ease-out-quick);
}
.skip-link:focus { top: 1rem; }

/* Utility: visually hidden (screen readers) */
.sr-only, .visually-hidden {
  position: absolute !important;
  height: 1px; width: 1px;
  overflow: hidden;
  clip: rect(1px, 1px, 1px, 1px);
  white-space: nowrap;
}

/* Global container */
.container {
  width: 100%;
  margin-left: auto;
  margin-right: auto;
  padding-left: var(--gutter);
  padding-right: var(--gutter);
  max-width: var(--container-max);
}

/* Grid helpers */
.row { display: flex; flex-wrap: wrap; gap: 1rem; }
.col { flex: 1 1 0; min-width: 0; }

/* Cards */
.card {
  background: linear-gradient(180deg, rgba(255,255,255,0.02), rgba(255,255,255,0.01));
  border-radius: 12px;
  padding: 1rem;
  box-shadow: var(--shadow-1);
  border: 1px solid rgba(255,255,255,0.03);
}

/* Headings */
h1, h2, h3, h4, h5 { color: var(--text); margin: 0 0 0.5rem 0; font-weight: 700; }
h1 { font-size: clamp(1.6rem, 4.4vw, 3.2rem); line-height: 1.05; }
h2 { font-size: clamp(1.25rem, 3.2vw, 2rem); }

p { margin: 0 0 1rem 0; color: var(--muted); }

/* Links */
a { color: var(--glow); text-decoration: none; transition: color 180ms var(--ease-smooth); }
a:hover, a:focus { color: var(--accent); outline: none; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 0.5rem; border: 0; cursor: pointer; border-radius: 10px;
  padding: 0.6rem 1rem; font-weight: 600; text-decoration: none;
  background: transparent; color: var(--text);
}

.btn:focus { outline: 3px solid rgba(123,111,255,0.18); outline-offset: 3px; }

.btn-primary {
  background: linear-gradient(90deg, var(--flame), var(--accent));
  color: #0b0710; box-shadow: 0 6px 20px rgba(123,111,255,0.12);
}

.btn-ghost {
  border: 1px solid rgba(255,255,255,0.06);
  background: linear-gradient(180deg, rgba(255,255,255,0.015), transparent);
}

.btn[disabled], .btn--disabled { opacity: 0.5; cursor: not-allowed; }

/* Form elements */
input[type="text"], input[type="email"], input[type="tel"], textarea, select {
  width: 100%; padding: 0.65rem 0.75rem; border-radius: 8px; border: 1px solid rgba(255,255,255,0.06);
  background: rgba(255,255,255,0.01); color: var(--text); font: inherit;
}

textarea { min-height: 120px; resize: vertical; }

.input-row { display: grid; gap: 0.75rem; grid-template-columns: 1fr; }
@media (min-width: 768px) { .input-row.two { grid-template-columns: 1fr 1fr; } }

.form-note { font-size: 0.9rem; color: var(--muted); }
.form-error { color: #ffb4a1; font-weight: 600; }

/* Header & navigation baseline */
.site-header {
  width: 100%;
  background: linear-gradient(180deg, rgba(10, 12, 20, 0.78), rgba(10, 12, 20, 0.64));
  backdrop-filter: blur(8px);
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 999;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  box-shadow: 0 10px 25px rgba(3, 3, 9, 0.28);
}

.header-inner { min-height: var(--header-height); display:flex; align-items:center; justify-content:space-between; gap:1rem; padding:0.6rem var(--gutter); }

.brand { display:flex; align-items:center; gap:0.6rem; }
.brand .logo { display:inline-block; }

.nav {
  position: relative;
  display: flex;
  gap: 1rem;
  align-items: center;
  padding-bottom: 0.35rem;
}
.nav .nav-link {
  position: relative;
  color: var(--muted);
  padding: 0.4rem 0.6rem;
  border-radius: 6px;
  transition: color 160ms var(--ease-out-quick);
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-weight: 500;
}
.nav .nav-link:hover,
.nav .nav-link:focus {
  color: var(--text);
  background: rgba(255,255,255,0.02);
}

.nav-link-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.1rem;
  height: 1.1rem;
  color: currentColor;
  opacity: 0.78;
  transition: opacity 160ms var(--ease-out-quick);
}

.nav-link:hover .nav-link-icon,
.nav-link:focus-visible .nav-link-icon,
.nav-link.is-active .nav-link-icon {
  opacity: 1;
}

.nav-link-label {
  line-height: 1;
}

/* Mobile nav toggle */
.mobile-toggle { display:none; background:transparent; border:0; color:var(--text); }
@media (max-width: 768px) { .nav { display:none; } .mobile-toggle { display:inline-flex; } }


/* Footer baseline */
.site-footer { padding: 2rem var(--gutter); background: linear-gradient(180deg, rgba(10,12,20,0.35), rgba(5,6,10,0.25)); color: var(--muted); border-top: 1px solid rgba(255,255,255,0.02); }
.site-footer .footer-grid { display:grid; grid-template-columns: repeat(auto-fit,minmax(180px,1fr)); gap:1rem; }

/* Utility: small text */
.small { font-size: 0.9rem; color: var(--muted); }

/* Focus visible for keyboard users */
:focus { outline: none; }
:focus-visible { outline: 3px solid rgba(255,213,107,0.14); outline-offset: 3px; }

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; scroll-behavior: auto !important; }
}

/* Scroll progress (simple) */
.scroll-progress { position: fixed; left: 0; top: 0; height: 3px; background: linear-gradient(90deg, var(--glow), var(--accent)); width: 0%; z-index: 9999; transition: width 120ms var(--ease-out-quick); }

/* Tiny helpers */
.center { display:flex; align-items:center; justify-content:center; }
.mt-1 { margin-top: 1rem; }
.mb-1 { margin-bottom: 1rem; }
.p-1 { padding: 1rem; }

main {
  padding-top: calc(var(--header-height) + 28px);
}

@media (max-width: 768px) {
  :root {
    --header-height: 72px;
  }

  main {
    padding-top: calc(var(--header-height) + 24px);
  }
}

/* Custom cursor */
html.cursor-enabled body {
  cursor: none;
}

.cursor {
  position: fixed;
  top: 0;
  left: 0;
  width: 32px;
  height: 32px;
  transform: translate3d(-50%, -50%, 0);
  pointer-events: none;
  z-index: 9999;
  opacity: 0;
  transition: opacity 180ms ease-out;
}

.cursor-visible .cursor {
  opacity: 1;
}

.cursor-ring,
.cursor-dot,
.cursor-glow,
.cursor-tail {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  pointer-events: none;
  transition: transform 180ms ease-out, opacity 180ms ease-out, border 180ms ease-out, background 180ms ease-out;
}

.cursor-ring {
  border: 1.5px solid rgba(255, 213, 107, 0.7);
  background: radial-gradient(circle, rgba(255, 213, 107, 0.15), transparent 70%);
}

.cursor-dot {
  width: 6px;
  height: 6px;
  margin: auto;
  background: var(--glow);
  box-shadow: 0 0 18px rgba(255, 213, 107, 0.5);
}

.cursor-glow {
  inset: -18px;
  background: radial-gradient(circle, rgba(123, 111, 255, 0.22), transparent 70%);
  opacity: 0.65;
  filter: blur(8px);
}

.cursor.is-active .cursor-ring {
  transform: scale(1.45);
  border-color: rgba(255, 77, 28, 0.65);
}

.cursor.is-active .cursor-dot {
  transform: scale(0.9);
  background: var(--flame);
  box-shadow: 0 0 22px rgba(255, 77, 28, 0.55);
}

.cursor.is-active .cursor-glow {
  opacity: 0.85;
  background: radial-gradient(circle, rgba(255, 77, 28, 0.28), transparent 70%);
}

.cursor.is-pressed .cursor-ring {
  transform: scale(0.7);
  border-color: rgba(255, 213, 107, 0.9);
}

.cursor.is-pressed .cursor-dot {
  transform: scale(1.4);
}

.cursor-hidden .cursor {
  opacity: 0 !important;
}

.cursor-tail {
  position: absolute;
  inset: -6px;
  border-radius: 999px;
  background: radial-gradient(circle, rgba(255, 213, 107, 0.25), transparent 70%);
  opacity: 0;
  filter: blur(6px);
  transform: scale(0.6);
  transition: opacity 220ms ease-out, transform 220ms ease-out;
}

.cursor-tail.is-visible {
  opacity: 0.75;
  transform: scale(1);
}

@keyframes cursorTrailFade {
  0% {
    transform: translate3d(var(--trail-x, 0), var(--trail-y, 0), 0) scale(1);
    opacity: 0.45;
  }
  75% {
    opacity: 0.25;
  }
  100% {
    transform: translate3d(var(--trail-x, 0), var(--trail-y, 0), 0) scale(0.2);
    opacity: 0;
  }
}

.cursor-trail-piece {
  position: fixed;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(123, 111, 255, 0.4), transparent 70%);
  pointer-events: none;
  mix-blend-mode: screen;
  z-index: 9990;
  animation: cursorTrailFade 600ms ease-out forwards;
}

@media (pointer: coarse) {
  html.cursor-enabled body {
    cursor: auto;
  }

  .cursor {
    display: none;
  }
}

/* Preloader */
.preloader {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at top, rgba(17, 19, 30, 0.96), rgba(3, 3, 9, 0.98));
  backdrop-filter: blur(6px);
  z-index: 10000;
  transition: opacity 240ms var(--ease-out-quick), visibility 240ms var(--ease-out-quick);
}

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

.preloader__inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  padding: 1.75rem 2.5rem;
  border-radius: 18px;
  background: rgba(18, 21, 34, 0.85);
  box-shadow: 0 20px 44px rgba(3, 3, 9, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.06);
  transform: translateY(0);
  transition: transform 280ms var(--ease-out-quick);
}

.preloader__spinner {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.12);
  border-top-color: var(--glow);
  animation: preloaderSpin 860ms linear infinite;
}

.preloader__text {
  font-size: 0.95rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

.preloader.is-hidden .preloader__inner {
  transform: translateY(8px);
  transition: transform 280ms var(--ease-out-quick);
}

@keyframes preloaderSpin {
  to {
    transform: rotate(1turn);
  }
}

@media (max-width: 480px) {
  .preloader__inner {
    width: min(320px, 90vw);
    padding: 1.5rem;
  }

  .preloader__text {
    font-size: 0.85rem;
  }
}

@media (min-width: 1440px) {
  :root {
    --container-max: 1320px;
  }

  body {
    font-size: clamp(16px, 1.35vw, 19px);
  }

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

/* Accessibility: high contrast overrides (users who switch UA setting) */
@media (-ms-high-contrast: active), (forced-colors: active) {
  :root { --bg: Window; --panel: WindowFrame; --text: WindowText; }
  a { text-decoration: underline; }
}

/* End of global.css */
