/* Copyright (c) 2026 LoveByPDF. All rights reserved.
   Round 79 - "How to use" guide (templates/_howto.html). Uses the site's own variables for surfaces and
   text; navy #1F3864 / blue #2E5395 for the numbered badges and accents (lighter in dark mode).
   Motion: the reveal is a plain opacity/translate transition on each step card, applied only when
   howto.js added .howto-anim (i.e. prefers-reduced-motion: no-preference). Nothing animates body,
   main or a wrapper of a fixed popup; the zoom overlay lives directly under <body>. */

.howto {
  --hw-navy: #1F3864;
  --hw-blue: #2E5395;
  --hw-blue-soft: rgba(46, 83, 149, 0.10);
  --hw-blue-line: rgba(46, 83, 149, 0.28);
  --hw-badge-fg: #fff;
  --hw-ring: #E5252A;
  max-width: 1120px;
  margin: 44px auto 12px;
  padding: 0 0 8px;
  color: var(--text);
  text-align: left;
}
:root[data-theme="dark"] .howto {
  --hw-navy: #8FB0E8;
  --hw-blue: #7FA2DF;
  --hw-blue-soft: rgba(127, 162, 223, 0.14);
  --hw-blue-line: rgba(127, 162, 223, 0.34);
  --hw-badge-fg: #0F1B33;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .howto {
    --hw-navy: #8FB0E8;
    --hw-blue: #7FA2DF;
    --hw-blue-soft: rgba(127, 162, 223, 0.14);
    --hw-blue-line: rgba(127, 162, 223, 0.34);
    --hw-badge-fg: #0F1B33;
  }
}

.howto-head { margin-bottom: 22px; }
.howto-eyebrow {
  display: inline-flex; align-items: center; gap: 7px;
  margin: 0 0 10px; padding: 5px 12px;
  font-size: 0.82rem; font-weight: 600; letter-spacing: 0.02em;
  color: var(--hw-blue); background: var(--hw-blue-soft);
  border: 1px solid var(--hw-blue-line); border-radius: 999px;
}
.howto h2 {
  margin: 0 0 10px; font-size: clamp(1.4rem, 1.1rem + 1.4vw, 2rem); line-height: 1.22;
  color: var(--hw-navy);
}
.howto-intro { margin: 0 0 16px; max-width: 78ch; font-size: 1.02rem; line-height: 1.65; color: var(--text); }

/* jump chips */
.howto-jump ol { display: flex; flex-wrap: wrap; gap: 8px; margin: 0; padding: 0; list-style: none; }
.howto-jump a {
  display: inline-flex; align-items: center; gap: 8px; max-width: 100%;
  padding: 6px 12px 6px 6px; font-size: 0.86rem; line-height: 1.25; text-decoration: none;
  color: var(--text); background: var(--card); border: 1px solid var(--border); border-radius: 999px;
  transition: border-color .15s ease, background-color .15s ease;
}
.howto-jump a:hover, .howto-jump a:focus-visible { border-color: var(--hw-blue); background: var(--hw-blue-soft); }
.howto-jump-n {
  flex: none; width: 24px; height: 24px; display: inline-grid; place-items: center;
  font-size: 0.78rem; font-weight: 700; color: var(--hw-badge-fg); background: var(--hw-navy); border-radius: 50%;
}

/* steps */
.howto-steps { list-style: none; margin: 26px 0 0; padding: 0; display: grid; gap: 22px; }
.howto-step {
  display: grid; grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.6fr); gap: 22px; align-items: start;
  padding: 20px; background: var(--card); border: 1px solid var(--border); border-radius: 18px;
  box-shadow: 0 1px 2px rgba(15, 27, 51, 0.04), 0 8px 24px -16px rgba(15, 27, 51, 0.18);
  scroll-margin-top: 90px;
}
.howto-step-textonly { grid-template-columns: 1fr; }
.howto-step-text { position: relative; padding-top: 2px; }
.howto-num {
  display: inline-grid; place-items: center; width: 40px; height: 40px; margin-bottom: 10px;
  font-size: 1.1rem; font-weight: 800; color: var(--hw-badge-fg);
  background: linear-gradient(135deg, var(--hw-navy), var(--hw-blue)); border-radius: 12px;
}
.howto-step h3 { margin: 0 0 8px; font-size: 1.15rem; line-height: 1.3; color: var(--hw-navy); }
.howto-step p { margin: 0; line-height: 1.65; color: var(--text); }

.howto-fig { margin: 0; min-width: 0; }
.howto-zoom {
  position: relative; display: block; width: 100%; padding: 0; margin: 0; cursor: zoom-in;
  background: var(--surface-soft); border: 1px solid var(--border); border-radius: 12px; overflow: hidden;
  line-height: 0;
}
.howto-zoom:focus-visible { outline: 3px solid var(--hw-blue); outline-offset: 2px; }
.howto-zoom img { display: block; width: 100%; height: auto; }
.howto-zoom-hint {
  position: absolute; right: 10px; bottom: 10px; padding: 4px 10px; font-size: 0.74rem; line-height: 1.4;
  color: #fff; background: rgba(15, 27, 51, 0.78); border-radius: 999px; opacity: 0;
  transition: opacity .15s ease; pointer-events: none;
}
.howto-zoom:hover .howto-zoom-hint, .howto-zoom:focus-visible .howto-zoom-hint { opacity: 1; }
.howto-fig figcaption { margin-top: 8px; font-size: 0.84rem; line-height: 1.45; color: var(--text-muted); }

/* tips / problems */
.howto-cols { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; margin-top: 26px; }
.howto-card { padding: 20px; background: var(--card); border: 1px solid var(--border); border-radius: 18px; }
.howto-card h3 { margin: 0 0 12px; font-size: 1.08rem; color: var(--hw-navy); }
.howto-tips { border-top: 3px solid var(--hw-blue); }
.howto-problems { border-top: 3px solid var(--hw-ring); }
.howto-tips ul { margin: 0; padding: 0; list-style: none; display: grid; gap: 9px; }
.howto-tips li { position: relative; padding-left: 24px; line-height: 1.55; }
.howto-tips li::before {
  content: ""; position: absolute; left: 3px; top: 0.5em; width: 10px; height: 6px;
  border-left: 2px solid var(--hw-blue); border-bottom: 2px solid var(--hw-blue); transform: rotate(-45deg);
}
.howto-problems dl { margin: 0; display: grid; gap: 4px; }
.howto-problems dt { margin-top: 8px; font-weight: 700; line-height: 1.4; }
.howto-problems dt:first-child { margin-top: 0; }
.howto-problems dd { margin: 0 0 2px; line-height: 1.55; color: var(--text-muted); }

/* FAQ */
.howto-faq { margin-top: 26px; }
.howto-faq h3 { margin: 0 0 12px; font-size: 1.08rem; color: var(--hw-navy); }
.howto-faq details {
  margin-bottom: 8px; background: var(--card); border: 1px solid var(--border); border-radius: 12px;
}
.howto-faq summary {
  cursor: pointer; padding: 13px 16px; font-weight: 600; line-height: 1.4; list-style: none;
  display: flex; justify-content: space-between; gap: 12px; align-items: center;
}
.howto-faq summary::-webkit-details-marker { display: none; }
.howto-faq summary::after {
  content: "+"; flex: none; width: 24px; height: 24px; display: inline-grid; place-items: center;
  font-size: 1.1rem; line-height: 1; color: var(--hw-blue); background: var(--hw-blue-soft); border-radius: 50%;
}
.howto-faq details[open] summary::after { content: "\2212"; }
.howto-faq summary:focus-visible { outline: 3px solid var(--hw-blue); outline-offset: -3px; border-radius: 12px; }
.howto-faq details p { margin: 0; padding: 0 16px 14px; line-height: 1.65; color: var(--text-muted); }

/* reveal (only when howto.js turned it on - never under reduced motion) */
.howto-anim .howto-step, .howto-anim .howto-card, .howto-anim .howto-faq {
  transition: opacity .5s ease, transform .5s ease;
}
.howto-anim .howto-step:not(.is-in), .howto-anim .howto-card:not(.is-in), .howto-anim .howto-faq:not(.is-in) {
  opacity: 0; transform: translateY(14px);
}

/* zoom overlay: a direct child of <body>, centred in the viewport */
.howto-lb {
  position: fixed; inset: 0; z-index: 2147483000; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 10px; padding: 16px;
  background: rgba(8, 14, 28, 0.86);
}
.howto-lb[hidden] { display: none; }
.howto-lb img {
  display: block; max-width: min(96vw, 1100px); max-height: calc(100vh - 110px); width: auto; height: auto;
  background: #fff; border-radius: 10px; box-shadow: 0 18px 60px rgba(0, 0, 0, 0.5);
}
.howto-lb-cap { max-width: 92vw; margin: 0; color: #E8EEF9; font-size: 0.92rem; line-height: 1.4; text-align: center; }
.howto-lb button {
  position: absolute; display: grid; place-items: center; width: 42px; height: 42px; padding: 0; cursor: pointer;
  font-size: 1.4rem; line-height: 1; color: #fff; background: rgba(255, 255, 255, 0.14);
  border: 1px solid rgba(255, 255, 255, 0.3); border-radius: 50%;
}
.howto-lb button:hover, .howto-lb button:focus-visible { background: rgba(255, 255, 255, 0.28); outline: none; }
.howto-lb .howto-lb-x { top: 14px; right: 14px; }
.howto-lb .howto-lb-prev { left: 14px; top: 50%; margin-top: -21px; }
.howto-lb .howto-lb-next { right: 14px; top: 50%; margin-top: -21px; }

@media (max-width: 820px) {
  .howto { margin-top: 32px; }
  .howto-step { grid-template-columns: 1fr; gap: 14px; padding: 16px; }
  .howto-cols { grid-template-columns: 1fr; }
  .howto-num { width: 36px; height: 36px; margin-bottom: 8px; }
  .howto-lb .howto-lb-prev, .howto-lb .howto-lb-next { top: auto; bottom: 14px; margin-top: 0; }
  .howto-lb .howto-lb-prev { left: calc(50% - 56px); }
  .howto-lb .howto-lb-next { right: calc(50% - 56px); }
}
@media (hover: none) { .howto-zoom-hint { opacity: 1; } }
@media print {
  .howto-zoom-hint, .howto-lb, .howto-jump { display: none !important; }
  .howto-step { break-inside: avoid; box-shadow: none; }
}
