/* ClassMemorial frontend — mobile-first, WeChat-friendly, light theme.
   Designed for QR-code traffic: fast first paint, no hover-only interactions,
   touch targets ≥44px, responsive images. */

:root {
  --c-bg: #f6f5f3;
  --c-surface: #ffffff;
  --c-surface-2: #fbfaf8;
  --c-text: #2a2a28;
  --c-text-soft: #4a4a47;
  --c-muted: #7a7873;
  --c-border: #ece9e3;
  --c-border-soft: #f2f0eb;
  --c-accent: #534AB7;
  --c-accent-2: #7F77DD;
  --c-accent-soft: #eeedfe;
  --c-accent-text: #3c3489;
  --c-red: #c0392b;
  --c-green: #1d9e75;
  --c-amber: #b7791f;
  --radius: 10px;
  --radius-lg: 16px;
  --radius-xl: 22px;
  --shadow-sm: 0 1px 2px rgba(20,20,40,.04);
  --shadow: 0 4px 16px rgba(20,20,40,.06);
  --shadow-lg: 0 10px 30px rgba(20,20,40,.10);
  --maxw: 820px;
  --header-h: 60px;
  --font-sans: 'HarmonyOS Sans', 'HarmonyOS Sans SC', -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", Roboto, sans-serif;
  --font-serif: 'HarmonyOS Sans', 'HarmonyOS Sans SC', "Noto Serif SC", "Source Han Serif SC", "Songti SC", Georgia, serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --c-bg: #141416;
    --c-surface: #1e1e22;
    --c-surface-2: #25252a;
    --c-text: #ece9e6;
    --c-text-soft: #cfcdba;
    --c-muted: #918f89;
    --c-border: #2e2e33;
    --c-border-soft: #28282d;
    --c-accent-soft: #2a2655;
    --shadow-sm: 0 1px 2px rgba(0,0,0,.3);
    --shadow: 0 4px 16px rgba(0,0,0,.4);
    --shadow-lg: 0 10px 30px rgba(0,0,0,.5);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--font-sans);
  background: var(--c-bg);
  color: var(--c-text);
  line-height: 1.75;
  font-size: 16px;
  font-weight: 500;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
img { max-width: 100%; height: auto; }
a { color: var(--c-accent); text-decoration: none; transition: color .15s; }
a:active { opacity: .65; }

.container { max-width: var(--maxw); margin: 0 auto; padding: 0 18px; }

/* ---------- header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: rgba(255,255,255,.86);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--c-border-soft);
}
@media (prefers-color-scheme: dark) {
  .site-header { background: rgba(30,30,34,.82); }
}
.header-inner { display: flex; align-items: center; justify-content: space-between; height: var(--header-h); }
.brand { display: flex; flex-direction: column; line-height: 1.15; }
.brand-title { font-weight: 700; font-size: 18px; color: var(--c-text); letter-spacing: .3px; }
.brand-sub { font-size: 11px; color: var(--c-muted); letter-spacing: 1px; }
.nav-toggle {
  display: flex; flex-direction: column; gap: 5px;
  background: none; border: 0; padding: 10px; cursor: pointer; border-radius: 8px;
}
.nav-toggle span { width: 22px; height: 2px; background: var(--c-text); border-radius: 2px; transition: .22s; }
.nav-toggle[aria-expanded="true"] span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.nav-toggle[aria-expanded="true"] span:nth-child(2) { opacity: 0; }
.nav-toggle[aria-expanded="true"] span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

.site-nav {
  position: fixed; top: var(--header-h); left: 0; right: 0;
  background: var(--c-surface); border-bottom: 1px solid var(--c-border);
  transform: translateY(-130%); transition: transform .25s ease; z-index: 49;
  padding: 8px 0; box-shadow: var(--shadow);
}
.site-nav.open { transform: translateY(0); }
.site-nav ul { list-style: none; margin: 0; padding: 0; }
.site-nav a {
  display: block; padding: 14px 22px; color: var(--c-text-soft); font-size: 15px;
  border-left: 3px solid transparent;
}
.site-nav a.active, .site-nav a:active { color: var(--c-accent); border-left-color: var(--c-accent); background: var(--c-accent-soft); }

@media (min-width: 760px) {
  .nav-toggle { display: none; }
  .site-nav { position: static; transform: none; border: 0; padding: 0; box-shadow: none; background: transparent; }
  .site-nav ul { display: flex; gap: 2px; }
  .site-nav a { padding: 8px 14px; border-left: 0; border-radius: 20px; color: var(--c-text-soft); }
  .site-nav a.active { background: var(--c-accent-soft); color: var(--c-accent-text); }
}

/* ---------- main ---------- */
.main-content { padding-top: 26px; padding-bottom: 56px; min-height: 60vh; }

/* ---------- hero ---------- */
.hero {
  position: relative;
  min-height: var(--hero-h, 70vh);
  display: flex; align-items: center; justify-content: center;
  background-size: cover; background-position: center;
  margin: 0 calc(50% - 50vw);   /* break out of .container to full width */
  width: 100vw;
}
.hero::after {
  content: ""; position: absolute; inset: 0;
  background: rgba(0,0,0,.35);
  pointer-events: none;
}
.hero-inner { position: relative; z-index: 2; text-align: center; color: #fff; padding: 40px 20px; }
.hero-title {
  margin: 0; font-size: clamp(28px, 6vw, 52px); font-weight: 700;
  letter-spacing: 2px; text-shadow: 0 2px 20px rgba(0,0,0,.5);
  font-family: var(--font-serif);
}
.hero-sub {
  margin: 14px 0 0; font-size: clamp(14px, 2.6vw, 18px);
  opacity: .95; letter-spacing: 1px; text-shadow: 0 1px 8px rgba(0,0,0,.5);
}
.hero-scroll {
  position: absolute; bottom: 18px; left: 50%; transform: translateX(-50%);
  color: #fff; font-size: 30px; line-height: 1; opacity: .85;
  animation: bounce 1.8s infinite; z-index: 2;
}
@keyframes bounce {
  0%,100% { transform: translate(-50%, 0); }
  50% { transform: translate(-50%, 8px); }
}
@media (max-width: 760px) { .hero { min-height: 56vh; } }

/* ---------- post list ---------- */
.post-list { display: flex; flex-direction: column; gap: 18px; margin-top: 22px; }
.post-card {
  background: var(--c-surface); border: 1px solid var(--c-border-soft);
  border-radius: var(--radius-lg); overflow: hidden; box-shadow: var(--shadow-sm);
  transition: transform .18s, box-shadow .18s, border-color .18s;
}
.post-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: var(--c-border); }
.post-card:active { transform: scale(.995); }
.post-cover { display: block; }
.post-cover img { width: 100%; aspect-ratio: 16/7; object-fit: cover; display: block; }
.post-card-body { padding: 18px 22px 20px; }
.post-card-title { margin: 0 0 8px; font-size: 19px; font-weight: 600; line-height: 1.45; }
.post-card-title a { color: var(--c-text); }
.post-card-title a:hover { color: var(--c-accent); }
.pin { font-size: 11px; background: var(--c-red); color: #fff; padding: 2px 7px; border-radius: 6px; vertical-align: middle; margin-left: 6px; font-weight: 500; }
.post-meta { font-size: 13px; color: var(--c-muted); margin-bottom: 10px; display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.cat { background: var(--c-accent-soft); color: var(--c-accent-text); padding: 2px 10px; border-radius: 12px; font-size: 12px; }
.post-excerpt { color: var(--c-text-soft); font-size: 14.5px; margin: 8px 0 14px; line-height: 1.7; }
.read-more { font-size: 14px; font-weight: 500; }
.read-more::after { content: " →"; }

/* ---------- post detail ---------- */
.post-detail, .page-detail { background: var(--c-surface); border: 1px solid var(--c-border-soft); border-radius: var(--radius-xl); padding: 30px 28px; box-shadow: var(--shadow); }
.post-header { margin-bottom: 22px; padding-bottom: 18px; border-bottom: 1px solid var(--c-border-soft); }
.post-title, .page-title { margin: 0 0 10px; font-size: 26px; line-height: 1.35; font-family: var(--font-serif); font-weight: 700; }
.post-license { margin-top: 34px; padding-top: 18px; border-top: 1px dashed var(--c-border); font-size: 13px; color: var(--c-muted); }

/* markdown body */
.markdown-body { font-size: 16.5px; line-height: 1.85; color: var(--c-text-soft); word-break: break-word; }
.markdown-body h1, .markdown-body h2, .markdown-body h3, .markdown-body h4 { line-height: 1.4; margin: 1.5em 0 .6em; color: var(--c-text); font-family: var(--font-serif); font-weight: 700; }
.markdown-body h1 { font-size: 23px; } .markdown-body h2 { font-size: 20px; padding-bottom: 6px; border-bottom: 1px solid var(--c-border-soft); } .markdown-body h3 { font-size: 17px; } .markdown-body h4 { font-size: 15px; }
.markdown-body p { margin: .9em 0; }
.markdown-body img { border-radius: 10px; margin: 14px 0; display: block; box-shadow: var(--shadow-sm); }
.markdown-body blockquote { margin: 1.2em 0; padding: 10px 18px; border-left: 4px solid var(--c-accent-2); background: var(--c-surface-2); color: var(--c-text-soft); border-radius: 0 10px 10px 0; }
.markdown-body code { background: var(--c-accent-soft); color: var(--c-accent-text); padding: 2px 7px; border-radius: 5px; font-size: .9em; font-family: ui-monospace, "Cascadia Code", "JetBrains Mono", Consolas, monospace; }
.markdown-body pre { background: #1e1e2e; color: #e8e6e3; padding: 16px; border-radius: 10px; overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 1.1em 0; }
.markdown-body pre code { background: none; color: inherit; padding: 0; font-size: 13.5px; }
.markdown-body table { width: 100%; border-collapse: collapse; margin: 1.1em 0; display: block; overflow-x: auto; }
.markdown-body th, .markdown-body td { border: 1px solid var(--c-border); padding: 8px 13px; }
.markdown-body th { background: var(--c-surface-2); font-weight: 600; }
.markdown-body a { border-bottom: 1px solid var(--c-accent-2); }
.markdown-body a:hover { color: var(--c-accent-2); }
.markdown-body hr { border: 0; border-top: 1px dashed var(--c-border); margin: 2em 0; }
/* GFM extras: strikethrough, highlight, task list */
.markdown-body del, .markdown-body .tilde { text-decoration: line-through; color: var(--c-muted); }
.markdown-body mark { background: #fff3a8; color: #5a4500; padding: 1px 4px; border-radius: 3px; }
.markdown-body .task-list-item { list-style: none; }
.markdown-body .task-list-item input { margin-right: 6px; transform: translateY(1px); }

/* ---------- comments ---------- */
.comments { margin-top: 28px; background: var(--c-surface); border: 1px solid var(--c-border-soft); border-radius: var(--radius-xl); padding: 20px 24px; box-shadow: var(--shadow); }

/* ---------- gallery ---------- */
.gallery-page { }
.page-sub { color: var(--c-muted); margin-top: -4px; margin-bottom: 18px; }
.gallery-tabs { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 12px; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
.gallery-tabs::-webkit-scrollbar { display: none; }
.gallery-tabs .tab { white-space: nowrap; padding: 7px 16px; border: 1px solid var(--c-border); background: var(--c-surface); border-radius: 20px; font-size: 13px; color: var(--c-muted); cursor: pointer; transition: .15s; }
.gallery-tabs .tab.active { background: var(--c-accent); color: #fff; border-color: var(--c-accent); }
.gallery-grid { columns: 2; column-gap: 10px; }
@media (min-width: 560px) { .gallery-grid { columns: 3; } }
@media (min-width: 900px) { .gallery-grid { columns: 4; } }
.gallery-item { break-inside: avoid; margin-bottom: 10px; position: relative; border-radius: var(--radius); overflow: hidden; background: var(--c-border-soft); cursor: pointer; }
.gallery-item img { width: 100%; display: block; transition: transform .35s; }
.gallery-item:hover img { transform: scale(1.04); }
.gallery-item figcaption { position: absolute; left: 0; right: 0; bottom: 0; padding: 20px 10px 8px; background: linear-gradient(transparent, rgba(0,0,0,.72)); color: #fff; font-size: 12px; opacity: 0; transition: opacity .2s; }
.gallery-item:active figcaption, .gallery-item:hover figcaption { opacity: 1; }
.gi-title { display: block; font-weight: 500; }
.gi-desc { display: block; opacity: .85; }

/* lightbox */
.lightbox { position: fixed; inset: 0; background: rgba(0,0,0,.94); display: none; align-items: center; justify-content: center; z-index: 100; }
.lightbox.open { display: flex; }
.lb-img { max-width: 94vw; max-height: 86vh; object-fit: contain; border-radius: 4px; }
.lb-close, .lb-prev, .lb-next { position: absolute; background: rgba(255,255,255,.14); color: #fff; border: 0; width: 48px; height: 48px; border-radius: 50%; font-size: 28px; cursor: pointer; display: flex; align-items: center; justify-content: center; transition: background .15s; }
.lb-close:hover, .lb-prev:hover, .lb-next:hover { background: rgba(255,255,255,.28); }
.lb-close { top: 18px; right: 18px; }
.lb-prev { left: 10px; top: 50%; transform: translateY(-50%); }
.lb-next { right: 10px; top: 50%; transform: translateY(-50%); }
.lb-caption { position: absolute; bottom: 28px; left: 0; right: 0; text-align: center; color: #fff; font-size: 14px; padding: 0 60px; }

/* ---------- archive ---------- */
.archive-page { background: var(--c-surface); border: 1px solid var(--c-border-soft); border-radius: var(--radius-xl); padding: 24px 26px; box-shadow: var(--shadow); }
.archive-month { font-size: 15px; color: var(--c-accent); margin: 22px 0 8px; padding-bottom: 6px; border-bottom: 1px solid var(--c-border-soft); font-weight: 600; }
.archive-month:first-child { margin-top: 0; }
.archive-row { display: flex; gap: 12px; align-items: baseline; padding: 11px 0; border-bottom: 1px dashed var(--c-border-soft); color: var(--c-text-soft); transition: padding .15s; }
.archive-row:hover { padding-left: 6px; color: var(--c-accent); }
.archive-row:last-child { border-bottom: 0; }
.ar-date { font-size: 12px; color: var(--c-muted); flex-shrink: 0; width: 82px; font-variant-numeric: tabular-nums; }
.ar-title { flex: 1; font-weight: 500; }
.ar-cats i { font-style: normal; font-size: 11px; color: var(--c-muted); background: var(--c-accent-soft); padding: 1px 7px; border-radius: 8px; margin-left: 4px; }

/* ---------- footer ---------- */
.site-footer { background: var(--c-surface); border-top: 1px solid var(--c-border-soft); padding: 28px 0 36px; margin-top: 36px; }
.footer-inner { text-align: center; font-size: 13px; color: var(--c-muted); }
.footer-meta { margin: 6px 0; }
.footer-contact { margin: 6px 0; }
.footer-beian { margin-top: 12px; display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; align-items: center; }
.footer-beian a { color: var(--c-muted); display: inline-flex; align-items: center; gap: 5px; }
.footer-beian a:hover { color: var(--c-accent); }
.footer-beian img { width: 18px; height: 18px; display: block; }

/* ---------- empty / 404 ---------- */
.empty { text-align: center; padding: 70px 20px; color: var(--c-muted); }
.notfound { text-align: center; padding: 90px 20px; }
.nf-code { font-size: 72px; font-weight: 700; color: var(--c-accent); font-family: var(--font-serif); }

/* ---------- agreement popup ---------- */
.agreement-mask { position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 200; display: flex; align-items: center; justify-content: center; padding: 16px; }
.agreement-box { background: var(--c-surface); border-radius: var(--radius-xl); width: 100%; max-width: 540px; max-height: 86vh; display: flex; flex-direction: column; overflow: hidden; box-shadow: var(--shadow-lg); }
.agreement-box h2 { margin: 0; padding: 18px 22px; font-size: 17px; border-bottom: 1px solid var(--c-border-soft); font-family: var(--font-serif); }
.agreement-content { padding: 18px 22px; overflow-y: auto; -webkit-overflow-scrolling: touch; font-size: 14px; line-height: 1.75; color: var(--c-text-soft); }
.agreement-content h1, .agreement-content h2, .agreement-content h3 { font-size: 15px; margin: 1em 0 .4em; color: var(--c-text); }
.agreement-actions { padding: 14px 22px; border-top: 1px solid var(--c-border-soft); display: flex; flex-direction: column; gap: 10px; }
.agreement-actions label { font-size: 14px; display: flex; align-items: center; gap: 8px; cursor: pointer; }
.agreement-actions .btns { display: flex; gap: 10px; }
.agreement-actions button { flex: 1; padding: 12px; border-radius: 10px; border: 1px solid var(--c-border); background: var(--c-surface); font-size: 15px; cursor: pointer; transition: .15s; }
.agreement-actions button#agree-btn { background: var(--c-accent); color: #fff; border-color: var(--c-accent); }
.agreement-actions button:disabled { opacity: .5; }
.agreement-actions button#reject-btn { color: var(--c-muted); }

/* safe-area for iPhone notch + WeChat bottom bar */
@supports (padding: env(safe-area-inset-bottom)) {
  .site-footer { padding-bottom: calc(36px + env(safe-area-inset-bottom)); }
}
