/* ========================================
   Code Panel — shared "view code" component
   Injected by code-panel.js into every effect section
   ======================================== */

.code-panel {
  width: 100%;
  margin-top: 1.25rem;
  font-family: 'Geist', system-ui, -apple-system, 'Segoe UI', sans-serif;
  text-align: left;
}

.code-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.4rem 0.85rem;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: #8b8ba0;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s, background 0.2s;
}

.code-toggle:hover {
  color: #f3f3f5;
  border-color: rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.06);
}

.code-toggle svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

.code-toggle .chevron {
  transition: transform 0.25s ease;
}

.code-panel.open .code-toggle .chevron {
  transform: rotate(180deg);
}

.code-view {
  margin-top: 0.75rem;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  background: #0b0b12;
  overflow: hidden;
}

.code-view-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.4rem 0.6rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
  background: rgba(255, 255, 255, 0.02);
}

.code-tabs {
  display: flex;
  gap: 0.25rem;
}

.code-tab {
  padding: 0.3rem 0.75rem;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  color: #6b6b80;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  cursor: pointer;
  transition: color 0.15s, background 0.15s;
}

.code-tab:hover {
  color: #f0f0f5;
}

.code-tab.active {
  color: #f3f3f5;
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.12);
}

.code-copy {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.3rem 0.7rem;
  font-size: 0.72rem;
  font-weight: 600;
  color: #8b8ba0;
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 6px;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}

.code-copy:hover {
  color: #f0f0f5;
  border-color: rgba(255, 255, 255, 0.25);
}

.code-copy.copied {
  color: #4ade80;
  border-color: rgba(74, 222, 128, 0.4);
}

.code-copy svg {
  width: 13px;
  height: 13px;
}

.code-pre {
  margin: 0;
  padding: 1rem 1.1rem;
  max-height: 420px;
  overflow: auto;
  font-size: 0.78rem;
  line-height: 1.6;
  tab-size: 2;
}

.code-pre code {
  font-family: ui-monospace, 'Cascadia Code', 'SF Mono', Menlo, Consolas, monospace;
  color: #c9c9d9;
  white-space: pre;
}

.code-pre::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

.code-pre::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.12);
  border-radius: 4px;
}

.code-pre::-webkit-scrollbar-track {
  background: transparent;
}

/* ── Page-specific fitting ─────────────────────────── */

/* typography.html panels: flows naturally after headline */

/* scroll.html: blocks are centered flex rows — let the panel wrap below */
/* Inside a .block-actions row the panel is not a box of its own — `display: contents`
   promotes its toggle and view into the row, so the toggle can sit beside Replay
   while the view still wraps onto its own full-width line below. */
.block-actions .code-panel {
  display: contents;
}

.block-actions .code-view {
  flex: 1 1 100%;
  max-width: 700px;
  margin: 0.35rem auto 0;
  text-align: left;
}

/* gallery / cursor / layout cards: panel sits at the card bottom */
.effect-block .code-panel,
.cursor-block .code-panel,
.layout-block .code-panel {
  margin-top: 0;
  padding: 0.75rem 1rem 1rem;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

/* ── Permalink ──────────────────────────────────────
   Icon-only link to the effect's standalone page, sitting beside the toggle.
   Same box as the toggle, muted until hovered, so it reads as part of it. */
.code-permalink {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  align-self: stretch; /* same height as the toggle beside it */
  color: #6b6b80;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  transition: color 0.2s, border-color 0.2s, background 0.2s;
}
.code-permalink:hover {
  color: #f3f3f5;
  border-color: rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.06);
}
.code-permalink svg { width: 13px; height: 13px; }
/* Toggle + permalink row. Inside .block-actions the panel is display:contents,
   so this row becomes one item of the shared Replay / View code row. */
.code-actions {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}
