/* ============================================================
   help.css — Main stylesheet for the help system
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Sans:ital,wght@0,300;0,400;0,500;0,600;1,400&family=IBM+Plex+Mono:wght@400;500&display=swap');

/* ── Variables ── */
:root {
  --sidebar-width: 280px;
  --header-height: 56px;

  /* Brand colours */
  --brand-orange:     #E4834C;
  --brand-orange-dk:  #c96b35;       /* darker for hover states */
  --brand-orange-lt:  #fdf0e8;       /* light tint for callout/accent-bg */
  --brand-slate:      #4C7085;
  --brand-slate-dk:   #2a3d47;       /* header/sidebar background */
  --brand-slate-dkr:  #1f2e35;       /* slightly deeper for sidebar active bg */

  /* Sidebar */
  --sidebar-bg:         var(--brand-slate-dk);
  --sidebar-text:       #c8d6dc;
  --sidebar-muted:      #6a8a97;
  --sidebar-active-bg:  var(--brand-slate-dkr);
  --sidebar-active:     var(--brand-orange);
  --sidebar-section:    #6a8a97;

  /* Content */
  --bg:           #f8f6f4;
  --surface:      #ffffff;
  --text:         #1e2d35;
  --text-muted:   #5a7280;
  --accent:       var(--brand-slate);
  --accent-light: #e8f2f7;
  --border:       #dde6ea;
  --code-bg:      #f0f4f6;

  --font-body:    'IBM Plex Sans', sans-serif;
  --font-mono:    'IBM Plex Mono', monospace;

  --radius:       6px;
  --shadow:       0 2px 12px rgba(0,0,0,0.08);
  --transition:   0.18s ease;
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }

body {
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.65;
  color: var(--text);
  background: var(--bg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ── Top Header ── */
#header {
  height: var(--header-height);
  background: var(--sidebar-bg);
  display: flex;
  align-items: center;
  padding: 0 16px 0 20px;
  gap: 12px;
  flex-shrink: 0;
  border-bottom: 2px solid var(--brand-orange);
  z-index: 200;
}

/* Hamburger — hidden on desktop */
#nav-toggle {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px;
  color: rgba(255,255,255,0.75);
  flex-shrink: 0;
  border-radius: var(--radius);
  transition: background var(--transition);
}
#nav-toggle:hover { background: rgba(255,255,255,0.1); color: #fff; }
#nav-toggle svg { display: block; }

#header .logo {
  color: #fff;
  font-weight: 600;
  font-size: 20px;
  letter-spacing: -0.01em;
  white-space: nowrap;
  text-decoration: none;
  flex-shrink: 0;
}
#header .logo span { color: var(--brand-orange); }

#search-wrapper {
  flex: 1;
  max-width: 440px;
  position: relative;
}

#search-input {
  width: 100%;
  background: rgba(255,255,255,0.09);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: var(--radius);
  color: #fff;
  font-family: var(--font-body);
  font-size: 14px;
  padding: 7px 12px 7px 36px;
  outline: none;
  transition: var(--transition);
}
#search-input::placeholder { color: rgba(255,255,255,0.35); }
#search-input:focus {
  background: rgba(255,255,255,0.13);
  border-color: rgba(228,131,76,0.5);
}

.search-icon {
  position: absolute;
  left: 11px;
  top: 50%;
  transform: translateY(-50%);
  color: rgba(255,255,255,0.35);
  pointer-events: none;
}

#search-results {
  position: absolute;
  top: calc(100% + 6px);
  left: 0; right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  max-height: 360px;
  overflow-y: auto;
  z-index: 400;
  display: none;
}
#search-results.visible { display: block; }

.search-result-item {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background var(--transition);
}
.search-result-item:last-child { border-bottom: none; }
.search-result-item:hover { background: var(--brand-orange-lt); }
.search-result-item strong { color: var(--brand-slate); font-size: 13px; font-weight: 600; display: block; }
.search-result-item span { color: var(--text-muted); font-size: 12px; }
.search-no-results { padding: 14px; color: var(--text-muted); font-size: 13px; text-align: center; }

#print-btn {
  background: transparent;
  border: 1px solid rgba(255,255,255,0.18);
  border-radius: var(--radius);
  color: rgba(255,255,255,0.6);
  cursor: pointer;
  font-size: 13px;
  padding: 6px 12px;
  font-family: var(--font-body);
  transition: var(--transition);
  white-space: nowrap;
  margin-left: auto;
  flex-shrink: 0;
}
#print-btn:hover { background: rgba(255,255,255,0.08); color: #fff; }

/* ── Layout ── */
#layout {
  display: flex;
  flex: 1;
  overflow: hidden;
  position: relative;
}

/* ── Mobile overlay backdrop ── */
#sidebar-backdrop {
  display: none;
  position: fixed;
  inset: var(--header-height) 0 0 0;
  background: rgba(0,0,0,0.45);
  z-index: 149;
  opacity: 0;
  transition: opacity 0.25s ease;
}
#sidebar-backdrop.visible {
  display: block;
  opacity: 1;
}

/* ── Sidebar ── */
#sidebar {
  width: var(--sidebar-width);
  min-width: 160px;
  max-width: 480px;
  background: var(--sidebar-bg);
  overflow: visible;
  flex-shrink: 0;
  position: relative;
  z-index: 150;
}

/* Inner scroll container */
#sidebar-inner {
  position: absolute;
  inset: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 16px 0 32px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.1) transparent;
}
#sidebar-inner::-webkit-scrollbar        { width: 4px; }
#sidebar-inner::-webkit-scrollbar-track  { background: transparent; }
#sidebar-inner::-webkit-scrollbar-thumb  { background: rgba(255,255,255,0.15); border-radius: 4px; }

/* ── Sidebar resize handle ── */
#sidebar-resizer {
  position: absolute;
  top: 0;
  right: -4px;
  width: 8px;
  height: 100%;
  cursor: col-resize;
  z-index: 200;
  background: transparent;
  transition: background var(--transition);
}
#sidebar-resizer:hover,
#sidebar-resizer.dragging {
  background: rgba(228,131,76,0.35);
}

/* ── TOC Sections ── */
.toc-section { margin-bottom: 4px; }

.toc-section-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px 6px;
  cursor: pointer;
  user-select: none;
}
.toc-section-header:hover .toc-section-title { color: #fff; }

.toc-section-icon { font-size: 13px; }
.toc-section-title {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--sidebar-section);
  flex: 1;
  transition: color var(--transition);
}
.toc-chevron {
  color: var(--sidebar-muted);
  font-size: 10px;
  transition: transform var(--transition);
}
.toc-section.collapsed .toc-chevron { transform: rotate(-90deg); }

.toc-topics { list-style: none; }
.toc-section.collapsed > .toc-topics { display: none; }

/* ── Topic rows (all levels) ── */
.toc-topic {
  display: flex;
  align-items: center;
  gap: 0;
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: 13.5px;
  transition: background var(--transition), color var(--transition);
  border-left: 2px solid transparent;
  cursor: pointer;
  user-select: none;
}
.toc-topic:hover { background: rgba(255,255,255,0.06); color: #fff; }
.toc-topic.active {
  background: var(--sidebar-active-bg);
  color: var(--brand-orange);
  border-left-color: var(--brand-orange);
}

/* Topic label */
.toc-topic-label {
  flex: 1;
  padding: 7px 12px 7px 0;
}

/* Expand/collapse arrow */
.toc-expand-btn {
  flex-shrink: 0;
  width: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--sidebar-muted);
  font-size: 9px;
  padding: 7px 0;
  transition: color var(--transition), transform var(--transition);
}
.toc-topic:hover .toc-expand-btn { color: rgba(255,255,255,0.5); }
.toc-topic.active .toc-expand-btn { color: var(--brand-orange); }
.toc-topic.expanded .toc-expand-btn { transform: rotate(90deg); }

/* Indentation per depth */
.toc-depth-0 .toc-topic-label { padding-left: 36px; }
.toc-topic[data-depth="1"] .toc-topic-label { padding-left: 52px; }
.toc-topic[data-depth="2"] .toc-topic-label { padding-left: 68px; }

/* Children list */
.toc-children { list-style: none; overflow: hidden; }
.toc-children.collapsed { display: none; }

/* ── Content Pane ── */
#content-pane {
  flex: 1;
  overflow-y: auto;
  background: var(--bg);
}

#content-area {
  max-width: 780px;
  margin: 0 auto;
  padding: 40px 48px 80px;
}
#content-area.loading { opacity: 0.4; pointer-events: none; }

.content-placeholder {
  text-align: center;
  padding: 80px 20px;
  color: var(--text-muted);
}
.content-placeholder h2 { font-size: 20px; font-weight: 500; margin-bottom: 8px; }
.content-placeholder p  { font-size: 14px; }

/* ── Topic content styles ── */
.topic-content h1 {
  font-size: 28px;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--brand-slate-dk);
  margin-bottom: 8px;
  line-height: 1.25;
}

.topic-content .topic-meta {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 28px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
}

.permalink-box {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 12px;
  margin-top: 40px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-muted);
  flex-wrap: wrap;
}
.permalink-box .permalink-label {
  font-family: var(--font-body);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  white-space: nowrap;
}
.permalink-url {
  flex: 1;
  color: var(--brand-slate);
  word-break: break-all;
  min-width: 0;
}
.permalink-copy {
  background: none;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 3px 8px;
  font-size: 11px;
  cursor: pointer;
  color: var(--text-muted);
  font-family: var(--font-body);
  white-space: nowrap;
  transition: var(--transition);
  flex-shrink: 0;
}
.permalink-copy:hover { background: var(--brand-orange); color: #fff; border-color: var(--brand-orange); }
.permalink-copy.copied { background: #2a9d6e; color: #fff; border-color: #2a9d6e; }

.topic-content h2 {
  font-size: 18px;
  font-weight: 600;
  color: var(--brand-slate-dk);
  margin: 32px 0 12px;
  padding-bottom: 6px;
  border-bottom: 2px solid var(--brand-orange-lt);
}
.topic-content h3 {
  font-size: 15px;
  font-weight: 600;
  color: var(--brand-slate);
  margin: 24px 0 8px;
}
.topic-content p { margin-bottom: 14px; }
.topic-content ul, .topic-content ol { margin: 0 0 14px 20px; }
.topic-content li { margin-bottom: 4px; }

.topic-content a { color: var(--brand-slate); text-decoration: underline; text-underline-offset: 2px; }
.topic-content a:hover { color: var(--brand-orange); }

.topic-content code {
  font-family: var(--font-mono);
  font-size: 13px;
  background: var(--code-bg);
  padding: 1px 5px;
  border-radius: 3px;
  border: 1px solid var(--border);
  color: var(--brand-slate-dk);
}
.topic-content pre {
  background: var(--brand-slate-dk);
  color: #c8d6dc;
  font-family: var(--font-mono);
  font-size: 13px;
  padding: 16px 20px;
  border-radius: var(--radius);
  overflow-x: auto;
  margin-bottom: 16px;
}
.topic-content pre code { background: none; border: none; padding: 0; color: inherit; }

.topic-content table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 16px;
  font-size: 14px;
}
.topic-content th {
  background: var(--accent-light);
  font-weight: 600;
  text-align: left;
  padding: 8px 12px;
  border: 1px solid var(--border);
  color: var(--brand-slate-dk);
}
.topic-content td {
  padding: 8px 12px;
  border: 1px solid var(--border);
}
.topic-content tr:nth-child(even) td { background: var(--bg); }

/* ── Callouts ── */
.callout {
  border-radius: var(--radius);
  padding: 12px 16px;
  margin-bottom: 16px;
  font-size: 14px;
  display: flex;
  gap: 10px;
  align-items: flex-start;
}
.callout-icon { flex-shrink: 0; font-size: 16px; margin-top: 1px; }
/* info uses brand slate */
.callout.info    { background: #e8f2f7; border-left: 3px solid var(--brand-slate); }
/* tip uses brand orange */
.callout.tip     { background: var(--brand-orange-lt); border-left: 3px solid var(--brand-orange); }
/* warning and danger stay universally understood colours */
.callout.warning { background: #fff8e6; border-left: 3px solid #d4900a; }
.callout.danger  { background: #fff0f0; border-left: 3px solid #cc3333; }

/* ── Collapsible sections ── */
details.collapsible {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 12px;
  overflow: hidden;
}
details.collapsible summary {
  padding: 10px 14px;
  cursor: pointer;
  font-weight: 500;
  font-size: 14px;
  background: var(--code-bg);
  list-style: none;
  display: flex;
  align-items: center;
  gap: 8px;
  user-select: none;
  color: var(--brand-slate-dk);
}
details.collapsible summary::before {
  content: '▶';
  font-size: 10px;
  color: var(--brand-orange);
  transition: transform var(--transition);
}
details.collapsible[open] summary::before { transform: rotate(90deg); }
details.collapsible .collapsible-body { padding: 14px; }

/* ── Scrollbars ── */
#content-pane::-webkit-scrollbar        { width: 6px; }
#content-pane::-webkit-scrollbar-track  { background: transparent; }
#content-pane::-webkit-scrollbar-thumb  { background: var(--border); border-radius: 4px; }

/* ── Responsive images ── */
.topic-content img {
  max-width: 100%;
  height: auto;
  display: block;
  border-radius: var(--radius);
  margin-bottom: 16px;
}
.topic-content img.screenshot {
  border: 1px solid var(--border);
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}
.topic-content figure {
  margin: 0 0 20px;
  text-align: center;
}
.topic-content figure img { margin-bottom: 8px; }
.topic-content figcaption {
  font-size: 12px;
  color: var(--text-muted);
  font-style: italic;
}

/* ── Responsive video (16:9 iframe embeds) ── */
.video-wrap {
  position: relative;
  padding-bottom: 56.25%;
  height: 0;
  overflow: hidden;
  border-radius: var(--radius);
  margin-bottom: 20px;
  background: #000;
}
.video-wrap iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: none;
}

/* ── Responsive — mobile ── */
@media (max-width: 700px) {
  #nav-toggle { display: flex; }
  #print-btn  { display: none; }

  #search-input { font-size: 16px; } /* prevent iOS zoom */

  #sidebar {
    position: fixed;
    top: var(--header-height);
    left: 0;
    bottom: 0;
    width: min(280px, 85vw) !important;
    min-width: unset;
    max-width: unset;
    transform: translateX(-110%);
    transition: transform 0.25s ease;
    box-shadow: 4px 0 24px rgba(0,0,0,0.35);
  }
  #sidebar.open { transform: translateX(0); }
  #sidebar-inner { position: absolute; inset: 0; }
  #sidebar-resizer { display: none; }

  #content-area { padding: 24px 18px 60px; }
  .topic-content h1 { font-size: 22px; }
  .topic-content h2 { font-size: 16px; }
}

/* ── Lightbox ── */
#lightbox-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.85);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.2s ease;
  cursor: zoom-out;
}
#lightbox-overlay.visible { opacity: 1; }

#lightbox-inner {
  position: relative;
  max-width: 90vw;
  max-height: 90vh;
  display: flex;
  align-items: center;
  justify-content: center;
}
#lightbox-inner img {
  max-width: 90vw;
  max-height: 90vh;
  border-radius: var(--radius);
  box-shadow: 0 8px 40px rgba(0,0,0,0.6);
  object-fit: contain;
  cursor: default;
}
#lightbox-close {
  position: absolute;
  top: -16px;
  right: -16px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--brand-orange);
  border: none;
  color: #fff;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition);
}
#lightbox-close:hover { background: var(--brand-orange-dk); }

/* ── Print ── */
@media print {
  #header, #sidebar, #sidebar-backdrop, #nav-toggle { display: none !important; }
  html, body { height: auto !important; overflow: visible !important; font-size: 12pt; }
  #layout { display: block; height: auto !important; overflow: visible !important; }
  #content-pane { overflow: visible !important; height: auto !important; }
  #content-area { max-width: 100%; padding: 0; height: auto !important; overflow: visible !important; }
  .topic-content { height: auto !important; overflow: visible !important; }
  .permalink-box { display: none; }
  .topic-content pre { white-space: pre-wrap; }
  a { color: inherit; text-decoration: underline; }
}
