/* Code blocks UI: toolbar, copy, expand, and accents */

:root{
  --cb-bg: #0a1022;
  --cb-border: rgba(255,255,255,0.08);
  --cb-text: #eaf0ff;
  --cb-muted: #a5afd6;
  --cb-toolbar-bg: rgba(14,18,30,0.55);
  --cb-toolbar-border: rgba(255,255,255,0.06);
  --cb-accent: #24d8b6;
  --cb-accent-2: #6aa3ff;

  --cb-radius: 14px;
  --cb-shadow: 0 16px 38px rgba(0,0,0,0.45);

  --cb-fade: linear-gradient(to bottom, rgba(10,16,34,0), rgba(10,16,34,0.85) 50%, rgba(10,16,34,1));
}

/* Wrapper */
.code-block{
  position: relative;
  border: 1px solid var(--cb-border);
  border-radius: var(--cb-radius);
  overflow: hidden;
  background: var(--cb-bg);
  box-shadow: var(--cb-shadow);
  margin: 1rem 0;
}

/* Language accent (left border) */
.code-block::before{
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  background: linear-gradient(180deg, var(--cb-accent), var(--cb-accent-2));
}

/* Toolbar */
.code-toolbar{
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
  padding: .5rem .6rem .5rem .75rem;
  background: var(--cb-toolbar-bg);
  border-bottom: 1px solid var(--cb-toolbar-border);
  backdrop-filter: blur(6px);
}

.code-id{
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  min-width: 0;
}

.code-dot{
  width: 10px; height: 10px; border-radius: 50%;
  background: linear-gradient(135deg, var(--cb-accent), var(--cb-accent-2));
  box-shadow: 0 0 0 2px rgba(255,255,255,0.04);
  flex: 0 0 auto;
}

.code-lang{
  font-weight: 800;
  letter-spacing: .2px;
  color: var(--cb-text);
  font-size: .9rem;
  white-space: nowrap;
}

.code-filename{
  color: var(--cb-muted);
  font-size: .85rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: min(44vw, 380px);
}

/* Actions */
.code-actions{
  display: inline-flex;
  align-items: center;
  gap: .4rem;
}

.code-btn{
  appearance: none;
  border: 1px solid rgba(255,255,255,0.10);
  background: rgba(255,255,255,0.04);
  color: var(--cb-text);
  font-weight: 700;
  font-size: .8rem;
  padding: .35rem .6rem;
  border-radius: 8px;
  cursor: pointer;
  transition: 160ms ease;
}
.code-btn:hover{ background: rgba(255,255,255,0.075); }

/* Pre/code area */
.code-block pre{
  margin: 0;
  background: transparent;
  border: 0;
  border-radius: 0;
  padding: .9rem .9rem 1.1rem;
  color: var(--cb-text);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono","Courier New", monospace;
  font-size: .95rem;
  line-height: 1.55;
  overflow: auto;
}

/* Make entire block copyable if desired (JS toggles) */
.code-block pre.copyable{ cursor: pointer; }

/* Bash/sh special treatment inside */
.code-block pre > code.language-bash,
.code-block pre > code.lang-bash,
.code-block pre > code.language-sh,
.code-block pre > code.lang-sh {
  display: block;
  background: linear-gradient(180deg, #071627, #081a2d);
  padding: .75rem;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.06);
}

/* Long block collapse */
.code-block.is-collapsed pre{
  max-height: 360px;
}

.code-fade{
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 80px;
  background: var(--cb-fade);
  pointer-events: none;
  opacity: 0;
  transition: opacity .18s ease;
}
.code-block.is-collapsed .code-fade{ opacity: 1; }

/* Toast (shared with previous CSS if present) */
#copy-toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  background: rgba(16,18,30,0.95);
  color: #f8fafc;
  padding: 0.9rem 1rem;
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(2,6,23,0.6);
  font-weight: 700;
  z-index: 99999;
  transform: translateY(12px) scale(0.98);
  opacity: 0;
  transition: opacity .18s ease, transform .18s cubic-bezier(.2,.9,.2,1);
  display: flex;
  gap: .6rem;
  align-items: center;
}
#copy-toast.show { transform: translateY(0) scale(1); opacity: 1; }
#copy-toast .icon{
  width: 20px; height: 20px; display: inline-block; border-radius: 4px;
  background: linear-gradient(135deg, #6aa3ff, #24d8b6);
}

/* Mobile tweaks */
@media (max-width: 560px){
  .code-toolbar{ padding-left: .6rem; padding-right: .6rem; }
  .code-filename{ max-width: 52vw; }
}
