/* ==========================================================================
   Math and AI Academy — core stylesheet
   Design: engineering-blueprint substrate, two accent hues encoding the two
   teaching tracks (Math = structural blue, AI = teal).
   ========================================================================== */

:root {
  --ink:        #14202E;
  --ink-soft:   #3D4E62;
  --ink-faint:  #7286A0;
  --paper:      #FCFCFA;
  --wash:       #EAEFF4;
  --rule:       #D3DCE5;

  --math:       #1F4E79;
  --math-tint:  #E6EEF6;
  --ai:         #0E7C74;
  --ai-tint:    #E1F0EE;

  --gold:       #A8802C;

  --sans: "Space Grotesk", "Noto Sans TC", -apple-system, BlinkMacSystemFont, sans-serif;
  --serif: "Source Serif 4", "Noto Serif TC", Georgia, serif;
  --cjk: "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", sans-serif;

  --measure: 68ch;
  --gutter: clamp(1.25rem, 5vw, 4rem);
  --stack: clamp(3.5rem, 8vw, 6.5rem);
}

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

html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 1.0625rem;
  line-height: 1.65;
  font-feature-settings: "kern";
  -webkit-font-smoothing: antialiased;
}

body[lang="zh-Hant"] { font-family: var(--cjk); line-height: 1.85; }
body[lang="zh-Hant"] h1,
body[lang="zh-Hant"] h2,
body[lang="zh-Hant"] h3,
body[lang="zh-Hant"] .brand__name { font-family: var(--cjk); letter-spacing: 0; }

h1, h2, h3, h4 {
  font-family: var(--sans);
  font-weight: 600;
  line-height: 1.15;
  letter-spacing: -0.02em;
  margin: 0 0 .6em;
  text-wrap: balance;
}

h1 { font-size: clamp(2.1rem, 5.5vw, 3.6rem); }
h2 { font-size: clamp(1.6rem, 3.4vw, 2.35rem); }
h3 { font-size: clamp(1.15rem, 2vw, 1.375rem); }

p { margin: 0 0 1.1em; max-width: var(--measure); }
a { color: var(--math); text-underline-offset: .18em; }
a:hover { color: var(--ink); }
img { max-width: 100%; height: auto; display: block; }

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

.wrap { max-width: 76rem; margin-inline: auto; padding-inline: var(--gutter); }
.narrow { max-width: 48rem; }

.skip {
  position: absolute; left: -9999px; top: 0; z-index: 200;
  background: var(--ink); color: #fff; padding: .75rem 1.25rem;
}
.skip:focus { left: .5rem; top: .5rem; }

/* ---------- Header ------------------------------------------------------ */

.masthead {
  position: sticky; top: 0; z-index: 100;
  background: rgba(252,252,250,.94);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--rule);
}
.masthead__inner {
  display: flex; align-items: center; gap: 1.5rem;
  min-height: 4.5rem;
}

.brand { display: flex; align-items: center; gap: .7rem; text-decoration: none; color: var(--ink); }
.brand__mark { flex: none; }
.brand__name {
  font-family: var(--sans); font-weight: 600; font-size: 1.0625rem;
  letter-spacing: -0.02em; line-height: 1.2;
}
.brand__name span { display: block; font-size: .75rem; font-weight: 400; color: var(--ink-faint); letter-spacing: 0; }

.nav { margin-left: auto; display: flex; align-items: center; gap: 1.6rem; }
.nav a {
  font-family: var(--sans); font-size: .9375rem; font-weight: 500;
  color: var(--ink-soft); text-decoration: none;
}
.nav a:hover, .nav a[aria-current="page"] { color: var(--ink); }
.nav a[aria-current="page"] { box-shadow: inset 0 -2px 0 var(--math); }

.lang {
  font-family: var(--sans); font-size: .875rem; color: var(--ink-faint);
  text-decoration: none; border: 1px solid var(--rule); border-radius: 999px;
  padding: .25rem .75rem;
}
.lang:hover { border-color: var(--ink-soft); color: var(--ink); }

.wa-btn {
  display: inline-flex; align-items: center; gap: .5rem;
  background: #1FA855; color: #fff; text-decoration: none;
  font-family: var(--sans); font-weight: 600; font-size: .9375rem;
  padding: .6rem 1.1rem; border-radius: 999px;
}
.wa-btn:hover { background: #17853F; color: #fff; }

.nav-toggle {
  display: none; margin-left: auto;
  background: none; border: 1px solid var(--rule); border-radius: 6px;
  padding: .45rem .6rem; cursor: pointer; color: var(--ink);
}

@media (max-width: 880px) {
  .nav-toggle { display: block; }
  .nav {
    display: none; position: absolute; left: 0; right: 0; top: 100%;
    flex-direction: column; align-items: stretch; gap: 0;
    background: var(--paper); border-bottom: 1px solid var(--rule);
    padding: .5rem var(--gutter) 1.25rem;
  }
  .nav[data-open="true"] { display: flex; }
  .nav a { padding: .7rem 0; border-bottom: 1px solid var(--rule); }
  .nav .lang, .nav .wa-btn { align-self: flex-start; margin-top: .9rem; border-bottom: 0; }
}

/* ---------- Hero — the one signature moment ----------------------------- */

.hero {
  position: relative;
  background: var(--ink);
  color: #fff;
  overflow: hidden;
  padding-block: clamp(3.5rem, 9vw, 6.5rem);
}
.hero::before {
  content: ""; position: absolute; inset: 0;
  background-image:
    linear-gradient(rgba(255,255,255,.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.045) 1px, transparent 1px);
  background-size: 34px 34px;
  mask-image: radial-gradient(ellipse 100% 80% at 60% 40%, #000 20%, transparent 80%);
}
/* Mathematical figures behind the headline. Decorative only. */
.hero::after {
  content: ""; position: absolute; inset: 0;
  background: url("../img/hero-math.svg") center right / cover no-repeat;
  opacity: .55;
  mask-image: linear-gradient(100deg, transparent 4%, #000 46%, #000 100%);
  -webkit-mask-image: linear-gradient(100deg, transparent 4%, #000 46%, #000 100%);
  pointer-events: none;
}
.hero--feature { padding-block: clamp(4.5rem, 12vw, 8.5rem); }
.hero--feature h1 { max-width: 15ch; font-size: clamp(2.3rem, 6vw, 4.1rem); }
.hero--feature .hero__lede { max-width: 44ch; }
.hero__body { max-width: 46rem; }
@media (max-width: 700px) {
  .hero::after { opacity: .3; mask-image: none; -webkit-mask-image: none;
    background-position: center; }
}
.hero > * { position: relative; }
.hero h1 { color: #fff; max-width: 18ch; }
.hero__lede { font-size: clamp(1.0625rem, 2vw, 1.25rem); color: #C3D0DE; max-width: 46ch; }

.hero__grid { display: grid; gap: clamp(2rem, 5vw, 3.5rem); grid-template-columns: 1fr; }
@media (min-width: 900px) { .hero__grid { grid-template-columns: 1.25fr .75fr; align-items: center; } }

.hero__portrait {
  border-radius: 4px;
  border: 1px solid rgba(255,255,255,.22);
  filter: saturate(.94);
}
.hero__caption { font-family: var(--sans); font-size: .875rem; color: var(--ink-faint); margin-top: .85rem; }

.cta-row { display: flex; flex-wrap: wrap; gap: .85rem; margin-top: 2rem; }

.btn {
  display: inline-flex; align-items: center; gap: .5rem;
  font-family: var(--sans); font-weight: 600; font-size: 1rem;
  padding: .85rem 1.5rem; border-radius: 3px; text-decoration: none;
  border: 1px solid transparent; cursor: pointer;
}
.btn--primary { background: #fff; color: var(--ink); }
.btn--primary:hover { background: var(--wash); color: var(--ink); }
.btn--ghost { border-color: rgba(255,255,255,.4); color: #fff; }
.btn--ghost:hover { border-color: #fff; color: #fff; background: rgba(255,255,255,.08); }
.btn--ink { background: var(--ink); color: #fff; }
.btn--ink:hover { background: var(--math); color: #fff; }
.btn--outline { border-color: var(--rule); color: var(--ink); }
.btn--outline:hover { border-color: var(--ink); color: var(--ink); }
.btn__sub { display: block; font-weight: 400; font-size: .8125rem; opacity: .72; }

/* ---------- Credential strip ------------------------------------------- */

.creds {
  background: var(--wash);
  border-bottom: 1px solid var(--rule);
  padding-block: 1.5rem;
}
.creds ul {
  list-style: none; margin: 0; padding: 0;
  display: flex; flex-wrap: wrap; gap: 1rem 2.5rem;
  font-family: var(--sans); font-size: .9375rem; color: var(--ink-soft);
}
.creds li { display: flex; align-items: baseline; gap: .5rem; }
.creds b { font-weight: 600; color: var(--ink); font-size: 1.0625rem; }

/* ---------- Sections ---------------------------------------------------- */

.section { padding-block: var(--stack); }
.section--wash { background: var(--wash); }
.section--ink { background: var(--ink); color: #fff; }
.section--ink h2, .section--ink h3 { color: #fff; }
.section--ink p { color: #C3D0DE; }

.section__head { max-width: 44rem; margin-bottom: clamp(2rem, 4vw, 3rem); }
.section__head p { color: var(--ink-soft); font-size: 1.125rem; }
.section--ink .section__head p { color: #C3D0DE; }

/* ---------- Two tracks -------------------------------------------------- */

.tracks { display: grid; gap: 1.5rem; grid-template-columns: 1fr; }
@media (min-width: 820px) { .tracks { grid-template-columns: 1fr 1fr; } }

.track {
  background: var(--paper);
  border: 1px solid var(--rule);
  border-top: 4px solid var(--track-hue, var(--math));
  padding: clamp(1.75rem, 3vw, 2.5rem);
  display: flex; flex-direction: column;
}
.track--math { --track-hue: var(--math); }
.track--ai   { --track-hue: var(--ai); }

.track__eyebrow {
  font-family: var(--sans); font-size: .875rem; font-weight: 600;
  color: var(--track-hue); margin-bottom: .75rem;
}
.track ul { padding-left: 1.1rem; margin: 0 0 1.5rem; color: var(--ink-soft); }
.track li { margin-bottom: .45rem; }
.track .btn { margin-top: auto; align-self: flex-start; }

/* ---------- Pillars / prose columns ------------------------------------- */

.cols { display: grid; gap: clamp(1.75rem, 4vw, 3rem); grid-template-columns: 1fr; }
@media (min-width: 780px) { .cols--3 { grid-template-columns: repeat(3, 1fr); } .cols--2 { grid-template-columns: 1fr 1fr; } }

.pillar { border-top: 2px solid var(--ink); padding-top: 1.1rem; }
.pillar h3 { margin-bottom: .5rem; }
.pillar p { color: var(--ink-soft); margin-bottom: 0; }
.section--ink .pillar { border-top-color: rgba(255,255,255,.3); }

/* ---------- Projects list ----------------------------------------------- */

.projects { list-style: none; margin: 0; padding: 0; display: grid; gap: 1px; background: var(--rule); border: 1px solid var(--rule); }
.projects li { background: var(--paper); padding: 1.4rem clamp(1.25rem, 3vw, 2rem); }
.projects h3 { font-size: 1.0625rem; margin-bottom: .35rem; }
.projects p { color: var(--ink-soft); margin: 0; font-size: .9688rem; }
@media (min-width: 780px) { .projects { grid-template-columns: 1fr 1fr; } }

/* ---------- Results ----------------------------------------------------- */

.outcomes { display: grid; gap: 1.25rem; grid-template-columns: 1fr; margin-bottom: 2.5rem; }
@media (min-width: 720px) { .outcomes { grid-template-columns: repeat(3, 1fr); } }
.outcome { border-left: 3px solid var(--gold); padding-left: 1.1rem; }
.outcome__uni { font-family: var(--sans); font-weight: 600; font-size: 1.0625rem; display: block; }
.outcome__course { color: var(--ink-soft); font-size: .9375rem; }

.schools { display: flex; flex-wrap: wrap; gap: .5rem; padding: 0; margin: 0; list-style: none; }
.schools li {
  font-family: var(--sans); font-size: .875rem; color: var(--ink-soft);
  border: 1px solid var(--rule); border-radius: 999px; padding: .35rem .9rem;
  background: var(--paper);
}

/* ---------- Testimonials (JS-rendered) ---------------------------------- */

.testimonials { display: grid; gap: 1.25rem; grid-template-columns: 1fr; }
@media (min-width: 760px) { .testimonials { grid-template-columns: 1fr 1fr; } }

.tcard {
  background: var(--paper); border: 1px solid var(--rule);
  padding: clamp(1.25rem, 3vw, 1.75rem);
}
.tcard blockquote { margin: 0 0 1.1rem; font-size: 1.0625rem; }
.tcard blockquote::before { content: "\201C"; }
.tcard blockquote::after { content: "\201D"; }
.tcard__who { display: flex; align-items: center; gap: .8rem; }
.tcard__avatar {
  width: 2.75rem; height: 2.75rem; border-radius: 50%; flex: none;
  background: var(--math-tint); color: var(--math);
  display: grid; place-items: center;
  font-family: var(--sans); font-weight: 600; font-size: .9375rem;
  object-fit: cover;
}
.tcard__name { font-family: var(--sans); font-weight: 600; font-size: .9375rem; }
.tcard__meta { color: var(--ink-faint); font-size: .875rem; }
.tcard__result { color: var(--gold); font-family: var(--sans); font-weight: 600; font-size: .875rem; }

.shots { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
.shots figure { margin: 0; }
.shots img { border: 1px solid var(--rule); border-radius: 3px; width: 100%; }
.shots figcaption { font-family: var(--sans); font-size: .8125rem; color: var(--ink-faint); margin-top: .5rem; }

/* ---------- Video (JS-rendered) ----------------------------------------- */

.video-frame { aspect-ratio: 16 / 9; width: 100%; border: 0; border-radius: 3px; background: var(--ink); }
.video-soon {
  aspect-ratio: 16 / 9; display: grid; place-content: center; text-align: center;
  border: 1px dashed var(--rule); border-radius: 3px; background: var(--wash);
  color: var(--ink-faint); font-family: var(--sans); gap: .35rem; padding: 1rem;
}
.video-soon b { color: var(--ink-soft); font-weight: 600; }

/* ---------- FAQ ---------------------------------------------------------- */

.faq { border-top: 1px solid var(--rule); max-width: 52rem; }
.faq details { border-bottom: 1px solid var(--rule); }
.faq summary {
  cursor: pointer; padding: 1.15rem 0; list-style: none;
  font-family: var(--sans); font-weight: 600; font-size: 1.0625rem;
  display: flex; justify-content: space-between; gap: 1rem; align-items: center;
}
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: "+"; color: var(--ink-faint); font-weight: 400; font-size: 1.4rem; }
.faq details[open] summary::after { content: "\2013"; }
.faq details p { padding-bottom: 1.15rem; color: var(--ink-soft); margin: 0; }

/* ---------- Contact ------------------------------------------------------ */

.contact-grid { display: grid; gap: clamp(2rem, 5vw, 3.5rem); grid-template-columns: 1fr; }
@media (min-width: 860px) { .contact-grid { grid-template-columns: 1.1fr .9fr; } }
.contact-list { list-style: none; padding: 0; margin: 0; }
.contact-list > div { padding: 1rem 0; border-bottom: 1px solid var(--rule); }
.contact-list dt { font-family: var(--sans); font-size: .875rem; color: var(--ink-faint); }
.contact-list dd { margin: .2rem 0 0; font-size: 1.0625rem; }

/* ---------- CTA band ----------------------------------------------------- */

.band { background: var(--ink); color: #fff; padding-block: clamp(3rem, 7vw, 4.5rem); }
.band h2 { color: #fff; max-width: 20ch; }
.band p { color: #C3D0DE; }

/* ---------- Footer ------------------------------------------------------- */

.foot { border-top: 1px solid var(--rule); padding-block: 2.5rem; font-size: .9375rem; }
.foot__grid { display: grid; gap: 1.75rem; grid-template-columns: 1fr; }
@media (min-width: 760px) { .foot__grid { grid-template-columns: 2fr 1fr 1fr; } }
.foot h4 { font-size: .875rem; color: var(--ink-faint); font-weight: 600; margin-bottom: .7rem; }
.foot ul { list-style: none; margin: 0; padding: 0; }
.foot li { margin-bottom: .45rem; }
.foot a { color: var(--ink-soft); text-decoration: none; }
.foot a:hover { color: var(--ink); text-decoration: underline; }
.foot__legal { margin-top: 2rem; color: var(--ink-faint); font-size: .875rem; }

/* ---------- Sticky mobile WhatsApp -------------------------------------- */

.wa-float {
  position: fixed; right: 1rem; bottom: 1rem; z-index: 90;
  display: none; box-shadow: 0 6px 20px rgba(20,32,46,.28);
}
@media (max-width: 880px) { .wa-float { display: inline-flex; } }

.prose h2 { margin-top: 2.5rem; }
.prose ul { color: var(--ink-soft); max-width: var(--measure); }
.prose li { margin-bottom: .5rem; }


/* ---------- About-page portrait ------------------------------------------ */

.portrait-col { display: flex; justify-content: flex-start; }

@media (max-width: 779px) {
  .portrait-col { justify-content: center; }
  

/* ---------- About-page portrait -------------------------------------------
   Floated inline with the biography text (magazine-style wrap). Size and
   aspect ratio are set inline on the <img> itself so a stale cached
   stylesheet can never distort or resize it — this rule only clears the
   float back to a stacked, centred layout on narrow screens. */
@media (max-width: 640px) {
  .prose .portrait {
    float: none !important;
    display: block !important;
    width: 200px !important;
    max-width: 200px !important;
    margin: 0 auto 1.5rem !important;
  }
}
.prose::after { content: ""; display: table; clear: both; }
