/* How a reading is made (#how-reading): four beats played by the scroll.
   Same visual language as the AshvaAI family scene (landing.css .stage,
   .node, .rule, .flows; thread.css .ai-scroll): the rounded stage panel,
   line art in the ink colour, pill chips with a dot, round avatar nodes and
   thin connectors that draw themselves. how-section.js sets every element's
   progress from the scroll position (transform, opacity, stroke-dashoffset),
   so scrolling back plays it backwards.
   Without JavaScript, or with reduced motion: the finished picture, no pin. */

.how .h2 { max-width:17ch; margin:0 auto; }

/* ---------- The pin (as .ai-scroll / .ai-pin / .ai-fit) ---------- */
.how-scroll { position:relative; }
html.how-scrolly .how-scroll { height:480vh; }
html.how-scrolly .how-pin { position:sticky; top:0; height:100vh; height:100svh; }
html.how-scrolly .how-fit { position:absolute; left:50%; top:50%; width:100%; transform:translate(-50%,-50%) scale(var(--fit,1)); transform-origin:center; }

/* ---------- The steps (the family scene's .demo-steps) ---------- */
.how-steps b { font-size:clamp(19px,1.75vw,24px); }

/* ---------- The stage ---------- */
.how-stage { position:relative; display:grid; grid-template-columns:minmax(0,.8fr) minmax(0,1.32fr) minmax(0,1fr) minmax(0,1.08fr);
  gap:clamp(18px,2.6vw,40px); align-items:center; min-height:500px;
  border:.5px solid var(--line); border-radius:32px; padding:clamp(22px,3vw,40px); overflow:hidden;
  background:radial-gradient(120% 90% at 55% 50%, color-mix(in srgb,var(--tint) 7%,var(--card)) 0%, var(--card) 70%); }
.how-flows { position:absolute; inset:0; width:100%; height:100%; pointer-events:none; z-index:0; overflow:visible; }
.how-flows path { fill:none; stroke:color-mix(in srgb,var(--thread) 80%,var(--line)); stroke-width:2; stroke-linecap:round; stroke-linejoin:round; stroke-dasharray:1; stroke-dashoffset:0; }
.how-flows path.pulse { stroke:var(--tint); stroke-width:7; stroke-dasharray:0 2; opacity:0; }
.how-g { position:relative; z-index:1; min-width:0; }

/* Beat 1: the three inputs, as the family scene's people. */
.how-g-in { display:flex; flex-direction:column; align-items:flex-start; gap:22px; }
.how-in { display:flex; align-items:center; gap:10px; padding:7px 16px 7px 7px; border-radius:999px; background:var(--card); border:.5px solid var(--line);
  box-shadow:0 14px 30px -20px rgba(0,0,0,.4); max-width:100%; }
.how-in .av { width:38px; height:38px; border-radius:50%; display:grid; place-items:center; background:var(--tint-grad); color:var(--on-accent); flex:none; }
[data-theme="white-light"] .how-in .av { color:#fff; }
.how-in .av svg { width:19px; height:19px; fill:none; stroke:currentColor; stroke-width:1.9; stroke-linecap:round; stroke-linejoin:round; }
.how-in b { font-size:15px; line-height:1.25; font-weight:600; }

/* Beats 1 and 2: the sky wheel and the kundali share one drawing. */
.how-g-chart { display:flex; flex-direction:column; align-items:center; gap:14px; }
.how-chart-box { width:100%; max-width:380px; aspect-ratio:1; }
html.how-scrolly .how-chart-box { transform-origin:50% 0; }
.how-chart { display:block; width:100%; height:100%; overflow:visible; }
.how-ln { fill:none; stroke:var(--fg2); stroke-width:1.6; stroke-linejoin:round; stroke-dasharray:1; stroke-dashoffset:0; }
.how-spk { stroke-width:1.2; }
.how-dash { stroke-dasharray:2 5; stroke-width:1; opacity:.6; }
.how-earth { fill:var(--fg2); transform-box:fill-box; transform-origin:center; }
.how-wheel { transform-origin:150px 150px; }
html:not(.how-scrolly) .how-wheel { display:none; }
.how-h10 { fill:color-mix(in srgb,var(--tint) 16%,transparent); }
.how-hl text { font:600 13px var(--font-body); fill:var(--fg2); text-anchor:middle; letter-spacing:0; }
.how-pl { fill:var(--tint); }
.how-ju { stroke:var(--card); stroke-width:1.5; }
.how-ring { fill:none; stroke:var(--tint); stroke-width:1.6; stroke-dasharray:1; stroke-dashoffset:0; }
.how-tags { display:grid; justify-items:center; }
.how-tag { grid-area:1 / 1; align-self:center; font-size:13px; font-weight:600; padding:5px 12px; border-radius:14px; background:color-mix(in srgb,var(--tint) 14%,var(--card)); color:var(--fg); text-align:center; text-wrap:balance; }
html:not(.how-scrolly) .how-tag:first-child { visibility:hidden; }

/* Beat 3: the rule, as a card (the family scene's answer card). */
.how-card { background:var(--card); border:.5px solid var(--line); border-radius:18px; padding:16px 18px 18px; box-shadow:0 20px 40px -28px rgba(0,0,0,.4); }
.how-card-h { font-size:12.5px; font-weight:700; letter-spacing:.08em; text-transform:uppercase; color:var(--muted); }
html[data-indic] .how-card-h, html[data-lang="zh"] .how-card-h { letter-spacing:.02em; font-size:13px; }
.how-conds { list-style:none; margin-top:12px; display:flex; flex-direction:column; gap:10px; }
.how-conds li { display:grid; grid-template-columns:24px minmax(0,1fr); column-gap:10px; align-items:start; }
.how-tk { grid-row:1 / 3; width:24px; height:24px; line-height:0; }
.how-tk svg { width:24px; height:24px; overflow:visible; }
.how-tk circle { fill:var(--card); stroke:var(--line); stroke-width:1.5; }
.how-tk .how-tk-f { fill:var(--tint); stroke:var(--tint); }
.how-tk path { fill:none; stroke:var(--on-accent); stroke-width:2.2; stroke-linecap:round; stroke-linejoin:round; stroke-dasharray:1; stroke-dashoffset:0; }
[data-theme="white-light"] .how-tk path { stroke:#fff; }
.how-kw { font-size:11.5px; font-weight:800; letter-spacing:.12em; color:var(--tint); line-height:1.4; }
[data-theme^="mono"] .how-kw { color:var(--fg); }
html[data-indic] .how-kw, html[data-lang="zh"] .how-kw { letter-spacing:.02em; font-size:13px; }
.how-ct { font-size:15px; line-height:1.4; color:var(--fg); }
.how-conds li.then .how-ct { font-weight:700; }
.how-src { display:flex; gap:8px; align-items:flex-start; margin-top:14px; padding:8px 12px; border-radius:14px; border:1px solid color-mix(in srgb,var(--tint) 45%,var(--line));
  font-size:13px; font-weight:600; line-height:1.4; }
.how-src::before { content:""; width:7px; height:7px; margin-top:6px; border-radius:50%; background:var(--tint); flex:none; }

/* Beat 4: rules that agree (the .rule pills), the window, AshvaAI. */
.how-g-res { display:flex; flex-direction:column; gap:22px; }
.how-chips { display:flex; flex-direction:column; align-items:flex-start; gap:8px; padding-left:22px; }
.how-chip { display:inline-flex; align-items:center; gap:8px; max-width:100%; font-size:13px; font-weight:700; line-height:1.3; padding:6px 12px 6px 7px; border-radius:16px;
  border:1px solid color-mix(in srgb,var(--tint) 45%,var(--line)); background:var(--card); }
.how-chip i { width:16px; height:16px; border-radius:50%; background:var(--tint); flex:none; display:grid; place-items:center; }
.how-chip svg { width:12px; height:12px; fill:none; stroke:var(--on-accent); stroke-width:1.8; stroke-linecap:round; stroke-linejoin:round; }
[data-theme="white-light"] .how-chip svg { stroke:#fff; }
.how-time { padding-left:22px; }
.how-line { display:flex; align-items:center; gap:8px; }
.how-yr { font-size:13px; font-weight:600; color:var(--muted); font-variant-numeric:tabular-nums; }
.how-track { position:relative; flex:1; height:22px; }
.how-track::before { content:""; position:absolute; left:0; right:0; top:50%; height:1.5px; margin-top:-.75px; background:var(--fg2); opacity:.55; }
.how-track i { position:absolute; left:calc(var(--m) / 12 * 100%); top:50%; width:1.5px; height:8px; margin:-4px 0 0 -.75px; background:var(--fg2); opacity:.55; }
.how-win { position:absolute; left:calc(5 / 12 * 100%); width:calc(5 / 12 * 100%); top:2px; bottom:2px; border-radius:999px; background:var(--tint-grad); transform-origin:left center; }
.how-time { padding-bottom:30px; }
.how-win-l { position:absolute; right:calc(2 / 12 * 100%); top:28px; font-size:15px; font-weight:700; text-align:right; width:max-content; max-width:calc(10 / 12 * 100% + 40px); }
.how-ai { display:flex; align-items:center; gap:14px; }
.how-node { width:88px; height:88px; flex:none; opacity:1; transform:none; transition:none; }
.how-node .site-mark { width:34px; height:34px; }
.how-node b { font-size:12px; }
.how-node.lit::after { animation:ring 2.4s var(--m-ease) infinite; }
.how-ai-l { font-size:14px; font-weight:600; line-height:1.4; color:var(--fg2); }

.how-close { max-width:30ch; margin-left:auto; margin-right:auto; }

/* ---------- Played by the scroll ---------- */
html.how-scrolly .how-demo [data-fx], html.how-scrolly .how-pl { will-change:opacity, transform; }
html.how-scrolly .how-demo .how-g { transition:none; }

/* ---------- Tablets: two columns ---------- */
@media (max-width:1100px) and (min-width:761px) {
  .how-stage { grid-template-columns:minmax(0,.7fr) minmax(0,1fr); row-gap:32px; }
  .how-g-in { flex-direction:row; flex-wrap:wrap; }
}

/* ---------- Phones: three screens that replace each other in the pin ---------- */
@media (max-width:760px) {
  html.thread-on #how-reading .wrap { padding-left:44px; padding-right:16px; }
  .how-close { text-align:left; margin-left:0; }
  .how-stage { display:flex; flex-direction:column; align-items:stretch; gap:26px; min-height:0; border:0; border-radius:0; padding:0; background:none; overflow:visible; }
  .how-g-in { flex-direction:row; flex-wrap:nowrap; justify-content:space-around; align-items:flex-start; gap:6px; }
  .how-in { flex:1 1 0; flex-direction:column; gap:6px; padding:0; border:0; border-radius:0; background:none; box-shadow:none; text-align:center; min-width:0; }
  .how-in .av { width:40px; height:40px; }
  .how-in .av svg { width:19px; height:19px; }
  .how-in b { font-size:14px; overflow-wrap:anywhere; }
  .how-chart-box { max-width:min(300px,100%); }
  .how-ct { font-size:16px; }
  .how-src { font-size:13.5px; }
  .how-win-l { font-size:16px; }

  /* Steps: a slim strip of four segments, then the current title and caption. */
  html.how-scrolly .how-steps { display:flex; gap:6px; position:relative; margin:0; padding-bottom:var(--cap-h,150px); }
  html.how-scrolly .how-steps li { flex:1; position:static; border:0; border-radius:0; padding:0; background:none; opacity:1; }
  html.how-scrolly .how-steps .n { width:100%; height:4px; margin:0; border:0; border-radius:2px; background:var(--line); font-size:0; color:transparent; }
  html.how-scrolly .how-steps li.on .n { background:var(--thread); }
  html.how-scrolly .how-st { position:absolute; left:0; right:0; top:14px; opacity:0; transform:translate3d(0,6px,0);
    transition:opacity var(--m-med) var(--m-ease), transform var(--m-med) var(--m-ease); }
  html.how-scrolly .how-steps b { margin:0; font-size:21px; line-height:1.2; }
  html[data-indic].how-scrolly .how-steps b { line-height:1.35; }
  html.how-scrolly .how-steps small { margin-top:6px; font-size:14.5px; line-height:1.45; }
  html.how-scrolly .how-steps li.cur .how-st, html.how-scrolly .how-steps:not(:has(.cur)) li:first-child .how-st { opacity:1; transform:none; }

  html.how-scrolly .how-fit { position:absolute; inset:0; width:auto; transform:none; }
  html.how-scrolly .how-demo { height:100%; display:flex; flex-direction:column; justify-content:flex-start; padding:16px 0 12px; }
  html.how-scrolly .how-stage { display:block; flex:1; min-height:0; position:relative; margin-top:10px; }
  html.how-scrolly .how-g { position:absolute; left:0; right:0; }
  html.how-scrolly .how-g-in { top:0; }
  html.how-scrolly .how-g-chart { top:var(--in-h,60px); bottom:0; justify-content:center; }
  html.how-scrolly .how-chart-box { width:auto; height:min(100%, 300px); max-height:calc(100% - 44px); }
  html.how-scrolly .how-g-rule, html.how-scrolly .how-g-res { transform-origin:0 0; }
  html.how-scrolly .how-g-rule { top:var(--thumb-h,150px); }
  html.how-scrolly .how-g-res { top:0; gap:34px; }
  .how-chips { gap:12px; }
  .how-chip { font-size:15px; padding:9px 14px 9px 9px; gap:10px; }
  .how-chip i { width:20px; height:20px; }
  .how-node { width:104px; height:104px; }
  .how-node .site-mark { width:40px; height:40px; }
  .how-ai-l { font-size:15px; }
  .how-ai { flex-direction:column; gap:10px; text-align:center; }
  .how-ai-l { max-width:30ch; }
  .how-card-h, .how-kw, html[data-indic] .how-kw, .how-node b, .how-yr { font-size:13px; }
}
@media (max-width:360px) {
  .how-ct { font-size:15px; }
  .how-in b { font-size:13px; }
  html.how-scrolly .how-steps b { font-size:19px; }
  html.how-scrolly .how-steps small { font-size:13.5px; }
}

/* ---------- Reduced motion: the finished picture, no pin ---------- */
@media (prefers-reduced-motion:reduce) {
  .how-node.lit::after { animation:none; }
}
