/**
 * CSS Reset - 重置瀏覽器預設樣式
 * BENS Laboratory Website
 *
 * 基於 modern-normalize 和 custom reset
 * 統一不同瀏覽器的預設樣式，提供一致的起點
 */

/* ========== Box Sizing Reset ========== */

*,
*::before,
*::after {
  box-sizing: border-box;
}

/* ========== Document & Sections ========== */

html {
  /* 防止 iOS 在橫向旋轉時調整字體大小 */
  -webkit-text-size-adjust: 100%;
  /* 設定基礎字體大小（1rem = 16px） */
  font-size: 16px;
  /* 平滑滾動 */
  scroll-behavior: smooth;
}

body {
  margin: 0;
  padding: 0;
  /* 使用系統字體堆疊 */
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Noto Sans TC', 'Microsoft JhengHei', sans-serif;
  /* 改善字體渲染 */
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  /* 文字選取顏色 */
  -webkit-tap-highlight-color: transparent;
}

/* ========== 標題 ========== */

h1, h2, h3, h4, h5, h6 {
  margin: 0;
  padding: 0;
  font-weight: inherit;
  font-size: inherit;
  line-height: inherit;
}

/* ========== 文字元素 ========== */

p, blockquote, pre {
  margin: 0;
  padding: 0;
}

/* 移除列表樣式 */
ul, ol {
  margin: 0;
  padding: 0;
  list-style: none;
}

/* 保留定義列表的間距 */
dd {
  margin: 0;
}

/* ========== 連結 ========== */

a {
  color: inherit;
  text-decoration: inherit;
  background-color: transparent;
}

a:hover {
  text-decoration: none;
}

/* ========== 強調與斜體 ========== */

b, strong {
  font-weight: bolder;
}

small {
  font-size: 80%;
}

/* 防止 sub 和 sup 影響行高 */
sub, sup {
  font-size: 75%;
  line-height: 0;
  position: relative;
  vertical-align: baseline;
}

sub {
  bottom: -0.25em;
}

sup {
  top: -0.5em;
}

/* ========== 程式碼 ========== */

code, kbd, samp, pre {
  font-family: 'Fira Code', 'Courier New', monospace;
  font-size: 1em;
}

/* ========== 圖片與媒體 ========== */

img, svg, video, canvas, audio, iframe, embed, object {
  display: block;
  max-width: 100%;
  height: auto;
}

img {
  border-style: none;
}

svg {
  overflow: hidden;
  vertical-align: middle;
}

/* ========== 表格 ========== */

table {
  border-collapse: collapse;
  border-spacing: 0;
}

caption {
  text-align: left;
}

th {
  text-align: inherit;
  font-weight: inherit;
}

/* ========== 表單元素 ========== */

button, input, optgroup, select, textarea {
  margin: 0;
  padding: 0;
  font-family: inherit;
  font-size: 100%;
  line-height: inherit;
  color: inherit;
}

/* 移除 Firefox 的內部 padding 和 border */
button::-moz-focus-inner,
[type='button']::-moz-focus-inner,
[type='reset']::-moz-focus-inner,
[type='submit']::-moz-focus-inner {
  border-style: none;
  padding: 0;
}

/* 恢復 Firefox 的 focus 樣式 */
button:-moz-focusring,
[type='button']:-moz-focusring,
[type='reset']:-moz-focusring,
[type='submit']:-moz-focusring {
  outline: 1px dotted ButtonText;
}

/* 統一按鈕樣式 */
button,
[type='button'],
[type='reset'],
[type='submit'] {
  -webkit-appearance: button;
  background-color: transparent;
  background-image: none;
  cursor: pointer;
  border: none;
}

/* 禁用狀態 */
button:disabled,
[type='button']:disabled,
[type='reset']:disabled,
[type='submit']:disabled {
  cursor: default;
  opacity: 0.5;
}

/* 輸入框 */
input, textarea {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  background-color: transparent;
  border: none;
  outline: none;
}

/* 移除 WebKit 的搜尋框裝飾 */
[type='search']::-webkit-search-decoration,
[type='search']::-webkit-search-cancel-button {
  -webkit-appearance: none;
}

/* 移除 WebKit 數字輸入框的上下箭頭 */
input::-webkit-outer-spin-button,
input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

/* Firefox 數字輸入框 */
input[type='number'] {
  -moz-appearance: textfield;
}

/* Textarea 只允許垂直調整大小 */
textarea {
  resize: vertical;
  overflow: auto;
}

/* Select */
select {
  text-transform: none;
}

/* Fieldset */
fieldset {
  margin: 0;
  padding: 0;
  border: none;
}

legend {
  padding: 0;
}

/* Progress */
progress {
  vertical-align: baseline;
}

/* ========== 互動元素 ========== */

summary {
  display: list-item;
  cursor: pointer;
}

/* ========== Hidden 屬性 ========== */

[hidden] {
  display: none !important;
}

/* ========== 輔助功能 ========== */

/* 螢幕閱讀器專用（視覺上隱藏） */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

/* Focus 可見性 */
.focus-visible:focus {
  outline: 2px solid var(--color-secondary, #2196F3);
  outline-offset: 2px;
}

/* ========== 選取樣式 ========== */

::selection {
  background-color: rgba(33, 150, 243, 0.3);
  color: inherit;
}

::-moz-selection {
  background-color: rgba(33, 150, 243, 0.3);
  color: inherit;
}

/* ========== 捲軸樣式（WebKit）========== */

::-webkit-scrollbar {
  width: 12px;
  height: 12px;
}

::-webkit-scrollbar-track {
  background: #f1f1f1;
}

::-webkit-scrollbar-thumb {
  background: #888;
  border-radius: 6px;
}

::-webkit-scrollbar-thumb:hover {
  background: #555;
}
