/**
 * Section code viewer (ui/section-code-modal.js) — tab strip, copy button, and
 * the gutter/code pair that shows one catalog section's source.
 */

.pb-seccode-modal .pb-modal-body {
  display: flex;
  flex-direction: column;
  gap: var(--pb-space-4);
  min-height: 0;
}

.pb-seccode-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--pb-space-4);
  flex-wrap: wrap;
}

.pb-seccode-tabs {
  display: flex;
  gap: var(--pb-space-1);
  flex-wrap: wrap;
}

.pb-seccode-tab {
  padding: var(--pb-space-2) var(--pb-space-4);
  min-height: var(--pb-control-height);
  border: 1px solid transparent;
  border-radius: var(--pb-radius);
  background: none;
  color: var(--pb-text-dim);
  font-size: var(--pb-font-sm);
  cursor: pointer;
  transition: color var(--pb-transition), background var(--pb-transition);
}

.pb-seccode-tab:hover {
  color: var(--pb-text);
}

.pb-seccode-tab-active {
  color: var(--pb-text);
  background: var(--pb-surface-2);
  border-color: var(--pb-border);
}

.pb-seccode-tab:focus-visible {
  outline: 2px solid var(--pb-accent);
  outline-offset: 2px;
}

.pb-seccode-panel {
  flex: 1 1 auto;
  min-height: 0;
}

/* The ONE scroller. Both children scroll together because they are inside it;
   the gutter then sticks to the left edge so line numbers stay put while the
   code scrolls horizontally. */
.pb-seccode-scroll {
  display: flex;
  align-items: flex-start;
  max-height: min(60dvh, 560px);
  overflow: auto;
  border: 1px solid var(--pb-border);
  border-radius: var(--pb-radius);
  background: var(--pb-content-bg);
}

.pb-seccode-gutter,
.pb-seccode-code {
  margin: 0;
  padding: var(--pb-space-4) 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: var(--pb-font-sm);
  line-height: 1.6;
  tab-size: 2;
}

.pb-seccode-gutter {
  position: sticky;
  left: 0;
  z-index: 1;
  padding-right: var(--pb-space-3);
  padding-left: var(--pb-space-3);
  text-align: right;
  color: var(--pb-text-dim);
  background: var(--pb-surface);
  border-right: 1px solid var(--pb-border);
  user-select: none;
  flex: 0 0 auto;
}

.pb-seccode-code {
  padding-left: var(--pb-space-4);
  padding-right: var(--pb-space-4);
  color: var(--pb-text);
  white-space: pre;
  flex: 1 1 auto;
}

.pb-seccode-code:focus-visible {
  outline: 2px solid var(--pb-accent);
  outline-offset: -2px;
}

.pb-seccode-message {
  padding: var(--pb-space-8) var(--pb-space-4);
  text-align: center;
  color: var(--pb-text-dim);
  font-size: var(--pb-font-sm);
}

.pb-seccode-message-error {
  color: var(--pb-danger);
}

@media (max-width: 640px) {
  .pb-seccode-head {
    align-items: stretch;
    flex-direction: column;
  }

  .pb-seccode-scroll {
    max-height: 50dvh;
  }
}
