/* ========================================================================
   曦儿（陈冬兰）艺术文献库 — Xier (Chen Donglan) Art Archive
   Design tokens & global styles
   ======================================================================== */

:root {
  /* Warm white palette */
  --paper:        oklch(0.985 0.008 75);   /* main warm ivory */
  --paper-2:      oklch(0.965 0.012 70);   /* card surface */
  --paper-3:      oklch(0.94  0.014 68);   /* divider band */
  --paper-deep:   oklch(0.91  0.016 65);   /* deepest warm tint */

  /* Ink */
  --ink:          oklch(0.18 0.008 60);    /* primary text */
  --ink-2:        oklch(0.34 0.008 60);    /* secondary text */
  --ink-3:        oklch(0.52 0.006 60);    /* tertiary / caption */
  --ink-4:        oklch(0.72 0.005 60);    /* hairline text */

  /* Single accent — refined cinnabar (朱砂) */
  --accent:       oklch(0.54 0.14 28);
  --accent-soft:  oklch(0.78 0.07 28);

  /* Hairline */
  --line:         oklch(0.85 0.01 65);
  --line-soft:    oklch(0.92 0.008 65);

  /* Type */
  --serif-zh: "Noto Serif SC", "Songti SC", "STSong", "FangSong", "Source Han Serif SC", serif;
  --sans-zh:  "Noto Sans SC", "PingFang SC", "Hiragino Sans GB", sans-serif;
  --serif-en: "Cormorant Garamond", "EB Garamond", "Times New Roman", serif;
  --sans-en:  "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --mono:     "JetBrains Mono", "IBM Plex Mono", ui-monospace, monospace;

  /* Motion */
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);
  --ease-art: cubic-bezier(0.4, 0.0, 0.1, 1);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--serif-en), var(--serif-zh);
  font-weight: 400;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  position: relative;
  padding-left: env(safe-area-inset-left, 0);
  padding-right: env(safe-area-inset-right, 0);
  padding-bottom: env(safe-area-inset-bottom, 0);
}

/* Prevent page scroll when mobile nav drawer is open */
body.nav-open {
  overflow: hidden;
  touch-action: none;
}

/* Lang-aware default font */
[lang="zh"] body, body[data-lang="zh"] {
  font-family: var(--serif-zh);
}
body[data-lang="en"] {
  font-family: var(--serif-en), var(--serif-zh);
}

a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: none; cursor: pointer; }
img { max-width: 100%; display: block; }

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

/* Subtle paper grain */
body::before {
  content: "";
  position: fixed; inset: 0;
  pointer-events: none;
  z-index: 1;
  background-image:
    radial-gradient(circle at 20% 30%, oklch(0.94 0.02 70 / 0.4), transparent 50%),
    radial-gradient(circle at 80% 70%, oklch(0.94 0.02 65 / 0.3), transparent 55%);
  mix-blend-mode: multiply;
  opacity: 0.7;
}

body::after {
  content: "";
  position: fixed; inset: 0;
  pointer-events: none;
  z-index: 2;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='200' height='200'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0.1  0 0 0 0 0.08  0 0 0 0 0.05  0 0 0 0.06 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
  opacity: 0.55;
}

/* Layout */
.container {
  width: 100%;
  max-width: 1480px;
  margin: 0 auto;
  padding: 0 clamp(24px, 4vw, 72px);
  position: relative;
  z-index: 5;
}

@media (max-width: 600px) {
  .container,
  .container--narrow {
    padding: 0 clamp(16px, 5vw, 28px);
  }
}

.container--narrow {
  max-width: 1100px;
}

/* Type */
.eyebrow {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--ink-3);
  display: inline-flex;
  align-items: center;
  gap: 12px;
}
.eyebrow::before {
  content: "";
  width: 28px; height: 1px;
  background: var(--ink-3);
  display: inline-block;
}

.display {
  font-family: var(--serif-en);
  font-weight: 300;
  font-style: italic;
  line-height: 0.95;
  letter-spacing: -0.02em;
}
[data-lang="zh"] .display {
  font-family: var(--serif-zh);
  font-weight: 300;
  font-style: normal;
  letter-spacing: 0.02em;
}

.h-section {
  font-family: var(--serif-en);
  font-style: italic;
  font-weight: 300;
  font-size: clamp(40px, 6vw, 88px);
  line-height: 1;
  letter-spacing: -0.015em;
}
[data-lang="zh"] .h-section {
  font-family: var(--serif-zh);
  font-style: normal;
  font-weight: 300;
  letter-spacing: 0.04em;
}

.body-text {
  font-family: var(--sans-en), var(--sans-zh);
  font-size: 15px;
  line-height: 1.7;
  color: var(--ink-2);
  font-weight: 400;
}
[data-lang="zh"] .body-text {
  font-family: var(--sans-zh);
}

/* Reveal animations */
.reveal {
  opacity: 0;
  transform: translateY(30px);
  transition: opacity 1.2s var(--ease-out), transform 1.2s var(--ease-out);
}
.reveal.is-in {
  opacity: 1;
  transform: translateY(0);
}

.reveal-line {
  display: inline-block;
  overflow: hidden;
  vertical-align: top;
}
.reveal-line > span {
  display: inline-block;
  transform: translateY(110%);
  transition: transform 1.4s var(--ease-out);
}
.reveal-line.is-in > span {
  transform: translateY(0);
}

@media (prefers-reduced-motion: reduce) {
  .reveal,
  .reveal.is-in,
  .reveal-line > span,
  .reveal-line.is-in > span {
    transition: none;
    transform: none;
    opacity: 1;
  }
}

/* Cursor */
.cursor-dot {
  position: fixed;
  pointer-events: none;
  z-index: 9999;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--accent);
  transform: translate(-50%, -50%);
  transition: transform 0.18s var(--ease-out), width 0.3s, height 0.3s, background 0.3s;
  mix-blend-mode: multiply;
}
.cursor-ring {
  position: fixed;
  pointer-events: none;
  z-index: 9998;
  width: 36px; height: 36px;
  border-radius: 50%;
  border: 1px solid var(--ink-3);
  transform: translate(-50%, -50%);
  transition: transform 0.4s var(--ease-out), width 0.4s, height 0.4s, border-color 0.3s;
}
body.cursor-hover .cursor-dot { width: 4px; height: 4px; }
body.cursor-hover .cursor-ring { width: 64px; height: 64px; border-color: var(--accent); }

@media (hover: none) {
  .cursor-dot, .cursor-ring { display: none; }
}

/* Loader */
.loader {
  position: fixed; inset: 0;
  background: var(--paper);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 32px;
  transition: opacity 0.9s var(--ease-out), visibility 0.9s;
}
.loader.is-out {
  opacity: 0;
  visibility: hidden;
}
.loader__seal {
  width: 48px; height: 48px;
  position: relative;
}
.loader__seal::before, .loader__seal::after {
  content: "";
  position: absolute; inset: 0;
  border: 1px solid var(--ink);
}
.loader__seal::after {
  background: var(--accent);
  inset: 6px;
  animation: sealPulse 1.6s var(--ease-in-out) infinite;
}
@keyframes sealPulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(0.6); opacity: 0.4; }
}
.loader__count {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.3em;
  color: var(--ink-3);
}

/* Page transition curtain */
.curtain {
  position: fixed; inset: 0;
  background: var(--ink);
  z-index: 9000;
  pointer-events: none;
  transform: translateY(100%);
}
.curtain.is-up { animation: curtainUp 1.1s var(--ease-art) forwards; }
.curtain.is-down { animation: curtainDown 1.1s var(--ease-art) forwards; }
@keyframes curtainUp {
  0% { transform: translateY(100%); }
  50% { transform: translateY(0); }
  100% { transform: translateY(-100%); }
}
@keyframes curtainDown {
  0% { transform: translateY(100%); }
  100% { transform: translateY(0); }
}

/* Buttons */
.btn-line {
  display: inline-flex;
  align-items: center;
  gap: 14px;
  padding: 14px 0;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--ink);
  position: relative;
  overflow: hidden;
}
.btn-line::after {
  content: "";
  position: absolute; left: 0; right: 0; bottom: 0;
  height: 1px;
  background: var(--ink);
  transform: scaleX(1);
  transform-origin: right;
  transition: transform 0.6s var(--ease-out);
}
.btn-line:hover::after {
  transform: scaleX(0);
  transform-origin: left;
}
.btn-line .arrow {
  display: inline-block;
  transition: transform 0.4s var(--ease-out);
}
.btn-line:hover .arrow { transform: translateX(6px); }

/* Scroll progress */
.scroll-progress {
  position: fixed;
  bottom: 0; left: 0;
  width: 100%;
  height: 1px;
  background: transparent;
  z-index: 100;
  pointer-events: none;
}
.scroll-progress__bar {
  height: 100%;
  width: 0%;
  background: var(--accent);
  transition: width 0.1s linear;
}

/* Placeholder image */
.ph {
  position: relative;
  background: var(--paper-2);
  overflow: hidden;
  border: 1px solid var(--line-soft);
}
.ph::before {
  content: "";
  position: absolute; inset: 0;
  background-image: repeating-linear-gradient(
    135deg,
    transparent 0,
    transparent 14px,
    oklch(0.88 0.01 65 / 0.55) 14px,
    oklch(0.88 0.01 65 / 0.55) 15px
  );
}
.ph__label {
  position: absolute;
  bottom: 14px; left: 14px; right: 14px;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-3);
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

/* Hide scrollbar styling */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--line); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--ink-3); }

/* Touch: avoid relying on hover for affordances */
@media (hover: none) and (pointer: coarse) {
  .btn-line:hover::after { transform: scaleX(1); }
  .btn-line:hover .arrow { transform: none; }
}
