/* Guide motion layer — section motion graphics, guide map, reading progress, animated FAQ.
   Everything is visible without JS; animations only arm once guide-motion.js adds .gm-js to <html>. */

/* ---------- reading progress (inside the sticky nav) ---------- */
.gm-progress { position: absolute; left: 0; right: 0; bottom: -1px; height: 2px; background: transparent; }
.nav { position: sticky; }
.gm-progress span { display: block; height: 100%; width: 100%; transform-origin: 0 50%; transform: scaleX(0); background: linear-gradient(90deg, var(--brass), var(--brass-soft)); }

/* ---------- guide map ("In this guide") ---------- */
.gm-toc { margin: 36px 0 8px; background: var(--surface-1); border: 1px solid var(--line); border-radius: 14px; padding: 24px 24px 18px; }
.gm-toc-top { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.gm-toc-label { font-family: 'IBM Plex Mono', monospace; font-size: 10.5px; letter-spacing: 1.6px; text-transform: uppercase; color: var(--brass); font-weight: 600; }
.gm-toc-meta { font-family: 'IBM Plex Mono', monospace; font-size: 10.5px; color: var(--ink-faint); letter-spacing: .5px; }
.gm-toc ol { list-style: none; margin: 0; padding: 0; position: relative; }
.gm-toc ol::before { content: ""; position: absolute; left: 15px; top: 14px; bottom: 14px; width: 1px; background: var(--line); }
.gm-toc ol::after { content: ""; position: absolute; left: 15px; top: 14px; width: 1px; height: calc(100% - 28px); background: var(--brass); transform-origin: top; transform: scaleY(var(--gm-toc-fill, 0)); transition: transform .3s linear; }
.gm-toc li { position: relative; }
.gm-toc a { display: flex; align-items: center; gap: 14px; padding: 7px 8px 7px 0; text-decoration: none; color: var(--ink-dim); font-size: 14px; line-height: 1.4; border-radius: 6px; transition: color .2s ease; }
.gm-toc a:hover { color: var(--ink); }
.gm-toc-n { position: relative; z-index: 1; flex: 0 0 31px; height: 31px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-2); border: 1px solid var(--line); font-family: 'IBM Plex Mono', monospace; font-size: 10.5px; font-weight: 600; color: var(--ink-faint); transition: background .25s ease, color .25s ease, border-color .25s ease, transform .25s ease; }
.gm-toc a.is-done .gm-toc-n { border-color: var(--brass); color: var(--brass-soft); }
.gm-toc a.is-active { color: var(--ink); }
.gm-toc a.is-active .gm-toc-n { background: var(--brass); border-color: var(--brass); color: #1a1408; transform: scale(1.08); }

/* ---------- section rail (wide screens only) ---------- */
.gm-rail { display: none; }
@media (min-width: 1240px) {
  .gm-rail { display: flex; flex-direction: column; gap: 10px; position: fixed; left: max(24px, calc(50% - 600px)); top: 50%; transform: translateY(-50%); z-index: 40; opacity: 0; pointer-events: none; transition: opacity .3s ease; }
  .gm-rail.is-on { opacity: 1; pointer-events: auto; }
  .gm-rail a { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink-faint); font-family: 'IBM Plex Mono', monospace; font-size: 10px; letter-spacing: .8px; }
  .gm-rail a i { width: 18px; height: 2px; border-radius: 2px; background: var(--line); transition: width .25s ease, background .25s ease; }
  .gm-rail a span { opacity: 0; transform: translateX(-4px); transition: opacity .2s ease, transform .2s ease; max-width: 150px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-transform: uppercase; }
  .gm-rail a.is-done i { background: var(--brass); }
  .gm-rail a.is-active { color: var(--brass-soft); }
  .gm-rail a.is-active i { width: 34px; background: var(--brass-soft); }
  .gm-rail:hover a span, .gm-rail a.is-active span { opacity: 1; transform: none; }
}

/* ---------- section header motion ---------- */
.gm-section { margin-top: 52px; scroll-margin-top: 80px; }
.gm-intro + .gm-section { margin-top: 40px; }
article .gm-section h2 { margin-top: 14px; }
.gm-sec-head { display: flex; align-items: center; gap: 14px; }
.gm-sec-num { font-family: 'Zilla Slab', Georgia, serif; font-size: 30px; font-weight: 800; line-height: 1; color: var(--brass); letter-spacing: -.5px; }
.gm-sec-line { flex: 1; height: 1px; background: linear-gradient(90deg, var(--brass), var(--line) 60%, transparent); transform-origin: 0 50%; }
.gm-sec-count { font-family: 'IBM Plex Mono', monospace; font-size: 10.5px; color: var(--ink-faint); letter-spacing: 1px; }

/* highlighted phrases inside paragraphs: marker sweep */
.gm-section p strong, .gm-intro p strong { background-image: linear-gradient(rgba(201,161,92,.22), rgba(201,161,92,.22)); background-repeat: no-repeat; background-position: 0 88%; background-size: 100% 38%; padding: 0 2px; border-radius: 2px; }

/* ---------- stat cards (list items carrying a figure) ---------- */
article ul.gm-stats { list-style: none; padding: 0; margin: 22px 0 18px; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
@media (max-width: 560px) { article ul.gm-stats { grid-template-columns: 1fr; } }
.gm-stat { margin: 0 !important; background: var(--surface-1); border: 1px solid var(--line); border-radius: 12px; padding: 18px 18px 16px; position: relative; overflow: hidden; }
.gm-stat::before { content: ""; position: absolute; left: 0; top: 0; height: 2px; width: 100%; background: linear-gradient(90deg, var(--brass), var(--brass-soft)); transform-origin: 0 50%; }
.gm-stat-label { display: block; font-family: 'IBM Plex Mono', monospace; font-size: 10px; letter-spacing: 1.2px; text-transform: uppercase; color: var(--sage); margin-bottom: 8px; }
.gm-stat-value { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 8px; margin-bottom: 10px; }
.gm-stat-num { font-family: 'Zilla Slab', Georgia, serif; font-size: 32px; font-weight: 800; line-height: 1; color: var(--brass-soft); font-variant-numeric: tabular-nums; }
.gm-stat-unit { font-size: 12px; color: var(--ink-faint); font-weight: 600; }
.gm-stat-text { display: block; font-size: 13.5px; line-height: 1.6; color: var(--ink-dim); }
.gm-stat-text strong { color: var(--ink); }

/* ---------- point cards (list items without a figure) ---------- */
article ul.gm-points, article ol.gm-steps { list-style: none; padding: 0; margin: 20px 0 18px; position: relative; }
.gm-point { display: flex; gap: 14px; align-items: flex-start; margin: 0 0 10px !important; background: var(--surface-1); border: 1px solid var(--line-soft); border-radius: 10px; padding: 14px 16px; }
.gm-point-n { flex: 0 0 26px; height: 26px; border-radius: 7px; display: grid; place-items: center; background: var(--surface-2); border: 1px solid var(--line); font-family: 'IBM Plex Mono', monospace; font-size: 10px; font-weight: 600; color: var(--brass-soft); margin-top: 1px; }
.gm-point-body { flex: 1; min-width: 0; }

/* ordered steps: connector line that draws down */
article ol.gm-steps::before { content: ""; position: absolute; left: 13px; top: 20px; bottom: 20px; width: 2px; background: var(--line); }
article ol.gm-steps::after { content: ""; position: absolute; left: 13px; top: 20px; bottom: 20px; width: 2px; background: linear-gradient(180deg, var(--brass), var(--clay)); transform-origin: top; }
.gm-steps .gm-point { background: transparent; border: none; padding: 8px 0; }
.gm-steps .gm-point-n { position: relative; z-index: 1; border-radius: 50%; background: var(--surface-0); border-color: var(--brass); }

/* ---------- callouts ---------- */
.callout.gm-callout { position: relative; overflow: hidden; border-left-color: transparent; }
.callout.gm-callout::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: linear-gradient(180deg, var(--brass-soft), var(--brass)); transform-origin: top; }

/* ---------- FAQ accordion ---------- */
.gm-faq-head { display: flex; align-items: center; gap: 14px; margin-bottom: 18px; }
.gm-faq-head h2 { margin: 0 !important; }
.gm-faq-head .gm-sec-line { flex: 1; }
.faq-item.gm-faq { padding-block: 0; }
.faq-item.gm-faq h3 { margin: 0; font-size: inherit; }
.gm-faq-q { all: unset; box-sizing: border-box; width: 100%; cursor: pointer; display: flex; align-items: center; gap: 14px; padding: 18px 4px; font-family: 'Zilla Slab', Georgia, serif; font-size: 16.5px; font-weight: 600; line-height: 1.35; color: var(--ink); }
.gm-faq-q:focus-visible { outline: 2px solid var(--brass); outline-offset: 2px; border-radius: 6px; }
.gm-faq-n { flex: 0 0 auto; font-family: 'IBM Plex Mono', monospace; font-size: 10.5px; font-weight: 600; color: var(--brass); letter-spacing: .5px; min-width: 26px; }
.gm-faq-text { flex: 1; }
.gm-faq-icon { flex: 0 0 26px; height: 26px; border-radius: 50%; border: 1px solid var(--line); position: relative; transition: background .3s ease, border-color .3s ease, transform .4s cubic-bezier(.2,.7,.2,1); }
.gm-faq-icon::before, .gm-faq-icon::after { content: ""; position: absolute; left: 50%; top: 50%; width: 10px; height: 1.5px; background: var(--brass-soft); transform: translate(-50%, -50%); transition: transform .4s cubic-bezier(.2,.7,.2,1), background .3s ease; }
.gm-faq-icon::after { transform: translate(-50%, -50%) rotate(90deg); }
.gm-faq.open .gm-faq-icon { background: var(--brass); border-color: var(--brass); transform: rotate(180deg); }
.gm-faq.open .gm-faq-icon::before, .gm-faq.open .gm-faq-icon::after { background: #1a1408; }
.gm-faq.open .gm-faq-icon::after { transform: translate(-50%, -50%) rotate(0deg); }
.gm-faq-a > div > p { padding: 0 4px 20px 44px; }
.gm-faq.open .gm-faq-q { color: var(--brass-soft); }

/* ============ motion (armed only when JS is running) ============ */
.gm-js .gm-anim { opacity: 0; transform: translateY(18px); transition: opacity .7s ease, transform .7s cubic-bezier(.2,.7,.2,1); }
.gm-js .gm-anim.in-view { opacity: 1; transform: none; }

.gm-js .gm-sec-num { display: inline-block; opacity: 0; transform: translateY(10px) scale(.9); transition: opacity .6s ease, transform .6s cubic-bezier(.2,.7,.2,1); }
.gm-js .gm-sec-line { transform: scaleX(0); transition: transform 1s cubic-bezier(.2,.7,.2,1) .15s; }
.gm-js .gm-sec-count { opacity: 0; transition: opacity .6s ease .5s; }
.gm-js .in-view .gm-sec-num { opacity: 1; transform: none; }
.gm-js .in-view .gm-sec-line { transform: scaleX(1); }
.gm-js .in-view .gm-sec-count { opacity: 1; }

.gm-js .gm-section h2 { opacity: 0; transform: translateY(12px); transition: opacity .6s ease .1s, transform .6s cubic-bezier(.2,.7,.2,1) .1s; }
.gm-js .gm-section.in-view h2 { opacity: 1; transform: none; }

.gm-js .gm-section p strong, .gm-js .gm-intro p strong { background-size: 0% 38%; transition: background-size .9s cubic-bezier(.2,.7,.2,1) .45s; }
.gm-js .in-view p strong { background-size: 100% 38%; }

.gm-js .gm-stat, .gm-js .gm-point { opacity: 0; transform: translateY(16px); transition: opacity .6s ease, transform .6s cubic-bezier(.2,.7,.2,1), border-color .25s ease; transition-delay: calc(var(--i, 0) * 110ms + 150ms); }
.gm-js .in-view .gm-stat, .gm-js .in-view .gm-point { opacity: 1; transform: none; }
.gm-js .gm-stat::before { transform: scaleX(0); transition: transform 1.1s cubic-bezier(.2,.7,.2,1); transition-delay: calc(var(--i, 0) * 110ms + 350ms); }
.gm-js .in-view .gm-stat::before { transform: scaleX(1); }
.gm-stat:hover, .gm-point:hover { border-color: var(--brass); }

.gm-js ol.gm-steps::after { transform: scaleY(0); transition: transform 1.4s cubic-bezier(.2,.7,.2,1) .3s; }
.gm-js .in-view ol.gm-steps::after { transform: scaleY(1); }

.gm-js .callout.gm-callout { opacity: 0; transform: translateX(-14px); transition: opacity .7s ease, transform .7s cubic-bezier(.2,.7,.2,1); }
.gm-js .callout.gm-callout.in-view { opacity: 1; transform: none; }
.gm-js .callout.gm-callout::before { transform: scaleY(0); transition: transform .9s cubic-bezier(.2,.7,.2,1) .25s; }
.gm-js .callout.gm-callout.in-view::before { transform: scaleY(1); }

.gm-js .gm-toc li { opacity: 0; transform: translateX(-10px); transition: opacity .5s ease, transform .5s ease; transition-delay: calc(var(--i, 0) * 80ms + 120ms); }
.gm-js .gm-toc.in-view li { opacity: 1; transform: none; }

.gm-js .gm-faq { opacity: 0; transform: translateY(12px); transition: opacity .55s ease, transform .55s cubic-bezier(.2,.7,.2,1); transition-delay: calc(var(--i, 0) * 70ms); }
.gm-js .gm-faq-list.in-view .gm-faq { opacity: 1; transform: none; }
.gm-js .gm-faq-a { display: grid; grid-template-rows: 0fr; transition: grid-template-rows .45s cubic-bezier(.2,.7,.2,1); }
.gm-js .gm-faq-a > div { overflow: hidden; }
.gm-js .gm-faq-a > div > p { opacity: 0; transform: translateY(-6px); transition: opacity .35s ease, transform .35s ease; }
.gm-js .gm-faq.open .gm-faq-a { grid-template-rows: 1fr; }
.gm-js .gm-faq.open .gm-faq-a > div > p { opacity: 1; transform: none; transition-delay: .12s; }

@media (prefers-reduced-motion: reduce) {
  .gm-js .gm-anim, .gm-js .gm-sec-num, .gm-js .gm-sec-line, .gm-js .gm-sec-count, .gm-js .gm-section h2,
  .gm-js .gm-stat, .gm-js .gm-point, .gm-js .gm-stat::before, .gm-js ol.gm-steps::after,
  .gm-js .callout.gm-callout, .gm-js .callout.gm-callout::before, .gm-js .gm-toc li, .gm-js .gm-faq,
  .gm-js .gm-faq-a, .gm-js .gm-faq-a > div > p, .gm-js .gm-section p strong, .gm-js .gm-intro p strong {
    transition: none !important; opacity: 1 !important; transform: none !important;
  }
  .gm-js .gm-section p strong, .gm-js .gm-intro p strong { background-size: 100% 38% !important; }
}
