/*
 * SAGRIS ODC — shared Help system styles.
 *
 * Pairs with /assets/sagris-help.js. Two surfaces, one stylesheet:
 *   1. the in-app slide-over Help drawer (injected into every app), and
 *   2. the standalone manuals + portal under /help/ (built by build_help.py,
 *      which links this file in its page template).
 *
 * Everything is namespaced `.sg-help*` so it never collides with an app's CSS,
 * and every value comes from the design tokens in sagris-theme.css so /config
 * retunes Help along with the rest of the platform.
 */

/* ── Top-bar Help button + per-panel "?" affordance ───────────────────────── */
.sg-help-btn{
  display:inline-flex;align-items:center;justify-content:center;gap:6px;
  height:26px;padding:0 12px;border:1px solid var(--blue3);border-radius:var(--radius-sm);
  background:var(--blue4);color:var(--blue);font-family:var(--sans);font-size:var(--fs-sm);
  font-weight:700;letter-spacing:.3px;cursor:pointer;
  transition:color .15s,border-color .15s,background .15s;white-space:nowrap;
}
.sg-help-btn:hover{color:#dfeeff;border-color:var(--blue2);background:var(--blue3)}
.sg-help-btn .sg-help-q{
  font-weight:800;display:inline-flex;align-items:center;justify-content:center;
  width:15px;height:15px;border-radius:50%;border:1.5px solid currentColor;font-size:10px;line-height:1;
}

/* small round "?" badge injected next to a panel heading */
.sg-help-dot{
  display:inline-flex;align-items:center;justify-content:center;
  width:18px;height:18px;margin-left:8px;border-radius:50%;
  border:1px solid var(--line2);background:var(--bg0);color:var(--txt3);
  font-family:var(--sans);font-size:11px;font-weight:800;font-style:italic;
  cursor:help;vertical-align:middle;transition:all .15s;user-select:none;
  position:relative;top:-1px;
}
.sg-help-dot:hover{color:var(--blue);border-color:var(--blue);background:var(--blue4)}

/* ── Drawer ───────────────────────────────────────────────────────────────── */
.sg-help-overlay{
  position:fixed;inset:0;background:rgba(4,8,14,.55);z-index:99998;
  opacity:0;pointer-events:none;transition:opacity .2s ease;
}
.sg-help-overlay.open{opacity:1;pointer-events:auto}

.sg-help-drawer{
  position:fixed;top:0;right:0;bottom:0;width:min(96vw, max(480px, 66.67vw));
  background:var(--panel);border-left:1px solid var(--line2);
  box-shadow:-8px 0 40px rgba(0,0,0,.5);z-index:99999;
  display:flex;flex-direction:column;
  transform:translateX(100%);transition:transform .24s cubic-bezier(.4,0,.2,1);
  font-family:var(--sans);color:var(--txt2);
}
.sg-help-drawer.open{transform:translateX(0)}

.sg-help-head{
  flex:0 0 auto;display:flex;align-items:center;gap:10px;
  padding:12px 16px;border-bottom:1px solid var(--line);background:var(--bg2);
}
.sg-help-head .sg-help-logo{
  width:22px;height:22px;border-radius:4px;flex-shrink:0;
  background:linear-gradient(135deg,var(--blue3),var(--blue2));
  display:flex;align-items:center;justify-content:center;font-weight:800;color:#fff;font-size:12px;
}
.sg-help-head .sg-help-title{font-size:var(--fs-lg);font-weight:700;color:var(--txt);flex:1;min-width:0}
.sg-help-head .sg-help-title small{display:block;font-size:var(--fs-xs);font-weight:500;color:var(--txt3);letter-spacing:.3px}
.sg-help-head .sg-help-open{
  display:inline-flex;align-items:center;height:28px;padding:0 14px;white-space:nowrap;
  font-family:var(--sans);font-size:var(--fs-sm);font-weight:700;letter-spacing:.3px;
  color:var(--blue);background:var(--blue4);border:1px solid var(--blue3);
  border-radius:var(--radius-sm);text-decoration:none;
  transition:color .15s,border-color .15s,background .15s;
}
.sg-help-head .sg-help-open:hover{color:#dfeeff;background:var(--blue3);border-color:var(--blue2)}
.sg-help-head .sg-help-close{
  background:none;border:none;color:var(--txt3);font-size:20px;line-height:1;cursor:pointer;padding:0 4px;
}
.sg-help-head .sg-help-close:hover{color:var(--txt)}

.sg-help-body{flex:1;display:flex;min-height:0}
.sg-help-toc{
  flex:0 0 auto;width:fit-content;max-width:38%;overflow-y:auto;
  border-right:1px solid var(--line);background:var(--bg1);padding:8px 0;
}
.sg-help-toc button{
  display:block;width:100%;text-align:left;background:none;border:none;white-space:nowrap;
  color:var(--txt2);font-family:var(--sans);font-size:var(--fs-md);font-weight:700;
  padding:7px 14px;cursor:pointer;border-left:2px solid transparent;transition:all .12s;
}
.sg-help-toc button:hover{color:var(--txt);background:var(--bg2)}
.sg-help-toc button.active{color:var(--blue);border-left-color:var(--blue);background:var(--blue4)}

.sg-help-content{flex:1;overflow-y:auto;padding:18px 22px 40px}

/* ── Rendered help content (shared by drawer + standalone manuals) ─────────── */
.sg-help-md{font-size:var(--fs-md);line-height:1.6;color:var(--txt2)}
.sg-help-md h1{font-size:var(--fs-2xl);color:var(--txt);margin:0 0 6px;font-weight:700}
.sg-help-md h2{font-size:calc(var(--font-base) + 4px);color:var(--txt);margin:22px 0 8px;font-weight:700;
  padding-bottom:5px;border-bottom:1px solid var(--line)}
.sg-help-md h3{font-size:calc(var(--font-base) + 1px);color:var(--txt);margin:18px 0 6px;font-weight:700}
.sg-help-md h4{font-size:var(--fs-md);color:var(--txt2);margin:14px 0 4px;font-weight:700;letter-spacing:.3px}
.sg-help-md p{margin:0 0 11px}
.sg-help-md ul,.sg-help-md ol{margin:0 0 12px;padding-left:22px}
.sg-help-md li{margin:3px 0}
.sg-help-md a{color:var(--blue);text-decoration:none}
.sg-help-md a:hover{text-decoration:underline}
.sg-help-md strong{color:var(--txt);font-weight:700}
.sg-help-md code{font-family:var(--mono);font-size:.88em;background:var(--bg0);
  border:1px solid var(--line);border-radius:3px;padding:1px 5px;color:var(--blue)}
.sg-help-md pre{background:var(--bg0);border:1px solid var(--line);border-radius:var(--radius-sm);
  padding:12px 14px;overflow-x:auto;margin:0 0 13px}
.sg-help-md pre code{background:none;border:none;padding:0;color:var(--txt2);font-size:.86em}
.sg-help-md blockquote{margin:0 0 13px;padding:10px 14px;border-left:3px solid var(--blue3);
  background:var(--blue4);border-radius:0 var(--radius-sm) var(--radius-sm) 0;color:var(--txt2)}
.sg-help-md blockquote p:last-child{margin:0}
.sg-help-md hr{border:none;border-top:1px solid var(--line);margin:20px 0}
.sg-help-md img{max-width:100%;height:auto;border:1px solid var(--line);border-radius:var(--radius-sm);margin:6px 0}
.sg-help-md table{border-collapse:collapse;width:100%;margin:0 0 14px;font-size:var(--fs-sm)}
.sg-help-md th,.sg-help-md td{border:1px solid var(--line);padding:6px 10px;text-align:left;vertical-align:top}
.sg-help-md th{background:var(--bg2);color:var(--txt);font-weight:700}
.sg-help-md tr:nth-child(even) td{background:var(--bg1)}
.sg-help-empty{color:var(--txt3);font-style:italic;padding:20px 0}
.sg-help-md .sg-help-steps{counter-reset:sgstep;list-style:none;padding-left:0}
.sg-help-md .sg-help-steps>li{position:relative;padding-left:34px;margin:10px 0}
.sg-help-md .sg-help-steps>li::before{counter-increment:sgstep;content:counter(sgstep);
  position:absolute;left:0;top:0;width:22px;height:22px;border-radius:50%;
  background:var(--blue3);color:#fff;font-weight:700;font-size:12px;
  display:flex;align-items:center;justify-content:center}

/* ── Standalone manual / portal page chrome (built pages only) ─────────────── */
.sg-help-page{max-width:920px;margin:0 auto;padding:0 24px 80px}
.sg-help-pagehead{display:flex;align-items:center;gap:12px;padding:20px 0 14px;margin-bottom:18px;
  border-bottom:1px solid var(--line)}
.sg-help-pagehead .sg-help-logo{width:30px;height:30px;font-size:15px}
.sg-help-pagehead h1{font-size:var(--fs-2xl);color:var(--txt);margin:0;font-weight:700}
.sg-help-pagehead .tl{font-size:var(--fs-sm);color:var(--txt3)}
.sg-help-pagenav{margin:0 0 26px;padding:14px 18px;background:var(--panel);border:1px solid var(--line);
  border-radius:var(--radius)}
.sg-help-pagenav h2{font-size:var(--fs-sm);text-transform:uppercase;letter-spacing:1px;color:var(--txt4);
  margin:0 0 8px;border:none;padding:0}
.sg-help-pagenav ul{columns:2;margin:0;padding-left:18px}
.sg-help-portal-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(240px,1fr));gap:16px;margin-top:8px}
.sg-help-portal-card{display:block;text-decoration:none;background:var(--panel);border:1px solid var(--line);
  border-radius:var(--radius);padding:16px 18px;transition:border-color .15s,transform .15s}
.sg-help-portal-card:hover{border-color:var(--blue3);transform:translateY(-2px)}
.sg-help-portal-card .nm{font-size:var(--fs-lg);font-weight:700;color:var(--txt)}
.sg-help-portal-card .tg{font-size:var(--fs-sm);color:var(--txt3);margin-top:3px}
.sg-help-portal-card .ct{font-size:var(--fs-xs);color:var(--txt4);margin-top:10px}
