/* Ninth Fall — site-wide maison motion kit */

:root {
  --nf-ease: cubic-bezier(0.22, 1, 0.36, 1);
  --nf-ease-soft: cubic-bezier(0.33, 1, 0.68, 1);
  --nf-duration: 1.05s;
  --nf-duration-slow: 1.35s;
}

@media (prefers-reduced-motion: reduce) {
  .nf-reveal,
  .nf-reveal-child,
  .nf-line,
  .nf-hero-polish,
  .nf-parallax-img,
  .nf-page-enter,
  header.nf-header-elevated,
  .nf-journey-pulse {
    opacity: 1 !important;
    transform: none !important;
    filter: none !important;
    transition: none !important;
    animation: none !important;
  }

  .nf-progress {
    display: none !important;
  }
}

/* ---------- Page enter ---------- */
.nf-page-enter main {
  opacity: 0;
  transform: translate3d(0, 18px, 0);
  animation: nf-page-in 1.05s var(--nf-ease) 0.08s forwards;
}

@keyframes nf-page-in {
  to {
    opacity: 1;
    transform: translate3d(0, 0, 0);
  }
}

/* ---------- Header elevate on scroll ---------- */
header {
  transition:
    background-color 0.45s var(--nf-ease),
    backdrop-filter 0.45s var(--nf-ease),
    box-shadow 0.45s var(--nf-ease),
    border-color 0.45s var(--nf-ease),
    padding 0.45s var(--nf-ease);
}

header.nf-header-elevated {
  backdrop-filter: blur(18px) saturate(1.1);
  -webkit-backdrop-filter: blur(18px) saturate(1.1);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.06);
}

header.nf-header-elevated[class*="text-white"] {
  background: rgba(10, 10, 10, 0.72) !important;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

header.nf-header-elevated[class*="text-black"],
header.nf-header-elevated[class*="bg-white"] {
  background: rgba(255, 255, 255, 0.94) !important;
  border-bottom-color: rgba(0, 0, 0, 0.07);
}

/* Light header utility hover — white/10 is invisible on white bars */
header[class*="bg-white"] button[aria-label],
header[class*="text-black"] button[aria-label] {
  transition: background-color 0.25s var(--nf-ease);
}

header[class*="bg-white"] button[aria-label]:hover,
header[class*="text-black"] button[aria-label]:hover {
  background-color: rgba(0, 0, 0, 0.05) !important;
}

/* Nav underline polish */
header .nav-link-line {
  transition: transform 0.45s var(--nf-ease) !important;
}

header .nav-link:hover .nav-link-line {
  transform: scaleX(1) !important;
}

/* Brand emblem before NINTH FALL wordmark */
header a.nf-brand-link,
header a[href="/"].nf-brand-link {
  display: inline-flex !important;
  align-items: center;
  gap: 0.55rem;
  white-space: nowrap !important;
  flex-wrap: nowrap !important;
  max-width: none;
}

header a.nf-brand-link,
header a[href="/"] {
  white-space: nowrap !important;
}

header .nf-brand-logo {
  display: block;
  width: 1.85rem;
  height: 1.85rem;
  object-fit: contain;
  object-position: center;
  background: transparent !important;
  mix-blend-mode: normal;
  flex-shrink: 0;
  image-rendering: auto;
  -ms-interpolation-mode: bicubic;
  /* Soft platinum — less glow, more maison */
  filter:
    brightness(1.06)
    contrast(1.05)
    drop-shadow(0 0 0.4px rgba(255, 255, 255, 0.4))
    drop-shadow(0 1px 2px rgba(0, 0, 0, 0.35))
    drop-shadow(0 3px 10px rgba(0, 0, 0, 0.18));
  transition:
    filter 0.45s ease,
    transform 0.45s ease;
}

header a.nf-brand-link:hover .nf-brand-logo {
  transform: scale(1.03);
  filter:
    brightness(1.1)
    contrast(1.06)
    drop-shadow(0 0 0.6px rgba(255, 255, 255, 0.5))
    drop-shadow(0 2px 3px rgba(0, 0, 0, 0.32))
    drop-shadow(0 4px 12px rgba(0, 0, 0, 0.2));
}

/* Light / elevated header — keep chrome crisp without heavy glow */
header[class*="text-black"] .nf-brand-logo,
header.nf-header-elevated[class*="bg-white"] .nf-brand-logo {
  filter:
    brightness(1.02)
    contrast(1.08)
    drop-shadow(0 0 0.4px rgba(255, 255, 255, 0.35))
    drop-shadow(0 1px 3px rgba(0, 0, 0, 0.16))
    drop-shadow(0 3px 10px rgba(0, 0, 0, 0.1));
}

header[class*="text-black"] a.nf-brand-link:hover .nf-brand-logo,
header.nf-header-elevated[class*="bg-white"] a.nf-brand-link:hover .nf-brand-logo {
  filter:
    brightness(1.06)
    contrast(1.1)
    drop-shadow(0 0 0.6px rgba(255, 255, 255, 0.45))
    drop-shadow(0 2px 5px rgba(0, 0, 0, 0.18))
    drop-shadow(0 4px 12px rgba(0, 0, 0, 0.12));
}

@media (min-width: 640px) {
  header .nf-brand-logo {
    width: 2.15rem;
    height: 2.15rem;
  }
}

@media (max-width: 480px) {
  header .nf-brand-logo {
    width: 1.5rem;
    height: 1.5rem;
  }

  header a.nf-brand-link,
  header a[href="/"].nf-brand-link,
  header a[href="/"] {
    gap: 0.35rem;
    white-space: nowrap !important;
    letter-spacing: 0.16em !important;
    font-size: clamp(0.78rem, 3.6vw, 0.95rem) !important;
  }
}

/* ---------- Homepage hero entrance ---------- */
html.nf-home main > section:first-child .fade-in > * {
  opacity: 0;
  transform: translateY(28px);
  animation: nf-hero-rise var(--nf-duration-slow) var(--nf-ease) forwards;
}

html.nf-home main > section:first-child .fade-in > *:nth-child(1) { animation-delay: 0.12s; }
html.nf-home main > section:first-child .fade-in > *:nth-child(2) { animation-delay: 0.28s; }
html.nf-home main > section:first-child .fade-in > *:nth-child(3) { animation-delay: 0.42s; }
html.nf-home main > section:first-child .fade-in > *:nth-child(4) { animation-delay: 0.56s; }
html.nf-home main > section:first-child .fade-in > *:nth-child(5) { animation-delay: 0.72s; }

html.nf-home main > section:first-child aside {
  opacity: 0;
  transform: translateX(24px);
  animation: nf-hero-side 1.2s var(--nf-ease) 0.55s forwards;
}

html.nf-home main > section:first-child .grain img {
  transform: scale(1.08);
  animation: nf-kenburns 18s var(--nf-ease-soft) infinite alternate;
}

@keyframes nf-hero-rise {
  to { opacity: 1; transform: translateY(0); }
}

@keyframes nf-hero-side {
  to { opacity: 1; transform: translateX(0); }
}

@keyframes nf-kenburns {
  from { transform: scale(1.08) translate3d(0, 0, 0); }
  to { transform: scale(1.14) translate3d(-1.5%, -1%, 0); }
}

/* Journey marker pulse */
.nf-journey-pulse {
  animation: nf-pulse 2.4s var(--nf-ease-soft) infinite;
}

@keyframes nf-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255, 255, 255, 0.35); }
  50% { box-shadow: 0 0 0 6px rgba(255, 255, 255, 0); }
}

/* ---------- Scroll reveal base ---------- */
.nf-reveal {
  opacity: 0;
  transform: translate3d(0, 48px, 0);
  filter: blur(2px);
  transition:
    opacity var(--nf-duration) var(--nf-ease),
    transform var(--nf-duration) var(--nf-ease),
    filter var(--nf-duration) var(--nf-ease);
  will-change: opacity, transform, filter;
}

.nf-reveal.is-inview {
  opacity: 1;
  transform: translate3d(0, 0, 0);
  filter: blur(0);
}

.nf-reveal[data-nf="fade"] {
  transform: none;
  filter: none;
}

.nf-reveal[data-nf="left"] {
  transform: translate3d(-40px, 0, 0);
  filter: none;
}

.nf-reveal[data-nf="right"] {
  transform: translate3d(40px, 0, 0);
  filter: none;
}

.nf-reveal[data-nf="scale"] {
  transform: scale(0.96);
  filter: none;
}

.nf-reveal[data-nf="clip"] {
  transform: none;
  filter: none;
  clip-path: inset(8% 8% 8% 8%);
  transition:
    opacity var(--nf-duration) var(--nf-ease),
    clip-path var(--nf-duration-slow) var(--nf-ease);
}

.nf-reveal[data-nf="clip"].is-inview {
  clip-path: inset(0 0 0 0);
}

/* Staggered children */
.nf-stagger > .nf-reveal-child {
  opacity: 0;
  transform: translate3d(0, 36px, 0);
  transition:
    opacity 0.9s var(--nf-ease),
    transform 0.9s var(--nf-ease);
}

.nf-stagger.is-inview > .nf-reveal-child {
  opacity: 1;
  transform: translate3d(0, 0, 0);
}

.nf-stagger.is-inview > .nf-reveal-child:nth-child(1) { transition-delay: 0.05s; }
.nf-stagger.is-inview > .nf-reveal-child:nth-child(2) { transition-delay: 0.14s; }
.nf-stagger.is-inview > .nf-reveal-child:nth-child(3) { transition-delay: 0.23s; }
.nf-stagger.is-inview > .nf-reveal-child:nth-child(4) { transition-delay: 0.32s; }
.nf-stagger.is-inview > .nf-reveal-child:nth-child(5) { transition-delay: 0.41s; }
.nf-stagger.is-inview > .nf-reveal-child:nth-child(6) { transition-delay: 0.5s; }
.nf-stagger.is-inview > .nf-reveal-child:nth-child(7) { transition-delay: 0.59s; }
.nf-stagger.is-inview > .nf-reveal-child:nth-child(8) { transition-delay: 0.68s; }
.nf-stagger.is-inview > .nf-reveal-child:nth-child(9) { transition-delay: 0.77s; }

/* Hairline rules */
.nf-line {
  transform: scaleX(0);
  transform-origin: center;
  transition: transform 1.15s var(--nf-ease);
}

.nf-line.is-inview {
  transform: scaleX(1);
}

/* Quote emphasis (homepage) */
html.nf-home main > section:nth-of-type(2) blockquote p {
  letter-spacing: 0.03em;
}

html.nf-home main > section:nth-of-type(2).is-inview blockquote p {
  animation: nf-quote-in 1.2s var(--nf-ease) both;
}

@keyframes nf-quote-in {
  from {
    opacity: 0;
    transform: translateY(24px);
    letter-spacing: 0.12em;
  }
  to {
    opacity: 1;
    transform: translateY(0);
    letter-spacing: 0.03em;
  }
}

/* Product / chapter / journal hover polish */
main article.group [class*="aspect-"],
main a.group [class*="aspect-"] {
  transition: transform 0.9s var(--nf-ease), box-shadow 0.9s var(--nf-ease);
}

main article.group:hover [class*="aspect-"],
main a.group:hover [class*="aspect-"] {
  transform: translateY(-6px);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.12);
}

main .img-zoom {
  transition: transform 1.1s var(--nf-ease), filter 0.8s var(--nf-ease) !important;
}

main a.group:hover .img-zoom,
main article.group:hover .img-zoom {
  transform: scale(1.06);
  filter: grayscale(0.35) contrast(1.05);
}

/* Parallax accents */
.nf-parallax-img {
  transition: transform 0.2s linear;
  will-change: transform;
}

/* CTA sheen — primary maison actions */
main a.btn-ghost,
main a[href*="/collections"],
main a[href*="/shop"],
main a[class*="bg-[#f3efe8]"],
main a[class*="bg-black"] {
  position: relative;
  overflow: hidden;
  transition: transform 0.35s var(--nf-ease), opacity 0.35s var(--nf-ease);
}

main a.btn-ghost:hover,
main a[class*="bg-[#f3efe8]"]:hover,
main a[class*="bg-black"]:hover {
  transform: translateY(-1px);
}

main a.btn-ghost:active,
main a[class*="bg-[#f3efe8]"]:active,
main a[class*="bg-black"]:active {
  transform: scale(0.985);
}

main a[class*="bg-[#f3efe8]"]::after,
main a.btn-ghost.bg-black::after,
main a[class*="bg-black text-white"]::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    105deg,
    transparent 35%,
    rgba(255, 255, 255, 0.28) 50%,
    transparent 65%
  );
  transform: translateX(-120%);
  transition: transform 0.9s var(--nf-ease);
  pointer-events: none;
}

main a[class*="bg-[#f3efe8]"]:hover::after,
main a.btn-ghost.bg-black:hover::after,
main a[class*="bg-black text-white"]:hover::after {
  transform: translateX(120%);
}

/* Scroll progress bar */
.nf-progress {
  position: fixed;
  top: 0;
  left: 0;
  height: 2px;
  width: 0%;
  z-index: 100;
  background: linear-gradient(90deg, #1a1a1a, #c8b8a0, #1a1a1a);
  pointer-events: none;
  transition: width 0.08s linear;
}

/* Detail page title polish */
main h1 {
  transition: letter-spacing 1.1s var(--nf-ease);
}

main .nf-reveal.is-inview h1,
main h1.nf-reveal.is-inview {
  letter-spacing: 0.08em;
}

@supports (animation-timeline: view()) {
  @media (prefers-reduced-motion: no-preference) {
    main a.group .img-zoom,
    main article.group .img-zoom {
      animation: nf-img-settle linear both;
      animation-timeline: view();
      animation-range: entry 10% cover 40%;
    }
  }
}

@keyframes nf-img-settle {
  from {
    transform: scale(1.08);
    filter: grayscale(1) brightness(0.92);
  }
  to {
    transform: scale(1);
    filter: grayscale(1) brightness(1);
  }
}
