/* =============================================================
   BASE — reset, typography, layout primitives, accessibility
   ============================================================= */

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

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--header-h) + 72px);
}

body {
  margin: 0;
  background: var(--cream);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: var(--fs-body);
  line-height: var(--lh-body);
  font-synthesis-weight: none;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
  /* room for the sticky mobile action bar */
  padding-bottom: calc(var(--actionbar-h) + var(--safe-b));
}

html[lang="zh"] body,
html[lang^="zh"] body { font-family: var(--font-zh); }

@media (min-width: 1024px) {
  body { padding-bottom: 0; }
}

body.is-locked { overflow: hidden; }

/* ---------- Headings ---------- */
h1, h2, h3, h4, h5 {
  font-family: var(--font-head);
  font-weight: 600;
  color: var(--bark);
  line-height: var(--lh-head);
  margin: 0 0 var(--sp-4);
  letter-spacing: -0.005em;
  text-wrap: balance;
}
h1 { font-size: var(--fs-h1); line-height: var(--lh-tight); }
h2 { font-size: var(--fs-h2); }
h3 { font-size: var(--fs-h3); }
h4 { font-size: var(--fs-h4); }

p { margin: 0 0 var(--sp-4); max-width: var(--maxw-text); text-wrap: pretty; }
p:last-child { margin-bottom: 0; }

.lead {
  font-size: var(--fs-lead);
  line-height: 1.6;
  color: var(--muted);
}

strong, b { font-weight: 600; color: var(--bark); }

small, .small { font-size: var(--fs-sm); line-height: 1.55; }

/* ---------- Links ---------- */
a { color: var(--sage-deep); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: var(--sage-dark); }

/* ---------- Lists ---------- */
ul, ol { padding-left: 1.25em; margin: 0 0 var(--sp-4); }
li { margin-bottom: var(--sp-2); }
.list-plain { list-style: none; padding: 0; margin: 0; }

/* ---------- Media ---------- */
img, svg, video { max-width: 100%; height: auto; display: block; }
img { background: var(--sand); }

/* ---------- Forms & buttons reset ---------- */
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }

/* ---------- Focus: always visible, never removed ---------- */
:focus { outline: none; }
:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
  border-radius: 4px;
}
.on-dark :focus-visible,
.footer :focus-visible { outline-color: var(--gold-soft); }

/* ---------- Skip link ---------- */
.skip-link {
  position: absolute; left: var(--sp-4); top: -100px;
  z-index: 200;
  background: var(--sage-dark); color: var(--white);
  padding: var(--sp-3) var(--sp-5);
  border-radius: 0 0 var(--r-md) var(--r-md);
  font-weight: 600; text-decoration: none;
  transition: top var(--t-fast) var(--ease);
}
.skip-link:focus { top: 0; color: var(--white); }
/* Only reveal it for genuine keyboard focus. If script ever moves focus
   here programmatically, it must not pop into view over the logo. */
.skip-link:focus:not(:focus-visible) { top: -100px; }
/* It must never sit under the header when it does appear. */
.skip-link { z-index: 300; }

/* ---------- Screen-reader only ---------- */
.sr-only {
  position: absolute !important;
  width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%);
  white-space: nowrap; border: 0;
}

/* ---------- Layout ---------- */
.container {
  width: 100%;
  max-width: var(--maxw);
  margin-inline: auto;
  padding-inline: var(--gutter);
}
.container--narrow { max-width: 880px; }

.section { padding-block: var(--section-y); }
.section--sand  { background: var(--sand); }
.section--tint  { background: var(--sage-tint); }
.section--dark  { background: var(--sage-dark); color: #F2EFE7; }
.section--dark h2, .section--dark h3 { color: var(--white); }

.section-head { margin-bottom: var(--sp-7); max-width: 62ch; }
.section-head .lead { margin-top: calc(var(--sp-3) * -1 + 0.25rem); }

/* Small caps eyebrow with a gold rule */
.eyebrow {
  display: inline-flex; align-items: center; gap: var(--sp-3);
  font-size: var(--fs-sm); font-weight: 600;
  letter-spacing: .12em; text-transform: uppercase;
  color: var(--gold-deep);
  margin-bottom: var(--sp-3);
}
.eyebrow::before {
  content: ""; width: 28px; height: 2px; border-radius: 2px;
  background: var(--gold); flex: none;
}

/* Generic responsive grid */
.grid { display: grid; gap: var(--sp-5); }
@media (min-width: 640px)  { .grid--2 { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 640px)  { .grid--3 { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1024px) { .grid--3 { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 900px)  { .grid--4 { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1200px) { .grid--4 { grid-template-columns: repeat(4, 1fr); } }

.stack > * + * { margin-top: var(--sp-4); }
.center { text-align: center; margin-inline: auto; }
.center p { margin-inline: auto; }

hr.rule {
  border: 0; height: 1px; background: var(--line);
  margin-block: var(--sp-7);
}

/* ---------- Missing-fact placeholder ----------
   Renders wherever config.js has no value yet, so nothing fake
   can ever ship. Deliberately impossible to miss. */
.placeholder {
  display: inline-block;
  font-family: var(--font-body);
  font-size: .9em; font-weight: 600;
  color: #7A4B00;
  background: repeating-linear-gradient(45deg, #FFF4DC, #FFF4DC 8px, #FDECC8 8px, #FDECC8 16px);
  border: 1.5px dashed #C98A14;
  border-radius: 6px;
  padding: .05em .45em;
  letter-spacing: .01em;
  white-space: nowrap;
}
.on-dark .placeholder, .footer .placeholder { color: #5A3600; }

/* Hidden until config supplies data */
[hidden] { display: none !important; }
