/* ==========================================================
   shared.css — 两页共用样式
   ========================================================== */

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

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  min-height: 100vh;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

img, picture, video, canvas, svg {
  display: block;
  max-width: 100%;
}

input, button, textarea, select {
  font: inherit;
}

p, h1, h2, h3, h4, h5, h6 {
  overflow-wrap: break-word;
}

a {
  color: inherit;
  text-decoration: none;
}

ul, ol {
  list-style: none;
}

/* --- CSS 变量系统（默认值，各页面覆盖） --- */
:root {
  --color-primary: #264653;
  --color-secondary: #F4E4BA;
  --color-accent: #E76F51;
  --color-bg: #FEFAF0;
  --color-text: #264653;
  --color-text-light: #5a6b73;
  --color-border: rgba(0, 0, 0, 0.08);
  --color-card-bg: #ffffff;
  --font-body: "Noto Serif SC", serif;
  --font-heading: "Noto Serif SC", serif;
  --radius-sm: 6px;
  --radius-md: 12px;
  --radius-lg: 20px;
  --shadow-card: 0 2px 12px rgba(0, 0, 0, 0.06);
  --shadow-card-hover: 0 8px 30px rgba(0, 0, 0, 0.12);
  --transition-base: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --max-width: 1200px;
}

/* --- 全局排版 --- */
body {
  font-family: var(--font-body);
  color: var(--color-text);
  background-color: var(--color-bg);
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading);
  line-height: 1.3;
}

/* --- Skip Link（可访问性） --- */
.skip-link {
  position: absolute;
  top: -100%;
  left: 16px;
  z-index: 9999;
  padding: 12px 24px;
  background: var(--color-primary);
  color: #fff;
  border-radius: var(--radius-sm);
  font-weight: 700;
  transition: top 0.2s;
}

.skip-link:focus {
  top: 16px;
}

/* --- 可访问性：focus-visible --- */
:focus-visible {
  outline: 3px solid var(--color-accent);
  outline-offset: 3px;
  border-radius: 2px;
}

:focus:not(:focus-visible) {
  outline: none;
}

/* --- Hero 区域基础样式 --- */
.hero {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 420px;
  padding: 80px 24px 60px;
  text-align: center;
  overflow: hidden;
}

.hero__title {
  font-size: clamp(2rem, 5vw, 3.5rem);
  font-weight: 900;
  margin-bottom: 16px;
  letter-spacing: 0.02em;
}

.hero__subtitle {
  font-size: clamp(1rem, 2.5vw, 1.25rem);
  max-width: 640px;
  opacity: 0.85;
  line-height: 1.8;
}

.hero__tagline {
  margin-top: 24px;
  font-size: 0.95rem;
  opacity: 0.7;
  font-style: italic;
}

/* --- Hero 背景图 --- */
.hero__bg {
  position: absolute;
  inset: 0;
  z-index: 0;
}

.hero__img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0.3;
}

.hero__overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    to bottom,
    rgba(0, 0, 0, 0.3) 0%,
    rgba(0, 0, 0, 0.1) 50%,
    rgba(0, 0, 0, 0.4) 100%
  );
}

.hero__content {
  position: relative;
  z-index: 1;
}

/* --- 返回链接 --- */
.back-link {
  position: absolute;
  top: 16px;
  left: 16px;
  z-index: 10;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  font-size: 0.85rem;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.9);
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 20px;
  text-decoration: none;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition: all 0.25s ease;
}

.back-link:hover {
  background: rgba(0, 0, 0, 0.4);
  color: #fff;
  transform: translateX(-3px);
}

.back-link__icon {
  font-size: 1.1em;
}

/* --- 筛选器 --- */
.filter-bar {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding: 16px 24px;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--color-border);
}

.filter-btn {
  padding: 10px 20px;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--color-primary);
  background: transparent;
  border: 2px solid var(--color-primary);
  border-radius: 24px;
  cursor: pointer;
  transition: all 0.25s ease;
  white-space: nowrap;
  /* 确保文字可见 */
  min-height: 42px;
  line-height: 1.2;
}

.filter-btn:hover {
  background: var(--color-primary);
  color: white;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.filter-btn--active,
.filter-btn.active,
.filter-btn[aria-selected="true"] {
  background: var(--color-primary);
  color: #fff !important;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  border-color: var(--color-primary);
}

/* 筛选器隐藏 */
[data-hidden] {
  display: none !important;
}

/* --- 分组 --- */
.card-group {
  padding: 48px 0 0;
  max-width: var(--max-width);
  margin: 0 auto;
}

/* 分组标题样式 */
.group-header {
  margin-bottom: 24px;
  padding: 0 24px;
}

.group-header__icon {
  font-size: 1.5rem;
  display: inline;
  margin-right: 4px;
  line-height: 1;
  font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", "Twemoji Mozilla", sans-serif;
}

.group-header__title {
  font-size: clamp(1.5rem, 3vw, 2rem);
  font-weight: 700;
  color: var(--color-primary);
  margin: 0 0 8px 0;
  display: inline;
  line-height: 1.3;
}

.group-header__desc {
  font-size: 1rem;
  color: var(--color-text-light);
  line-height: 1.6;
  margin: 0;
  display: block;
}

/* --- Grid 系统 --- */
.card-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 24px;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 24px;
}

/* --- 卡片基础样式 --- */
.card {
  position: relative;
  background: var(--color-card-bg);
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-card);
  transition: transform var(--transition-base), box-shadow var(--transition-base);
}

.card:hover {
  box-shadow: var(--shadow-card-hover);
}

/* 卡片媒体区 */
.card__image {
  position: relative;
  width: 100%;
  aspect-ratio: 3 / 2;
  overflow: hidden;
  background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-secondary) 100%);
  border-radius: var(--radius-md) var(--radius-md) 0 0;
}

.card__image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.4s ease;
}

/* 图片加载失败时隐藏，显示渐变背景 */
.card__image img[style*="display: none"],
.card__image img.hidden {
  display: none;
}

.card:hover .card__image img {
  transform: scale(1.05);
}

/* 色调叠加层 */
.card__image::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    to bottom,
    transparent 40%,
    rgba(0, 0, 0, 0.15) 100%
  );
  pointer-events: none;
}

/* 卡片内容区 */
.card__body {
  padding: 20px;
}

.card__category {
  display: inline-block;
  padding: 3px 10px;
  margin-bottom: 10px;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-accent);
  background: rgba(231, 111, 81, 0.1);
  border-radius: 999px;
}

.card__title {
  font-size: 1.15rem;
  font-weight: 700;
  margin-bottom: 8px;
  line-height: 1.4;
}

.card__desc {
  font-size: 0.9rem;
  color: var(--color-text-light);
  line-height: 1.7;
  margin-bottom: 12px;
}

/* 引用来源 — ≥12px, 对比度 ≥4.5:1 */
.card__source {
  font-size: 12px;
  color: #5a6b73; /* contrast ≥4.5:1 on white */
  opacity: 0.8;
}

.card__source a {
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* 卡片标签 */
.card__tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 12px;
}

.card__tag {
  font-size: 0.75rem;
  padding: 2px 8px;
  background: var(--color-secondary);
  border-radius: 4px;
  color: var(--color-text);
}

/* --- 推荐卡片 --- */
.card--featured {
  grid-column: 1 / -1;
}

.card--featured .card__image {
  aspect-ratio: 21 / 9;
}

.card--featured .card__title {
  font-size: 1.5rem;
}

.card--featured .card__desc {
  font-size: 1rem;
}

/* --- 地图区域 --- */
.map-section {
  padding: 48px 24px;
  max-width: var(--max-width);
  margin: 0 auto;
}

.map-section__title {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 16px;
}

.map-section__container {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--color-secondary);
  box-shadow: var(--shadow-card);
}

.map-section__container iframe {
  width: 100%;
  height: 100%;
  border: 0;
}

.map-section__fallback {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  font-size: 1rem;
  color: var(--color-text-light);
}

/* --- Footer --- */
.footer {
  padding: 48px 24px 32px;
  text-align: center;
  border-top: 1px solid var(--color-border);
  margin-top: 64px;
}

.footer__nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 24px;
  margin-bottom: 16px;
}

.footer__link {
  font-size: 0.9rem;
  color: var(--color-text-light);
  transition: color var(--transition-base);
}

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

.footer__copy {
  font-size: 0.8rem;
  color: var(--color-text-light);
  opacity: 0.7;
}

.footer__credit {
  font-size: 12px; /* ≥12px */
  color: #5a6b73;  /* contrast ≥4.5:1 on white */
  margin-top: 8px;
}

/* ==========================================================
   动画
   ========================================================== */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(24px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (prefers-reduced-motion: no-preference) {
  .card {
    animation: fadeInUp 0.5s ease both;
  }

  /* 21 张卡片各自独立 delay */
  .card:nth-child(1)  { animation-delay: 0.05s; }
  .card:nth-child(2)  { animation-delay: 0.10s; }
  .card:nth-child(3)  { animation-delay: 0.15s; }
  .card:nth-child(4)  { animation-delay: 0.20s; }
  .card:nth-child(5)  { animation-delay: 0.25s; }
  .card:nth-child(6)  { animation-delay: 0.30s; }
  .card:nth-child(7)  { animation-delay: 0.35s; }
  .card:nth-child(8)  { animation-delay: 0.40s; }
  .card:nth-child(9)  { animation-delay: 0.45s; }
  .card:nth-child(10) { animation-delay: 0.50s; }
  .card:nth-child(11) { animation-delay: 0.55s; }
  .card:nth-child(12) { animation-delay: 0.60s; }
  .card:nth-child(13) { animation-delay: 0.65s; }
  .card:nth-child(14) { animation-delay: 0.70s; }
  .card:nth-child(15) { animation-delay: 0.75s; }
  .card:nth-child(16) { animation-delay: 0.80s; }
  .card:nth-child(17) { animation-delay: 0.85s; }
  .card:nth-child(18) { animation-delay: 0.90s; }
  .card:nth-child(19) { animation-delay: 0.95s; }
  .card:nth-child(20) { animation-delay: 1.00s; }
  .card:nth-child(21) { animation-delay: 1.05s; }

  .hero__title {
    animation: fadeInUp 0.6s ease both;
  }

  .hero__subtitle {
    animation: fadeInUp 0.6s ease 0.15s both;
  }

  .hero__tagline {
    animation: fadeInUp 0.6s ease 0.3s both;
  }
}

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

/* ==========================================================
   响应式断点
   ========================================================== */

/* ≥480px — 小平板 */
@media (min-width: 480px) {
  .card-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .card--featured {
    grid-column: 1 / -1;
  }
}

/* ≥768px — 平板 */
@media (min-width: 768px) {
  .hero {
    min-height: 500px;
    padding: 100px 40px 80px;
  }

  .card-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: 24px;
    padding: 0 40px;
  }

  .card:not(.card--featured) {
    grid-column: span 2;
  }

  .card--featured {
    grid-column: span 4;
  }

  .group-header {
    padding: 0 40px;
  }

  .card-group {
    padding: 64px 0 0;
  }

  .map-section {
    padding: 64px 40px;
  }

  .filter-bar {
    padding: 16px 40px;
    justify-content: center;
  }
}

/* ≥1024px — 桌面 */
@media (min-width: 1024px) {
  .card-grid {
    grid-template-columns: repeat(6, 1fr);
    gap: 28px;
    padding: 0 60px;
  }

  .card:not(.card--featured) {
    grid-column: span 2;
  }

  .card--featured {
    grid-column: span 3;
  }

  .hero {
    min-height: 560px;
    padding: 120px 60px 80px;
  }

  .card-group {
    padding: 80px 0 0;
  }

  .group-header {
    padding: 0 60px;
  }

  .map-section {
    padding: 80px 60px;
  }

  .filter-bar {
    padding: 20px 60px;
  }
}

/* ≥1400px — 大屏 4列 */
@media (min-width: 1400px) {
  .card-grid {
    grid-template-columns: repeat(8, 1fr);
    gap: 32px;
  }

  .card:not(.card--featured) {
    grid-column: span 2;
  }

  .card--featured {
    grid-column: span 4;
  }
}
