/* 我和三毛的一天 · shared design tokens and components (visitor app, console, screens) */

@font-face {
  font-family: "Sanmao Serif";
  src: url("/assets/fonts/serif-semibold.woff2?v=7") format("woff2");
  font-weight: 400 700;
  font-display: swap;
}
@font-face {
  font-family: "Sanmao Serif";
  src: url("/assets/fonts/serif-black.woff2?v=7") format("woff2");
  font-weight: 800 900;
  font-display: swap;
}

:root {
  --paper: #f6f1e3;
  --paper-2: #eee6d2;
  --paper-3: #e4d9bf;
  --card: #fffdf6;
  --ink: #1d1a17;
  --ink-2: #4a443d;
  --muted: #7a7064;
  --line: rgba(29, 26, 23, 0.14);
  --line-strong: rgba(29, 26, 23, 0.32);
  --sun: #f3d64e;
  --sun-soft: #f8e9a0;
  --sky: #4a7fc1;
  --sky-soft: #dbe6f4;
  --brick: #a4492f;
  --brick-soft: #f1d9cf;
  --leaf: #5f9d7a;
  --leaf-soft: #d9ebe0;
  --danger: #b3261e;
  --serif: "Sanmao Serif", "Songti SC", "Noto Serif SC", "Source Han Serif SC", serif;
  --sans: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", "Microsoft YaHei", sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --r-s: 8px;
  --r-m: 14px;
  --r-l: 22px;
  --shadow-1: 0 1px 2px rgba(29, 26, 23, 0.08), 0 2px 8px rgba(29, 26, 23, 0.06);
  --shadow-2: 0 6px 24px rgba(29, 26, 23, 0.16), 0 2px 6px rgba(29, 26, 23, 0.08);
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
  --ease-out-back: cubic-bezier(0.34, 1.56, 0.64, 1);
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--sans);
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  text-rendering: optimizeLegibility;
  line-height: 1.55;
}
img, svg, canvas, video { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--sky); }
:focus-visible { outline: 3px solid var(--sky); outline-offset: 2px; border-radius: 6px; }
[hidden] { display: none !important; }
.phrase { word-break: keep-all; overflow-wrap: anywhere; text-wrap: balance; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.serif { font-family: var(--serif); }
h1, h2, h3, .title { font-family: var(--serif); font-weight: 700; line-height: 1.25; margin: 0; letter-spacing: 0.01em; }
h1 { font-size: 28px; }
h2 { font-size: 21px; }
h3 { font-size: 17px; }
p { margin: 0; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.tiny { font-size: 11.5px; }
.mono { font-family: var(--mono); font-size: 0.92em; }
.stack > * + * { margin-top: var(--gap, 12px); }
.row { display: flex; align-items: center; gap: var(--gap, 10px); }
.row.wrap { flex-wrap: wrap; }
.grow { flex: 1 1 auto; min-width: 0; }
.nowrap { white-space: nowrap; flex: none; }
.center { text-align: center; }

/* paper texture: subtle fibres, no image request */
.paper {
  background-color: var(--paper);
  background-image:
    radial-gradient(rgba(29, 26, 23, 0.035) 1px, transparent 1.2px),
    radial-gradient(rgba(164, 73, 47, 0.025) 1px, transparent 1.4px);
  background-size: 7px 7px, 13px 13px;
  background-position: 0 0, 3px 5px;
}

/* ---- buttons ------------------------------------------------------------------------------------ */
.btn {
  --bg: var(--ink); --fg: var(--paper); --bd: var(--ink);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 22px; border-radius: 999px;
  border: 2px solid var(--bd); background: var(--bg); color: var(--fg);
  font-family: var(--serif); font-weight: 700; font-size: 17px; letter-spacing: 0.04em; text-decoration: none;
  transition: transform 0.15s var(--ease), background 0.2s, box-shadow 0.2s, opacity 0.2s;
  box-shadow: 0 3px 0 rgba(29, 26, 23, 0.85);
  user-select: none; -webkit-user-select: none; touch-action: manipulation;
}
.btn:active { transform: translateY(2px); box-shadow: 0 1px 0 rgba(29, 26, 23, 0.85); }
.btn[disabled] { opacity: 0.45; pointer-events: none; }
.btn.sun { --bg: var(--sun); --fg: var(--ink); }
.btn.brick { --bg: var(--brick); --fg: #fff; --bd: var(--ink); }
.btn.ghost { --bg: transparent; --fg: var(--ink); box-shadow: none; }
.btn.light { --bg: var(--card); --fg: var(--ink); }
.btn.small { min-height: 36px; padding: 0 14px; font-size: 14px; box-shadow: 0 2px 0 rgba(29, 26, 23, 0.85); }
.btn.block { display: flex; width: 100%; }
.btn.icon { width: 44px; min-height: 44px; padding: 0; border-radius: 50%; font-size: 20px; }
.btn.busy { position: relative; color: transparent !important; }
.btn.busy::after {
  content: ""; position: absolute; width: 18px; height: 18px; border-radius: 50%;
  border: 2.5px solid var(--fg); border-right-color: transparent; animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.link-btn { background: none; border: 0; padding: 6px 4px; color: var(--ink-2); text-decoration: underline; text-underline-offset: 3px; font-size: 14px; }

/* ---- chips, tags, labels ----------------------------------------------------------------------- */
.chip {
  display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 10px; border-radius: 999px;
  font-size: 12.5px; font-weight: 600; background: var(--paper-2); color: var(--ink-2); border: 1px solid var(--line);
  white-space: nowrap;
}
.chip.ink { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.chip.sun { background: var(--sun); color: var(--ink); border-color: rgba(29, 26, 23, 0.25); }
.chip.leaf { background: var(--leaf-soft); color: #2e5e43; border-color: rgba(95, 157, 122, 0.4); }
.chip.sky { background: var(--sky-soft); color: #234d7f; border-color: rgba(74, 127, 193, 0.35); }
.chip.brick { background: var(--brick-soft); color: #7b2f1b; border-color: rgba(164, 73, 47, 0.35); }

/* content labels (中期方案 · 内容标签): 史料 / 体验改编 / 剧情演绎 / 示例作品 / 交互示意 */
.label {
  display: inline-flex; align-items: center; gap: 4px; height: 22px; padding: 0 8px; border-radius: 4px;
  font-size: 11.5px; font-weight: 700; letter-spacing: 0.06em; border: 1.5px solid currentColor; background: transparent;
  cursor: pointer; width: fit-content; justify-self: start; flex: none; white-space: nowrap;
}
.label[data-kind="史料"] { color: #7b2f1b; }
.label[data-kind="体验改编"] { color: #234d7f; }
.label[data-kind="剧情演绎"] { color: #2e5e43; }
.label[data-kind="示例作品"] { color: #7a5a00; }
.label[data-kind="交互示意"] { color: var(--muted); }
.label::after { content: "ⓘ"; font-weight: 400; opacity: 0.7; }

/* ---- cards & surfaces ---------------------------------------------------------------------------- */
.card {
  background: var(--card); border: 2px solid var(--ink); border-radius: var(--r-l);
  box-shadow: 4px 5px 0 rgba(29, 26, 23, 0.9); padding: 18px;
}
.card.soft { border: 1px solid var(--line); box-shadow: var(--shadow-1); }
.hr { height: 1px; background: var(--line); border: 0; margin: 14px 0; }

/* ---- bottom sheet / modal -------------------------------------------------------------------------- */
.scrim {
  position: fixed; inset: 0; background: rgba(29, 26, 23, 0.42); z-index: 80;
  opacity: 0; transition: opacity 0.25s var(--ease); backdrop-filter: blur(2px); -webkit-backdrop-filter: blur(2px);
}
.scrim.open { opacity: 1; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 81; max-height: 88vh; overflow: auto;
  background: var(--card); border-top: 2px solid var(--ink); border-radius: 24px 24px 0 0;
  padding: 10px 20px calc(22px + var(--safe-b)); transform: translateY(105%); transition: transform 0.32s var(--ease);
  overscroll-behavior: contain;
}
.sheet.open { transform: none; }
.sheet .grip { width: 44px; height: 5px; border-radius: 3px; background: var(--line-strong); margin: 4px auto 12px; }
.sheet .sheet-title { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
@media (min-width: 720px) {
  .sheet { left: 50%; right: auto; width: 560px; bottom: 50%; border: 2px solid var(--ink); border-radius: 24px;
    transform: translate(-50%, 60%) scale(0.96); opacity: 0; transition: transform 0.28s var(--ease), opacity 0.2s; }
  .sheet.open { transform: translate(-50%, 50%); opacity: 1; }
}

/* ---- toasts ---------------------------------------------------------------------------------------- */
.toasts { position: fixed; left: 0; right: 0; top: calc(10px + var(--safe-t)); z-index: 120; display: grid; justify-items: center; gap: 8px; pointer-events: none; }
.toast {
  pointer-events: auto; max-width: min(92vw, 460px); padding: 10px 16px; border-radius: 14px;
  background: var(--ink); color: var(--paper); font-size: 14.5px; box-shadow: var(--shadow-2);
  animation: toast-in 0.28s var(--ease-out-back);
}
.toast.warn { background: var(--brick); }
.toast.ok { background: #2e5e43; }
.toast.out { animation: toast-out 0.22s var(--ease) forwards; }
@keyframes toast-in { from { transform: translateY(-14px) scale(0.96); opacity: 0; } }
@keyframes toast-out { to { transform: translateY(-10px); opacity: 0; } }

/* ---- form controls ------------------------------------------------------------------------------- */
.field { display: grid; gap: 6px; }
.field > span { font-size: 13px; color: var(--ink-2); font-weight: 600; }
.input, select.input, textarea.input {
  width: 100%; min-height: 44px; padding: 10px 12px; border-radius: 12px; border: 1.5px solid var(--line-strong);
  background: #fff; outline: none; transition: border-color 0.15s, box-shadow 0.15s;
}
.input:focus { border-color: var(--sky); box-shadow: 0 0 0 3px rgba(74, 127, 193, 0.2); }
textarea.input { min-height: 90px; resize: vertical; }
.switch { position: relative; width: 52px; height: 30px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch span { position: absolute; inset: 0; border-radius: 999px; background: var(--paper-3); border: 2px solid var(--ink); transition: background 0.2s; }
.switch span::after { content: ""; position: absolute; top: 2px; left: 2px; width: 22px; height: 22px; border-radius: 50%; background: #fff; border: 2px solid var(--ink); transition: transform 0.2s var(--ease); }
.switch input:checked + span { background: var(--leaf); }
.switch input:checked + span::after { transform: translateX(22px); }

/* ---- motion preferences ----------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}
