/* Common Styles — shared across all themes */

/* ========== Base Reset ========== */
* { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }

a { text-decoration: none; }

/* Skip link for accessibility */
.skip-link {
  position: absolute;
  left: -9999px;
  top: auto;
  width: 1px;
  height: 1px;
  overflow: hidden;
  background: var(--accent);
  color: #fff;
  padding: 0.5rem 1rem;
  border-radius: 4px;
  z-index: 9999;
}
.skip-link:focus {
  position: fixed;
  top: 0;
  left: 0;
  width: auto;
  height: auto;
}

/* ========== Focus visible ========== */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 2px;
}
.skip-link:focus-visible { outline: none; }

/* ========== Reduced motion ========== */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ========== Selection ========== */
::selection { background: var(--accent); color: #fff; }

/* ========== Search highlight ========== */
.search-highlight {
  background: var(--accent);
  color: #fff;
  padding: 0.1rem 0.3rem;
  border-radius: 3px;
}

/* ========== Post card cover ========== */
.post-card-cover {
  width: 100%;
  max-height: 240px;
  object-fit: cover;
  border-radius: 8px;
  margin-bottom: 0.75rem;
}

/* ========== Tag base ========== */
.tag {
  display: inline-block;
  padding: 0.2rem 0.6rem;
  border-radius: 4px;
  font-size: 0.75rem;
  transition: all 0.2s;
}

/* ========== Category badge ========== */
.article-category, .card-category {
  display: inline-block;
  padding: 0.2rem 0.6rem;
  border-radius: 4px;
  font-size: 0.75rem;
  background: var(--accent);
  color: #fff;
  text-decoration: none;
  margin-right: 0.5rem;
}
.article-category a, .card-category a { color: #fff; text-decoration: none; }

/* ========== Code block copy button ========== */
.code-copy-btn {
  position: absolute;
  top: 0.4rem;
  right: 0.4rem;
  padding: 0.25rem 0.6rem;
  font-size: 0.75rem;
  background: var(--bg-secondary);
  color: var(--text-secondary);
  border: 1px solid var(--border);
  border-radius: 4px;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.2s;
  font-family: inherit;
}
.article-content pre { position: relative; overflow-x: auto; }
.article-content:hover .code-copy-btn,
.code-copy-btn:focus { opacity: 1; }
.code-copy-btn:hover { background: var(--accent); color: #fff; border-color: var(--accent); }

/* ========== Article prev/next nav ========== */
.article-nav {
  display: flex;
  justify-content: space-between;
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
  gap: 1rem;
}
.article-nav a {
  flex: 1;
  padding: 1rem;
  border-radius: 8px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  text-decoration: none;
  color: var(--text);
  transition: all 0.2s;
  font-size: 0.9rem;
  display: block;
}
.article-nav a:hover { border-color: var(--accent); }
.article-nav-prev { text-align: left; }
.article-nav-next { text-align: right; }

/* ========== Share buttons ========== */
.share-buttons {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem 0;
  margin: 1.5rem 0;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.share-label { font-size: 0.9rem; color: var(--text-secondary); font-weight: 500; }
.share-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.4rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-secondary);
  font-size: 0.8rem;
  cursor: pointer;
  background: var(--bg);
  transition: all 0.2s;
  font-family: inherit;
}
.share-btn:hover { border-color: var(--accent); color: var(--accent); }
.share-btn svg { width: 14px; height: 14px; }
.share-btn span { margin-left: 0.25rem; }

/* ========== 404 ========== */
.not-found-page {
  text-align: center;
  padding: 6rem 0;
  background: var(--bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.not-found-page h1 { font-size: 5rem; color: var(--accent); margin-bottom: 1rem; line-height: 1; }
.not-found-text { font-size: 1.5rem; color: var(--text-secondary); margin-bottom: 2rem; }
.not-found-link {
  display: inline-block;
  padding: 0.75rem 2rem;
  background: var(--accent);
  color: #fff;
  border-radius: var(--radius-sm);
  font-size: 1rem;
  transition: all 0.2s;
}
.not-found-link:hover { background: var(--accent-hover); text-decoration: none; }

/* ========== Loading spinner ========== */
.loading-spinner {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 3rem 0;
}
.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ========== Reading progress bar ========== */
#reading-progress {
  position: fixed;
  top: 0;
  left: 0;
  width: 0%;
  height: 3px;
  background: var(--accent);
  z-index: 1000;
  transition: width 0.1s linear;
}

/* ========== Pagination ========== */
.pagination {
  display: flex;
  justify-content: center;
  gap: 0.5rem;
  margin: 2rem 0;
}
.pagination a, .pagination span {
  padding: 0.5rem 1rem;
  font-size: 0.9rem;
  border-radius: 6px;
}
.pagination a:hover { text-decoration: none; }

/* ========== Empty state ========== */
.empty-state {
  text-align: center;
  padding: 4rem 0;
  color: var(--text-secondary);
}
.empty-state svg { width: 48px; height: 48px; margin-bottom: 1rem; opacity: 0.4; }

/* ========== TOC shared ========== */
.toc ul { list-style: none; }
.toc li { margin: 0.3rem 0; }
.toc li[data-level="2"] { padding-left: 0; }
.toc li[data-level="3"] { padding-left: 1rem; }
.toc li[data-level="4"] { padding-left: 2rem; }

/* ========== Archives ========== */
.archive-year { margin-bottom: 2rem; }
.archive-year h2 { font-size: 1.5rem; margin-bottom: 0.75rem; color: var(--accent); }
.archive-month { margin-left: 1rem; margin-bottom: 1rem; }
.archive-month h3 { font-size: 1.1rem; margin-bottom: 0.5rem; color: var(--text-secondary); }
.archive-count { color: var(--text-muted); font-size: 0.9rem; }
.archive-list { list-style: none; }
.archive-list li { padding: 0.3rem 0; }
.archive-list li a { color: var(--text); }
.archive-date { color: var(--text-secondary); font-size: 0.85rem; margin-left: 0.5rem; }

/* ========== Dark mode image dimming ========== */
[data-theme="dark"] .post-card-cover,
[data-theme="dark"] .article-content img {
  filter: brightness(0.8) contrast(1.05);
  transition: filter 0.3s;
}
[data-theme="dark"] .post-card-cover:hover,
[data-theme="dark"] .article-content img:hover {
  filter: brightness(0.9) contrast(1.05);
}

/* ========== Admin shared ========== */
.admin-form { border-radius: 12px; padding: 2rem; }
.form-group { margin-bottom: 1.25rem; }
.form-label {
  display: block;
  font-weight: 600;
  margin-bottom: 0.4rem;
  font-size: 0.9rem;
}
.form-input, .form-textarea {
  width: 100%;
  padding: 0.7rem 0.9rem;
  border: 2px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  font-size: 0.95rem;
  color: var(--text);
}
.form-input:focus, .form-textarea:focus {
  outline: none;
  border-color: var(--accent);
}
.form-textarea {
  min-height: 300px;
  font-family: "JetBrains Mono", "SF Mono", monospace;
  font-size: 0.85rem;
  resize: vertical;
}
.form-row { display: flex; gap: 1rem; }
.form-row .form-group { flex: 1; }
.form-checkbox { display: flex; align-items: center; gap: 0.5rem; }
.form-checkbox input { width: auto; accent-color: var(--accent); }

.btn {
  display: inline-block;
  padding: 0.7rem 1.4rem;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.9rem;
  transition: all 0.2s;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-danger { background: #dc3545; color: #fff; }
.btn-secondary {
  background: var(--bg-secondary);
  color: var(--text);
  border: 1px solid var(--border);
}
.admin-actions { display: flex; gap: 0.5rem; margin-top: 1rem; }
.admin-list { list-style: none; }

.admin-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem;
  border-radius: 12px;
  margin-bottom: 0.75rem;
  transition: all 0.2s;
}
.admin-item-info { flex: 1; }
.admin-item-title { font-weight: 600; }
.admin-item-meta { font-size: 0.8rem; color: var(--text-secondary); }
.admin-item-actions { display: flex; gap: 0.5rem; }

/* Admin table */
.admin-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background: var(--bg, #fff);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: var(--shadow);
}
.admin-table th {
  text-align: left;
  padding: 0.85rem 1rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
  border-bottom: 2px solid var(--border);
  background: var(--bg-secondary);
}
.admin-table td {
  padding: 0.75rem 1rem;
  font-size: 0.9rem;
  color: var(--text);
  border-bottom: 1px solid var(--border);
}
.admin-table tr:last-child td { border-bottom: none; }
.admin-table tr:hover td { background: var(--accent-light); }
.admin-table code { font-size: 0.85rem; color: var(--accent); }

/* Categories page */
.categories-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
  margin: 1.5rem 0;
}
.category-item {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  padding: 1.25rem 1.5rem;
  background: var(--card-bg, #fff);
  border: 1px solid var(--border);
  border-radius: 10px;
  transition: all 0.2s;
  text-decoration: none;
  color: var(--text);
}
.category-item:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
}
.category-name { font-size: 1.1rem; font-weight: 600; color: var(--text); }
.category-desc { font-size: 0.85rem; color: var(--text-secondary); line-height: 1.4; }
.category-count { font-size: 0.8rem; color: var(--text-muted); margin-top: 0.2rem; }

/* ========== Mobile responsive ========== */
@media (max-width: 768px) {
  .container { padding: 0 1rem; }
  .form-row { flex-direction: column; gap: 0; }
  .admin-item { flex-direction: column; align-items: flex-start; gap: 0.75rem; }
  .footer-inner { flex-direction: column; gap: 1rem; }
  .article-nav { flex-direction: column; }
}
