/*
 * Sebas Granda Automotive — Del plano a la presencia
 * Home-only atmospheric WebGL layer. The canvas never receives pointer input.
 */

.sg-construction-3d {
  --sg3d-opacity: 0;
  --sg3d-poster-opacity: 1;
  --sg3d-canvas-opacity: 0;
  position: fixed;
  z-index: 1;
  inset: 0;
  width: 100vw;
  height: 100dvh;
  overflow: hidden;
  pointer-events: none;
  opacity: var(--sg3d-opacity);
  contain: strict;
  isolation: isolate;
  transition: opacity 500ms ease;
}

.sg-construction-3d::before,
.sg-construction-3d::after {
  content: "";
  position: absolute;
  z-index: 4;
  inset: 0;
  pointer-events: none;
}

.sg-construction-3d::before {
  background:
    linear-gradient(90deg, rgba(5, 6, 6, .68) 0%, rgba(5, 6, 6, .12) 28%, rgba(5, 6, 6, .05) 70%, rgba(5, 6, 6, .54) 100%),
    linear-gradient(180deg, rgba(5, 6, 6, .5) 0%, transparent 25%, transparent 67%, rgba(5, 6, 6, .78) 100%);
}

.sg-construction-3d::after {
  opacity: .72;
  background: radial-gradient(ellipse at 52% 56%, transparent 15%, rgba(5, 6, 6, .1) 48%, rgba(5, 6, 6, .72) 100%);
}

.sg-construction-3d__poster,
.sg-construction-3d__poster img,
.sg-construction-3d__canvas,
.sg-construction-3d__technical {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.sg-construction-3d__poster {
  z-index: 1;
  opacity: var(--sg3d-poster-opacity);
  transition: opacity 720ms cubic-bezier(.22, .78, .24, 1);
}

.sg-construction-3d__poster img {
  object-fit: cover;
  object-position: center;
  filter: saturate(.76) contrast(1.08) brightness(.8);
}

.sg-construction-3d__canvas {
  z-index: 2;
  display: block;
  opacity: var(--sg3d-canvas-opacity);
  filter: saturate(.88) contrast(1.04);
  transition: opacity 720ms cubic-bezier(.22, .78, .24, 1);
}

.sg-construction-3d__technical {
  z-index: 3;
  opacity: .22;
  background:
    linear-gradient(90deg, transparent 49.92%, rgba(205,188,146,.18) 50%, transparent 50.08%),
    linear-gradient(180deg, transparent 49.92%, rgba(205,188,146,.1) 50%, transparent 50.08%);
  mask-image: radial-gradient(ellipse at center, #000 0 34%, transparent 72%);
}

.sg-construction-3d.is-live {
  --sg3d-poster-opacity: 0;
  --sg3d-canvas-opacity: 1;
}

.sg-construction-3d.is-fallback,
.sg-construction-3d.is-reduced {
  --sg3d-poster-opacity: 1;
  --sg3d-canvas-opacity: 0;
}

.sg-construction-3d.is-fallback .sg-construction-3d__poster img,
.sg-construction-3d.is-reduced .sg-construction-3d__poster img {
  object-fit: cover;
  filter: saturate(.78) contrast(1.1) brightness(.82);
}

.sg-construction-copy {
  position: fixed;
  z-index: 4;
  left: clamp(22px, 5vw, 82px);
  top: clamp(112px, 18vh, 210px);
  width: min(520px, calc(100vw - 44px));
  padding: 24px 28px 26px;
  pointer-events: none;
  opacity: 0;
  transform: translate3d(0, 18px, 0);
  background: linear-gradient(90deg, rgba(5,6,6,.78), rgba(5,6,6,.42) 66%, transparent);
  transition: opacity 180ms linear, transform 420ms cubic-bezier(.22,.78,.24,1);
}

.sg-construction-copy.is-visible {
  transform: none;
}

.sg-construction-copy--final {
  top: auto;
  bottom: clamp(105px, 15vh, 178px);
}

.sg-construction-copy__eyebrow {
  display: block;
  margin-bottom: 13px;
  color: var(--home-champagne, #cdbc92);
  font-size: .58rem;
  font-weight: 680;
  letter-spacing: .3em;
  text-transform: uppercase;
}

.sg-construction-copy strong {
  display: block;
  color: var(--home-paper, #f3efe6);
  font-family: var(--display, Georgia, serif);
  font-size: clamp(2.35rem, 5vw, 5.7rem);
  font-weight: 400;
  letter-spacing: -.055em;
  line-height: .86;
  text-wrap: balance;
}

.sg-construction-copy small {
  display: block;
  margin-top: 17px;
  color: rgba(243,239,230,.58);
  font-size: .57rem;
  font-weight: 560;
  letter-spacing: .2em;
  text-transform: uppercase;
}

.sg-construction-demo-badge {
  position: fixed;
  z-index: 108;
  top: 50%;
  right: max(16px, env(safe-area-inset-right));
  display: grid;
  gap: 4px;
  min-width: 142px;
  padding: 11px 14px 12px;
  border: 1px solid rgba(243,239,230,.18);
  background: rgba(7,8,8,.74);
  color: var(--home-paper, #f3efe6);
  pointer-events: none;
  transform: translateY(-50%);
  backdrop-filter: blur(16px) saturate(125%);
  box-shadow: 0 16px 45px rgba(0,0,0,.18);
}

.sg-construction-demo-badge::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 2px;
  height: 100%;
  background: linear-gradient(180deg, transparent, var(--home-champagne, #cdbc92), transparent);
}

.sg-construction-demo-badge strong {
  font-size: .57rem;
  font-weight: 740;
  letter-spacing: .28em;
}

.sg-construction-demo-badge span {
  color: rgba(243,239,230,.56);
  font-size: .5rem;
  font-weight: 560;
  letter-spacing: .12em;
  line-height: 1.4;
  text-transform: uppercase;
}

/* The atmospheric canvas may overlap media, never the readable or actionable layer. */
.sg-home.sg-construction-enabled :is(
  .home-header,
  .home-hero__content,
  .hero-index,
  .vehicle-copy,
  .find-drive__intro,
  .drive-options,
  .drive-results,
  .car-moment__content,
  .section-heading,
  .two-step-form,
  .sell-section__content,
  .vault-section__content,
  .about-copy,
  .services,
  .inventory-close > *,
  .final-cta__content,
  .sound-toggle,
  .shortlist-peek
) {
  position: relative;
  z-index: 5;
}

.sg-home.sg-construction-enabled .mobile-menu { z-index: 115; }
.sg-home.sg-construction-enabled .home-header { z-index: 120; }
.sg-home.sg-construction-enabled .sound-toggle,
.sg-home.sg-construction-enabled .shortlist-peek { position: fixed; z-index: 105; }

/* Local contrast protection behind content; no visual blocking or pointer capture. */
.sg-home.sg-construction-enabled .vehicle-copy::before,
.sg-home.sg-construction-enabled .section-heading::before,
.sg-home.sg-construction-enabled .about-copy::before {
  content: "";
  position: absolute;
  z-index: -1;
  inset: -34px -44px;
  pointer-events: none;
  background: radial-gradient(ellipse at center, rgba(7,8,8,.66), rgba(7,8,8,.16) 60%, transparent 78%);
  filter: blur(5px);
}

/* Demo indicator used on the ten individual vehicle pages. */
.sg-vehicle-demo-badge {
  position: fixed;
  z-index: 108;
  right: max(16px, env(safe-area-inset-right));
  bottom: max(18px, env(safe-area-inset-bottom));
  display: grid;
  gap: 4px;
  min-width: 146px;
  padding: 10px 14px 11px;
  border: 1px solid rgba(243,239,230,.18);
  background: rgba(7,8,8,.78);
  color: var(--home-paper, #f3efe6);
  pointer-events: none;
  backdrop-filter: blur(16px) saturate(120%);
  box-shadow: 0 14px 42px rgba(0,0,0,.22);
}

.sg-vehicle-demo-badge strong {
  color: var(--home-champagne, #cdbc92);
  font-size: .55rem;
  font-weight: 720;
  letter-spacing: .27em;
}

.sg-vehicle-demo-badge span {
  color: rgba(243,239,230,.58);
  font-size: .49rem;
  font-weight: 560;
  letter-spacing: .12em;
  line-height: 1.4;
  text-transform: uppercase;
}

@media (max-width: 820px) {
  .sg-construction-3d::before {
    background:
      linear-gradient(180deg, rgba(5,6,6,.55), transparent 26%, transparent 63%, rgba(5,6,6,.82)),
      linear-gradient(90deg, rgba(5,6,6,.42), transparent 44%, rgba(5,6,6,.36));
  }

  .sg-construction-3d__poster img { object-position: center 56%; }

  .sg-construction-copy {
    top: max(94px, calc(env(safe-area-inset-top) + 80px));
    left: 18px;
    width: calc(100vw - 36px);
    padding: 17px 18px 20px;
  }

  .sg-construction-copy--final {
    top: auto;
    bottom: 112px;
  }

  .sg-construction-copy strong {
    max-width: 11ch;
    font-size: clamp(2.2rem, 12.5vw, 4.5rem);
  }

  .sg-construction-demo-badge {
    top: auto;
    right: max(12px, env(safe-area-inset-right));
    bottom: max(66px, calc(env(safe-area-inset-bottom) + 54px));
    min-width: 132px;
    padding: 9px 11px 10px;
    transform: none;
  }

  .sg-construction-demo-badge.is-hero-safe {
    top: max(86px, calc(env(safe-area-inset-top) + 74px));
    bottom: auto;
  }

  .sg-vehicle-demo-badge {
    right: max(12px, env(safe-area-inset-right));
    bottom: max(14px, env(safe-area-inset-bottom));
    min-width: 132px;
    padding: 9px 11px 10px;
  }

  .sg-home.sg-construction-enabled .vehicle-copy::before,
  .sg-home.sg-construction-enabled .section-heading::before,
  .sg-home.sg-construction-enabled .about-copy::before {
    inset: -20px;
    background: radial-gradient(ellipse at center, rgba(7,8,8,.74), rgba(7,8,8,.2) 66%, transparent 84%);
  }
}

@media (forced-colors: active) {
  .sg-construction-3d { display: none !important; }
  .sg-construction-copy { position: static; width: auto; margin: 18px; opacity: 1 !important; transform: none; }
  .sg-construction-demo-badge,
  .sg-vehicle-demo-badge { border: 1px solid CanvasText; background: Canvas; color: CanvasText; forced-color-adjust: auto; }
}

@media (prefers-reduced-motion: reduce) {
  .sg-construction-3d,
  .sg-construction-3d__poster,
  .sg-construction-3d__canvas,
  .sg-construction-copy {
    transition: none !important;
  }

  .sg-construction-copy { transform: none !important; }
}
