/*
 * Kouider — Code blocks: shell, label bar, copy button.
 * The shell markup is produced by inc/blog.php (render_block filter on core/code).
 */

.k-code {
  position: relative;
  margin: 1.7em 0;
  border: 1px solid rgba(255, 255, 255, .10);
  border-radius: 14px;
  background: rgba(255, 255, 255, .035);
  overflow: hidden;
}

/* --- separator bar --- */
.k-code-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px 9px 14px;
  background: #111114;
  border-bottom: 1px solid rgba(255, 255, 255, .08);
}

.k-code-dots {
  display: inline-flex;
  gap: 6px;
  flex: 0 0 auto;
}
.k-code-dots i {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: rgba(255, 255, 255, .16);
}
.k-code-dots i:first-child { background: #ff2638; }
.k-code-dots i:nth-child(2) { background: rgba(255, 255, 255, .3); }

.k-code-lang {
  font-family: ui-monospace, 'Cascadia Code', 'JetBrains Mono', Menlo, Consolas, monospace;
  font-size: .69rem;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--wp--preset--color--k-muted, #a6a6ad);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* --- copy button --- */
.k-code-copy {
  margin-left: auto;
  flex: 0 0 auto;
  font-family: ui-monospace, 'Cascadia Code', 'JetBrains Mono', Menlo, Consolas, monospace;
  font-size: .7rem;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--wp--preset--color--k-white, #f7f7f8);
  background: rgba(255, 255, 255, .05);
  border: 1px solid rgba(255, 255, 255, .16);
  border-radius: 999px;
  padding: 5px 13px;
  line-height: 1.35;
  cursor: pointer;
  transition: background .18s ease, border-color .18s ease, color .18s ease;
}
.k-code-copy:hover,
.k-code-copy:focus-visible {
  background: rgba(255, 38, 56, .16);
  border-color: rgba(255, 38, 56, .55);
  color: #fff;
  outline: none;
}
.k-code-copy.is-copied {
  background: rgba(52, 211, 153, .16);
  border-color: rgba(52, 211, 153, .55);
  color: #a7f3d0;
}
.k-code-copy.is-failed {
  background: rgba(255, 38, 56, .2);
  border-color: rgba(255, 38, 56, .6);
  color: #ffc9cf;
}

/* --- body: neutralise the generic post-content pre rules --- */
.k-code .k-code-body > pre,
.k-code .k-code-body pre.wp-block-code {
  margin: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  padding: 18px 20px;
}
.k-code .k-code-body > pre code {
  display: block;
  background: none;
  border: 0;
  padding: 0;
}

/* Long lines scroll inside the shell, never the page. */
.k-code .k-code-body {
  overflow-x: auto;
}
.k-code .k-code-body > pre {
  overflow: visible;
}

@media (max-width: 600px) {
  .k-code-bar { padding: 8px 10px 8px 12px; }
  .k-code-copy { padding: 5px 10px; font-size: .66rem; }
  .k-code .k-code-body > pre { padding: 14px 14px; }
}

/* Never print the button. */
@media print {
  .k-code-copy, .k-code-dots { display: none; }
  .k-code { border-color: #ccc; background: #fff; }
  .k-code-bar { background: #f2f2f2; }
}