/*
 * Presentation styles for the code viewer (3-pane HTML / CSS / JS tabs).
 *
 * The stimeo--tabs controller owns the tab behavior; this only provides looks.
 * Uses its own .code-viewer namespace so it never clashes with the demo .tabs.
 * Flat wireframe aesthetic overall (per the playground-presentation-css skill).
 */

.code-viewer {
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  overflow: hidden;
}

/* Tab row (tablist) */
.code-viewer__tablist {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
  background: var(--sidebar-bg);
}

/* Individual tab */
.code-viewer__tab {
  appearance: none;
  border: none;
  background: transparent;
  padding: 0.5rem 1rem;
  font: inherit;
  font-size: 0.85rem;
  color: var(--muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
}

.code-viewer__tab:hover {
  color: var(--fg);
}

/* Selected tab: hook off aria-selected, which stimeo--tabs toggles */
.code-viewer__tab[aria-selected="true"] {
  color: var(--fg);
  border-bottom-color: var(--accent);
}

/* Visible focus */
.code-viewer__tab:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

/* Drop the code block's own margin/radius so it inherits the panel's rounded frame */
.code-viewer__panel .code {
  margin: 0;
  border-radius: 0;
}

/* Empty-state message for demos that have no consumer JS */
.code-viewer__empty {
  margin: 0;
  padding: 1rem 1.25rem;
  color: var(--muted);
  font-size: 0.85rem;
}

/* ── Code block with a copy button (dogfooded stimeo--clipboard) ─────── */
/* The code panel is always dark, so the button is light-on-dark in both themes. */
.code-block {
  position: relative;
}

/* Icon-only copy button (clipboard → check on success). */
.code-block__copy {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.875rem;
  height: 1.875rem;
  color: var(--on-code);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: var(--radius-sm);
  cursor: pointer;
  opacity: 0.8;
  transition:
    opacity var(--duration-fast) var(--ease-out),
    color var(--duration-fast) var(--ease-out),
    border-color var(--duration-fast) var(--ease-out);
}

.code-block__copy:hover {
  opacity: 1;
  border-color: rgba(255, 255, 255, 0.32);
}

.code-block__copy:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
  opacity: 1;
}

.code-block__copy-icon,
.code-block__copy-check {
  display: inline-flex;
}

.code-block__copy-check {
  display: none;
}

/* Clipboard → check swap + a brief pop, driven by stimeo--clipboard's data-state. */
.code-block[data-state="copied"] .code-block__copy-icon {
  display: none;
}

.code-block[data-state="copied"] .code-block__copy-check {
  display: inline-flex;
  animation: code-copy-pop var(--duration-base) var(--ease-spring);
}

.code-block[data-state="copied"] .code-block__copy {
  color: #fff;
  background: rgba(var(--vital-rgb), 0.22);
  border-color: var(--color-primary);
  opacity: 1;
}

.code-block[data-state="error"] .code-block__copy {
  color: #fff;
  border-color: var(--ruby-500);
  opacity: 1;
}

@keyframes code-copy-pop {
  0% { transform: scale(0.5); opacity: 0; }
  60% { transform: scale(1.15); }
  100% { transform: scale(1); opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .code-block[data-state="copied"] .code-block__copy-check {
    animation: none;
  }
}

/* "You also need the shared styles (light + dark)" note under the Code tab. */
.code-viewer__shared-note {
  margin: 0.75rem 0 0;
  font-size: 0.8125rem;
  line-height: 1.5;
  color: var(--color-text-muted);
}

.code-viewer__shared-note a {
  color: var(--color-link);
  text-decoration: none;
}

.code-viewer__shared-note a:hover {
  text-decoration: underline;
}

.code-viewer__shared-note code {
  font-family: var(--font-mono);
  font-size: 0.9em;
  color: var(--color-text);
}
