/* ===== SCROLLBAR STYLES ===== */
figure.shiki div.codeblock::-webkit-scrollbar {
  width: 5px;
  height: 5px;
}

figure.shiki div.codeblock::-webkit-scrollbar-thumb {
  background: var(--hlscrollbar-bg);
  border-radius: 2.5px;
}

/* ===== MAIN CODE BLOCK FIGURE ===== */
figure.shiki {
  margin: 0 0 24px;
  padding: 0;
  border-radius: 8px !important;
  border: #313244 1.5px solid;
  background: var(--hl-bg);
  color: var(--hl-color);
  line-height: 1.6;
  position: relative;
  overflow: auto;
  -webkit-transform: translateZ(0);
  transform: translateZ(0);
}

/* Hide content when toolbar is closed */
figure.shiki .shiki-tools.closed~* {
  display: none;
}

/* ===== TOOLBAR STYLES ===== */
.shiki-tools {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 30px;
  height: 0.9em;
  padding: 0 15px;
  border-radius: 35px 35px 0 0;
  background: var(--hltools-bg);
  color: var(--hltools-color);
  font-size: 1em;
  user-select: none;
  overflow: hidden;
  position: relative;
}

/* Toolbar sections */
.shiki-tools .left,
.shiki-tools .right {
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

.shiki-tools .left {
  gap: 5px;
}

.shiki-tools .right {
  gap: 10px;
}

.shiki-tools .center {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-grow: 1;
  overflow: hidden;
  min-width: 0;
}

/* ===== INTERACTIVE ELEMENTS ===== */
.shiki-tools .copy-button,
.shiki-tools .raw-button,
.shiki-tools .fa-list-ol,
.shiki-tools .fa-arrow-down-wide-short,
.shiki-tools .expand {
  cursor: pointer;
  transition: color 0.3s, transform 0.3s ease;
}

.shiki-tools .expand {
  font-size: 1.2em;
  margin-left: -2px;
}

.shiki-tools .expand.closed {
  transform: rotate(90deg);
}

/* Hover effects */
.shiki-tools .copy-button:hover,
.shiki-tools .raw-button:hover,
.shiki-tools .fa-list-ol:hover,
.shiki-tools .fa-arrow-down-wide-short:hover,
.shiki-tools .expand:hover {
  color: #89b4fa;
}

/* ===== COPY NOTICE ===== */
.shiki-tools .copy-notice {
  position: absolute;
  color: #89b4fa;
  background: var(--hltools-bg);
  white-space: nowrap;
  opacity: 0;
  visibility: hidden;
  z-index: 1000;
  padding: 0 5px 0 0;
  transform: translateX(-110%);
  transition: opacity 0.2s ease, visibility 0.2s ease;
}

.shiki-tools .copy-notice[style*="opacity: 1"] {
  opacity: 1;
  visibility: visible;
}

/* ===== TITLE AND LANGUAGE STYLES ===== */
.shiki-tools .code-title {
  font-size: 0.9em;
  font-weight: 500;
  padding: 0 10px;
  color: var(--hltools-color);
  user-select: text;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex-shrink: 1;
}

.shiki-tools .code-lang {
  padding-left: 5px;
  font-size: 0.9em;
  font-weight: 500;
  opacity: 0;
  visibility: hidden;
  user-select: none;
  transition: opacity 0.4s ease, visibility 0.4s ease;
}

figure.shiki:hover .shiki-tools .code-lang {
  opacity: 1;
  visibility: visible;
}

/* ===== TRAFFIC LIGHTS ===== */
.shiki-tools .left .traffic-lights {
  display: flex;
  align-items: center;
  padding-right: 8px;
  margin-left: -7px;
}

.traffic-light {
  display: block;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  margin-left: 8px;
  background-color: #ddd;
  position: relative;
}

.traffic-light.red {
  background-color: #f38ba8;
}

.traffic-light.yellow {
  background-color: #fab387;
}

.traffic-light.green {
  background-color: #a6e3a1;
}

/* Traffic light hover icons */
.traffic-light::after {
  content: "";
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  color: rgba(0, 0, 0, 0.6);
  font-weight: bold;
  font-size: 9px;
  font-family: "Lucida Grande", "Segoe UI", sans-serif;
  opacity: 0;
  transition: opacity 0.2s ease-in-out;
}

/* ===== EXPAND BUTTON ===== */
.code-expand-btn {
  position: absolute;
  bottom: 0;
  width: 100%;
  z-index: 1000;
  display: flex;
  justify-content: center;
  align-items: center;
  background: var(--hlexpand-bg);
  font-size: 1em;
  cursor: pointer;
}

.code-expand-btn i {
  padding: 6px 0;
  color: var(--hlnumber-color);
  animation: code-expand-pulse 1.2s infinite;
}

.code-expand-btn.expand-done>i {
  transform: rotate(180deg);
}

@keyframes code-expand-pulse {

  0%,
  100% {
    opacity: 0.6;
  }

  50% {
    opacity: 0.1;
  }
}

/* ===== CODE BLOCK CONTENT ===== */
figure.shiki div.codeblock {
  margin: 0;
  border: none;
  border-radius: 0 0 8px 8px !important;
  display: flex;
  overflow: auto;
  padding-bottom: 10px;
}

figure.shiki div.codeblock div {
  padding: 0;
  border: none;
}

/* Line numbers (gutter) */
figure.shiki .gutter pre {
  margin-right: 8px !important;
  padding: 0 8px !important;
  background-color: var(--hlnumber-bg) !important;
  color: var(--hlnumber-color) !important;
  text-align: right !important;
  user-select: none !important;
  border: none !important;
  border-radius: 0 !important;
}

/* Code content */
figure.shiki pre {
  margin: 0 !important;
  padding: 0 !important;
  border-radius: 0 !important;
}

figure.shiki pre code {
  background: none !important;
  border: none !important;
}

figure.shiki .codeblock pre * {
  font-size: 1em;
  font-family: "Maple Mono NF CN", "Fira Code", "JetbrainsMono Nerd Font", Menlo, "DejaVu Sans Mono", monospace, 宋体;
  line-height: 1.6;
  overflow: auto !important;
}

figure.shiki .code pre {
  width: 100% !important;
  padding: 0 !important;
  background: none !important;
}

/* Expand button interactions */
.code-expand-btn:not(.expand-done)~pre,
.code-expand-btn:not(.expand-done)~* pre {
  overflow: hidden;
}

.code-expand-btn.expand-done+pre,
.code-expand-btn.expand-done+* pre,
.code-expand-btn.expand-done+div.codeblock,
.code-expand-btn.expand-done+* div.codeblock {
  margin-bottom: 1.8em;
}

.code-expand-btn.expand-done+pre,
.code-expand-btn.expand-done+* pre,
.code-expand-btn.expand-done+div.codeblock,
.code-expand-btn.expand-done+* div.codeblock {
  margin-bottom: 1.8em;
}
