/**
 * CGC Luxury — Page Transition v3: Smooth & Visible (all viewports)
 * Fix for "too fast to see on mobile": extend visible time, sync JS wait
 * with CSS animation timeline, add responsive sizing, smoother easing.
 * All effects use transform/opacity only (GPU).
 */

/* Native View Transitions — slightly longer, smoother */
::view-transition-old(root) { animation: cgc-view-old 260ms ease-out both; }
::view-transition-new(root) { animation: cgc-view-new 520ms cubic-bezier(0.25,1,0.5,1) both; }
@keyframes cgc-view-old { to { opacity: 0; } }
@keyframes cgc-view-new { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* Overlay — luxury alabaster, perfectly centered (all viewports), prevents scroll */
.cgc-redirect {
  position: fixed;
  inset: 0;
  top: 0;
  left: 0;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  height: 100svh;
  min-height: 100vh;
  min-height: 100dvh;
  min-height: 100svh;
  z-index: 99999;
  display: grid;
  place-items: center;
  place-content: center;
  align-items: center;
  justify-items: center;
  align-content: center;
  justify-content: center;
  padding: 32px 24px;
  padding-top: max(32px, env(safe-area-inset-top));
  padding-bottom: max(32px, env(safe-area-inset-bottom));
  background: #FAF9F6;
  opacity: 0;
  animation: cgc-redirect-in 380ms cubic-bezier(0.25,1,0.5,1) forwards;
  will-change: opacity;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  box-sizing: border-box;
  isolation: isolate;
}
@keyframes cgc-redirect-in { to { opacity: 1; } }

.cgc-redirect__inner {
  text-align: center;
  max-width: 640px;
  width: 100%;
  max-height: 100%;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  margin: auto;
  box-sizing: border-box;
  overflow: visible;
}

/* Orbit container — responsive, smooth rotation */
.cgc-redirect__orbit {
  position: relative;
  width: 176px;
  height: 176px;
  margin: 0 auto 28px;
  border: 1px solid rgba(212,178,111,0.16);
  border-radius: 50%;
  animation: cgc-orbit-rotate 1100ms cubic-bezier(0.25,1,0.5,1) forwards;
  will-change: transform;
  flex-shrink: 0;
}
@keyframes cgc-orbit-rotate {
  from { transform: rotate(-18deg) scale(0.96); }
  to   { transform: rotate(24deg) scale(1); }
}

/* Icons — positioned around orbit, counter-rotate to stay upright */
.cgc-redirect__icon {
  position: absolute;
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--cgc-gold, #D4B26F);
  background: #FAF9F6;
  border: 1px solid rgba(212,178,111,0.24);
  border-radius: 50%;
  box-shadow: 0 3px 12px rgba(0,0,0,0.06);
  animation: cgc-orbit-counter 1100ms cubic-bezier(0.25,1,0.5,1) forwards;
  will-change: transform;
}
.cgc-redirect__icon svg { width: 22px; height: 22px; }
@keyframes cgc-orbit-counter {
  from { transform: rotate(18deg); }
  to   { transform: rotate(-24deg); }
}
/* Place 5 product icons evenly around ring */
.cgc-redirect__icon--bangles  { left: 50%; top: 0;    transform: translate(-50%, -50%); }
.cgc-redirect__icon--rings    { right: 0; top: 50%;  transform: translate(50%, -50%); }
.cgc-redirect__icon--earrings { left: 50%; bottom: 0; transform: translate(-50%, 50%); }
.cgc-redirect__icon--necklace { left: 0; top: 50%;  transform: translate(-50%, -50%); }
.cgc-redirect__icon--chains   { left: 50%; top: 50%; transform: translate(-50%, -50%) scale(0.9); opacity: 0.9; }

/* Throw — active icon flies to center, luxury pop with overshoot */
.cgc-redirect__icon.is-thrown {
  width: 72px !important;
  height: 72px !important;
  left: 50% !important;
  top: 50% !important;
  transform: translate(-50%, -50%) scale(1) !important;
  animation: cgc-throw-pop 580ms cubic-bezier(0.34,1.56,0.64,1) forwards !important;
  z-index: 10;
  border: 1.5px solid var(--cgc-gold, #D4B26F);
  background: #fff;
  box-shadow: 0 12px 32px rgba(212,178,111,0.30), 0 2px 10px rgba(0,0,0,0.07);
}
.cgc-redirect__icon.is-thrown svg { width: 36px !important; height: 36px !important; }
@keyframes cgc-throw-pop {
  0%   { transform: translate(-50%, -50%) scale(0.68); opacity: 0; }
  60%  { transform: translate(-50%, -50%) scale(1.14); opacity: 1; }
  100% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
}
/* After throw, dim other icons */
.cgc-redirect.is-thrown .cgc-redirect__icon:not(.is-thrown) {
  opacity: 0.22;
  transform: scale(0.86);
  transition: opacity 420ms ease, transform 420ms cubic-bezier(0.25,1,0.5,1);
}
.cgc-redirect.is-thrown .cgc-redirect__orbit {
  border-color: rgba(212,178,111,0.07);
  transition: border-color 420ms ease;
}

/* Label block — timed to appear WITHIN JS wait (1480ms), hold visible */
.cgc-redirect__eyebrow {
  font-family: var(--font-sans, 'Plus Jakarta Sans', system-ui, sans-serif);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--cgc-gold, #D4B26F);
  opacity: 0;
  transform: translateY(10px);
  animation: cgc-redirect-up 480ms cubic-bezier(0.25,1,0.5,1) forwards;
  animation-delay: 780ms;
  will-change: transform, opacity;
}
.cgc-redirect__label {
  font-family: var(--font-serif, 'Cormorant Garamond', Georgia, serif);
  font-size: clamp(30px, 7vw, 58px);
  font-weight: 300;
  line-height: 0.96;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #1C1C1C;
  margin: 14px 0 0;
  opacity: 0;
  transform: translateY(14px);
  animation: cgc-redirect-up 560ms cubic-bezier(0.25,1,0.5,1) forwards;
  animation-delay: 880ms;
  word-break: break-word;
  text-shadow: 0 1px 0 rgba(0,0,0,0.03);
  will-change: transform, opacity;
}
.cgc-redirect__line {
  width: 64px;
  height: 1px;
  background: var(--cgc-gold, #D4B26F);
  margin: 16px auto 0;
  transform: scaleX(0);
  transform-origin: center;
  animation: cgc-redirect-line 480ms cubic-bezier(0.25,1,0.5,1) forwards;
  animation-delay: 1060ms;
  will-change: transform;
}
.cgc-redirect__sub {
  font-family: var(--font-sans, 'Plus Jakarta Sans', system-ui, sans-serif);
  font-size: 13px;
  font-weight: 400;
  letter-spacing: 0.04em;
  color: #8a8a8a;
  margin-top: 12px;
  opacity: 0;
  transform: translateY(8px);
  animation: cgc-redirect-up 440ms cubic-bezier(0.25,1,0.5,1) forwards;
  animation-delay: 1140ms;
  will-change: transform, opacity;
}
.cgc-redirect__meta {
  font-family: var(--font-sans, sans-serif);
  font-size: 10.5px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: #a8a8a8;
  margin-top: 10px;
  opacity: 0;
  transform: translateY(6px);
  animation: cgc-redirect-up 420ms cubic-bezier(0.25,1,0.5,1) forwards;
  animation-delay: 1220ms;
  will-change: transform, opacity;
}
@keyframes cgc-redirect-up { to { opacity: 1; transform: none; } }
@keyframes cgc-redirect-line { to { transform: scaleX(1); } }

/* Page enter — smoother fade + slight lift.
   NOTE: fill must stay `backwards` (never `both`/`forwards`). A retained
   transform fill on <body> makes Chrome treat body as the containing block
   for ALL position:fixed descendants site-wide (filter bottom-sheet,
   backdrop, mini-cart, search) — they render at document bottom (footer)
   instead of the viewport. The `to` keyframe equals natural styles, so
   `backwards` looks identical without the permanent fill. */
.cgc-page-enter { animation: cgc-page-enter 520ms cubic-bezier(0.25,1,0.5,1) backwards; }
@keyframes cgc-page-enter { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ===== Responsive: tablet ===== */
@media (max-width: 768px) {
  .cgc-redirect {
    padding: 28px 20px;
  }
  .cgc-redirect__orbit {
    width: 152px;
    height: 152px;
    margin-bottom: 22px;
  }
  .cgc-redirect__icon {
    width: 34px;
    height: 34px;
  }
  .cgc-redirect__icon svg { width: 19px; height: 19px; }
  .cgc-redirect__icon.is-thrown {
    width: 64px !important;
    height: 64px !important;
  }
  .cgc-redirect__icon.is-thrown svg { width: 32px !important; height: 32px !important; }
  .cgc-redirect__label {
    font-size: clamp(26px, 7.2vw, 42px);
    margin-top: 12px;
  }
  .cgc-redirect__eyebrow { font-size: 10.5px; letter-spacing: 0.24em; }
  .cgc-redirect__sub { font-size: 12px; margin-top: 10px; }
  .cgc-redirect__line { width: 56px; margin-top: 14px; }
}

/* ===== Responsive: mobile ===== */
@media (max-width: 480px) {
  .cgc-redirect {
    padding: 24px 16px;
    padding-top: max(20px, env(safe-area-inset-top));
  }
  .cgc-redirect__orbit {
    width: 132px;
    height: 132px;
    margin-bottom: 18px;
    border-width: 1px;
  }
  .cgc-redirect__icon {
    width: 30px;
    height: 30px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
  }
  .cgc-redirect__icon svg { width: 17px; height: 17px; }
  .cgc-redirect__icon.is-thrown {
    width: 56px !important;
    height: 56px !important;
    box-shadow: 0 10px 26px rgba(212,178,111,0.30), 0 2px 8px rgba(0,0,0,0.06);
  }
  .cgc-redirect__icon.is-thrown svg { width: 28px !important; height: 28px !important; }
  .cgc-redirect__inner { max-width: 92vw; }
  .cgc-redirect__label {
    font-size: clamp(24px, 7.5vw, 36px);
    letter-spacing: 0.07em;
    line-height: 0.98;
  }
  .cgc-redirect__eyebrow { font-size: 10px; letter-spacing: 0.22em; }
  .cgc-redirect__sub { font-size: 11.5px; padding: 0 8px; }
  .cgc-redirect__meta { font-size: 10px; letter-spacing: 0.14em; }
  .cgc-redirect__line { width: 48px; margin-top: 12px; }
}

/* ===== Extra small (320-360) ===== */
@media (max-width: 360px) {
  .cgc-redirect__orbit {
    width: 116px;
    height: 116px;
    margin-bottom: 16px;
  }
  .cgc-redirect__icon { width: 28px; height: 28px; }
  .cgc-redirect__icon svg { width: 16px; height: 16px; }
  .cgc-redirect__icon.is-thrown { width: 52px !important; height: 52px !important; }
  .cgc-redirect__label { font-size: clamp(22px, 8vw, 32px); }
}

/* ===== Reduced motion ===== */
@media (prefers-reduced-motion: reduce) {
  ::view-transition-old(root), ::view-transition-new(root),
  .cgc-redirect, .cgc-redirect__orbit, .cgc-redirect__icon,
  .cgc-redirect__eyebrow, .cgc-redirect__label,
  .cgc-redirect__line, .cgc-redirect__sub, .cgc-redirect__meta,
  .cgc-page-enter {
    animation: none !important;
    transition: none !important;
  }
  .cgc-redirect { opacity: 1; }
  .cgc-redirect__eyebrow, .cgc-redirect__label, .cgc-redirect__sub, .cgc-redirect__meta { opacity: 1; transform: none; }
  .cgc-redirect__line { transform: scaleX(1); }
  .cgc-redirect__orbit { opacity: 1; transform: none; }
  .cgc-redirect__icon { opacity: 1; transform: translate(-50%,-50%); }
}

/* Ensure overlay covers dynamic viewport on mobile browsers — now handled above with grid */
@supports (height: 100dvh) {
  .cgc-redirect { min-height: 100dvh; height: 100dvh; }
}
@supports (height: 100svh) {
  .cgc-redirect { min-height: 100svh; height: 100svh; }
}
