/* ==========================================================================
   slince.log — Pixel Paper theme
   Warm paper + 8-bit UI. All colours live in tokens so dark mode only swaps
   variables (see theme-dark.css).
   ========================================================================== */

html {
  /* pixel unit: every border / shadow / step is a multiple of this */
  --px: 3px;

  /* palette — light "paper" */
  --bg: #ede2d0;
  --surface: #f7efe1;
  --surface-2: #e6d8c3;
  --line: #2b2118;
  --ink: #2b2118;
  --muted: #7a6650;
  --shadow: #c7b391;
  --grid: rgba(136, 98, 71, 0.06);
  --accent: #d9583b;
  --accent-ink: #fff6e8;
  --accent-2: #3f8f5a;
  --gold: #e8a93a;
  --sky: #4d7fc4;
  --select: #f3c78a;

  --grass: #6abe30;
  --grass-dk: #3f8f2a;
  --dirt: #b98b5e;
  --dirt-dk: #8f6440;

  --font-body: 'Slince Rounded', 'Yuanti SC', 'Hiragino Maru Gothic ProN', 'PingFang SC', 'Microsoft YaHei', sans-serif;
  --font-pixel: 'Slince Pixel', 'Slince Dots', 'Slince Rounded', monospace;
  --font-dots: 'Slince Dots', 'Slince Pixel', monospace;
  --font-mono: Consolas, Menlo, Monaco, monospace;

  /* hard 8-bit easing: motion moves in visible steps */
  --step-ease: steps(4, end);
  --snap: cubic-bezier(0.2, 0.9, 0.2, 1.2);

  color: var(--ink);
  background-color: var(--bg);
  background-image:
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 12px 12px;
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-family: var(--font-body);
  font-variant-numeric: tabular-nums;
  font-variant-ligatures: none;
  transition: background-color 240ms steps(3, end), color 240ms steps(3, end);
}

body {
  max-width: 720px;
  padding: 0 16px;
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
/* 只给内容区做入场动画：body 上的 transform 会让 position:fixed 元素失效 */
body > .page {
  flex: 1 0 auto;
  animation: page-in 360ms steps(6, end);
}

@keyframes page-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

/* cross-document page transitions (Chromium) */
@view-transition { navigation: auto; }
::view-transition-old(root) { animation: vt-out 180ms steps(3, end) both; }
::view-transition-new(root) { animation: vt-in 240ms steps(4, end) both; }
@keyframes vt-out { to { opacity: 0; } }
@keyframes vt-in { from { opacity: 0; } }

/* theme switch: stepped circle wipe from the toggle button */
html.theme-switching::view-transition-old(root) { animation: none; }
html.theme-switching::view-transition-new(root) {
  animation: theme-wipe 560ms steps(8, end) both;
}
@keyframes theme-wipe {
  from { clip-path: circle(0 at var(--vt-x, 50%) var(--vt-y, 0)); }
  to { clip-path: circle(150vmax at var(--vt-x, 50%) var(--vt-y, 0)); }
}

* { -webkit-tap-highlight-color: transparent; box-sizing: border-box; }
ol, ul { list-style: none; }
p, h1, h2, h3, h4, h5, ul, ol, li, blockquote, dl, dd { padding: 0; margin: 0; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
input, select, textarea {
  font-family: inherit;
  outline: 0;
  -webkit-appearance: none;
  appearance: none;
  border: none;
}
pre, code { font-family: var(--font-mono); }
input:-webkit-autofill {
  -webkit-text-fill-color: var(--ink) !important;
  transition: background-color 2592000s ease-in-out 0s;
}

::-webkit-scrollbar { width: 9px; height: 9px; background-color: transparent; }
::-webkit-scrollbar-thumb { background-color: var(--muted); border: 3px solid var(--bg); }
::selection { background-color: var(--select); color: var(--ink); }

:focus-visible {
  outline: var(--px) dashed var(--accent);
  outline-offset: 4px;
}

/* --------------------------------------------------------------------------
   Pixel primitives
   -------------------------------------------------------------------------- */

/* notched 8-bit frame + stepped drop shadow */
.px-box,
.px-btn,
.chip {
  box-shadow:
    0 calc(var(--px) * -1) 0 0 var(--line),
    0 var(--px) 0 0 var(--line),
    calc(var(--px) * -1) 0 0 0 var(--line),
    var(--px) 0 0 0 var(--line),
    var(--px) calc(var(--px) * 2) 0 0 var(--shadow),
    calc(var(--px) * 2) var(--px) 0 0 var(--shadow);
}
.px-box { background: var(--surface); }

.px-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 30px;
  padding: 6px 10px;
  font-family: var(--font-pixel);
  font-size: 12px;
  line-height: 1;
  letter-spacing: 0.04em;
  white-space: nowrap;
  color: var(--ink);
  background: var(--surface);
  cursor: pointer;
  user-select: none;
  transition: transform 90ms steps(2, end), background-color 90ms steps(2, end), color 90ms steps(2, end);
}
.px-btn:hover {
  background: var(--gold);
  color: var(--line);
  transform: translate(-1px, -2px);
}
.px-btn:active,
.px-btn.is-pressed {
  transform: translate(var(--px), var(--px));
  box-shadow:
    0 calc(var(--px) * -1) 0 0 var(--line),
    0 var(--px) 0 0 var(--line),
    calc(var(--px) * -1) 0 0 0 var(--line),
    var(--px) 0 0 0 var(--line);
}
.px-btn[aria-current='page'] {
  background: var(--accent);
  color: var(--accent-ink);
}

.sr-only {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.pixel-text {
  font-family: var(--font-pixel);
  -webkit-font-smoothing: none;
  font-smooth: never;
}

.blink { animation: blink 1s steps(1, end) infinite; }
@keyframes blink { 50% { opacity: 0; } }

/* legacy helper still used by post / category links */
.hover-underline { position: relative; }
.hover-underline::after {
  content: '';
  position: absolute;
  left: 0;
  bottom: -3px;
  width: 100%;
  height: var(--px);
  background-image: linear-gradient(90deg, var(--accent) 50%, transparent 50%);
  background-size: calc(var(--px) * 2) 100%;
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 200ms steps(5, end);
}
.hover-underline:hover::after,
.hover-underline:focus-visible::after { transform: scaleX(1); }

/* --------------------------------------------------------------------------
   Header
   -------------------------------------------------------------------------- */
.header {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 0 16px;
  margin-bottom: 28px;
  background-color: var(--bg);
  background-image: linear-gradient(90deg, var(--line) 50%, transparent 50%);
  background-size: calc(var(--px) * 2) var(--px);
  background-repeat: repeat-x;
  background-position: 0 100%;
  transition: transform 200ms steps(4, end);
}
.header.is-hidden { transform: translateY(-110%); }

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}
.brand-avatar {
  position: relative;
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  box-shadow:
    0 calc(var(--px) * -1) 0 0 var(--line),
    0 var(--px) 0 0 var(--line),
    calc(var(--px) * -1) 0 0 0 var(--line),
    var(--px) 0 0 0 var(--line);
  background: var(--surface);
}
.brand-avatar picture { position: static; }
.header .logo {
  display: block;
  width: 40px;
  height: 40px;
  user-select: none;
}
.brand:hover .brand-avatar { animation: hop 420ms steps(6, end); }
@keyframes hop {
  0%, 100% { transform: translateY(0); }
  40% { transform: translateY(-8px); }
  70% { transform: translateY(0) scaleY(0.9); }
}
.brand-name {
  font-family: var(--font-pixel);
  font-size: 24px;
  line-height: 1;
  letter-spacing: 0.02em;
  white-space: nowrap;
  -webkit-font-smoothing: none;
}
.brand-dot { color: var(--accent); }
.brand-caret { color: var(--accent); animation: blink 1s steps(1, end) infinite; }

.header .menu {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 12px 12px;
  padding: var(--px) calc(var(--px) * 2) calc(var(--px) * 2) var(--px);
  user-select: none;
}
.header .menu a::after { display: none; }

.theme-toggle { width: 34px; padding: 6px; }
.theme-toggle svg { width: 18px; height: 18px; display: block; shape-rendering: crispEdges; }
.theme-toggle .icon-moon { display: none; }
html.dark .theme-toggle .icon-sun { display: none; }
html.dark .theme-toggle .icon-moon { display: block; }
.theme-toggle:hover svg { animation: wiggle 300ms steps(3, end); }
@keyframes wiggle {
  33% { transform: rotate(-12deg); }
  66% { transform: rotate(12deg); }
}

.language-switch .lang-text { font-size: 12px; }

@media screen and (max-width: 600px) {
  .header {
    flex-direction: column;
    align-items: flex-start;
    gap: 14px;
    padding: 16px 0 14px;
    margin-bottom: 22px;
  }
  .header .menu { justify-content: flex-start; gap: 10px; }
  .brand-name { font-size: 24px; }
}

/* --------------------------------------------------------------------------
   Footer: pixel ground + wandering slime
   -------------------------------------------------------------------------- */
.footer {
  margin-top: 56px;
  font-size: 12px;
}
.ground {
  position: relative;
  height: 42px;
  background:
    linear-gradient(to bottom, var(--grass) 0 6px, var(--grass-dk) 6px 9px, transparent 9px),
    conic-gradient(from 90deg at 3px 3px, var(--dirt) 25%, var(--dirt-dk) 0) 0 9px / 15px 12px,
    var(--dirt);
}
.ground::before {
  /* grass tufts */
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  top: -3px;
  height: 3px;
  background: repeating-linear-gradient(90deg, var(--grass) 0 3px, transparent 3px 12px, var(--grass) 12px 18px, transparent 18px 27px);
}
.slime {
  position: absolute;
  left: 0;
  bottom: 39px;
  width: 36px;
  height: 30px;
  cursor: pointer;
  animation: slime-walk 18s linear infinite;
}
.slime-sprite {
  display: block;
  width: 36px;
  height: 30px;
  background-repeat: no-repeat;
  background-size: 36px 30px;
  image-rendering: pixelated;
  transform-origin: 50% 100%;
  animation: slime-bounce 600ms steps(3, end) infinite;
}
.slime.is-jumping .slime-sprite { animation: slime-jump 520ms steps(6, end); }
@keyframes slime-walk {
  0% { left: 0; transform: scaleX(1); }
  48% { left: calc(100% - 36px); transform: scaleX(1); }
  50% { left: calc(100% - 36px); transform: scaleX(-1); }
  98% { left: 0; transform: scaleX(-1); }
  100% { left: 0; transform: scaleX(1); }
}
@keyframes slime-bounce {
  0%, 100% { transform: scale(1, 1); }
  50% { transform: scale(1.1, 0.86); }
}
@keyframes slime-jump {
  0% { transform: scale(1.15, 0.8); }
  35% { transform: translateY(-26px) scale(0.9, 1.1); }
  70% { transform: translateY(0) scale(1.1, 0.88); }
  100% { transform: none; }
}
.coin-pop {
  position: absolute;
  bottom: 72px;
  font-family: var(--font-pixel);
  font-size: 12px;
  color: var(--gold);
  text-shadow: var(--px) var(--px) 0 var(--line);
  pointer-events: none;
  animation: coin-pop 700ms steps(7, end) forwards;
}
@keyframes coin-pop {
  to { transform: translateY(-30px); opacity: 0; }
}

.footer-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px 16px;
  padding: 14px 0 28px;
  font-family: var(--font-pixel);
  color: var(--muted);
}
.coin-counter { display: inline-flex; align-items: center; gap: 6px; }
.coin {
  display: inline-block;
  width: 12px;
  height: 12px;
  background:
    linear-gradient(var(--gold), var(--gold)) 3px 0 / 6px 12px no-repeat,
    linear-gradient(var(--gold), var(--gold)) 0 3px / 12px 6px no-repeat;
  animation: coin-spin 1.2s steps(4, end) infinite;
}
@keyframes coin-spin {
  50% { transform: scaleX(0.3); }
}
.footer .footer-repo {
  color: var(--muted);
  text-decoration: none;
}
.footer .footer-repo:hover { color: var(--accent); }

/* --------------------------------------------------------------------------
   Back-to-top
   -------------------------------------------------------------------------- */
#to-top {
  position: fixed;
  z-index: 60;
  right: 20px;
  bottom: 20px;
  width: 40px;
  height: 40px;
  padding: 8px;
  transform: translateY(90px);
  transition: transform 240ms steps(4, end), background-color 90ms steps(2, end);
}
#to-top svg { width: 100%; height: 100%; display: block; shape-rendering: crispEdges; }
#to-top.show { transform: translateY(0); }
#to-top.show:hover { transform: translateY(-4px); }
#to-top.launch { transform: translateY(-120vh) !important; transition: transform 500ms steps(8, end); }

/* --------------------------------------------------------------------------
   Toast + click particles + CRT easter egg
   -------------------------------------------------------------------------- */
.px-toast {
  position: fixed;
  left: 50%;
  top: 18px;
  z-index: 200;
  padding: 10px 14px;
  font-family: var(--font-pixel);
  font-size: 12px;
  transform: translate(-50%, -80px);
  transition: transform 220ms steps(4, end);
  pointer-events: none;
}
.px-toast.show { transform: translate(-50%, 0); }

.px-particle {
  position: fixed;
  z-index: 300;
  width: 6px;
  height: 6px;
  pointer-events: none;
  animation: px-burst 520ms steps(6, end) forwards;
}
@keyframes px-burst {
  to { transform: translate(var(--dx), var(--dy)) scale(0.4); opacity: 0; }
}

html.crt body::after {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 400;
  pointer-events: none;
  background:
    repeating-linear-gradient(to bottom, rgba(0, 0, 0, 0.12) 0 1px, transparent 1px 3px),
    radial-gradient(ellipse at center, transparent 60%, rgba(0, 0, 0, 0.35));
  animation: crt-flicker 120ms steps(2, end) infinite;
}
html.crt .header,
html.crt .page,
html.crt .footer { filter: saturate(1.25) contrast(1.05); }
@keyframes crt-flicker { 50% { opacity: 0.85; } }

/* --------------------------------------------------------------------------
   Comments (utterances is cross-origin)
   -------------------------------------------------------------------------- */
.comments-container { isolation: isolate; margin-top: 40px; }
html:not(.dark) .comments-container .utterances-frame { mix-blend-mode: multiply; }

/* --------------------------------------------------------------------------
   Motion safety
   -------------------------------------------------------------------------- */
@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;
  }
  .slime { animation: none; left: 12px; }
  .px-particle { display: none; }
}
