/* ============================================================
   拾一·夜集 — base.css
   设计令牌 / 重置 / 排版 / 通用细节
   视觉概念：午夜纸本市集 — 墨色夜、奶油纸、朱红印章
   ============================================================ */

:root {
  /* —— 色彩 —— */
  --ink: #12100e;
  --ink-2: #191512;
  --ink-3: #221c17;
  --paper: #f4ecdf;
  --paper-2: #e9dfcf;
  --paper-3: #dcd0bd;
  --red: #e8452c;
  --red-deep: #c3341f;
  --gold: #e3b45c;
  --jade: #7f9a86;
  --text: #f4ecdf;
  --muted: #a89a88;
  --muted-2: #8a7d6c;
  --line: rgba(244, 236, 223, 0.13);
  --line-strong: rgba(244, 236, 223, 0.24);
  --line-ink: rgba(23, 19, 16, 0.16);
  --red-soft: rgba(232, 69, 44, 0.14);

  /* —— 字体 —— */
  --font-display: "Noto Serif SC", "Songti SC", "Source Han Serif SC", SimSun, Georgia, serif;
  --font-sans: "Noto Sans SC", "PingFang SC", "Microsoft YaHei", "Helvetica Neue", sans-serif;
  --font-num: "Anton", "Bebas Neue", Impact, "Haettenschweiler", "Arial Narrow Bold", sans-serif;
  --font-mono: "Space Mono", "Courier New", monospace;

  /* —— 布局 —— */
  --wrap: 1240px;
  --gutter: clamp(1.25rem, 4vw, 3rem);
  --head-h: 76px;
  --radius: 16px;
  --radius-lg: 26px;

  /* —— 动效 —— */
  --ease: cubic-bezier(0.22, 0.8, 0.24, 1);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --t-fast: 160ms;
  --t-mid: 280ms;
  --t-slow: 620ms;

  /* —— 层级 —— */
  --z-head: 100;
  --z-tab: 120;
  --z-backdrop: 240;
  --z-drawer: 260;
  --z-modal: 300;
  --z-toast: 400;
  --z-grain: 380;
}

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

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

body {
  margin: 0;
  min-width: 320px;
  background: var(--ink);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.75;
  letter-spacing: 0.01em;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

body.is-locked {
  overflow: hidden;
}

h1, h2, h3, h4, p, figure, blockquote, ul, ol {
  margin: 0;
}

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

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

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

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

button {
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

input,
select {
  -webkit-appearance: none;
  appearance: none;
}

::selection {
  background: var(--red);
  color: var(--paper);
}

:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 3px;
  border-radius: 4px;
}

::placeholder {
  color: rgba(244, 236, 223, 0.42);
}

/* 细自定义滚动条 */
* {
  scrollbar-width: thin;
  scrollbar-color: rgba(244, 236, 223, 0.22) transparent;
}
::-webkit-scrollbar {
  width: 9px;
  height: 9px;
}
::-webkit-scrollbar-thumb {
  background: rgba(244, 236, 223, 0.2);
  border-radius: 99px;
}
::-webkit-scrollbar-track {
  background: transparent;
}

/* ------------------------------ 排版工具 ------------------------------ */
.wrap {
  width: 100%;
  max-width: var(--wrap);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

.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;
}

.sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

.skip-link {
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 999;
  padding: 10px 18px;
  background: var(--paper);
  color: var(--ink);
  font-weight: 700;
  border-radius: 6px;
  transform: translateY(-150%);
  transition: transform var(--t-fast) var(--ease);
}
.skip-link:focus-visible {
  transform: none;
}

.eyebrow,
.sec-eyebrow {
  display: flex;
  align-items: center;
  gap: 0.7em;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
}

.eyebrow-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--red);
  box-shadow: 0 0 0 4px rgba(232, 69, 44, 0.16);
  flex: none;
}

.sec-title {
  font-family: var(--font-display);
  font-weight: 900;
  font-size: clamp(1.9rem, 4.4vw, 3.4rem);
  line-height: 1.16;
  letter-spacing: -0.02em;
  margin-top: 0.55rem;
}

.sec-title em,
.math-title em {
  font-style: normal;
  color: var(--red);
  position: relative;
  white-space: nowrap;
}

.sec-title em::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -0.06em;
  height: 0.08em;
  background: currentColor;
  opacity: 0.5;
  border-radius: 2px;
  transform: rotate(-0.8deg);
}

.sec-lead {
  max-width: 34em;
  color: var(--muted);
  font-size: clamp(0.95rem, 1.4vw, 1.05rem);
  line-height: 1.85;
}

.sec-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 2rem;
  margin-bottom: clamp(2rem, 4.5vw, 3.4rem);
}

.sec-note {
  max-width: 17em;
  padding-bottom: 0.5rem;
  color: var(--muted-2);
  font-size: 0.82rem;
  line-height: 1.7;
  text-align: right;
}

.sec-head--tight {
  margin-bottom: 1.8rem;
}

/* ------------------------------ 氛围层 ------------------------------ */
/* 全站颗粒：让深色背景有纸张 / 胶片质感 */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: var(--z-grain);
  pointer-events: none;
  opacity: 0.045;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 220 220'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.86' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: 220px 220px;
}

/* ------------------------------ 入场与滚动动效 ------------------------------ */
@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(26px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

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

@keyframes marquee {
  to { transform: translateX(-50%); }
}

@keyframes pop {
  0% { transform: scale(0.6); opacity: 0; }
  60% { transform: scale(1.12); }
  100% { transform: scale(1); opacity: 1; }
}

@keyframes pulse-ring {
  0% { box-shadow: 0 0 0 0 rgba(232, 69, 44, 0.4); }
  70% { box-shadow: 0 0 0 12px rgba(232, 69, 44, 0); }
  100% { box-shadow: 0 0 0 0 rgba(232, 69, 44, 0); }
}

@keyframes shake-x {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}

.stagger {
  animation: rise 0.9s var(--ease-out) both;
  animation-delay: calc(var(--d, 0) * 100ms + 100ms);
}

.reveal {
  opacity: 0;
  transform: translateY(28px);
  transition: opacity 0.8s var(--ease-out), transform 0.8s var(--ease-out);
  transition-delay: calc(var(--d, 0) * 70ms);
}

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

/* 数字使用等宽数字，避免倒计时跳动 */
.mono,
[data-cd],
.cart-count,
.calc-amount,
.receipt-rows b {
  font-variant-numeric: tabular-nums;
}

/* ------------------------------ 无障碍：减少动效 ------------------------------ */
@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;
  }
}
