/* ============================================================
   林家影像簿 — Base
   Tokens / reset / typography / primitives
   ============================================================ */

:root {
  /* Paper & ink */
  --paper:      #F3EEE3;
  --paper-1:    #FBF8F1;
  --paper-2:    #E9E1D1;
  --paper-3:    #DFD5C2;
  --ink:        #1C1914;
  --ink-2:      #4E4739;
  --ink-3:      #8A8171;
  --ink-4:      #A9A090;

  /* Accents */
  --pine:       #1E3A31;
  --pine-2:     #2B5044;
  --pine-3:     #16281F;
  --clay:       #B04A33;
  --clay-soft:  #C97A5E;

  /* Semantic */
  --ok:         #3E6B4F;
  --warn:       #9A6B1F;
  --danger:     #A33A2A;

  --line:       rgba(28, 25, 20, .14);
  --line-soft:  rgba(28, 25, 20, .08);
  --line-strong:rgba(28, 25, 20, .26);
  --line-light: rgba(251, 248, 241, .18);

  /* Type */
  --serif: "Noto Serif SC", "Songti SC", "STSong", "SimSun", Georgia, serif;
  --sans:  "Noto Sans SC", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --mono:  "SF Mono", "JetBrains Mono", "Cascadia Mono", Consolas, monospace;

  --fs-display: clamp(42px, 5.6vw, 84px);
  --fs-h1:      clamp(30px, 3.4vw, 48px);
  --fs-h2:      clamp(24px, 2.3vw, 32px);
  --fs-h3:      19px;
  --fs-body:    15.5px;
  --fs-sm:      13px;
  --fs-xs:      11.5px;

  /* Space */
  --sp-1: 4px;  --sp-2: 8px;  --sp-3: 12px; --sp-4: 16px;
  --sp-5: 24px; --sp-6: 32px; --sp-7: 48px; --sp-8: 64px;
  --sp-9: 96px; --sp-10: 128px;

  --gutter: clamp(20px, 4vw, 64px);
  --maxw: 1400px;

  /* Radius — printed matter stays close to square */
  --r-1: 2px;
  --r-2: 3px;
  --r-3: 5px;
  --r-pill: 999px;

  /* Elevation */
  --sh-1: 0 1px 2px rgba(28,25,20,.05);
  --sh-2: 0 6px 18px -8px rgba(28,25,20,.20);
  --sh-3: 0 18px 42px -18px rgba(28,25,20,.30);
  --sh-4: 0 34px 90px -30px rgba(28,25,20,.46);

  /* Motion */
  --ease: cubic-bezier(.22, .68, .28, 1);
  --ease-out: cubic-bezier(.16, 1, .3, 1);
  --t-1: 140ms;
  --t-2: 240ms;
  --t-3: 460ms;

  --grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.82' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)'/%3E%3C/svg%3E");
}

*, *::before, *::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: var(--fs-body);
  font-weight: 400;
  line-height: 1.72;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  /* hidden 会让 body 变成滚动容器，sticky 就失效了；clip 不会 */
  overflow-x: clip;
}

@supports not (overflow-x: clip) {
  /* 老浏览器退回 hidden，代价是那一代设备上吸顶失效 */
  body { overflow-x: hidden; }
}

body.is-locked { overflow: hidden; }

h1, h2, h3, h4, h5 {
  font-family: var(--serif);
  font-weight: 600;
  line-height: 1.24;
  letter-spacing: .01em;
  margin: 0;
  text-wrap: balance;
}

p { margin: 0; text-wrap: pretty; }

img { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { background: none; border: 0; padding: 0; cursor: pointer; }
ul, ol { margin: 0; padding: 0; list-style: none; }
table { border-collapse: collapse; width: 100%; }
svg { display: block; }

::selection { background: rgba(176, 74, 51, .18); }

/* Scrollbar */
* { scrollbar-width: thin; scrollbar-color: var(--paper-3) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb {
  background: var(--paper-3);
  border: 3px solid var(--paper);
  border-radius: 99px;
}
*::-webkit-scrollbar-thumb:hover { background: var(--ink-4); }

/* Focus */
:focus-visible {
  outline: 2px solid var(--clay);
  outline-offset: 3px;
  border-radius: 1px;
}
:focus:not(:focus-visible) { outline: none; }

/* ---------- Layout ---------- */
.wrap {
  width: 100%;
  max-width: var(--maxw);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

.section { padding-block: clamp(56px, 7vw, 104px); }
.section--tight { padding-block: clamp(40px, 4.6vw, 64px); }

.rule {
  height: 1px;
  background: var(--line);
  border: 0;
  margin: 0;
}

/* ---------- Type helpers ---------- */
.eyebrow {
  font-family: var(--sans);
  font-size: var(--fs-xs);
  font-weight: 500;
  letter-spacing: .22em;
  text-transform: uppercase;
  color: var(--ink-3);
  display: flex;
  align-items: center;
  gap: 10px;
}
.eyebrow::before {
  content: "";
  width: 22px;
  height: 1px;
  background: var(--line-strong);
  flex: none;
}
.eyebrow--plain::before { display: none; }

.serif { font-family: var(--serif); }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--ink-3); }
.ink-2 { color: var(--ink-2); }

.label {
  font-size: var(--fs-xs);
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--ink-3);
  font-weight: 500;
}

/* Chinese seal — used sparingly as the family mark */
.seal {
  width: 38px;
  height: 38px;
  border-radius: 3px;
  background: var(--clay);
  color: #FBF3EA;
  font-family: var(--serif);
  font-size: 19px;
  font-weight: 700;
  display: grid;
  place-items: center;
  flex: none;
  box-shadow: inset 0 0 0 1.5px rgba(251,243,234,.55), 0 2px 6px rgba(176,74,51,.28);
  letter-spacing: 0;
}

/* ---------- Buttons ---------- */
.btn {
  --btn-bg: transparent;
  --btn-fg: var(--ink);
  --btn-bd: var(--line-strong);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 20px;
  border: 1px solid var(--btn-bd);
  border-radius: var(--r-1);
  background: var(--btn-bg);
  color: var(--btn-fg);
  font-size: 13.5px;
  font-weight: 500;
  letter-spacing: .04em;
  cursor: pointer;
  transition: background var(--t-2) var(--ease), color var(--t-2) var(--ease),
              border-color var(--t-2) var(--ease), transform var(--t-1) var(--ease);
  white-space: nowrap;
  user-select: none;
}
.btn svg { width: 16px; height: 16px; flex: none; }
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }

.btn--primary {
  --btn-bg: var(--pine);
  --btn-fg: #F6F1E6;
  --btn-bd: var(--pine);
}
.btn--primary:hover { --btn-bg: var(--pine-2); --btn-bd: var(--pine-2); }

.btn--clay {
  --btn-bg: var(--clay);
  --btn-fg: #FCF5EF;
  --btn-bd: var(--clay);
}
.btn--clay:hover { --btn-bg: #9E4029; --btn-bd: #9E4029; }

.btn--ghost:hover { --btn-bg: rgba(28,25,20,.05); }

.btn--quiet {
  --btn-bd: transparent;
  padding-inline: 12px;
  color: var(--ink-2);
}
.btn--quiet:hover { --btn-bg: rgba(28,25,20,.06); }

.btn--sm { min-height: 34px; padding: 0 12px; font-size: 12.5px; }
.btn--sm svg { width: 14px; height: 14px; }
.btn--full { width: 100%; }

.btn:disabled,
.btn[aria-disabled="true"] {
  opacity: .42;
  cursor: not-allowed;
  transform: none;
}

.link-underline {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding-bottom: 2px;
  font-size: 13.5px;
}
.link-underline::after {
  content: "";
  position: absolute;
  left: 0; bottom: 0;
  width: 100%; height: 1px;
  background: currentColor;
  transform-origin: left;
  transition: transform var(--t-2) var(--ease);
}
.link-underline:hover::after { transform: scaleX(.3); }

/* ---------- Chips / tags ---------- */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 26px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: var(--r-pill);
  font-size: var(--fs-xs);
  letter-spacing: .04em;
  color: var(--ink-2);
  background: transparent;
  white-space: nowrap;
}
.chip--solid { background: var(--paper-2); border-color: transparent; }
.chip--pine { background: rgba(30,58,49,.08); border-color: rgba(30,58,49,.18); color: var(--pine); }
.chip--clay { background: rgba(176,74,51,.09); border-color: rgba(176,74,51,.22); color: var(--clay); }

.dot {
  width: 5px; height: 5px;
  border-radius: 50%;
  background: currentColor;
  flex: none;
}

/* ---------- Form ---------- */
.field { display: flex; flex-direction: column; gap: 7px; }
.field > label,
.field-label {
  font-size: 12px;
  letter-spacing: .08em;
  color: var(--ink-2);
  font-weight: 500;
}
.input, .select, .textarea {
  width: 100%;
  min-height: 42px;
  padding: 9px 12px;
  background: var(--paper-1);
  border: 1px solid var(--line);
  border-radius: var(--r-1);
  font-size: 13.5px;
  color: var(--ink);
  transition: border-color var(--t-1) var(--ease), background var(--t-1) var(--ease);
  appearance: none;
}
.input::placeholder, .textarea::placeholder { color: var(--ink-4); }
.input:hover, .select:hover, .textarea:hover { border-color: var(--line-strong); }
.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--pine);
  background: #fff;
}
.textarea { min-height: 92px; resize: vertical; line-height: 1.65; }
.select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5 6 6.5 11 1.5' fill='none' stroke='%238A8171' stroke-width='1.3' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
  cursor: pointer;
}

/* 紧凑下拉：右侧留够箭头的位置，避免压住文字 */
.imp-pick {
  width: auto;
  height: 30px;
  font-size: 12.5px;
  padding: 0 30px 0 10px;
  background-position: right 10px center;
}

.checkbox {
  appearance: none;
  width: 16px; height: 16px;
  border: 1px solid var(--line-strong);
  border-radius: 2px;
  background: var(--paper-1);
  cursor: pointer;
  flex: none;
  position: relative;
  transition: background var(--t-1) var(--ease), border-color var(--t-1) var(--ease);
}
.checkbox:checked {
  background: var(--pine);
  border-color: var(--pine);
}
.checkbox:checked::after {
  content: "";
  position: absolute;
  left: 4.5px; top: 1.5px;
  width: 4px; height: 8px;
  border: solid #F6F1E6;
  border-width: 0 1.6px 1.6px 0;
  transform: rotate(43deg);
}

/* ---------- Status ---------- */
.status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: var(--fs-xs);
  letter-spacing: .04em;
  color: var(--ink-2);
  white-space: nowrap;
}
.status::before {
  content: "";
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--ink-4);
  flex: none;
}
.status--ok::before   { background: var(--ok); }
.status--warn::before { background: var(--warn); }
.status--danger::before { background: var(--danger); }
.status--idle::before { background: var(--ink-4); }

/* ---------- Media ---------- */
.thumb {
  position: relative;
  overflow: hidden;
  background: var(--paper-2);
  border-radius: var(--r-1);
}
.thumb img {
  width: 100%; height: 100%;
  object-fit: cover;
  transition: transform var(--t-3) var(--ease-out), filter var(--t-3) var(--ease);
}
.thumb--4x3 { aspect-ratio: 4 / 3; }
.thumb--1x1 { aspect-ratio: 1 / 1; }
.thumb--3x4 { aspect-ratio: 3 / 4; }
.thumb--16x9 { aspect-ratio: 16 / 9; }

.media-badge {
  position: absolute;
  left: 8px; top: 8px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 22px;
  padding: 0 8px;
  border-radius: 2px;
  background: rgba(20,17,13,.62);
  backdrop-filter: blur(6px);
  color: #F5EFE3;
  font-size: 10.5px;
  letter-spacing: .1em;
  text-transform: uppercase;
}
.media-badge svg { width: 12px; height: 12px; }

.duration-badge {
  position: absolute;
  right: 8px; bottom: 8px;
  height: 20px;
  padding: 0 6px;
  display: inline-flex;
  align-items: center;
  border-radius: 2px;
  background: rgba(20,17,13,.66);
  color: #F5EFE3;
  font-size: 10.5px;
  font-variant-numeric: tabular-nums;
  letter-spacing: .04em;
}

/* ---------- Reveal ---------- */
.reveal {
  opacity: 0;
  transform: translateY(16px);
  transition: opacity 720ms var(--ease-out), transform 720ms var(--ease-out);
  transition-delay: var(--d, 0ms);
  will-change: opacity, transform;
}
.reveal.is-in { opacity: 1; transform: none; }

/* ---------- Utility ---------- */
.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;
}
.row { display: flex; align-items: center; }
.gap-2 { gap: 8px; } .gap-3 { gap: 12px; } .gap-4 { gap: 16px; }
.spacer { flex: 1; }
.hidden { display: none !important; }

.grain {
  position: relative;
  isolation: isolate;
}
.grain::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image: var(--grain);
  opacity: .035;
  mix-blend-mode: multiply;
  pointer-events: none;
  z-index: 1;
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }
  .reveal { opacity: 1; transform: none; }
}
