/* layout.css — header, footer, mobile drawer, page hero, section rhythm */

/* ---- Header ---- */
.site-header {
  background: var(--paper);
  border-bottom: 1px solid var(--gray-200);
  position: sticky; top: 0; z-index: 50;
  box-shadow: var(--shadow-xs);
}
.header-inner {
  max-width: var(--content-max); margin: 0 auto;
  padding: 0 clamp(16px, 2.5vw, 32px);
  min-height: var(--header-h);
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: var(--sp-5);
}
.brand {
  display: flex; align-items: center; gap: var(--sp-3);
  text-decoration: none; color: var(--navy);
  min-height: 44px;
}
.brand img {
  height: 52px; width: auto; max-width: 240px; object-fit: contain;
  flex: 0 0 auto;
}
.brand img.brand-lockup { height: 44px; max-width: 260px; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-zh { font-family: var(--font-serif); font-size: 1.05rem; font-weight: 600; color: var(--navy); }
.brand-en { font-size: 0.78rem; color: var(--gray-600); letter-spacing: 0.02em; }
html[lang="en"] .brand-en { color: var(--gray-500); }

.header-actions { display: flex; align-items: center; gap: clamp(8px, 1vw, 12px); white-space: nowrap; }
.header-actions .btn-donate { padding: 0 clamp(10px, 1.2vw, 16px); font-size: clamp(0.8rem, 0.9vw, 0.9rem); }
.header-actions .lang-switch { font-size: clamp(0.8rem, 0.9vw, 0.9rem); padding: 0 clamp(8px, 1vw, 12px); }
.lang-switch {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 44px; padding: 0 var(--sp-3);
  color: var(--ink); text-decoration: none;
  border: 1px solid var(--gray-300); border-radius: var(--radius-full);
  font-weight: 500; font-size: 0.9rem;
  transition: border-color var(--dur-1) var(--ease), background var(--dur-1) var(--ease);
}
.lang-switch:hover { border-color: var(--navy); background: var(--surface); }

/* ---- Nav (desktop) ---- */
.site-nav { justify-self: center; }
.site-nav ul {
  display: flex; align-items: center; gap: clamp(0px, 0.3vw, 2px);
  list-style: none; margin: 0; padding: 0;
}
.site-nav li { position: relative; }
.site-nav a, .site-nav .nav-trigger {
  display: inline-flex; align-items: center; gap: 4px;
  min-height: 44px; padding: 0 clamp(8px, 1vw, 14px);
  color: var(--ink); text-decoration: none;
  border-radius: var(--radius); font-size: clamp(0.85rem, 0.95vw, 0.95rem); font-weight: 500;
  white-space: nowrap;
  background: transparent; border: 0; cursor: pointer;
  transition: background var(--dur-1) var(--ease), color var(--dur-1) var(--ease);
}
.site-nav a:hover, .site-nav .nav-trigger:hover { background: var(--surface); color: var(--navy); }
.site-nav .nav-trigger[aria-expanded="true"] { background: var(--surface); color: var(--navy); }
.site-nav .caret { width: 10px; height: 10px; transition: transform var(--dur-2) var(--ease); }
.site-nav .nav-trigger[aria-expanded="true"] .caret { transform: rotate(180deg); }

/* Dropdown */
.dropdown {
  position: absolute; top: calc(100% + 4px); left: 0;
  min-width: 240px;
  background: var(--paper);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  padding: var(--sp-2) 0;
  display: none;
  z-index: 60;
}
.dropdown.open { display: block; }
.dropdown a {
  display: flex; align-items: center; gap: var(--sp-2);
  width: 100%; padding: var(--sp-2) var(--sp-4);
  color: var(--ink); font-size: 0.925rem;
  border-radius: 0;
}
.dropdown a:hover, .dropdown a:focus-visible { background: var(--surface); color: var(--navy); }
.dropdown a.active { background: var(--surface-2); color: var(--navy); font-weight: 600; }

/* ---- Mobile drawer ---- */
.nav-toggle {
  display: none;
  align-items: center; justify-content: center;
  width: 44px; height: 44px;
  background: transparent; border: 1px solid var(--gray-300); border-radius: var(--radius);
  cursor: pointer; color: var(--ink);
}
.nav-toggle:hover { background: var(--surface); }
.nav-toggle svg { width: 22px; height: 22px; }

.drawer-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(7, 26, 51, 0.55);
  z-index: 90;
  opacity: 0; transition: opacity var(--dur-2) var(--ease);
}
.drawer-overlay.visible { opacity: 1; }
.mobile-drawer {
  display: none;
  position: fixed; top: 0; right: 0; bottom: 0;
  width: min(360px, 88vw);
  background: var(--paper);
  box-shadow: var(--shadow-lg);
  z-index: 95;
  transform: translateX(100%);
  transition: transform var(--dur-3) var(--ease);
  overflow-y: auto;
  padding: var(--sp-5);
}
.mobile-drawer.open { transform: translateX(0); }
.mobile-drawer .drawer-head {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: var(--sp-5);
}
.drawer-close {
  width: 44px; height: 44px; display: inline-flex; align-items: center; justify-content: center;
  background: transparent; border: 1px solid var(--gray-300); border-radius: var(--radius);
  cursor: pointer; color: var(--ink);
}
.mobile-drawer .nav-tree { list-style: none; margin: 0; padding: 0; }
.mobile-drawer .nav-tree > li { border-bottom: 1px solid var(--gray-200); }
.mobile-drawer .nav-tree > li > a,
.mobile-drawer .nav-tree > li > button {
  display: flex; justify-content: space-between; align-items: center;
  width: 100%; min-height: 48px; padding: var(--sp-3) var(--sp-2);
  color: var(--ink); font-weight: 500; font-size: 1rem;
  text-decoration: none; background: transparent; border: 0; cursor: pointer;
}
.mobile-drawer .nav-tree > li > button[aria-expanded="true"] .caret { transform: rotate(180deg); }
.mobile-drawer .sublist { list-style: none; margin: 0; padding: 0 0 0 var(--sp-3); }
.mobile-drawer .sublist a {
  display: block; padding: var(--sp-2) var(--sp-2); color: var(--gray-600);
  min-height: 40px; font-size: 0.95rem;
}
.mobile-drawer .drawer-cta { margin-top: var(--sp-5); }
.mobile-drawer .drawer-cta .btn { width: 100%; justify-content: center; }

@media (max-width: 1100px) {
  .site-nav { display: none; }
  .nav-toggle { display: inline-flex; }
  .mobile-drawer { display: block; }
  .header-inner { grid-template-columns: 1fr auto; padding: 0 var(--sp-4); min-height: 64px; }
  .brand { justify-self: start; }
  .header-actions { justify-self: end; }
  .brand img { height: 44px; max-width: 200px; }
  .brand img.brand-lockup { height: 38px; }
  .brand-text { display: none; }
  .btn-donate { padding: 0 var(--sp-3); font-size: 0.85rem; }
}

/* ---- Footer ---- */
.site-footer {
  background: var(--navy-900);
  color: var(--gray-300);
  padding: var(--sp-8) 0 var(--sp-5);
  margin-top: var(--sp-9);
  font-size: 0.95rem;
}
.footer-grid {
  max-width: var(--content-max); margin: 0 auto; padding: 0 var(--sp-5);
  display: grid; grid-template-columns: 1.4fr 1fr 1fr 1fr; gap: var(--sp-6);
}
.footer-col h2, .site-footer h2 {
  font-family: var(--font-sans);
  font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.08em;
  margin: 0 0 var(--sp-4); color: var(--gray-400); font-weight: 600;
}
.footer-col ul { list-style: none; padding: 0; margin: 0; }
.footer-col li { margin: 0.4rem 0; }
.footer-col a { color: var(--gray-300); text-decoration: none; }
.footer-col a:hover { color: #fff; text-decoration: underline; }
/* Footer social icons (icon-only links) */
.footer-col ul.social { display: flex; gap: var(--sp-3); margin-top: 4px; }
.footer-col ul.social li { margin: 0; }
.footer-col ul.social a {
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; border-radius: 50%;
  background: rgba(255,255,255,0.08);
}
.footer-col ul.social a:hover { text-decoration: none; background: rgba(255,255,255,0.16); color: #fff; }
.footer-col ul.social svg { width: 18px; height: 18px; fill: currentColor; display: block; }
.footer-brand img { width: auto; height: 56px; max-width: 320px; margin-bottom: var(--sp-3); }
.footer-brand img.footer-lockup { height: 56px; width: auto; }
.footer-brand .brand-zh { color: #fff; font-size: 1.1rem; }
.footer-brand .brand-en { color: var(--gray-400); }
.footer-portal {
  display: inline-block; margin-top: var(--sp-3);
  padding: 0.5rem 1rem; background: var(--blue);
  border: 1px solid transparent; border-radius: var(--radius);
  color: #fff; text-decoration: none; font-weight: 500;
  min-height: 44px; display: inline-flex; align-items: center;
}
.footer-portal:hover { background: var(--blue-700); color: #fff; }
.footer-legal {
  max-width: var(--content-max); margin: var(--sp-6) auto 0; padding: var(--sp-5) var(--sp-5) 0;
  border-top: 1px solid rgba(255,255,255,0.12);
  display: flex; justify-content: space-between; flex-wrap: wrap; gap: var(--sp-3);
  font-size: 0.85rem; color: var(--gray-400);
}
.footer-legal a { color: var(--gray-400); }
.footer-legal a:hover { color: #fff; }
@media (max-width: 800px) {
  .footer-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 520px) {
  .footer-grid { grid-template-columns: 1fr; }
}

/* ---- Page hero ---- */
.hero {
  position: relative;
  background: linear-gradient(135deg, var(--navy) 0%, var(--navy-700) 100%);
  color: #fff;
  overflow: hidden;
}

.hero .hero-inner {
  max-width: var(--content-max); margin: 0 auto; padding: var(--sp-8) var(--sp-5);
  position: relative; z-index: 2;
}
.hero h1 { color: #fff; font-size: var(--fs-04); margin-bottom: var(--sp-4); }
.hero .hero-sub { color: rgba(255,255,255,0.85); font-size: var(--fs-08); max-width: 60ch; margin-bottom: var(--sp-5); }
.hero .hero-cta { display: flex; flex-wrap: wrap; gap: var(--sp-3); }
.hero--photo { background-size: cover; background-position: center; }
.hero--photo::before {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(100deg, rgba(11,37,69,0.92) 0%, rgba(11,37,69,0.55) 55%, rgba(11,37,69,0.35) 100%);
}
.hero--photo .hero-inner { z-index: 2; }
.hero--slim .hero-inner { padding: var(--sp-6) var(--sp-5); }
.hero--slim h1 { font-size: var(--fs-06); margin-bottom: var(--sp-2); }

/* ---- Section heading ---- */
.section { padding: var(--sp-8) 0; }
.section-alt { background: var(--surface); }
.section-head {
  max-width: var(--content-max); margin: 0 auto var(--sp-6); padding: 0 var(--sp-5);
  display: flex; align-items: end; justify-content: space-between; gap: var(--sp-4); flex-wrap: wrap;
}
.section-title {
  font-family: var(--font-serif); font-size: var(--fs-06); color: var(--navy);
  margin: 0; position: relative; padding-left: 0;
}
.section-title::before {
  content: ""; display: block; width: 40px; height: 4px;
  background: var(--red); margin-bottom: var(--sp-3); border-radius: 2px;
}
.section-kicker {
  color: var(--red); font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.12em;
  font-weight: 600; margin-bottom: var(--sp-2);
}
.section-link {
  color: var(--navy); font-weight: 600; text-decoration: none;
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 44px;
}
.section-link:hover { color: var(--red); }
.section-desc { color: var(--gray-600); margin: var(--sp-2) 0 0; max-width: 65ch; }

/* ---- Breadcrumb ---- */
.breadcrumb {
  max-width: var(--content-max); margin: 0 auto; padding: var(--sp-4) var(--sp-5) 0;
  font-size: 0.9rem; color: var(--gray-500);
}
.breadcrumb ol { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: var(--sp-2); }
.breadcrumb a { color: var(--gray-600); }
.breadcrumb a:hover { color: var(--red); }
.breadcrumb li[aria-current="page"] { color: var(--ink); font-weight: 500; }
.breadcrumb .sep { color: var(--gray-300); }

/* ---- Hero carousel (Phase 8) ---- */
.hero-carousel {
  position: relative;
  isolation: isolate;
  background: var(--navy, #0B2545);
  overflow: hidden;
  min-height: clamp(420px, 62vh, 640px);
}
.hero-carousel-slides {
  position: relative;
  height: 100%;
  min-height: inherit;
}
.hero-carousel-slide {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-rows: 1fr;
  opacity: 0;
  visibility: hidden;
  transition: opacity .55s ease, visibility .55s ease;
}
.hero-carousel-slide.is-current,
.hero-carousel-slide:first-child {
  opacity: 1;
  visibility: visible;
  z-index: 1;
}
.hero-carousel-media {
  position: absolute;
  inset: 0;
  z-index: 0;
  overflow: hidden;
}
.hero-carousel-img {
  width: 100%; height: 100%;
  object-fit: cover; object-position: center;
  display: block;
}
.hero-carousel-fallback {
  width: 100%; height: 100%;
  background: linear-gradient(135deg, #0B2545 0%, #1F2D9C 100%);
}
.hero-carousel-media::after {
  content: "";
  position: absolute; inset: 0;
  background: linear-gradient(90deg, rgba(11,37,69,0.82) 0%, rgba(11,37,69,0.55) 45%, rgba(11,37,69,0.15) 100%);
  pointer-events: none;
}
.hero-carousel-slide.is-home .hero-carousel-media::after {
  background: linear-gradient(90deg, rgba(11,37,69,0.88) 0%, rgba(11,37,69,0.55) 55%, rgba(11,37,69,0.20) 100%);
}
.hero-carousel-inner {
  position: relative; z-index: 2;
  align-self: end;
  padding: clamp(24px, 5vw, 56px) clamp(20px, 6vw, 72px);
  color: #fff;
}
.hero-carousel-h1 {
  margin: 0 0 12px;
  font-family: var(--font-display, "Noto Serif TC","Songti TC",Georgia,serif);
  font-size: clamp(1.9rem, 4.6vw, 3.4rem);
  line-height: 1.15;
  letter-spacing: 0.01em;
}
.hero-carousel-tagline {
  margin: 0 0 24px;
  font-size: clamp(1rem, 1.6vw, 1.2rem);
  color: rgba(255,255,255,0.9);
  max-width: 52ch;
}
.hero-carousel-cta { display: flex; flex-wrap: wrap; gap: 12px; }
.hero-carousel-caption {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  flex-wrap: wrap;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.2);
  backdrop-filter: blur(6px);
  padding: 14px 18px;
  border-radius: 14px;
  max-width: 640px;
}
.hero-carousel-caption-text { color: #fff; font-size: 1.05rem; }
.hero-carousel-controls {
  position: absolute; z-index: 3;
  inset-inline: 0; bottom: 18px;
  display: flex; justify-content: space-between;
  padding: 0 clamp(16px, 5vw, 64px);
  pointer-events: none;
}
.hero-carousel-btn {
  pointer-events: auto;
  background: rgba(255,255,255,0.12);
  border: 1px solid rgba(255,255,255,0.35);
  color: #fff;
  width: 44px; height: 44px;
  border-radius: 999px;
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: background .2s ease, transform .2s ease;
}
.hero-carousel-btn:hover { background: rgba(255,255,255,0.24); transform: scale(1.05); }
.hero-carousel-btn:focus-visible { outline: 3px solid #fff; outline-offset: 2px; }
.hero-carousel-dots {
  position: absolute; z-index: 3;
  left: 50%; bottom: 24px; transform: translateX(-50%);
  display: flex; gap: 8px;
}
.hero-carousel-dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: rgba(255,255,255,0.45);
  border: 1px solid rgba(255,255,255,0.6);
  cursor: pointer;
  transition: background .2s ease, transform .2s ease;
  padding: 0;
}
.hero-carousel-dot.is-active { background: #fff; transform: scale(1.25); }
.hero-carousel-dot:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
@media (max-width: 768px) {
  .hero-carousel { min-height: 380px; }
  .hero-carousel-controls { bottom: 60px; }
  .hero-carousel-dots { bottom: 18px; }
}
@media (prefers-reduced-motion: reduce) {
  .hero-carousel-slide { transition: none; }
  .hero-carousel-btn { transition: none; }
}

/* Top-level items with a page AND a submenu (like the original site):
   the label is a link; the caret button / hover opens the dropdown. */
.site-nav .has-sub { display: flex; align-items: center; }
.site-nav .has-sub > .nav-top { padding-right: 2px; }
.site-nav .has-sub > .nav-trigger { min-height: 44px; padding: 0 6px 0 2px; }
.site-nav .has-sub:hover > .dropdown,
.site-nav .has-sub:focus-within > .dropdown { display: block; }
.site-nav .has-sub:hover > .nav-trigger .caret { transform: rotate(180deg); }
.dropdown { top: 100%; padding-top: var(--sp-2); }
.mobile-drawer .nav-tree > li.has-sub { display: flex; flex-wrap: wrap; align-items: center; }
.mobile-drawer .nav-tree > li.has-sub > a { flex: 1; width: auto; }
.mobile-drawer .nav-tree > li.has-sub > button { width: 48px; justify-content: center; flex: 0 0 48px; }
.mobile-drawer .nav-tree > li.has-sub > .sublist { flex: 0 0 100%; }

/* hero captions (non-home slides): box, text and "Learn more" centered */
.hero-carousel-slide:not(.is-home) .hero-carousel-inner { display: flex; justify-content: center; align-self: end; padding-bottom: clamp(48px, 7vw, 72px); }
.hero-carousel-caption { flex-direction: column; justify-content: center; align-items: center; text-align: center; gap: 12px; margin-inline: auto; }

/* Hero: all slides share one grid cell, so the carousel is as tall as its tallest slide (the intro) */
.hero-carousel-slides { display: grid; }
.hero-carousel-slide { position: relative; inset: auto; grid-area: 1 / 1; min-height: clamp(420px, 62vh, 640px); }
.hero-carousel-slide.is-intro { background: var(--paper, #fff); color: var(--ink); align-items: center; min-height: 0; padding: clamp(24px, 4vw, 40px) clamp(16px, 5vw, 64px) clamp(56px, 6vw, 72px); }
.hero-intro { width: 100%; max-width: 1100px; margin-inline: auto; }
.hero-intro .blk-columns { grid-template-columns: 90px minmax(0, 1fr) minmax(0, 1fr) 90px; align-items: start; gap: var(--sp-5); }
.hero-intro .blk-richtext { max-width: none; }
.hero-intro .blk-richtext p { line-height: 1.7; }
.hero-intro .blk-image img { box-shadow: none; border-radius: 0; width: 100%; }
@media (max-width: 800px) { .hero-intro .blk-columns { grid-template-columns: 1fr; } .hero-intro .hide-phone { display: none !important; } }
.hero-carousel:has(.is-intro.is-current) .hero-carousel-btn { background: rgba(11,37,69,.55); border-color: transparent; }
.hero-carousel:has(.is-intro.is-current) .hero-carousel-dot { background: rgba(11,37,69,.25); border-color: rgba(11,37,69,.35); }
.hero-carousel:has(.is-intro.is-current) .hero-carousel-dot.is-active { background: var(--navy); }

/* Enroll slide: text + buttons centered over the generated background */
.hero-carousel-slide:has(.hero-enroll) .hero-carousel-media::after { background: linear-gradient(180deg, rgba(11,37,69,.35) 0%, rgba(11,37,69,.80) 100%); }
.hero-carousel-slide:has(.hero-enroll) .hero-carousel-inner { align-self: center; justify-content: center; padding-bottom: clamp(40px, 6vw, 64px); }
.hero-enroll { text-align: center; display: grid; justify-items: center; gap: 4px; }
.hero-enroll .hero-carousel-tagline { max-width: 44ch; text-wrap: balance; font-size: clamp(1.4rem, 3vw, 2.2rem); font-family: var(--font-serif); color: #fff; margin: 0 0 20px; text-shadow: 0 2px 12px rgba(0,0,0,.45); }
.hero-enroll .hero-carousel-cta { justify-content: center; }

/* intro slide: plum-blossom background, light veil so the text stays readable */
.hero-carousel-slide.is-intro .hero-carousel-media::after { background: rgba(255,252,246,.55); }
.hero-carousel-slide.is-intro .hero-carousel-media { z-index: 0; }
.hero-carousel-slide.is-intro .hero-intro { position: relative; z-index: 1; }
.hero-carousel:has(.is-intro.is-current) { background: #fffaf2; }
.footer-portal + .footer-portal { display: flex; width: max-content; margin-top: 10px; background: transparent; border: 1px solid rgba(255, 255, 255, .6); }
.footer-portal + .footer-portal:hover { background: rgba(255, 255, 255, .14); }
