/* ============================================================
   Interactive App Flow — Premium Dark Modal
   ============================================================ */

.flow-root {
  position: fixed;
  inset: 0;
  z-index: 300;
  pointer-events: none;
}

.flow-root:not([hidden]) {
  pointer-events: auto;
}

.flow-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(7, 11, 20, 0.75);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  opacity: 0;
  transition: opacity 0.45s cubic-bezier(0.4, 0, 0.2, 1);
}

.flow-root.is-visible .flow-backdrop {
  opacity: 1;
}

/* Morphing shell — expands from card rect to centered app container */
.flow-shell {
  position: fixed;
  z-index: 301;
  overflow: hidden;
  background: var(--bg-elevated);
  border: 1px solid var(--border-medium);
  box-shadow:
    0 32px 80px rgba(0, 0, 0, 0.6),
    0 0 60px var(--glow-violet);
  transition:
    top 0.55s cubic-bezier(0.4, 0, 0.2, 1),
    left 0.55s cubic-bezier(0.4, 0, 0.2, 1),
    width 0.55s cubic-bezier(0.4, 0, 0.2, 1),
    height 0.55s cubic-bezier(0.4, 0, 0.2, 1),
    border-radius 0.55s cubic-bezier(0.4, 0, 0.2, 1),
    transform 0.55s cubic-bezier(0.4, 0, 0.2, 1),
    opacity 0.35s ease;
  opacity: 0;
}

.flow-root.is-visible .flow-shell {
  opacity: 1;
}

.flow-root.is-expanded .flow-shell {
  top: 50% !important;
  left: 50% !important;
  width: min(calc(100% - 2rem), 26rem) !important;
  height: min(calc(100dvh - 2rem), 42rem) !important;
  transform: translate(-50%, -50%) !important;
  border-radius: var(--radius-2xl) !important;
}

.flow-shell::before {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--gradient-iris-soft);
  opacity: 0.4;
  pointer-events: none;
}

.flow-close {
  position: absolute;
  top: var(--space-md);
  right: var(--space-md);
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-medium);
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  color: var(--text-secondary);
  transition: color var(--transition), border-color var(--transition), box-shadow var(--transition);
}

.flow-close:hover,
.flow-close:focus-visible {
  color: var(--text-primary);
  border-color: rgba(34, 211, 238, 0.4);
  box-shadow: 0 0 20px var(--glow-cyan);
  outline: none;
}

.flow-viewport {
  position: relative;
  height: 100%;
  overflow: hidden;
}

/* Steps */
.flow-step {
  position: absolute;
  inset: 0;
  padding: var(--space-xl) var(--space-lg);
  overflow-y: auto;
  opacity: 0;
  visibility: hidden;
  transform: translateX(24px);
  transition:
    opacity 0.4s cubic-bezier(0.4, 0, 0.2, 1),
    transform 0.4s cubic-bezier(0.4, 0, 0.2, 1),
    visibility 0.4s;
}

.flow-step.is-active {
  opacity: 1;
  visibility: visible;
  transform: translateX(0);
}

.flow-step.is-exiting {
  opacity: 0;
  transform: translateX(-24px);
}

.flow-step-inner {
  position: relative;
  z-index: 1;
  min-height: 100%;
  display: flex;
  flex-direction: column;
}

.flow-step-inner--connect {
  align-items: center;
  text-align: center;
  justify-content: center;
  padding-top: var(--space-lg);
  padding-bottom: var(--space-xl);
}

.flow-step-inner--success {
  padding-bottom: var(--space-md);
}

/* Hero icon */
.flow-hero-icon {
  width: 4.5rem;
  height: 4.5rem;
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin-bottom: var(--space-lg);
  border: 2px solid var(--border-medium);
  box-shadow: 0 0 32px var(--glow-cyan);
  animation: flow-icon-pulse 3s ease-in-out infinite;
}

.flow-hero-icon img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

@keyframes flow-icon-pulse {
  0%, 100% { box-shadow: 0 0 24px var(--glow-cyan); }
  50% { box-shadow: 0 0 40px var(--glow-violet); }
}

.flow-title {
  font-family: var(--font-display);
  font-size: var(--fs-lg);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.25;
  margin-bottom: var(--space-sm);
}

.flow-subtitle {
  font-size: var(--fs-sm);
  color: var(--text-secondary);
  line-height: 1.6;
  max-width: 28ch;
}

.flow-step-inner--connect .flow-subtitle {
  margin-bottom: var(--space-lg);
}

/* Glass badges */
.flow-badges {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--space-sm);
  margin-bottom: var(--space-xl);
}

.flow-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: var(--space-xs) var(--space-md);
  font-size: var(--fs-xs);
  font-weight: 600;
  color: var(--text-primary);
  background: rgba(26, 35, 54, 0.65);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-full);
}

.flow-badge svg {
  color: var(--iris-cyan);
  flex-shrink: 0;
}

/* Primary button */
.flow-btn-primary {
  position: relative;
  width: 100%;
  max-width: 18rem;
  padding: var(--space-md) var(--space-xl);
  font-family: var(--font-display);
  font-size: var(--fs-sm);
  font-weight: 700;
  color: var(--text-primary);
  background: var(--gradient-iris);
  background-size: 200% 200%;
  border-radius: var(--radius-full);
  border: none;
  box-shadow: 0 4px 24px var(--glow-violet);
  animation: shimmer-ring 4s linear infinite;
  transition: transform 0.25s ease, box-shadow 0.25s ease;
}

.flow-btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 32px var(--glow-cyan);
}

.flow-btn-primary:active {
  transform: translateY(0) scale(0.98);
}

.flow-btn-primary:focus-visible {
  outline: 2px solid var(--iris-cyan);
  outline-offset: 3px;
}

.flow-hint {
  margin-top: var(--space-md);
  font-size: var(--fs-xs);
  color: var(--text-dim);
}

.flow-btn-start {
  max-width: none;
  margin-top: auto;
  padding: var(--space-md) var(--space-xl);
  font-size: var(--fs-base);
}

/* Header with back */
.flow-header {
  display: flex;
  align-items: flex-start;
  gap: var(--space-sm);
  margin-bottom: var(--space-lg);
}

.flow-header--center {
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.flow-header--center .flow-subtitle {
  max-width: none;
}

.flow-back {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  flex-shrink: 0;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-medium);
  background: rgba(26, 35, 54, 0.5);
  color: var(--text-secondary);
  transition: color var(--transition), border-color var(--transition), box-shadow var(--transition);
}

.flow-back:hover,
.flow-back:focus-visible {
  color: var(--iris-cyan);
  border-color: rgba(34, 211, 238, 0.35);
  box-shadow: 0 0 16px var(--glow-cyan);
  outline: none;
}

.flow-header-text {
  flex: 1;
  min-width: 0;
}

/* Brand grid */
.flow-brand-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-sm);
  flex: 1;
  align-content: start;
}

.flow-brand-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: var(--space-md) var(--space-xs);
  min-height: 5.5rem;
  background: rgba(26, 35, 54, 0.55);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition:
    border-color 0.25s ease,
    box-shadow 0.25s ease,
    transform 0.25s ease,
    background 0.25s ease;
}

.flow-brand-card:hover {
  border-color: rgba(167, 139, 250, 0.4);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}

.flow-brand-card.is-selected,
.flow-brand-card:active {
  border-color: var(--iris-cyan);
  background: rgba(34, 211, 238, 0.08);
  box-shadow: 0 0 24px var(--glow-cyan);
}

.flow-brand-card svg {
  color: var(--iris-violet);
}

.flow-brand-name {
  font-size: var(--fs-xs);
  font-weight: 600;
  text-align: center;
  line-height: 1.2;
}

.flow-brand-type {
  font-size: 0.625rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* Progress bar */
.flow-progress-wrap {
  margin-bottom: var(--space-xl);
}

.flow-progress-track {
  height: 6px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: var(--radius-full);
  overflow: hidden;
  margin-bottom: var(--space-xs);
}

.flow-progress-bar {
  height: 100%;
  width: 0%;
  background: var(--gradient-iris);
  background-size: 200% 100%;
  border-radius: inherit;
  animation: shimmer-ring 2s linear infinite;
  transition: width 0.15s linear;
}

.flow-progress-label {
  font-size: var(--fs-xs);
  font-weight: 600;
  color: var(--iris-cyan);
}

/* Checklist */
.flow-checklist {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

.flow-check-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
  padding: var(--space-sm) var(--space-md);
  background: rgba(26, 35, 54, 0.45);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  font-size: var(--fs-sm);
  color: var(--text-secondary);
  transition: border-color 0.3s ease, color 0.3s ease;
}

.flow-check-item.is-done {
  color: var(--text-primary);
  border-color: rgba(52, 211, 153, 0.25);
}

.flow-check-label {
  flex: 1;
}

.flow-check-status {
  flex-shrink: 0;
  width: 1.25rem;
  height: 1.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.flow-check-status svg {
  width: 1.125rem;
  height: 1.125rem;
}

.flow-check-status .icon-check {
  color: var(--iris-emerald);
  opacity: 0;
  transform: scale(0.5);
  transition: opacity 0.35s ease, transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.flow-check-item.is-done .icon-check {
  opacity: 1;
  transform: scale(1);
}

.flow-spinner {
  width: 1.125rem;
  height: 1.125rem;
  border: 2px solid rgba(255, 255, 255, 0.1);
  border-top-color: var(--iris-cyan);
  border-radius: 50%;
  animation: flow-spin 0.8s linear infinite;
}

.flow-check-item.is-done .flow-spinner {
  display: none;
}

@keyframes flow-spin {
  to { transform: rotate(360deg); }
}

/* Success */
.flow-ready-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  align-self: center;
  padding: var(--space-xs) var(--space-md);
  margin-bottom: var(--space-md);
  font-size: var(--fs-xs);
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--iris-emerald);
  background: rgba(52, 211, 153, 0.1);
  border: 1px solid rgba(52, 211, 153, 0.3);
  border-radius: var(--radius-full);
  box-shadow: 0 0 20px rgba(52, 211, 153, 0.2);
}

.flow-ready-dot {
  width: 8px;
  height: 8px;
  background: var(--iris-emerald);
  border-radius: 50%;
  animation: ready-pulse 2s ease-in-out infinite;
}

@keyframes ready-pulse {
  0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(52, 211, 153, 0.5); }
  50% { opacity: 0.7; box-shadow: 0 0 0 6px rgba(52, 211, 153, 0); }
}

.flow-step-inner--success .flow-title,
.flow-step-inner--success .flow-subtitle {
  text-align: center;
  align-self: center;
}

.flow-step-inner--success .flow-subtitle {
  margin-bottom: var(--space-lg);
}

.flow-checklist--success {
  margin-bottom: var(--space-lg);
}

/* Signal bars */
.flow-signal-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-md);
  margin-bottom: var(--space-lg);
  background: rgba(26, 35, 54, 0.55);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-md);
}

.flow-signal-label {
  display: block;
  font-size: var(--fs-sm);
  font-weight: 600;
  margin-bottom: 2px;
}

.flow-signal-value {
  font-size: var(--fs-xs);
  color: var(--iris-emerald);
  font-weight: 600;
}

.flow-signal-bars {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 1.25rem;
}

.flow-bar {
  width: 4px;
  border-radius: 2px;
  background: var(--gradient-iris);
  animation: signal-bar 1.2s ease-in-out infinite;
}

.flow-bar:nth-child(1) { height: 35%; animation-delay: 0s; }
.flow-bar:nth-child(2) { height: 55%; animation-delay: 0.15s; }
.flow-bar:nth-child(3) { height: 75%; animation-delay: 0.3s; }
.flow-bar:nth-child(4) { height: 100%; animation-delay: 0.45s; }

@keyframes signal-bar {
  0%, 100% { opacity: 0.5; transform: scaleY(0.85); }
  50% { opacity: 1; transform: scaleY(1); }
}

/* Highlight link as button — preserve gradient text from styles.css */
button.highlight-link {
  border: none;
  cursor: pointer;
  font: inherit;
  padding: 0;
}

/* Body lock */
body.flow-open {
  overflow: hidden;
}

@media (min-width: 480px) {
  .flow-root.is-expanded .flow-shell {
    width: min(calc(100% - 3rem), 28rem) !important;
    height: min(calc(100dvh - 3rem), 44rem) !important;
  }
}

@media (prefers-reduced-motion: reduce) {
  .flow-shell,
  .flow-step,
  .flow-backdrop,
  .flow-progress-bar,
  .flow-hero-icon,
  .flow-bar,
  .flow-ready-dot {
    animation: none !important;
    transition-duration: 0.01ms !important;
  }
}
