/* How it works page (/how-it-works/). Uses the tokens from motion.css. */

.hiw-kicker {
  display: inline-block;
  font-family: var(--font-body);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--accent-cyan);
}

.hiw-head {
  display: grid;
  gap: 6px;
  justify-items: center;
  text-align: center;
  margin-bottom: clamp(32px, 5vw, 56px);
}

.hiw-head .section-title,
.hiw-head .section-subtitle {
  margin: 0;
  max-width: 34ch;
}

.hiw-head .section-subtitle {
  max-width: 56ch;
}

/* First section sits under the fixed nav */
.hiw-first {
  padding-top: 150px;
}

/* --- Process: keyframe timeline --- */
.hiw-tl {
  display: grid;
  gap: clamp(26px, 4vw, 44px);
  max-width: 900px;
  margin: 0 auto;
}

.hiw-tl-track {
  position: relative;
  height: 70px;
}

.hiw-tl-line,
.hiw-tl-fill {
  position: absolute;
  left: 0;
  top: 22px;
  height: 2px;
  border-radius: 2px;
}

.hiw-tl-line {
  right: 0;
  background: rgba(255, 255, 255, 0.16);
}

.hiw-tl-fill {
  width: var(--p, 0%);
  background: linear-gradient(90deg, var(--accent-cyan), var(--accent-indigo));
  transition: width 0.9s var(--ease-out-expo);
}

.hiw-tl-head {
  position: absolute;
  top: 0;
  left: var(--p, 0%);
  width: 2px;
  height: 46px;
  background: var(--accent-pink);
  box-shadow: 0 0 12px var(--accent-pink);
  transform: translateX(-1px);
  transition: left 0.9s var(--ease-out-expo);
}

.hiw-tl-head::before {
  content: "";
  position: absolute;
  top: -6px;
  left: -6px;
  width: 14px;
  height: 10px;
  background: var(--accent-pink);
  clip-path: polygon(0 0, 100% 0, 100% 60%, 50% 100%, 0 60%);
}

.hiw-kf {
  position: absolute;
  top: 0;
  transform: translateX(-50%);
  appearance: none;
  background: none;
  border: 0;
  /* 44px tap area; the diamond stays centred on the line */
  min-width: 44px;
  min-height: 44px;
  padding: 13px 4px 0;
  cursor: pointer;
  display: grid;
  justify-items: center;
  gap: 12px;
  color: var(--text-muted);
  font-family: var(--font-heading);
  font-size: 0.85rem;
  font-weight: 500;
  white-space: nowrap;
}

.hiw-kf i {
  width: 16px;
  height: 16px;
  transform: rotate(45deg);
  border: 2px solid rgba(255, 255, 255, 0.2);
  background: var(--bg-deep);
  border-radius: 3px;
  transition: all 0.5s var(--ease-out-expo);
}

.hiw-kf:hover i {
  border-color: var(--accent-indigo);
}

.hiw-kf.done i {
  background: var(--accent-indigo);
  border-color: var(--accent-indigo);
}

.hiw-kf.on {
  color: var(--text-bright);
}

.hiw-kf.on i {
  background: linear-gradient(135deg, var(--accent-cyan), var(--accent-violet));
  border-color: transparent;
  box-shadow: 0 0 18px var(--border-glow);
  transform: rotate(45deg) scale(1.25);
}

.hiw-kf:focus-visible {
  outline: 2px solid var(--accent-cyan);
  outline-offset: 4px;
  border-radius: 6px;
}

.hiw-tl-panel {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: clamp(18px, 4vw, 48px);
  align-items: center;
  min-height: 200px;
}

.hiw-tl-num {
  font-family: var(--font-heading);
  font-weight: 800;
  font-size: clamp(5rem, 13vw, 9rem);
  line-height: 0.8;
  letter-spacing: -0.04em;
  color: transparent;
  -webkit-text-stroke: 1.5px rgba(123, 97, 255, 0.65);
}

.hiw-tl-body {
  display: grid;
  gap: 12px;
  min-width: 0;
}

.hiw-tl-body h3 {
  margin: 0;
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: clamp(1.5rem, 3vw, 2.1rem);
  line-height: 1.1;
  color: var(--text-bright);
}

.hiw-tl-body p {
  margin: 0;
  font-size: 1.05rem;
  color: var(--text-main);
  max-width: 48ch;
}

.hiw-tl-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
  align-items: center;
}

.hiw-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-bright);
  background: rgba(123, 97, 255, 0.16);
  border: 1px solid var(--border-glow);
  padding: 5px 12px;
  border-radius: 999px;
  white-space: nowrap;
}

.hiw-from {
  font-size: 0.9rem;
  color: var(--text-muted);
}

.hiw-from b {
  color: var(--text-main);
  font-weight: 500;
}

.hiw-tl-panel.swap > .hiw-tl-body {
  animation: hiw-swap 0.7s var(--ease-out-expo) both;
}

.hiw-tl-panel.swap > .hiw-tl-num {
  animation: hiw-num 0.8s var(--ease-out-expo) both;
}

@keyframes hiw-swap {
  from { opacity: 0; transform: translateY(14px); filter: blur(6px); }
  to { opacity: 1; transform: none; filter: none; }
}

@keyframes hiw-num {
  from { opacity: 0; transform: translateX(-24px); }
  to { opacity: 1; transform: none; }
}

/* --- What's included: storyboard frames --- */
.hiw-sb {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: clamp(28px, 3vw, 40px) clamp(18px, 2.4vw, 28px);
  max-width: 1100px;
  margin: 0 auto;
}

.hiw-sb-item {
  display: grid;
  gap: 14px;
  align-content: start;
  min-width: 0;
}

.hiw-sb-frame {
  position: relative;
  aspect-ratio: 16 / 9;
  max-width: 100%;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 14px;
  background: linear-gradient(160deg, #0e1330, #090c1f);
  overflow: hidden;
  transition: transform 0.6s var(--ease-out-expo), border-color 0.4s, box-shadow 0.4s;
}

.hiw-sb-item:hover .hiw-sb-frame {
  transform: translateY(-4px);
  border-color: var(--border-glow);
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.35);
}

.hiw-sb-frame svg {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 34%;
  height: auto;
  transform: translate(-50%, -50%);
  overflow: visible;
}

.hiw-sb-frame .ln {
  fill: none;
  stroke: var(--text-main);
  stroke-width: 1.4;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
  transition: stroke 0.6s;
}

.hiw-sb.in .ln {
  animation: hiw-draw 1.4s var(--ease-out-expo) forwards;
  animation-delay: var(--d, 0s);
}

.hiw-sb.in .hiw-sb-item .ln {
  stroke: var(--accent-cyan);
  transition-delay: calc(var(--d, 0s) + 1.1s);
}

.hiw-sb-item:hover .ln {
  stroke: var(--text-bright);
}

@keyframes hiw-draw {
  to { stroke-dashoffset: 0; }
}

.hiw-sb-frame::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(60% 70% at 50% 55%, rgba(123, 97, 255, 0.28), transparent 70%);
  opacity: 0;
  transition: opacity 1s ease;
  transition-delay: calc(var(--d, 0s) + 1s);
}

.hiw-sb.in .hiw-sb-frame::after {
  opacity: 1;
}

.hiw-sb-corner,
.hiw-sb-tc {
  position: absolute;
  font-family: ui-monospace, Menlo, monospace;
  font-size: 0.62rem;
  letter-spacing: 0.06em;
  z-index: 1;
}

.hiw-sb-corner {
  top: 9px;
  left: 11px;
  color: var(--text-muted);
}

.hiw-sb-tc {
  bottom: 9px;
  right: 11px;
  color: #5c6590;
}

.hiw-sb-cap {
  display: grid;
  gap: 4px;
}

.hiw-sb-cap h3 {
  margin: 0;
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 1.08rem;
  color: var(--text-bright);
}

.hiw-sb-cap p {
  margin: 0;
  font-size: 0.9rem;
  color: var(--text-muted);
}

/* --- FAQ --- */
.hiw-faq {
  display: grid;
  gap: 12px;
  max-width: 820px;
  margin: 0 auto;
}

.hiw-faq details {
  background: var(--bg-glass);
  border: 1px solid var(--border-glass);
  border-radius: 16px;
  padding: 0 22px;
  transition: border-color 0.3s;
}

.hiw-faq details[open] {
  border-color: var(--border-glow);
}

.hiw-faq summary {
  cursor: pointer;
  list-style: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 18px 0;
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 1.02rem;
  color: var(--text-bright);
}

.hiw-faq summary::-webkit-details-marker {
  display: none;
}

.hiw-faq summary::after {
  content: "";
  flex: none;
  width: 12px;
  height: 12px;
  border-right: 2px solid var(--accent-indigo);
  border-bottom: 2px solid var(--accent-indigo);
  transform: rotate(45deg) translateY(-3px);
  transition: transform 0.4s var(--ease-out-expo);
}

.hiw-faq details[open] summary::after {
  transform: rotate(-135deg) translateY(-3px);
}

.hiw-faq summary:focus-visible {
  outline: 2px solid var(--accent-cyan);
  outline-offset: 2px;
  border-radius: 6px;
}

.hiw-faq .hiw-a {
  margin: 0;
  padding-bottom: 20px;
  color: var(--text-main);
  white-space: pre-line;
}

.hiw-faq details[open] .hiw-a {
  animation: hiw-swap 0.5s var(--ease-out-expo) both;
}

/* --- Responsive --- */
@media (max-width: 1000px) {
  .hiw-sb {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .hiw-first {
    padding-top: 120px;
  }

  .hiw-kf span {
    display: none;
  }

  .hiw-tl-panel {
    grid-template-columns: 1fr;
    gap: 4px;
    min-height: 0;
  }

  .hiw-tl-num {
    font-size: 4.5rem;
  }

  /* Storyboard frames become a compact list: small frame left, text right */
  .hiw-sb {
    grid-template-columns: 1fr;
    gap: 18px;
  }

  .hiw-sb-item {
    grid-template-columns: 120px minmax(0, 1fr);
    align-items: center;
    gap: 16px;
  }

  .hiw-sb-corner,
  .hiw-sb-tc {
    display: none;
  }

  .hiw-faq details {
    padding: 0 16px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .hiw-sb-frame .ln {
    stroke-dashoffset: 0;
    stroke: var(--accent-cyan);
  }

  .hiw-sb-frame::after {
    opacity: 1;
  }

  .hiw-tl-panel.swap > *,
  .hiw-faq details[open] .hiw-a {
    animation: none;
  }

  .hiw-tl-fill,
  .hiw-tl-head {
    transition: none;
  }
}
