/* ==========================================================================
   UNITED ECHOES — homepage "How it works": the four steps play as a short
   looping animation of the client portal (script: assets/js/how-it-works.js).
   ========================================================================== */

/* heading above the animation: centred on laptops, left-aligned on phones.
   The animation sits straight on the page background (no frame) and is only as tall as its content. */
.hw-wrap { display: grid; gap: 1.25rem; align-items: center; }
.hw-wrap > .hm-head { margin-bottom: 0; }
/* laptops and desktops: the heading centred, with the animation centred right under it */
@media (min-width: 900px) {
  .hw-wrap { justify-items: center; gap: 1.75rem; }
  .hw-wrap > .hm-head { text-align: center; }
  .hw-wrap > .hw { width: min(100%, 620px); }
}
.hw { position: relative; }
/* the four steps are still read out by screen readers (visually hidden by .sr-only) */
.hw-prog i { transform: scaleX(0); }

/* ---- The animation ------------------------------------------------------------------- */
.hw-device { position: relative; container-type: inline-size; }
.hw-screen { display: grid; font-size: clamp(12px, 3.2cqi, 15px); color: var(--text); }
.hw-scene {
  grid-area: 1 / 1; position: relative; display: flex; flex-direction: column; justify-content: center; gap: .9em;
  padding: .25em 0 3.4em;   /* room at the bottom for the small "done" message */
  opacity: 0; visibility: hidden; transform: translateY(10px);
  transition: opacity .5s ease, transform .5s var(--ease, ease), visibility 0s linear .5s;
}
.hw-scene.is-on { opacity: 1; visibility: visible; transform: none; transition: opacity .5s ease, transform .5s var(--ease, ease), visibility 0s; }
.hw-scene svg { width: 1.2em; height: 1.2em; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* shared bits */
.hw-h { margin: 0; font-weight: 700; font-size: 1.35em; letter-spacing: -.01em; }
.hw-card, .hw-form, .hw-plan { display: grid; gap: .75em; padding: 1.1em 1.2em; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); box-shadow: 0 14px 30px -24px rgba(60, 20, 140, .5); }
.hw-lbl { font-size: .78em; font-weight: 600; color: var(--text-muted); }
.hw-field { display: grid; gap: .3em; }
.hw-input { display: flex; align-items: center; min-height: 2.3em; padding: 0 .8em; border: 1px solid var(--line); border-radius: 9px; background: var(--bg); }
.hw-type { display: inline-block; overflow: hidden; white-space: nowrap; max-width: var(--hw-w, 26ch); border-right: 2px solid transparent; }
.hw-btn { display: inline-flex; align-items: center; justify-content: center; gap: .45em; min-height: 2.5em; padding: 0 1.1em; border-radius: 10px; background: #763AED; color: #FFFFFF; font-weight: 700; font-size: .92em; box-shadow: 0 10px 20px -12px rgba(118, 58, 237, .9); justify-self: start; }
.hw-toast { position: absolute; left: 50%; bottom: 0; display: inline-flex; align-items: center; gap: .55em; padding: .7em 1em; border-radius: 12px; background: #1A1128; color: #FFFFFF; font-weight: 600; font-size: .9em; white-space: nowrap; transform: translateX(-50%); box-shadow: 0 16px 30px -14px rgba(0, 0, 0, .55); }
:root[data-theme="dark"] .hw-toast { background: #FFFFFF; color: #1A1128; }
.hw-ok { display: grid; place-items: center; width: 1.5em; height: 1.5em; border-radius: 50%; background: #22A06B; color: #FFFFFF; flex: none; }
.hw-ok svg { width: .95em; height: .95em; stroke-width: 3; }

/* scene 1: sign up */
.hw-s1 .hw-card { width: min(100%, 24em); margin: 0 auto; }
/* scene 2: what you need */
.hw-choices { display: grid; grid-template-columns: 1fr 1fr; gap: .6em; }
.hw-choice { display: flex; align-items: center; gap: .5em; padding: .8em .9em; border: 1.5px solid var(--line); border-radius: 12px; background: var(--surface); font-weight: 700; font-size: .92em; color: var(--text); }
.hw-choice svg { color: #763AED; }
.hw-pick { border-color: #763AED; background: #763AED; color: #FFFFFF; box-shadow: 0 12px 24px -14px rgba(118, 58, 237, .9); }
.hw-pick svg { color: #FFFFFF; }
.hw-row { display: flex; align-items: center; justify-content: space-between; gap: .6em; }
.hw-chip { padding: .35em .8em; border-radius: 999px; background: var(--brand-tint); color: var(--brand-text); font-weight: 700; font-size: .85em; }
.hw-upload { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: .3em .6em; padding: .7em .8em; border: 1px dashed var(--brand-line); border-radius: 10px; color: #763AED; }
.hw-file { color: var(--text); font-size: .88em; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hw-pbar { grid-column: 1 / -1; height: .45em; border-radius: 9px; background: var(--brand-tint); overflow: hidden; }
.hw-pbar i { display: block; height: 100%; width: 100%; border-radius: inherit; background: linear-gradient(90deg, #8B5CF6, #763AED); transform-origin: left; }
/* scene 3: review and plan */
.hw-chat { display: grid; gap: .75em; }
.hw-msg { display: flex; align-items: flex-end; gap: .55em; max-width: 88%; }
.hw-msg p { margin: 0; padding: .65em .9em; border-radius: 14px; font-size: .92em; line-height: 1.4; }
.hw-in p { background: var(--surface); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.hw-out { justify-self: end; }
.hw-out p { background: #763AED; color: #FFFFFF; border-bottom-right-radius: 4px; }
.hw-av { display: grid; place-items: center; width: 2em; height: 2em; border-radius: 50%; background: #FFFFFF; border: 1px solid var(--brand-line); flex: none; }
.hw-av img { width: 70%; height: auto; }
.hw-plan { gap: .55em; margin-left: 2.55em; }
.hw-plan-h { margin: 0; font-weight: 700; }
.hw-plan ul { list-style: none; margin: 0; padding: 0; display: grid; gap: .35em; }
.hw-plan li { display: flex; justify-content: space-between; gap: 1em; padding-bottom: .35em; border-bottom: 1px solid var(--line); font-size: .88em; }
.hw-plan li span { color: var(--text-muted); }
.hw-plan li b { text-align: right; }
.hw-b3 { display: inline-grid; background: #22A06B; box-shadow: 0 10px 20px -12px rgba(34, 160, 107, .9); }   /* final look: approved */
.hw-b3 > span { grid-area: 1 / 1; display: inline-flex; align-items: center; justify-content: center; gap: .35em; }
.hw-b3a { opacity: 0; }
.hw-b3b svg { stroke-width: 3; }
/* scene 4: produce and deliver */
.hw-track { position: relative; display: grid; grid-template-columns: repeat(4, 1fr); padding-top: .2em; }
.hw-line { position: absolute; left: 12.5%; right: 12.5%; top: calc(.2em + .7em - 2px); height: 4px; border-radius: 4px; background: var(--brand-tint); }
.hw-line i { display: block; height: 100%; width: 100%; border-radius: inherit; background: #763AED; transform-origin: left; }
.hw-dot { position: relative; display: grid; justify-items: center; gap: .45em; text-align: center; }
.hw-dot i { width: 1.4em; height: 1.4em; border-radius: 50%; background: #763AED; box-shadow: 0 0 0 4px var(--bg), 0 0 0 6px rgba(118, 58, 237, .35); }
.hw-dot em { font-style: normal; font-size: .78em; font-weight: 600; color: var(--text); }
.hw-done { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: .7em; }
.hw-badge { display: inline-flex; align-items: center; gap: .5em; padding: .55em .9em; border-radius: 999px; background: rgba(34, 160, 107, .12); color: #17825A; font-weight: 700; font-size: .9em; }
:root[data-theme="dark"] .hw-badge { color: #5BD3A2; background: rgba(34, 160, 107, .18); }
.hw-b4 { justify-self: center; }

/* ---- The animation of each scene (plays every time the scene comes on) --------------------- */
.hw-t1 { --hw-w: 6ch; }
.hw-t2 { --hw-w: 24ch; }
.hw-scene.is-on .hw-t1 { animation: hw-type .7s steps(6) .35s both, hw-caret .5s step-end .35s 2; }
.hw-scene.is-on .hw-t2 { animation: hw-type 1.2s steps(24) 1.45s both, hw-caret .5s step-end 1.45s 2; }
.hw-scene.is-on .hw-t3 { animation: hw-type .7s steps(10) 2.65s both; }
.hw-scene.is-on .hw-b1 { animation: hw-press .45s ease 3.45s both; }
.hw-scene.is-on .hw-toast1 { animation: hw-toast .5s var(--ease, ease) 3.75s both; }
@keyframes hw-type { from { max-width: 0; } to { max-width: var(--hw-w, 26ch); } }
@keyframes hw-caret { 50% { border-right-color: #763AED; } }
@keyframes hw-press { 40% { transform: scale(.92); filter: brightness(1.1); } }
@keyframes hw-toast { from { opacity: 0; transform: translate(-50%, 14px); } to { opacity: 1; transform: translate(-50%, 0); } }

.hw-scene.is-on .hw-pick { animation: hw-pick .5s var(--ease, ease) .55s both; }
.hw-scene.is-on .hw-form { animation: hw-rise .5s var(--ease, ease) 1s both; }
.hw-scene.is-on .hw-chip { animation: hw-pop .4s var(--ease, ease) 1.35s both; }
.hw-scene.is-on .hw-pbar i { animation: hw-fill 1.6s cubic-bezier(.4, 0, .2, 1) 1.65s both; }
.hw-scene.is-on .hw-b2 { animation: hw-press .45s ease 3.5s both; }
.hw-scene.is-on .hw-toast2 { animation: hw-toast .5s var(--ease, ease) 3.8s both; }
@keyframes hw-pick { from { background: var(--surface); color: var(--text); border-color: var(--line); box-shadow: none; } }
@keyframes hw-rise { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
@keyframes hw-pop { from { opacity: 0; transform: scale(.7); } 70% { transform: scale(1.06); } to { opacity: 1; transform: none; } }
@keyframes hw-fill { from { transform: scaleX(0); } to { transform: none; } }

.hw-scene.is-on .hw-in { animation: hw-rise .45s var(--ease, ease) .3s both; }
.hw-scene.is-on .hw-plan { animation: hw-rise .5s var(--ease, ease) .95s both; }
.hw-scene.is-on .hw-plan li:nth-child(1) { animation: hw-rise .4s ease 1.3s both; }
.hw-scene.is-on .hw-plan li:nth-child(2) { animation: hw-rise .4s ease 1.5s both; }
.hw-scene.is-on .hw-plan li:nth-child(3) { animation: hw-rise .4s ease 1.7s both; }
.hw-scene.is-on .hw-b3 { animation: hw-press .45s ease 2.6s, hw-green .3s ease 2.9s both; }
.hw-scene.is-on .hw-b3a { animation: hw-out .25s ease 2.9s both; }
.hw-scene.is-on .hw-b3b { animation: hw-show .3s ease 2.95s both; }
.hw-scene.is-on .hw-out { animation: hw-rise .45s var(--ease, ease) 3.55s both; }
@keyframes hw-green { from { background: #763AED; box-shadow: 0 10px 20px -12px rgba(118, 58, 237, .9); } }
@keyframes hw-out { from { opacity: 1; } to { opacity: 0; } }
@keyframes hw-show { from { opacity: 0; } to { opacity: 1; } }

.hw-scene.is-on .hw-line i { animation: hw-fill 2.6s linear .45s both; }
.hw-scene.is-on .hw-d1 i { animation: hw-dot .4s ease .35s both; }
.hw-scene.is-on .hw-d2 i { animation: hw-dot .4s ease 1.2s both; }
.hw-scene.is-on .hw-d3 i { animation: hw-dot .4s ease 2.05s both; }
.hw-scene.is-on .hw-d4 i { animation: hw-dot .4s ease 2.9s both; }
.hw-scene.is-on .hw-badge { animation: hw-pop .5s var(--ease, ease) 3.35s both; }
.hw-scene.is-on .hw-b4 { animation: hw-rise .45s var(--ease, ease) 3.8s both; }
@keyframes hw-dot { from { background: var(--surface-2); box-shadow: 0 0 0 4px var(--bg), 0 0 0 6px var(--line); transform: scale(.85); } }

/* paused (mouse over it, scrolled away, or another tab) */
.hw.is-held .hw-scene * { animation-play-state: paused !important; }

/* without JavaScript: the four steps are listed as plain text instead of the animation */
html:not(.js) .hw-steps.sr-only { position: static; width: auto; height: auto; margin: 0; padding: 0; overflow: visible; clip: auto; white-space: normal; list-style: decimal inside; display: grid; gap: .75rem; }
html:not(.js) .hw-steps .hw-num, html:not(.js) .hw-steps .hw-prog { display: none; }
html:not(.js) .hw-device { display: none; }

@media (prefers-reduced-motion: reduce) {
  .hw-scene, .hw-scene * , .hw-prog i { animation: none !important; transition: opacity .01s !important; }
}
