/* updated (changed) on: 2024/03/29 (CSS Nesting) */
/* pre 要素のラッパー要素（div）に指定するクラス */
.hljs-wrap {
  position: relative;

  /* pre 要素 */
  pre {
    overflow-wrap: break-word;
    overflow-x: hidden;
    padding: 0;
    margin: 0;
    /* 必要に応じてフォントサイズなどを設定 */
  }

  /* pre-wrap クラスを指定すると行を自動で折り返す */
  pre.pre-wrap {
    white-space: pre-wrap;
  }

  /* pre クラスを指定すると行を自動で折返さない */
  pre.pre {
    white-space: pre;
  }

  /* code 要素 */
  pre code {
    padding-left: 3rem;
    position: relative;
    /* 自動折り返しの設定は親要素（pre）の値を継承 */
    white-space: inherit;
    /* コード内に垂直方向のスクロールバーが表示されるのを防止（必要に応じて） */
    overflow-y: hidden;
  }

  /* 行番号横枠線を表示する場合 */
  &.line-num-bordered pre code {
    padding-left: 3.25rem;
  }

  /* ツールバーを使わない場合の code 要素 */
  &.no-toolbar pre code,
  body.no-toolbar & pre code {
    padding-bottom: 1.5rem;
    padding-top: 2.5rem;
  }

  &.no-toolbar pre code.show-no-lang,
  body.no-toolbar & pre code.show-no-lang {
    padding-top: 1rem;
  }

  &.no-toolbar.has-copy-btn pre code.show-no-lang,
  body.no-toolbar.has-copy-btn & pre code.show-no-lang {
    padding-top: 2rem;
  }

  &.no-toolbar pre code,
  body.no-toolbar & pre code {
    padding-bottom: 1rem;
  }

  /* ツールバー */
  .highlight-toolbar {
    height: 2rem;
    background-color: #3a3e4a;
    padding-right: 5px;
    color: #999;
    font-size: 12px;
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: center;
  }

  &.no-lang .highlight-toolbar {
    justify-content: flex-end;
  }

  .highlight-toolbar + pre {
    margin-top: 0;
  }

  .highlight-toolbar label {
    color: #888;
    cursor: pointer;
    margin: 0 10px 0 0;
    transition: color 0.3s;
  }

  .highlight-toolbar input[type="checkbox"] {
    background-color: #262b37;
    transition: background-color 0.3s;
    display: none;
  }

  @media screen and (min-width: 640px) {
    .highlight-toolbar label {
      margin: 0 10px 0 3px;
    }

    .highlight-toolbar input[type="checkbox"] {
      display: block;
    }
  }

  .highlight-toolbar input[type="checkbox"]:hover {
    background-color: #0d37a9;
  }

  /* チェックボックスのスタイルのリセット */
  .highlight-toolbar input[type="checkbox"] {
    border-radius: 0;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
  }

  /* チェックボックスのスタイル */
  .highlight-toolbar input[type="checkbox"] {
    position: relative;
    width: 16px;
    height: 16px;
    border: 1px solid #333;
    cursor: pointer;
  }

  /* チェックマークのスタイル */
  .highlight-toolbar input[type="checkbox"]:checked:before {
    content: "";
    position: absolute;
    top: 0px;
    left: 4px;
    transform: rotate(45deg);
    width: 4px;
    height: 8px;
    border-right: 2px solid #bbb;
    border-bottom: 3px solid #bbb;
  }

  .highlight-toolbar input[type="checkbox"]:checked + label {
    color: #b9bfd0;
  }

  /* 言語名を表示 */
  code[data-language]::before {
    content: attr(data-language);
    position: absolute;
    top: 0;
    left: 0;
    color: #ccc;
    display: inline-block;
    padding: 0.5rem 1rem;
    /* コードの背景色と同じにする場合は background-color: #282c34; */
    background-color: #40547d;
    z-index: 5;
  }

  code[data-language].hide-line-num::before {
    left: 2.5rem;
  }

  /* ツールバーの中の言語名の表示 */
  .highlight-toolbar .lng-span {
    margin-right: auto;
    margin-left: 10px;
    font-size: 13px;
    color: #ccc;
  }

  /* コピーボタン（ツールバーを使用しない場合） */
  .hljs-copy-btn {
    position: absolute;
    top: 0;
    right: 0;
    background-color: #262b37;
    border: none;
    padding: 8px;
    color: #999;
    cursor: pointer;
    transition: color 0.3s, background-color 0.3s;
  }

  .hljs-copy-btn:hover {
    color: #eee;
    background-color: #162858;
  }

  /* ツールバーの中のコピーボタン */
  .highlight-toolbar .hljs-copy-btn {
    position: relative;
    margin: 0 10px;
    padding: 2px 4px;
  }

  /* ラベルとリンク（data-label 属性と data-label-url 属性で指定した文字列） */
  .hljs-label,
  .hljs-label-url {
    position: absolute;
    top: -2rem;
    right: 10px;
    color: #999;
    display: inline-block;
    padding: 0.5rem 0;
  }

  .hljs-label-url {
    color: #3987c7;
    text-decoration: none;
  }

  .hljs-label-url:hover {
    color: #55924f;
  }

  &.has-label {
    margin-top: 4rem;
  }

  &:not(.has-label) {
    margin-top: 2.25rem;
  }

  /* 行番号（CSS カウンター）*/
  pre {
    counter-reset: lineNumber;
  }

  pre span.line-num::before {
    counter-increment: lineNumber;
    content: counter(lineNumber);
    min-width: 2.5rem;
    display: inline-block;
    color: #777;
    text-align: center;
    position: absolute;
    left: 0;
    background: #282c34;
  }

  /* 行番号を非表示にする場合 */
  pre code.hide-line-num span.line-num::before {
    left: -2.5rem;
  }

  /* 行番号を非表示にする場合 */
  pre code.hide-line-num {
    margin-left: -2.5rem;
  }

  /* 行番号右側の枠線 */
  .hljs-border-span {
    background-color: transparent;
    width: 2.5rem;
    border-right: 1px solid #595a60;
    top: 0;
    left: 0;
  }

  /* 行番号非表示の場合（枠線なし） */
  pre code.hide-line-num .hljs-border-span {
    border: none;
  }

  /* 行のハイライト時の行番号部分 */
  pre span.line-num.line-num-highlight::before {
    color: #c2c21a;
    /* background: #424638; */
  }

  /* 行のハイライト時のコード部分 */
  .line-highlight {
    position: absolute;
    /* 行番号の幅と合わせる */
    left: 2.5rem;
    width: calc(100% - 2.5rem);
    margin-left: -2.5rem;
    width: 100%;
    background: linear-gradient(
      to right,
      hsla(254, 15%, 51%, 0.2) 50%,
      hsla(254, 15%, 51%, 0.01)
    );
    pointer-events: none;
  }

  /* 行数を指定して表示する場合にコード下に表示する領域 */
  .scroll-footer {
    margin: 0;
    font-size: 0.75rem;
    color: #999;
    /* コードの背景色と同じ色 */
    background-color: #282c34;
    padding: 8px;
    display: flex;
    justify-content: flex-end;
  }

  /* .scroll-footer の右端に表示するテキスト*/
  .scroll-footer-text {
    margin-left: auto;
  }

  /* .scroll-footer-text の左側に表示するアイコン（色は fill='%23aaaaaa' の aaaaaa 部分） */
  .scroll-footer-text::before {
    content: "";
    display: inline-block;
    height: 0.875rem;
    width: 0.875rem;
    vertical-align: -2px;
    margin-right: 8px;
    background-repeat: no-repeat;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='%23aaaaaa' viewBox='0 0 16 16'%3E  %3Cpath fill-rule='evenodd' d='M11.5 15a.5.5 0 0 0 .5-.5V2.707l3.146 3.147a.5.5 0 0 0 .708-.708l-4-4a.5.5 0 0 0-.708 0l-4 4a.5.5 0 1 0 .708.708L11 2.707V14.5a.5.5 0 0 0 .5.5m-7-14a.5.5 0 0 1 .5.5v11.793l3.146-3.147a.5.5 0 0 1 .708.708l-4 4a.5.5 0 0 1-.708 0l-4-4a.5.5 0 0 1 .708-.708L4 13.293V1.5a.5.5 0 0 1 .5-.5'/%3E%3C/svg%3E");
  }

  /* テーマ（atom-one-dark）のコメントの色を上書き */
  .hljs-comment {
    color: #6b788f;
  }
}

/* コードの表示・非表示（ details 要素と summary 要素によるアコーディオン）*/
details.toggle-code-animation {
  border: none;
  margin: 2rem 0;

  .details-content-wrapper {
    padding: 1rem 0;
  }

  .details-content {
    overflow: hidden;
  }

  summary {
    display: inline-block;
    cursor: pointer;
    position: relative;
    padding: 0.5rem 1.5rem 0.5rem 2.25rem;
    border: 1px solid #aaa;
    font-size: 13px;
  }

  summary::-webkit-details-marker {
    display: none;
  }

  summary::before {
    content: "";
    position: absolute;
    top: 0;
    bottom: 0;
    left: 10px;
    margin: auto 0;
    width: 8px;
    height: 8px;
    border-top: 3px solid #097b27;
    border-right: 3px solid #097b27;
    transform: rotate(45deg);
  }
}