/*
 * OneHLP in-app help (ADR-006, after OneDoc ADR-045). Shared by the staff
 * panel and the portal; ADR-002 roles only. Pushing the page aside is done
 * per frame (onehlp-staff.css, onehlp-portal.css) via html.oh-help-open.
 */
:root { --oh-help-w: 26rem; }

/* ---------- "?" in the top bar ---------- */
.oh-help-btn {
  width: 36px; height: 36px; padding: 0; flex: none;
  display: inline-grid; place-items: center;
  border: 1px solid var(--oh-border-strong); border-radius: 50%;
  background: var(--oh-surface); color: var(--oh-text-muted);
  font: 700 1.125rem/1 var(--oh-font); cursor: pointer;
}
.oh-help-btn:hover { color: var(--oh-text); background: var(--oh-subtle); }
.oh-help-btn[aria-expanded="true"] {
  background: var(--oh-primary-soft); color: var(--oh-primary-text); border-color: var(--oh-primary-border);
}
.oh-help-btn:focus-visible, .oh-help-pop-btn:focus-visible, .oh-help-close:focus-visible, .oh-help-link:focus-visible {
  outline: 2px solid var(--oh-primary); outline-offset: 2px;
}

/* ---------- Panel ---------- */
.oh-help {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 400;   /* above rail (300) and footer; under popups (910) */
  width: var(--oh-help-w); max-width: 100vw;
  display: flex; flex-direction: column;
  background: var(--oh-surface); color: var(--oh-text);
  border-left: 1px solid var(--oh-border);
  box-shadow: var(--oh-shadow-lg);
  font: 1rem/1.5 var(--oh-font);
  text-align: left;   /* the sign-in page centres everything */
  animation: oh-help-in .2s ease-out;
}
.oh-help:focus { outline: none; }
.oh-help[hidden] { display: none; }
@keyframes oh-help-in { from { transform: translateX(24px); opacity: 0; } to { transform: none; opacity: 1; } }

.oh-help-head {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 14px 16px 14px 20px; border-bottom: 1px solid var(--oh-border);
  padding-top: max(14px, env(safe-area-inset-top));
}
.oh-help-mark {
  flex: none; width: 20px; height: 20px; margin-top: 1px; border-radius: 50%;
  border: 2px solid var(--oh-primary); color: var(--oh-primary-text);
  display: grid; place-items: center; font: 700 .8125rem/1 var(--oh-font); box-sizing: border-box;
}
.oh-help-titles { flex: 1; min-width: 0; }
.oh-help-titles h2, .oh-help-titles strong {
  display: block; margin: 0; font-size: 1rem; font-weight: 600; line-height: 1.4; color: var(--oh-text); letter-spacing: 0;
}
.oh-help-titles p { margin: 0; font-size: .875rem; color: var(--oh-text-muted); }
.oh-help-close {
  flex: none; width: 28px; height: 28px; margin: 0; padding: 0; box-sizing: border-box;
  display: inline-grid; place-items: center;
  border: 1px solid var(--oh-border-strong); border-radius: 50%; background: var(--oh-surface);
  color: var(--oh-text-muted); font: 400 1.25rem/1 var(--oh-font); cursor: pointer;
}
.oh-help-close:hover { background: var(--oh-subtle); color: var(--oh-text); }
.oh-help-body {
  flex: 1; overflow-y: auto; overscroll-behavior: contain;
  padding: 16px 20px calc(24px + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; gap: 16px;
}

/* ---------- Sections (panel and popups) ---------- */
.oh-help-sec { display: flex; flex-direction: column; gap: 6px; }
.oh-help-sec h4 {
  margin: 0; display: flex; align-items: center; gap: 6px;
  font-size: .8125rem; font-weight: 600; line-height: 1.4; text-transform: uppercase; letter-spacing: .06em;
  color: var(--oh-text-muted);
}
.oh-help-sec p { margin: 0; font-size: 1rem; line-height: 1.55; color: var(--oh-text); }
.oh-help-sec ul { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 6px; }
.oh-help-sec li { position: relative; padding-left: 23px; font-size: 1rem; line-height: 1.5; color: var(--oh-text); }
.oh-help-sec li::before {
  content: "\2713"; position: absolute; left: 0; top: 3px;
  width: 15px; height: 15px; box-sizing: border-box; border-radius: 50%;
  border: 1.5px solid var(--oh-success); color: var(--oh-success);
  font-size: .625rem; font-weight: 700; line-height: 12px; text-align: center;
}
.oh-help-tip, .oh-help-warning { padding: 8px 12px; border-radius: var(--oh-radius-sm); border-left: 2px solid; }
.oh-help-tip { border-color: var(--oh-primary); background: rgba(var(--oh-primary-rgb), .06); }
.oh-help-warning { border-color: var(--oh-danger); background: var(--oh-danger-faint); }
.oh-help-warning h4 { color: var(--oh-danger-strong); }
.oh-help-tone {
  width: 13px; height: 13px; border-radius: 50%; border: 1.5px solid currentColor; box-sizing: border-box;
  display: inline-grid; place-items: center; font-size: .5625rem; font-weight: 700; text-transform: none;
}
.oh-help-example { display: flex; flex-direction: column; gap: 2px; }
.oh-help-example span { font-size: .875rem; color: var(--oh-text-muted); }
.oh-help-example pre {
  margin: 0; padding: 6px 10px; overflow-x: auto; user-select: all;
  border: 1px solid var(--oh-border); border-radius: var(--oh-radius-sm); background: var(--oh-subtle);
  font: .875rem/1.5 ui-monospace, Menlo, Consolas, monospace; color: var(--oh-text);
}
.oh-help-foot { margin-top: 8px; padding-top: 12px; border-top: 1px solid var(--oh-border); }
.oh-help-link {
  padding: 0; border: 0; background: none; cursor: pointer;
  font: .875rem/1.5 var(--oh-font); color: var(--oh-text-muted); text-decoration: underline;
}
.oh-help-link:hover { color: var(--oh-text); }
.oh-help-link.oh-help-back { color: var(--oh-primary-text); text-decoration: none; }
.oh-help-error, .oh-help-loading { margin: 0; color: var(--oh-text-muted); font-size: 1rem; }
.oh-help-error .oh-help-link { font-size: 1rem; color: var(--oh-primary-text); }

/* ---------- Popups: "?" beside × and help inside ---------- */
.oh-help-pop-btn {
  width: 28px; height: 28px; padding: 0;
  display: inline-grid; place-items: center;
  border: 1px solid var(--oh-border-strong); border-radius: 50%;
  background: var(--oh-surface); color: var(--oh-text-muted);
  font: 700 1rem/1 var(--oh-font); cursor: pointer;
}
.oh-help-pop-btn:hover { color: var(--oh-text); background: var(--oh-subtle); }
.oh-help-pop-btn.on { background: var(--oh-primary-soft); color: var(--oh-primary-text); border-color: var(--oh-primary-border); }
/* osTicket popups: × sits at top 18px / right 18px */
.dialog > .oh-help-pop-btn, .dialog .body > .oh-help-pop-btn,
.dialog [data-help] + .oh-help-pop-btn { position: absolute; top: 14px; right: 48px; }   /* also titles in a wrapper (user lookup) */
.dialog.oh-has-help h3, .dialog.oh-has-help .body > h3 { padding-right: 76px; }
/* Native <dialog> (Angular pages, portal): "?" left of the round × (onehlp-help.js adds the ×) */
dialog > .oh-help-pop-btn, dialog form > .oh-help-pop-btn { position: absolute; top: 14px; right: 48px; }
dialog.oh-has-x h3 { padding-right: 40px; }
dialog.oh-has-help h3 { padding-right: 76px; }

/* One close button for every popup: osTicket popups (.dialog a.close, onehlp-staff.css), native <dialog>s
   (.oh-dialog-x) and the rich-text editor's popups (.redactor-close) are the same round button as the "?" */
.oh-dialog-x, body .redactor-modal .redactor-close {
  position: absolute; top: 14px; right: 14px; z-index: 1;
  width: 28px; height: 28px; padding: 0; box-sizing: border-box;
  display: inline-grid; place-items: center;
  border: 1px solid var(--oh-border-strong); border-radius: 50%;
  background: var(--oh-surface); color: var(--oh-text-muted); opacity: 1;
  font: 400 1.25rem/1 var(--oh-font); cursor: pointer;
}
.oh-dialog-x:hover, body .redactor-modal .redactor-close:hover { color: var(--oh-text); background: var(--oh-subtle); opacity: 1; }
.oh-dialog-x:focus-visible, body .redactor-modal .redactor-close:focus-visible { outline: 2px solid var(--oh-primary); outline-offset: 2px; }
body .redactor-modal .redactor-close:before { content: "\00d7"; }

.oh-help-inline {
  max-height: 40vh; overflow-y: auto; overscroll-behavior: contain;
  margin: 0 0 12px; padding: 12px 16px;
  display: flex; flex-direction: column; gap: 12px;
  background: var(--oh-subtle); border: 1px solid var(--oh-border); border-radius: var(--oh-radius-sm);
  font: 1rem/1.5 var(--oh-font); text-align: left;
}
.oh-help-inline[hidden] { display: none; }
.oh-help-inline-head { display: flex; gap: 8px; align-items: flex-start; }

@media (max-width: 760px) {
  .oh-help-btn { width: 44px; height: 44px; }
  .oh-help { width: 100vw; border-left: 0; z-index: 920; }   /* full screen, above the bottom bar */
  .oh-help-close { width: 36px; height: 36px; }
  .oh-help-head { align-items: center; padding-left: 16px; }
  .oh-help-body { padding-left: 16px; padding-right: 16px; }
  .oh-help-pop-btn { width: 36px; height: 36px; }
  .oh-dialog-x, body .redactor-modal .redactor-close { width: 36px; height: 36px; top: 10px; right: 4px; }
  dialog > .oh-help-pop-btn, dialog form > .oh-help-pop-btn { top: 10px; right: 44px; }
  dialog.oh-has-help h3 { padding-right: 84px; }
  .dialog > .oh-help-pop-btn, .dialog .body > .oh-help-pop-btn,
  .dialog [data-help] + .oh-help-pop-btn { top: 10px; right: 44px; }
  .dialog.oh-has-help h3, .dialog.oh-has-help .body > h3 { padding-right: 84px; }
}
@media (prefers-reduced-motion: reduce) { .oh-help { animation: none; } }
