/* =========================================================
   CSS Development Lab 04
   Alternating Content Sections
   ========================================================= */

:root {
  --page-max: 1200px;
  --text: #171717;
  --muted: #686868;
  --line: #e5e5df;
  --surface: #ffffff;
  --soft: #f5f5f1;
  --radius: 28px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  color: var(--text);
  background: var(--surface);
  font-family: Inter, "PingFang SC", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
  line-height: 1.65;
}

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

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

.page-wrap {
  width: min(calc(100% - 40px), var(--page-max));
  margin-inline: auto;
}

.eyebrow {
  margin: 0 0 14px;
  color: #858585;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.15em;
}

.intro {
  padding: clamp(72px, 10vw, 130px) 0 clamp(58px, 8vw, 90px);
  background:
    radial-gradient(circle at 85% 10%, rgba(0, 0, 0, 0.05), transparent 28%),
    linear-gradient(180deg, #fafaf8 0%, #f3f3ef 100%);
}

.intro-inner {
  max-width: 980px;
}

.intro h1,
.story-content h2,
.notes h2 {
  margin: 0;
  line-height: 1.04;
  letter-spacing: -0.045em;
}

.intro h1 {
  font-size: clamp(2.8rem, 7vw, 6rem);
}

.intro-desc {
  max-width: 760px;
  margin: 24px 0 0;
  color: var(--muted);
  font-size: clamp(1rem, 1.7vw, 1.18rem);
}

/* ---------- Alternating sections ---------- */

.story-list {
  padding: clamp(72px, 10vw, 130px) 0;
}

.story {
  display: grid;
  grid-template-columns: minmax(0, 1.06fr) minmax(0, 0.94fr);
  align-items: center;
  gap: clamp(34px, 7vw, 96px);
  padding-block: clamp(50px, 7vw, 92px);
  border-bottom: 1px solid var(--line);
}

.story:first-child {
  padding-top: 0;
}

.story:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.story-media {
  min-width: 0;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  border-radius: var(--radius);
  background: #deded8;
}

.story-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.story-content {
  min-width: 0;
  max-width: 560px;
}

.story-content h2 {
  font-size: clamp(2rem, 4.3vw, 4.35rem);
}

.story-content > p:not(.eyebrow) {
  margin: clamp(18px, 3vw, 26px) 0 0;
  color: var(--muted);
  font-size: clamp(1rem, 1.4vw, 1.08rem);
}

.feature-list {
  margin: 24px 0 0;
  padding: 0;
  display: grid;
  gap: 10px;
  list-style: none;
}

.feature-list li {
  position: relative;
  padding-left: 18px;
  font-size: 0.95rem;
  font-weight: 650;
}

.feature-list li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.8em;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #171717;
}

.text-link {
  margin-top: 28px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 750;
}

.text-link span {
  transition: transform 180ms ease;
}

.text-link:hover span {
  transform: translateX(4px);
}

/*
 * 核心：
 * 偶数项只改变“视觉位置”，不改变 HTML 源码顺序。
 */
.story:nth-child(even) .story-media {
  grid-column: 2;
  grid-row: 1;
}

.story:nth-child(even) .story-content {
  grid-column: 1;
  grid-row: 1;
  justify-self: start;
}

.story:nth-child(odd) .story-content {
  justify-self: end;
}

/* ---------- Notes ---------- */

.notes {
  padding: 0 0 clamp(90px, 12vw, 150px);
}

.notes-grid {
  padding: clamp(30px, 6vw, 64px);
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 0.8fr);
  align-items: center;
  gap: clamp(30px, 7vw, 90px);
  border-radius: 28px;
  background: var(--soft);
}

.notes h2 {
  font-size: clamp(2rem, 4.5vw, 4.5rem);
}

.notes-grid > p {
  margin: 0;
  color: var(--muted);
}

/* ---------- Responsive ---------- */

@media (max-width: 820px) {
  .story,
  .notes-grid {
    grid-template-columns: 1fr;
  }

  /*
   * 手机端恢复自然阅读顺序：
   * HTML 中本来就是 media 在前、content 在后。
   */
  .story:nth-child(even) .story-media,
  .story:nth-child(even) .story-content {
    grid-column: auto;
    grid-row: auto;
  }

  .story-content,
  .story:nth-child(odd) .story-content,
  .story:nth-child(even) .story-content {
    max-width: none;
    justify-self: stretch;
  }
}

@media (max-width: 640px) {
  .page-wrap {
    width: calc(100% - 28px);
  }

  .story {
    gap: 28px;
    padding-block: 56px;
  }

  .story-media {
    aspect-ratio: 4 / 3;
    border-radius: 22px;
  }

  .notes-grid {
    padding: 24px;
  }
}

:focus-visible {
  outline: 2px solid #171717;
  outline-offset: 3px;
}

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