/* ==========================================================================
   Endo — 基礎層
   reset、文件層級的排版、版面容器、無障礙工具類別。
   這一層不含任何元件。
   ========================================================================== */

*,
*::before,
*::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--e-bg);
  color: var(--e-text);
  font-family: var(--e-font-mixed);
  font-size: var(--e-fs-lg);
  line-height: var(--e-lh-body);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* 標題預設不帶 margin，間距一律交給外層的 flex gap 控制，
   這樣就不會再有 margin collapse 要debug。 */
h1, h2, h3, h4, h5, h6, p, figure, blockquote, dl, dd { margin: 0; }

h1 { font-family: var(--e-font-display); font-size: var(--e-fs-h1); line-height: var(--e-lh-tight); }
h2 { font-family: var(--e-font-display); font-size: var(--e-fs-h2); line-height: var(--e-lh-title); }
h3 { font-family: var(--e-font-title);   font-size: var(--e-fs-h3); line-height: var(--e-lh-title); }
h4 { font-family: var(--e-font-title);   font-size: var(--e-fs-h4); line-height: var(--e-lh-title); }

a { color: var(--e-link); text-decoration: none; }
a:hover { color: var(--e-link-hover); text-decoration: underline; }

ul, ol { margin: 0; padding-left: 1.3em; }
li + li { margin-top: var(--e-sp-2); }

img, svg, video { display: block; max-width: 100%; }

/* 表單元素不會自動繼承字體，要明寫 */
input, select, textarea, button { font: inherit; color: inherit; }
button { cursor: pointer; }

table { border-collapse: collapse; width: 100%; }

summary::-webkit-details-marker { display: none; }
summary { cursor: pointer; list-style: none; }

/* --------------------------------------------------------------------------
   focus：滑鼠點擊不出現外框，鍵盤 Tab 一定要出現。
   :focus-visible 是唯一正確的做法，不要用 outline: none 把它關掉。
   -------------------------------------------------------------------------- */
:focus-visible {
  outline: 2px solid var(--e-focus-color);
  outline-offset: 2px;
  border-radius: var(--e-r-xs);
}

/* --------------------------------------------------------------------------
   版面
   -------------------------------------------------------------------------- */
.e-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--e-bg);
}

.e-main { flex-grow: 1; }

/* 置中的內容容器。桌機左右留白 100px，手機 20px。 */
.e-container {
  width: 100%;
  max-width: calc(var(--e-container) + var(--e-gutter) * 2);
  margin-inline: auto;
  padding-inline: var(--e-gutter);
}

/* 垂直節奏：區塊之間 */
.e-section { padding-block: var(--e-sp-12); }
.e-section--tight { padding-block: var(--e-sp-9); }

/* 直向堆疊，間距用 --gap 覆寫 */
.e-stack {
  display: flex;
  flex-direction: column;
  gap: var(--gap, var(--e-sp-7));
}

/* 橫向排列，會換行 */
.e-row {
  display: flex;
  align-items: center;
  gap: var(--gap, var(--e-sp-5));
  flex-wrap: wrap;
}

.e-spacer { flex-grow: 1; }

/* 自動換行的等寬網格。--min 控制每欄最小寬，低於它就少一欄。 */
.e-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(var(--min, 260px), 1fr));
  gap: var(--gap, var(--e-sp-8));
}

/* --------------------------------------------------------------------------
   文字工具
   -------------------------------------------------------------------------- */
.e-title      { font-family: var(--e-font-title); }
.e-display    { font-family: var(--e-font-display); }
.e-num        { font-family: var(--e-font-num); font-weight: 600; }
.e-muted      { color: var(--e-text-muted); }
.e-faint      { color: var(--e-text-faint); font-size: var(--e-fs-sm); }
.e-lead       { font-size: var(--e-fs-lg); line-height: var(--e-lh-body); color: var(--e-text-muted); }

/* 英文副標：全大寫＋字距，用在賽事名稱底下 */
.e-eyebrow {
  font-family: var(--e-font-num);
  font-weight: 500;
  font-size: var(--e-fs-base);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--e-text-faint);
}

/* 截斷 */
.e-truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.e-clamp-2 {
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2;
  line-clamp: 2; overflow: hidden;
}

/* --------------------------------------------------------------------------
   無障礙
   -------------------------------------------------------------------------- */

/* 視覺上隱藏但螢幕閱讀器讀得到。不要用 display:none，那樣會一起消失。 */
.e-sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* 跳到主內容：鍵盤使用者按第一下 Tab 就會看到 */
.e-skip-link {
  position: absolute;
  left: var(--e-sp-5);
  top: calc(var(--e-sp-5) * -6);
  z-index: 100;
  padding: var(--e-sp-4) var(--e-sp-7);
  background: var(--e-surface);
  border: 1px solid var(--e-border-strong);
  border-radius: var(--e-r-lg);
  font-family: var(--e-font-title);
  transition: top var(--e-dur) var(--e-ease);
}
.e-skip-link:focus { top: var(--e-sp-5); }

/* --------------------------------------------------------------------------
   手機
   -------------------------------------------------------------------------- */
/* 中間尺寸：左右留白先收窄，內容才不會太早被擠掉 */
@media (max-width: 1200px) {
  :root { --e-gutter: 48px; }
}

@media (max-width: 900px) {
  :root {
    --e-gutter: var(--e-gutter-mobile);
    --e-fs-h1: var(--e-fs-h1-sm);
    --e-fs-h2: var(--e-fs-h3);
  }
  .e-section { padding-block: var(--e-sp-9); }
}
