/* Card Forge tutorials (help.html). Layout only: colours are style.css's
   --ui-* roles, so both themes work. */

.help-page .home-header { position: sticky; top: 0; z-index: 30; background: var(--ui-bg); border-bottom: 1px solid var(--ui-line); }
.home-nav a[aria-current="page"] { color: var(--ui-strong); }
.help-toc-btn { display: none; }

/* ---------- Hero ---------- */
.help-hero { max-width: 880px; margin: 0 auto; padding: 56px 24px 28px; text-align: center; }
.help-hero h1 { margin: 6px 0 12px; font-size: clamp(28px, 4vw, 42px); line-height: 1.12; color: var(--ui-strong); }
.help-hero .lede { margin: 0 auto 24px; max-width: 640px; color: var(--ui-dim); font-size: 16px; line-height: 1.6; }
.hl-swatch { padding: 0 6px; border-radius: 5px; outline: 2px solid #ffb020; outline-offset: 1px; color: var(--ui-text); }

.help-search { display: flex; align-items: center; gap: 10px; max-width: 560px; margin: 0 auto; padding: 0 16px;
  background: var(--ui-panel); border: 1px solid var(--ui-line-2); border-radius: 12px; }
.help-search:focus-within { border-color: var(--ui-accent); box-shadow: 0 0 0 3px var(--ui-accent-soft); }
.help-search svg { width: 18px; height: 18px; flex: none; fill: none; stroke: var(--ui-dim); stroke-width: 2; stroke-linecap: round; }
.help-search input { flex: 1; min-width: 0; height: 48px; border: 0; background: none; color: var(--ui-text); font: inherit; font-size: 16px; outline: none; }
.help-count { min-height: 20px; margin: 8px 0 0; color: var(--ui-dim); font-size: 13px; }

.quick-path { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin: 18px 0 0; padding: 0; list-style: none; }
.quick-path a { display: inline-flex; align-items: center; gap: 8px; padding: 7px 14px 7px 7px; border-radius: 999px;
  background: var(--ui-panel); border: 1px solid var(--ui-line); color: var(--ui-text); text-decoration: none; font-size: 14px; font-weight: 600; }
.quick-path a:hover { border-color: var(--ui-hover-line); }
.quick-path b { display: grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: var(--ui-accent); color: var(--ui-on-accent); font-size: 13px; }

/* ---------- Layout ---------- */
.help-layout { display: grid; grid-template-columns: 250px minmax(0, 1fr); gap: 40px; max-width: 1240px; margin: 0 auto; padding: 16px 24px 64px; }

.toc { position: sticky; top: 84px; align-self: start; max-height: calc(100vh - 100px); overflow: auto; padding-right: 6px; font-size: 14px; }
.toc-head { display: none; }
.toc ol { margin: 0; padding: 0; list-style: none; }
.toc > ol > li { margin-bottom: 4px; }
.toc a { display: block; padding: 5px 10px; border-radius: 7px; color: var(--ui-dim); text-decoration: none; line-height: 1.35; }
.toc a:hover { color: var(--ui-text); background: var(--ui-panel); }
.toc .toc-ch > a { color: var(--ui-text); font-weight: 700; }
.toc .toc-ch > a span { display: inline-block; min-width: 22px; color: var(--ui-faint); }
.toc .toc-ch ol { padding-left: 22px; }
.toc a.is-current { color: var(--ui-accent-text); background: var(--ui-accent-soft); }
.toc li.is-filtered { display: none; }

/* ---------- Chapters and topics ---------- */
.help-main { min-width: 0; }
.chapter { margin-bottom: 40px; }
.chapter.is-filtered, .topic.is-filtered { display: none; }
.chapter-head { display: flex; gap: 16px; align-items: flex-start; padding: 18px 0 14px; margin-bottom: 18px; border-bottom: 1px solid var(--ui-line-2); }
.chapter-num { display: grid; place-items: center; flex: none; width: 44px; height: 44px; border-radius: 12px;
  background: linear-gradient(135deg, var(--ui-accent-2), var(--ui-accent)); color: var(--ui-on-accent); font-size: 20px; font-weight: 800; }
.chapter-head h2 { margin: 0; font-size: 26px; color: var(--ui-strong); }
.chapter-head p { margin: 4px 0 0; color: var(--ui-dim); }

.topic { margin: 0 0 22px; padding: 24px 26px; background: var(--ui-panel); border: 1px solid var(--ui-line); border-radius: 16px; scroll-margin-top: 84px; }
.chapter { scroll-margin-top: 84px; }
.topic h3 { margin: 0 0 6px; font-size: 20px; color: var(--ui-strong); }
.topic h3 a.anchor { margin-left: 8px; color: var(--ui-faint); text-decoration: none; font-weight: 400; opacity: 0; }
.topic:hover h3 a.anchor, .topic h3 a.anchor:focus { opacity: 1; }
.topic .lead { margin: 0 0 16px; color: var(--ui-dim); font-size: 15px; line-height: 1.6; }
.topic a { color: var(--ui-accent); }

.shot { margin: 0 0 18px; }
.shot button { display: block; width: 100%; padding: 0; border: 1px solid var(--ui-line-2); border-radius: 12px; overflow: hidden;
  background: var(--ui-bg-2); cursor: zoom-in; box-shadow: 0 10px 30px var(--ui-shadow); }
.shot img { display: block; width: 100%; height: auto; }
.shot-narrow button { max-width: 360px; margin: 0 auto; }
.topic-row { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 26px; align-items: start; }
.shot-phone button { max-width: 300px; border-radius: 22px; }

/* Numbered steps */
.steps, .legend { margin: 0; padding: 0; list-style: none; counter-reset: step; }
.steps li { position: relative; margin: 0 0 10px; padding: 2px 0 0 40px; line-height: 1.6; counter-increment: step; }
.steps li::before { content: counter(step); position: absolute; left: 0; top: 0; display: grid; place-items: center; width: 28px; height: 28px;
  border-radius: 50%; background: var(--ui-accent-soft); color: var(--ui-accent-text); font-size: 13px; font-weight: 800; }
.legend { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 22px; }
.legend li { display: flex; gap: 10px; line-height: 1.5; }
.legend b { display: grid; place-items: center; flex: none; width: 26px; height: 26px; border-radius: 50%; background: #ffb020; color: #16120a; font-size: 13px; }

.tip, .note { margin: 14px 0 0; padding: 12px 14px; border-radius: 10px; line-height: 1.55; font-size: 14px; }
.tip { background: var(--ui-ok-bg); border: 1px solid var(--ui-ok-line); color: var(--ui-ok-text); }
.tip strong:first-child { margin-right: 6px; padding: 1px 7px; border-radius: 5px; background: var(--ui-ok-line); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
.note { background: var(--ui-warn-bg); border: 1px solid var(--ui-warn-line); color: var(--ui-warn-text); }

kbd { display: inline-block; min-width: 20px; padding: 1px 6px; border: 1px solid var(--ui-line-2); border-bottom-width: 2px; border-radius: 5px;
  background: var(--ui-bg-2); color: var(--ui-text); font: 600 12px/1.5 ui-monospace, Consolas, monospace; text-align: center; }
code { padding: 1px 5px; border-radius: 4px; background: var(--ui-bg-2); color: var(--ui-accent-text); font: 13px ui-monospace, Consolas, monospace; }

.cheat { width: 100%; margin: 0 0 16px; border-collapse: collapse; font-size: 14px; }
.cheat th, .cheat td { padding: 9px 10px; border-bottom: 1px solid var(--ui-line); text-align: left; vertical-align: top; }
.cheat th { color: var(--ui-dim); font-weight: 600; }
.cheat.keys td:nth-child(odd) { white-space: nowrap; }
.cheat.keys td:nth-child(3) { border-left: 1px solid var(--ui-line); }

.help-none { padding: 40px; text-align: center; color: var(--ui-dim); font-size: 16px; }
.help-end { margin: 30px 0 0; color: var(--ui-dim); text-align: center; }
mark.help-mark { padding: 0 2px; border-radius: 3px; background: rgba(255, 176, 32, .35); color: inherit; }

/* ---------- Lightbox ---------- */
.lightbox { position: fixed; inset: 0; z-index: 100; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px;
  padding: 24px; background: var(--ui-scrim-strong); cursor: zoom-out; }
.lightbox[hidden] { display: none; }
.lightbox img { max-width: 100%; max-height: calc(100% - 50px); border-radius: 10px; box-shadow: 0 20px 60px var(--ui-shadow-strong); }
.lightbox-cap { margin: 0; color: var(--ui-text); font-size: 14px; text-align: center; }
.lightbox-close { position: absolute; top: 14px; right: 16px; width: 40px; height: 40px; border: 0; border-radius: 50%;
  background: var(--ui-panel); color: var(--ui-text); font-size: 18px; cursor: pointer; }

/* ---------- Narrow screens ---------- */
@media (max-width: 960px) {
  .help-layout { grid-template-columns: minmax(0, 1fr); padding: 8px 16px 48px; }
  .help-toc-btn { display: inline-flex; }
  /* align-self applies to a fixed box too: start would size it to its content. */
  .toc { position: fixed; top: 0; bottom: 0; left: 0; z-index: 60; align-self: stretch; width: min(320px, 86vw); max-height: none; padding: 16px; overscroll-behavior: contain;
    background: var(--ui-panel); border-right: 1px solid var(--ui-line-2); box-shadow: 10px 0 40px var(--ui-shadow);
    transform: translateX(-105%); transition: transform .2s ease; }
  .toc.is-open { transform: none; }
  .toc-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
  .topic { padding: 18px 16px; }
  .topic-row { grid-template-columns: minmax(0, 1fr); }
  .shot-phone button { margin: 0 auto; }
  .legend { grid-template-columns: minmax(0, 1fr); }
  .topic h3 a.anchor { display: none; }
}
@media (max-width: 600px) {
  .help-page .home-header { padding: 10px 16px; }
  .help-page .home-nav { display: none; }
  .help-page .brand-text p { display: none; }
  .help-hero { padding: 32px 16px 16px; }
  .chapter-head h2 { font-size: 22px; }
  .cheat.keys, .cheat.keys tbody, .cheat.keys tr { display: block; }
  .cheat.keys td { display: inline-block; border: 0 !important; padding: 6px 6px 6px 0; white-space: normal !important; }
  .cheat.keys td:nth-child(even) { width: calc(50% - 12px); color: var(--ui-dim); }
  .cheat.keys td:nth-child(odd) { width: 50%; }
  .cheat.keys tr { border-bottom: 1px solid var(--ui-line); padding: 4px 0; }
  .cheat.plans { font-size: 12px; }
  .cheat.plans th, .cheat.plans td { padding: 7px 5px; }
}
@media (prefers-reduced-motion: reduce) { .toc { transition: none; } }
