/**
 * help-tab.css: the "Help" button in the top bar and the panel it opens (src/core/help-tab.js).
 *
 * The panel hangs from the sticky top bar and lies over the page: nothing under it moves, so
 * pinned toolbars that measure the top bar (Archive) keep their place. Its text is for reading,
 * so it is sized to show at 16px even though the desktop UI is zoomed (ui-zoom.css).
 */

.help-tab-btn {
  display: inline-flex; align-items: center; gap: 6px;
  height: 36px; padding: 0 12px;
  font: inherit; font-size: 14px; font-weight: 600;
  color: var(--navy);
  background: transparent;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-pill);
  cursor: pointer;
}
.help-tab-btn[hidden] { display: none; }   /* display above would show it before the app has started */
.help-tab-btn:hover { background: var(--color-bg-hover); }
.help-tab-btn.is-open { background: var(--color-bg-active); border-color: var(--brand-line); }
.help-tab-btn svg { flex: 0 0 auto; }

.help-panel {
  position: absolute; top: 100%; left: 0; right: 0;
  z-index: 80;
  display: flex; flex-direction: column;
  max-height: min(420px, calc(60vh * var(--vhfix, 1)));
  max-height: min(420px, calc(60dvh * var(--vhfix, 1)));
  background: var(--card-bg);
  color: var(--color-text);
  border-bottom: 1px solid var(--hairline);
  border-radius: 0 0 var(--radius-card) var(--radius-card);
  box-shadow: var(--shadow-md);
  font-size: 16px;
  line-height: 1.55;
}
.help-panel[hidden] { display: none; }
@media (min-width: 1025px) and (hover: hover) and (pointer: fine) {
  html.ui-zoom .help-panel { font-size: calc(16px / var(--uiz, 1)); }   /* shows at 16px after the zoom */
}
@media (prefers-reduced-motion: no-preference) {
  .help-panel:not([hidden]) { animation: help-panel-in 150ms ease; }
  @keyframes help-panel-in { from { opacity: 0; transform: translateY(-6px); } }
}

.help-panel-head { display: flex; align-items: flex-start; gap: 12px; padding: 14px 20px 0; }
.help-panel-heading { flex: 1 1 auto; min-width: 0; }
.help-panel-eyebrow {
  display: block; font-size: .7em; font-weight: 600; letter-spacing: .04em; text-transform: uppercase;
  color: var(--slate);
}
.help-panel-title { margin: 0; font-size: 1.08em; font-weight: 600; line-height: 1.3; color: var(--navy); }
.help-panel-title:focus { outline: none; }
.help-panel-x {
  flex: 0 0 auto; width: 36px; height: 36px; margin: -4px -8px 0 0;
  font-size: 1.5em; line-height: 1; color: var(--slate);
  background: none; border: 0; border-radius: var(--radius-pill); cursor: pointer;
}
.help-panel-x:hover { background: var(--color-bg-hover); }

.help-panel-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 8px 20px 14px; }
.help-panel-body > * { max-width: 70ch; }
.help-panel-text > :first-child { margin-top: 0; }
.help-panel-text p, .help-panel-text ul, .help-panel-text ol { margin: 0 0 .6em; }
.help-panel-text > :last-child { margin-bottom: 0; }
.help-panel a { color: var(--blue); text-underline-offset: 2px; }
.help-panel-general {
  margin: 0 0 .7em; padding: 6px 10px; font-size: .88em;
  background: var(--brand-softer); border: 1px solid var(--brand-line); border-radius: var(--radius-chip);
}
.help-panel strong.help-live { padding: 1px 6px; background: var(--brand-soft); border-radius: 4px; }
.help-panel .help-live.is-missing, .help-panel .help-live.is-empty { color: var(--slate); font-style: italic; }
.help-panel .help-live-table th { width: 30%; }
.help-panel-note {
  margin: 0 0 .8em; padding: 8px 12px;
  background: var(--brand-softer); border: 1px solid var(--brand-line); border-radius: var(--radius-chip);
}
.help-panel-note-title { margin: 0 0 .25em; font-size: .82em; font-weight: 700; color: var(--brand-deep); }
.help-panel-note-body > :first-child { margin-top: 0; }
.help-panel-note-body > :last-child { margin-bottom: 0; }
.help-panel-note-body p, .help-panel-note-body ul, .help-panel-note-body ol { margin: 0 0 .5em; }
.help-panel-note-body.is-clamped { max-height: calc(1.55em * 4); overflow: hidden; }
.help-panel-note-more { margin-top: .3em; padding: 0; font: inherit; font-size: .9em; color: var(--blue); background: none; border: 0; text-decoration: underline; cursor: pointer; }
.help-strip .help-panel-note { background: var(--card-bg); }
.help-panel-related { margin: .8em 0 0; font-size: .92em; }
.help-panel-related > span:first-child { color: var(--slate); }
.help-panel-message { margin: 0 0 .6em; }
.help-panel-actions { display: flex; align-items: center; gap: 14px; margin: 0; }

.help-panel-skeleton span {
  display: block; height: .8em; margin: .55em 0; max-width: 60ch;
  background: var(--nested-bg); border-radius: 4px;
}
.help-panel-skeleton span:nth-child(2) { max-width: 52ch; }
.help-panel-skeleton span:nth-child(3) { max-width: 34ch; }

.help-panel-foot {
  flex: 0 0 auto;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 20px;
  border-top: 1px solid var(--hairline);
  font-size: .92em;
}
.help-panel-more { font-weight: 600; }
.help-panel-close {
  margin-left: auto; padding: 6px 14px;
  font: inherit; font-weight: 600; color: var(--navy);
  background: none; border: 1px solid var(--color-border); border-radius: var(--radius-chip); cursor: pointer;
}
.help-panel-close:hover { background: var(--color-bg-hover); }

/* ── Help inside a dialog (src/core/help-dialog.js): "?" in the header, a strip under it ── */
.help-dialog-btn { font-weight: 700; line-height: 1; }
.modal-hd .help-dialog-btn {
  flex: 0 0 auto; width: 32px; height: 32px;
  font-size: 16px; color: var(--slate);
  background: var(--nested-bg); border: 0; border-radius: 50%; cursor: pointer;
}
.modal-hd .help-dialog-btn:hover, .modal-hd .help-dialog-btn.is-open { background: var(--color-bg-active); color: var(--navy); }
.help-dialog-btn.hdr-btn.is-open { background: rgba(255, 255, 255, .3); }

.help-panel.help-strip {
  position: static;
  flex: 0 0 auto;
  max-height: min(320px, calc(40vh * var(--vhfix, 1)));
  max-height: min(320px, calc(40dvh * var(--vhfix, 1)));
  background: var(--nested-bg);
  border-radius: 0;
  box-shadow: none;
  animation: none;
  text-align: left;
}
.help-strip .help-panel-general { background: var(--card-bg); }
.help-strip .help-panel-skeleton span { background: var(--hairline); }

/* Keyboard focus. The app has no shared focus ring yet (kraftbj/church-app issue 45). */
.help-tab-btn:focus-visible,
.help-dialog-btn:focus-visible,
.help-panel a:focus-visible,
.help-panel button:focus-visible { outline: 2px solid var(--brand-dark); outline-offset: 2px; }
.help-panel-body:focus-visible { outline: 2px solid var(--brand-dark); outline-offset: -2px; }

@media (max-width: 860px) {
  .help-tab-btn { width: 36px; padding: 0; justify-content: center; }
  .help-tab-btn span { display: none; }
  .help-panel-head, .help-panel-body, .help-panel-foot { padding-left: 14px; padding-right: 14px; }
  .help-panel-x, .help-panel-close { min-height: 44px; min-width: 44px; }
}
