/* =================================
   CSS 變數定義 - 方便統一管理顏色
   ================================= */
:root {
  --primary-color: #ff845b;
  --primary-light: #feebe5;
  --text-color: #333333;
  --border-color: #c2c7cd;
  --shadow-light: rgba(158, 158, 158, 0.25);
  --background-white: #ffffff;
  --background-gray: #f2f2f2;
  --footer-bg: #f2f2f2;
  --footer-border: #bdbdbd;
  --uofx-base-font-size: 0.7rem;
}

body {
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
}

/* =================================
   基礎版面配置
   ================================= */
@media screen {
  .md-grid {
    max-width: 75rem;
  }

  .md-main__inner {
    margin-top: 0;
  }
}

.md-content__inner {
  margin-bottom: 100px !important;
}

/* =================================
   頁首樣式
   ================================= */
.md-header,
.md-header--shadow,
.md-header--lifted {
  background: var(--background-white);
  box-shadow: 0 2px 8px var(--shadow-light);
  color: var(--text-color) !important;
}

.md-nav--primary .md-nav__title {
  background-color: var(--background-white) !important;
  color: var(--text-color) !important;
}

/* =================================
   搜尋框樣式
   ================================= */
.md-search__form,
.md-search__output,
.md-search__input {
  border-radius: 20px !important;
}

@media screen and (min-width: 60em) {
  .md-search__form {
    background-color: var(--background-gray) !important;
  }

  .md-search__input + .md-search__icon {
    color: #79839c !important;
  }

  .md-search__input::placeholder {
    color: #616c82 !important;
    opacity: 0.7;
  }
}

/* =================================
   標題樣式
   ================================= */
.md-typeset h1 {
  font-weight: 600;
  color: var(--text-color) !important;
}

.md-typeset h2 {
  font-weight: 500;
  padding: 0.2em 0;
  margin: 1.8em 0;
  border-bottom: 3px solid var(--border-color);
}

.md-typeset h3 {
  font-weight: 500;
  position: relative;
  padding-left: 1.3em;
  line-height: 1.4;
}

.md-typeset h3::before {
  font-family: "FontAwesome";
  content: "\f00c";
  font-weight: 900;
  position: absolute;
  font-size: 1em;
  left: 0;
  top: 0;
  color: var(--primary-color);
}

/* =================================
   標籤頁樣式
   ================================= */
.md-tabs {
  background: var(--background-white);
}

.md-tabs__link,
.md-tabs__item {
  color: var(--text-color) !important;
  font-weight: 600;
}

.md-tabs__item--active,
.md-tabs__item:focus,
.md-tabs__item:hover {
  background: #ededed;
}

/* =================================
   頁尾樣式
   ================================= */
.md-footer {
  color: var(--text-color);
  position: relative;
  .md-footer-meta {
    background-color: var(--footer-bg);
    .md-copyright,
    .md-copyright__highlight {
      color: var(--text-color);
      a {
        color: var(--text-color);
        text-decoration: underline;
      }
    }
  }
}

/* 頁尾版本號樣式 - 使用純 CSS 方式 */
.md-footer-meta__inner {
  position: relative;
}

.md-footer-meta__inner::after {
  content: "建置版號: 2.128.301";
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.7rem;
  color: var(--text-color);
  font-weight: 500;
  margin-right: 12px;
}

/* 響應式：小螢幕時版本號移到下方 */
@media screen and (max-width: 768px) {
  .md-footer-meta__inner::after {
    position: static;
    transform: none;
    display: block;
    text-align: left;
    margin: .6rem;
    font-size: 0.7rem;
  }
}

/* =================================
   深色主題樣式
   ================================= */
[data-md-color-scheme="slate"] .md-tabs {
  background: #333;
}

[data-md-color-scheme="slate"] .md-tabs__link,
[data-md-color-scheme="slate"] .md-tabs__item {
  color: var(--background-white) !important;
  font-weight: 600;
}

[data-md-color-scheme="slate"] .md-tabs__item--active,
[data-md-color-scheme="slate"] .md-tabs__item:focus,
[data-md-color-scheme="slate"] .md-tabs__item:hover {
  background: #727171;
}

/* =================================
   回到頂端按鈕樣式
   ================================= */
.md-top {
  background-color: #616c82;
  color: var(--background-white);
  transition: background-color 0.3s ease;
}

.md-top:hover {
  background-color: #4a5568 !important;
  color: var(--background-white) !important;
}

/* 深色主題下的回到頂端按鈕 */
[data-md-color-scheme="slate"] .md-top {
  background-color: #4a5568;
  color: var(--background-white);
}

[data-md-color-scheme="slate"] .md-top:hover {
  background-color: #616c82 !important;
  color: var(--background-white) !important;
}

/* =================================
   響應式設計優化
   ================================= */
@media screen and (min-width: 76.25em) {
  .md-nav--primary .md-nav__title[for=__drawer] {
    display: none;
  }
}

@media screen and (max-width: 76.2344em) {
  .md-nav--primary .md-nav__item--active > .md-nav__link {
    color: var(--primary-color) !important;
  }
    
  .md-nav--primary .md-nav__link {
    padding: 0.6rem 0.8rem !important;
  }
}

/* =================================
   側邊欄樣式
   ================================= */
.md-sidebar {
  padding: 0.8rem 0 !important;
}

/* =================================
   滾動條樣式優化
   ================================= */
.md-sidebar__scrollwrap:focus-within,
.md-sidebar__scrollwrap:hover,
.md-typeset pre > code:hover {
  scrollbar-color: #999 #f8f8f8;
  scrollbar-width: thin;
}

/* Webkit 瀏覽器滾動條樣式 */
.md-sidebar__scrollwrap::-webkit-scrollbar {
  width: 6px;
}

.md-sidebar__scrollwrap::-webkit-scrollbar-track {
  background: #f1f1f1;
  border-radius: 3px;
}

.md-sidebar__scrollwrap::-webkit-scrollbar-thumb {
  background: #999;
  border-radius: 3px;
}

.md-sidebar__scrollwrap::-webkit-scrollbar-thumb:hover {
  background: #666;
}

/* =================================
   導航連結樣式優化
   ================================= */
li.md-nav__item .md-nav__link:hover,
li.md-nav__item .md-nav__link:focus {
  color: var(--primary-color);
  transition: color 0.3s ease;
}

li.md-nav__item .md-nav__link--active {
  color: var(--primary-color);
  background-color: var(--primary-light);
  font-weight: 600;
  padding: 4px;
  border-radius: 5px;
  transition: all 0.3s ease;
}

li.md-nav__item .md-nav__link--active:hover,
li.md-nav__item .md-nav__link--active:focus {
  color: var(--primary-color);
  background-color: var(--primary-light);
}

/* =================================
   字級與間距
   ================================= */

.md-typeset {
  font-size: var(--uofx-base-font-size);
  line-height: 1.55;
}

.md-typeset h1 {
  margin: 1.4rem 0 0.7rem;
}

.md-typeset h2 {
  margin: 1.2rem 0 0.7rem;
}

.md-typeset p {
  margin: 0.4em 0 0.65em;
}

.md-typeset ul,
.md-typeset ol {
  margin: 0.35em 0 0.75em;
}

.md-typeset li {
  margin: 0.12em 0;
}

.md-typeset table:not([class]) {
  font-size: calc(var(--uofx-base-font-size) * 0.93);
}

.md-typeset table:not([class]) td,
.md-typeset table:not([class]) th {
  padding: 0.3em 0.5em;
}

/* 個別表格套用：以 <div class="nowrap-col1 nowrap-col2" markdown> 包住表格
   可自由指定哪幾欄不折行，支援第 1～6 欄 */
.md-typeset .nowrap-col1 td:nth-child(1),
.md-typeset .nowrap-col1 th:nth-child(1) { white-space: nowrap; }

.md-typeset .nowrap-col2 td:nth-child(2),
.md-typeset .nowrap-col2 th:nth-child(2) { white-space: nowrap; }

.md-typeset .nowrap-col3 td:nth-child(3),
.md-typeset .nowrap-col3 th:nth-child(3) { white-space: nowrap; }

.md-typeset .nowrap-col4 td:nth-child(4),
.md-typeset .nowrap-col4 th:nth-child(4) { white-space: nowrap; }

.md-typeset .nowrap-col5 td:nth-child(5),
.md-typeset .nowrap-col5 th:nth-child(5) { white-space: nowrap; }

.md-typeset .nowrap-col6 td:nth-child(6),
.md-typeset .nowrap-col6 th:nth-child(6) { white-space: nowrap; }

.md-typeset code,
.md-typeset pre {
  font-size: calc(var(--uofx-base-font-size) * 0.93);
}

.md-nav {
  font-size: calc(var(--uofx-base-font-size) * 0.93);
}

/* ---------------------------------
   右上角字級切換按鈕樣式
   --------------------------------- */

.uofx-font-size-switcher {
  display: flex;
  align-items: center;
  gap: 0.2rem;
  margin-left: 0.5rem;
  padding: 0.1rem;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.03);
}

.uofx-font-size-switcher__btn {
  border: none;
  background: transparent;
  padding: 0.1rem 0.4rem;
  font-size: 0.7rem;
  cursor: pointer;
  color: #555;
}

.uofx-font-size-switcher__btn.is-active {
  background: var(--primary-light);
  color: var(--primary-color);
  border-radius: 999px;
  font-weight: 600;
}

.uofx-font-size-switcher__btn:hover {
  color: var(--primary-color);
}

@media screen and (max-width: 720px) {
  .uofx-font-size-switcher {
    display: none;
  }
}
