/* ============================================================
   台北大加蚋扶輪社官網 — 版面樣式
   僅使用 tokens.css 的 CSS 變數，不得寫死色碼。
   斷點：768px、1080px
   ============================================================ */

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

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--font-body);
  font-size: var(--fs-base);
  line-height: var(--lh-base);
  color: var(--c-text);
  background: var(--c-bg);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 {
  font-family: var(--font-display);
  color: var(--c-heading);
  line-height: var(--lh-tight);
  letter-spacing: var(--ls-heading-cjk);
  margin: 0;
}

p { margin: 0 0 var(--sp-4); }
p:last-child { margin-bottom: 0; }

a { color: var(--c-link); }
a:hover { color: var(--c-link-hover); }

img { max-width: 100%; height: auto; display: block; }

:focus-visible {
  outline: 3px solid var(--c-focus);
  outline-offset: 2px;
  border-radius: var(--radius);
}

.container {
  width: 100%;
  max-width: var(--container);
  margin-inline: auto;
  padding-inline: var(--sp-4);
}

.skip {
  position: absolute;
  left: var(--sp-4);
  top: calc(var(--sp-4) * -4);
  z-index: 100;
  background: var(--c-accent);
  color: var(--c-text-on-gold);
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--radius);
  font-weight: var(--fw-bold);
  text-decoration: none;
  transition: top .15s ease;
}
.skip:focus { top: var(--sp-4); color: var(--c-text-on-gold); }

.visually-hidden {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip-path: inset(50%); white-space: nowrap;
}

/* ---------- 頁首 ---------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--c-header-bg);
  border-bottom: 1px solid var(--c-border);
}

.header-inner {
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  min-height: 68px;
  flex-wrap: wrap;
  padding-block: var(--sp-3);
}

.brand { display: block; flex: 0 0 auto; line-height: 0; order: 1; }
.brand img { width: 168px; height: auto; }
.brand .sig-wide { display: none; }
.brand .sig-compact { display: block; }

/* ---------- 主導覽 ----------
   行動優先：768px 以下是漢堡按鈕 + 滿版選單，768px 以上還原為橫向導覽列。
   滿版選單自頁首下緣展開（--header-h 由 nav.js 量測寫入），
   頁首維持白底，社徽才不會落在深藍底上失效。 */

.nav-toggle {
  order: 2;
  margin-left: auto;
  width: 44px;
  height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  background: none;
  border: 0;
  cursor: pointer;
  position: relative;
  z-index: 2;
}
.nav-toggle-bars,
.nav-toggle-bars::before,
.nav-toggle-bars::after {
  display: block;
  width: 24px;
  height: 2px;
  border-radius: 2px;
  background: var(--c-heading);
  transition: transform .3s ease-in-out, background-color .3s ease-in-out;
}
.nav-toggle-bars { position: relative; }
.nav-toggle-bars::before,
.nav-toggle-bars::after { content: ""; position: absolute; left: 0; }
.nav-toggle-bars::before { top: -7px; }
.nav-toggle-bars::after  { top: 7px; }

/* 展開後三條線變 X：中線消失，上下線交叉 */
.nav-open .nav-toggle-bars { background: transparent; }
.nav-open .nav-toggle-bars::before { transform: translateY(7px) rotate(45deg); }
.nav-open .nav-toggle-bars::after  { transform: translateY(-7px) rotate(-45deg); }

.main-nav {
  position: fixed;
  top: var(--header-h, 68px);
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1;
  background: var(--c-footer-bg);
  padding: var(--sp-5) var(--sp-4) var(--sp-8);
  overflow-y: auto;
  overscroll-behavior: contain;
  opacity: 0;
  visibility: hidden;
  transform: translateX(100%);
  transition: opacity .3s ease-in-out, transform .3s ease-in-out, visibility .3s ease-in-out;
}
.nav-open .main-nav {
  opacity: 1;
  visibility: visible;
  transform: translateX(0);
}

.main-nav ul {
  display: flex;
  flex-direction: column;
  list-style: none;
  margin: 0;
  padding: 0;
  gap: 0;
}
.main-nav li { position: relative; }
.main-nav a {
  display: flex;
  align-items: center;
  min-height: 44px;
  padding: var(--sp-3) 0;
  color: var(--c-on-dark);
  text-decoration: none;
  font-size: var(--fs-lg);
  font-weight: var(--fw-medium);
  border-bottom: 1px solid rgb(255 255 255 / .18);
}
.main-nav a:hover { color: var(--c-on-dark); }
.main-nav a[aria-current="page"] { color: var(--c-on-dark); border-bottom-color: var(--c-accent); }

/* 次級選單：父層連結與展開鈕分開，才能既點進頁面又能展開 */
.has-submenu > a { padding-right: 52px; }
.submenu-btn {
  position: absolute;
  top: 0;
  right: 0;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  background: none;
  border: 0;
  cursor: pointer;
}
.submenu-btn::after {
  content: "";
  width: 0;
  height: 0;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-top: 6px solid var(--c-on-dark);
  transition: transform .3s ease-in-out;
}
.submenu-btn[aria-expanded="true"]::after { transform: rotate(180deg); }

.submenu {
  max-height: 0;
  overflow: hidden;
  transition: max-height .3s ease-in-out;
}
.submenu-btn[aria-expanded="true"] ~ .submenu { max-height: 30em; }
.submenu a {
  padding-left: var(--sp-5);
  font-size: var(--fs-base);
  font-weight: var(--fw-regular);
}

/* 選單展開時鎖住背景捲動 */
.nav-open { overflow: hidden; }

/* 三個語言標籤之間不放分隔符號，改以間距區隔；桌機與手機共用同一組樣式 */
.lang-switch {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  font-size: var(--fs-xs);
  order: 3;
  flex-basis: 100%;
}
.lang-switch a {
  color: var(--c-text-muted);
  text-decoration: none;
  padding: var(--sp-1) var(--sp-2);
  border-radius: var(--radius);
}
.lang-switch a:hover { color: var(--c-link); }
.lang-switch [aria-current="true"] {
  color: var(--c-on-dark);
  background: var(--c-heading);
  font-weight: var(--fw-bold);
}

/* ---------- Hero ---------- */

.hero {
  background: var(--c-bg-alt);
  border-bottom: 1px solid var(--c-border);
  padding-top: var(--sp-3);
  padding-bottom: var(--sp-7);
}

.hero-grid { display: grid; gap: var(--sp-2); align-items: center; }

.eyebrow {
  font-size: var(--fs-xs);
  font-weight: var(--fw-bold);
  letter-spacing: .12em;
  color: var(--c-text-muted);
  text-transform: none;
  margin-bottom: var(--sp-1);
}
.eyebrow::after {
  content: "";
  display: block;
  width: 44px;
  height: 3px;
  background: var(--c-accent);
  margin-top: var(--sp-1);
}

.hero h1 {
  font-size: var(--fs-xl);
  margin-bottom: 0;
}
.hero h1 .latin {
  display: block;
  font-size: var(--fs-sm);
  font-weight: var(--fw-regular);
  letter-spacing: var(--ls-heading-lat);
  color: var(--c-text-muted);
  margin-top: 0;
}

.hero .tagline {
  font-size: var(--fs-lg);
  font-weight: var(--fw-light);
  color: var(--c-text);
  max-width: var(--measure);
  margin-block: var(--sp-1);
}

.hero-art { margin: 0; }
.hero-art img {
  width: 100%;
  aspect-ratio: 3 / 1;
  object-fit: cover;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
}
.hero-art figcaption {
  font-size: var(--fs-xs);
  color: var(--c-text-muted);
  margin-top: var(--sp-1);
  padding-left: var(--sp-3);
  border-left: 3px solid var(--c-rule-accent);
}

/* 例會資訊卡 */
.meeting-card {
  margin-top: var(--sp-6);
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-left: 4px solid var(--c-accent);
  border-radius: var(--radius);
  padding: var(--sp-5);
  box-shadow: var(--shadow-sm);
}
.meeting-card h2 {
  font-size: var(--fs-sm);
  letter-spacing: .1em;
  margin-bottom: var(--sp-4);
  padding-bottom: var(--sp-3);
  border-bottom: 1px solid var(--c-border);
}
.meeting-card dl { margin: 0; display: grid; gap: var(--sp-4); }
.meeting-card dt {
  font-size: var(--fs-xs);
  color: var(--c-text-muted);
  margin-bottom: var(--sp-1);
}
.meeting-card dd { margin: 0; font-size: var(--fs-sm); }
/* 交通說明。例會資訊卡內、聯絡我們頁的地點區塊都會用到，故不限定在卡片下 */
.transit { color: var(--c-text-muted); font-size: var(--fs-xs); }

.run-sheet { list-style: none; margin: var(--sp-2) 0 0; padding: 0; display: grid; gap: var(--sp-2); }
.run-sheet li { display: flex; gap: var(--sp-3); font-size: var(--fs-sm); }
.run-sheet time {
  font-family: var(--font-num);
  font-weight: var(--fw-bold);
  color: var(--c-heading);
  flex: 0 0 3.6em;
}

/* ---------- 區塊通用 ---------- */

.section { padding-block: var(--sp-8); }
.section-alt { background: var(--c-bg-alt); }

.section-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: var(--sp-3) var(--sp-4);
  margin-bottom: var(--sp-6);
  padding-bottom: var(--sp-4);
  border-bottom: 2px solid var(--c-border);
}
.section-head h2 { font-size: var(--fs-2xl); }
.section-head .lede {
  color: var(--c-text-muted);
  font-size: var(--fs-sm);
  margin: 0;
}
.section-head .more { margin-left: auto; }

.btn {
  display: inline-block;
  padding: var(--sp-3) var(--sp-5);
  border-radius: var(--radius);
  font-size: var(--fs-sm);
  font-weight: var(--fw-bold);
  text-decoration: none;
  border: 2px solid transparent;
}
.btn-primary { background: var(--c-accent); color: var(--c-text-on-gold); }
.btn-primary:hover { color: var(--c-text-on-gold); filter: brightness(.94); }
.btn-ghost { border-color: var(--c-heading); color: var(--c-heading); }
.btn-ghost:hover { background: var(--c-heading); color: var(--c-on-dark); }

/* ---------- 例會卡片 ---------- */

.card-grid { display: grid; gap: var(--sp-5); }

.event-card {
  display: flex;
  flex-direction: column;
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  overflow: hidden;
}
.event-card:hover { box-shadow: var(--shadow-md); }

.event-card .banner {
  aspect-ratio: var(--banner-ratio);
  background: var(--c-bg-alt);
}
.event-card .banner img { width: 100%; height: 100%; object-fit: cover; }

.event-body {
  padding: var(--sp-4);
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
  flex: 1;
}

.event-meta { display: flex; align-items: center; gap: var(--sp-3); flex-wrap: wrap; }
.event-date {
  font-family: var(--font-num);
  font-size: var(--fs-sm);
  font-weight: var(--fw-bold);
  color: var(--c-heading);
}

.tag {
  font-size: var(--fs-xs);
  font-weight: var(--fw-bold);
  padding: 2px var(--sp-2);
  border-radius: var(--radius);
  white-space: nowrap;
}
.tag-regular    { background: var(--c-tag-regular);    color: var(--c-tag-regular-text); }
.tag-service    { background: var(--c-tag-service);    color: var(--c-tag-service-text); }
.tag-fellowship { background: var(--c-tag-fellowship); color: var(--c-tag-fellowship-text); }
.tag-joint      { background: var(--c-tag-joint);      color: var(--c-tag-joint-text); }

.event-card h3 { font-size: var(--fs-lg); }
.event-speaker { font-size: var(--fs-sm); color: var(--c-text-muted); margin: 0; }
.event-speaker b { color: var(--c-text); font-weight: var(--fw-medium); }
.event-summary { font-size: var(--fs-sm); margin: 0; }
.event-links { margin-top: auto; padding-top: var(--sp-2); }
.event-links a { font-size: var(--fs-sm); }

/* ---------- 服務計畫摘要 ---------- */

.service-grid { display: grid; gap: var(--sp-6); }

.mission-body { max-width: var(--measure); }
.mission-body h2 { font-size: var(--fs-2xl); margin-bottom: var(--sp-4); }

.facts { display: grid; gap: var(--sp-4); }
.fact {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-left: 3px solid var(--c-accent);
  border-radius: var(--radius);
  padding: var(--sp-4);
}
.fact .value {
  display: block;
  font-family: var(--font-num);
  font-size: var(--fs-2xl);
  font-weight: var(--fw-bold);
  color: var(--c-heading);
  line-height: 1.1;
}
.fact .label {
  display: block;
  font-size: var(--fs-sm);
  font-weight: var(--fw-bold);
  margin-block: var(--sp-2) var(--sp-1);
}
.fact .detail { font-size: var(--fs-xs); color: var(--c-text-muted); line-height: 1.6; }
.facts { align-items: stretch; }
.fact { display: flex; flex-direction: column; }
/* 說明文字緊接標籤向上對齊，不推到卡片底部 */
.fact .detail { padding-top: var(--sp-2); }

/* ---------- 服務軌跡時間軸 ---------- */

.timeline { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--sp-5); }

.timeline-item {
  position: relative;
  padding-left: var(--sp-6);
  border-left: 2px solid var(--c-border);
}
.timeline-item::before {
  content: "";
  position: absolute;
  left: -7px;
  top: 7px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--c-accent);
  border: 2px solid var(--c-bg);
}
.timeline-item h3 { font-size: var(--fs-lg); margin-bottom: var(--sp-2); }
.timeline-item p { font-size: var(--fs-sm); max-width: var(--measure); }

.timeline-year {
  display: block;
  font-family: var(--font-num);
  font-size: var(--fs-sm);
  font-weight: var(--fw-bold);
  color: var(--c-heading);
  margin-bottom: var(--sp-1);
}

/* 本年度：淺底強調，軸線與圓點改金色 */
.timeline-current {
  background: var(--c-bg-alt);
  border-left-color: var(--c-accent);
  border-radius: 0 var(--radius) var(--radius) 0;
  padding-block: var(--sp-4);
  padding-right: var(--sp-5);
}
.timeline-current::before { top: calc(var(--sp-4) + 7px); }
.timeline-current ul {
  margin: var(--sp-3) 0 0;
  padding-left: var(--sp-5);
  display: grid;
  gap: var(--sp-2);
}
.timeline-current li { font-size: var(--fs-sm); max-width: var(--measure); }

/* ---------- 社旗意象 ---------- */

.concept-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: var(--sp-3);
  counter-reset: concept;
}
.concept-item {
  display: flex;
  align-items: baseline;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-left: 3px solid var(--c-rule-accent);
  border-radius: var(--radius);
}
.concept-item::before {
  counter-increment: concept;
  content: counter(concept);
  flex: 0 0 auto;
  font-family: var(--font-num);
  font-size: var(--fs-sm);
  font-weight: var(--fw-bold);
  color: var(--c-heading);
}

.flag-figure { margin: 0; }
.flag-figure img {
  width: 100%;
  max-width: 280px;
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
}
.flag-figure figcaption {
  max-width: 280px;
  font-size: var(--fs-xs);
  color: var(--c-text-muted);
  margin-top: var(--sp-3);
  padding-left: var(--sp-3);
  border-left: 3px solid var(--c-rule-accent);
}


/* ---------- 頁尾 ---------- */

.site-footer {
  background: var(--c-footer-bg);
  color: var(--c-footer-text);
  padding-block: var(--sp-7) var(--sp-5);
}
.site-footer a { color: var(--c-on-dark); }
.site-footer h2, .site-footer h3 { color: var(--c-on-dark); }

.footer-grid { display: grid; gap: var(--sp-6); }

/* 頁尾第一欄：QR code 在左，社名資訊在右
   QR 圖檔為不透明白底，在深藍頁尾上對比足夠、可正常掃描 */
.footer-brand {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-4);
}
.footer-qr {
  flex: 0 0 auto;
  width: 104px;
  border-radius: var(--radius);
}

.footer-brand .name {
  font-family: var(--font-display);
  font-size: var(--fs-lg);
  font-weight: var(--fw-bold);
  color: var(--c-on-dark);
  letter-spacing: var(--ls-heading-cjk);
}
.footer-brand .name-latin {
  font-size: var(--fs-sm);
  letter-spacing: var(--ls-heading-lat);
  margin-top: var(--sp-1);
}
.footer-brand .meta { font-size: var(--fs-xs); margin-top: var(--sp-3); }

.site-footer h3 {
  font-size: var(--fs-sm);
  margin-bottom: var(--sp-3);
  padding-bottom: var(--sp-2);
  border-bottom: 1px solid rgb(255 255 255 / .22);
}
.site-footer ul { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--sp-2); }
.site-footer li, .site-footer p { font-size: var(--fs-sm); }

.footer-legal {
  margin-top: var(--sp-6);
  padding-top: var(--sp-4);
  border-top: 1px solid rgb(255 255 255 / .22);
  display: grid;
  gap: var(--sp-2);
}
.footer-legal p { font-size: var(--fs-xs); margin: 0; }

/* ============================================================
   英文版排版：主標題與主導覽用 ALL CAPS
   中日文不用大寫（CJK 無大小寫），改以字重與字距區別 —— 見 tokens.css
   ============================================================ */
html[lang="en"] h1 {
  text-transform: uppercase;
  letter-spacing: var(--ls-heading-lat);
}
html[lang="en"] .main-nav a {
  text-transform: uppercase;
  letter-spacing: var(--ls-heading-lat);
}

/* ============================================================
   768px 以上
   ============================================================ */
@media (min-width: 768px) {
  /* 768–1079 沿用窄版社徽：五項導覽加語言切換器在此寬度放不下寬版社徽，
     日文標籤最長（約 370px），必須把社徽的 232px 讓出來才不會換行 */
  .header-inner { flex-wrap: nowrap; min-height: 84px; }

  /* 還原為橫向導覽列，漢堡按鈕與滿版選單樣式全部解除 */
  .nav-toggle { display: none; }
  .brand, .lang-switch { order: 0; }
  .lang-switch { flex-basis: auto; margin-left: 0; }

  /* 主選單靠左貼近社徽，語言切換器推到最右，兩者形成明顯區隔 */
  .main-nav {
    position: static;
    margin-left: var(--sp-4);
    margin-right: auto;
    z-index: auto;
    background: none;
    padding: 0;
    overflow: visible;
    opacity: 1;
    visibility: visible;
    transform: none;
  }
  .main-nav ul { flex-direction: row; flex-wrap: nowrap; gap: var(--sp-2); }
  .main-nav a { white-space: nowrap; }
  .main-nav a {
    display: block;
    min-height: 0;
    padding: var(--sp-2) 0;
    color: var(--c-heading);
    font-size: var(--fs-sm);
    border-bottom: 2px solid transparent;
  }
  .main-nav a:hover,
  .main-nav a[aria-current="page"] {
    color: var(--c-heading);
    border-bottom-color: var(--c-accent);
  }

  /* 桌機的次級選單樣式待實際有子項目時再設計 */
  .has-submenu > a { padding-right: 0; }
  .submenu-btn, .submenu { display: none; }

  .hero { padding-top: var(--sp-5); padding-bottom: var(--sp-8); }
  .hero-grid { grid-template-columns: 1.05fr .95fr; gap: var(--sp-5); }
  .hero h1 { font-size: var(--fs-2xl); }
  .hero .tagline { font-size: var(--fs-xl); }

  .meeting-card dl { grid-template-columns: repeat(2, 1fr); gap: var(--sp-5); }

  .card-grid { grid-template-columns: repeat(2, 1fr); }
  .facts { grid-template-columns: repeat(2, 1fr); }

  .concept-list { grid-template-columns: repeat(3, 1fr); }

  .footer-grid { grid-template-columns: 1.4fr 1fr 1fr; gap: var(--sp-7); }
  .footer-legal { grid-template-columns: 1fr auto; align-items: baseline; }
}

/* ============================================================
   1080px 以上
   ============================================================ */
@media (min-width: 1080px) {
  /* 版面夠寬了，換回寬版社徽並放鬆導覽間距 */
  .brand .sig-wide { display: block; }
  .brand .sig-compact { display: none; }
  .brand img { width: 232px; }
  .main-nav { margin-left: var(--sp-5); }
  .main-nav ul { gap: var(--sp-4); }

  .card-grid { grid-template-columns: repeat(3, 1fr); }
  .facts { grid-template-columns: repeat(4, 1fr); }
  .meeting-card dl { grid-template-columns: repeat(3, 1fr); }
  .service-grid { grid-template-columns: 1fr; }
  .hero-grid { gap: var(--sp-6); }
}

/* ---------- 列印 ---------- */
@media print {
  .site-header, .lang-switch, .skip, .event-links { display: none; }
  body { color: var(--black); }
  .site-footer { background: none; color: var(--black); }
  .site-footer a, .site-footer h3, .footer-brand .name { color: var(--black); }
}
