/* =============================================================================
   Panel documentation sections
   -----------------------------------------------------------------------------
   Shared styles for the in-panel "Documentation" block that every tool
   page renders below its controls, and the yellow "?" button in each
   panel header that scrolls to it.
   ============================================================================= */

/* ── Yellow "?" help button ──────────────────────────────────────────────── */

.help-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 1px solid rgba(251, 241, 87, 0.55);
  background: rgba(251, 241, 87, 0.18);
  color: var(--color-accent);
  font-size: 13px;
  font-weight: 700;
  line-height: 1;
  padding: 0;
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast),
              border-color var(--transition-fast), box-shadow var(--transition-fast);
  flex-shrink: 0;
}

.help-button:hover,
.help-button:focus-visible {
  background: var(--color-accent);
  color: #1a1506;
  border-color: var(--color-accent);
  box-shadow: var(--glow-accent);
  outline: none;
}

/* Shared sizing for the help-button when it lives inside a panel h2 —
   slightly smaller than the base 22px so it blends with the heading. */
.panel h2 > .help-button,
.fxdata-toolbar-left h2 > .help-button,
.sfx-container h2 > .help-button {
  font-size: 12px;
  width: 20px;
  height: 20px;
}

/* Right-align the help-button to the right edge of the page contents.
   Only applied where the panel's h2 is a direct block child of the panel
   content; FXData's h2 sits inside a narrow toolbar-left flex column, so
   pushing to the right there would collide with the title text — it keeps
   the inline-beside-heading positioning below. */
.panel > h2:has(> .help-button),
.sfx-container > h2:has(> .help-button) {
  display: flex;
  align-items: center;
}

.panel > h2 > .help-button,
.sfx-container > h2 > .help-button {
  margin-left: auto;
}

/* FXData: inline beside the heading text, with a small gap. */
.fxdata-toolbar-left h2 > .help-button {
  vertical-align: middle;
  margin-left: var(--space-sm);
  position: relative;
  top: -3px;
}

/* Small variant — used inside the Pixel Editor toolbar next to the gear.
   Overrides the default 22px to blend with the other 18px toolbar icons. */
.help-button.help-button-sm {
  width: 18px;
  height: 18px;
  font-size: 11px;
}

/* ── Documentation section ─────────────────────────────────────────────────
   Styled to match the dedicated /docs tab: no darkened background panel,
   text flows directly in the page with generous line-height and a thin
   divider rule at the top of each major heading. */

.documentation-section {
  max-width: 820px;
  margin: var(--space-2xl) auto var(--space-xl);
  padding: 0;
  background: transparent;
  border: none;
  color: var(--color-text);
  line-height: 1.7;
  scroll-margin-top: var(--space-xl);
}

/* Music and FXData panels expand to 1400px; let their documentation section
   match the panel width rather than sit narrow at the default 820px. */
#panel-music .documentation-section,
#panel-fxdata .documentation-section {
  max-width: 1400px;
}

/* FXData and Package editors use fixed-viewport inner layouts, so their docs
   section needs more breathing room before the first heading to clear the
   editor above it. */
#panel-fxdata .documentation-section,
#panel-package .documentation-section {
  margin-top: calc(var(--space-2xl) * 3);
}

/* The shared .site-footer carries a top border for the welcome page, but in
   the tool panels the documentation-section above already provides enough
   visual separation — drop the rule there. */
.panel > .site-footer {
  border-top: none;
}

.documentation-section h4 {
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--color-text);
  margin: var(--space-xl) 0 var(--space-sm);
  border-top: 1px solid var(--color-border-subtle);
  padding-top: var(--space-md);
}

.documentation-section h4:first-child {
  border-top: none;
  padding-top: 0;
  margin-top: 0;
}

.documentation-section p {
  font-size: var(--font-size-base);
  color: var(--color-text-secondary);
  margin: 0 0 var(--space-md);
}

.documentation-section p:last-child { margin-bottom: 0; }

.documentation-section strong { color: var(--color-text); }

.documentation-section ul,
.documentation-section ol {
  margin: 0 0 var(--space-md);
  padding-left: var(--space-lg);
  color: var(--color-text-secondary);
}

.documentation-section li {
  margin-bottom: var(--space-xs);
  font-size: var(--font-size-base);
}

.documentation-section li strong {
  color: var(--color-text);
  font-weight: 600;
}

.documentation-section code {
  font-family: var(--font-mono);
  font-size: 0.88em;
  padding: 0.1em 0.35em;
  background: var(--color-bg-elevated);
  border-radius: var(--radius-sm);
  color: var(--color-accent);
}

.documentation-section kbd {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.8em;
  padding: 2px 7px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-bottom-width: 2px;
  border-radius: 4px;
  color: var(--color-text);
  min-width: 16px;
  text-align: center;
  vertical-align: baseline;
}

/* Accordion (details/summary) */
.documentation-section details {
  margin-top: var(--space-md);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.02);
  overflow: hidden;
}

.documentation-section details[open] {
  background: rgba(255, 255, 255, 0.03);
}

.documentation-section details > summary {
  list-style: none;
  padding: var(--space-sm) var(--space-md);
  font-weight: 600;
  font-size: var(--font-size-base);
  color: var(--color-text);
  cursor: pointer;
  user-select: none;
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  transition: background var(--transition-fast);
}

.documentation-section details > summary::-webkit-details-marker { display: none; }

.documentation-section details > summary::before {
  content: '▶';
  font-size: 10px;
  color: var(--color-text-muted);
  transition: transform var(--transition-fast);
}

.documentation-section details[open] > summary::before {
  transform: rotate(90deg);
}

.documentation-section details > summary:hover {
  background: rgba(255, 255, 255, 0.04);
}

.documentation-section details > *:not(summary) {
  padding: var(--space-xs) var(--space-md) var(--space-md);
}

/* Figures / screenshots */
.documentation-section figure.doc-screenshot {
  margin: var(--space-md) 0;
  padding: 0;
  border-radius: var(--radius-md);
  overflow: hidden;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.documentation-section figure.doc-screenshot img {
  display: block;
  width: 100%;
  height: auto;
  max-width: 720px;
  margin: 0 auto;
}

.documentation-section figure.doc-screenshot figcaption {
  padding: var(--space-xs) var(--space-md) var(--space-sm);
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
  text-align: center;
  font-style: italic;
  background: rgba(0, 0, 0, 0.25);
  border-top: 1px solid rgba(255, 255, 255, 0.04);
}

/* Keyboard reference table (auto-generated from the hotkey registry) */
.documentation-section table.doc-keys {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--font-size-sm);
  margin-bottom: var(--space-md);
}

.documentation-section table.doc-keys td {
  padding: var(--space-xs) var(--space-sm);
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  vertical-align: top;
}

.documentation-section table.doc-keys td:first-child {
  width: 140px;
  white-space: nowrap;
  color: var(--color-text-muted);
}

/* ── Hotkey overlay (press `?` anywhere) ─────────────────────────────────── */

.hotkey-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-lg);
  animation: hotkey-overlay-fade 150ms ease;
}

@keyframes hotkey-overlay-fade {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.hotkey-overlay-panel {
  width: 100%;
  max-width: 640px;
  max-height: 80vh;
  overflow-y: auto;
  background: var(--color-bg);
  border: var(--glass-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--glass-shadow-lg);
  padding: var(--space-lg);
}

.hotkey-overlay-panel h3 {
  color: var(--color-accent);
  margin-bottom: var(--space-sm);
  font-size: var(--font-size-lg);
}

.hotkey-overlay-panel .hotkey-overlay-hint {
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
  margin-bottom: var(--space-md);
}
