/* ═══════════════════════════════════════════════════════════════════════
   ULTRA-V3.CSS  —  Satyajit Puhan Portfolio  —  Next-Level Visual Layer
   Adds: film grain, image reveals, spring utilities, glassmorphism v2,
         enhanced focus, content-visibility, depth parallax, noise overlay
   This file layers ON TOP of site-core.css and light-theme.css.
═══════════════════════════════════════════════════════════════════════ */

/* ── 1. Smooth Scroll Root ── */
html {
  scroll-behavior: smooth;
}
@supports (scroll-behavior: smooth) {
  html.lenis {
    scroll-behavior: auto;
  }
  html.lenis body {
    height: auto;
  }
}

/* ── 2. Noise / Film Grain Overlay ── */
.ae-noise-overlay {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9999;
  opacity: 0.035;
  mix-blend-mode: overlay;
  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.85' 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;
  animation: ae-noise-shift 0.5s steps(4) infinite;
}
@keyframes ae-noise-shift {
  0%   { transform: translate(0, 0); }
  25%  { transform: translate(-5%, -5%); }
  50%  { transform: translate(5%, -5%); }
  75%  { transform: translate(-5%, 5%); }
  100% { transform: translate(5%, 5%); }
}

[data-theme="light"] .ae-noise-overlay {
  opacity: 0.02;
  mix-blend-mode: multiply;
}

/* Reduced motion: freeze noise */
@media (prefers-reduced-motion: reduce) {
  .ae-noise-overlay {
    animation: none;
    opacity: 0.02;
  }
}

/* ── 3. Content Visibility (Performance) ── */
section, .section {
  content-visibility: auto;
  contain-intrinsic-size: 0 500px;
}
#home, #contact {
  content-visibility: visible;
}

/* ── 4. Enhanced Custom Cursor v2 ── */
#ae-cursor {
  position: fixed;
  top: 0;
  left: 0;
  pointer-events: none;
  z-index: 10000;
  mix-blend-mode: difference;
}
#ae-cursor .ae-cursor-dot {
  width: 8px;
  height: 8px;
  background: #fff;
  border-radius: 50%;
  position: fixed;
  transition: transform 0.08s ease-out, width 0.2s ease, height 0.2s ease, background 0.2s ease;
  will-change: transform;
}
#ae-cursor .ae-cursor-ring {
  width: 40px;
  height: 40px;
  border: 1.5px solid rgba(255,255,255,0.6);
  border-radius: 50%;
  position: fixed;
  transition: transform 0.18s ease-out, width 0.3s ease, height 0.3s ease, border-color 0.3s ease;
  will-change: transform;
}
#ae-cursor .ae-cursor-trail {
  position: fixed;
  width: 4px;
  height: 4px;
  background: rgba(255,255,255,0.3);
  border-radius: 50%;
  pointer-events: none;
  will-change: transform, opacity;
}

/* Cursor states */
#ae-cursor.hover-link .ae-cursor-ring {
  width: 60px;
  height: 60px;
  border-color: rgba(232,164,68,0.8);
  background: rgba(232,164,68,0.06);
}
#ae-cursor.hover-link .ae-cursor-dot {
  width: 0px;
  height: 0px;
  opacity: 0;
}
#ae-cursor.hover-image .ae-cursor-ring {
  width: 80px;
  height: 80px;
  border-color: rgba(46,196,182,0.7);
  background: rgba(46,196,182,0.05);
}
#ae-cursor.hover-image .ae-cursor-dot {
  opacity: 0;
}

@media (pointer: coarse) {
  #ae-cursor { display: none !important; }
}

/* ── 5. Text Scramble Effect ── */
.ae-scramble {
  display: inline-block;
  font-family: var(--font-h, 'Space Grotesk', system-ui, sans-serif);
}
.ae-scramble .scramble-char {
  display: inline-block;
  transition: color 0.15s ease;
}
.ae-scramble .scramble-char.decoded {
  color: inherit;
}
.ae-scramble .scramble-char.encoded {
  color: var(--gold, #e8a444);
  opacity: 0.7;
}

/* ── 6. Image Mask Reveal ── */
.ae-img-reveal {
  position: relative;
  overflow: hidden;
}
.ae-img-reveal img {
  transform: scale(1.15);
  transition: transform 1.2s var(--ease, cubic-bezier(0.23, 1, 0.32, 1));
}
.ae-img-reveal.ae-revealed img {
  transform: scale(1);
}
.ae-img-reveal::after {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--bg, #050911);
  transform: translateY(0);
  transition: transform 1s var(--ease, cubic-bezier(0.23, 1, 0.32, 1)) 0.1s;
  z-index: 2;
}
.ae-img-reveal.ae-revealed::after {
  transform: translateY(101%);
}

/* Alternate mask directions */
.ae-img-reveal.mask-left::after   { transform: translateX(0); }
.ae-img-reveal.mask-left.ae-revealed::after   { transform: translateX(-101%); }
.ae-img-reveal.mask-right::after  { transform: translateX(0); }
.ae-img-reveal.mask-right.ae-revealed::after  { transform: translateX(101%); }

/* ── 7. Glassmorphism v2 Utilities ── */
.ae-glass {
  background: rgba(12, 17, 32, 0.65);
  backdrop-filter: blur(20px) saturate(1.2);
  -webkit-backdrop-filter: blur(20px) saturate(1.2);
  border: 1px solid rgba(255,255,255,0.08);
}
[data-theme="light"] .ae-glass {
  background: rgba(255, 255, 255, 0.7);
  border-color: rgba(15,23,42,0.08);
}

.ae-glass-strong {
  background: rgba(12, 17, 32, 0.85);
  backdrop-filter: blur(30px) saturate(1.3);
  -webkit-backdrop-filter: blur(30px) saturate(1.3);
  border: 1px solid rgba(255,255,255,0.1);
}

/* ── 8. Spring Animation Utilities ── */
@keyframes ae-spring-in {
  0%   { opacity: 0; transform: translateY(60px) scale(0.95); }
  60%  { opacity: 1; transform: translateY(-4px) scale(1.01); }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes ae-spring-scale {
  0%   { transform: scale(0.8); opacity: 0; }
  70%  { transform: scale(1.03); }
  100% { transform: scale(1); opacity: 1; }
}
@keyframes ae-spring-bounce {
  0%   { transform: translateY(0); }
  40%  { transform: translateY(-12px); }
  80%  { transform: translateY(3px); }
  100% { transform: translateY(0); }
}

.ae-spring-in {
  opacity: 0;
  animation: ae-spring-in 0.9s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}
.ae-spring-scale {
  opacity: 0;
  animation: ae-spring-scale 0.7s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

/* ── 9. Stagger Children ── */
.ae-stagger > * {
  opacity: 0;
  transform: translateY(30px);
  transition: opacity 0.6s var(--ease), transform 0.6s var(--ease);
}
.ae-stagger.ae-revealed > *:nth-child(1)  { transition-delay: 0ms;   opacity: 1; transform: translateY(0); }
.ae-stagger.ae-revealed > *:nth-child(2)  { transition-delay: 80ms;  opacity: 1; transform: translateY(0); }
.ae-stagger.ae-revealed > *:nth-child(3)  { transition-delay: 160ms; opacity: 1; transform: translateY(0); }
.ae-stagger.ae-revealed > *:nth-child(4)  { transition-delay: 240ms; opacity: 1; transform: translateY(0); }
.ae-stagger.ae-revealed > *:nth-child(5)  { transition-delay: 320ms; opacity: 1; transform: translateY(0); }
.ae-stagger.ae-revealed > *:nth-child(6)  { transition-delay: 400ms; opacity: 1; transform: translateY(0); }
.ae-stagger.ae-revealed > *:nth-child(7)  { transition-delay: 480ms; opacity: 1; transform: translateY(0); }
.ae-stagger.ae-revealed > *:nth-child(8)  { transition-delay: 560ms; opacity: 1; transform: translateY(0); }
.ae-stagger.ae-revealed > *:nth-child(9)  { transition-delay: 640ms; opacity: 1; transform: translateY(0); }
.ae-stagger.ae-revealed > *:nth-child(10) { transition-delay: 720ms; opacity: 1; transform: translateY(0); }

/* ── 10. Depth Parallax Layers ── */
[data-parallax] {
  will-change: transform;
  transition: transform 0.1s linear;
}
[data-parallax="0.1"] { --parallax-depth: 0.1; }
[data-parallax="0.2"] { --parallax-depth: 0.2; }
[data-parallax="0.3"] { --parallax-depth: 0.3; }
[data-parallax="0.4"] { --parallax-depth: 0.4; }
[data-parallax="0.5"] { --parallax-depth: 0.5; }
[data-parallax="0.6"] { --parallax-depth: 0.6; }
[data-parallax="0.8"] { --parallax-depth: 0.8; }
[data-parallax="1.0"] { --parallax-depth: 1.0; }

/* ── 11. Magnetic Button v2 ── */
.ae-magnetic {
  transition: transform 0.15s cubic-bezier(0.23, 1, 0.32, 1);
  will-change: transform;
}

/* ── 12. Focus States (Accessibility) ── */
a:focus-visible,
button:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid var(--gold, #e8a444);
  outline-offset: 3px;
  border-radius: 4px;
}
[data-theme="light"] a:focus-visible,
[data-theme="light"] button:focus-visible,
[data-theme="light"] [tabindex]:focus-visible {
  outline-color: #8b5cf6;
}

/* ── 13. Selection Colors ── */
::selection {
  background: rgba(232, 164, 68, 0.25);
  color: inherit;
}
::-moz-selection {
  background: rgba(232, 164, 68, 0.25);
  color: inherit;
}

/* ── 14. Scrollbar Styling ── */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: var(--bg, #050911);
}
::-webkit-scrollbar-thumb {
  background: rgba(232, 164, 68, 0.3);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(232, 164, 68, 0.5);
}
[data-theme="light"] ::-webkit-scrollbar-track {
  background: #f1f5f9;
}
[data-theme="light"] ::-webkit-scrollbar-thumb {
  background: rgba(139, 92, 246, 0.3);
}

/* ── 15. Shimmer / Skeleton Loading ── */
.ae-shimmer {
  background: linear-gradient(
    90deg,
    var(--bg-2, #0c1120) 25%,
    var(--bg-3, #111928) 50%,
    var(--bg-2, #0c1120) 75%
  );
  background-size: 200% 100%;
  animation: ae-shimmer 1.5s infinite;
  border-radius: var(--r-sm, 8px);
}
@keyframes ae-shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ── 16. Glow Pulse on Interactive Elements ── */
.ae-glow-pulse {
  position: relative;
}
.ae-glow-pulse::before {
  content: '';
  position: absolute;
  inset: -2px;
  border-radius: inherit;
  background: linear-gradient(135deg, var(--gold, #e8a444), var(--teal, #2ec4b6));
  opacity: 0;
  z-index: -1;
  filter: blur(12px);
  transition: opacity 0.4s ease;
}
.ae-glow-pulse:hover::before {
  opacity: 0.4;
  animation: ae-glow-breathe 2s ease-in-out infinite;
}
@keyframes ae-glow-breathe {
  0%, 100% { opacity: 0.3; }
  50%      { opacity: 0.5; }
}

/* ── 17. Underline Reveal for Links ── */
.ae-underline-reveal {
  position: relative;
  text-decoration: none;
}
.ae-underline-reveal::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 50%;
  width: 0;
  height: 1.5px;
  background: var(--gold, #e8a444);
  transition: width 0.35s var(--ease), left 0.35s var(--ease);
}
.ae-underline-reveal:hover::after {
  width: 100%;
  left: 0;
}

/* ── 18. Card Hover Lift ── */
.ae-lift {
  transition: transform 0.35s var(--ease), box-shadow 0.35s var(--ease);
}
.ae-lift:hover {
  transform: translateY(-6px);
  box-shadow: 0 20px 50px rgba(0,0,0,0.35);
}
[data-theme="light"] .ae-lift:hover {
  box-shadow: 0 20px 50px rgba(0,0,0,0.12);
}

/* ── 19. Gradient Text Animation ── */
.ae-gradient-text {
  background: linear-gradient(90deg, #e8a444, #2ec4b6, #e05c7a, #e8a444);
  background-size: 300% 100%;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: ae-gradient-text-shift 4s linear infinite;
}
@keyframes ae-gradient-text-shift {
  0%   { background-position: 0% 50%; }
  100% { background-position: 300% 50%; }
}

/* ── 20. Reduced Motion Support ── */
@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;
  }
  .ae-noise-overlay { display: none; }
  [data-parallax] { transform: none !important; }
}

/* ── 21. Mobile Optimizations ── */
@media (max-width: 768px) {
  .ae-noise-overlay { opacity: 0.02; }
  [data-parallax] { transform: none !important; }
  .ae-img-reveal::after { display: none; }
  .ae-img-reveal img { transform: none; }
}

/* ── 22. Loading Screen ── */
#ae-loading-screen {
  position: fixed;
  inset: 0;
  background: var(--bg, #050911);
  z-index: 99999;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 24px;
  transition: opacity 0.6s ease, visibility 0.6s ease;
}
#ae-loading-screen.done {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}
.ae-loading-spinner {
  width: 48px;
  height: 48px;
  border: 2px solid transparent;
  border-top-color: var(--gold, #e8a444);
  border-right-color: var(--teal, #2ec4b6);
  border-radius: 50%;
  animation: ae-spin 1s linear infinite;
}
@keyframes ae-spin {
  to { transform: rotate(360deg); }
}
.ae-loading-text {
  font-family: var(--font-m, 'JetBrains Mono', monospace);
  font-size: 0.75rem;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: var(--text-muted, rgba(255,255,255,0.45));
}

/* ── 23. Smooth Scrollbar Progress (thin line on right) ── */
#ae-scroll-progress-v2 {
  position: fixed;
  right: 0;
  top: 0;
  width: 3px;
  height: 0%;
  background: linear-gradient(to bottom, var(--gold, #e8a444), var(--teal, #2ec4b6));
  z-index: 9998;
  opacity: 0.6;
  transition: height 0.1s linear;
}

/* ── 24. Hover Spotlight (for cards) ── */
.ae-spotlight {
  position: relative;
  overflow: hidden;
}
.ae-spotlight::before {
  content: '';
  position: absolute;
  width: 200px;
  height: 200px;
  background: radial-gradient(circle, rgba(232,164,68,0.12) 0%, transparent 70%);
  border-radius: 50%;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s ease;
  left: var(--spotlight-x, 50%);
  top: var(--spotlight-y, 50%);
  transform: translate(-50%, -50%);
  z-index: 0;
}
.ae-spotlight:hover::before {
  opacity: 1;
}

/* ── 26. Skip Link (Accessibility) ── */
.ae-skip-link {
  position: absolute;
  top: -40px;
  left: 0;
  background: var(--gold, #e8a444);
  color: #000;
  padding: 8px 16px;
  font-weight: 700;
  font-size: 0.85rem;
  z-index: 100000;
  text-decoration: none;
  border-radius: 0 0 8px 0;
  transition: top 0.3s ease;
  font-family: var(--font-b, 'Inter', system-ui, sans-serif);
}
.ae-skip-link:focus {
  top: 0;
  outline: 2px solid #000;
  outline-offset: 2px;
}

/* ── 27. Screen Reader Only ── */
.ae-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;
}

/* ── 28. High Contrast Support ── */
@media (prefers-contrast: more) {
  a:focus-visible,
  button:focus-visible {
    outline: 3px solid currentColor;
    outline-offset: 4px;
  }
  .ae-noise-overlay { display: none; }
}

/* ── 29. Print Styles ── */
@media print {
  .ae-noise-overlay,
  #ae-cursor,
  #ae-scroll-progress,
  #ae-scroll-progress-v2,
  #ae-loading-screen,
  .ae-spotlight::before,
  .ae-glow-pulse::before { display: none !important; }
  body { background: #fff !important; color: #000 !important; }
  a { text-decoration: underline; color: #000 !important; }
}
.ae-border-gradient {
  position: relative;
  background: var(--bg, #050911);
  border-radius: var(--r-md, 14px);
  z-index: 1;
}
.ae-border-gradient::before {
  content: '';
  position: absolute;
  inset: -1px;
  border-radius: inherit;
  padding: 1px;
  background: linear-gradient(135deg, var(--gold, #e8a444), var(--teal, #2ec4b6), var(--rose, #e05c7a), var(--gold, #e8a444));
  background-size: 300% 300%;
  animation: ae-border-gradient-anim 4s ease infinite;
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  z-index: -1;
  pointer-events: none;
}
@keyframes ae-border-gradient-anim {
  0%   { background-position: 0% 50%; }
  50%  { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}
