/* ---------------------------------------------------------------
   网站入口：只有这本书的封面。

   配色 / 纸纹 / 布纹 / 字体全部沿用 App 的那一套（tokens.css + book.css），
   只是把"手机屏"换成"浏览器窗口"，所以单位用 vw / vh，书里的字号
   仍按书本身的宽度算（容器单位 cqw），比例才不会换一台机器就变。

   动效只碰 transform / opacity：
     · 整本书极慢地浮一下（9 秒一个来回，幅度 5px，只是让它别像一张图）
     · 底下那行提示 420ms 后轻轻浮出来
   系统要求减少动效时，两样都关掉。
   --------------------------------------------------------------- */

@font-face {
  font-family: "Cormorant Cover";
  src: url("/fonts/cormorant-garamond-cover.woff2") format("woff2");
  font-weight: 500 600;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Great Vibes Cover";
  src: url("/fonts/great-vibes-cover.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: block;
}

:root {
  color-scheme: light;

  --paper: #fbf7f0;
  --paper-2: #f4ede1;
  --paper-3: #ece0cf;
  --ink: #2c2723;
  --ink-2: #5e564d;
  --ink-3: #9a9084;

  --line: rgba(44, 39, 35, 0.12);
  --line-strong: rgba(44, 39, 35, 0.22);
  --paper-glass: rgba(251, 247, 240, 0.72);
  --paper-edge: #e6d8c4;

  --clay: #a6534a;

  /* 硬书壳：陶土红布面 + 烫金 */
  --cover-1: #7f423a;
  --cover-2: #582a25;
  --cover-ink: #f4e8d6;
  --cover-foil: #d9b071;
  --cover-line: rgba(244, 232, 214, 0.3);
  --cover-line-soft: rgba(244, 232, 214, 0.14);

  /* 纸纹 / 布纹：跟 App 里同一份噪点 */
  --paper-grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)' opacity='0.05'/%3E%3C/svg%3E");
  --cloth-grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='1.15' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='120' height='120' filter='url(%23n)' opacity='0.08'/%3E%3C/svg%3E");

  --glow: rgba(255, 255, 255, 0.62);

  --font-sans: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei",
    system-ui, sans-serif;
  --font-display: "Cormorant Cover", "Iowan Old Style", "Palatino Linotype", "Book Antiqua", Palatino,
    Georgia, "Times New Roman", serif;
  --font-script: "Great Vibes Cover", "Cormorant Cover", "Iowan Old Style", "Palatino Linotype", Palatino,
    Georgia, "Times New Roman", serif;

  --ease-out: cubic-bezier(0.2, 0.7, 0.2, 1);
  --radius-pill: 999px;
  --inner-top: inset 0 1px 0 rgba(255, 255, 255, 0.55);
  --shadow-1: 0 1px 2px rgba(44, 39, 35, 0.05), 0 1px 1px rgba(44, 39, 35, 0.03);
}

/* 暗色：灯下看同一本书。只换值，不换名字（与 App 的暗色 token 对齐） */
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;

    --paper: #14110e;
    --paper-2: #1c1814;
    --paper-3: #241d17;
    --ink: #efe7da;
    --ink-2: #b6aba0;
    --ink-3: #8a8075;

    --line: rgba(239, 231, 218, 0.14);
    --line-strong: rgba(239, 231, 218, 0.26);
    --paper-glass: rgba(20, 17, 14, 0.72);
    --paper-edge: #2e251d;

    --clay: #c97b6c;

    --cover-1: #8a4a41;
    --cover-2: #61302a;
    --cover-ink: #f7ecdc;
    --cover-foil: #e3bd7f;
    --cover-line: rgba(247, 236, 220, 0.32);
    --cover-line-soft: rgba(247, 236, 220, 0.15);

    --glow: rgba(255, 236, 210, 0.06);

    --inner-top: inset 0 1px 0 rgba(255, 255, 255, 0.06);
    --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.32), 0 1px 1px rgba(0, 0, 0, 0.18);
  }
}

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

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background:
    var(--paper-grain),
    radial-gradient(62% 46% at 50% 44%, var(--glow), transparent 70%),
    linear-gradient(180deg, var(--paper) 0%, var(--paper-2) 62%, var(--paper-3) 100%);
  color: var(--ink);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
}

/* ---------------- 整页 ---------------- */

.site {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 100vh;
  min-height: 100dvh;
  padding: 6vh 0 calc(64px + env(safe-area-inset-bottom, 0px));
  overflow: hidden;
}

/* ---------------- 书 ---------------- */

.site__scene {
  position: relative;
  /* 高度也要能塞进窗口：书高 = 宽 / 0.74，留出提示胶囊与页脚的位置 */
  width: min(80vw, calc((100vh - 170px) * 0.74), 400px);
  width: min(80vw, calc((100dvh - 170px) * 0.74), 400px);
  animation: site-float 9s cubic-bezier(0.45, 0, 0.55, 1) infinite;
}

/* 桌面上的落影：贴着书底，别飘在书一半的地方 */
.site__scene::after {
  content: "";
  position: absolute;
  right: 2%;
  bottom: -5.5%;
  left: 2%;
  z-index: -1;
  height: 13%;
  border-radius: 50%;
  background: radial-gradient(50% 50% at 50% 50%, rgba(20, 17, 14, 0.42), transparent 72%);
  filter: blur(1px);
  pointer-events: none;
}

@keyframes site-float {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-5px);
  }
}

/* 字号按"书本身的宽度"算（与 App 的 16.4cqw / 390px 屏一致） */
.site__book {
  position: relative;
  width: 100%;
  aspect-ratio: 0.74;
  container-type: size;
}

/* 合着的书页块：在右侧与下沿露一点纸边，书才有厚度 */
.site__stack {
  position: absolute;
  inset: 4px -5px -4px 4px;
  border-radius: 4px 8px 8px 4px;
  background:
    repeating-linear-gradient(90deg, var(--paper-3) 0 1px, var(--paper-2) 1px 3px),
    var(--paper-3);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.4) inset,
    0 8px 16px -12px rgba(20, 17, 14, 0.55),
    0 2px 0 -1px var(--paper-edge);
  pointer-events: none;
}

/* ---------------- 硬书壳 ---------------- */

.book-leaf {
  position: absolute;
  inset: 0;
  overflow: hidden;
}

.book-leaf--hardcover {
  inset: 2px 2px 1px;
  border-radius: 5px;
  color: var(--cover-ink);
  background:
    var(--cloth-grain),
    repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.028) 0 1px, transparent 1px 3px),
    repeating-linear-gradient(90deg, rgba(0, 0, 0, 0.05) 0 1px, transparent 1px 3px),
    radial-gradient(120% 100% at 50% -8%, rgba(255, 255, 255, 0.1), transparent 55%),
    radial-gradient(120% 95% at 50% 116%, rgba(0, 0, 0, 0.42), transparent 62%),
    linear-gradient(160deg, var(--cover-1), var(--cover-2));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.16),
    inset 0 0 0 1px rgba(0, 0, 0, 0.12),
    inset 0 -18px 26px -22px rgba(0, 0, 0, 0.7),
    0 1px 0 rgba(20, 17, 14, 0.45),
    0 14px 26px -14px rgba(20, 17, 14, 0.62);
}

/* 装订沟：靠书脊那一条更深的竖影 */
.book-leaf--hardcover::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  z-index: 2;
  width: 13px;
  border-radius: 5px 0 0 5px;
  background: linear-gradient(90deg, rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0.14) 62%, rgba(255, 255, 255, 0.09));
  pointer-events: none;
}

/* 布面上一道斜光：从左上方掠过，像书真的摆在桌上 */
.book-leaf--hardcover::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  border-radius: 5px;
  background: linear-gradient(
    128deg,
    rgba(255, 255, 255, 0.09) 0%,
    rgba(255, 255, 255, 0.03) 26%,
    transparent 46%,
    rgba(0, 0, 0, 0.06) 84%
  );
  pointer-events: none;
}

/* 压凹双框 */
.hardcover__frame {
  position: absolute;
  inset: 10px;
  z-index: 1;
  border: 1px solid var(--cover-line);
  border-radius: 2px;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.22), 0 0 0 1px rgba(0, 0, 0, 0.06);
  pointer-events: none;
}

.hardcover__frame::after {
  content: "";
  position: absolute;
  inset: 4px;
  border: 1px solid var(--cover-line-soft);
  border-radius: 1px;
}

.hardcover__face {
  position: absolute;
  inset: 10px;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 30px 18px 34px;
  text-align: center;
}

/* 饰线：一条细横线，中间一枚金色小菱形 */
.hardcover__ornament {
  position: relative;
  width: clamp(34px, 17cqw, 54px);
  height: 1px;
  margin-bottom: 2px;
  background: linear-gradient(90deg, transparent, var(--cover-line) 22%, var(--cover-line) 78%, transparent);
}

.hardcover__ornament::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 5px;
  height: 5px;
  transform: translate(-50%, -50%) rotate(45deg);
  background: var(--cover-foil);
  box-shadow: 0 0 6px rgba(217, 176, 113, 0.35);
}

/* 书名：花体手写，压凹——上缘吃光、下缘一道浅影 */
.hardcover__title {
  margin: 0;
  padding-inline: 4px;
  color: var(--cover-ink);
  font-family: var(--font-script);
  font-size: clamp(26px, 20.4cqw, 78px);
  font-weight: 400;
  line-height: 1.16;
  letter-spacing: 0;
  font-feature-settings: "liga" 1, "dlig" 1;
  text-shadow: 0 -1px 0 rgba(255, 255, 255, 0.08), 0 1px 0 rgba(0, 0, 0, 0.5);
}

.hardcover__credit {
  display: flex;
  align-items: baseline;
  gap: 0.7em;
  margin: 0;
  color: rgba(244, 232, 214, 0.86);
  /* 横屏 / 小屏上不许把「LX & LZR」折成两行 */
  white-space: nowrap;
}

.hardcover__credit-label {
  font-family: var(--font-script);
  font-size: clamp(8px, 3.5cqw, 11px);
  font-weight: 400;
  letter-spacing: 0.1em;
  text-indent: 0.1em;
  opacity: 0.78;
}

.hardcover__credit-names {
  color: var(--cover-ink);
  font-family: var(--font-script);
  font-size: clamp(10px, 5.1cqw, 16px);
  font-weight: 400;
  letter-spacing: 0.3em;
  text-indent: 0.3em;
}

.hardcover__credit-names em {
  padding: 0 0.12em;
  color: var(--cover-foil);
  font-style: normal;
}

/* 下沿那行烫金小字 */
.hardcover__press {
  position: absolute;
  right: 0;
  bottom: 12px;
  left: 0;
  margin: 0;
  color: var(--cover-foil);
  font-family: var(--font-display);
  font-size: clamp(8px, 3.8cqw, 12px);
  letter-spacing: 0.26em;
  text-indent: 0.26em;
  opacity: 0.92;
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.35);
}

/* ---------------- 请在 App 里打开 ---------------- */

.site__hit {
  display: inline-flex;
  margin-top: clamp(20px, 4vh, 38px);
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.site__hint {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  height: 42px;
  padding: 0 20px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-pill);
  background: var(--paper-glass);
  color: var(--ink-2);
  font-size: 12px;
  letter-spacing: 0.18em;
  text-indent: 0.18em;
  white-space: nowrap;
  box-shadow: var(--inner-top), var(--shadow-1);
  opacity: 0;
  transform: translateY(5px);
  transition:
    opacity 620ms var(--ease-out) 60ms,
    transform 620ms var(--ease-out) 60ms,
    border-color 320ms var(--ease-out),
    background-color 320ms var(--ease-out);
}

/* 行首一枚陶土红小菱形，跟封面饰件同一个语汇 */
.site__hint::before {
  content: "";
  width: 5px;
  height: 5px;
  transform: rotate(45deg);
  background: var(--clay);
  opacity: 0.55;
}

.site__hint.is-ready {
  opacity: 1;
  transform: none;
}

/* 点一下的回应：边框亮成陶土红，整块轻轻一鼓 */
.site__hint.is-pulse {
  border-color: var(--clay);
  background: var(--paper-glass);
  transform: scale(1.035);
}

.site__hit:focus-visible .site__hint {
  outline: 2px solid var(--clay);
  outline-offset: 3px;
}

@media (hover: hover) {
  .site__hint:hover {
    border-color: var(--line-strong);
  }
}

/* ---------------- 备案号 ---------------- */

.site__foot {
  position: absolute;
  right: 0;
  bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  left: 0;
  margin: 0;
  color: var(--ink-3);
  font-size: 11px;
  letter-spacing: 0.06em;
  text-align: center;
}

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

/* 系统要求减少动效：不浮、不呼吸，提示直接就是最终样子 */
@media (prefers-reduced-motion: reduce) {
  .site__scene {
    animation: none;
  }

  .site__hint {
    transition-duration: 1ms;
    transition-delay: 0s;
  }
}
