/* ==========================================================================
   鸣雀 ID · Base: reset, typography, texture, layout primitives
   ========================================================================== */

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-padding-top: 96px;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.75;
  letter-spacing: 0.01em;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

/* 噪点／细网格：Art Deco 的纸面质感，纯 CSS/SVG，无图片依赖 */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-image: var(--noise);
  opacity: var(--noise-opacity);
  mix-blend-mode: multiply;
}

[data-theme='dark'] body::before,
:root:not([data-theme='light']) body::before {
  mix-blend-mode: screen;
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme='dark']) body::before {
    mix-blend-mode: multiply;
  }
}

body::after {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-image: repeating-linear-gradient(
    90deg,
    transparent 0,
    transparent calc(100% - 1px),
    var(--line) calc(100% - 1px),
    var(--line) 100%
  );
  background-size: 88px 100%;
  opacity: 0.45;
  mask-image: linear-gradient(180deg, transparent, #000 18%, #000 82%, transparent);
}

.shell {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

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

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

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

a {
  color: var(--teal-ink);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

a:hover {
  color: var(--gold-ink);
}

::selection {
  background: var(--gold);
  color: var(--ink);
}

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

:focus:not(:focus-visible) {
  outline: none;
}

h1,
h2,
h3,
h4 {
  margin: 0;
  font-family: var(--font-serif);
  font-weight: 400;
  line-height: 1.18;
  letter-spacing: 0.02em;
  color: var(--fg);
  text-wrap: balance;
}

h1 {
  font-size: clamp(2.5rem, 6.4vw, 5.25rem);
  line-height: 1.06;
  letter-spacing: 0.015em;
}

h2 {
  font-size: clamp(1.75rem, 3.2vw, 2.5rem);
}

h3 {
  font-size: clamp(1.125rem, 1.8vw, 1.375rem);
}

p {
  margin: 0;
  max-width: 68ch;
  text-wrap: pretty;
}

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

table {
  border-collapse: collapse;
  width: 100%;
}

code,
kbd,
samp {
  font-family: var(--font-mono);
  font-size: 0.875em;
}

hr {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 0;
}

[hidden] {
  display: none !important;
}

/* ---- layout primitives ---------------------------------------------- */

.wrap {
  width: 100%;
  max-width: 1360px;
  margin-inline: auto;
  padding-inline: clamp(20px, 5vw, 88px);
}

.wrap--narrow {
  max-width: 980px;
}

.grid12 {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 24px;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: var(--s-4);
}

.row {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  flex-wrap: wrap;
}

.spread {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-4);
  flex-wrap: wrap;
}

.section {
  padding-block: clamp(56px, 8vw, 128px);
  position: relative;
}

.section--flush {
  padding-block: 0;
}

/* ---- editorial type helpers ---------------------------------------- */

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 14px;
  font-family: var(--font-display);
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--gold-ink);
  line-height: 1.4;
}

.eyebrow::before {
  content: '';
  width: 34px;
  height: 1px;
  background: var(--gold);
  flex: none;
}

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

.display {
  font-family: var(--font-display);
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.serif {
  font-family: var(--font-serif);
}

.mono {
  font-family: var(--font-mono);
}

.tnum {
  font-variant-numeric: tabular-nums;
  font-feature-settings: 'tnum' 1;
}

.muted {
  color: var(--fg-muted);
}

.faint {
  color: var(--fg-faint);
}

.small {
  font-size: 0.8125rem;
  line-height: 1.65;
}

.tiny {
  font-size: 0.75rem;
  line-height: 1.55;
}

.gold-text {
  color: var(--gold-ink);
}

.teal-text {
  color: var(--teal-ink);
}

.rule {
  height: 1px;
  border: 0;
  background: linear-gradient(90deg, transparent, var(--gold) 12%, var(--gold) 88%, transparent);
  opacity: 0.55;
}

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

/* Art Deco 章节编号 */
.deco-num {
  font-family: var(--font-display);
  font-size: clamp(2.75rem, 5vw, 4.25rem);
  font-weight: 400;
  line-height: 0.8;
  letter-spacing: 0.02em;
  color: transparent;
  -webkit-text-stroke: 1px var(--gold);
  opacity: 0.85;
  user-select: none;
}

/* 双线框（Art Deco 的经典收口） */
.frame {
  position: relative;
  border: 1px solid var(--line-strong);
  padding: var(--s-6);
}

.frame::before {
  content: '';
  position: absolute;
  inset: 5px;
  border: 1px solid var(--line);
  pointer-events: none;
}

.frame--gold {
  border-color: var(--gold);
}

.frame--gold::before {
  border-color: color-mix(in srgb, var(--gold) 42%, transparent);
}

.step-corners {
  position: relative;
}

.step-corners::before,
.step-corners::after {
  content: '';
  position: absolute;
  width: 18px;
  height: 18px;
  border-color: var(--gold);
  border-style: solid;
  opacity: 0.75;
  pointer-events: none;
}

.step-corners::before {
  top: -1px;
  left: -1px;
  border-width: 1px 0 0 1px;
}

.step-corners::after {
  bottom: -1px;
  right: -1px;
  border-width: 0 1px 1px 0;
}

/* ---- accessibility -------------------------------------------------- */

.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;
  transform: translateY(-180%);
  background: var(--bg-2);
  border: 1px solid var(--gold);
  padding: 10px 16px;
  font-size: 0.875rem;
  color: var(--fg);
  transition: transform var(--dur-1) var(--ease);
}

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

/* ---- route transition ---------------------------------------------- */

.route-enter {
  animation: route-in var(--dur-2) var(--ease) both;
}

@keyframes route-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.stagger > * {
  animation: route-in var(--dur-3) var(--ease) both;
}

.stagger > *:nth-child(1) {
  animation-delay: 0ms;
}
.stagger > *:nth-child(2) {
  animation-delay: 40ms;
}
.stagger > *:nth-child(3) {
  animation-delay: 80ms;
}
.stagger > *:nth-child(4) {
  animation-delay: 120ms;
}
.stagger > *:nth-child(5) {
  animation-delay: 160ms;
}
.stagger > *:nth-child(6) {
  animation-delay: 200ms;
}

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

/* ---- responsive visibility ----------------------------------------- */

.only-mobile {
  display: none !important;
}

@media (max-width: 900px) {
  .only-mobile {
    display: initial !important;
  }
  .hide-mobile {
    display: none !important;
  }
  .grid12 {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 16px;
  }
}

@media (max-width: 560px) {
  .grid12 {
    grid-template-columns: 1fr;
    gap: 14px;
  }
}
