/* ==========================================================================
   5000s Association / 五千年代学会 — shared site stylesheet
   One stylesheet for every page. Sizes are in rem so that legacy Word/FrontPage
   inline sizes (converted to rem) never compound and all scale together with
   the root size set in the media queries at the bottom of this file.
   ========================================================================== */

:root {
  --bg:          #f6f8fa;
  --surface:     #ffffff;
  --border:      #d0d7de;
  --border-soft: #e4e8ed;
  --text:        #1f2328;
  --muted:       #59636e;
  --link:        #0969da;
  --link-hover:  #0550ae;
  --brand:       #1c3f63;
  --brand-ink:   #ffffff;
  --shadow-sm:   0 1px 2px rgba(27, 31, 36, .06);
  --shadow-md:   0 4px 14px rgba(27, 31, 36, .10);
  --measure:     58rem;
}

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

html {
  font-size: 17px;                 /* the rem baseline every page size derives from */
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue",
               Arial, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei",
               "Noto Sans CJK SC", "Source Han Sans SC", "WenQuanYi Micro Hei",
               sans-serif;
  font-size: 1rem;
  line-height: 1.9;                /* generous leading: most text here is CJK */
  overflow-wrap: break-word;
}

/* Traditional-Chinese passages get TC faces so glyph shapes stay correct. */
:lang(zh-TW), :lang(zh-Hant), :lang(zh-HK) {
  font-family: system-ui, -apple-system, "Segoe UI", "PingFang TC",
               "Hiragino Sans CNS", "Microsoft JhengHei", "Noto Sans CJK TC",
               "Source Han Sans TC", PMingLiU, sans-serif;
}

/* --------------------------------------------------------------- site chrome */

.site-head {
  background: var(--brand);
  color: var(--brand-ink);
  box-shadow: var(--shadow-sm);
}
.site-head > div {
  max-width: var(--measure);
  margin: 0 auto;
  padding: .7rem 1.2rem;
}
.site-brand {
  display: inline-block;
  color: var(--brand-ink);
  text-decoration: none;
  font-size: 1.25rem;
  font-weight: 700;
  line-height: 1.3;
  letter-spacing: .02em;
}
.site-brand span {
  display: block;
  font-size: .72rem;
  font-weight: 500;
  letter-spacing: .12em;
  text-transform: uppercase;
  opacity: .72;
}
.site-nav {
  margin-top: .55rem;
  display: flex;
  flex-wrap: wrap;
  gap: .2rem .1rem;
}
.site-nav a {
  color: var(--brand-ink);
  text-decoration: none;
  font-size: .88rem;
  padding: .25rem .6rem;
  border-radius: 999px;
  opacity: .88;
}
.site-nav a:hover,
.site-nav a:focus-visible { background: rgba(255, 255, 255, .16); opacity: 1; }
.site-nav a[aria-current="page"] {
  background: rgba(255, 255, 255, .22);
  font-weight: 700;
  opacity: 1;
}

.wrap {
  max-width: var(--measure);
  margin: 0 auto;
  padding: 1.6rem 1.2rem 3.5rem;
}

.site-foot {
  border-top: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  font-size: .82rem;
  text-align: center;
}
.site-foot > div {
  max-width: var(--measure);
  margin: 0 auto;
  padding: 1.4rem 1.2rem;
}
.site-foot a { color: var(--link); }

/* ------------------------------------------------------------------- content */

a { color: var(--link); text-decoration: underline; text-underline-offset: .15em; }
a:hover { color: var(--link-hover); }

img {
  max-width: 100%;
  height: auto;
  border-radius: .3rem;
}
/* Article figures sit on their own line and centre themselves. */
.page-article .wrap img { display: block; margin: 1.2rem auto; }

/* Legacy FrontPage/Word tables are fixed-width; let them scroll rather than
   forcing the page to. */
.wrap table { max-width: 100%; border-collapse: collapse; }
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
/* Top-level legacy tables carry hardcoded pixel widths; scroll them instead of
   letting them widen the page. */
.wrap > table { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; }

h1, h2, h3 { line-height: 1.4; font-weight: 700; }

/* Breadcrumb above the content, and the return links below it. */
.article-nav, .category-nav {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: .4rem;
  padding: .55rem 1rem;
  margin: 0 0 1.4rem;
  font-size: .85rem;
  box-shadow: var(--shadow-sm);
}
.article-nav a, .category-nav a { font-weight: 600; text-decoration: none; }
.article-nav a:hover, .category-nav a:hover { text-decoration: underline; }
.crumb-sep { color: var(--muted); margin: 0 .5rem; }
.crumb-here { color: var(--text); font-weight: 600; }

.article-footer {
  margin-top: 2.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  font-size: .85rem;
  text-align: center;
}
.article-footer a { font-weight: 600; text-decoration: none; margin: 0 .7rem; }
.article-footer a:hover { text-decoration: underline; }

.category-title {
  font-size: 1.6rem;
  margin: .6rem 0 1.4rem;
  padding-bottom: .7rem;
  border-bottom: 2px solid var(--border);
}

/* ------------------------------------------------------------------ post list
   Numbers come from a CSS counter, so a list cannot drift out of sequence the
   way the hand-typed "1," ... "22)" markers in the source had. */

.post-list { list-style: none; counter-reset: post; margin: 0; padding: 0; }
.post-list li { counter-increment: post; margin-bottom: .45rem; }
.post-list a {
  display: grid;
  grid-template-columns: 2.2rem 1fr;
  align-items: baseline;
  gap: .3rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: .4rem;
  padding: .75rem 1rem;
  text-decoration: none;
  color: var(--link);
  font-weight: 600;
  box-shadow: var(--shadow-sm);
  transition: border-color .15s ease, box-shadow .15s ease, transform .15s ease;
}
.post-list a::before {
  content: counter(post);
  font-variant-numeric: tabular-nums;
  font-weight: 500;
  font-size: .85rem;
  color: var(--muted);
}
.post-list a:hover {
  border-color: var(--link);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.page-article .wrap > p { margin: 0 0 1.15em; }

/* ---------------------------------------------------------------- article body
   The markup carries no inline sizing any more, so all typography lives here. */

.article-title { font-size: 1.75rem; line-height: 1.35; margin: .2rem 0 .4rem; }
.kicker {
  margin: 0 0 .2rem;
  font-size: .82rem;
  font-weight: 600;
  letter-spacing: .06em;
  color: var(--muted);
}
.byline {
  margin: 0 0 1.8rem;
  padding-bottom: .9rem;
  border-bottom: 1px solid var(--border);
  font-size: .88rem;
  color: var(--muted);
}
.page-article .wrap h2 { font-size: 1.2rem; margin: 2rem 0 .6rem; }
.page-article .wrap h3 { font-size: 1.05rem; margin: 1.6rem 0 .5rem; }

/* ----------------------------------------------------------------- home page */

.hero {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: .5rem;
  padding: 1.8rem 1.6rem;
  margin-bottom: 2rem;
  box-shadow: var(--shadow-sm);
  text-align: center;
}
.hero h1 { font-size: 2rem; margin: 0 0 .3rem; color: var(--brand); }
.hero .hero-sub {
  margin: 0;
  color: var(--muted);
  font-size: .85rem;
  letter-spacing: .14em;
  text-transform: uppercase;
}
.hero img { margin-top: 1.2rem; border-radius: .4rem; }

h2.section-heading {
  font-size: 1.15rem;
  margin: 2.2rem 0 1rem;
  padding-bottom: .5rem;
  border-bottom: 1px solid var(--border);
  color: var(--muted);
  letter-spacing: .06em;
  text-transform: uppercase;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(13rem, 1fr));
  gap: .8rem;
  list-style: none;
  margin: 0;
  padding: 0;
}
.card-grid a {
  display: block;
  height: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: .4rem;
  padding: .9rem 1.1rem;
  text-decoration: none;
  color: var(--text);
  box-shadow: var(--shadow-sm);
  transition: border-color .15s ease, box-shadow .15s ease, transform .15s ease;
}
.card-grid a:hover {
  border-color: var(--link);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}
.card-grid strong { display: block; font-size: 1.05rem; color: var(--link); }
.card-grid span { display: block; font-size: .78rem; color: var(--muted); }

.feature-list { list-style: none; margin: 0; padding: 0; }
.feature-list li { margin-bottom: .5rem; }
.feature-list a {
  display: flex;
  flex-wrap: wrap;
  gap: 0 .6rem;
  align-items: baseline;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: .2rem solid var(--link);
  border-radius: .3rem;
  padding: .7rem 1rem;
  text-decoration: none;
  color: var(--text);
  box-shadow: var(--shadow-sm);
  transition: border-color .15s ease, box-shadow .15s ease, transform .15s ease;
}
.feature-list a:hover {
  box-shadow: var(--shadow-md);
  transform: translateX(2px);
}
.feature-list .f-title { font-weight: 600; color: var(--link); }
.feature-list .f-cat { font-size: .76rem; color: var(--muted); }


/* ----------------------------------------------------------- chronology tables */

.page-chronology .wrap {
  max-width: 76rem;
}

.preface-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--brand);
  border-radius: .4rem;
  padding: 1rem 1.25rem;
  margin: 0 0 1.5rem;
  box-shadow: var(--shadow-sm);
}

.preface-title {
  margin: 0 0 .4rem;
  font-size: 1.05rem;
  color: var(--brand);
}

.preface-card p:last-child {
  margin-bottom: 0;
  font-size: .92rem;
  color: var(--text);
  line-height: 1.7;
}

.century-nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .45rem;
  margin: 1.2rem 0 2.4rem;
  padding: .75rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: .5rem;
  box-shadow: var(--shadow-sm);
}

.century-nav-label {
  font-size: .85rem;
  font-weight: 700;
  color: var(--muted);
  margin-right: .3rem;
}

.century-nav a {
  display: inline-block;
  padding: .35rem .75rem;
  border-radius: 999px;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--link);
  font-size: .84rem;
  font-weight: 600;
  text-decoration: none;
  transition: all .15s ease;
}

.century-nav a:hover,
.century-nav a:focus-visible {
  background: var(--brand);
  color: var(--brand-ink);
  border-color: var(--brand);
  box-shadow: var(--shadow-sm);
}

.century-section {
  margin-bottom: 3.2rem;
  scroll-margin-top: 1.5rem;
}

.century-header {
  margin-bottom: .85rem;
  padding-bottom: .6rem;
  border-bottom: 2px solid var(--brand);
}

.century-header h2 {
  font-size: 1.35rem;
  margin: 0;
  color: var(--text);
  line-height: 1.3;
}

.century-sub {
  display: block;
  font-size: .82rem;
  color: var(--muted);
  font-weight: 500;
  margin-top: .2rem;
}

.history-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .84rem;
  line-height: 1.45;
}

.history-table th {
  background: #f6f8fa;
  color: var(--text);
  font-weight: 700;
  padding: .65rem .75rem;
  border: 1px solid var(--border);
  border-bottom: 2px solid var(--border);
  vertical-align: top;
  text-align: left;
}

.history-table th .en-sub {
  display: block;
  font-size: .72rem;
  font-weight: 500;
  color: var(--muted);
  line-height: 1.25;
  margin-top: .2rem;
}

.history-table td {
  padding: .5rem .7rem;
  border: 1px solid #e1e4e8;
  vertical-align: top;
  text-align: left;
}

.history-table tbody tr:nth-child(even) {
  background: #fafbfc;
}

.history-table tbody tr:hover {
  background: #f1f8ff;
}

.history-table tr.has-event {
  background: #fffdf9;
}
.history-table tr.has-event:nth-child(even) {
  background: #fdfbf7;
}
.history-table tr.has-event:hover {
  background: #f1f8ff;
}

.history-table .col-sn {
  white-space: nowrap;
  font-weight: 600;
  color: var(--brand);
}

.history-table .col-bc {
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  color: #3f4752;
}

.history-table .col-dyn {
  white-space: nowrap;
  font-weight: 500;
}

.history-table .col-zod {
  white-space: nowrap;
}

.history-table .col-gz {
  white-space: nowrap;
  color: #4b5563;
}

.history-table .col-cn,
.history-table .col-wr {
  min-width: 14rem;
  max-width: 28rem;
  word-break: normal;
  overflow-wrap: break-word;
}

.event-zh {
  color: var(--text);
  line-height: 1.5;
}

.event-en {
  color: #57606a;
  font-size: .8rem;
  line-height: 1.45;
  margin-top: .3rem;
}

.century-back-top {
  margin-top: .6rem;
  text-align: right;
  font-size: .82rem;
}
.century-back-top a {
  color: var(--muted);
  text-decoration: none;
}
.century-back-top a:hover {
  color: var(--link);
  text-decoration: underline;
}


/* -------------------------------------------------------------- small screens
   Shrinking the root size shrinks every converted legacy size with it, so
   desktop-authored 24pt headings stop overflowing narrow viewports. */

@media (max-width: 900px) { html { font-size: 16px; } }
@media (max-width: 560px) {
  html { font-size: 15px; }
  .wrap { padding: 1.2rem .9rem 2.5rem; }
  .site-head > div { padding: .6rem .9rem; }
  .card-grid { grid-template-columns: 1fr; }
  .century-nav { gap: .35rem; padding: .6rem; }
  .century-nav a { font-size: .78rem; padding: .25rem .55rem; }
  .century-header h2 { font-size: 1.15rem; }
}

@media print {
  .site-head, .site-nav, .site-foot, .article-nav, .article-footer { display: none; }
  body { background: #fff; }
}
