/* ==========================================================================
   纸上 · Design tokens & base
   ========================================================================== */

:root {
  /* Colour */
  --paper: #f1ede4;
  --paper-deep: #e8e2d5;
  --surface: #faf7f0;
  --surface-raised: #fffdf8;
  --ink: #191814;
  --ink-soft: #666055;
  --ink-faint: #6f695e;
  --line: rgba(25, 24, 20, 0.14);
  --line-strong: rgba(25, 24, 20, 0.3);
  --accent: #b1412b;
  --accent-deep: #8d3221;
  --moss: #314638;
  --moss-deep: #25362b;
  --sand: #d9c9a5;
  --white: #fffdf8;
  --danger: #9e2f22;
  --success: #3e6146;

  /* Type */
  --font-serif: "Iowan Old Style", "Songti SC", "Noto Serif SC",
    "Source Han Serif SC", "STSong", "SimSun", Georgia, serif;
  --font-sans: "Avenir Next", "Helvetica Neue", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei UI", "Microsoft YaHei", sans-serif;
  --font-mono: "SFMono-Regular", "Cascadia Mono", "Roboto Mono", Consolas,
    monospace;

  /* Layout */
  --page-gutter: clamp(20px, 4.2vw, 72px);
  --container: 1480px;
  --header-h: 84px;
  --radius-xs: 2px;
  --radius-sm: 4px;
  --radius-md: 8px;

  /* Motion */
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);
  --dur-fast: 160ms;
  --dur: 280ms;
  --dur-slow: 700ms;
}

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

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scrollbar-gutter: stable;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 9999;
  pointer-events: none;
  opacity: 0.32;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.82' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.17'/%3E%3C/svg%3E");
  mix-blend-mode: multiply;
}

::selection {
  background: var(--accent);
  color: var(--white);
}

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

button,
input,
textarea,
select {
  font: inherit;
  color: inherit;
}

button {
  border: 0;
  padding: 0;
  background: none;
  cursor: pointer;
}

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

p,
h1,
h2,
h3,
h4,
h5,
h6,
figure,
blockquote,
dl,
dd {
  margin: 0;
}

ul,
ol {
  margin: 0;
  padding: 0;
  list-style: none;
}

[hidden] {
  display: none !important;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 4px;
}

/* --------------------------------------------------------------------------
   Shared primitives
   -------------------------------------------------------------------------- */
.container {
  width: 100%;
  max-width: var(--container);
  margin-inline: auto;
  padding-inline: var(--page-gutter);
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink-soft);
  font-family: var(--font-sans);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.22em;
  line-height: 1.3;
  text-transform: uppercase;
}

.eyebrow::before {
  content: "";
  width: 22px;
  height: 1px;
  flex: 0 0 auto;
  background: currentColor;
  opacity: 0.55;
}

.eyebrow--plain::before {
  display: none;
}

.label {
  font-family: var(--font-sans);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.2em;
  text-transform: uppercase;
}

.serif {
  font-family: var(--font-serif);
  font-weight: 500;
  letter-spacing: -0.015em;
}

.muted {
  color: var(--ink-soft);
}

.accent {
  color: var(--accent);
}

.rule {
  height: 1px;
  border: 0;
  background: var(--line);
}

.icon {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  stroke-width: 1.5;
}

.icon--sm {
  width: 15px;
  height: 15px;
}

.icon--lg {
  width: 24px;
  height: 24px;
}

.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: 12px;
  left: 12px;
  z-index: 10001;
  padding: 10px 16px;
  background: var(--ink);
  color: var(--white);
  font-size: 12px;
  transform: translateY(-160%);
  transition: transform var(--dur-fast) ease;
}

.skip-link:focus {
  transform: translateY(0);
}

/* Buttons */
.btn {
  --btn-bg: transparent;
  --btn-fg: var(--ink);
  --btn-border: var(--line-strong);
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  min-height: 46px;
  padding: 12px 22px;
  border: 1px solid var(--btn-border);
  border-radius: 999px;
  background: var(--btn-bg);
  color: var(--btn-fg);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.06em;
  line-height: 1.2;
  text-align: center;
  cursor: pointer;
  transition:
    background var(--dur-fast) ease,
    color var(--dur-fast) ease,
    border-color var(--dur-fast) ease,
    transform var(--dur-fast) var(--ease-out);
}

.btn:hover {
  --btn-bg: var(--ink);
  --btn-fg: var(--white);
  --btn-border: var(--ink);
}

.btn:active {
  transform: scale(0.98);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.btn--solid {
  --btn-bg: var(--ink);
  --btn-fg: var(--white);
  --btn-border: var(--ink);
}

.btn--solid:hover {
  --btn-bg: var(--accent);
  --btn-border: var(--accent);
}

.btn--accent {
  --btn-bg: var(--accent);
  --btn-fg: var(--white);
  --btn-border: var(--accent);
}

.btn--accent:hover {
  --btn-bg: var(--accent-deep);
  --btn-border: var(--accent-deep);
}

.btn--quiet {
  min-height: 36px;
  padding: 8px 12px;
  border-color: transparent;
  font-size: 11px;
}

.btn--quiet:hover {
  --btn-bg: rgba(25, 24, 20, 0.06);
  --btn-fg: var(--ink);
  --btn-border: transparent;
}

.btn--icon {
  width: 44px;
  height: 44px;
  min-height: 44px;
  padding: 0;
  border-radius: 50%;
}

.btn .icon {
  transition: transform var(--dur) var(--ease-out);
}

.btn:hover .icon {
  transform: translate(2px, -2px);
}

.text-link {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding-bottom: 5px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.06em;
  line-height: 1.2;
}

.text-link::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 1px;
  background: currentColor;
  transform: scaleX(1);
  transform-origin: right;
  transition: transform var(--dur) var(--ease-out);
}

.text-link:hover::after {
  transform: scaleX(0.25);
}

.text-link .icon {
  transition: transform var(--dur) var(--ease-out);
}

.text-link:hover .icon {
  transform: translate(3px, -3px);
}

/* Reveal */
.reveal {
  opacity: 0;
  transform: translateY(26px);
  transition:
    opacity 800ms var(--ease-out),
    transform 800ms var(--ease-out);
  transition-delay: var(--reveal-delay, 0ms);
}

.reveal.is-visible {
  opacity: 1;
  transform: translateY(0);
}

/* Toast & spinner */
.toast {
  position: fixed;
  right: clamp(16px, 3vw, 34px);
  bottom: clamp(16px, 3vw, 34px);
  z-index: 10000;
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: min(360px, calc(100vw - 32px));
  padding: 13px 18px;
  border: 1px solid rgba(255, 253, 248, 0.14);
  border-radius: 999px;
  background: var(--ink);
  color: var(--white);
  font-size: 11px;
  line-height: 1.5;
  opacity: 0;
  transform: translateY(16px);
  pointer-events: none;
  transition:
    opacity var(--dur) ease,
    transform var(--dur) var(--ease-out);
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.toast .icon {
  width: 15px;
  height: 15px;
  color: var(--sand);
}

.toast--error {
  background: var(--danger);
}

.toast--error .icon {
  color: var(--white);
}

.spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  flex: 0 0 auto;
  border: 1.5px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 700ms linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* Not found */
.not-found-page {
  display: grid;
  min-height: 100svh;
  place-items: center;
  background: var(--paper);
}

.not-found {
  width: min(760px, calc(100vw - 48px));
  padding-block: 80px;
}

.not-found h1 {
  margin: 24px 0;
  font-family: var(--font-serif);
  font-size: clamp(50px, 9vw, 110px);
  font-weight: 500;
  letter-spacing: -0.045em;
  line-height: 1.02;
}

.not-found p {
  margin-bottom: 36px;
  color: var(--ink-soft);
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }

  .reveal {
    opacity: 1;
    transform: none;
  }
}
