/* Modal that hosts the configurator iframe.
   The frame element ALWAYS has its target (open) dimensions in the layout —
   FLIP from the card to the modal is animated via `transform` (translate+scale),
   not by mutating width/height. This keeps the iframe's CSS viewport stable so
   the WebGL canvas inside initializes at full target size and never sees a
   zero-sized framebuffer. (1×1 sizing breaks GL: zero-size textures, incomplete
   framebuffers, etc.)

   States, controlled by aria on `.jc-modal`:
   - aria-hidden="true"  : frame opacity 0, pointer-events none — iframe stays
                           mounted and rendering at full target size, invisible.
   - aria-hidden="false" : frame opacity 1, transform animates from the clicked
                           card's rect to identity. */

.jc-modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  pointer-events: none;
}

.jc-modal[aria-hidden="false"] {
  pointer-events: auto;
}

.jc-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(20, 20, 20, 0);
  /* No backdrop-filter when closed — the open-state rule below adds blur(8px),
     and applying blur(0) here would still create a compositor layer for the
     idle modal, costing GPU on every frame. */
  transition: background 320ms ease, backdrop-filter 320ms ease, -webkit-backdrop-filter 320ms ease;
  pointer-events: none;
}

.jc-modal[aria-hidden="false"] .jc-modal__backdrop {
  background: rgba(20, 20, 20, 0.55);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  pointer-events: auto;
}

/* The frame stays centered at the target rect via top/left:50% + negative
   margin equal to half the dimensions. transform is reserved for FLIP. */
.jc-modal__frame {
  --jc-w: min(1200px, 90vw);
  --jc-h: min(800px, 90vh);
  position: absolute;
  top: 50%;
  left: 50%;
  width: var(--jc-w);
  height: var(--jc-h);
  margin-left: calc(var(--jc-w) / -2);
  margin-top: calc(var(--jc-h) / -2);
  background: #E7E7E7;
  /* matches configurator body background */
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.35);
  border-radius: 16px;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
  transform-origin: center center;
  transition:
    transform 480ms cubic-bezier(0.2, 0.8, 0.2, 1),
    opacity 280ms ease;
  /* will-change is set via JS only during the open/close transition;
     applying it statically would promote the idle frame to its own compositor
     layer on every page load, costing GPU memory for nothing. */
}

.jc-modal[aria-hidden="false"] .jc-modal__frame {
  opacity: 1;
  pointer-events: auto;
}

.jc-modal__iframe {
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
  background: #E7E7E7;
}

.jc-modal__close {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 2;
  width: 40px;
  height: 40px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  font-size: 22px;
  line-height: 1;
  border: 0;
  cursor: pointer;
  opacity: 0;
  transition: opacity 200ms ease 200ms, background 150ms ease;
}

.jc-modal__close:hover {
  background: rgba(0, 0, 0, 0.75);
  outline: none;
}

.jc-modal__close:focus-visible {
  background: rgba(0, 0, 0, 0.75);
  outline: 2px solid rgba(255, 255, 255, 0.8);
  outline-offset: 2px;
}

.jc-modal[aria-hidden="false"] .jc-modal__close {
  opacity: 1;
}

/* Mobile: frame fills the viewport. Keep transform-based FLIP working. */
@media (max-width: 640px) {
  .jc-modal__frame {
    --jc-w: 100vw;
    --jc-h: 100vh;
    border-radius: 0;
  }
}

/* Reduced motion: cut transitions but keep functionality. */
@media (prefers-reduced-motion: reduce) {

  .jc-modal__frame,
  .jc-modal__backdrop,
  .jc-modal__close {
    transition: none;
  }
}


/* CTA strip — overlays the bottom of the iframe inside the modal frame.
   Fades in with the modal open state, with a short delay so it appears
   after the frame animation settles. */
.jc-modal__cta {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.75rem 1.5rem;
  background: rgba(10, 10, 10, 0.72);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  color: #C5A059;
  font-family: sans-serif;
  font-size: 0.9375rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  text-decoration: none;
  opacity: 0;
  pointer-events: none;
  transition: opacity 200ms ease 350ms, background 150ms ease;
}

.jc-modal[aria-hidden="false"] .jc-modal__cta {
  opacity: 1;
  pointer-events: auto;
}

.jc-modal__cta:hover {
  background: rgba(10, 10, 10, 0.88);
  color: #d6b571;
}

.jc-modal__cta:focus-visible {
  outline: 2px solid #C5A059;
  outline-offset: -2px;
  opacity: 1;
  pointer-events: auto;
}

@media (max-width: 640px) {
  .jc-modal__cta {
    font-size: 0.8125rem;
    padding: 0.625rem 1rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .jc-modal__cta {
    transition: none;
  }
}

/* Cards become clickable; subtle hint on hover. */
[data-jc-card] {
  cursor: pointer;
  transition: transform 240ms ease, box-shadow 240ms ease;
}

/* Hover lift gated behind both a real pointer (no sticky-tap on touch) AND
   the user's motion preference — sub-second transforms are still motion
   under WCAG 2.3.3 / prefers-reduced-motion. */
@media (hover: hover) and (prefers-reduced-motion: no-preference) {
  [data-jc-card]:hover {
    transform: translateY(-2px);
  }
}

/* Suppress the browser's default focus ring on click/tap, but show a
   brand-coloured outline for genuine keyboard navigation (Tab). The thin
   black default ring looks bad on rounded corners; this golden outline with
   offset traces the card's radius cleanly and matches the landing's accent. */
[data-jc-card]:focus {
  outline: none;
}

[data-jc-card]:focus-visible {
  outline: 2px solid #C5A059;
  outline-offset: 4px;
}
