/* Chih-hsing Ho, personal site. Shared by the English and Traditional Chinese pages.
   Layout: sticky profile (left), content (middle), sticky table of contents (right). */

:root {
  --paper: #ffffff;
  --ink: #1d2430;
  --muted: #5d6675;
  --rule: #e2e5ea;
  --wash: #f4f5f7;
  --link: #23488f;
  --serif: "Source Serif 4", "Noto Serif TC", "Songti TC", Georgia, serif;
  --sans: "Public Sans", "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", system-ui, sans-serif;
  --header-h: 4rem;
  --radius: 0.375rem;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: calc(var(--header-h) + 1.5rem); }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
html, body { overflow-x: clip; }
body { margin: 0; background: var(--paper); color: var(--ink); font-family: var(--sans); font-size: 1rem; line-height: 1.65; }
:lang(zh-Hant) body, body:lang(zh-Hant) { line-height: 1.8; }
a { color: var(--link); text-underline-offset: 3px; text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--link); outline-offset: 2px; }
p, ul, ol, dl, h1, h2, h3 { margin: 0; }
ul, ol { padding: 0; list-style: none; }

.wrap { max-width: 86rem; margin-inline: auto; padding-inline: clamp(1.25rem, 4vw, 2.5rem); }

/* Header */
.site-header { position: sticky; top: 0; z-index: 10; background: var(--paper); border-bottom: 1px solid var(--rule); }
.site-header .wrap { display: flex; align-items: center; justify-content: space-between; gap: 1rem; height: var(--header-h); }
.site-name { font-family: var(--serif); font-size: 1.25rem; font-weight: 600; color: var(--ink); }
.site-name:hover { text-decoration: none; }
.header-tools { display: flex; align-items: center; gap: 1.25rem; font-size: 0.9375rem; }
.lang a[aria-current="true"] { color: var(--ink); font-weight: 600; pointer-events: none; }
.lang a + a::before { content: "/"; color: var(--rule); margin: 0 0.5rem; display: inline-block; }

/* Contents dropdown, shown when the right-hand column doesn't fit */
.toc-drop { position: relative; }
.toc-drop summary { cursor: pointer; list-style: none; padding: 0.3rem 0.75rem; border: 1px solid var(--rule); border-radius: var(--radius); }
.toc-drop summary::-webkit-details-marker { display: none; }
.toc-drop[open] summary { background: var(--wash); }
.toc-drop ul { position: absolute; right: 0; top: calc(100% + 0.5rem); width: 15rem; background: var(--paper); border: 1px solid var(--rule); border-radius: var(--radius); padding: 0.5rem; box-shadow: 0 8px 24px rgb(29 36 48 / 0.08); }
.toc-drop li a { display: block; padding: 0.35rem 0.6rem; border-radius: 0.25rem; color: var(--ink); }
.toc-drop li a:hover { background: var(--wash); text-decoration: none; }
@media (min-width: 1200px) { .toc-drop { display: none; } }

/* Three-column layout */
.layout { display: grid; grid-template-columns: minmax(0, 1fr); gap: 2.5rem 3.5rem; padding-block: 3rem 5rem; }
@media (min-width: 880px) { .layout { grid-template-columns: 15rem minmax(0, 1fr); column-gap: 4.5rem; } }
/* Wider gutters either side of the content column give it room to breathe (issue #9). */
@media (min-width: 1200px) { .layout { grid-template-columns: 15rem minmax(0, 1fr) 12rem; column-gap: clamp(4.5rem, 6vw, 6rem); } }

/* Profile */
.profile { font-size: 0.9375rem; }
@media (min-width: 880px) { .profile { position: sticky; top: calc(var(--header-h) + 2rem); align-self: start; } }
.portrait { display: block; width: 100%; height: auto; max-width: 15rem; aspect-ratio: 1 / 1; object-fit: cover; border-radius: var(--radius); background: var(--wash); }
@media (max-width: 879px) { .profile { display: grid; grid-template-columns: 7rem minmax(0, 1fr); gap: 0 1.25rem; align-items: start; } }
.profile h1, .profile .name { font-family: var(--serif); font-size: 1.5rem; font-weight: 600; line-height: 1.25; margin-top: 1rem; }
.profile h1 .alt, .profile .name .alt { display: block; font-size: 1.125rem; font-weight: 500; color: var(--muted); }
.profile .name a { color: var(--ink); }
@media (max-width: 879px) { .profile h1, .profile .name { margin-top: 0; } }
.profile .role { color: var(--muted); line-height: 1.5; margin-top: 0.5rem; }
.profile .contact { margin-top: 1rem; display: grid; gap: 0.2rem; overflow-wrap: anywhere; }
.profile .contact .addr { color: var(--muted); }

/* Right-hand table of contents */
.toc { display: none; }
@media (min-width: 1200px) {
  .toc { display: block; position: sticky; top: calc(var(--header-h) + 2rem); align-self: start; max-height: calc(100dvh - var(--header-h) - 4rem); overflow-y: auto; font-size: 0.875rem; }
}
.toc-title { font-weight: 600; margin-bottom: 0.5rem; padding-left: 0.85rem; }
.toc > ol { border-left: 1px solid var(--rule); }
.toc a { display: block; padding: 0.22rem 0 0.22rem 0.85rem; margin-left: -1px; border-left: 2px solid transparent; color: var(--muted); line-height: 1.35; }
.toc ol ol a { padding-left: 1.6rem; font-size: 0.8125rem; }
.toc a:hover { color: var(--ink); text-decoration: none; }
.toc a[aria-current="true"] { color: var(--link); border-left-color: var(--link); font-weight: 500; }
.toc .back { margin-top: 1rem; }

/* Content */
main { min-width: 0; }
/* Topic pages (/topic/…): the page title sits at the top of the content column. */
main h1 { font-family: var(--serif); font-size: 1.75rem; font-weight: 600; line-height: 1.3; margin-bottom: 0.25rem; }
main .kicker { color: var(--muted); margin-bottom: 1.75rem; }
main .kicker + section h2 { margin-top: 0; }
/* Publication pages (/publications/…, /zh-tw/publications/…). */
.crumbs { color: var(--muted); font-size: 0.9375rem; margin-bottom: 0.75rem; }
.pub-page h1 { font-size: 1.5rem; max-width: 46rem; }
.pub-page > .alt { color: var(--muted); font-size: 1.0625rem; margin-top: 0.35rem; max-width: 46rem; }
.pub-cite { color: var(--muted); margin-top: 0.75rem; max-width: 46rem; }
.pub-cite b { color: var(--ink); font-weight: 600; }
.pub-src { margin-top: 0.75rem; }
.pub-page section h2 { margin-top: 2.75rem; }
main h2 { font-family: var(--serif); font-size: 1.375rem; font-weight: 600; line-height: 1.3; margin: 3.25rem 0 0.75rem; }
main section:first-child h2 { margin-top: 0; }
main h3 { font-family: var(--serif); font-size: 1.0625rem; font-weight: 600; color: var(--muted); margin: 1.75rem 0 0.25rem; }
.prose { max-width: 42rem; }
.prose p + p { margin-top: 1rem; }
.bullets { list-style: disc; padding-left: 1.25rem; max-width: 42rem; }

.pubs { max-width: 46rem; }
.pubs li { padding-block: 0.85rem; border-bottom: 1px solid var(--rule); }
.pubs .t { font-weight: 500; color: var(--ink); }
.pubs a.t { color: var(--link); }
.pubs .m { color: var(--muted); font-size: 0.9375rem; }
.pubs .m b { color: var(--ink); font-weight: 600; }
.pubs .alt { font-size: 0.9375rem; color: var(--muted); }

.rows { width: 100%; max-width: 46rem; border-collapse: collapse; }
.rows td { padding: 0.6rem 0; border-bottom: 1px solid var(--rule); vertical-align: top; }
.rows td:first-child { width: 8.5rem; padding-right: 1rem; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.rows .sub { display: block; color: var(--muted); font-size: 0.9375rem; }
@media (max-width: 560px) {
  .rows td:first-child { width: auto; white-space: normal; }
  .rows tr { display: grid; border-bottom: 1px solid var(--rule); padding-block: 0.6rem; }
  .rows td { border: 0; padding: 0; }
}
.note { color: var(--muted); font-size: 0.875rem; margin-top: 0.75rem; max-width: 46rem; }

.site-footer { border-top: 1px solid var(--rule); color: var(--muted); font-size: 0.875rem; padding-block: 1.5rem; }
