/* 哈希仙人 · 动画全集 — 青绿与淡金，祥云符纹底。 */

:root {
  --jade: #10a37f;
  --jade-deep: #0e6e5b;
  --jade-light: #aeead6;
  --gold: #e8c56a;
  --gold-pale: #f6e3ac;
  --paper: #f7f9f8;

  --ink: #041713;
  --ink-2: #072520;
  --surface: rgba(12, 52, 45, 0.62);
  --surface-2: rgba(9, 41, 35, 0.78);
  --line: rgba(174, 234, 214, 0.16);
  --line-strong: rgba(232, 197, 106, 0.38);

  --text: #e8f5ef;
  --text-dim: #a9c9be;
  --text-faint: #7ea79a;

  --radius: 18px;
  --radius-sm: 10px;
  --shadow: 0 18px 40px -24px rgba(0, 0, 0, 0.9);
  --maxw: 1240px;
}

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

/* 需要换成英文时，早期内联脚本先加上 locale-swap，等 app.js 换完文本再摘掉，
 * 避免中文一闪而过。脚本自带 1.2 秒兜底；没有 JS 时这个类根本不会出现。 */
html.locale-swap body {
  visibility: hidden;
}

/* 切换语言的那一帧：关掉平滑滚动（否则恢复坐标会被动画化）和滚动锚定
 * （否则中英文行高差导致的回流会让浏览器自己挪 scrollTop）。app.js 恢复完就摘掉。 */
html.locale-reflow {
  scroll-behavior: auto !important;
  overflow-anchor: none;
}

html.locale-reflow body {
  overflow-anchor: none;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--ink);
  color: var(--text);
  font: 400 16px/1.7 "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* 底纹：远处的青绿霞光与两道淡金祥云 */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -2;
  background:
    radial-gradient(1100px 620px at 12% -8%, rgba(16, 163, 127, 0.34), transparent 62%),
    radial-gradient(880px 520px at 96% 4%, rgba(232, 197, 106, 0.16), transparent 58%),
    radial-gradient(1000px 700px at 50% 118%, rgba(14, 110, 91, 0.32), transparent 66%),
    linear-gradient(180deg, #05201b 0%, #041713 46%, #030f0d 100%);
}

body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  opacity: 0.5;
  background-image: url("cloud-pattern.svg");
  background-size: 520px auto;
  background-repeat: repeat;
  pointer-events: none;
}

a {
  color: var(--gold-pale);
  text-decoration-color: rgba(232, 197, 106, 0.4);
  text-underline-offset: 3px;
}

a:hover {
  color: #fff3d4;
}

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

.wrap {
  width: min(100% - 40px, var(--maxw));
  margin-inline: auto;
}

.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;
}

/* ---------- 页首 ---------- */

.masthead {
  position: relative;
  padding: clamp(56px, 9vw, 108px) 0 clamp(28px, 4vw, 44px);
  text-align: center;
}

.seal {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 7px 18px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: rgba(8, 38, 32, 0.55);
  color: var(--gold-pale);
  font-size: 13px;
  letter-spacing: 0.14em;
}

.seal .hash {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  color: var(--gold);
}

.masthead h1 {
  margin: 22px 0 0;
  font-size: clamp(34px, 6.4vw, 62px);
  line-height: 1.15;
  font-weight: 600;
  letter-spacing: 0.04em;
  background: linear-gradient(104deg, var(--jade-light) 6%, var(--paper) 40%, var(--gold-pale) 92%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.masthead .latin {
  margin: 12px 0 0;
  color: var(--text-faint);
  font-size: clamp(12px, 2.1vw, 14px);
  letter-spacing: 0.34em;
  text-transform: uppercase;
}

.masthead .intro {
  margin: 24px auto 0;
  max-width: 62ch;
  color: var(--text-dim);
  font-size: clamp(15px, 2.4vw, 17px);
}

.masthead .figures {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
  margin-top: 30px;
  padding: 0;
  list-style: none;
}

.figures li {
  min-width: 118px;
  padding: 12px 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
}

.figures b {
  display: block;
  font-size: 26px;
  font-weight: 600;
  color: var(--gold-pale);
  font-variant-numeric: tabular-nums;
}

.figures span {
  font-size: 12.5px;
  color: var(--text-faint);
  letter-spacing: 0.08em;
}

/* ---------- 工具条 ---------- */

.toolbar {
  position: sticky;
  top: 0;
  z-index: 20;
  margin-top: 26px;
  padding: 12px 0;
  backdrop-filter: blur(14px);
  background: linear-gradient(180deg, rgba(4, 23, 19, 0.94), rgba(4, 23, 19, 0.74));
  border-bottom: 1px solid var(--line);
}

.toolbar .wrap {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.filters {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.chip {
  appearance: none;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(10, 45, 38, 0.6);
  color: var(--text-dim);
  font: inherit;
  font-size: 14px;
  padding: 8px 17px;
  cursor: pointer;
  transition: color 0.18s, border-color 0.18s, background 0.18s;
}

.chip:hover {
  color: var(--text);
  border-color: rgba(174, 234, 214, 0.4);
}

.chip[aria-pressed="true"] {
  color: var(--ink);
  background: linear-gradient(120deg, var(--jade-light), var(--gold-pale));
  border-color: transparent;
  font-weight: 600;
}

.chip .count {
  margin-left: 7px;
  font-size: 12px;
  opacity: 0.75;
  font-variant-numeric: tabular-nums;
}

.toolbar-end {
  display: flex;
  align-items: center;
  gap: 8px 16px;
  margin-left: auto;
  flex-wrap: wrap;
}

/* 语言切换 */

.lang {
  display: inline-flex;
  gap: 3px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(6, 32, 27, 0.9);
}

.lang button {
  appearance: none;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--text-faint);
  font: inherit;
  font-size: 13px;
  line-height: 1;
  padding: 7px 14px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.16s, color 0.16s;
}

.lang button:hover {
  color: var(--text);
}

.lang button[aria-pressed="true"] {
  background: linear-gradient(120deg, var(--jade-light), var(--gold-pale));
  color: var(--ink);
  font-weight: 600;
}

.mode {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font-size: 13.5px;
  color: var(--text-dim);
  cursor: pointer;
  user-select: none;
}

.mode input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.mode .track {
  width: 42px;
  height: 23px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(6, 32, 27, 0.9);
  position: relative;
  transition: background 0.2s, border-color 0.2s;
}

.mode .track::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: var(--text-faint);
  transition: transform 0.2s, background 0.2s;
}

.mode input:checked + .track {
  background: rgba(16, 163, 127, 0.55);
  border-color: rgba(232, 197, 106, 0.45);
}

.mode input:checked + .track::after {
  transform: translateX(19px);
  background: var(--gold-pale);
}

.mode input:focus-visible + .track {
  outline: 2px solid var(--gold);
  outline-offset: 3px;
}

/* ---------- 分区与卡片 ---------- */

main {
  padding-bottom: 40px;
}

.series {
  padding-top: clamp(38px, 6vw, 62px);
  scroll-margin-top: 72px;
}

.series-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 8px 16px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--line);
}

.series-head h2 {
  margin: 0;
  font-size: clamp(22px, 3.6vw, 30px);
  font-weight: 600;
  letter-spacing: 0.05em;
  color: var(--paper);
}

.series-head h2::before {
  content: "";
  display: inline-block;
  width: 10px;
  height: 10px;
  margin-right: 12px;
  border-radius: 2px;
  transform: rotate(45deg);
  background: linear-gradient(135deg, var(--jade), var(--gold));
}

.series-head .tally {
  color: var(--gold-pale);
  font-size: 13px;
  letter-spacing: 0.1em;
  font-variant-numeric: tabular-nums;
}

.series-head p {
  flex: 1 1 100%;
  margin: 4px 0 0;
  color: var(--text-faint);
  font-size: 14.5px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(272px, 1fr));
  gap: clamp(16px, 2.2vw, 26px);
  margin-top: 26px;
  padding: 0;
  list-style: none;
}

.card {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
  box-shadow: var(--shadow);
  overflow: hidden;
  transition: border-color 0.22s, transform 0.22s;
}

.card:hover {
  border-color: rgba(232, 197, 106, 0.32);
  transform: translateY(-2px);
}

.card.is-hidden {
  display: none;
}

/* 舞台 */

.stage {
  position: relative;
  aspect-ratio: 1 / 1;
  background:
    radial-gradient(78% 62% at 50% 40%, rgba(16, 163, 127, 0.24), transparent 72%),
    linear-gradient(170deg, rgba(10, 52, 44, 0.9), rgba(4, 22, 19, 0.95));
  border-bottom: 1px solid var(--line);
  overflow: hidden;
}

.stage::after {
  content: "";
  position: absolute;
  inset: auto 0 0 0;
  height: 42%;
  background: radial-gradient(60% 100% at 50% 100%, rgba(232, 197, 106, 0.13), transparent 70%);
  pointer-events: none;
}

.stage img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: 6%;
  display: block;
}

.stage .poster {
  z-index: 1;
  transition: opacity 0.35s ease;
}

.stage .anim {
  z-index: 2;
  opacity: 0;
  transition: opacity 0.35s ease;
}

.card.is-playing .anim {
  opacity: 1;
}

.card.is-playing .poster {
  opacity: 0;
}

/* 载入状态 */

.stage .status {
  position: absolute;
  z-index: 3;
  left: 10px;
  bottom: 10px;
  display: none;
  align-items: center;
  gap: 7px;
  padding: 5px 11px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(4, 22, 19, 0.82);
  color: var(--text-dim);
  font-size: 12px;
  letter-spacing: 0.04em;
  pointer-events: none;
}

.card.is-loading .status {
  display: inline-flex;
}

.status .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--gold);
  animation: pulse 1.1s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 0.25; transform: scale(0.75); }
  50% { opacity: 1; transform: scale(1); }
}

/* 点按播放按钮 */

.stage .trigger {
  position: absolute;
  inset: 0;
  z-index: 4;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  padding: 0 0 16px;
  border: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  cursor: pointer;
}

.card.is-playing .trigger,
.card.is-loading .trigger {
  display: none;
}

.trigger .pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: rgba(4, 22, 19, 0.86);
  color: var(--gold-pale);
  font-size: 13px;
  letter-spacing: 0.05em;
  transition: background 0.18s, color 0.18s;
}

.trigger:hover .pill {
  background: rgba(16, 163, 127, 0.3);
  color: #fff6de;
}

.trigger .pill::before {
  content: "";
  width: 0;
  height: 0;
  border-left: 9px solid currentColor;
  border-top: 5.5px solid transparent;
  border-bottom: 5.5px solid transparent;
}

/* 变体切换 */

.variants {
  position: absolute;
  z-index: 5;
  top: 10px;
  right: 10px;
  display: flex;
  gap: 4px;
  padding: 3px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(4, 22, 19, 0.82);
}

.variants button {
  appearance: none;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--text-faint);
  font: inherit;
  font-size: 12px;
  padding: 3px 11px;
  cursor: pointer;
  transition: background 0.16s, color 0.16s;
}

.variants button[aria-pressed="true"] {
  background: linear-gradient(120deg, var(--jade), var(--jade-deep));
  color: var(--paper);
}

.index-mark {
  position: absolute;
  z-index: 5;
  top: 10px;
  left: 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  letter-spacing: 0.1em;
  color: rgba(232, 197, 106, 0.6);
  pointer-events: none;
}

/* 失败提示是真实元素，跟着语言字典走，不写死在 CSS content 里。 */
.stage .errmsg {
  position: absolute;
  z-index: 6;
  inset: auto 0 14px;
  display: none;
  text-align: center;
  color: var(--gold-pale);
  font-size: 13px;
  pointer-events: none;
}

.card.is-error .errmsg {
  display: block;
}

/* 卡片文字 */

.body {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 16px 18px 18px;
  flex: 1 1 auto;
}

.body .state {
  align-self: flex-start;
  padding: 3px 10px;
  border-radius: 999px;
  border: 1px solid rgba(174, 234, 214, 0.22);
  background: rgba(16, 163, 127, 0.14);
  color: var(--jade-light);
  font-size: 12px;
  letter-spacing: 0.06em;
}

.body h3 {
  margin: 0;
  font-size: 19px;
  font-weight: 600;
  letter-spacing: 0.03em;
  color: var(--paper);
}

.body p {
  margin: 0;
  color: var(--text-dim);
  font-size: 14.5px;
  line-height: 1.66;
}

.specs {
  display: flex;
  flex-wrap: wrap;
  gap: 5px 12px;
  margin: 4px 0 0;
  padding-top: 11px;
  border-top: 1px dashed rgba(174, 234, 214, 0.15);
  color: var(--text-faint);
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
}

.specs .file {
  width: 100%;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11.5px;
  color: rgba(126, 167, 154, 0.85);
  word-break: break-all;
}

/* ---------- 页脚 ---------- */

.colophon {
  margin-top: clamp(48px, 7vw, 82px);
  padding: clamp(30px, 4vw, 46px) 0 60px;
  border-top: 1px solid var(--line);
  background: linear-gradient(180deg, transparent, rgba(4, 18, 15, 0.7));
}

.colophon .cols {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(258px, 1fr));
  gap: clamp(20px, 3vw, 40px);
}

.colophon h2 {
  margin: 0 0 10px;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.12em;
  color: var(--gold-pale);
}

.colophon p {
  margin: 0 0 10px;
  color: var(--text-faint);
  font-size: 13.5px;
  line-height: 1.72;
}

.colophon ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

.colophon li + li {
  margin-top: 7px;
}

.colophon .fine {
  margin-top: 26px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
  color: rgba(126, 167, 154, 0.8);
  font-size: 12.5px;
}

/* ---------- 窄屏 ---------- */

@media (max-width: 640px) {
  .wrap {
    width: min(100% - 28px, var(--maxw));
  }

  .grid {
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  }

  .toolbar .wrap {
    gap: 8px;
  }

  .toolbar-end {
    flex: 1 1 100%;
    margin-left: 0;
    justify-content: space-between;
    gap: 10px;
    padding-top: 2px;
  }

  .mode {
    flex: 0 1 auto;
    min-width: 0;
  }

  .mode > span:last-child {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .lang button {
    padding: 6px 12px;
  }

  .chip {
    padding: 7px 14px;
    font-size: 13.5px;
  }

  .figures li {
    flex: 1 1 42%;
    min-width: 0;
    padding: 10px 12px;
  }
}

@media (max-width: 380px) {
  .grid {
    grid-template-columns: 1fr;
  }
}

/* ---------- 尊重减少动态偏好 ---------- */

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }

  .card:hover {
    transform: none;
  }

  body::after {
    opacity: 0.3;
  }
}
