/* ============================================================
   Agridence GeoJSON Studio — FAQ page (faq.html)
   Loads after css/app.css and reuses its tokens and components
   (topbar, brand, buttons, chips, callouts, .sect cards, kbd).
   The rules below adapt the app shell to a scrolling page and
   lay out the document next to a fixed side navigation.
   ============================================================ */

:root {
  --faq-top: 56px;      /* topbar height */
  --faq-side-w: 264px;  /* side navigation width */
}

html, body { height: auto; }
body.faq-page { overflow: auto; background: var(--color-surface-subtle); }
@media (prefers-reduced-motion: no-preference) { html { scroll-behavior: smooth; } }

/* topbar: the app sizes it from the #app grid; here it needs its own height */
.faq-page header.topbar { height: var(--faq-top); position: sticky; top: 0; }
.faq-page a.btn { text-decoration: none; }
.faq-nav-toggle { display: none; }

/* ---------------- side navigation (always on screen) ---------------- */
.faq-side {
  position: fixed; top: var(--faq-top); left: 0; bottom: 0; width: var(--faq-side-w);
  overflow-y: auto; z-index: 900;
  background: #fff; border-right: 1px solid var(--color-border-default);
  padding: 18px 14px 24px;
}
.faq-side-label, .faq-search label {
  display: block; font-size: 11px; font-weight: 800; letter-spacing: .07em;
  text-transform: uppercase; color: var(--color-text-muted); margin: 0 0 8px; padding: 0 2px;
}
.faq-search { margin-bottom: 18px; }
.faq-search input {
  width: 100%; height: 38px; padding: 8px 12px; font-size: 13.5px; background: #fff;
  border: 1px solid var(--color-border-input); border-radius: var(--radius-input);
}
.faq-search input:focus { border-color: var(--color-primary); outline: none; box-shadow: 0 0 0 3px rgba(20,95,245,0.12); }
.faq-count { min-height: 18px; margin-top: 6px; padding: 0 2px; font-size: 12px; color: var(--color-text-muted); }
.faq-side ol { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.faq-side li a {
  display: block; padding: 7px 12px; border-radius: var(--radius-md);
  font-size: 13px; font-weight: 600; line-height: 1.35;
  color: var(--color-text-secondary); text-decoration: none;
  border-left: 3px solid transparent;
  transition: background var(--motion-fast) var(--motion-ease), color var(--motion-fast) var(--motion-ease);
}
.faq-side li a:hover { background: var(--color-primary-hover); color: var(--color-primary); }
.faq-side li a.active { background: var(--color-primary-light); color: var(--color-primary-dark); border-left-color: var(--color-primary); }
.faq-side li a.dim { opacity: .45; }
.faq-backdrop { display: none; }

/* ---------------- document ---------------- */
.faq-main { margin-left: var(--faq-side-w); padding: 28px clamp(16px, 4vw, 48px) 64px; }
.faq-doc { max-width: 880px; margin: 0 auto; min-width: 0; display: flex; flex-direction: column; gap: 14px; }
.faq-doc h1 { margin: 0; font-size: 28px; font-weight: 800; letter-spacing: -0.4px; color: var(--color-text-primary); }
.faq-lead { margin: 0; max-width: 68ch; font-size: 15px; line-height: 1.55; color: var(--color-text-secondary); }
.faq-lead a, .qa a, .faq-doc .sect-body a { color: var(--color-primary); }

.faq-doc .sect { scroll-margin-top: calc(var(--faq-top) + 16px); }
.faq-doc .sect > .sect-head { font-size: 14px; }
.faq-doc .sect > .sect-body { padding: 2px 18px 14px; }
.faq-doc .sect-body > p { margin: 12px 0 0; font-size: 14px; line-height: 1.55; color: var(--color-text-secondary); max-width: 72ch; }
.faq-doc .sect-body ul { margin: 8px 0 0; padding-left: 20px; font-size: 14px; line-height: 1.55; color: var(--color-text-secondary); }
.faq-doc .sect-body li { margin: 3px 0; }
.faq-doc .sect-body strong { color: var(--color-text-primary); font-weight: 700; }
.faq-doc .sect-body .callout { margin: 14px 0 2px; }

/* one question and its answer */
.qa { padding: 12px 0; border-bottom: 1px solid var(--color-border-default); }
.qa:last-child { border-bottom: 0; }
.qa h3 { margin: 0 0 4px; font-size: 14px; font-weight: 700; color: var(--color-text-primary); }
.qa p { margin: 0; max-width: 72ch; font-size: 14px; line-height: 1.55; color: var(--color-text-secondary); }
.qa p + p { margin-top: 6px; }

/* keyboard keys outside the help grid get the help-modal treatment */
.faq-doc kbd {
  display: inline-block; font-family: var(--mono); font-size: 11px; line-height: 1;
  background: var(--color-surface-subtle); border: 1px solid var(--color-border-default); border-bottom-width: 2px;
  border-radius: 5px; padding: 4px 6px; color: var(--color-text-primary); white-space: nowrap;
}
.faq-doc .help-keys { padding: 12px 0 4px; }

/* reference tables */
.faq-table-wrap { overflow-x: auto; margin: 12px 0 2px; }
table.faq-table { width: 100%; min-width: 640px; border-collapse: collapse; font-size: 13px; }
table.faq-table thead th {
  text-align: left; padding: 8px 10px; font-size: 11px; font-weight: 800; letter-spacing: .06em;
  text-transform: uppercase; color: var(--color-text-muted); background: var(--color-surface-subtle);
  border-bottom: 1px solid var(--color-border-default);
}
table.faq-table tbody td { padding: 9px 10px; vertical-align: top; line-height: 1.45; color: var(--color-text-secondary); border-bottom: 1px solid var(--color-border-default); }
table.faq-table tbody tr:last-child td { border-bottom: 0; }
table.faq-table td.rule-id { font-family: var(--mono); font-weight: 700; color: var(--color-text-primary); white-space: nowrap; }
table.faq-table td.rule-fix { min-width: 210px; }

.faq-foot { margin: 6px 0 0; font-size: 12px; color: var(--color-text-muted); }
.faq-foot a { color: var(--color-text-secondary); }

/* ---------------- narrow screens: the side nav becomes a drawer ---------------- */
@media (max-width: 900px) {
  .faq-nav-toggle { display: inline-flex; }
  .faq-side {
    transform: translateX(-100%);
    transition: transform var(--motion-base) var(--motion-ease);
    width: min(var(--faq-side-w), 84vw);
  }
  .faq-side.open { transform: none; box-shadow: var(--shadow-popover); }
  .faq-backdrop {
    display: block; position: fixed; left: 0; right: 0; top: var(--faq-top); bottom: 0;
    background: var(--color-surface-overlay); z-index: 850;
  }
  .faq-backdrop[hidden] { display: none; }
  .faq-main { margin-left: 0; }
}
@media (prefers-reduced-motion: reduce) { .faq-side { transition: none; } }
@media (max-width: 600px) {
  .faq-main { padding-inline: 16px; }
  .faq-doc .sect > .sect-body { padding: 2px 14px 12px; }
}

@media print {
  .faq-page header.topbar, .faq-side, .faq-backdrop, .faq-nav-toggle { display: none; }
  body.faq-page { background: #fff; }
  .faq-main { margin-left: 0; padding: 0; }
  .faq-doc .sect { box-shadow: none; break-inside: avoid; }
}

/* Simplified Chinese (faq.zh.html): the same floor as the app, see the
   Chinese section at the end of css/app.css. Text never below 12 px, no
   weight above 700, and a little more room in the key caps. */
:lang(zh) .faq-side-label, :lang(zh) .faq-search label, :lang(zh) table.faq-table thead th { font-size: 12px; font-weight: 700; }
:lang(zh) .faq-doc kbd { font-size: 12px; line-height: 1.3; }
/* on phones the header holds the logo, the language button, Sections and Back:
   the name gives way (the page heading right below says it) */
@media (max-width: 480px) {
  .faq-page .brand > div, .faq-page .brand .sep, .faq-page .version-chip { display: none; }
}
