/* ==========================================================================
   Shared UI Components (fixed module order)
   01. Buttons
   02. Forms
   03. Overlay / Sheet
   04. State Utilities
   05. Shared Lists
   06. Floating Global UI
   07. Pagination
   08. Cards
   09. Latest List
   10. Tag / News List
   ========================================================================== */

/* 01. Buttons */
.btn,
button,
input[type="submit"],
input[type="button"] {
  border-radius: 10px;
}

.btn {
  display: inline-block;
  padding: 8px 12px;
  border: 1px solid #ddd;
  text-decoration: none;
  color: inherit;
  white-space: nowrap;
  background: #fff;
}

.btn-primary {
  color: #fff;
  background: var(--accent);
  border: 1px solid transparent;
}

.btn-secondary {
  color: var(--primary);
  background: #fff;
  border: 1px solid var(--border);
}

.btn:hover {
  filter: brightness(.98);
}

.btn.active {
  background: #111;
  color: #fff;
  border-color: #111;
}

.btn.disabled,
.btn.is-disabled {
  opacity: 0.45;
  pointer-events: none;
}

/* 02. Forms */
.form-label {
  display: block;
  margin: 10px 0 6px;
  font-weight: 600;
}

.form-control {
  width: 100%;
  padding: 10px;
  border: 1px solid #ddd;
  border-radius: 10px;
}

.form-select {
  width: 100%;
  padding: 10px;
  border: 1px solid #ddd;
  border-radius: 10px;
  background: #fff;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.form-hint {
  color: #666;
  font-size: 13px;
  margin-top: 6px;
  line-height: 1.45;
}

/* 03. Overlay / Sheet */
.ui-overlay[hidden] {
  display: none !important;
}

.ui-overlay {
  position: fixed;
  inset: 0;
  z-index: 1200;
}

.ui-overlay__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.62);
  backdrop-filter: blur(2px);
}

.ui-sheet {
  position: absolute;
  left: 50%;
  bottom: max(16px, env(safe-area-inset-bottom, 16px));
  transform: translateX(-50%);
  width: min(92vw, 560px);
  border-radius: 24px;
  background: #ffffff;
  color: #172033;
  box-shadow: 0 28px 80px rgba(15, 23, 42, 0.3);
  padding: 22px;
}

.ui-sheet__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.ui-sheet__close {
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 999px;
  background: #eef2f7;
  color: #172033;
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
}

.ui-sheet__close:hover {
  background: #f6f8fb;
}

.ui-sheet__close:focus-visible {
  outline: 2px solid rgba(200, 29, 37, 0.55);
  outline-offset: 2px;
}

/* 04. State Utilities */
.ui-empty {
  color: #94a3b8;
  font-size: 0.95rem;
  line-height: 1.6;
}

.ui-loading {
  color: #94a3b8;
  font-size: 0.92rem;
  line-height: 1.6;
}

/* 05. Shared Lists */
.tag-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.sidebar-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.sidebar-list li {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px 0;
  border-bottom: 1px dashed #e6e6e6;
}

.sidebar-list li:last-child {
  border-bottom: none;
}

.sidebar-list a {
  color: #333;
  text-decoration: none;
}

.sidebar-list a:hover {
  color: #ff4757;
}

.sidebar-list .meta {
  font-size: 12px;
  color: #999;
}

.sidebar-list .empty {
  color: #999;
  padding: 8px 0;
}

/* 公共层仅保留结构与基础排版；页面差异请在 layout.css / article-detail.css 作用域内覆盖 */

/* 06. Floating Global UI */
.global-back-to-top {
  position: fixed;
  right: 16px;
  bottom: max(16px, env(safe-area-inset-bottom, 0px));
  z-index: 1100;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 56px;
  height: 56px;
  border: none;
  border-radius: 999px;
  background: color-mix(in srgb, var(--accent) 86%, #000 14%);
  color: #fff;
  box-shadow: 0 14px 28px rgba(10, 18, 32, 0.28);
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transform: translateY(12px);
  transition: opacity 0.24s ease, transform 0.24s ease, box-shadow 0.2s ease, background 0.2s ease;
}
.global-back-to-top__icon { font-size: 1rem; line-height: 1; }
.global-back-to-top__label { display: none; }
.global-back-to-top.is-visible { opacity: 1; pointer-events: auto; transform: translateY(0); }
.global-back-to-top:hover { background: color-mix(in srgb, var(--accent) 72%, #000 28%); box-shadow: 0 18px 30px rgba(10, 18, 32, 0.34); }

.pwa-install-btn {
  position: fixed;
  right: 16px;
  bottom: 18px;
  z-index: 99;
  border: none;
  border-radius: 999px;
  padding: 10px 14px;
  font-weight: 700;
  color: #fff;
  background: #0f172a;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.28);
}

.pwa-install-btn[hidden] { display: none !important; }

.pwa-status-banner {
  position: fixed;
  right: 16px;
  bottom: 74px;
  z-index: 98;
  width: min(360px, calc(100vw - 24px));
  border-radius: 12px;
  border: 1px solid #dbe2ef;
  background: #fff;
  box-shadow: 0 14px 32px rgba(15, 23, 42, 0.22);
  padding: 12px;
  display: grid;
  gap: 10px;
}
.pwa-status-banner[hidden] { display: none !important; }
.pwa-status-banner__content { display: grid; gap: 6px; }
.pwa-status-banner__title { font-size: 0.95rem; }
.pwa-status-banner__text { margin: 0; font-size: 0.85rem; color: #475569; }
.pwa-status-banner__actions { display: flex; gap: 8px; flex-wrap: wrap; }
.pwa-status-banner__btn { border: 1px solid #cbd5e1; border-radius: 999px; background: #fff; color: #0f172a; font-size: 0.82rem; font-weight: 600; padding: 6px 12px; }
.pwa-status-banner__btn--primary { border-color: #0f172a; background: #0f172a; color: #fff; }
.pwa-status-banner__btn[hidden] { display: none !important; }

/* 07. Pagination */
.pagination a,
.pagination span,
.pagination button {
  border-radius: 8px;
}

.pagination {
  grid-column: 1 / -1;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 40px 0;
  gap: 8px;
  width: 100%;
  margin-top: 20px;
  clear: both;
  flex-wrap: wrap;
}

.pagination a,
.pagination span,
.pagination button {
  padding: 8px 16px;
  border: 1px solid var(--border);
  text-decoration: none;
  color: var(--muted);
  border-radius: 6px;
  transition: all 0.2s;
  background: var(--surface);
  font-size: 0.95rem;
  line-height: 1.2;
}

.pagination a.active,
.pagination span.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.pagination a:hover:not(.active) {
  background-color: #f3f4f6;
  color: var(--accent);
}

.pagination .disabled {
  color: #9ca3af;
  border-color: var(--border);
  background: #f3f4f6;
  cursor: not-allowed;
}

.pagination .pagination__ellipsis {
  border-color: transparent;
  background: transparent;
  color: var(--muted);
  padding: 8px 6px;
}

.pagination__meta {
  color: var(--muted);
  padding: 8px 12px;
}

.pagination__jump {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.pagination__jump input {
  width: 70px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
}

.pagination__jump button {
  cursor: pointer;
}

.pagination a:focus-visible,
.pagination button:focus-visible,
.pagination__jump input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* 08. Cards */
.card {
  background: var(--surface);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: all 0.2s ease;
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
}

.card--panel {
  border: 1px solid #eee;
  border-radius: 14px;
  padding: 14px;
  background: #fff;
  box-shadow: none;
}

.card--interactive {
  cursor: pointer;
}

.card--compact .card-content {
  padding: 14px;
}

.card--compact .card-content h3 {
  font-size: 1.05rem;
}

.card--muted {
  background: #f8fafc;
  border-color: #e2e8f0;
}

.card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.card-thumb {
  width: 100%;
  aspect-ratio: 16 / 10;
  overflow: hidden;
  background: #f3f4f6;
}

.card-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.card-content {
  padding: 20px;
  flex-grow: 1;
}

.card-content h3 {
  margin: 0 0 10px;
  font-size: 1.2rem;
  line-height: 1.55;
}

.card-content p {
  margin: 0;
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.7;
}

.meta {
  font-size: 0.85rem;
  color: var(--muted);
  padding: 12px 20px;
  border-top: 1px solid var(--border);
}

.source-link {
  color: inherit;
  font-weight: 600;
  opacity: 0.92;
  text-decoration-line: underline;
  text-decoration-color: transparent;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
  border-radius: 6px;
  transition: color 0.15s ease, opacity 0.15s ease, text-decoration-color 0.15s ease, background-color 0.15s ease;
}

.source-link:hover {
  opacity: 1;
  color: var(--primary);
  text-decoration-color: currentColor;
}

.source-link:visited {
  color: inherit;
}

.source-link:focus-visible {
  outline: 2px solid color-mix(in srgb, var(--accent) 25%, transparent);
  outline-offset: 2px;
  background: color-mix(in srgb, var(--accent) 8%, transparent);
}

/* 09. Latest List */
.latest-item {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.latest-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
}

.latest-item:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.latest-body {
  flex: 1;
  min-width: 0;
}

.latest-body h3 {
  margin: 0 0 12px;
  font-size: 1.2rem;
  line-height: 1.6;
}

.latest-body h3 a {
  color: var(--primary);
  text-decoration: none;
}

.latest-body h3 a:hover {
  color: var(--accent);
}

.latest-body h3 a:focus-visible,
.news-item h3 a:focus-visible,
.card-content h3 a:focus-visible {
  outline: 2px solid rgba(200, 29, 37, 0.55);
  outline-offset: 2px;
  border-radius: 6px;
}

.latest-meta {
  display: flex;
  gap: 16px;
  font-size: 0.85rem;
  color: var(--muted);
}

.latest-meta span {
  padding: 4px 10px;
  border-radius: 999px;
  background: #f8fafc;
  border: 1px solid var(--border);
}

.latest-thumb {
  width: 160px;
  aspect-ratio: 16 / 10;
  border-radius: 10px;
  overflow: hidden;
  background: #f3f4f6;
  flex-shrink: 0;
}

.latest-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}


.sidebar-list[data-home-async-sidebar] {
  min-height: 204px;
}

.sidebar-skeleton-item {
  border-bottom: 1px dashed #e6e6e6;
  padding: 10px 0;
}

.sidebar-skeleton-line {
  display: block;
  width: 100%;
  height: 12px;
  border-radius: 999px;
  background: linear-gradient(90deg, #eef2f7 25%, #f6f8fb 37%, #eef2f7 63%);
  background-size: 400% 100%;
  animation: sidebar-skeleton-shimmer 1.4s ease infinite;
}

@keyframes sidebar-skeleton-shimmer {
  0% { background-position: 100% 50%; }
  100% { background-position: 0 50%; }
}
