/* ============================================================
   CTA BUTTONS — HERO
   ============================================================ */

.btn--modal-trigger {
  position: relative;
  overflow: hidden;
}
.btn--modal-trigger::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(105deg, transparent 40%, rgba(255,255,255,0.12) 50%, transparent 60%);
  transform: translateX(-100%);
  transition: transform 0.55s cubic-bezier(0.16,1,0.3,1);
}
.btn--modal-trigger:hover::after {
  transform: translateX(100%);
}
.btn-icon {
  display: inline-flex;
  align-items: center;
  transition: transform 0.25s cubic-bezier(0.16,1,0.3,1);
}
.btn--modal-trigger:hover .btn-icon {
  transform: translateX(3px);
}

.btn--process-trigger {
  position: relative;
}
.btn-pulse {
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--gold);
  opacity: 0;
  transition: opacity 0.2s;
}
.btn-pulse::before {
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 1px solid var(--gold);
  animation: pulsering 2s ease-out infinite;
  opacity: 0;
}
.btn--process-trigger:hover .btn-pulse      { opacity: 1; }
.btn--process-trigger:hover .btn-pulse::before { opacity: 1; }

@keyframes pulsering {
  0%   { transform: scale(1);   opacity: 0.6; }
  100% { transform: scale(2.4); opacity: 0; }
}


/* ============================================================
   MODAL OVERLAY
   ============================================================ */

/*
 * FIX 1 — Hover blocking when modal is closed
 *
 * Root cause: .modal-overlay is position:fixed; inset:0 — a full-viewport
 * layer always present in the DOM. pointer-events:none alone is not
 * reliable enough to prevent it from interfering with hover detection
 * on elements beneath it across all browsers and GPU compositing layers.
 *
 * Fix: Add visibility:hidden when closed. This removes the element from
 * the browser's hit-test tree entirely, guaranteeing zero interference
 * with any hover/pointer events on the page underneath.
 */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 9000;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  visibility: hidden; /* KEY FIX: removes layer from hit-testing when closed */
}
.modal-overlay:not([hidden]) {
  pointer-events: all;
  visibility: visible;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(4, 5, 10, 0.0);
  backdrop-filter: blur(0px);
  -webkit-backdrop-filter: blur(0px);
  transition: none;
}

.modal-glow {
  position: absolute;
  top: -20%;
  right: -10%;
  width: 700px;
  height: 700px;
  background: radial-gradient(circle, rgba(240,192,64,0.06) 0%, transparent 65%);
  border-radius: 50%;
  pointer-events: none;
  will-change: transform;
}

.modal-close {
  position: absolute;
  top: clamp(20px, 3vw, 36px);
  right: clamp(20px, 3vw, 36px);
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 1px solid var(--stroke-hi);
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--ink-700);
  z-index: 10;
  transition: background 0.2s, border-color 0.2s, transform 0.25s cubic-bezier(0.16,1,0.3,1);
  opacity: 0;
  transform: scale(0.85);
}
.modal-close:hover {
  background: var(--ink-500);
  border-color: var(--stroke-hi);
  transform: scale(1) rotate(90deg);
}
.modal-close span {
  position: absolute;
  width: 14px;
  height: 1.5px;
  background: var(--text-secondary);
  border-radius: 2px;
  transition: background 0.2s;
}
.modal-close span:nth-child(1) { transform: rotate(45deg); }
.modal-close span:nth-child(2) { transform: rotate(-45deg); }
.modal-close:hover span { background: var(--text-primary); }


/* ── Main content panel ── */

/*
 * FIX 2 — Green card bleeding outside modal boundary
 *
 * Root cause: overflow:visible was set so the ::before gold top-line
 * at top:-1px wouldn't clip. But this also allowed absolutely-positioned
 * .mv-card children inside .modal-visual to paint outside the modal's
 * rounded boundary, making card-3 peek out at the bottom during transitions.
 *
 * Fix: Change to overflow:hidden and move ::before to top:0 (1px difference,
 * visually imperceptible). The modal boundary now clips all children cleanly.
 */
.modal-content {
  position: relative;
  z-index: 2;
  width: min(1060px, calc(100vw - 40px));
  max-height: calc(100svh - 80px);
  overflow: hidden; /* CHANGED from visible — stops card bleed-through */

  background: var(--ink-800);
  border: 1px solid var(--stroke-hi);
  border-radius: 20px;
  display: grid;
  grid-template-rows: auto 1fr;
  grid-template-columns: 1fr 360px;
  grid-template-areas:
    "steps steps"
    "panels visual";

  opacity: 0;
  transform: translateY(32px) scale(0.98);
  transition: none;
}
.modal-content::before {
  content: '';
  position: absolute;
  top: 0;      /* CHANGED from -1px — renders inside clip boundary */
  left: 10%; right: 10%;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(240,192,64,0.5), transparent);
  border-radius: 1px;
  z-index: 1;
}


/* ── Step indicator bar ── */
.modal-steps {
  grid-area: steps;
  display: flex;
  align-items: center;
  gap: 0;
  padding: clamp(16px, 2.5vw, 28px) clamp(24px, 4vw, 48px);
  border-bottom: 1px solid var(--stroke);
  background: var(--ink-700);
  border-radius: 20px 20px 0 0;
  position: relative;
  z-index: 1;
}
.ms-item {
  display: flex;
  align-items: center;
  gap: 8px;
  opacity: 0.35;
  transition: opacity 0.35s cubic-bezier(0.16,1,0.3,1);
  white-space: nowrap;
}
.ms-item.active { opacity: 1; }
.ms-item.done   { opacity: 0.55; }
.ms-num {
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .1em;
  color: var(--text-tertiary);
  font-family: var(--font-ui);
  transition: color 0.3s;
}
.ms-item.active .ms-num { color: var(--gold); }
.ms-label {
  font-size: .78rem;
  font-weight: 500;
  color: var(--text-secondary);
  transition: color 0.3s;
}
.ms-item.active .ms-label { color: var(--text-primary); }
.ms-sep {
  flex: 1;
  height: 1px;
  background: var(--stroke-hi);
  margin: 0 clamp(12px, 2vw, 24px);
  min-width: 20px;
}


/* ── Panels area ── */
.modal-panels {
  grid-area: panels;
  position: relative;
  overflow: hidden;
  padding: clamp(28px, 4vw, 52px) clamp(24px, 4vw, 48px);
}

/*
 * Panel visibility system:
 *
 * Default (inactive): position:absolute, overlaid, invisible, no pointer events.
 * Active:             position:relative, in flow, visible, pointer events on.
 * Exit:               position:absolute, fading out left, no pointer events.
 *
 * IMPORTANT: The JS must clear all inline style overrides on the outgoing
 * panel BEFORE class changes, so CSS transition values are not suppressed
 * by leftover inline opacity/transform from the previous animation.
 * See goToStep() in the JS for the removeProperty() calls.
 */
.modal-panel {
  position: absolute;
  inset: clamp(28px, 4vw, 52px) clamp(24px, 4vw, 48px);
  display: flex;
  flex-direction: column;
  opacity: 0;
  transform: translateX(40px);
  pointer-events: none;
  transition: opacity 0.5s cubic-bezier(0.16,1,0.3,1),
              transform 0.55s cubic-bezier(0.16,1,0.3,1);
}
.modal-panel.active {
  opacity: 1;
  transform: translateX(0);
  pointer-events: all;
  position: relative;
  inset: unset;
}
.modal-panel.exit {
  opacity: 0;
  transform: translateX(-40px);
  pointer-events: none;
  position: absolute;
  inset: clamp(28px, 4vw, 52px) clamp(24px, 4vw, 48px);
}

.mp-eyebrow {
  font-size: .67rem;
  font-weight: 600;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: clamp(12px, 1.8vw, 20px);
  opacity: 0;
  transform: translateY(8px);
}
.mp-title {
  font-family: var(--font-display);
  font-size: clamp(1.8rem, 3.5vw, 2.8rem);
  font-weight: 400;
  line-height: 1.04;
  letter-spacing: -.03em;
  color: #fff;
  margin-bottom: clamp(14px, 2vw, 22px);
  opacity: 0;
  transform: translateY(12px);
}
.mp-title em {
  font-style: italic;
  color: var(--gold);
}
.mp-body {
  font-size: clamp(.84rem, 1.2vw, .93rem);
  color: var(--text-secondary);
  line-height: 1.78;
  font-weight: 300;
  max-width: 420px;
  margin-bottom: clamp(20px, 2.5vw, 32px);
  opacity: 0;
  transform: translateY(10px);
}
.mp-features {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: clamp(24px, 3vw, 36px);
  opacity: 0;
  transform: translateY(10px);
}
.mp-feat {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: .83rem;
  color: var(--text-secondary);
  font-weight: 400;
}
.mp-feat-icon {
  color: var(--gold);
  font-size: .7rem;
  flex-shrink: 0;
}
.mp-next {
  align-self: flex-start;
  opacity: 0;
  transform: translateY(8px);
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.mp-next svg { transition: transform 0.2s cubic-bezier(0.16,1,0.3,1); }
.mp-next:hover svg { transform: translateX(3px); }

.mp-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  opacity: 0;
  transform: translateY(10px);
}
.mpf-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.mpf-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.mpf-field--full { grid-column: 1 / -1; }
.mpf-field label {
  font-size: .65rem;
  font-weight: 600;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--text-tertiary);
}
.mpf-field input,
.mpf-field textarea {
  background: var(--ink-600);
  border: 1px solid var(--stroke);
  border-radius: 8px;
  padding: 10px 13px;
  font-size: .875rem;
  color: var(--text-primary);
  outline: none;
  resize: none;
  -webkit-appearance: none;
  font-family: var(--font-ui);
  transition: border-color 0.2s, box-shadow 0.25s;
}
.mpf-field input::placeholder,
.mpf-field textarea::placeholder { color: var(--text-tertiary); }
.mpf-field input:focus,
.mpf-field textarea:focus {
  border-color: rgba(240,192,64,0.4);
  box-shadow: 0 0 0 3px rgba(240,192,64,0.07);
}
.mp-submit {
  align-self: flex-start;
  margin-top: 4px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.mp-submit svg { transition: transform 0.2s cubic-bezier(0.16,1,0.3,1); }
.mp-submit:hover svg { transform: translateX(3px); }

.mp-success {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 40px 0;
  text-align: center;
}
.mp-success-icon {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: rgba(52,211,153,0.1);
  border: 1px solid rgba(52,211,153,0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  color: #6ee7b7;
}
.mp-success-text {
  font-size: .95rem;
  color: var(--text-secondary);
}


/* ── Visual column ── */
.modal-visual {
  grid-area: visual;
  border-left: 1px solid var(--stroke);
  background: var(--ink-700);
  border-radius: 0 0 20px 0;
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(24px, 3vw, 40px);
}
.modal-visual::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 180px;
  background: linear-gradient(to bottom, var(--gold-soft), transparent);
  pointer-events: none;
  z-index: 0;
}

/*
 * FIX 3 — Visual card overlap and hover on right column
 *
 * Root cause A (visual bleed): opacity:0 alone does not remove an element
 * from the compositor's paint layer. During the 120ms setTimeout gap in the
 * original switchVisual(), all three cards briefly had no .active class and
 * sat stacked at position:absolute; inset:40px — card 3 bled through the
 * modal boundary because modal-content had overflow:visible.
 *
 * Root cause B (hover broken): Cards without .active had pointer-events:none
 * in CSS, but inline styles set by the old JS (position, inset) could override
 * the expected layout, causing invisible cards to sit on top of visible ones
 * and intercept mouse events.
 *
 * Fix: Add visibility:hidden to inactive state with a delayed transition
 * (delay = fade-out duration) so the element is fully removed from hit-testing
 * AFTER it finishes fading. On activation, visibility:visible fires instantly
 * (0s delay) so the fade-in is visible from the first frame.
 *
 * The JS (switchVisual) no longer uses setTimeout — active is toggled
 * immediately and synchronously, eliminating the gap where no card had .active.
 */
.mv-card {
  position: absolute;
  inset: clamp(24px, 3vw, 40px);
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: clamp(16px, 2.5vw, 24px);
  opacity: 0;
  visibility: hidden;                  /* ADDED */
  transform: translateY(16px);
  pointer-events: none;
  transition: opacity 0.45s cubic-bezier(0.16,1,0.3,1),
              transform 0.5s cubic-bezier(0.16,1,0.3,1),
              visibility 0s linear 0.45s; /* ADDED: hides after fade completes */
  z-index: 1;
}
.mv-card.active {
  opacity: 1;
  visibility: visible;                 /* ADDED */
  transform: none;
  pointer-events: all;
  position: relative;
  inset: unset;
  transition: opacity 0.45s cubic-bezier(0.16,1,0.3,1),
              transform 0.5s cubic-bezier(0.16,1,0.3,1),
              visibility 0s linear 0s; /* ADDED: shows immediately on activation */
}

/* Card 1 — metrics */
.mv-metric {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 14px 16px;
  background: var(--ink-600);
  border: 1px solid var(--stroke);
  border-radius: 10px;
  transition: border-color 0.2s;
}
.mv-metric:hover { border-color: var(--stroke-hi); }
.mv-val {
  font-family: var(--font-display);
  font-size: 1.6rem;
  color: var(--gold);
  font-style: italic;
  letter-spacing: -.03em;
  line-height: 1;
}
.mv-lbl {
  font-size: .72rem;
  color: var(--text-tertiary);
  letter-spacing: .02em;
}
.mv-bar-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.mv-bar-label {
  font-size: .68rem;
  color: var(--text-tertiary);
  letter-spacing: .04em;
  margin-bottom: 2px;
}
.mv-bar {
  height: 4px;
  background: var(--ink-500);
  border-radius: 99px;
  overflow: hidden;
}
.mv-bar-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--gold), rgba(240,192,64,0.5));
  border-radius: 99px;
  transition: width 1s cubic-bezier(0.16,1,0.3,1);
}
.mv-card.active .mv-bar-fill { width: var(--w); }

/* Card 2 — code */
.mv-code-preview {
  font-size: .78rem;
  font-family: 'SF Mono', 'Fira Code', monospace;
  line-height: 1.9;
  background: var(--ink-900);
  border: 1px solid var(--stroke);
  border-radius: 10px;
  padding: 18px 20px;
}
.mvc-line { white-space: nowrap; }
.mvc-indent { padding-left: 18px; }
.mvc-k { color: var(--gold); opacity: 0.85; }
.mvc-v { color: #7dd3fc; }
.mvc-s { color: #86efac; }
.mvc-b { color: #f9a8d4; }

/* Card 3 — timeline */
.mv-timeline {
  display: flex;
  flex-direction: column;
  gap: 0;
}
.mvt-row {
  display: grid;
  grid-template-columns: 18px 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--stroke);
  font-size: .8rem;
  color: var(--text-tertiary);
  transition: color 0.2s;
}
.mvt-row:last-child { border-bottom: none; }
.mvt-row.done   { color: var(--text-secondary); }
.mvt-row.active { color: var(--text-primary); }
.mvt-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--ink-400);
  border: 1.5px solid var(--stroke-hi);
  flex-shrink: 0;
  transition: background 0.2s, border-color 0.2s;
}
.mvt-row.done .mvt-dot {
  background: rgba(52,211,153,0.4);
  border-color: rgba(52,211,153,0.5);
}
.mvt-row.active .mvt-dot {
  background: var(--gold);
  border-color: var(--gold);
  box-shadow: 0 0 8px rgba(240,192,64,0.4);
}
.mvt-label { font-weight: 500; }
.mvt-day   { font-size: .68rem; letter-spacing: .04em; }


/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 860px) {
  .modal-content {
    grid-template-columns: 1fr;
    grid-template-areas:
      "steps"
      "panels";
    width: calc(100vw - 24px);
    max-height: calc(100svh - 40px);
    overflow-y: auto;
  }
  .modal-visual { display: none; }
  .modal-content::before { left: 5%; right: 5%; }
  .mpf-row { grid-template-columns: 1fr; }
}
@media (max-width: 500px) {
  .ms-label { display: none; }
  .ms-sep { min-width: 12px; }
}
