/* ==========================================================================
   盲盒 · style.css
   纸感、单色强调：只用一种强调色（砖红），其余靠字号、间距和细线分层。
   1 变量 · 2 基础 · 3 头部 · 4 首页 · 5 盒子 · 6 按钮与结果
   7 收藏册 · 8 概率与关于 · 9 页脚 · 10 动画与窄屏
   ========================================================================== */

/* 1 · 变量 */
:root {
  --paper: #fbfaf7;
  --surface: #ffffff;
  --ink: #1c1b18;
  --ink-2: #3b3833;
  --muted: #6c6862;
  --line: #e6e1d9;
  --line-2: #d3ccbf;
  --accent: #a3461f;
  --accent-soft: #f4e8e1;

  --r: 10px;
  --shadow: 0 1px 2px rgba(28, 27, 24, .05), 0 8px 24px -18px rgba(28, 27, 24, .25);
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #171613;
    --surface: #1e1c18;
    --ink: #f1eee7;
    --ink-2: #d6d1c7;
    --muted: #9d978c;
    --line: #302d27;
    --line-2: #423d34;
    --accent: #d78a62;
    --accent-soft: #2a211b;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4);
  }
}

/* 2 · 基础 */
*,
*::before,
*::after { box-sizing: border-box; }

[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: system-ui, -apple-system, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 17px;
  line-height: 1.7;
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 {
  margin: 0 0 .5em;
  line-height: 1.3;
  font-weight: 650;
  letter-spacing: -.01em;
}
h1 { font-size: clamp(1.55rem, 3.4vw, 2.1rem); }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }

p { margin: 0 0 1em; }
p:last-child { margin-bottom: 0; }

a { color: var(--ink); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: .18em; }

button { font: inherit; color: inherit; }

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

.wrap {
  width: 100%;
  max-width: 52rem;
  margin: 0 auto;
  padding: 0 24px;
}

.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 {
  position: absolute;
  left: -9999px;
}
.skip:focus {
  left: 16px;
  top: 12px;
  z-index: 100;
  padding: .5em 1em;
  background: var(--surface);
  border: 1px solid var(--line-2);
  border-radius: var(--r);
}

/* 3 · 头部 */
.site-head {
  border-bottom: 1px solid var(--line);
  background: var(--paper);
}
.head-inner {
  display: flex;
  align-items: center;
  gap: 16px;
  min-height: 64px;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font-weight: 650;
  letter-spacing: .01em;
  white-space: nowrap;
}
.brand:hover { text-decoration: none; }
.mark { width: 22px; height: 22px; flex: none; color: var(--accent); }

.site-nav { margin-left: auto; }
.site-nav ul {
  display: flex;
  gap: 2px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.site-nav a {
  display: inline-block;
  padding: .38em .7em;
  font-size: .95rem;
  color: var(--muted);
  border-radius: 6px;
}
.site-nav a:hover { color: var(--ink); background: var(--accent-soft); text-decoration: none; }
.site-nav a[aria-current="page"] { color: var(--ink); font-weight: 600; }
.site-nav a[aria-current="page"]:hover { background: transparent; }

/* 4 · 首页 */
html { scroll-behavior: smooth; }
[id] { scroll-margin-top: 24px; }

.intro {
  padding: clamp(32px, 6vw, 56px) 0 22px;
  max-width: 38rem;
}

/* 本页目录：几条锚点链接，点了直接跳到下面的小节 */
.toc {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 6px 14px;
  margin: 0 0 26px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
  font-size: .88rem;
}
.toc__label {
  font-size: .74rem;
  letter-spacing: .12em;
  color: var(--muted);
}
.toc a {
  color: var(--ink-2);
  border-bottom: 1px solid var(--line-2);
}
.toc a:hover { color: var(--accent); border-color: currentColor; text-decoration: none; }

/* 目录跳过去的小节 */
.section {
  max-width: 38rem;
  padding: 26px 0 6px;
  border-top: 1px solid var(--line);
}
.section h2 { margin-bottom: 10px; font-size: 1.05rem; }
.section p { color: var(--ink-2); }
.section .rules { margin: 0 0 14px; }
.section__more {
  margin: 0;
  font-size: .86rem;
}
.section__more a { color: var(--muted); border-bottom: 1px solid var(--line-2); }
.section__more a:hover { color: var(--accent); border-color: currentColor; text-decoration: none; }
.section__more .dot { margin: 0 .55em; color: var(--line-2); }
.eyebrow {
  margin: 0 0 .9em;
  font-size: .78rem;
  font-weight: 600;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--accent);
}
.lede {
  color: var(--muted);
  margin-bottom: 1.2em;
}
.stats {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 20px;
  margin: 0;
  font-size: .9rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.stats b { font-weight: 600; color: var(--ink); }

.machine {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  padding: 18px 18px 16px;
  margin-bottom: 26px;
  box-shadow: var(--shadow);
}
.machine-head {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 16px;
}
.machine-head h2 { margin: 0; font-size: 1rem; }
.machine-head .count { font-size: .82rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.quiet-link {
  margin-left: auto;
  font-size: .82rem;
  color: var(--muted);
  border-bottom: 1px solid var(--line-2);
}
.quiet-link:hover { color: var(--accent); border-color: currentColor; text-decoration: none; }

/* 稀有度在盒子上只用一个小圆点表示，颜色压得很低 */
[data-rarity="N"] { --rarity: #9b9488; }
[data-rarity="R"] { --rarity: #6c6862; }
[data-rarity="SR"] { --rarity: var(--accent); }
[data-rarity="SSR"] { --rarity: #7d3416; }
[data-rarity="UR"] { --rarity: #1c1b18; }

@media (prefers-color-scheme: dark) {
  [data-rarity="N"] { --rarity: #8f897e; }
  [data-rarity="R"] { --rarity: #b3ada2; }
  [data-rarity="SSR"] { --rarity: #d79a72; }
  [data-rarity="UR"] { --rarity: #f1eee7; }
}

/* 5 · 盒子 */
.case {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 10px;
}
.box {
  position: relative;
  aspect-ratio: 1 / 1;
  padding: 0;
  background: var(--surface);
  border: 1px solid var(--line-2);
  border-radius: var(--r);
  cursor: pointer;
  transition: border-color .15s, transform .15s;
  display: grid;
  place-items: center;
}
.box:hover:not(.is-open) {
  border-color: var(--ink);
  transform: translateY(-2px);
}
.box__no {
  font-size: .76rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  letter-spacing: .04em;
}
.box__glyph { display: none; width: 30px; height: 30px; color: var(--ink); }
.box__glyph svg { display: block; width: 100%; height: 100%; }

.box.is-open {
  cursor: default;
  background: var(--paper);
  transform: none;
}
.box.is-open .box__no { display: none; }
.box.is-open .box__glyph { display: block; }
.box.is-open::after {
  content: "";
  position: absolute;
  top: 7px;
  right: 7px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--rarity, var(--muted));
}

.box.is-shaking { animation: nudge .42s ease-in-out; }

.machine-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}
.machine-foot p { margin: 0; font-size: .82rem; color: var(--muted); }

.recent {
  margin: 12px 0 0;
  font-size: .82rem;
  color: var(--muted);
  min-height: 1.4em;
}
.recent b { font-weight: 600; color: var(--ink-2); }

/* 6 · 按钮与结果 */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: .6em 1.05em;
  font-size: .92rem;
  font-weight: 600;
  border-radius: 8px;
  border: 1px solid var(--line-2);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  transition: background-color .15s, border-color .15s;
}
.btn:hover { border-color: var(--ink); }
.btn--primary {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--paper);
}
.btn--primary:hover { background: var(--ink-2); border-color: var(--ink-2); }
.btn--sm { padding: .42em .8em; font-size: .84rem; }

.overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(24, 22, 18, .55);
  animation: fade .16s ease both;
}
.dialog {
  position: relative;
  width: min(360px, 100%);
  padding: 26px 24px 22px;
  background: var(--surface);
  border: 1px solid var(--line-2);
  border-radius: 14px;
  box-shadow: 0 24px 60px -30px rgba(0, 0, 0, .5);
  text-align: center;
  animation: rise .22s ease both;
}
.dialog__close {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  font-size: 1.1rem;
  line-height: 1;
}
.dialog__close:hover { background: var(--accent-soft); color: var(--ink); }

.dialog__glyph {
  display: block;
  width: 64px;
  height: 64px;
  margin: 10px auto 24px;
  color: var(--ink);
}
.dialog__actions { display: flex; gap: 10px; }
.dialog__actions .btn { flex: 1 1 0; }

/* 7 · 收藏册 */
.page-head {
  padding: clamp(28px, 5vw, 44px) 0 4px;
  max-width: 38rem;
}
.page-head .lede { margin-bottom: 0; }

.progress {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 24px 0 18px;
  font-size: .84rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.progress__bar {
  flex: 1;
  height: 4px;
  background: var(--line);
  border-radius: 2px;
  overflow: hidden;
}
.progress__fill {
  display: block;
  height: 100%;
  width: 0;
  background: var(--accent);
  transition: width .4s ease;
}

.grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 28px;
}
.card {
  position: relative;
  display: grid;
  place-items: center;
  padding: 22px 10px;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--surface);
}
.card--locked {
  background: transparent;
  border-style: dashed;
  border-color: var(--line-2);
}
.card__glyph {
  width: 34px;
  height: 34px;
  color: var(--ink);
}
.card--locked .card__glyph { color: var(--line-2); }
.card__glyph--ghost {
  color: var(--line-2);
  opacity: .9;
}
.card__count {
  position: absolute;
  top: 7px;
  right: 9px;
  font-size: .72rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin-bottom: 48px;
}
.actions p { margin: 0; font-size: .82rem; color: var(--muted); }

/* 8 · 概率与关于 */
.panel {
  padding: 20px 0;
  border-top: 1px solid var(--line);
}
.panel:first-of-type { border-top: 0; }
.panel h2 { margin-bottom: 12px; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: .9rem;
  margin-bottom: 10px;
}
caption {
  text-align: left;
  font-size: .8rem;
  color: var(--muted);
  padding-bottom: 8px;
}
th, td {
  padding: .5em .3em;
  text-align: left;
  border-bottom: 1px solid var(--line);
}
th { font-size: .78rem; font-weight: 600; color: var(--muted); }
td:last-child, th:last-child { text-align: right; font-variant-numeric: tabular-nums; }
tbody tr:last-child td { border-bottom: 0; }

.list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 6px;
  font-size: .9rem;
}
.list li {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--line);
}
.list li:last-child { border-bottom: 0; }
.list .li-glyph { width: 20px; height: 20px; flex: none; color: var(--ink); }
.list .li-name { font-weight: 600; }
.list .li-meta { color: var(--muted); }
.list .li-chance { margin-left: auto; color: var(--muted); font-variant-numeric: tabular-nums; }

.rules {
  margin: 0;
  padding-left: 1.2em;
  display: grid;
  gap: 8px;
  color: var(--ink-2);
  font-size: .92rem;
}
.rules b { color: var(--ink); }

.note {
  font-size: .86rem;
  color: var(--muted);
  padding: 12px 14px;
  border-left: 2px solid var(--line-2);
  margin: 14px 0 0;
}

/* 9 · 关于页正文 */
.prose { max-width: 38rem; }
.prose h2 { margin-top: 1.8em; }
.prose ul { padding-left: 1.2em; margin: 0 0 1em; color: var(--ink-2); }
.prose li { margin-bottom: .3em; }
.prose code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .88em;
  padding: .1em .35em;
  background: var(--accent-soft);
  border-radius: 4px;
}

/* 10 · 页脚 */
.site-foot {
  border-top: 1px solid var(--line);
  padding: 22px 0 40px;
  font-size: .82rem;
  color: var(--muted);
}
.site-foot .wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 20px;
}
.site-foot a { color: var(--muted); border-bottom: 1px solid var(--line-2); }
.site-foot a:hover { color: var(--accent); text-decoration: none; }

/* 11 · 动画与窄屏 */
@keyframes nudge {
  0%, 100% { transform: translateY(0) rotate(0); }
  25% { transform: translateY(-3px) rotate(-1.5deg); }
  60% { transform: translateY(-1px) rotate(1.5deg); }
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes rise {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

@media (max-width: 720px) {
  body { font-size: 16px; }
  .wrap { padding: 0 18px; }
  .case { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 520px) {
  .head-inner { min-height: 58px; gap: 8px; }
  .brand { font-size: .95rem; }
  .mark { width: 19px; height: 19px; }
  .site-nav a { padding: .38em .55em; font-size: .88rem; }
  .case { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .machine { padding: 14px; }
  .dialog__actions { flex-direction: column-reverse; }
}
@media (max-width: 360px) {
  .case { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

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