/* ==========================================================================
   Base Styles - AnkeLab OC
   ========================================================================== */

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

/* ── Root ── */
html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

body {
  background: var(--bg-primary);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: var(--leading-normal);
  min-height: 100vh;
}

/* ── Links ── */
a {
  color: var(--accent);
  text-decoration: none;
  transition: color var(--transition-fast);
}

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

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

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

img {
  height: auto;
}

/* ── Form Elements ── */
button, input, select, textarea {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  background: none;
  border: none;
}

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

/* ── Lists ── */
ul, ol {
  list-style: none;
}

/* ── Typography ── */
h1, h2, h3, h4, h5, h6 {
  font-weight: var(--font-semibold);
  line-height: var(--leading-tight);
  letter-spacing: -0.02em;
}

h1 { font-size: var(--text-5xl); }
h2 { font-size: var(--text-4xl); }
h3 { font-size: var(--text-3xl); }
h4 { font-size: var(--text-2xl); }
h5 { font-size: var(--text-xl); }
h6 { font-size: var(--text-lg); }

p {
  line-height: var(--leading-relaxed);
}

code {
  font-family: var(--font-mono);
  font-size: 0.9em;
  background: var(--bg-tertiary);
  padding: 0.2em 0.4em;
  border-radius: var(--radius-sm);
}

pre {
  font-family: var(--font-mono);
  background: var(--bg-tertiary);
  padding: var(--space-4);
  border-radius: var(--radius-md);
  overflow-x: auto;
}

pre code {
  background: none;
  padding: 0;
}

/* ── Selection ── */
::selection {
  background: var(--accent);
  color: var(--bg-primary);
}

/* ── Scrollbar ── */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

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

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

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

/* ── Utility Classes ── */
.container {
  width: 100%;
  max-width: var(--container-xl);
  margin: 0 auto;
  padding: 0 var(--space-6);
}

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

/* ── Animation Utilities ── */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeInDown {
  from {
    opacity: 0;
    transform: translateY(-20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes scaleIn {
  from {
    opacity: 0;
    transform: scale(0.95);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes slideInRight {
  from {
    opacity: 0;
    transform: translateX(20px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}

@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

/* ── Animation Classes ── */
.animate-fade-in {
  animation: fadeIn 0.4s ease forwards;
}

.animate-fade-in-up {
  animation: fadeInUp 0.5s ease forwards;
}

.animate-scale-in {
  animation: scaleIn 0.3s ease forwards;
}

.animate-slide-in {
  animation: slideInRight 0.4s ease forwards;
}

.animate-pulse {
  animation: pulse 2s ease-in-out infinite;
}

.animate-spin {
  animation: spin 1s linear infinite;
}

/* ── Stagger Delays ── */
.stagger-1 { animation-delay: 0.1s; }
.stagger-2 { animation-delay: 0.2s; }
.stagger-3 { animation-delay: 0.3s; }
.stagger-4 { animation-delay: 0.4s; }
.stagger-5 { animation-delay: 0.5s; }
.stagger-6 { animation-delay: 0.6s; }

/* ── Skeleton Loading ── */
.skeleton {
  background: linear-gradient(
    90deg,
    var(--bg-tertiary) 25%,
    var(--bg-elevated) 50%,
    var(--bg-tertiary) 75%
  );
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-md);
}

/* ==========================================================================
   Scroll Parallax Effects
   ========================================================================== */
[data-parallax] {
  will-change: transform;
  transition: transform 0.1s linear;
}

.parallax-container {
  perspective: 1000px;
  overflow: hidden;
}

.parallax-slow { transform: translateY(calc(var(--scroll-y, 0) * 0.3px)); }
.parallax-medium { transform: translateY(calc(var(--scroll-y, 0) * 0.5px)); }
.parallax-fast { transform: translateY(calc(var(--scroll-y, 0) * 0.7px)); }

/* ==========================================================================
   3D Card Flip Effect
   ========================================================================== */
.flip-card {
  perspective: 1000px;
}

.flip-card-inner {
  position: relative;
  width: 100%;
  height: 100%;
  transition: transform 0.8s cubic-bezier(0.4, 0, 0.2, 1);
  transform-style: preserve-3d;
}

.flip-card:hover .flip-card-inner,
.flip-card:focus-within .flip-card-inner {
  transform: rotateY(180deg);
}

.flip-card-front,
.flip-card-back {
  position: absolute;
  width: 100%;
  height: 100%;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

.flip-card-back {
  transform: rotateY(180deg);
}

/* ==========================================================================
   Typewriter Effect
   ========================================================================== */
.typewriter {
  overflow: hidden;
  white-space: nowrap;
  border-right: 2px solid var(--accent);
  animation: typing 3s steps(40, end), blink-caret 0.75s step-end infinite;
}

@keyframes typing {
  from { width: 0; }
  to { width: 100%; }
}

@keyframes blink-caret {
  from, to { border-color: transparent; }
  50% { border-color: var(--accent); }
}

.typewriter-block {
  display: inline-block;
}

.typewriter-block .char {
  display: inline-block;
  opacity: 0;
  transform: translateY(-10px);
  animation: typeChar 0.05s forwards;
}

@keyframes typeChar {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ==========================================================================
   Page Transition Effects
   ========================================================================== */
.page-transition-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg-primary);
  z-index: 9999;
  transform: scaleY(0);
  transform-origin: bottom;
  pointer-events: none;
}

body.transitioning-out .page-transition-overlay {
  animation: pageExit 0.4s ease forwards;
}

body.transitioning-in .page-transition-overlay {
  animation: pageEnter 0.4s ease forwards;
  transform-origin: top;
}

@keyframes pageExit {
  0% { transform: scaleY(0); }
  100% { transform: scaleY(1); }
}

@keyframes pageEnter {
  0% { transform: scaleY(1); }
  100% { transform: scaleY(0); }
}

/* Fade in on load */
.fade-in-page {
  animation: fadeInPage 0.6s ease forwards;
}

@keyframes fadeInPage {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ==========================================================================
   Scroll-Triggered Animations
   ========================================================================== */
.animate-on-scroll {
  opacity: 0;
  transform: translateY(30px);
  transition: opacity 0.6s ease, transform 0.6s ease;
}

.animate-on-scroll.in-view {
  opacity: 1;
  transform: translateY(0);
}

.animate-on-scroll.scale-in {
  transform: scale(0.95) translateY(30px);
}

.animate-on-scroll.scale-in.in-view {
  transform: scale(1) translateY(0);
}

.animate-on-scroll.slide-left {
  transform: translateX(-50px) translateY(30px);
}

.animate-on-scroll.slide-left.in-view {
  transform: translateX(0) translateY(0);
}

.animate-on-scroll.slide-right {
  transform: translateX(50px) translateY(30px);
}

.animate-on-scroll.slide-right.in-view {
  transform: translateX(0) translateY(0);
}

/* Stagger children */
.stagger-item {
  opacity: 0;
  transform: translateY(20px);
}

.stagger-item.in-view {
  animation: staggerFadeIn 0.5s ease forwards;
}

@keyframes staggerFadeIn {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ==========================================================================
   3D Hover Effects
   ========================================================================== */
.hover-3d {
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  transform-style: preserve-3d;
}

.hover-3d:hover {
  transform: perspective(1000px) rotateX(5deg) rotateY(5deg) translateZ(10px);
  box-shadow: var(--shadow-xl);
}

/* ==========================================================================
   Gradient Text Animation
   ========================================================================== */
.gradient-text {
  background: linear-gradient(
    90deg,
    var(--accent) 0%,
    var(--info) 50%,
    var(--accent) 100%
  );
  background-size: 200% auto;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: gradientFlow 3s linear infinite;
}

@keyframes gradientFlow {
  0% { background-position: 0% center; }
  100% { background-position: 200% center; }
}

/* ==========================================================================
   Morphing Shape Animation
   ========================================================================== */
.morphing-shape {
  animation: morphShape 8s ease-in-out infinite;
}

@keyframes morphShape {
  0%, 100% {
    border-radius: 60% 40% 30% 70% / 60% 30% 70% 40%;
  }
  50% {
    border-radius: 30% 60% 70% 40% / 50% 60% 30% 60%;
  }
}

/* ── Glass Effect ── */
.glass {
  background: var(--bg-overlay);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}

/* ── Hover Effects ── */
.hover-lift {
  transition: transform var(--transition-base), box-shadow var(--transition-base);
}

.hover-lift:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
}

.hover-scale {
  transition: transform var(--transition-spring);
}

.hover-scale:hover {
  transform: scale(1.02);
}

.hover-glow:hover {
  box-shadow: var(--shadow-glow);
}
