/* MaiArchive shared design layer: tokens, base, buttons, header, footer, back-to-top.
   Every page loads this first, then its own stylesheet (home.css, song.css, stats.css).
   Difficulty colours are the only saturated colour family; everything else is neutral plus one accent. */

/* ---------- Tokens ---------- */
:root {
  --bg: #f6f5f2;
  --surface: #ffffff;
  --surface-2: #efeee9;
  --text: #1d2024;
  --muted: #666b73;
  --faint: #979ba2;
  --line: #e2e1dc;
  --accent: #3d6fe0;
  --accent-soft: #e8eefc;
  --brand: #7fa8ea;
  --ok: #1f9d6b;
  --warn: #c9871a;
  --hot: #d9622b;
  --bad: #d64545;
  --shadow-sm: 0 1px 2px rgb(20 22 26 / 5%);
  --shadow: 0 1px 2px rgb(20 22 26 / 4%), 0 8px 24px rgb(20 22 26 / 7%);
  --shadow-pop: 0 2px 6px rgb(20 22 26 / 6%), 0 20px 50px rgb(20 22 26 / 16%);
  --scrim: rgb(17 19 21 / 52%);
  --d2: #3ea84a; --d3: #e09a00; --d4: #e5475a; --d5: #9246d6; --d6: #e4d2fa; --d6-text: #4b2a72; --d7: #e0569a;
  --radius: 12px;
  --header-h: 64px;
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
  --spring: cubic-bezier(0.34, 1.4, 0.64, 1);
  --ui: "Hiragino Sans", "Hiragino Kaku Gothic ProN", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  --display: "FOT NewRodin", var(--ui);
  color-scheme: light;
}
html[data-theme="dark"] {
  --bg: #111315;
  --surface: #191c1f;
  --surface-2: #23272b;
  --text: #eef0f2;
  --muted: #a0a6ae;
  --faint: #6f767e;
  --line: #2d3237;
  --accent: #8aaeff;
  --accent-soft: #1e2a42;
  --ok: #3cc58c;
  --warn: #f0a94a;
  --hot: #f08a54;
  --bad: #f06a6a;
  --shadow-sm: 0 1px 2px rgb(0 0 0 / 30%);
  --shadow: 0 1px 2px rgb(0 0 0 / 30%), 0 8px 24px rgb(0 0 0 / 32%);
  --shadow-pop: 0 2px 6px rgb(0 0 0 / 40%), 0 20px 50px rgb(0 0 0 / 55%);
  --scrim: rgb(0 0 0 / 62%);
  --d6: #5a3f80; --d6-text: #f1e5ff;
  color-scheme: dark;
}
@font-face {
  font-family: "FOT NewRodin";
  src: url("/fonts/rodin-eb.woff2") format("woff2");
  font-weight: 400 900;
  font-display: swap;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: calc(var(--header-h) + 64px); }
body { margin: 0; min-height: 100dvh; background: var(--bg); color: var(--text); font: 14px/1.5 var(--ui); -webkit-font-smoothing: antialiased; }
a { color: inherit; text-decoration: none; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
img { max-width: 100%; }
h1, h2, h3, p { margin: 0; text-wrap: pretty; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.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; }
.ico { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.wrap { width: 100%; max-width: 1440px; margin: 0 auto; padding: 0 32px; }
.skip-link { position: fixed; top: 8px; left: 16px; z-index: 2000; padding: 10px 16px; border-radius: 8px; background: var(--surface); box-shadow: var(--shadow); transform: translateY(-180%); }
.skip-link:focus { transform: none; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 40px; padding: 0 14px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--surface);
  font-size: 13px; font-weight: 600; white-space: nowrap;
  transition: border-color 160ms ease, background 160ms ease, color 160ms ease, transform 160ms var(--ease);
}
.btn:hover { border-color: color-mix(in srgb, var(--accent) 50%, var(--line)); }
.btn:active:not(:disabled) { transform: scale(0.97); }
.btn .ico { width: 16px; height: 16px; }
.btn-primary { border-color: var(--text); background: var(--text); color: var(--bg); }
.btn-primary:hover { border-color: var(--text); opacity: 0.88; }
.btn.active, .btn[aria-expanded="true"]:not(.btn-primary) { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.btn-primary[aria-expanded="true"] { opacity: 0.88; }
.icon-btn {
  display: inline-grid; place-items: center; width: 40px; height: 40px;
  border: 0; border-radius: 10px; background: none; color: var(--muted);
  transition: background 160ms ease, color 160ms ease, transform 160ms var(--ease);
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn:active { transform: scale(0.94); }

/* ---------- Header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 60;
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  -webkit-backdrop-filter: saturate(160%) blur(14px);
  backdrop-filter: saturate(160%) blur(14px);
  border-bottom: 1px solid transparent;
  transition: border-color 200ms ease, box-shadow 200ms ease;
}
body.is-scrolled .site-header { border-bottom-color: var(--line); box-shadow: 0 6px 20px rgb(0 0 0 / 4%); }
.header-inner { display: flex; align-items: center; gap: 24px; height: var(--header-h); }
.brand { display: flex; align-items: center; gap: 10px; flex: none; }
.brand-logo { width: 40px; height: 40px; border-radius: 50%; transition: transform 400ms var(--spring); }
.brand:hover .brand-logo { transform: rotate(-8deg) scale(1.05); }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-name { font-family: var(--display); font-size: 18px; font-weight: 800; letter-spacing: -0.02em; }
.brand-note { margin-top: 3px; color: var(--muted); font-size: 10.5px; }
.search-field {
  flex: 1 1 auto; max-width: 620px;
  display: flex; align-items: center; gap: 10px; height: 42px; padding: 0 10px 0 14px;
  border: 1px solid var(--line); border-radius: 12px; background: var(--surface); color: var(--faint);
  transition: border-color 160ms ease, box-shadow 160ms ease, color 160ms ease;
}
.search-field:focus-within { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); color: var(--accent); }
.search-field input { flex: 1; min-width: 0; height: 100%; padding: 0; border: 0; outline: 0; background: none; color: var(--text); font-size: 15px; }
.search-field input::placeholder { color: var(--faint); }
.search-field input::-webkit-search-cancel-button { cursor: pointer; }
.search-field kbd { padding: 3px 7px; border: 1px solid var(--line); border-radius: 6px; color: var(--faint); font: 600 11px/1 var(--ui); }
.search-field:focus-within kbd { display: none; }
.archive-nav { display: flex; align-items: center; gap: 4px; margin-left: auto; }
.archive-nav a:not(.archive-support-link) { padding: 8px 12px; border-radius: 8px; color: var(--muted); font-size: 13px; font-weight: 600; transition: color 160ms ease, background 160ms ease; }
.archive-nav a:not(.archive-support-link):hover { color: var(--text); background: var(--surface-2); }
.archive-nav a[aria-current="page"] { color: var(--text); }
.archive-nav .archive-support-link {
  display: inline-flex; align-items: center; gap: 6px; min-height: 44px; margin-left: 6px; padding: 0 12px;
  color: var(--d7); font-size: 12px; font-weight: 700; white-space: nowrap;
}
.archive-nav .archive-support-link::before {
  content: ""; position: absolute; z-index: -1; inset: 5px 0; border-radius: 999px;
  background: color-mix(in srgb, var(--d7) 12%, transparent); transition: background 160ms ease;
}
.archive-nav .archive-support-link { position: relative; isolation: isolate; }
.archive-nav .archive-support-link:hover::before { background: color-mix(in srgb, var(--d7) 20%, transparent); }
.archive-support-link .ico { width: 15px; height: 15px; transition: transform 240ms var(--spring), fill 160ms ease; }
.archive-support-link:hover .ico { transform: scale(1.15); fill: currentColor; }
.header-tools { display: flex; align-items: center; gap: 2px; }
.theme-icon { display: grid; }
.theme-icon .ico { grid-area: 1 / 1; transition: opacity 220ms ease, transform 360ms var(--spring); }
html[data-theme="dark"] .theme-icon .ico-moon,
html:not([data-theme="dark"]) .theme-icon .ico-sun { opacity: 0; transform: rotate(-90deg) scale(0.5); }


/* Difficulty colour lookup shared by badges, level pills and the chart player. */
.lv-2 { --c: var(--d2); } .lv-3 { --c: var(--d3); } .lv-4 { --c: var(--d4); }
.lv-5 { --c: var(--d5); } .lv-6 { --c: var(--d6); --c-text: var(--d6-text); } .lv-7 { --c: var(--d7); }

/* ---------- Footer ---------- */
.site-footer { margin-top: 40px; border-top: 1px solid var(--line); color: var(--muted); font-size: 12px; }
.footer-inner { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 16px; padding-top: 24px; padding-bottom: 24px; }
.archive-about { display: flex; align-items: center; gap: 12px; }
.archive-about img { border-radius: 50%; }
.footer-title { color: var(--text); font-weight: 650; }
.archive-about a, .footer-support { color: var(--accent); }
.seo-song-index-links a:hover { color: var(--accent); }
.seo-prerender { display: none; }
.site-icp-footer { padding: 16px 32px 28px; border-top: 1px solid var(--line); }
.site-icp-footer-inner { display: flex; flex-direction: column; align-items: center; gap: 10px; font-size: 12px; color: var(--muted); }

/* ---------- Back to top ---------- */
.back-to-top {
  position: fixed; right: 24px; bottom: 24px; z-index: 90;
  display: grid; place-items: center; width: 44px; height: 44px;
  border: 1px solid var(--line); border-radius: 12px; background: var(--surface); color: var(--text); box-shadow: var(--shadow);
  opacity: 0; visibility: hidden; transform: translateY(12px) scale(0.9);
  transition: opacity 200ms ease, transform 280ms var(--spring), visibility 0s linear 280ms, border-color 160ms ease, color 160ms ease;
}
.back-to-top.is-visible { opacity: 1; visibility: visible; transform: none; transition: opacity 200ms ease, transform 280ms var(--spring), visibility 0s, border-color 160ms ease, color 160ms ease; }
.back-to-top:hover { border-color: var(--accent); color: var(--accent); }
.back-to-top .ico { width: 20px; height: 20px; }
body:has(.stats-text .stats-action) .back-to-top { bottom: 84px; }

/* ---------- Theme switch + page transitions ---------- */
::view-transition-old(root), ::view-transition-new(root) { animation-duration: 280ms; animation-timing-function: ease; }
/* 同源页面跳转（首页 → 详情页、返回）不白屏：浏览器做交叉淡化，顶栏保持不动，
   被点开的封面放大到详情页大图（app.js markSongCoverForTransition / song.css #songCover） */
@view-transition { navigation: auto; }
.site-header { view-transition-name: site-header; }
::view-transition-group(song-cover) { animation-duration: 360ms; animation-timing-function: cubic-bezier(0.2, 0.8, 0.2, 1); }
::view-transition-old(song-cover), ::view-transition-new(song-cover) { height: 100%; object-fit: cover; }

/* Breadcrumb used by detail pages */
.crumbs { display: flex; align-items: center; gap: 8px; margin: 20px 0 0; color: var(--muted); font-size: 12px; }
.crumbs a { display: inline-flex; align-items: center; gap: 4px; min-height: 32px; }
.crumbs a:hover { color: var(--accent); }
.crumbs .ico { width: 14px; height: 14px; }

/* ---------- Responsive (shared chrome) ---------- */
@media (max-width: 1100px) {
  .archive-nav a:not(.archive-support-link) { padding: 8px; }
}
@media (max-width: 900px) {
  :root { --header-h: 112px; }
  .wrap { padding: 0 16px; }
  .header-inner { flex-wrap: wrap; gap: 10px 8px; height: auto; padding-top: 10px; padding-bottom: 10px; }
  .brand-logo { width: 36px; height: 36px; }
  .brand-name { font-size: 16px; }
  .search-field { order: 3; flex-basis: 100%; max-width: none; }
  .search-field kbd { display: none; }
  .archive-nav { gap: 0; }
  .archive-nav a:not(.archive-support-link) { display: none; }
  .archive-nav .archive-support-link span { display: none; }
  .archive-nav .archive-support-link { width: 44px; padding: 0; justify-content: center; margin-left: 0; }
}
@media (max-width: 560px) {
  .back-to-top { right: 16px; bottom: 16px; }
  .footer-inner { flex-direction: column; align-items: flex-start; }
}
/* motion.js (anime.js) hides an element only until its entrance starts; printing or reduced motion always shows it. */
.motion-pending { opacity: 0; }
@media (prefers-reduced-motion: reduce) {
  .motion-pending { opacity: 1 !important; }
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
  ::view-transition-old(root), ::view-transition-new(root) { animation: none; }
  ::view-transition-group(*) { animation: none !important; }
}
@media print {
  .motion-pending { opacity: 1 !important; }
  .site-header, .back-to-top { display: none !important; }
}
