/* ==========================================================================
   Interactive "How it works" demo — a faux order flow that auto-plays.
   Replicates the real order forms (Amount → Comfort → EA → Status) with an
   animated cursor + typing. Pure presentational; no business logic.
   Palette mirrors the real order flow (coins.css): bg #1a1e22, panels
   #22262c / #272e36, accent green #48ff91, slider purple #726bff.
   ========================================================================== */

.hiw-demo {
  /* colours mirror the real order flow (coins.css): green accent #48ff91,
     purple progress #726bff, panels #22262c / #272e36, EA input #161a1d. */
  --hiw-bg: #1a1e22;
  --hiw-panel: #22262c;
  --hiw-panel-2: #272e36;
  --hiw-track: #272e36;
  --hiw-border: rgba(255, 255, 255, 0.09);
  --hiw-border-hover: rgba(255, 255, 255, 0.22);
  --hiw-text: #fff;
  --hiw-muted: #878e96;
  --hiw-accent: #48ff91;
  --hiw-accent-soft: rgba(72, 255, 145, 0.14);
  --hiw-purple: #726bff;
  --hiw-radius: 14px;
  font-family: "Gilroy", sans-serif;

  position: relative;
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  font-family: inherit;
  color: var(--hiw-text);
  -webkit-user-select: none;
  user-select: none;
}

/* --- window chrome --- */
.hiw-demo__window {
  position: relative;
  background: var(--hiw-bg);
  border: 1px solid var(--hiw-border);
  border-radius: var(--hiw-radius);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
  overflow: hidden;
}
.hiw-demo__bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  background: rgba(255, 255, 255, 0.02);
  border-bottom: 1px solid var(--hiw-border);
}
.hiw-demo__dots { display: flex; gap: 6px; }
.hiw-demo__dot { width: 10px; height: 10px; border-radius: 50%; background: rgba(255,255,255,0.16); }
.hiw-demo__dot--g { background: #48ff91; }
.hiw-demo__url {
  margin-left: 8px;
  font-size: 12px;
  color: var(--hiw-muted);
  letter-spacing: 0.02em;
}

/* --- step progress (nav) — mirrors the real .coins-progress stepper:
   circular icons on a connecting line; active = purple #726bff with glow;
   completed = purple with a checkmark. --- */
.hiw-demo__nav {
  position: relative;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 20px 24px 4px;
}
.hiw-demo__nav-line {
  position: absolute;
  left: 46px; right: 46px; top: 42px;
  border-top: 2px solid #1c2227;
  z-index: 0;
}
.hiw-demo__nav-item {
  position: relative;
  z-index: 1;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  min-width: 0;
}
.hiw-demo__nav-icon {
  width: 40px; height: 40px;
  flex: 0 0 40px;
  border-radius: 50%;
  background: var(--hiw-panel-2);
  display: grid;
  place-items: center;
  color: rgba(255, 255, 255, 0.55);
  transition: background 0.3s ease, box-shadow 0.3s ease, color 0.3s ease;
}
.hiw-demo__nav-icon svg { width: 20px; height: 20px; fill: currentColor; }
.hiw-demo__nav-check { display: none; }
/* active step — purple circle with glow (like coins-progress__item--active) */
.hiw-demo__nav-item.is-active .hiw-demo__nav-icon {
  background: var(--hiw-purple);
  box-shadow: 0 0 20px 0 var(--hiw-purple);
  color: #fff;
}
/* completed step — purple, showing the checkmark instead of the glyph */
.hiw-demo__nav-item.is-done .hiw-demo__nav-icon {
  background: var(--hiw-purple);
  color: #fff;
}
.hiw-demo__nav-item.is-done .hiw-demo__nav-glyph { display: none; }
.hiw-demo__nav-item.is-done .hiw-demo__nav-check { display: block; }
.hiw-demo__nav-label {
  font-size: 12px;
  color: #939393;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
  transition: color 0.3s ease;
}
.hiw-demo__nav-item.is-active .hiw-demo__nav-label { color: #fff; }

/* --- stage: holds the swappable step panels --- */
.hiw-demo__stage {
  position: relative;
  padding: 18px 16px 24px;
  min-height: 360px;
}
.hiw-demo__step {
  position: absolute;
  inset: 18px 16px 24px;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.4s ease, transform 0.4s ease;
  pointer-events: none;
}
.hiw-demo__step.is-active {
  opacity: 1;
  transform: none;
  pointer-events: auto;
}
.hiw-demo__step-title {
  font-size: 15px;
  font-weight: 600;
  margin: 0 0 14px;
}
.hiw-demo__step-title span { color: var(--hiw-accent); }

/* --- generic field --- */
.hiw-field { margin-bottom: 12px; }
.hiw-field__label {
  display: inline-block;
  font-size: 13px;
  color: #a1abb5;
  background: #2f3943;
  padding: 3px 10px;
  border-radius: 5px;
  margin-bottom: 8px;
}
.hiw-field__input {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 46px;
  padding: 0 14px;
  background: #161a1d;
  border: 1px solid transparent;
  border-radius: 5px;
  font-size: 16px;
  transition: border-color 0.2s ease;
}
.hiw-field__input.is-focus { border-color: var(--hiw-purple); box-shadow: 0 0 0 3px rgba(114, 107, 255, 0.25); }
.hiw-field__value { color: #e5e5e5; }
.hiw-field__value--muted { color: var(--hiw-muted); }
.hiw-caret {
  display: inline-block;
  width: 1.5px;
  height: 18px;
  background: var(--hiw-purple);
  margin-left: 1px;
  opacity: 0;
}
.hiw-field__input.is-focus .hiw-caret { animation: hiw-blink 1s step-end infinite; }
@keyframes hiw-blink { 0%,100% { opacity: 1; } 50% { opacity: 0; } }
.hiw-field__coin { width: 24px; height: 24px; margin-left: auto; flex: 0 0 auto; }

/* --- Amount step --- */
.hiw-amount__slider {
  position: relative;
  height: 4px;
  border-radius: 5px;
  background: var(--hiw-track);
  margin: 22px 4px 26px;
}
.hiw-amount__fill {
  position: absolute; left: 0; top: 0; bottom: 0;
  width: 20%;
  border-radius: 5px;
  background: var(--hiw-purple);
  transition: width 1.1s cubic-bezier(.22,.61,.36,1);
}
.hiw-amount__knob {
  position: absolute; top: 50%;
  left: 20%;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 8px rgba(0,0,0,0.4);
  transform: translate(-50%, -50%);
  transition: left 1.1s cubic-bezier(.22,.61,.36,1);
}
.hiw-amount__tags { display: flex; flex-wrap: wrap; gap: 7px; margin-bottom: 16px; }
.hiw-amount__tag {
  padding: 8px 13px;
  border-radius: 14px;
  background: var(--hiw-panel-2);
  border: none;
  font-size: 14px;
  color: #c8cfd7;
  transition: all 0.25s ease;
}
.hiw-amount__tag.is-selected {
  background: rgba(114, 107, 255, 0.16);
  color: var(--hiw-text);
  box-shadow: inset 0 0 0 1px var(--hiw-purple);
}
.hiw-amount__details {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 14px;
  border-radius: 10px;
  background: var(--hiw-panel);
  margin-bottom: 4px;
}
.hiw-amount__detail-label { font-size: 14px; color: var(--hiw-muted); }
.hiw-amount__detail-val { font-size: 14px; color: #ebebeb; }
.hiw-amount__price { font-size: 24px; font-weight: 700; color: #fff; font-family: "Gilroy", sans-serif; }

/* --- Comfort / delivery method cards --- */
.hiw-methods { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.hiw-method {
  padding: 14px;
  border-radius: 12px;
  background: var(--hiw-panel);
  border: 1.5px solid var(--hiw-border);
  transition: all 0.3s ease;
}
.hiw-method.is-selected {
  border-color: var(--hiw-accent);
  background: var(--hiw-accent-soft);
}
.hiw-method.is-dim { opacity: 0.45; }
.hiw-method__tag {
  display: inline-block;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: var(--hiw-purple);
  color: #292e35;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 4px;
  margin-bottom: 8px;
}
.hiw-method__name { font-size: 14px; font-weight: 600; margin-bottom: 6px; }
.hiw-method__desc { font-size: 11.5px; color: var(--hiw-muted); line-height: 1.45; }
.hiw-method__check {
  float: right;
  width: 20px; height: 20px;
  border-radius: 50%;
  border: 1.5px solid var(--hiw-border);
  display: grid; place-items: center;
  transition: all 0.3s ease;
}
.hiw-method.is-selected .hiw-method__check {
  background: var(--hiw-accent);
  border-color: var(--hiw-accent);
}
.hiw-method__check svg { width: 12px; height: 12px; fill: #1a1e22; opacity: 0; transition: opacity 0.3s ease 0.1s; }
.hiw-method.is-selected .hiw-method__check svg { opacity: 1; }

/* --- CTA button --- */
.hiw-cta {
  width: 100%;
  height: 50px;
  margin-top: 16px;
  border: none;
  border-radius: 5px;
  background: var(--hiw-accent);
  color: #1a1e22;
  font-size: 18px;
  font-weight: 700;
  font-family: "Gilroy", sans-serif;
  box-shadow: 0px 4px 9px 0px rgba(0, 0, 0, 0.16);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: transform 0.12s ease, box-shadow 0.2s ease;
}
.hiw-cta.is-press { transform: scale(0.97); box-shadow: 0 0 0 4px var(--hiw-accent-soft); }
.hiw-cta__icon { width: 18px; height: 18px; fill: #1a1e22; }
.hiw-bolt { width: 15px; height: 15px; fill: var(--hiw-accent); vertical-align: -2px; }

/* --- Status step --- */
.hiw-status { text-align: center; padding-top: 6px; }
.hiw-status__ring {
  position: relative;
  width: 96px; height: 96px;
  margin: 6px auto 16px;
}
.hiw-status__ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.hiw-status__ring circle { fill: none; stroke-width: 6; }
.hiw-status__track { stroke: var(--hiw-panel); }
.hiw-status__prog {
  stroke: var(--hiw-accent);
  stroke-linecap: round;
  stroke-dasharray: 264;
  stroke-dashoffset: 264;
  transition: stroke-dashoffset 2.4s linear;
}
.hiw-status__pct {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  font-size: 20px; font-weight: 700;
}
.hiw-status__title { font-size: 15px; font-weight: 600; margin-bottom: 6px; }
.hiw-status__title.is-done { color: var(--hiw-accent); }
.hiw-status__desc { font-size: 12.5px; color: var(--hiw-muted); line-height: 1.5; }
.hiw-status__badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 14px;
  padding: 7px 14px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  background: var(--hiw-accent-soft);
  color: var(--hiw-accent);
  opacity: 0;
  transform: scale(0.9);
  transition: all 0.4s cubic-bezier(.34,1.56,.64,1);
}
.hiw-status__badge.is-show { opacity: 1; transform: none; }
.hiw-status__badge svg { width: 14px; height: 14px; fill: currentColor; }

/* --- animated cursor --- */
.hiw-cursor {
  position: absolute;
  top: 0; left: 0;
  width: 22px; height: 22px;
  z-index: 20;
  pointer-events: none;
  transform: translate(40px, 40px);
  transition: transform 0.8s cubic-bezier(.5,.1,.25,1);
  will-change: transform;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.5));
}
.hiw-cursor svg { width: 100%; height: 100%; }
.hiw-cursor.is-click { transform: translate(var(--x), var(--y)) scale(0.82); }
.hiw-cursor__ping {
  position: absolute; inset: 0;
  border-radius: 50%;
  border: 2px solid var(--hiw-accent);
  opacity: 0;
}
.hiw-cursor.is-click .hiw-cursor__ping { animation: hiw-ping 0.5s ease-out; }
@keyframes hiw-ping {
  0% { opacity: 0.7; transform: scale(0.4); }
  100% { opacity: 0; transform: scale(2.4); }
}

/* --- caption under the window --- */
.hiw-demo__caption {
  margin-top: 16px;
  text-align: center;
  font-size: 13px;
  color: var(--hiw-muted);
  min-height: 20px;
}
.hiw-demo__caption b { color: var(--hiw-text); font-weight: 600; }

/* --- replay control --- */
.hiw-demo__replay {
  position: absolute;
  right: 12px; bottom: 12px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 11px;
  border-radius: 999px;
  background: rgba(0,0,0,0.4);
  border: 1px solid var(--hiw-border);
  color: var(--hiw-muted);
  font-size: 11px;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.3s ease;
}
.hiw-demo:hover .hiw-demo__replay { opacity: 1; }
.hiw-demo__replay:hover { color: var(--hiw-text); border-color: var(--hiw-border-hover); }
.hiw-demo__replay svg { width: 13px; height: 13px; }

/* reduce motion */
@media (prefers-reduced-motion: reduce) {
  .hiw-cursor { display: none; }
  .hiw-demo__step, .hiw-amount__fill, .hiw-amount__knob,
  .hiw-status__prog, .hiw-status__badge { transition-duration: 0.01ms !important; }
}

/* mobile */
@media (max-width: 767px) {
  .hiw-demo { max-width: 100%; }
  .hiw-demo__nav-label { display: none; }
  .hiw-demo__nav-item { justify-content: center; }
  .hiw-methods { grid-template-columns: 1fr; }
  .hiw-demo__stage { min-height: 320px; }
  .hiw-demo__step { inset: 18px 16px 20px; }
}
