/**
 * Premium motion styles — pairs with animations.js (GSAP + Lenis)
 */

/* ── Intro curtain ── */
.intro-curtain {
  position: fixed;
  inset: 0;
  z-index: 10002;
  background: var(--chess-dark);
  pointer-events: none;
  transform-origin: top center;
}

/* ── Hero ambient ── */
.hero-section {
  position: relative;
  overflow: hidden;
}

.hero-mesh {
  position: absolute;
  inset: -20% -10%;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse 55% 45% at 18% 22%, rgba(212, 192, 161, 0.16), transparent 55%),
    radial-gradient(ellipse 45% 40% at 82% 12%, rgba(154, 132, 98, 0.12), transparent 50%),
    radial-gradient(ellipse 50% 50% at 60% 80%, rgba(212, 192, 161, 0.08), transparent 55%);
  animation: meshDrift 22s ease-in-out infinite alternate;
}

.hero-grain {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: 0.045;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  mix-blend-mode: soft-light;
}

@keyframes meshDrift {
  from { transform: translate3d(0, 0, 0) scale(1); }
  to { transform: translate3d(-2%, -3%, 0) scale(1.06); }
}

.hero-section > *:not(.hero-mesh):not(.hero-grain) {
  position: relative;
  z-index: 1;
}

/* Override theme.css hero keyframes when JS motion is active */
html.js-motion .hero-kicker,
html.js-motion .page-hero-lede,
html.js-motion .hero-actions,
html.js-motion .status-rows,
html.js-motion .name-line,
html.js-motion .intro-copy {
  animation: none !important;
}

html.js-motion .name-line {
  transform: none;
  overflow: visible;
}

html.js-motion .intro-copy {
  opacity: 1;
  transform: none;
}

html.hero-ready .hero-kicker,
html.hero-ready .page-hero-lede,
html.hero-ready .hero-actions,
html.hero-ready .status-rows,
html.hero-ready .site-nav-shell {
  opacity: 1 !important;
  visibility: visible !important;
  transform: none !important;
}

.display-name,
.name-line {
  perspective: 1200px;
}

/* Neutralize theme.css opacity:0 gate — GSAP controls entrance via inline styles */
html.gsap-ready .project-card,
html.gsap-ready .service-card,
html.gsap-ready .blog-card,
html.gsap-ready .resume-card,
html.gsap-ready .skill-card {
  transition: border-color 0.3s ease, background 0.3s ease, box-shadow 0.35s ease;
  visibility: visible;
}

html.gsap-ready .project-card.motion-pending,
html.gsap-ready .service-card.motion-pending,
html.gsap-ready .blog-card.motion-pending,
html.gsap-ready .skill-card.motion-pending,
html.gsap-ready .resume-card:not(.is-in) {
  opacity: 0;
  transform: translateY(28px) scale(0.98);
}

html.gsap-ready .project-card.is-in,
html.gsap-ready .service-card.is-in,
html.gsap-ready .blog-card.is-in,
html.gsap-ready .resume-card.is-in,
html.gsap-ready .skill-card.is-in {
  opacity: 1 !important;
  transform: none !important;
  visibility: visible !important;
}

html.js-motion .split-word-inner,
html.js-motion .split-line-inner {
  will-change: transform, opacity, filter;
}

/* ── Split text wrappers ── */
.split-char,
.split-word,
.split-line {
  display: inline-block;
  overflow: hidden;
  vertical-align: top;
}

.split-word { margin-right: 0.28em; }

.split-line {
  display: block;
  margin-bottom: 0.65em;
}

.split-char-inner,
.split-word-inner,
.split-line-inner {
  display: inline-block;
  will-change: transform, opacity, filter;
}

/* ── Scroll progress ── */
.scroll-progress {
  position: fixed;
  top: 0;
  left: 0;
  height: 2px;
  width: 100%;
  z-index: 10001;
  pointer-events: none;
  transform-origin: left center;
  transform: scaleX(0);
  background: linear-gradient(90deg, #9a8462, #d4c0a1);
}

/* ── Custom cursor ── */
.has-custom-cursor,
.has-custom-cursor body.theme-editorial {
  cursor: none;
}

.cursor-dot {
  position: fixed;
  top: 0;
  left: 0;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #f4efe6;
  mix-blend-mode: difference;
  pointer-events: none;
  z-index: 10003;
  will-change: transform;
}

/* ── Nav scroll state ── */
.site-nav-shell.nav-scrolled {
  backdrop-filter: blur(18px) saturate(1.15);
  -webkit-backdrop-filter: blur(18px) saturate(1.15);
}

.site-nav-shell .main-nav,
.site-nav-shell .nav-tabs-wrap {
  transition: padding 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

.site-nav-shell.nav-scrolled .main-nav {
  padding-top: 0.35rem;
  padding-bottom: 0.35rem;
}

.site-nav-shell .nav-tabs a {
  position: relative;
}

.site-nav-shell .nav-tabs a::after {
  content: '';
  position: absolute;
  left: 0;
  bottom: -2px;
  width: 100%;
  height: 1px;
  background: #d4c0a1;
  transform: scaleX(0);
  transform-origin: left center;
  transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

.site-nav-shell .nav-tabs a:hover::after,
.site-nav-shell .nav-tabs a.active::after {
  transform: scaleX(1);
}

.nav-avatar-img {
  will-change: clip-path, transform;
}

/* ── Stats bars ── */
.bar-fill[data-bar-fill] {
  width: 100% !important;
  transform: scaleX(0);
  transform-origin: left center;
}

[data-clip-reveal] {
  will-change: clip-path;
}

[data-tilt] {
  transform-style: preserve-3d;
  will-change: transform;
}

/* ── Timeline ── */
[data-scrub-timeline] {
  position: relative;
  padding-left: 1.25rem;
}

.timeline-line {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 2px;
  background: linear-gradient(180deg, #d4c0a1, rgba(212, 192, 161, 0.12));
  transform: scaleY(0);
  transform-origin: top center;
}

[data-scrub-timeline] .resume-card {
  position: relative;
  z-index: 1;
}

/* ── Hover micro-interactions ── */
.btn-primary,
.btn-ghost,
.blog-read-more,
.blog-view-all-btn {
  position: relative;
  overflow: hidden;
  isolation: isolate;
}

.btn-primary::before,
.btn-ghost::before,
.blog-read-more::before {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(244, 239, 230, 0.12);
  transform: translateX(-101%);
  transition: transform 0.45s cubic-bezier(0.16, 1, 0.3, 1);
  z-index: -1;
}

.btn-primary:hover::before,
.btn-ghost:hover::before,
.blog-card-link:hover .blog-read-more::before {
  transform: translateX(0);
}

.btn-primary i,
.btn-ghost i {
  display: inline-block;
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.btn-primary:hover i,
.btn-ghost:hover i {
  transform: translate3d(5px, 0, 0);
}

.blog-read-more i {
  display: inline-block;
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.blog-card-link:hover .blog-read-more i {
  transform: translate3d(6px, 0, 0);
}

.project-card:hover,
.service-card:hover,
.blog-card:hover {
  box-shadow: 0 20px 48px rgba(0, 0, 0, 0.38);
}

.project-card .project-cover {
  overflow: hidden;
}

/* ── Contact form ── */
[data-float-field] {
  position: relative;
  padding-top: 0.25rem;
}

[data-float-field] label {
  transition: color 0.25s ease, transform 0.25s ease;
}

[data-float-field]:focus-within label {
  color: #d4c0a1;
  transform: translateY(-2px);
}

[data-float-field]::after {
  content: '';
  position: absolute;
  left: 0;
  bottom: 0;
  width: 100%;
  height: 2px;
  background: #d4c0a1;
  transform: scaleX(0);
  transform-origin: left center;
  transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

[data-float-field]:focus-within::after {
  transform: scaleX(1);
}

[data-float-field]:focus-within input,
[data-float-field]:focus-within textarea {
  box-shadow: 0 0 0 3px rgba(212, 192, 161, 0.12);
}

.submit-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  width: fit-content !important;
  min-width: 0;
}

.submit-check {
  width: 1.1em;
  height: 1.1em;
  opacity: 0;
  transform: scale(0.5);
}

.submit-check path {
  stroke-dasharray: 24;
  stroke-dashoffset: 24;
  transition: stroke-dashoffset 0.5s ease 0.1s;
}

.submit-btn.is-sending .submit-label { opacity: 0.6; }

.submit-btn.is-success {
  background: #c8e0b0 !important;
  border-color: #c8e0b0 !important;
}

.submit-btn.is-success .submit-check {
  opacity: 1;
  transform: scale(1);
}

.submit-btn.is-success .submit-check path { stroke-dashoffset: 0; }

.submit-btn.is-success .submit-label {
  opacity: 0;
  position: absolute;
}

/* ── Lenis ── */
html.lenis, html.lenis body { height: auto; }
html.lenis.lenis-smooth { scroll-behavior: auto !important; }

/* ── Unified stats card + hero (mobile matches laptop editorial theme) ── */
html.js-motion .project-summary-card,
html.gsap-ready .project-summary-card {
  background:
    radial-gradient(circle at 12% 0%, rgba(212, 192, 161, 0.16), transparent 42%),
    var(--card-background) !important;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
  border: 1px solid rgba(244, 239, 230, 0.1) !important;
  border-radius: 18px !important;
  box-shadow: none !important;
  opacity: 1 !important;
  transform: none !important;
  animation: none !important;
  max-width: none !important;
  width: 100% !important;
  margin-left: 0 !important;
  margin-right: 0 !important;
  overflow: hidden;
}

html.js-motion .project-summary-card::before {
  background: linear-gradient(135deg, rgba(212, 192, 161, 0.45), rgba(212, 192, 161, 0.05)) !important;
}

html.js-motion .psc-shimmer,
html.js-motion .psc-ambient {
  display: block !important;
}

html.js-motion .psc-orb--1 { background: rgba(212, 192, 161, 0.18) !important; }
html.js-motion .psc-orb--2 { background: rgba(154, 132, 98, 0.16) !important; }
html.js-motion .psc-orb--3 { background: rgba(212, 192, 161, 0.1) !important; }

html.js-motion .project-summary-card .tech-label,
html.js-motion .project-summary-card .bar-count {
  color: #e7e1d6 !important;
}

html.js-motion .project-summary-card .bar-bg {
  background: rgba(244, 239, 230, 0.06) !important;
  border-color: rgba(212, 192, 161, 0.15) !important;
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.2) !important;
}

html.js-motion .hero-section.page-section {
  background: transparent !important;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
  border: none !important;
  box-shadow: none !important;
}

html.js-motion .loader-overlay {
  background: var(--chess-dark) !important;
}

html.hero-ready .split-char-inner,
html.hero-ready .split-word-inner {
  opacity: 1 !important;
  transform: none !important;
  filter: none !important;
}

html.hero-ready .intro-curtain,
html.hero-ready .loader-overlay {
  display: none !important;
  opacity: 0 !important;
  visibility: hidden !important;
  pointer-events: none !important;
}

/* ── Reduced motion ── */
@media (prefers-reduced-motion: reduce) {
  .intro-curtain, .hero-mesh, .scroll-progress, .cursor-dot { display: none !important; }
  .hero-mesh { animation: none; }
}

html.motion-reduced [data-clip-reveal],
html.motion-reduced .skill-card,
html.motion-reduced .status-card,
html.motion-reduced .resume-card,
html.motion-reduced .project-card,
html.motion-reduced .service-card,
html.motion-reduced .blog-card {
  opacity: 1 !important;
  transform: none !important;
  clip-path: none !important;
  filter: none !important;
}

@media (hover: none), (pointer: coarse) {
  .cursor-dot { display: none !important; }
  body.theme-editorial { cursor: auto; }
  [data-tilt] { transform: none !important; }
}

/* Mobile hero — no cream/yellow mesh card behind intro block */
@media (max-width: 768px) {
  .hero-section .hero-mesh,
  .hero-section .hero-grain {
    display: none !important;
  }

  #about.hero-section,
  .hero-section.page-section {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    border-radius: 0 !important;
    overflow: visible;
  }

  #about {
    margin-top: 0 !important;
    padding-top: 0 !important;
  }

  .hero-section.page-section {
    padding-left: 0 !important;
    padding-right: 0 !important;
    padding-top: 0.5rem !important;
  }
}
