/* unun.io 主样式 — 对齐 updn.pub Bear 风格 */
@import url('variables.css?v=20260211q');

/* Reset */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* Base */
html {
  overflow-y: scroll;
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-body);
  font-size: var(--font-size-base);
  line-height: var(--line-height-base);
  color: var(--color-text);
  background: var(--color-bg);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Main content area fills remaining space → footer always at bottom */
main.container {
  flex: 1;
}

/* Selection */
::selection {
  background: var(--color-accent);
  color: var(--color-bg);
}

/* Layout */
.container {
  width: 100%;
  max-width: var(--page-width, 1024px);
  margin: 0 auto;
  padding: var(--header-padding-top, 6.5rem) var(--spacing-lg, 1.5rem) var(--spacing-2xl, 3rem);
}

.content {
  max-width: var(--content-width, 700px);
  margin: 0 auto;
}

/* Links */
a {
  color: var(--color-link);
  text-decoration: none;
  transition: color 0.2s;
}

a:hover {
  color: var(--color-link);
}

/* ===== Blog Post Detail ===== */

/* Post title (above prose) */
.post-title {
  font-size: var(--font-size-h1);
  font-weight: 700;
  line-height: var(--line-height-heading);
  margin-bottom: 0.3em;
}

/* Post meta at bottom */
.post-meta-wrapper {
  padding-top: 2.5em;
  margin-bottom: 1em;
  display: flex;
  align-items: center;
}

.post-meta {
  font-size: var(--font-size-sm);
  color: var(--color-text-secondary);
}

/* Post tags at bottom */
.post-tags-wrapper {
  margin-top: 2em;
  margin-bottom: 1em;
}

.post-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5em;
}

.bear-tag {
  display: inline-block;
  padding: 0.3em 0.8em;
  background-color: #E4E5E6;
  color: #444444;
  border-radius: 1em;
  font-size: var(--font-size-sm);
  text-decoration: none;
  transition: background-color 0.2s;
}

.bear-tag:hover {
  background-color: #d0d1d2;
}

html[data-theme="dark"] .bear-tag {
  background-color: #333333;
  color: #e0e0e0;
}

html[data-theme="dark"] .bear-tag:hover {
  background-color: #444444;
}

/* ===== Prose (article body) — 对齐 updn.pub markdown.css ===== */

/* Headings — em 基准间距（对齐 updn.pub） */
.prose h1,
.prose h2,
.prose h3,
.prose h4,
.prose h5,
.prose h6 {
  font-family: var(--font-heading);
  line-height: var(--line-height-heading);
}

.prose h1 { font-size: var(--font-size-h1); margin: 1.5em 0 0.5em; font-weight: 700; }
.prose h2 { font-size: var(--font-size-h2); margin: 1.4em 0 0.4em; font-weight: 600; }
.prose h3 { font-size: var(--font-size-h3); margin: 1.3em 0 0.3em; font-weight: 600; }
.prose h4 { font-size: var(--font-size-h4); margin: 1.2em 0 0.2em; font-weight: 600; }
.prose h5 { font-size: 1em;                 margin: 1.1em 0 0.2em; font-weight: 600; }
.prose h6 { font-size: 0.9em;               margin: 1em 0 0.2em;   font-weight: 600; }

/* First heading: tighter bottom margin */
.prose h1:first-child { margin-top: 0; margin-bottom: 0.3em; }

/* Heading links: inherit color */
.prose h1 a, .prose h2 a, .prose h3 a,
.prose h4 a, .prose h5 a, .prose h6 a {
  color: inherit;
  text-decoration: none;
}

/* Scroll margin for fixed header */
.prose h1[id], .prose h2[id], .prose h3[id],
.prose h4[id], .prose h5[id], .prose h6[id] {
  scroll-margin-top: var(--header-padding-top, 6rem);
}

/* Paragraphs */
.prose p {
  margin: 1em 0;
}

.prose p:first-child { margin-top: 0; }
.prose p:last-child { margin-bottom: 0; }

/* Links — 对齐 updn.pub：默认下划线 + offset */
.prose a {
  color: var(--color-link);
  text-decoration: underline;
  text-underline-offset: 2px;
  word-break: break-all;
  overflow-wrap: break-word;
}

.prose a:hover {
  text-decoration-thickness: 2px;
}

/* External link emoji */
.prose p a[href^="http"]::before {
  content: "🔗 ";
  font-size: 0.7em;
  opacity: 0.4;
  text-decoration: none;
  display: inline;
}

/* Strong / Em / Del */
.prose strong { font-weight: 700; }
.prose em { font-style: italic; }

.prose del,
.prose s {
  text-decoration: line-through;
  color: var(--color-text-secondary);
}

/* Mark / Highlight */
.prose mark {
  background-color: var(--color-highlight-bg);
  color: var(--color-highlight-text);
  padding: 0.1em 0.2em;
  border-radius: 2px;
}

/* Bear-style lists */
.prose ul {
  margin-bottom: var(--spacing-md);
  padding-left: 1.5em;
  list-style: none;
}

.prose ul > li {
  position: relative;
  margin: 0.4em 0;
}

.prose ul > li::before {
  content: "•";
  position: absolute;
  left: -1.2em;
  color: var(--color-accent);
  font-weight: bold;
}

.prose ol {
  margin-bottom: var(--spacing-md);
  padding-left: 1.5em;
  list-style: none;
  counter-reset: bear-ol;
}

.prose ol > li {
  position: relative;
  margin: 0.4em 0;
  counter-increment: bear-ol;
}

.prose ol > li::before {
  content: counter(bear-ol) ".";
  position: absolute;
  left: -1.8em;
  color: var(--color-accent);
  font-weight: 500;
}

.prose li {
  margin-bottom: var(--spacing-xs);
}

.prose ul ul,
.prose ol ol,
.prose ul ol,
.prose ol ul {
  margin: 0.3em 0;
}

/* Bear-style blockquote */
.prose blockquote {
  padding-left: 1.5em;
  margin: 1.5em 0;
  position: relative;
  color: var(--color-accent);
  border-left: none;
}

.prose blockquote::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  width: 3px;
  height: 100%;
  background-color: var(--color-accent);
  border-radius: 3px;
}

/* Bear-style inline code */
.prose code {
  font-family: var(--font-mono);
  font-size: var(--font-size-code);
  background: var(--color-code-bg);
  padding: 0.15em 0.4em;
  border-radius: 3px;
  border: 1px solid var(--color-border);
}

/* Bear-style code block */
.prose pre {
  font-family: var(--font-mono);
  font-size: 0.91em;
  line-height: 1.6;
  background: var(--color-code-bg);
  padding: 1em;
  border-radius: 6px;
  overflow-x: auto;
  margin-bottom: var(--spacing-md);
}

.prose pre code {
  background: none;
  padding: 0;
  border: none;
  border-radius: 0;
}

/* Code block wrapper (JS-injected) */
.code-block {
  position: relative;
  margin-bottom: var(--spacing-md);
}

.code-block .prose pre,
.code-block pre {
  margin-bottom: 0;
  border-radius: 0 0 6px 6px;
}

.code-block-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--color-code-bg);
  border-radius: 6px 6px 0 0;
  padding: 0.4em 0.8em;
  border-bottom: 1px solid var(--color-border);
  min-height: 2em;
}

.code-block-lang {
  font-family: var(--font-mono);
  font-size: 0.75em;
  font-weight: 600;
  color: var(--color-text-secondary);
  letter-spacing: 0.05em;
  user-select: none;
}

/* Copy button — hidden by default */
.code-copy-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  color: var(--color-text-secondary);
  opacity: 0;
  transition: opacity 0.15s, color 0.15s, background-color 0.15s;
}

/* Hover on code block → show button (light) */
.code-block:hover .code-copy-btn {
  opacity: 0.5;
}

/* Hover on the button itself → darken */
.code-block .code-copy-btn:hover {
  opacity: 1;
  color: var(--color-text);
  background-color: rgba(0, 0, 0, 0.08);
}

html[data-theme="dark"] .code-block .code-copy-btn:hover {
  background-color: rgba(255, 255, 255, 0.1);
}

/* Copied state → checkmark always visible */
.code-copy-btn.copied {
  opacity: 1;
  color: #22c55e;
}

/* Images — 对齐 updn.pub */
.prose img {
  max-width: 100%;
  height: auto;
  border-radius: 4px;
  margin: 1.5em 0;
}

/* Bear-style table (bottom border only) */
.prose table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5em 0;
}

.prose th,
.prose td {
  padding: 0.6em 1em;
  border-bottom: 1px solid var(--color-border);
  text-align: left;
}

.prose th {
  font-weight: 600;
}

/* Horizontal rule — 对齐 updn.pub */
.prose hr {
  border: none;
  border-top: 1px solid var(--color-border);
  margin: 2em 0;
}

/* ===== Blog Posts Grid (Card Layout) ===== */
.posts-grid {
  display: grid;
  gap: 1.5rem;
}

/* Post Card */
.post-card-link {
  text-decoration: none;
  display: block;
  color: var(--color-text);
  perspective: 1000px;
}

.post-card-link:hover {
  text-decoration: none;
}

.post-card {
  background: var(--color-bg);
  border-radius: 12px;
  padding: 24px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
  transition: box-shadow 0.3s ease;
  cursor: pointer;
  transform-style: preserve-3d;
  will-change: transform;
}

html[data-theme="dark"] .post-card {
  background: rgba(255, 255, 255, 0.05);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.post-card:hover {
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12);
}

html[data-theme="dark"] .post-card:hover {
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.5);
}

.post-card-content {
  transform: translateZ(20px);
  position: relative;
}

.post-card-pinned {
  font-size: var(--font-size-xs);
  color: var(--color-accent);
  font-weight: 500;
}

.post-card-date {
  font-size: var(--font-size-sm);
  color: var(--color-text-secondary);
  display: block;
  margin-bottom: 8px;
}

.post-card-title {
  font-size: var(--font-size-lg);
  font-weight: 600;
  margin: 0 0 12px 0;
  color: #333;
  line-height: var(--line-height-tight);
}

html[data-theme="dark"] .post-card-title {
  color: #eee;
}

.post-card-desc {
  font-size: var(--font-size-base);
  color: #666;
  line-height: 1.6;
  margin: 0 0 12px 0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

html[data-theme="dark"] .post-card-desc {
  color: #bbb;
}

.post-card-tags {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.post-card-tag {
  font-size: var(--font-size-sm);
  color: #444;
  background: #E4E5E6;
  padding: 0.3em 0.8em;
  border-radius: 1em;
}

html[data-theme="dark"] .post-card-tag {
  background: #333333;
  color: #e0e0e0;
}

/* ===== Gallery ===== */
.gallery {
  display: grid;
  gap: var(--spacing-sm);
  margin: var(--spacing-md) 0;
}

.gallery-1 { grid-template-columns: 1fr; }
.gallery-1 img { aspect-ratio: auto; }
.gallery-2 { grid-template-columns: repeat(2, 1fr); }
.gallery-3 { grid-template-columns: repeat(3, 1fr); }
.gallery-4 { grid-template-columns: repeat(2, 1fr); }

@media (min-width: 640px) {
  .gallery-4 { grid-template-columns: repeat(4, 1fr); }
}

.gallery img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 6px;
}

/* ===== Timeline (notes) — styles moved to note.css ===== */

/* ===== Home sections ===== */
.home-section {
  margin-bottom: var(--spacing-2xl);
}

.home-section h2 {
  font-size: var(--font-size-xl);
  font-weight: 600;
  margin-bottom: var(--spacing-lg);
  padding-bottom: var(--spacing-sm);
  border-bottom: 1px solid var(--color-border);
}

.home-section h2 a {
  color: var(--color-text);
  text-decoration: none;
}

.section-more {
  margin-top: var(--spacing-md);
  font-size: var(--font-size-sm);
}

/* ===== Footer ===== */
.site-footer {
  padding: var(--spacing-xl) 0;
  margin-top: var(--spacing-2xl);
  text-align: center;
  font-size: var(--font-size-xs);
  color: var(--color-text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  font-weight: 600;
}

.site-footer a {
  color: var(--color-text-secondary);
  text-decoration: none;
}

.site-footer a:hover {
  color: var(--color-accent);
}

.rss-link {
  display: inline-flex;
  align-items: center;
  transition: color 0.2s;
}

.rss-link:hover {
  color: var(--color-accent);
}

/* ===== Back link ===== */
.back-link {
  display: inline-block;
  margin-bottom: var(--spacing-lg);
  color: var(--color-text-secondary);
  font-size: var(--font-size-sm);
}

.back-link:hover {
  color: var(--color-accent);
}

/* ===== Pagination ===== */
.pagination {
  display: flex;
  justify-content: center;
  gap: var(--spacing-md);
  padding: var(--spacing-xl) 0;
}

.pagination a,
.pagination span {
  font-size: var(--font-size-sm);
  color: var(--color-text-secondary);
}

.pagination a:hover {
  color: var(--color-accent);
}

/* Pinned indicator */
.pinned-badge {
  font-size: var(--font-size-xs);
  color: var(--color-accent);
  font-weight: 500;
}

/* ─── Notification Bell ─── */
.notif-bell {
  position: relative;
  background: none; border: none; cursor: pointer;
  color: var(--color-text-secondary);
  padding: 0.35rem; border-radius: 6px;
  transition: color 0.2s;
  display: none; /* shown by notifications.js when logged in */
}
.notif-bell:hover { color: var(--color-text); }
.notif-badge {
  position: absolute; top: -2px; right: -4px;
  background: #DD4C4F; color: #fff;
  font-size: 0.6rem; font-weight: 600;
  min-width: 16px; height: 16px;
  border-radius: 8px; padding: 0 4px;
  display: flex; align-items: center; justify-content: center;
  line-height: 1;
}
.notif-panel {
  position: fixed; z-index: 900;
  width: 320px; max-height: 420px;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.15);
  overflow: hidden;
}
html[data-theme="dark"] .notif-panel {
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
}
.notif-panel-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--color-border);
}
.notif-panel-title { font-weight: 600; font-size: 0.9rem; }
.notif-mark-read {
  background: none; border: none; cursor: pointer;
  font-size: 0.8rem; color: #DD4C4F;
}
.notif-list { max-height: 340px; overflow-y: auto; }
.notif-item {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid rgba(0,0,0,0.04);
  transition: background 0.15s;
}
html[data-theme="dark"] .notif-item { border-bottom-color: rgba(255,255,255,0.04); }
.notif-item:hover { background: rgba(0,0,0,0.02); }
html[data-theme="dark"] .notif-item:hover { background: rgba(255,255,255,0.03); }
.notif-item.unread { background: rgba(221,76,79,0.04); }
.notif-text { font-size: 0.85rem; line-height: 1.4; }
.notif-time { font-size: 0.75rem; color: var(--color-text-secondary); margin-top: 0.25rem; }
.notif-empty {
  padding: 2rem 1rem; text-align: center;
  color: var(--color-text-secondary); font-size: 0.85rem;
}
@media (max-width: 520px) {
  .notif-panel { width: calc(100vw - 2rem); right: 1rem !important; }
}
