/* ============================================================
   SMC · Base + global layout
   ============================================================ */

@import url("./tokens.css");
/* Chinese display/body serif — referenced by the zh-hk pages; load it for real
   so 繁中 renders in Noto Serif TC, not an inconsistent system fallback. */
@import url("https://fonts.googleapis.com/css2?family=Noto+Serif+TC:wght@400;500;600;700&display=swap");

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

html { -webkit-text-size-adjust: 100%; font-size: 112.5%; }   /* 16 → 18px base — larger reading text for elderly visitors */

body {
  margin: 0;
  background: var(--ink-0);
  color: var(--vellum-1);
  font-family: var(--font-body);
  font-size: var(--fs-body);
  line-height: var(--lh-body);
  font-weight: 400;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  font-optical-sizing: auto;
  font-variant-ligatures: contextual common-ligatures;
  font-feature-settings: "kern" 1, "liga" 1, "calt" 1;
  /* atmospheric candle wash */
  background-image:
    radial-gradient(120% 80% at 50% -10%, rgba(122, 29, 36, 0.18) 0%, rgba(122, 29, 36, 0) 55%),
    radial-gradient(60% 40% at 80% 0%, rgba(224, 183, 116, 0.06) 0%, rgba(224, 183, 116, 0) 60%);
  background-attachment: fixed;
  min-height: 100vh;
}

/* grain — universal */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 999;
  opacity: 0.35;
  mix-blend-mode: overlay;
  background-image: url("../assets/grain.svg");
  background-size: 240px 240px;
}

/* lang switch */
:lang(zh-hk), [lang^="zh"] {
  font-family: "Noto Serif TC", "Noto Serif HK", "Songti TC", "PMingLiU", serif;
  line-height: 1.85;
  letter-spacing: 0.01em;
}
:lang(zh-hk) .display, [lang^="zh"] .display {
  font-family: "Noto Serif TC", "Noto Serif HK", "Songti TC", serif;
  font-weight: 600;
  letter-spacing: 0.02em;
}

/* typography primitives */
h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 500;
  color: var(--vellum-0);
  letter-spacing: var(--tracking-tight);
  margin: 0;
  text-wrap: balance;
}
h1 { font-size: var(--fs-h1); line-height: var(--lh-h); letter-spacing: var(--tracking-display); }
h2 { font-size: var(--fs-h2); line-height: var(--lh-h); }
h3 { font-size: var(--fs-h3); line-height: var(--lh-tight); letter-spacing: 0; }

p { margin: 0; text-wrap: pretty; }
p + p { margin-top: 1em; }

a {
  color: var(--gilt-0);
  text-decoration: none;
  text-underline-offset: 0.18em;
  text-decoration-thickness: 1px;
  border-bottom: 1px solid color-mix(in oklab, var(--gilt-0) 35%, transparent);
  transition: color var(--dur-fast) var(--ease-out),
              border-color var(--dur-fast) var(--ease-out);
}
a:hover { color: var(--vellum-0); border-bottom-color: var(--vellum-0); }
a:focus-visible {
  outline: 2px solid var(--gilt-0);
  outline-offset: 3px;
  border-radius: 2px;
}

/* selection */
::selection { background: var(--ember-2); color: var(--vellum-0); }

/* container */
.wrap {
  max-width: var(--content-max);
  margin: 0 auto;
  padding: 0 var(--sp-5);
}

/* utility — eyebrow / small caps label */
.eyebrow {
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 500;
  font-size: var(--fs-small);
  letter-spacing: 0.04em;
  color: var(--gilt-0);
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
}
.eyebrow::before {
  content: "";
  width: 18px; height: 1px;
  background: var(--gilt-0);
  display: inline-block;
  opacity: 0.7;
}

.label-caps {
  font-family: var(--font-body);
  font-size: var(--fs-micro);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--vellum-2);
  font-weight: 500;
}

/* hr — woven gilt rule */
.rule {
  border: 0;
  height: 1px;
  background: linear-gradient(90deg,
    transparent 0%,
    color-mix(in oklab, var(--gilt-0) 35%, transparent) 30%,
    color-mix(in oklab, var(--gilt-0) 60%, transparent) 50%,
    color-mix(in oklab, var(--gilt-0) 35%, transparent) 70%,
    transparent 100%
  );
  margin: var(--sp-7) auto;
  max-width: 240px;
}
.rule--full { max-width: 100%; }

/* visually hidden */
.sr-only {
  position: absolute !important; width: 1px; height: 1px;
  margin: -1px; padding: 0; overflow: hidden;
  clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

/* focus default for buttons */
button:focus-visible,
[role="button"]:focus-visible,
.btn:focus-visible {
  outline: 2px solid var(--gilt-0);
  outline-offset: 3px;
}

button {
  font-family: inherit;
  color: inherit;
  background: transparent;
  border: 0;
  cursor: pointer;
}

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

/* page-load reveal — runs once per page */
.reveal > * {
  opacity: 0;
  transform: translateY(8px);
  animation: revealUp 700ms var(--ease-out) forwards;
}
.reveal > *:nth-child(1) { animation-delay: 80ms; }
.reveal > *:nth-child(2) { animation-delay: 200ms; }
.reveal > *:nth-child(3) { animation-delay: 320ms; }
.reveal > *:nth-child(4) { animation-delay: 440ms; }
.reveal > *:nth-child(5) { animation-delay: 560ms; }
.reveal > *:nth-child(6) { animation-delay: 680ms; }
.reveal > *:nth-child(7) { animation-delay: 800ms; }

@keyframes revealUp {
  to { opacity: 1; transform: translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
  .reveal > * { opacity: 1; transform: none; }
}

/* desktop — type now scales fluidly via clamp() in tokens.css, so only the
   reading width + atmosphere step up here. */
@media (min-width: 720px) {
  :root { --content-max: 720px; }
  body {
    background-image:
      radial-gradient(80% 60% at 50% -10%, rgba(122, 29, 36, 0.22) 0%, rgba(122, 29, 36, 0) 60%),
      radial-gradient(40% 30% at 80% 0%, rgba(224, 183, 116, 0.08) 0%, rgba(224, 183, 116, 0) 60%);
  }
}
