/* ==========================================================================
   Ming-Hung Wang — site styles
   Plain CSS (no build step). Black and white, one typeface, few ornaments.
   ========================================================================== */

:root {
  --text: #202124;
  --muted: #5f6368;
  --faint: #9aa0a6;
  --line: #e3e3e3;
  --bg: #ffffff;
  --sans: "Open Sans", "Noto Sans TC", system-ui, -apple-system, "Segoe UI", "PingFang TC", "Microsoft JhengHei", sans-serif;
  --container: 1120px;
  --header-h: 64px;
}

/* --------------------------------------------------------------------------
   Base
   -------------------------------------------------------------------------- */

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

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

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

a { color: inherit; text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: .18em; }
a:hover { text-decoration-thickness: 2px; }

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

.container { width: 100%; max-width: var(--container); margin: 0 auto; padding: 0 28px; }

.skip-link { position: absolute; left: -9999px; top: 8px; z-index: 100; padding: 8px 14px; background: var(--bg); }
.skip-link:focus { left: 16px; }

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

.site-header { position: relative; background: var(--bg); }

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  height: var(--header-h);
}

.brand { flex-shrink: 0; white-space: nowrap; font-size: 1.25rem; font-weight: 500; letter-spacing: .04em; color: var(--text); text-decoration: none; }
.brand:hover { text-decoration: none; }

.site-nav { display: flex; align-items: center; font-size: .95rem; }
.site-nav a { color: var(--muted); text-decoration: none; white-space: nowrap; }
.site-nav a + a::before { content: "·"; margin: 0 .8em; color: var(--faint); font-weight: 400; }
.site-nav a:hover { color: var(--text); }
.site-nav a[aria-current="page"] { color: var(--text); font-weight: 700; }
.nav-en { margin-left: .3em; }

.nav-toggle { display: none; }

@media (max-width: 980px) {
  .nav-toggle {
    display: inline-flex;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
    width: 40px;
    height: 40px;
    padding: 0 9px;
    border: 0;
    background: transparent;
    cursor: pointer;
  }
  .nav-toggle span { display: block; height: 2px; background: var(--text); transition: transform .2s, opacity .2s; }
  .nav-toggle[aria-expanded="true"] span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
  .nav-toggle[aria-expanded="true"] span:nth-child(2) { opacity: 0; }
  .nav-toggle[aria-expanded="true"] span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

  .js .site-nav {
    position: absolute;
    top: var(--header-h);
    left: 0;
    right: 0;
    z-index: 50;
    display: none;
    flex-direction: column;
    align-items: stretch;
    padding: 4px 18px 14px;
    background: var(--bg);
    border-bottom: 1px solid var(--line);
  }
  .js .site-nav.open { display: flex; }
  .site-nav a { padding: 10px 0; }
  .site-nav a + a::before { content: none; }

  .no-js .header-inner { height: auto; flex-wrap: wrap; padding: 12px 0; }
  .no-js .site-nav { flex-wrap: wrap; }
}

@media (max-width: 600px) { .container { padding: 0 18px; } }

/* --------------------------------------------------------------------------
   Page title (centred, with a short black rule)
   -------------------------------------------------------------------------- */

.page-head { padding: 64px 0 52px; text-align: center; }
.page-title { margin: 0; font-size: 2.4rem; font-weight: 600; line-height: 1.25; color: var(--text); }
.page-title::after { content: ""; display: block; width: 100px; height: 5px; margin: 22px auto 0; background: var(--text); }
.page-lead { max-width: 40rem; margin: 22px auto 0; font-size: .9rem; color: var(--muted); }

.page-body { padding-bottom: 96px; }

@media (max-width: 600px) {
  .page-head { padding: 40px 0 32px; }
  .page-title { font-size: 1.9rem; }
}

/* --------------------------------------------------------------------------
   Home: photo and side notes on the left, introduction on the right
   -------------------------------------------------------------------------- */

.home-grid {
  display: grid;
  grid-template-columns: minmax(0, 5fr) minmax(0, 7fr);
  gap: 40px;
  padding-bottom: 96px;
}

.home-side .photo { width: 100%; }
.identity { margin-top: 16px; }
.identity p { margin: 0 0 4px; font-size: .95rem; line-height: 1.6; }
.identity .id-name { font-size: 1.15rem; font-weight: 600; }
.identity .id-zh { color: var(--muted); }
.identity .home-links { margin-top: 10px; }
.home-side h2 { margin: 28px 0 10px; font-size: 1.5rem; font-weight: 600; line-height: 1.3; }
.home-side p { margin: 0 0 .9em; font-size: .95rem; }
.home-side .interests { margin-bottom: .25em; }
.interests span { white-space: nowrap; }

.home-main p { text-align: justify; }
.home-main .lang-panel + .lang-panel { margin-top: 1.6em; }

@media (max-width: 860px) {
  .home-grid { grid-template-columns: minmax(0, 1fr); gap: 8px; }
  .home-main p { text-align: left; }
}

/* --------------------------------------------------------------------------
   Prose
   -------------------------------------------------------------------------- */

.prose { max-width: 960px; margin: 0 auto; }
.prose p { margin: 0 0 1em; }
.prose strong { font-weight: 600; }
.prose h2 { margin: 2.4rem 0 .8rem; font-size: 1.3rem; font-weight: 600; line-height: 1.35; }
.prose > h2:first-child { margin-top: 0; }
.prose h3 { margin: 1.8rem 0 .6rem; font-size: 1.05rem; font-weight: 600; }
.prose ul, .prose ol { margin: 0 0 1em; padding-left: 1.4em; }
.prose li { margin-bottom: .3em; }

/* bullet lists */
.plain-list { list-style: disc; }
.cols-2 { columns: 2; column-gap: 40px; }
.cols-2 li { break-inside: avoid; }
@media (max-width: 700px) { .cols-2 { columns: 1; } }

/* publications: numbered, as on the old site */
.pub-list { list-style: decimal; padding-left: 1.9em; }
.pub-list li { margin-bottom: .6em; line-height: 1.6; padding-left: .2em; }
.pub-list .me { text-decoration: underline; text-underline-offset: .18em; }
.pub-list em.cjk { font-style: normal; }
a.doi, a.cite { margin-left: .35em; font-size: .85em; color: var(--muted); white-space: nowrap; }

/* experience: title and dates on one line, English below */
.prose .cv-list { list-style: none; padding: 0; }
.cv-list li { display: grid; grid-template-columns: minmax(0, 1fr) auto; column-gap: 24px; margin: 0; padding-bottom: 16px; }
.cv-zh { grid-column: 1; grid-row: 1; }
.cv-date { grid-column: 2; grid-row: 1; white-space: nowrap; font-size: .92rem; font-variant-numeric: tabular-nums; color: var(--muted); }
.cv-en { grid-column: 1 / -1; grid-row: 2; font-size: .93rem; line-height: 1.55; color: var(--muted); }
@media (max-width: 600px) {
  .cv-list li { display: block; }
  .cv-zh, .cv-date, .cv-en { display: block; }
}

/* honours: year column; repeated years are hidden by script */
.prose .year-list { list-style: none; padding: 0; }
.year-list li { display: grid; grid-template-columns: 6.5rem minmax(0, 1fr); column-gap: 20px; margin: 10px 0 0; }
.year-list li:first-child, .year-list li.same-year { margin-top: 2px; }
.year-list li.same-year .yr { visibility: hidden; }
.yr { font-variant-numeric: tabular-nums; color: var(--muted); }
@media (max-width: 600px) { .year-list li { grid-template-columns: 5.2rem minmax(0, 1fr); column-gap: 12px; } }

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

.site-footer { padding: 22px 0 30px; border-top: 1px solid var(--line); font-size: .82rem; color: var(--muted); }
.footer-inner { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 6px 24px; }

/* --------------------------------------------------------------------------
   Print (also used to produce the CV PDF)
   -------------------------------------------------------------------------- */

.print-only { display: none; }

@media print {
  @page { size: A4; margin: 15mm 16mm 16mm; }
  html { font-size: 10pt; }
  body { font-size: 1rem; line-height: 1.5; color: #000; }
  a { color: #000; text-decoration: none; }
  .pub-list .me { text-decoration: underline; }
  a.doi { display: none; }
  .site-header, .site-footer, .skip-link, .nav-toggle { display: none !important; }
  .container { max-width: none; padding: 0; }
  .prose { max-width: none; }
  .page-head { padding: 0 0 12pt; text-align: left; }
  .page-title { font-size: 15pt; }
  .page-title::after { width: 36pt; height: 2.5pt; margin: 6pt 0 0; }
  .page-lead { margin: 6pt 0 0; max-width: none; }
  .page-body, .home-grid { padding-bottom: 0; }
  .prose h2 { margin: 14pt 0 6pt; font-size: 12pt; break-after: avoid; }
  .prose h3 { margin: 10pt 0 4pt; font-size: 10.5pt; break-after: avoid; }
  .pub-list li, .cv-list li, .year-list li { break-inside: avoid; }
  .cv-list li { padding-bottom: 6pt; }
  .year-list li { margin-top: 4pt; }

  /* home page becomes the CV header: name, position, contact, interests, summary */
  .is-home .page-head, .home-side .photo, .home-side .news, .identity .home-links { display: none; }
  .home-grid { display: block; }
  .identity { margin: 0 0 8pt; }
  .identity .id-name { font-size: 18pt; }
  .print-only { display: block; }
  .home-side h2 { margin: 8pt 0 2pt; font-size: 12pt; }
  .home-main .lang-panel[lang^="zh"] { display: none; }
  .home-main p { text-align: left; }
}
