/* ---------- Header overrides (fixed overlay, no page scroll) ---------- */
.page-example .site-header {
  position: fixed;
  width: 100%;
}

.page-example {
  overflow: hidden;
}

.page-example main {
  height: 100vh;
}

.page-example .page-content {
  padding-top: var(--space-3);
  padding-bottom: var(--space-3);
  height: 100%;
  display: flex;
  flex-direction: column;
}

.page-example.header-pinned .page-content {
  padding-top: calc(77px + var(--space-3));
}

.page-example .page-content .container {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  /* Match .header-inner's max-width and fixed side padding so this
     page's content aligns with the header instead of .container's
     narrower max-width and responsive clamp. */
  max-width: 1440px;
  padding: 0 2rem;
}

/* ---------- Playground example viewer ---------- */
.example-back-link {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.95rem;
  font-weight: 400;
  color: var(--color-text);
  transition: color 0.15s ease;
}

.example-back-link:hover {
  color: #aaaaaa;
}

.example-back-link .playground-card-link-icon,
.example-pagination-label .playground-card-link-icon {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  transition: transform 0.2s ease;
}

.example-back-link:hover .playground-card-link-icon {
  transform: translateX(-3px);
}

.example-header {
  margin-top: var(--space-3);
}

.example-header-top {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.example-header-top h2 {
  font-size: clamp(1rem, 1.4vw, 1.15rem);
  font-weight: 500;
}

.page-content .example-description {
  margin-top: 0.4rem;
  font-size: 14px;
  font-weight: 400;
}

.example-code-panel {
  margin-top: var(--space-2);
  width: min(1600px, calc(100vw - 2 * clamp(1.25rem, 4vw, 3rem)));
  margin-left: 50%;
  transform: translateX(-50%);
  flex: 1;
  min-height: 0;
  border: 1px solid var(--color-border);
  border-radius: 14px;
  overflow: hidden;
  background: var(--color-bg);
  display: grid;
  grid-template-columns: 1fr 1fr;
  position: sticky;
  top: calc(76px + 12px);
  z-index: 5;
  transition: top 0.25s ease;
}

.example-code-panel.is-pinned-top {
  top: 12px;
}

.example-code-panel-col {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}

.example-code-panel-preview {
  border-right: 1px solid var(--color-border);
}

.example-code-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: 52px;
  padding: 0.75rem 1.1rem;
  background: var(--color-bg);
  border-bottom: 1px solid var(--color-border);
}

.example-code-panel-header-label {
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--color-text);
  white-space: nowrap;
}

.example-copy-code-btn[hidden] {
  display: none;
}

.example-code-panel-header-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.example-zoom-control {
  position: relative;
  display: flex;
  align-items: center;
  width: 90px;
}

.example-zoom-control input[type="range"] {
  width: 100%;
  height: 20px;
  margin: 0;
  appearance: none;
  background: transparent;
}

.example-zoom-control input[type="range"]::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: 2px;
  background: #e5e5e5;
}

.example-zoom-control input[type="range"]::-webkit-slider-thumb {
  appearance: none;
  width: 14px;
  height: 14px;
  margin-top: -5px;
  border-radius: 50%;
  background: #ffffff;
  border: 0.5px solid #ececec;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
  cursor: pointer;
}

.example-zoom-control input[type="range"]::-moz-range-track {
  height: 4px;
  border-radius: 2px;
  background: #e5e5e5;
}

.example-zoom-control input[type="range"]::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #ffffff;
  border: 0.5px solid #ececec;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
  cursor: pointer;
}

.example-zoom-popup {
  position: absolute;
  top: 100%;
  left: 0;
  transform: translateX(-50%);
  margin-top: 0.4rem;
  padding: 0.25rem 0.55rem;
  height: fit-content;
  border-radius: 6px;
  background: var(--color-text);
  color: var(--color-bg);
  font-size: 0.7rem;
  font-weight: 500;
  line-height: 1;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease;
  z-index: 20;
}

.example-zoom-popup.is-visible {
  opacity: 1;
}

.example-copy-toast {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  padding: 0.55rem 1.1rem;
  border-radius: 8px;
  background: var(--color-text);
  color: var(--color-bg);
  font-family: var(--font-body);
  font-size: 0.85rem;
  font-weight: 500;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  z-index: 25;
}

.example-copy-toast.is-visible {
  opacity: 1;
}

.example-preview-toast {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  padding: 0.55rem 1.1rem;
  border-radius: 8px;
  background: var(--color-text);
  color: var(--color-bg);
  font-family: var(--font-body);
  font-size: 0.85rem;
  font-weight: 500;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  z-index: 25;
}

.example-preview-toast.is-visible {
  opacity: 1;
}

.example-auto-run-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 12px;
  font-weight: 500;
  color: var(--color-text);
  cursor: pointer;
  white-space: nowrap;
  transition: color 0.15s ease;
}

.example-auto-run-toggle:has(.toggle-switch-input:not(:checked)) {
  color: var(--color-text-muted);
}

.toggle-switch-input {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.toggle-switch {
  position: relative;
  display: inline-block;
  width: 30px;
  height: 18px;
  background-color: #eee;
  border-radius: 100vw;
  transition: 0.3s;
  flex-shrink: 0;
}

.toggle-switch-knob {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  background-color: #fff;
  border-radius: 100%;
  transition: transform 0.3s;
}

.toggle-switch-input:checked ~ .toggle-switch {
  background-color: #ddd;
}

.toggle-switch-input:checked ~ .toggle-switch .toggle-switch-knob {
  background-color: #fff;
  transform: translate(12px);
}

.toggle-switch-input:focus-visible ~ .toggle-switch {
  outline: 2px solid #ddd;
  outline-offset: 2px;
}

.example-header-divider {
  width: 1px;
  height: 20px;
  margin: 0 0.375rem;
  background: var(--color-border);
  flex-shrink: 0;
}

.example-copy-code-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.example-copy-code-btn:disabled:hover {
  background: var(--color-bg);
}

.example-copy-code-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.3rem 0.65rem;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-body);
  font-size: 0.75rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s ease;
}

.example-copy-code-btn:hover {
  background: var(--color-surface);
}

.example-copy-code-label {
  font-size: 12px;
  font-weight: 500;
}

.example-code-panel .code-block {
  flex: 1;
  width: 100%;
  max-width: none;
  min-width: 0;
  margin: 0;
  padding: 0;
  border: none;
  border-radius: 0;
  background: #eee;
  min-height: 0;
  overflow: hidden;
}

.example-monaco-container {
  position: absolute;
  inset: 0;
}

.example-canvas-preview {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.85rem;
  padding: 1.5rem;
  background: #eee;
  overflow: auto;
}

.example-canvas {
  max-width: 100%;
  height: auto;
  background: #ffffff;
  border: 1px solid var(--color-border);
}

.example-canvas.is-dark {
  background: #1a1a1a;
}

@media (max-width: 860px) {
  .example-code-panel {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr 1fr;
  }

  .example-code-panel-preview {
    border-right: none;
    border-bottom: 1px solid var(--color-border);
  }
}

.example-pagination[hidden] {
  display: none;
}

.example-pagination {
  margin-top: var(--space-3);
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 1rem;
}

.example-pagination-count {
  justify-self: center;
}

.example-pagination-link.is-next {
  justify-self: end;
}

.example-pagination-link {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  font-size: 0.8rem;
  color: var(--color-text);
  transition: color 0.15s ease;
}

.example-pagination-link:hover {
  color: #aaaaaa;
}

.example-pagination-link.is-next {
  text-align: right;
  align-items: flex-end;
}

.example-pagination-link[hidden] {
  visibility: hidden;
}

.example-pagination-label {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  text-transform: uppercase;
}

#example-prev-link:hover .playground-card-link-icon {
  transform: translateX(-3px);
}

#example-next-link:hover .playground-card-link-icon {
  transform: translateX(3px);
}

.example-pagination-title {
  font-size: 0.9rem;
  font-weight: 400;
  color: var(--color-text-muted);
}

.example-pagination-count {
  font-size: 0.78rem;
  font-weight: 400;
  color: var(--color-text);
  white-space: nowrap;
}
