/* public/css/help.css
   The floating help panel. Opens as a half-screen sheet on the right, over the
   app, with an index of the user's granted apps and a search box pinned to the
   bottom. CSP-safe: all class-based, no inline styles anywhere.

   Visibility is toggled by the `.is-open` class on .helppanel (added by
   help.js), never by inline display — the strict CSP forbids inline styles and
   the codebase toggles with classList throughout. */

/* The Help control in the side menu — a button styled to match the app links. */
.appside__help {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  border: 0;
  background: none;
  cursor: pointer;
  font: inherit;
  text-align: left;
  color: var(--soft, #6b635a);
  padding: 9px 14px;
  border-radius: 8px;
  text-decoration: none;
}
.appside__help:hover { background: var(--card, #fbf9f5); color: var(--ink, #1f1b17); }
.appside__help svg { flex: 0 0 auto; }

/* Dim the app behind the open panel. Click it to close. */
.help-scrim {
  position: fixed;
  inset: 0;
  background: rgba(31, 27, 23, 0.34);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.18s ease, visibility 0.18s ease;
  z-index: 900;
}
.help-scrim.is-open { opacity: 1; visibility: visible; }

/* The panel itself: half the screen, floating on the right, full height. */
.helppanel {
  position: fixed;
  top: 0;
  right: 0;
  height: 100vh;
  width: 50vw;
  min-width: 380px;
  max-width: 560px;
  background: var(--paper, #f4f0e9);
  box-shadow: -18px 0 44px rgba(31, 27, 23, 0.22);
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.22s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 950;
  will-change: transform;
}
.helppanel.is-open { transform: translateX(0); }

@media (max-width: 720px) {
  .helppanel { width: 100vw; min-width: 0; max-width: none; }
}

/* Header */
.helppanel__head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line, #e6ddcf);
  flex: 0 0 auto;
}
.helppanel__head h2 {
  font-size: 18px;
  margin: 0;
  flex: 1 1 auto;
}
.helppanel__back {
  border: 0;
  background: none;
  cursor: pointer;
  font: inherit;
  color: var(--accent, #c8553d);
  padding: 4px 6px;
  border-radius: 6px;
  display: none;
  align-items: center;
  gap: 4px;
}
.helppanel__back:hover { background: var(--card, #fbf9f5); }
.helppanel.is-article .helppanel__back { display: inline-flex; }
.helppanel__close {
  border: 0;
  background: none;
  cursor: pointer;
  font-size: 22px;
  line-height: 1;
  color: var(--soft, #6b635a);
  padding: 2px 8px;
  border-radius: 6px;
}
.helppanel__close:hover { background: var(--card, #fbf9f5); color: var(--ink, #1f1b17); }

/* Scrolling body */
.helppanel__body {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 18px;
}

/* Index view */
.help-intro { color: var(--soft, #6b635a); font-size: 14px; margin: 0 0 16px; }
.help-index { list-style: none; margin: 0; padding: 0; }
.help-index__item { margin: 0 0 8px; }
.help-index__link {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  width: 100%;
  text-align: left;
  border: 1px solid var(--line, #e6ddcf);
  background: var(--card, #fbf9f5);
  border-radius: 10px;
  padding: 13px 15px;
  cursor: pointer;
  font: inherit;
  color: inherit;
  text-decoration: none;
  transition: border-color 0.14s ease, transform 0.08s ease;
}
.help-index__link:hover { border-color: var(--accent, #c8553d); transform: translateY(-1px); }
.help-index__icon {
  flex: 0 0 auto;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: var(--green-bg, #e7f0dc);
  color: var(--green, #3f7d5c);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 15px;
}
.help-index__text strong { display: block; font-size: 15px; margin-bottom: 2px; }
.help-index__text span { font-size: 13px; color: var(--soft, #6b635a); line-height: 1.4; }

/* Articles: only the selected one shows. */
.help-article { display: none; }
.help-article.is-active { display: block; }
.helppanel.is-article .help-index,
.helppanel.is-article .help-intro { display: none; }

.help-article h3 {
  font-size: 20px;
  margin: 0 0 4px;
}
.help-article h4 {
  font-size: 15px;
  margin: 22px 0 6px;
  padding-top: 14px;
  border-top: 1px solid var(--line, #e6ddcf);
}
.help-article h4:first-of-type { border-top: 0; padding-top: 0; }
.help-article p { font-size: 14.5px; line-height: 1.6; margin: 0 0 12px; }
.help-article ul, .help-article ol { font-size: 14.5px; line-height: 1.6; margin: 0 0 12px; padding-left: 20px; }
.help-article li { margin-bottom: 6px; }
.help-article .help-lede { color: var(--soft, #6b635a); font-size: 15px; }
.help-article code {
  background: var(--card, #fbf9f5);
  border: 1px solid var(--line, #e6ddcf);
  border-radius: 4px;
  padding: 1px 5px;
  font-size: 13px;
}

/* A tip / note callout. */
.help-tip {
  background: var(--green-bg, #e7f0dc);
  border-left: 3px solid var(--green, #3f7d5c);
  border-radius: 8px;
  padding: 10px 14px;
  margin: 0 0 14px;
  font-size: 13.5px;
  line-height: 1.55;
}
.help-tip strong { color: var(--ink, #1f1b17); }
.help-warn {
  background: #f6ead0;
  border-left: 3px solid #b07d23;
  border-radius: 8px;
  padding: 10px 14px;
  margin: 0 0 14px;
  font-size: 13.5px;
  line-height: 1.55;
}

/* Annotated UI illustration. The SVG carries numbered callouts; the legend
   beneath it explains each number. */
.help-figure {
  margin: 4px 0 16px;
  border: 1px solid var(--line, #e6ddcf);
  border-radius: 10px;
  overflow: hidden;
  background: #fff;
}
.help-figure svg { display: block; width: 100%; height: auto; }
.help-figure__legend {
  margin: 0;
  padding: 12px 14px;
  background: var(--card, #fbf9f5);
  border-top: 1px solid var(--line, #e6ddcf);
  list-style: none;
  font-size: 13px;
  line-height: 1.5;
}
/* A hanging indent, NOT flex. The legend text after the number is a mix of
   <strong> and plain text; in a flex row each of those becomes its own flex
   item and wraps independently, which is what threw "photo" onto a second line
   and left a gap. Positioning the number absolutely in a left gutter lets the
   text flow and wrap as ordinary text. */
.help-figure__legend li {
  position: relative;
  padding-left: 26px;
  margin-bottom: 5px;
  line-height: 1.5;
}
.help-figure__legend li:last-child { margin-bottom: 0; }
.help-figure__num {
  position: absolute;
  left: 0;
  top: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent, #c8553d);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Search — pinned to the bottom, as required. */
.helppanel__search {
  flex: 0 0 auto;
  border-top: 1px solid var(--line, #e6ddcf);
  padding: 12px 16px;
  background: var(--paper, #f4f0e9);
}
.helppanel__search-wrap { position: relative; }
.helppanel__search input {
  width: 100%;
  border: 1.5px solid var(--line, #e6ddcf);
  border-radius: 9px;
  padding: 10px 12px 10px 36px;
  font: inherit;
  font-size: 14px;
  background: #fff;
  color: var(--ink, #1f1b17);
}
.helppanel__search input:focus {
  outline: none;
  border-color: var(--accent, #c8553d);
  box-shadow: 0 0 0 3px rgba(200, 85, 61, 0.14);
}
.helppanel__search-icon {
  position: absolute;
  left: 11px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--soft, #6b635a);
  pointer-events: none;
}

/* Search results overlay the index. */
.help-results { list-style: none; margin: 0; padding: 0; }
.help-results__empty { color: var(--soft, #6b635a); font-size: 14px; padding: 8px 2px; }
.help-results__link {
  display: block;
  width: 100%;
  text-align: left;
  border: 0;
  border-bottom: 1px solid var(--line, #e6ddcf);
  background: none;
  cursor: pointer;
  font: inherit;
  padding: 11px 4px;
  color: inherit;
}
.help-results__link:hover { color: var(--accent, #c8553d); }
.help-results__link strong { display: block; font-size: 14px; }
.help-results__link span { font-size: 12.5px; color: var(--soft, #6b635a); }
.help-results__app {
  display: inline-block;
  font-size: 11px;
  color: var(--green, #3f7d5c);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 2px;
}
mark { background: #ffe95c; color: inherit; padding: 0 1px; border-radius: 2px; }

/* When search is active, hide the normal index/article and show results. */
.helppanel.is-searching .help-index,
.helppanel.is-searching .help-intro,
.helppanel.is-searching .help-article,
.helppanel.is-searching .helppanel__back { display: none; }
.help-results { display: none; }
.helppanel.is-searching .help-results { display: block; }

/* ── Floating "? Help" button (bottom-right) ────────────────────────────────
   Replaces the old in-menu link. Sits in the corner the panel slides from, so
   the two read as one control. Hidden while the panel is open. */
.help-fab {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 890;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 0;
  cursor: pointer;
  font: inherit;
  font-weight: 600;
  font-size: 15px;
  color: #fff;
  background: var(--accent, #c8553d);
  padding: 12px 18px;
  border-radius: 999px;
  box-shadow: 0 6px 20px rgba(31, 27, 23, 0.28);
  transition: transform 0.12s ease, background 0.15s ease, opacity 0.18s ease;
}
.help-fab:hover { background: var(--accent-deep, #a8412c); transform: translateY(-2px); }
.help-fab svg { flex: 0 0 auto; }
.help-fab:focus-visible { outline: 3px solid var(--ink, #1f1b17); outline-offset: 2px; }
/* Out of the way while the panel is open. */
body.help-open .help-fab { opacity: 0; pointer-events: none; }
/* On a narrow screen, tuck it above the bottom edge and shrink to the icon. */
@media (max-width: 560px) {
  .help-fab { right: 14px; bottom: 14px; padding: 12px; }
  .help-fab span { display: none; }
}

/* Open-in-new-window link in the panel header. */
.helppanel__window {
  border: 0;
  background: none;
  cursor: pointer;
  color: var(--soft, #6b635a);
  padding: 4px 8px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  text-decoration: none;
}
.helppanel__window:hover { background: var(--card, #fbf9f5); color: var(--ink, #1f1b17); }

/* ── Standalone help window (/help) ─────────────────────────────────────────
   A plain, scrollable document — every guide shown in full, no JavaScript. */
body.helpwin { margin: 0; background: var(--paper, #f4f0e9); color: var(--ink, #1f1b17); }
.helpwin__head {
  position: sticky;
  top: 0;
  background: rgba(244, 240, 233, 0.94);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--line, #e6ddcf);
  padding: 14px 22px;
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}
.helpwin__brand { display: flex; align-items: center; gap: 10px; }
.helpwin__logo {
  width: 30px; height: 30px; border-radius: 8px;
  background: var(--accent, #c8553d); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 18px;
}
.helpwin__brand strong { display: block; font-size: 16px; }
.helpwin__brand span { font-size: 12px; color: var(--soft, #6b635a); }
.helpwin__hint { margin: 0 0 0 auto; font-size: 12px; color: var(--soft, #6b635a); max-width: 34ch; }
.helpwin__hint kbd {
  background: #fff; border: 1px solid var(--line, #e6ddcf); border-bottom-width: 2px;
  border-radius: 4px; padding: 0 4px; font-size: 11px; font-family: inherit;
}
.helpwin__main { max-width: 760px; margin: 0 auto; padding: 26px 22px 64px; }

/* Table of contents. */
.helpwin__toc {
  background: var(--card, #fbf9f5);
  border: 1px solid var(--line, #e6ddcf);
  border-radius: 12px;
  padding: 18px 22px;
  margin-bottom: 30px;
}
.helpwin__toc h2 { font-size: 15px; margin: 0 0 10px; }
.helpwin__toc ul { margin: 0; padding-left: 18px; }
.helpwin__toc li { margin-bottom: 6px; }
.helpwin__toc a { color: var(--accent-deep, #a8412c); font-weight: 500; }
.helpwin__toc a:hover { text-decoration: underline; }

/* On this page every guide is shown in full (the panel hides them by default). */
.helpwin .help-article { display: block; }
.helpwin__section {
  padding-top: 20px;
  margin-top: 32px;
  border-top: 2px solid var(--line, #e6ddcf);
  scroll-margin-top: 84px; /* clears the sticky header when jumped to */
}
.helpwin__section:first-of-type { border-top: 0; margin-top: 0; padding-top: 0; }
.helpwin .help-figure { max-width: 620px; }
.helpwin__foot {
  margin-top: 40px; padding-top: 18px;
  border-top: 1px solid var(--line, #e6ddcf);
  font-size: 14px; color: var(--soft, #6b635a);
}
.helpwin__foot a { color: var(--accent-deep, #a8412c); font-weight: 600; }

@media print {
  .helpwin__head, .helpwin__toc { display: none; }
  .helpwin__section { break-inside: avoid; }
}
