/**
 * Host Wi-Fi flow: checking → ready (+ modal) → offline stub.
 * Shares canvas with host-name-session / .hn purple band.
 */

.wf {
  position: relative;
  box-sizing: border-box;
  min-height: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  color: var(--text-primary);
  background-color: var(--iquq-onboarding-surface);
  background-image: radial-gradient(
      ellipse 130% 75% at 50% -22%,
      rgba(101, 35, 206, 0.3),
      transparent 52%
    ),
    linear-gradient(
      90deg,
      var(--iquq-onboarding-surface) 0%,
      var(--iquq-onboarding-band-mid) 52.404%,
      var(--iquq-onboarding-surface) 100%
    );
}

.wf__scroll {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  padding: 0 var(--space-md) 24px;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.wf__topbar {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 54px;
  padding: 4px 12px 0;
  flex-shrink: 0;
}

.wf__topbar-time {
  font-size: 15px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.85);
}

.wf__topbar-icons {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 12px;
  opacity: 0.9;
}

.wf__brand {
  width: 100%;
  max-width: 100%;
  padding: 4px 0 6px;
  margin: 0 0 4px;
}

.wf__brand-row {
  display: grid;
  grid-template-columns: minmax(48px, 1fr) auto minmax(48px, 1fr);
  align-items: center;
  width: 100%;
}

.wf__back {
  grid-column: 1;
  justify-self: start;
  align-self: center;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border: none;
  border-radius: 12px;
  background: transparent;
  color: rgba(255, 255, 255, 0.92);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  text-decoration: none;
}

.wf__back:hover {
  background: rgba(255, 255, 255, 0.06);
}

.wf__brand-wordblock {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 0;
}

.wf__brand-shelf {
  grid-column: 3;
  justify-self: end;
  width: 48px;
  height: 44px;
  visibility: hidden;
  pointer-events: none;
}

.wf__chips-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-top: 10px;
}

.wf__chip-stream,
.wf__chip-host,
.wf__chip-session {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 8px;
  border-radius: 6px;
  border: none;
  background: rgba(0, 0, 0, 0.58);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
  color: rgba(251, 251, 251, 0.95);
  font-size: 10px;
  font-weight: 500;
  line-height: 1;
}

.wf__chip-stream-icon,
.wf__chip-host svg,
.wf__chip-session svg {
  flex-shrink: 0;
  width: 11px;
  height: 11px;
  opacity: 0.95;
}

.wf__chip-session {
  display: none;
}

.wf__chip-session.is-visible {
  display: inline-flex;
}

/* —— Checking state —— */
.wf__stage {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 24px 0 48px;
  min-height: 200px;
}

.wf__checking-icon {
  width: 56px;
  height: 56px;
  margin-bottom: 20px;
  color: #f59e0b;
  filter: drop-shadow(0 4px 20px rgba(245, 158, 11, 0.35));
}

.wf__checking-title {
  margin: 0 0 24px;
  font-size: clamp(22px, 5.5vw, 26px);
  font-weight: 700;
  letter-spacing: -0.03em;
  color: #fbbf24;
}

.wf__progress-track {
  width: min(280px, 100%);
  height: 6px;
  border-radius: 999px;
  background: rgba(31, 11, 64, 0.55);
  overflow: hidden;
}

.wf__progress-fill {
  height: 100%;
  width: 42%;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(167, 139, 250, 0.85), rgba(124, 58, 237, 0.95));
  animation: wf-progress 1.35s ease-in-out infinite;
}

@keyframes wf-progress {
  0% {
    transform: translateX(-100%);
  }
  100% {
    transform: translateX(320%);
  }
}

@media (prefers-reduced-motion: reduce) {
  .wf__progress-fill {
    animation: none;
    width: 55%;
    transform: none;
  }
}

/* —— Ready state —— */
.wf__ready {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 34px 0 24px;
}

.wf__ready-icon {
  width: 64px;
  height: 64px;
  margin-bottom: 8px;
  color: #22c55e;
  filter: drop-shadow(0 4px 16px rgba(34, 197, 94, 0.25));
}

.wf__ready-kicker {
  margin: 0;
  font-size: clamp(24px, 6.2vw, 28px);
  font-weight: 750;
  letter-spacing: -0.03em;
  line-height: 1.15;
  color: rgba(251, 251, 251, 0.98);
}

.wf__ready-sub {
  margin: 6px 0 0;
  font-size: 13px;
  font-weight: 600;
  color: rgba(34, 197, 94, 0.85);
}

.wf__ready-ssid {
  margin: 2px 0 28px;
  font-size: clamp(22px, 5.8vw, 28px);
  font-weight: 750;
  letter-spacing: -0.03em;
  color: rgba(251, 251, 251, 0.98);
  word-break: break-word;
  max-width: min(18ch, 100%);
  text-wrap: balance;
  overflow-wrap: anywhere;
}

.wf__btn-primary {
  display: block;
  width: 100%;
  max-width: 280px;
  margin: 0 auto 16px;
  padding: 14px 20px;
  border: none;
  border-radius: 14px;
  background: linear-gradient(180deg, rgba(125, 42, 255, 0.98) 0%, rgba(101, 35, 206, 0.99) 100%);
  color: #fff;
  font-family: var(--font-sans);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.02em;
  cursor: pointer;
  text-decoration: none;
  text-align: center;
  box-shadow: 0 8px 28px rgba(31, 11, 64, 0.35);
  box-sizing: border-box;
  transition: filter 0.15s ease;
}

.wf__btn-primary:hover {
  filter: brightness(1.05);
}

.wf__ready-footer {
  margin-top: auto;
  padding: 28px 12px 0;
  width: 100%;
  max-width: 100%;
  text-align: center;
}

.wf__ready-hint {
  margin: 0 0 10px;
  font-size: 13px;
  font-weight: 500;
  color: rgba(251, 251, 251, 0.48);
}

.wf__btn-ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: auto;
  padding: 12px 20px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 12px;
  background: transparent;
  color: rgba(251, 251, 251, 0.72);
  font-family: var(--font-sans);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  box-sizing: border-box;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.wf__btn-ghost:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.22);
  color: rgba(251, 251, 251, 0.88);
}

body.device-preview:has(.wf__prototype-links) {
  flex-direction: column;
}

.device-frame + .wf__prototype-links {
  width: min(var(--device-w), calc(100% - 24px));
  margin-top: 100px;
}

.wf__prototype-links {
  text-align: center;
}

.wf__prototype-links a {
  display: inline-block;
  font-size: 12px;
  font-weight: 500;
  color: rgba(196, 181, 253, 0.95);
  text-decoration: none;
}

.wf__prototype-links a:hover {
  text-decoration: underline;
}

/* —— Offline stub —— */
.wf__offline-icon {
  width: 64px;
  height: 64px;
  margin-bottom: 8px;
  color: rgba(251, 251, 251, 0.55);
  filter: drop-shadow(0 4px 16px rgba(0, 0, 0, 0.2));
}

.wf__bt-stage {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  width: 100%;
  padding: 28px 0 24px;
}

.wf__bt-stage--missing {
  padding-top: 34px;
}

.wf__bt-stage--ready {
  padding-top: 34px;
}

.wf__bt-group {
  width: 100%;
  max-width: 320px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.wf__bt-group--status {
  gap: 4px;
  margin-bottom: 28px;
}

.wf__bt-group--action {
  gap: 10px;
  margin-bottom: 0;
}

.wf__bt-icon {
  width: 64px;
  height: 64px;
  margin-bottom: 8px;
  filter: drop-shadow(0 4px 16px rgba(34, 197, 94, 0.25));
}

.wf__bt-title {
  margin: 0;
  font-size: clamp(24px, 6.2vw, 28px);
  font-weight: 750;
  letter-spacing: -0.03em;
  line-height: 1.15;
  color: rgba(251, 251, 251, 0.98);
  text-wrap: balance;
  max-width: 14ch;
}

.wf__bt-sub {
  margin: 6px 0 0;
  font-size: 13px;
  font-weight: 600;
  color: rgba(34, 197, 94, 0.85);
}

.wf__bt-device {
  margin: 2px 0 0;
  max-width: min(18ch, 100%);
  font-size: clamp(22px, 5.8vw, 28px);
  font-weight: 750;
  letter-spacing: -0.03em;
  line-height: 1.1;
  color: rgba(251, 251, 251, 0.98);
  text-wrap: balance;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.wf__bt-primary {
  max-width: 280px;
  margin-bottom: 0;
}

.wf__bt-help {
  margin: 4px 0 0;
  font-size: 13px;
  line-height: 1.35;
  font-weight: 500;
  color: rgba(251, 251, 251, 0.48);
  max-width: 22em;
  text-wrap: balance;
}

.wf__bt-next-disabled {
  margin-top: auto;
  display: block;
  width: 100%;
  max-width: 280px;
  min-height: 48px;
  padding: 13px 20px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 14px;
  background: linear-gradient(180deg, rgba(125, 42, 255, 0.3) 0%, rgba(101, 35, 206, 0.3) 100%);
  color: rgba(255, 255, 255, 0.3);
  font-family: var(--font-sans);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.02em;
  cursor: not-allowed;
  box-sizing: border-box;
  text-wrap: balance;
  line-height: 1.2;
}

.wf__bt-footer {
  width: 100%;
  max-width: 300px;
  margin-top: auto;
}

/* —— Session meta details —— */
.wf__meta-stage {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  width: 100%;
  padding: 30px 0 24px;
}

.wf__meta-icon {
  width: 96px;
  height: 96px;
  color: #22c55e;
  filter: drop-shadow(0 4px 18px rgba(34, 197, 94, 0.32));
}

.wf__meta-icon--disco {
  display: inline-block;
  background-color: #22c55e;
  -webkit-mask: url("../assets/figma-onboarding/disco-ball-v2.svg") center / contain no-repeat;
  mask: url("../assets/figma-onboarding/disco-ball-v2.svg") center / contain no-repeat;
}

.wf__meta-title {
  margin: 8px 0 22px;
  font-size: clamp(24px, 7vw, 30px);
  font-weight: 750;
  letter-spacing: -0.03em;
  line-height: 1.06;
  color: rgba(251, 251, 251, 0.98);
}

.wf__meta-card {
  width: 100%;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: linear-gradient(145deg, rgba(124, 58, 237, 0.2), rgba(49, 20, 102, 0.42));
  box-shadow: 0 8px 22px rgba(31, 11, 64, 0.22), 0 1px 0 rgba(255, 255, 255, 0.06) inset;
  overflow: hidden;
  text-align: left;
  margin-bottom: 28px;
}

.wf__meta-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 13px 16px;
  font-size: 13px;
  line-height: 1.3;
  font-weight: 500;
  color: rgba(248, 245, 255, 0.62);
}

.wf__meta-row + .wf__meta-row {
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.wf__meta-value {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  color: rgba(251, 251, 251, 0.95);
}

.wf__meta-check {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: rgba(34, 197, 94, 0.15);
  color: rgba(34, 197, 94, 0.95);
  font-size: 11px;
  font-weight: 800;
  line-height: 1;
}

.wf__meta-cta {
  width: min(310px, 100%);
  margin: 0 auto;
}

/* ── Ready screen exit choreography ── */
@keyframes wf-exit-slide-up {
  0%   { opacity: 1; transform: translateY(0); }
  100% { opacity: 0; transform: translateY(-60px); }
}
@keyframes wf-exit-slide-down {
  0%   { opacity: 1; transform: translateY(0); }
  100% { opacity: 0; transform: translateY(80px); }
}
@keyframes wf-exit-zoom-fade {
  0%   { opacity: 1; transform: scale(1); }
  100% { opacity: 0; transform: scale(0.7); }
}

.wf--phase1 .wf__brand {
  animation: wf-exit-slide-up 0.4s cubic-bezier(0.4, 0, 1, 1) forwards;
}
.wf--phase1 .wf__topbar {
  animation: wf-exit-slide-up 0.35s cubic-bezier(0.4, 0, 1, 1) forwards;
  animation-delay: 0.03s;
}
.wf--phase1 .wf__meta-card {
  animation: wf-exit-slide-down 0.4s cubic-bezier(0.4, 0, 1, 1) forwards;
}
.wf--phase1 .wf__meta-cta {
  animation: wf-exit-slide-down 0.35s cubic-bezier(0.4, 0, 1, 1) forwards;
  animation-delay: 0.05s;
}

.wf--phase2 .wf__meta-title {
  animation: wf-exit-zoom-fade 0.6s cubic-bezier(0.4, 0, 1, 1) forwards;
  animation-delay: 0.25s;
}
.wf--phase2 .wf__meta-icon {
  animation: wf-exit-zoom-fade 0.7s cubic-bezier(0.4, 0, 1, 1) forwards;
  animation-delay: 0.45s;
}

.confetti-canvas {
  position: absolute;
  inset: 0;
  z-index: 100;
  pointer-events: none;
}

.wf__offline-title {
  margin: 0 0 36px;
  font-size: clamp(22px, 5.8vw, 26px);
  font-weight: 750;
  letter-spacing: -0.03em;
  line-height: 1.15;
  color: rgba(251, 251, 251, 0.98);
  max-width: 20ch;
}

.wf__offline-desc {
  margin: 0 0 28px;
  font-size: 15px;
  line-height: 1.45;
  color: rgba(251, 251, 251, 0.72);
  max-width: 22em;
}

.wf__btn-row {
  display: flex;
  flex-direction: column;
  gap: 0;
  width: 100%;
  max-width: 340px;
}

.wf__option {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.wf__option:first-child {
  position: relative;
  margin-bottom: 24px;
  padding-bottom: 24px;
}

.wf__option:first-child::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 1px;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(199, 164, 255, 0.35) 20%,
    rgba(199, 164, 255, 0.35) 80%,
    transparent 100%
  );
}

.wf__option-label {
  margin: 0 0 8px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  line-height: 1.2;
  text-transform: uppercase;
  color: rgba(196, 181, 253, 0.6);
  text-align: center;
}

.wf__option-help {
  margin: 8px 0 0;
  max-width: 22em;
  font-size: 12px;
  line-height: 1.4;
  font-weight: 500;
  color: rgba(251, 251, 251, 0.48);
  text-align: center;
}

.wf__btn-secondary {
  display: block;
  width: 100%;
  padding: 14px 20px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.06);
  color: rgba(251, 251, 251, 0.72);
  font-family: var(--font-sans);
  font-size: 15px;
  font-weight: 600;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  box-sizing: border-box;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.wf__btn-secondary:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.22);
}

/* —— Modal —— */
.wf__modal[hidden] {
  display: none !important;
}

.wf__modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  box-sizing: border-box;
  opacity: 0;
  transition: opacity 0.22s ease;
}

.wf__modal--visible {
  opacity: 1;
}

.wf__modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(10, 6, 22, 0.72);
  backdrop-filter: blur(4px);
}

.wf__modal-panel {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 320px;
  padding: 22px 20px 18px;
  border-radius: 18px;
  background: linear-gradient(165deg, rgba(45, 25, 80, 0.98) 0%, rgba(25, 12, 48, 0.99) 100%);
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
  transform: scale(0.95) translateY(6px);
  transition: transform 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}

.wf__modal--visible .wf__modal-panel {
  transform: scale(1) translateY(0);
}

.wf__modal-title {
  margin: 0 0 12px;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.02em;
  text-align: center;
  color: rgba(251, 251, 251, 0.98);
}

.wf__modal-body {
  margin: 0 0 20px;
  font-size: 14px;
  line-height: 1.45;
  text-align: center;
  color: rgba(226, 220, 240, 0.9);
}

.wf__modal-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.wf__modal-actions .wf__btn-secondary {
  padding: 12px 14px;
  font-size: 15px;
}

.wf__modal-actions .wf__btn-settings {
  background: rgba(255, 255, 255, 0.14);
  border-color: rgba(255, 255, 255, 0.2);
}

.device-frame__screen--wifi-flow {
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.device-frame__screen > .wf {
  min-height: calc(var(--device-h) - 1px);
}

/* —— Session discovery —— */
.wf__discover {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding-top: 32px;
}

.wf__discover-title {
  margin: 0 0 6px;
  font-family: var(--font-sans);
  font-size: 24px;
  font-weight: 740;
  letter-spacing: -0.025em;
  color: rgba(251, 251, 251, 0.98);
}

.wf__discover-sub {
  margin: 0 0 28px;
  font-size: 14px;
  line-height: 1.45;
  color: rgba(226, 220, 240, 0.62);
  text-wrap: balance;
}

.wf__discover-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
  padding: 0 4px;
  box-sizing: border-box;
}

.wf__discover-card {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 16px;
  border-radius: var(--radius-md);
  border: 1.5px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-primary);
  cursor: pointer;
  text-align: left;
  transition: border-color 0.18s ease, background 0.18s ease, transform 0.1s ease;
  box-sizing: border-box;
}

.wf__discover-card:hover {
  background: rgba(255, 255, 255, 0.07);
  border-color: rgba(255, 255, 255, 0.14);
}

.wf__discover-card:active {
  transform: scale(0.995);
}

.wf__discover-card[aria-checked="true"] {
  border-color: var(--iquq-purple-deep);
  background: rgba(124, 58, 237, 0.08);
}

.wf__discover-card-icon {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.06);
  color: rgba(226, 220, 240, 0.5);
}

.wf__discover-card[aria-checked="true"] .wf__discover-card-icon {
  background: rgba(124, 58, 237, 0.12);
  color: var(--iquq-purple-deep);
}

.wf__discover-card-body {
  flex: 1;
  min-width: 0;
}

.wf__discover-card-name {
  margin: 0 0 2px;
  font-family: var(--font-sans);
  font-size: 15px;
  font-weight: 650;
  letter-spacing: -0.015em;
  color: rgba(251, 251, 251, 0.92);
}

.wf__discover-card-meta {
  margin: 0;
  font-size: 12.5px;
  letter-spacing: -0.005em;
  color: rgba(226, 220, 240, 0.5);
}

.wf__discover-card-check {
  flex-shrink: 0;
  opacity: 0;
  transform: scale(0.6);
  transition: opacity 0.18s ease, transform 0.18s cubic-bezier(0.16, 1, 0.3, 1);
}

.wf__discover-card[aria-checked="true"] .wf__discover-card-check {
  opacity: 1;
  transform: scale(1);
}

.wf__discover-scan {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  margin-top: 28px;
  width: 100%;
  padding: 0 4px;
  box-sizing: border-box;
}

.wf__discover-scan-label {
  margin: 0;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: rgba(226, 220, 240, 0.4);
}

.wf__discover-footer {
  padding: 16px var(--space-md) calc(16px + env(safe-area-inset-bottom, 0px));
}

.wf__discover-join {
  display: block;
  text-align: center;
  text-decoration: none;
}

.wf__discover-join[aria-disabled="true"],
.wf__discover-join--disabled {
  opacity: 0.35;
  pointer-events: none;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
