/* Playground: editor + syntax highlight + completions */

.playground-main {
  padding: 2rem 0 3rem;
}

.playground-main h1 {
  font-size: 1.75rem;
  font-weight: 700;
  margin: 0 0 0.5rem;
}

.playground-intro {
  color: var(--text-muted);
  margin: 0 0 1.25rem;
  font-size: 0.95rem;
}

.playground-intro kbd {
  font-family: var(--font-mono);
  font-size: 0.85em;
  padding: 0.1em 0.4em;
  background: var(--code-bg);
  border-radius: 4px;
  border: 1px solid var(--border);
}

.playground-editor-wrap {
  position: relative;
  margin-bottom: 1rem;
}

.playground-editor {
  position: relative;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: #2d2a2e;
  min-height: 280px;
}

/* Must match textarea exactly so caret aligns with highlighted text */
.playground-highlight,
.playground-textarea {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  margin: 0;
  padding: 16px 20px;
  font-family: var(--font-mono);
  font-size: 14px;
  line-height: 21px;
  tab-size: 4;
  white-space: pre-wrap;
  word-wrap: break-word;
  box-sizing: border-box;
  letter-spacing: normal;
}

.playground-highlight {
  overflow: hidden;
  pointer-events: none;
  color: #e6e4e1;
  /* No extra spacing so first line aligns with textarea */
  padding: 16px 20px;
  margin: 0;
  font-size: 14px;
  line-height: 21px;
}

/* Override Prism theme so code uses same metrics as textarea (Prism sets 1em / 1.5) */
.playground-editor .playground-highlight code,
.playground-editor .playground-highlight code[class*="language-"] {
  display: block;
  background: none !important;
  padding: 0 !important;
  margin: 0 !important;
  font-family: var(--font-mono) !important;
  font-size: 14px !important;
  line-height: 21px !important;
  color: inherit;
  vertical-align: top;
}

.playground-editor .playground-highlight code *,
.playground-editor .playground-highlight code[class*="language-"] * {
  line-height: 21px !important;
  font-size: 14px !important;
  font-family: var(--font-mono) !important;
}

.playground-textarea {
  resize: none;
  background: transparent;
  color: transparent;
  caret-color: #fff;
  border: none;
  outline: none;
  overflow: auto;
}

.playground-textarea::placeholder {
  color: rgba(255,255,255,0.35);
}

.completion-list {
  position: absolute;
  margin-top: 4px;
  width: 100%;
  max-width: 420px;
  max-height: 200px;
  overflow-y: auto;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  z-index: 100;
  /* top/left set in JS to caret position */
}

.completion-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.4rem 0.75rem;
  cursor: pointer;
  font-size: 0.9rem;
  border-bottom: 1px solid var(--border);
}

.completion-item:last-child {
  border-bottom: none;
}

.completion-item:hover,
.completion-item.selected {
  background: var(--code-bg);
}

.completion-label {
  font-family: var(--font-mono);
  font-weight: 500;
}

.completion-detail {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.playground-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

.playground-hint {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-left: 0.5rem;
}

.playground-output {
  padding: 1rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.9rem;
}

.playground-output pre {
  margin: 0.5rem 0 0;
  padding: 0.75rem;
  background: var(--code-bg);
  border-radius: 4px;
  overflow-x: auto;
}

.playground-output code {
  font-size: 0.85rem;
}
