/* 修改 mkdocs-material 的 Grid Card 背景顏色 */
.grid.cards li {
    background-color: #ecfbf1; /* 你想要的背景顏色 */
}

/* 側邊導覽：頁面 icon 與標題對齊，讓選單更醒目 */
.md-nav--primary .md-nav__link {
    align-items: center;
    gap: 0.45rem;
}

.md-nav--primary .md-nav__link svg {
    width: 1.15rem;
    height: 1.15rem;
    fill: var(--md-primary-fg-color, #4051b5);
    flex-shrink: 0;
}

.md-nav--primary .md-nav__item--active > .md-nav__link svg {
    fill: var(--md-accent-fg-color, #ff2b2b);
}

/* 標題：主標題跟頂欄同色系、淡底；次標題淺灰底＋柔和紅條 */
.md-content .md-typeset :is(h1, h2, h3, h4, h5, h6) {
    --heading-accent: #e25555;
    --heading-bg: #f6f6f7;
    position: relative;
    letter-spacing: 0.02em;
    line-height: 1.45;
}

.md-content .md-typeset h1 {
    font-size: 2em;
    font-weight: 700;
    color: var(--md-primary-fg-color, #4051b5);
    background: linear-gradient(
        90deg,
        color-mix(in srgb, var(--md-primary-fg-color, #4051b5) 12%, #ffffff) 0%,
        color-mix(in srgb, var(--md-primary-fg-color, #4051b5) 5%, #ffffff) 72%,
        #ffffff 100%
    );
    border-left: 4px solid var(--md-primary-fg-color, #4051b5);
    padding: 0.4em 1em 0.4em 0.85em;
    margin: 0.1em 0 0.85em;
    border-radius: 0 10px 10px 0;
    box-shadow: none;
}

.md-content .md-typeset h2 {
    font-weight: 700;
    color: #2c2c2c;
    background: var(--heading-bg);
    border-left: 4px solid var(--heading-accent);
    padding: 0.3em 0.9em 0.3em 0.8em;
    margin-top: 2.1em;
    margin-bottom: 0.7em;
    border-radius: 0 8px 8px 0;
}

.md-content .md-typeset h3 {
    font-weight: 700;
    color: #2c2c2c;
    background: #f8f8f8;
    border-left: 3px solid var(--heading-accent);
    padding: 0.24em 0.75em 0.24em 0.7em;
    margin-top: 1.7em;
    margin-bottom: 0.55em;
    border-radius: 0 6px 6px 0;
}

.md-content .md-typeset :is(h4, h5, h6) {
    font-weight: 600;
    color: #333;
    background: none;
    border-left: 2px solid var(--heading-accent);
    padding: 0.1em 0 0.1em 0.6em;
    margin-top: 1.45em;
    margin-bottom: 0.45em;
    border-radius: 0;
}

/* 正文節奏：中文較舒適的行高，標題靠近所屬內容、段落之間留白 */
.md-content .md-typeset {
    line-height: 1.75;
}

.md-content .md-typeset p:not(.admonition-title),
.md-content .md-typeset li {
    line-height: 1.8;
}

.md-content .md-typeset p:not(.admonition-title) {
    margin-block: 0.8em 1.15em;
}

/* Admonition 標題是 <p class="admonition-title">，不要套用正文段落間距 */
.md-content .md-typeset .admonition-title,
.md-content .md-typeset details > summary {
    margin-block: 0;
    line-height: 1.3;
}

.md-content .md-typeset .admonition > p:not(.admonition-title),
.md-content .md-typeset details > p {
    margin-block: 0.35em 0.5em;
}

.md-content .md-typeset .admonition > :last-child,
.md-content .md-typeset details > :last-child {
    margin-bottom: 0.5em;
}

.md-content .md-typeset :is(h1, h2, h3) + p {
    margin-top: 0.15em;
}

.md-content .md-typeset .grid.cards {
    margin: 0.9em 0 0.3em;
}

.md-content .md-typeset pre,
.md-content .md-typeset .highlight {
    margin-block: 0.7em 1.25em;
}

.md-content .md-typeset :is(h1, h2, h3) .twemoji {
    display: inline-flex;
    align-items: center;
    margin-right: 0.4em;
    vertical-align: -0.18em;
}

.md-content .md-typeset h1 .twemoji {
    width: 1.05em;
    height: 1.05em;
}

.md-content .md-typeset :is(h2, h3) .twemoji {
    width: 0.95em;
    height: 0.95em;
}

.md-content .md-typeset h1 .twemoji svg {
    fill: currentColor;
}

.md-content .md-typeset :is(h2, h3) .twemoji svg {
    fill: var(--heading-accent);
}

[data-md-color-scheme="slate"] .md-content .md-typeset :is(h1, h2, h3, h4, h5, h6) {
    --heading-accent: #ff5252;
    --heading-bg: rgba(255, 255, 255, 0.07);
    color: var(--md-default-fg-color);
}

[data-md-color-scheme="slate"] .md-content .md-typeset h1 {
    color: #c5cae9;
    background: linear-gradient(
        90deg,
        color-mix(in srgb, var(--md-primary-fg-color, #4051b5) 28%, transparent) 0%,
        color-mix(in srgb, var(--md-primary-fg-color, #4051b5) 8%, transparent) 100%
    );
    box-shadow: none;
}

[data-md-color-scheme="slate"] .md-content .md-typeset h2,
[data-md-color-scheme="slate"] .md-content .md-typeset h3 {
    color: var(--md-default-fg-color);
    background: var(--heading-bg);
}

[data-md-color-scheme="slate"] .md-content .md-typeset :is(h4, h5, h6) {
    color: var(--md-default-fg-color);
}

[data-md-color-scheme="slate"] .md-nav--primary .md-nav__link svg {
    fill: #c5cae9;
}

[data-md-color-scheme="slate"] .md-nav--primary .md-nav__item--active > .md-nav__link svg {
    fill: var(--md-accent-fg-color, #ff5252);
}

/* 可以根據需要調整 margin 的數值 */
.md-typeset a.md-button {
    margin: 4px;
    padding: 4px 8px;
}

.md-typeset__table {
    line-height: 1;
    width: auto;
}

.md-typeset__table table:not([class]) {
    font-size: .74rem;
    border: 1px solid black;
}

.md-typeset__table table:not([class]) td,
.md-typeset__table table:not([class]) th {
    padding: 5px;
    border: 1px solid gray;
    min-width: 30px;
}

.md-typeset__table tr:nth-child(2n) {
    background-color: #f8f8f8;
}

[data-md-color-scheme="slate"] .md-typeset__table tr:nth-child(2n) {
    background-color: hsla(var(--md-hue),25%,25%,1)
}


/* 底下的設定是為了不讓 content 上捲時， Nav Bar 跟著向上移動一點點 */

/* 桌面側欄：隱藏 nav title，避免內容上捲時標題列造成位移。
   不可在手機一併隱藏——進到分類後，.md-nav__title 就是返回上一層的按鈕。 */
@media screen and (min-width: 76.25em) {
  .md-nav__title {
    display: none;
  }
}

/* 手機抽屜：回首頁／回上一層列改成與一般 Navbar 選項同高，不要佔 5.6rem。 */
@media screen and (max-width: 76.1875em) {
  .md-nav--primary .md-nav__title {
    display: flex;
    align-items: center;
    height: auto;
    min-height: 0;
    padding: 0.6rem 0.8rem;
    line-height: 1.5;
    font-size: 0.8rem;
  }

  .md-nav--primary .md-nav__title .md-nav__icon {
    position: static;
    top: auto;
    left: auto;
    right: auto;
    width: 1.15rem;
    height: 1.15rem;
    margin: 0 0.45rem 0 0;
    flex-shrink: 0;
  }

  .md-nav--primary .md-nav__title .md-logo {
    position: static;
    left: auto;
    right: auto;
    top: auto;
    display: inline-flex;
    align-items: center;
    padding: 0;
    margin: 0 0.45rem 0 0;
  }

  .md-nav--primary .md-nav__title .md-nav__button.md-logo img,
  .md-nav--primary .md-nav__title .md-nav__button.md-logo svg {
    width: 1.15rem;
    height: 1.15rem;
    max-width: 1.15rem;
  }
}

/* 設定 md-main__inner 的 margin 和 padding 為 0 */
.md-main__inner.md-grid {
    margin-top: 0 !important;
    /* padding: 0 !important; */
}

/* 隱藏 div.mermaid 的原始文字 */
div.mermaid {
    color:transparent;
}

/* 修正 inline <code> 裡面的 css，凸顯他的顯示 */
.md-typeset code:not(pre code) {
    font-family: "JetBrains Mono", "Source Code Pro", Consolas, Menlo, monospace;
    font-size: 1em;
    color: red;
    background-color: #f0f0f0;
    padding: 0.1em 0.25em;
    border-radius: 3px;
}

/* 讓 admonition 裡的文字恢復正常字體大小 */
.md-typeset .admonition,
.md-typeset details {
  font-size: 1em;
}

/* 窄螢幕：頁尾版權與社交圖示維持左右，不要因為 copyright 寬度 100% 而上下疊。 */
.md-footer-meta__inner {
  flex-wrap: nowrap;
  align-items: center;
}

.md-footer-meta .md-copyright {
  width: auto;
  flex: 1 1 auto;
  min-width: 0;
}

.md-footer-meta .md-social {
  flex-shrink: 0;
  padding-top: 0.4rem;
  padding-bottom: 0.4rem;
}

/* 手機：主題預設隱藏「上一頁」標題，只留箭頭。改回兩邊都顯示頁名。 */
@media screen and (max-width: 44.984375em) {
  .md-footer__link {
    min-width: 0;
    max-width: 50%;
  }

  .md-footer__link--prev {
    flex-shrink: 1;
  }

  .md-footer__link--prev .md-footer__title {
    display: block;
  }
}

/* Front matter 日期列（標題上方：主色圖示） */
.md-content__inner.md-typeset > .doc-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 1.1rem;
  margin: 0 0 0.85em;
  padding: 0.15em 0.15em 0;
  color: var(--md-default-fg-color--light, #666);
  font-size: 0.82em;
}

.md-content__inner.md-typeset > .doc-meta .doc-meta__item {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}

.md-content__inner.md-typeset > .doc-meta .twemoji {
  width: 0.95em;
  height: 0.95em;
}

.md-content__inner.md-typeset > .doc-meta .twemoji svg {
  fill: var(--md-primary-fg-color, #4051b5);
}

/* YouTube iframe：維持 16:9，避免把版面撐破 */
.md-typeset .video-wrapper {
  position: relative;
  width: 100%;
  max-width: 840px;
  aspect-ratio: 16 / 9;
  margin: 0.6em 0 1.6em;
  background: #111;
  border-radius: 10px;
  overflow: hidden;
}

.md-typeset .video-wrapper iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}
