/* How it works: few words, many moving pictures. Light by default, follows the theme. */

h1 em, h2 em { font-family: var(--serif); font-style: italic; font-weight: 500; letter-spacing: -.01em; color: var(--accent); }

/* -- hero ----------------------------------------------------------------------------------------- */
.hw-hero { position: relative; overflow: hidden; padding: 48px 0 40px;
           background: linear-gradient(180deg, var(--band-2), var(--bg)); }
.hw-hero-in { text-align: center; max-width: 860px; }
.hw-hero h1 { font-size: clamp(2.3rem, 5vw, 3.9rem); line-height: 1.05; letter-spacing: -.035em; margin-bottom: 16px; }
.hw-hero h1 em { display: block; }
.hw-hero .lead { margin: 0 auto; }

/* -- swarm: papers pass through the agents; dots on a canvas, agents and picks as HTML -------------- */
.swarm { position: relative; margin-top: 30px; height: clamp(400px, 40vw, 480px); border-radius: 24px;
         background: var(--card); border: 1px solid var(--line); box-shadow: var(--shadow-2); overflow: hidden;
         --cy: 58%; }
.swarm canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }

.station { position: absolute; top: 16px; left: calc(var(--x) * 100%); transform: translateX(-50%);
           display: grid; justify-items: center; gap: 3px; padding: 4px 6px; border: 0; border-radius: 14px;
           background: none; font: inherit; color: var(--ink-2); cursor: pointer; z-index: 2; }
.st-ico { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; background: var(--card);
          box-shadow: inset 0 0 0 1.5px var(--line-2); transition: background .35s, box-shadow .35s, transform .35s var(--ease); }
.st-ico svg { width: 19px; height: 19px; fill: none; stroke: var(--ink-3); stroke-width: 1.8; stroke-linecap: round;
              stroke-linejoin: round; transition: stroke .35s; }
.st-name { font-weight: 700; font-size: .88rem; color: var(--ink); }
.st-n { font-size: .74rem; color: var(--ink-3); font-variant-numeric: tabular-nums; white-space: nowrap; }
.st-n b { color: var(--ink); font-weight: 750; }
.station:hover .st-ico { box-shadow: inset 0 0 0 2px var(--c); }
.station.on .st-ico { background: var(--c); transform: scale(1.08);
                      box-shadow: 0 0 0 6px color-mix(in srgb, var(--c) 18%, transparent); }
.station.on .st-ico svg { stroke: #fff; }
.station.on .st-n b { color: var(--c); }

.sources { position: absolute; left: 14px; top: var(--cy); transform: translateY(-50%); display: grid; gap: 12px; z-index: 1; }
.src-chip { padding: 7px 11px; border-radius: 10px; background: var(--band-2); border: 1px solid var(--line-2);
            font-size: .8rem; font-weight: 650; color: var(--ink); white-space: nowrap; }

.picks { position: absolute; right: 14px; top: var(--cy); transform: translateY(-50%); list-style: none; margin: 0; padding: 0;
         width: clamp(120px, 15vw, 190px); display: grid; gap: 10px; z-index: 1; }
.picks li { position: relative; height: clamp(34px, 3.6vw, 42px); border-radius: 11px; background: var(--card-2); border: 1px dashed var(--line-2);
            padding: 0 12px; display: grid; align-content: center; gap: 6px;
            transition: background .4s, border-color .4s, box-shadow .4s, transform .4s var(--ease); }
.picks li i { display: block; height: 5px; border-radius: 3px; background: var(--line); opacity: .5; transition: background .4s, opacity .4s; }
.picks li i + i { width: 60%; }
.picks li.lit { background: var(--card); border: 1px solid color-mix(in srgb, var(--accent) 45%, var(--line)); transform: translateX(-3px);
                box-shadow: 0 8px 22px color-mix(in srgb, var(--accent) 14%, transparent); }
.picks li.lit i { opacity: 1; background: var(--line-2); }
.picks li.lit i:first-child { background: color-mix(in srgb, var(--accent) 55%, var(--line)); }
.picks li.wild.lit { border-color: color-mix(in srgb, var(--accent-3) 60%, var(--line));
                     box-shadow: 0 8px 22px color-mix(in srgb, var(--accent-3) 16%, transparent); }
.picks li.wild.lit i:first-child { background: color-mix(in srgb, var(--accent-3) 60%, var(--line)); }
.picks em { position: absolute; right: -4px; top: -9px; font-style: normal; font-size: .6rem; font-weight: 700; letter-spacing: .04em;
            text-transform: uppercase; padding: 2px 7px; border-radius: 99px; background: var(--accent-3); color: #fff;
            opacity: 0; transition: opacity .4s; }
.picks li.lit em { opacity: 1; }

.swarm-prog { position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: var(--line); }
.swarm-prog i { display: block; height: 100%; width: 100%; background: var(--grad); transform-origin: left; transform: scaleX(0); }

.swarm-foot { display: grid; grid-template-columns: auto 1fr; align-items: center; gap: 6px 18px; margin-top: 16px; }
.swarm-ctl { display: flex; gap: 8px; grid-row: span 2; }
.sw-btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 38px; min-width: 38px; padding: 0 10px;
          border-radius: 99px; border: 1px solid var(--line-2); background: var(--card); color: var(--ink);
          font: inherit; font-size: .86rem; font-weight: 650; cursor: pointer; transition: border-color .2s, box-shadow .2s; }
.sw-btn.wide { padding: 0 14px 0 11px; }
.sw-btn:hover { border-color: var(--ink-3); box-shadow: var(--shadow-1); }
.sw-btn svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.sw-btn .i-play { fill: currentColor; stroke: none; display: none; }
.sw-btn.paused .i-play { display: block; }
.sw-btn.paused .i-pause { display: none; }
.swarm-say { margin: 0; font-weight: 600; color: var(--ink); min-height: 2.6em; display: flex; align-items: center; }
.swarm-hint { margin: 0; font-size: .82rem; color: var(--ink-3); }

@media (max-width: 640px) {
  .swarm { height: 400px; border-radius: 18px; }
  .station { top: 12px; padding: 2px; left: calc(var(--xm) * 100%); }
  .st-n .u { display: none; }
  .st-ico { width: 32px; height: 32px; }
  .st-ico svg { width: 16px; height: 16px; }
  .st-name { font-size: .7rem; }
  .st-n { font-size: .64rem; }
  .sources { left: 8px; gap: 10px; }
  .src-chip { font-size: 0; padding: 5px 7px; border-radius: 8px; }
  .src-chip::before { content: attr(data-short); font-size: .66rem; }
  .picks { right: 8px; width: 58px; gap: 8px; }
  .picks li { height: 30px; padding: 0 7px; border-radius: 8px; }
  .picks em { display: none; }
  .swarm-foot { grid-template-columns: 1fr; text-align: center; }
  .swarm-ctl { grid-row: auto; justify-content: center; order: 2; }
  .swarm-say { justify-content: center; }
}

/* -- steps: one row of three cards ------------------------------------------------------------------ */
.hw-steps h2 { font-size: clamp(2rem, 4vw, 3rem); }
.step-row { display: grid; gap: 20px; }
@media (min-width: 860px) { .step-row { grid-template-columns: repeat(3, 1fr); } }
.hw-step { background: var(--card); border: 1px solid var(--line); border-radius: 22px; box-shadow: var(--shadow-1); overflow: hidden;
           display: flex; flex-direction: column; }
.hw-vis { height: 210px; padding: 18px; display: grid; place-items: center; overflow: hidden;
          background: var(--card-2); border-bottom: 1px solid var(--line); }
.hw-vis svg { width: 100%; height: 100%; overflow: visible; }
.hw-copy { padding: 20px 22px 24px; }
.hw-n { font-family: var(--serif); font-style: italic; font-size: 1.05rem; color: var(--accent); }
.hw-copy h3 { font-size: 1.4rem; letter-spacing: -.02em; margin: 2px 0 6px; }
.hw-copy p { color: var(--ink-2); margin: 0; }

/* gather */
.vis-gather .src rect { fill: var(--band-2); stroke: var(--line-2); }
.vis-gather .src text { font-size: 13px; font-weight: 650; fill: var(--ink); }
.vis-gather .pipe { fill: none; stroke: var(--line); stroke-width: 6; stroke-linecap: round; }
.vis-gather .flow { fill: none; stroke: var(--accent); stroke-width: 3; stroke-linecap: round; stroke-dasharray: 4 14; opacity: 0; }
.in .vis-gather .flow { opacity: .9; animation: dash 1s linear infinite; }
.in .vis-gather .f2 { animation-duration: .8s; stroke: var(--accent-2); }
.in .vis-gather .f3 { animation-duration: 1.2s; stroke: var(--accent-3); }
@keyframes dash { to { stroke-dashoffset: -18; } }
.vis-gather .pool { fill: var(--ink); }
.vis-gather .pool-ring { fill: none; stroke: color-mix(in srgb, var(--accent) 40%, transparent); stroke-width: 2; transform-box: fill-box; transform-origin: center; }
.in .vis-gather .pool-ring { animation: ripple 2.4s ease-out infinite; }
@keyframes ripple { from { transform: scale(.85); opacity: 1; } to { transform: scale(1.25); opacity: 0; } }
.vis-gather .pool-n { fill: var(--bg); font-size: 24px; font-weight: 800; font-variant-numeric: tabular-nums; }
.vis-gather .pool-l { fill: color-mix(in srgb, var(--bg) 70%, transparent); font-size: 10px; font-weight: 600; }

/* choose: rows slide into ranked order */
.rank { list-style: none; margin: 0; padding: 0; width: 100%; max-width: 340px; position: relative; height: 186px; }
.rank li { position: absolute; left: 0; right: 0; top: 0; height: 26px; display: grid; grid-template-columns: 22px 1fr 28px;
           align-items: center; gap: 12px; padding: 0 10px; border-radius: 9px; background: var(--card);
           border: 1px solid var(--line); transform: translateY(calc(var(--from) * 32px));
           transition: transform 1s var(--ease), background .6s, border-color .6s, opacity .6s; }
.in .vis-choose .rank li { transform: translateY(calc(var(--to) * 32px)); transition-delay: .5s; }
.in .vis-choose .rank li:not(.top) { opacity: .5; transition-delay: .5s, 1.3s, 1.3s, 1.3s; }
.in .vis-choose .rank li.top { border-color: color-mix(in srgb, var(--accent) 40%, var(--line));
                                box-shadow: var(--shadow-1); transition-delay: .5s, 1.3s, 1.3s, 1.3s; }
.r-doc { display: grid; gap: 3px; width: 16px; height: 18px; padding: 4px 3px; border-radius: 3px; background: var(--card-2); box-shadow: inset 0 0 0 1px var(--line-2); }
.r-doc i { display: block; height: 2px; border-radius: 1px; background: var(--line-2); }
.r-bar { height: 7px; border-radius: 4px; background: var(--line); overflow: hidden; }
.r-bar i { display: block; height: 100%; width: var(--s); border-radius: inherit; background: var(--ink-3);
           transform-origin: left; transform: scaleX(0); transition: transform .9s var(--ease) .1s, background .6s 1.3s; }
.in .vis-choose .r-bar i { transform: scaleX(1); }
.in .vis-choose .top .r-bar i { background: var(--accent); }
.in .vis-choose [data-explore] .r-bar i { background: var(--accent-3); }
.rank b { font-size: .78rem; font-variant-numeric: tabular-nums; color: var(--ink-2); text-align: right; }
.rank li[data-explore]::after { content: "explore"; position: absolute; right: -6px; top: -9px; font-size: .58rem; font-weight: 700;
                                letter-spacing: .04em; text-transform: uppercase; padding: 1px 6px; border-radius: 99px;
                                background: var(--accent-3); color: #fff; opacity: 0; transition: opacity .4s 1.6s; }
.in .vis-choose .rank li[data-explore]::after { opacity: 1; }

/* learn: a loop that never stops */
.vis-learn .loop { fill: none; stroke: var(--line); stroke-width: 2; }
.vis-learn .runner { fill: var(--accent); }
.vis-learn .core circle { fill: var(--ink); }
.vis-learn .core-i { fill: none; stroke: var(--bg); stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.vis-learn .act circle { fill: var(--card); stroke: var(--line-2); stroke-width: 1.5; }
.vis-learn .act path { fill: none; stroke: var(--ink); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.vis-learn .act { animation: ping 5s ease-in-out infinite; }
.vis-learn .a2 { animation-delay: 1.66s; }
.vis-learn .a3 { animation-delay: 3.33s; }
@keyframes ping { 0%, 18%, 100% { opacity: .55; } 6% { opacity: 1; } }
.vis-learn .act-l { font-size: 13px; font-weight: 650; fill: var(--ink-2); }

/* -- under the hood --------------------------------------------------------------------------------- */
.narrow { max-width: 780px; }
.center { text-align: center; }
.deep { margin-top: 28px; border-top: 1px solid var(--line); }
.deep details { border-bottom: 1px solid var(--line); }
.deep summary { cursor: pointer; list-style: none; display: flex; justify-content: space-between; align-items: center;
                padding: 18px 4px; font-weight: 650; font-size: 1.02rem; }
.deep summary::-webkit-details-marker { display: none; }
.deep summary::after { content: "+"; font-size: 1.3rem; font-weight: 400; color: var(--ink-3); transition: transform .25s var(--ease); }
.deep details[open] summary::after { transform: rotate(45deg); }
.deep p { margin: 0 4px 20px; color: var(--ink-2); font-size: .95rem; }

/* -- closing (matches the home page's last section) -------------------------------------------------- */
.hw-end .center-head { margin-bottom: 0; }
.hw-end h2 { font-size: clamp(1.8rem, 3.4vw, 2.5rem); }
.end-actions { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; margin-top: 26px; }
.end-actions .btn { padding: 13px 24px; font-size: 1rem; }

@media (prefers-reduced-motion: reduce) {
  .how-page * { animation: none !important; transition: none !important; }
}
