/* ==========================================================================
   CINEMA LAYER — Grain, lighting, depth, scroll progress, cursor
   Apple / Tesla / BMW aesthetic
   ========================================================================== */

/* --- Global film grain --- */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 9998;
  pointer-events: none;
  opacity: 0.035;
  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: overlay;
}

/* --- Scroll progress (Tesla-style) --- */
.scroll-progress {
  position: fixed;
  top: 0;
  left: 0;
  height: 2px;
  width: 0%;
  z-index: var(--z-scroll-progress);
  background: linear-gradient(90deg, var(--brand-red-deep), var(--brand-red-bright), var(--brand-champagne));
  box-shadow: 0 0 12px var(--brand-red-glow);
  transition: width 0.08s linear;
  pointer-events: none;
}

/* --- Cursor ambient light (desktop) --- */
.cursor-glow {
  position: fixed;
  width: 480px;
  height: 480px;
  border-radius: 50%;
  pointer-events: none;
  z-index: var(--z-cursor-glow);
  background: radial-gradient(circle, var(--brand-red-subtle) 0%, transparent 65%);
  transform: translate(-50%, -50%);
  opacity: 0;
  transition: opacity 0.4s ease;
  mix-blend-mode: screen;
  filter: blur(40px);
}

html.has-cursor-glow .cursor-glow {
  opacity: 1;
}

html.is-menu-open .cursor-glow,
html.is-loading .cursor-glow {
  opacity: 0 !important;
}

/* --- Hero cinema stack --- */
.hero__grain {
  position: absolute;
  inset: 0;
  z-index: var(--z-grain);
  opacity: 0.06;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 512 512' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='g'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.7' numOctaves='3'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23g)'/%3E%3C/svg%3E");
  pointer-events: none;
  mix-blend-mode: soft-light;
}

.hero__beam {
  position: absolute;
  top: -20%;
  right: -10%;
  width: 70vw;
  height: 80vh;
  z-index: var(--z-hero-fx);
  background: radial-gradient(ellipse at 60% 40%, var(--light-ambient-red) 0%, transparent 55%);
  pointer-events: none;
  animation: beamDrift 12s var(--ease-in-out-smooth) infinite alternate;
}

.hero__shine {
  position: absolute;
  inset: 0;
  z-index: var(--z-hero-fx);
  background: linear-gradient(
    105deg,
    transparent 0%,
    rgba(255, 255, 255, 0.03) 45%,
    transparent 55%
  );
  background-size: 200% 100%;
  animation: shineSweep 8s var(--ease-in-out-smooth) infinite;
  pointer-events: none;
}

.hero__horizon {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 40%;
  z-index: var(--z-hero-fx);
  background: linear-gradient(to top, var(--brand-black) 0%, transparent 100%);
  pointer-events: none;
}

@media (prefers-reduced-motion: no-preference) {
  .hero__media img {
    animation: kenBurns 28s var(--ease-in-out-smooth) infinite alternate;
  }
}

@keyframes kenBurns {
  0% { transform: scale(1.06) translate(0, 0); }
  100% { transform: scale(1.12) translate(-1%, -0.5%); }
}

@keyframes beamDrift {
  0% { transform: translate(0, 0) scale(1); opacity: 0.7; }
  100% { transform: translate(-4%, 3%) scale(1.05); opacity: 1; }
}

@keyframes shineSweep {
  0%, 100% { background-position: 200% 0; }
  50% { background-position: -100% 0; }
}

/* Hero title — word stagger */
.hero__title {
  max-width: none;
  font-weight: var(--font-weight-semibold);
  letter-spacing: var(--tracking-tighter);
}

.hero__line {
  display: block;
  overflow: hidden;
}

.hero__line .word {
  display: inline-block;
  opacity: 0;
  transform: translateY(110%);
}

.hero.is-ready .hero__line .word {
  animation: wordRise var(--duration-cinematic) var(--ease-out-expo) forwards;
}

.hero.is-ready .hero__line:nth-child(1) .word:nth-child(1) { animation-delay: 0.15s; }
.hero.is-ready .hero__line:nth-child(1) .word:nth-child(2) { animation-delay: 0.22s; }
.hero.is-ready .hero__line:nth-child(2) .word { animation-delay: 0.35s; }
.hero.is-ready .hero__line:nth-child(3) .word:nth-child(1) { animation-delay: 0.48s; }
.hero.is-ready .hero__line:nth-child(3) .word:nth-child(2) { animation-delay: 0.55s; }
.hero.is-ready .hero__line:nth-child(3) .word:nth-child(3) { animation-delay: 0.62s; }
.hero.is-ready .hero__line:nth-child(3) .word:nth-child(4) { animation-delay: 0.7s; }
.hero.is-ready .hero__line:nth-child(3) .word:nth-child(5) { animation-delay: 0.78s; }

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

.hero__title .line-accent-text {
  font-weight: var(--font-weight-light);
  background: linear-gradient(
    120deg,
    var(--brand-white) 0%,
    var(--brand-champagne) 40%,
    var(--brand-red-bright) 100%
  );
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* --- Glass with saturation (Apple vibrancy) --- */
.glass {
  backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturate));
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturate));
}

/* --- Cards: rim light + depth on hover --- */
.card,
.service-card,
.ba-card,
.metric,
.testimonial {
  transform-style: preserve-3d;
  perspective: var(--perspective);
}

.card::before,
.service-card::before,
.ba-card::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  padding: 1px;
  background: linear-gradient(
    145deg,
    var(--light-rim) 0%,
    transparent 40%,
    transparent 60%,
    rgba(255, 255, 255, 0.03) 100%
  );
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  pointer-events: none;
  opacity: 0.6;
  transition: opacity var(--duration-base);
}

.card:hover::before,
.service-card:hover::before,
.ba-card:hover::before {
  opacity: 1;
}

/* --- Buttons: BMW precision depth --- */
.btn--primary {
  position: relative;
  box-shadow:
    0 1px 0 var(--light-specular) inset,
    0 8px 32px var(--brand-red-glow),
    0 2px 8px rgba(0, 0, 0, 0.4);
}

.btn--ghost {
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

/* Magnetic hover lift */
.btn.is-magnetic-ready {
  transition: transform 0.35s var(--ease-out-expo), box-shadow 0.35s ease;
}

/* --- Section scrub (scroll depth) --- */
[data-scrub] {
  --scrub-opacity: 1;
  --scrub-y: 0px;
  --scrub-scale: 1;
  opacity: var(--scrub-opacity);
  transform: translateY(var(--scrub-y)) scale(var(--scrub-scale));
  will-change: transform, opacity;
  transition: none;
}

/* Trust bar integrada em .site-top — ver 03-components.css */

/* --- Gallery: cinematic hover --- */
.ba-card__compare {
  transition: transform var(--duration-slow) var(--ease-out-expo);
}

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

.ba-card__compare::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, transparent 60%, rgba(0, 0, 0, 0.5) 100%);
  pointer-events: none;
  z-index: 3;
  opacity: 0.6;
  transition: opacity var(--duration-base);
}

.ba-card:hover .ba-card__compare::after {
  opacity: 0.85;
}

/* --- Timeline: connected luxury line (desktop) --- */
@media (min-width: 992px) {
  .timeline {
    position: relative;
  }

  .timeline::after {
    content: "";
    position: absolute;
    top: 28px;
    left: 10%;
    right: 10%;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--brand-border-strong), transparent);
    z-index: 0;
  }

  .timeline__item {
    position: relative;
    z-index: 1;
  }
}

/* --- Loader: minimal Apple --- */
.loader {
  background: var(--brand-black);
}

.loader__brand {
  font-weight: var(--font-weight-medium);
  letter-spacing: 0.35em;
  font-size: var(--text-sm);
}

/* --- Header: ultra minimal --- */
.site-top.is-scrolled .header {
  box-shadow: none;
}

/* --- Scroll-driven reveals (modern browsers) --- */
@supports (animation-timeline: view()) {
  .reveal-timeline {
    opacity: 0;
    transform: translateY(48px);
    animation: revealTimeline linear both;
    animation-timeline: view();
    animation-range: entry 5% cover 35%;
  }

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

/* --- Reduced motion --- */
@media (prefers-reduced-motion: reduce) {
  .hero__media img,
  .hero__beam,
  .hero__shine,
  .trust-bar,
  .trust-pill {
    animation: none !important;
  }

  .hero__line .word {
    opacity: 1;
    transform: none;
  }

  body::before {
    display: none;
  }
}
