/* ==========================================================================
   LTHY · Base layer: reset, atmosphere, typography, primitives
   ========================================================================== */

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

* { margin: 0; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--nav-h) + 1.5rem);
}

/* 背景图固定不动，内容在上面滚 —— 玻璃要透的就是它。 */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background-image: var(--backdrop);
  background-size: cover;
  background-position: 18% 30%;
  opacity: var(--backdrop-opacity);
}

/*
  照片上面按主题压一层遮罩，之后才是内容。

  这一层曾经整条丢失过：--backdrop-veil 和 --hero-scrim 在 tokens.css 里定义得好好的，
  但没人引用，于是照片以原始亮度直接显示，正文全读不清，而且改那些变量毫无效果。
  改背景明暗请改 tokens.css 的 --backdrop-veil，但**先确认这条规则还在**。
*/
body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background: var(--backdrop-veil);
}

body {
  min-height: 100svh;
  /* 先铺那张内联的糊图：它随 CSS 一起到，不占额外请求，所以切换页面时不会先黑一下。
     大图（body::before）解码完就盖在上面。 */
  background-color: var(--bg);
  background-image: var(--backdrop-lqip);
  background-size: cover;
  background-position: 18% 30%;
  background-repeat: no-repeat;
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: var(--fs-body);
  line-height: var(--lh-body);
  letter-spacing: .004em;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

img, svg, video, canvas { display: block; max-width: 100%; }

[hidden] { display: none !important; }
img { height: auto; }

a { color: inherit; text-decoration: none; }

button, input, select, textarea { font: inherit; color: inherit; }
button { background: none; border: 0; cursor: pointer; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: var(--r-xs);
}

::selection { background: color-mix(in oklab, var(--c-red) 42%, transparent); color: var(--ink); }

/* --- Custom scrollbar ------------------------------------------------ */
* { scrollbar-width: thin; scrollbar-color: color-mix(in oklab, var(--accent) 55%, transparent) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: linear-gradient(var(--c-red), var(--c-gold));
  border-radius: var(--r-full);
  border: 3px solid transparent;
  background-clip: content-box;
}

/* 没有任何背景特效：没有粒子、极光、光斑、噪点。页面就是一层底色。 */
.page { position: relative; z-index: 1; }

/* ==========================================================================
   Layout primitives
   ========================================================================== */

.wrap {
  width: min(100% - (var(--gutter) * 2), var(--maxw));
  margin-inline: auto;
}

.wrap--read { width: min(100% - (var(--gutter) * 2), var(--maxw-read)); }

.section { padding-block: clamp(3.5rem, 9vw, 7rem); }
.section--tight { padding-block: clamp(2rem, 5vw, 3.5rem); }

.stack > * + * { margin-top: var(--stack-gap, 1rem); }

.hairline {
  height: 1px;
  border: 0;
  background: var(--grad-line);
  opacity: .5;
}

/* ==========================================================================
   Typography
   ========================================================================== */

h1, h2, h3, h4 {
  line-height: var(--lh-tight);
  letter-spacing: var(--tracking-tight);
  font-weight: 660;
  text-wrap: balance;
}

h1 { font-size: var(--fs-h1); }
h2 { font-size: var(--fs-h2); }
h3 { font-size: var(--fs-h3); font-weight: 620; }

p { text-wrap: pretty; }

.lead { font-size: var(--fs-lead); color: var(--ink-dim); line-height: 1.75; }
.lead p + p { margin-top: .9rem; }

.grad-text {
  background: var(--grad-brand);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.eyebrow {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  color: var(--accent);
  display: inline-flex;
  align-items: center;
  gap: .55rem;
}

.eyebrow::before {
  content: "";
  width: 26px;
  height: 1px;
  background: currentColor;
  opacity: .7;
}

.mono { font-family: var(--font-mono); }
.dim { color: var(--ink-dim); }
.faint { color: var(--ink-faint); }

a.link {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-color: color-mix(in oklab, var(--accent) 40%, transparent);
  text-underline-offset: 3px;
  transition: text-decoration-color var(--dur-fast);
}
a.link:hover { text-decoration-color: currentColor; }

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

.skip-link {
  position: fixed;
  top: 10px; left: 10px;
  z-index: 999;
  padding: .7rem 1.1rem;
  background: var(--surface-solid);
  border: 1px solid var(--border-hi);
  border-radius: var(--r-sm);
  transform: translateY(-160%);
  transition: transform var(--dur) var(--ease-out);
}
.skip-link:focus-visible { transform: translateY(0); }

/* ==========================================================================
   Scroll reveal
   ========================================================================== */

.reveal {
  opacity: 0;
  transform: translateY(26px) scale(.985);
  transition:
    opacity var(--dur-slow) var(--ease-out),
    transform var(--dur-slow) var(--ease-out);
  transition-delay: calc(var(--i, 0) * 65ms);
  will-change: opacity, transform;
}

.reveal.is-in { opacity: 1; transform: none; }

/* ==========================================================================
   Motion & transparency preferences
   ========================================================================== */

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

@media print {
  .fx, .nav, .footer, .progress-bar, .to-top, .toc { display: none !important; }
  body { background: #fff; color: #000; }
}
