/* =========================
   Prism code block
========================= */

.code-block {
  background: #1e1e1e;
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 24px;
  padding: 20px 22px 18px;
  margin: 24px 0;
  overflow: hidden;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.03),
    0 0 0 1px rgba(255, 255, 255, 0.02);
}

.code-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  margin-bottom: 14px;
}

.code-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.code-file {
  color: rgba(255, 255, 255, 0.85);
  font-size: 0.95rem;
  font-weight: 500;
}

.code-lang {
  color: rgba(255, 255, 255, 0.5);
  font-size: 0.85rem;
  letter-spacing: 0.05em;
}

.copy-btn {
  width: 42px;
  height: 42px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: rgba(255, 255, 255, 0.88);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.18s ease, transform 0.18s ease, color 0.18s ease;
  flex-shrink: 0;
}

.copy-btn:hover {
  background: rgba(255, 255, 255, 0.08);
}

.copy-btn:active {
  transform: scale(0.96);
}

.copy-btn svg {
  width: 22px;
  height: 22px;
}

.code-copy-status {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.code-block pre[class*="language-"] {
  margin: 0;
  padding: 1.1rem 1rem !important;
  background: transparent !important;
  border-radius: 0;
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
}

.code-block code[class*="language-"] {
  display: block;
  min-width: max-content;
  font-family: Consolas, Monaco, "Courier New", monospace;
  font-size: 0.98rem;
  line-height: 1.7;
}

.code-block pre,
.code-block code {
  white-space: pre;
  word-break: normal;
  word-wrap: normal;
}

/* Line numbers */
.code-block pre.line-numbers {
  position: relative;
  padding-left: 3.8em !important;
}

.code-block pre.line-numbers > code {
  position: relative;
  white-space: inherit;
}

.code-block .line-numbers .line-numbers-rows {
  position: absolute;
  pointer-events: none;
  top: 0;
  left: -3.8em;
  width: 3em;
  border-right: 1px solid rgba(255, 255, 255, 0.1);
  user-select: none;
}

.code-block .line-numbers-rows > span {
  display: block;
  counter-increment: linenumber;
}

.code-block .line-numbers-rows > span::before {
  content: counter(linenumber);
  display: block;
  padding-right: 0.8em;
  text-align: right;
  color: rgba(255, 255, 255, 0.32);
}

/* Scrollbar */
.code-block pre[class*="language-"]::-webkit-scrollbar {
  height: 8px;
}

.code-block pre[class*="language-"]::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.18);
  border-radius: 999px;
}

.code-block pre[class*="language-"]::-webkit-scrollbar-track {
  background: transparent;
}

.kw-red {
  color: #ff5f56;
}

.kw-blue {
  color: #33AAFF;
}

.kw-reddishpurple {
  color: #881144;
}

.kw-togenashi-tog {
  color: #D90E2C;
}

.kw-togenashi-ena {
  color: #85C9DC;
}

.kw-togenashi-shi {
  color: #76BD53;
}

.kw-togeari-tog {
  color: #E34D8D;
}

.kw-togeari-eari {
  color: #EEDA01;
}

@media (max-width: 900px) {
  .code-block {
    padding: 16px 16px 14px;
    margin: 18px 0;
  }

  .code-header {
    margin-bottom: 10px;
  }

  .code-lang {
    font-size: 0.95rem;
  }

  .copy-btn {
    width: 38px;
    height: 38px;
    border-radius: 10px;
  }

  .copy-btn svg {
    width: 20px;
    height: 20px;
  }

  .code-block code[class*="language-"] {
    font-size: 0.92rem;
    line-height: 1.6;
  }

  .code-block pre[class*="language-"] {
    padding: 1rem 0.9rem !important;
  }

  .code-block pre.line-numbers {
    padding-left: 3.6em !important;
  }

  .code-block .line-numbers .line-numbers-rows {
    left: -3.6em;
    width: 2.8em;
  }
}

.about-page .code-block.code-block-with-gutter {
  position: relative;
}

.about-page .code-block.code-block-with-gutter pre[class*="language-"] {
  padding-left: 4.4rem !important;
}

.about-page .code-block.code-block-with-gutter > .custom-line-numbers {
  position: absolute;
  top: 6.25rem;
  left: 1.35rem;
  width: 2.5rem;
  padding-right: 0.85rem;
  border-right: 1px solid rgba(19, 26, 38, 0.14);
  color: rgba(19, 26, 38, 0.45);
  font-family: ui-monospace, "SFMono-Regular", "SF Mono", Menlo, Monaco,
    Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 0.98rem;
  line-height: 1.7;
  text-align: right;
  pointer-events: none;
  user-select: none;
  z-index: 4;
}

.about-page .code-block.code-block-with-gutter > .custom-line-numbers span {
  display: block;
}

@media (min-width: 901px) {
  .about-page .code-block {
    max-width: 1120px;
    margin-left: auto;
    margin-right: auto;
  }
}

@media (max-width: 900px) {
  .about-page .code-block.code-block-with-gutter pre[class*="language-"] {
    padding-left: 3.4rem !important;
  }

  .about-page .code-block.code-block-with-gutter > .custom-line-numbers {
    top: 5.35rem;
    left: 0.95rem;
    width: 1.9rem;
    padding-right: 0.55rem;
    font-size: 0.68rem;
    line-height: 1.5;
  }
}

@media (max-width: 430px) {
  .about-page .code-block.code-block-with-gutter pre[class*="language-"] {
    padding-left: 3.15rem !important;
  }

  .about-page .code-block.code-block-with-gutter > .custom-line-numbers {
    top: 5.05rem;
    left: 0.8rem;
    width: 1.75rem;
    padding-right: 0.5rem;
    font-size: 0.62rem;
    line-height: 1.48;
  }
}

@media (prefers-reduced-motion: reduce) {
  .about-page .copy-btn,
  .about-page .code-block.code-block-with-gutter code[class*="language-"],
  .about-page .code-block.code-block-with-gutter > .custom-line-numbers {
    transition: none !important;
  }

  .about-page .copy-btn:active {
    transform: none;
  }
}
