/* ==========================================================================
   Yuan-Chung Cheng Research Group — site stylesheet
   Colours and fonts are set once in :root below; change them there.
   ========================================================================== */

:root {
  --size: 18px;                 /* base text size; everything scales from this */
  --lh: 1.75;
  --font: "Plus Jakarta Sans", "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", system-ui, sans-serif;

  --bg: #faf8f4;                /* page background (warm off-white) */
  --surface: #fff;              /* cards */
  --fg: #14213d;                /* text (navy) */
  --muted: #545d70;
  --line: #e7e2d8;
  --accent: #1d3a72;            /* navy */
  --accent-2: #c2780a;          /* amber */
  --accent-soft: #eef1f8;
  --hero: linear-gradient(100deg, rgba(20,33,61,.94) 0%, rgba(20,33,61,.78) 55%, rgba(194,120,10,.35));
  --pagehead: linear-gradient(120deg, #14213d, #1d3a72 60%, #8a5a12);
  --radius: 14px;
  color-scheme: light;
}

/* Dark palette: follows the visitor's system setting */
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1524;
    --surface: #172036;
    --fg: #ebe7df;
    --muted: #a9b0c0;
    --line: #28324a;
    --accent: #9db6ec;
    --accent-2: #f2a83b;
    --accent-soft: #1c2742;
    color-scheme: dark;
  }
}

/* ---------- Base ---------- */
* { box-sizing: border-box; }
html { font-size: var(--size); scroll-padding-top: 5rem; }
body { margin: 0; background: var(--bg); color: var(--fg); font-family: var(--font); line-height: var(--lh); }
h1, h2, h3 { font-weight: 800; line-height: 1.25; }
img { max-width: 100%; height: auto; display: block; }
a { color: var(--accent); }
.inner { max-width: 1120px; margin: 0 auto; padding-inline: 24px; }
main { padding-block: 2.5rem 4rem; }
h2 { font-size: 1.6rem; letter-spacing: -.01em; margin: 2.5rem 0 1rem; }
.zh { font-weight: 500; }
.muted { color: var(--muted); }

.skip { position: absolute; left: -999px; top: 0; background: var(--accent); color: #fff; padding: .5rem 1rem; z-index: 100; }
.skip:focus { left: 1rem; }

/* ---------- Top bar ---------- */
.top {
  position: sticky; top: 0; z-index: 10;
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.top .inner { display: flex; align-items: center; justify-content: space-between; gap: .5rem 1rem; flex-wrap: wrap; padding-block: .7rem; }
.brand { display: flex; gap: .7rem; align-items: center; text-decoration: none; color: var(--fg); line-height: 1.3; }
.brand strong { font-weight: 800; }
.brand small { display: block; font-size: .75rem; color: var(--muted); }
.logo {
  width: 40px; height: 40px; border-radius: 12px; flex: none;
  display: grid; place-items: center;
  font: 600 1.4rem/1 Georgia, serif; color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
}
.nav ul { display: flex; gap: .25rem; list-style: none; margin: 0; padding: 0; }
.nav a {
  display: block; padding: .45rem .8rem; border-radius: 999px; white-space: nowrap;
  color: var(--muted); text-decoration: none; font-weight: 500; font-size: .92rem;
}
.nav a:hover { background: var(--accent-soft); color: var(--fg); }
.nav a[aria-current] { background: var(--fg); color: var(--bg); }
/* On phones the menu becomes one horizontally scrollable row */
@media (max-width: 860px) {
  .nav { width: 100%; overflow-x: auto; scrollbar-width: none; margin-inline: -.8rem; }
  .nav::-webkit-scrollbar { display: none; }
}

/* ---------- Buttons ---------- */
.btn { display: inline-block; padding: .65rem 1.25rem; border-radius: 999px; font-weight: 600; text-decoration: none; font-size: .95rem; }
.btn.primary { background: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.12); }
.btn.ghost { border: 1px solid rgba(255,255,255,.5); color: #fff; }
.btn.ghost:hover { background: rgba(255,255,255,.12); }
@media (prefers-color-scheme: dark) { .btn.primary { color: #0f1524; } }

/* ---------- Home: photo banner ---------- */
.hero {
  color: #fff; padding-block: 1.8rem 1.6rem;
  background: var(--hero), url(../img/campus.jpg) center / cover;
}
.hero .inner > * { max-width: 900px; }
.eyebrow { letter-spacing: .12em; font-size: 1.7rem; font-weight: 600; opacity: .92; margin: 0; }
.hero h1 { font-size: clamp(2.1rem, 5vw, 3.4rem); line-height: 1.08; letter-spacing: -.02em; margin: .4rem 0 .8rem; }
.hero p { font-size: 1.12rem; color: #dde1ee; }
.cta { display: flex; gap: .8rem; flex-wrap: wrap; margin-top: 1rem; }

/* ---------- Page header (inner pages) ---------- */
.pagehead { background: var(--pagehead); color: #fff; padding-block: 2.6rem 2.2rem; }
.pagehead h1 { margin: 0 0 .5rem; font-size: clamp(2rem, 4vw, 2.8rem); letter-spacing: -.02em; }
.pagehead p { max-width: 780px; color: #dde1ee; margin: 0; }
.pagehead a { color: #fff; }

/* ---------- Section heading with link ---------- */
.sechead { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; }
.sechead a { text-decoration: none; font-weight: 600; font-size: .92rem; }

/* ---------- Research cards (home) ---------- */
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1.1rem; }
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden; text-decoration: none; color: var(--fg);
  transition: transform .2s, box-shadow .2s;
}
.card:hover { transform: translateY(-4px); box-shadow: 0 14px 30px -12px rgba(15,23,42,.25); }
.thumb { aspect-ratio: 16 / 10; background: #fff; overflow: hidden; }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.card h3 { font-size: 1.05rem; margin: 1rem 1.1rem .3rem; }
.card p { margin: 0 1.1rem 1.2rem; color: var(--muted); font-size: .92rem; line-height: 1.5; }

/* ---------- News timeline (home) + join box ---------- */
.split { display: grid; grid-template-columns: 1.6fr 1fr; gap: 2rem; align-items: start; }
@media (max-width: 800px) { .split { grid-template-columns: 1fr; } }
.timeline { list-style: none; margin: 0; padding: 0; border-left: 2px solid var(--line); }
.timeline li { position: relative; padding: 0 0 1.3rem 1.4rem; }
.timeline li::before {
  content: ""; position: absolute; left: -7px; top: .4rem; width: 12px; height: 12px; border-radius: 50%;
  background: var(--accent-2); box-shadow: 0 0 0 4px var(--bg);
}
.timeline time, .newslist time { font-size: .8rem; font-weight: 700; color: var(--accent-2); text-transform: uppercase; letter-spacing: .06em; }
.timeline p { margin: .15rem 0 0; }
.join {
  background: linear-gradient(150deg, var(--accent-soft), var(--surface));
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: .5rem 1.6rem 1.6rem; margin-top: 2.5rem;
}
.join h2 { margin-top: 1rem; font-size: 1.3rem; }

/* ---------- News archive ---------- */
.yearblock { display: grid; grid-template-columns: 110px 1fr; gap: 1rem; border-top: 1px solid var(--line); padding-top: 1rem; margin-top: 1rem; }
.yearblock > h2 { margin: 0; font-size: 1.5rem; color: var(--muted); }
@media (max-width: 640px) { .yearblock { grid-template-columns: 1fr; gap: .3rem; } }
.newslist { list-style: none; margin: 0; padding: 0; }
.newslist li { padding: .2rem 0 1rem 1.4rem; border-left: 2px solid var(--line); position: relative; }
.newslist li::before {
  content: ""; position: absolute; left: -6px; top: .45rem; width: 10px; height: 10px; border-radius: 50%;
  background: var(--accent-2);
}
.newslist time { display: block; }

/* ---------- Research page ---------- */
.feature { display: grid; grid-template-columns: 320px 1fr; gap: 2.5rem; align-items: start; padding: 2.5rem 0; border-bottom: 1px solid var(--line); }
.feature.flip { grid-template-columns: 1fr 320px; }
.feature.flip .fimg { order: 2; }
.fimg { background: #fff; border-radius: var(--radius); padding: 1rem; border: 1px solid var(--line); display: grid; place-items: center; }
.feature h2 { margin: .2rem 0 1rem; }
.num { font-weight: 800; color: var(--accent-2); margin: 0; letter-spacing: .1em; }
@media (max-width: 760px) {
  .feature, .feature.flip { grid-template-columns: 1fr; }
  .feature.flip .fimg { order: 0; }
}
.software { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: .4rem 1.6rem 1.2rem; margin-top: 2.5rem; }

/* ---------- Members ---------- */
.pi { display: grid; grid-template-columns: 220px 1fr; gap: 2rem; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.6rem; }
.pi img { border-radius: 12px; width: 220px; }
.pi h3 { font-size: 1.5rem; margin: 0; }
.pi .zh { color: var(--muted); }
.role { color: var(--accent); font-weight: 600; margin: .2rem 0 .8rem; }
@media (max-width: 640px) { .pi { grid-template-columns: 1fr; } }
.contact { display: grid; grid-template-columns: auto 1fr; gap: .25rem 1rem; font-size: .95rem; }
.contact dt { color: var(--muted); }
.contact dd { margin: 0; }
.profile { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 1.2rem; margin-top: 1.2rem; }
.profile section { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: .2rem 1.4rem 1rem; }
.profile section.wide { grid-column: 1 / -1; }
.profile h3 { font-size: 1.05rem; color: var(--accent); margin: 1rem 0 .5rem; }
.profile ul { list-style: none; margin: 0; padding: 0; }
.profile li { padding: .35rem 0; border-bottom: 1px solid var(--line); font-size: .95rem; line-height: 1.55; }
.profile li:last-child { border-bottom: 0; }
.profile p { font-size: .95rem; margin-top: 0; }
.when { color: var(--accent-2); font-weight: 700; font-size: .85rem; white-space: nowrap; margin-left: .4rem; }
.service .when { display: inline-block; min-width: 6.5rem; margin: 0 .6rem 0 0; }
.placeholder { background: var(--surface); border: 1px dashed var(--line); border-radius: var(--radius); padding: 1.2rem; color: var(--muted); }
.people, .alumni { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: .8rem; list-style: none; padding: 0; }
.people li, .alumni li { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: .8rem 1rem; }
.name { display: block; font-weight: 700; }
.name .en { color: var(--muted); font-weight: 500; font-size: .9rem; }
.deg, .note { display: block; font-size: .85rem; color: var(--muted); }
.groupphoto { margin: 2.5rem 0 0; }
.groupphoto img { border-radius: var(--radius); width: 100%; }
.groupphoto figcaption { color: var(--muted); font-size: .9rem; margin-top: .5rem; }

/* ---------- Publications ---------- */
.toolbar { display: flex; gap: 1rem; align-items: center; flex-wrap: wrap; position: sticky; top: 4.1rem; background: var(--bg); padding: .6rem 0; z-index: 5; }
@media (max-width: 1000px) { .toolbar { position: static; } }
#pubsearch {
  flex: 1; min-width: 220px; max-width: 480px; font: inherit; padding: .65rem 1rem;
  border-radius: 999px; border: 1px solid var(--line); background: var(--surface); color: var(--fg);
}
.toolbar > span { color: var(--muted); font-size: .9rem; }
.yeargroup { display: grid; grid-template-columns: 90px 1fr; gap: 1rem; }
.year { margin: 1rem 0 0; font-size: 1.5rem; color: var(--muted); font-weight: 800; }
@media (max-width: 640px) { .yeargroup { grid-template-columns: 1fr; gap: 0; } }
.pubs { list-style: none; margin: 0; padding: 0; }
.pubs li { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 1rem 1.2rem; margin: .8rem 0; }
.pubs p { margin: 0; }
.ptitle { font-weight: 700; line-height: 1.4; }
.authors { color: var(--muted); font-size: .9rem; margin-top: .25rem !important; }
.meta { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin-top: .5rem !important; font-size: .88rem; }
.venue { font-style: italic; margin-right: auto; }
.chip { font-size: .78rem; font-weight: 700; padding: .2rem .75rem; border-radius: 999px; background: var(--accent-soft); text-decoration: none; }
.chip:hover { background: var(--accent); color: #fff; }

/* ---------- Teaching ---------- */
.term { margin: 0 0 1.2rem; }
.term h3 { font-size: 1rem; margin: 0 0 .4rem; color: var(--accent-2); }
.courses { list-style: none; margin: 0; padding: 0; }
.courses li { padding: .45rem 0; border-bottom: 1px solid var(--line); }
.courses li:last-child { border-bottom: 0; }
.courses a.chip { margin-left: .4rem; }

/* ---------- Prose pages (course pages) ---------- */
.prose { max-width: 820px; }
.prose h2 { font-size: 1.35rem; }
.prose li { margin: .3rem 0; }
.prose .chip { margin-left: .3rem; }

/* ---------- Contact ---------- */
.contactgrid { display: grid; grid-template-columns: 1fr 1.2fr; gap: 2rem; align-items: start; }
@media (max-width: 800px) { .contactgrid { grid-template-columns: 1fr; } }
.contactcard { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.2rem 1.6rem 1.6rem; }
.contactcard h2 { margin-top: .6rem; font-size: 1.3rem; }
.contactgrid figure { margin: 0; }
.contactgrid figure img { border-radius: var(--radius); width: 100%; }
.contactgrid figcaption { color: var(--muted); font-size: .9rem; margin-top: .5rem; }

/* ---------- Gallery ---------- */
.album { margin-bottom: 3rem; }
.album > p { color: var(--muted); margin-top: -.5rem; }
.photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: .8rem; }
.photos a { display: block; aspect-ratio: 4 / 3; overflow: hidden; border-radius: 10px; background: var(--line); }
.photos img { width: 100%; height: 100%; object-fit: cover; transition: transform .3s; }
.photos a:hover img { transform: scale(1.04); }
.lightbox { border: 0; padding: 0; background: transparent; max-width: 94vw; max-height: 94vh; }
.lightbox::backdrop { background: rgba(5,10,20,.88); }
.lightbox img { max-width: 94vw; max-height: 88vh; border-radius: 8px; margin: auto; }
.lightbox button {
  position: fixed; top: 1rem; right: 1rem; width: 2.6rem; height: 2.6rem; border-radius: 50%;
  border: 0; background: #fff; color: #14213d; font-size: 1.4rem; line-height: 1; cursor: pointer;
}

/* ---------- Footer ---------- */
.foot { border-top: 1px solid var(--line); background: var(--surface); color: var(--muted); font-size: .9rem; }
.foot .inner { display: flex; justify-content: space-between; gap: 1.5rem 2.5rem; flex-wrap: wrap; padding-block: 2rem; }
.foot strong { color: var(--fg); }
.foot ul { list-style: none; margin: 0; padding: 0; }
.foot a { color: var(--muted); }
.foot a:hover { color: var(--accent); }
