/* 基础样式：重置、排版、通用组件 */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
}

body {
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}

img {
  max-width: 100%;
  display: block;
}

a {
  color: var(--accent);
  text-decoration: none;
}

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

h1,
h2,
h3,
h4 {
  margin: 0 0 var(--space-3);
  line-height: 1.3;
  font-weight: 700;
  letter-spacing: 0.01em;
}

h1 {
  font-size: clamp(1.9rem, 4vw, 3rem);
}

h2 {
  font-size: clamp(1.35rem, 2.4vw, 1.9rem);
}

h3 {
  font-size: 1.15rem;
}

p {
  margin: 0 0 var(--space-4);
}

hr {
  border: 0;
  border-top: 1px solid var(--line);
  margin: var(--space-6) 0;
}

code,
pre {
  font-family: var(--font-mono);
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* —— 布局工具 —— */
.container {
  width: 100%;
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 var(--space-5);
}

.section {
  padding: var(--space-8) 0;
}

.section--tight {
  padding: var(--space-6) 0;
}

.section__head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--space-4);
  margin-bottom: var(--space-6);
}

.section__title {
  margin: 0;
}

.section__subtitle {
  margin: var(--space-2) 0 0;
  color: var(--text-muted);
  font-size: 0.95rem;
}

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

.skip-link {
  position: absolute;
  left: -999px;
  top: 0;
  z-index: 100;
  background: var(--accent);
  color: #ffffff;
  padding: var(--space-2) var(--space-4);
  border-radius: 0 0 var(--radius) 0;
}

.skip-link:focus {
  left: 0;
}

/* —— 按钮 —— */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: 10px 20px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-3);
  color: var(--text);
  font: inherit;
  font-size: 0.95rem;
  cursor: pointer;
  transition: background 0.18s ease, border-color 0.18s ease, transform 0.18s ease;
}

.btn:hover {
  background: var(--surface-4);
  border-color: var(--accent-line);
  color: var(--text);
}

.btn:active {
  transform: translateY(1px);
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn--primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
  font-weight: 600;
}

.btn--primary:hover {
  background: var(--accent-strong);
  border-color: var(--accent-strong);
  color: #ffffff;
}

.btn--ghost {
  background: transparent;
}

.btn--danger {
  color: var(--error);
  border-color: rgba(191, 59, 43, 0.35);
}

.btn--sm {
  padding: 6px 12px;
  font-size: 0.85rem;
}

/* —— 标签 —— */
.chip {
  display: inline-flex;
  align-items: center;
  padding: 4px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text-muted);
  font-size: 0.82rem;
  line-height: 1.6;
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}

.chip:hover {
  color: var(--text);
  border-color: var(--accent-line);
}

.chip[aria-pressed="true"],
.chip.is-active {
  background: var(--accent-soft);
  border-color: var(--accent-line);
  color: var(--accent-strong);
}

.chip--static {
  cursor: default;
}

/* —— 卡片 —— */
.card {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.card:hover {
  transform: translateY(-3px);
  border-color: var(--accent-line);
  box-shadow: var(--shadow-2);
}

@media (prefers-reduced-motion: reduce) {
  .card,
  .card:hover {
    transform: none;
    transition: none;
  }
}

.card__body {
  padding: var(--space-4) var(--space-5) var(--space-5);
}

.card__title {
  margin: 0 0 var(--space-2);
  font-size: 1.08rem;
}

.card__summary {
  margin: 0 0 var(--space-4);
  color: var(--text-muted);
  font-size: 0.92rem;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card__meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  color: var(--text-dim);
  font-size: 0.8rem;
}

/* —— 媒体占位（零跳动） —— */
.media {
  position: relative;
  width: 100%;
  background: linear-gradient(135deg, var(--surface-3), var(--surface));
  overflow: hidden;
}

.media--fallback {
  aspect-ratio: 16 / 10;
}

.media > img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity 0.35s ease;
}

.media > img.is-loaded {
  opacity: 1;
}

.media__placeholder {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(120% 90% at 20% 10%, rgba(164, 98, 15, 0.08), transparent 60%),
    linear-gradient(135deg, var(--surface-3), var(--surface));
  animation: pulse 1.6s ease-in-out infinite;
}

@keyframes pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.55;
  }
}

@media (prefers-reduced-motion: reduce) {
  .media__placeholder {
    animation: none;
  }
}

/* —— 状态 —— */
.empty-state,
.error-state {
  padding: var(--space-8) var(--space-5);
  border: 1px dashed var(--line);
  border-radius: var(--radius-lg);
  text-align: center;
  color: var(--text-muted);
}

.empty-state__title,
.error-state__title {
  color: var(--text);
  font-size: 1.1rem;
  margin-bottom: var(--space-2);
}

.badge {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-size: 0.75rem;
}

.badge--muted {
  background: var(--surface-3);
  color: var(--text-dim);
}

.badge--draft {
  background: rgba(143, 100, 18, 0.12);
  color: var(--warn);
}

.loading-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-8) 0;
  color: var(--text-muted);
}

.loading-screen__spinner {
  width: 26px;
  height: 26px;
  border: 2px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* —— 提示条 —— */
.toast-root {
  position: fixed;
  right: var(--space-5);
  bottom: var(--space-5);
  z-index: 60;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  pointer-events: none;
}

.toast {
  min-width: 220px;
  max-width: 360px;
  padding: 10px 16px;
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  background: var(--surface-2);
  box-shadow: var(--shadow-2);
  font-size: 0.9rem;
  pointer-events: auto;
}

.toast--ok {
  border-left-color: var(--ok);
}

.toast--error {
  border-left-color: var(--error);
}

/* —— 表单 —— */
.field {
  display: block;
  margin-bottom: var(--space-5);
}

.field__label {
  display: block;
  margin-bottom: var(--space-2);
  font-size: 0.9rem;
  color: var(--text-muted);
}

.field__label .required {
  color: var(--accent);
}

.input,
.textarea,
.select {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 0.95rem;
}

.input:focus,
.textarea:focus,
.select:focus {
  border-color: var(--accent-line);
  outline: none;
}

.textarea {
  min-height: 120px;
  resize: vertical;
}

.field__hint {
  margin: var(--space-2) 0 0;
  color: var(--text-dim);
  font-size: 0.82rem;
}

.field__error {
  margin: var(--space-2) 0 0;
  color: var(--error);
  font-size: 0.85rem;
  min-height: 1.2em;
}

.field.has-error .input,
.field.has-error .textarea {
  border-color: var(--error);
}
