/* =========================================================
   CSS Development Lab 15
   Hover Image Cards
   ========================================================= */

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

*,
*::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;
}

code {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

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

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

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

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

.intro h1,
.section-head h2,
.layers h2,
.compare-copy h2,
.tips-head h2 {
  margin: 0;
  line-height: 1.04;
  letter-spacing: -.045em;
}

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

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

/* ---------- Main demo ---------- */

.lab {
  padding: clamp(80px, 10vw, 130px) 0;
}

.section-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, .78fr);
  align-items: end;
  gap: clamp(28px, 6vw, 80px);
}

.section-head h2,
.layers h2,
.compare-copy h2,
.tips-head h2 {
  font-size: clamp(2rem, 4.5vw, 4.5rem);
}

.section-head > p,
.layers-grid > div:first-child > p:last-child,
.compare-copy > p {
  margin: 0;
  color: var(--muted);
}

.card-grid {
  margin-top: clamp(38px, 6vw, 60px);
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

/* ---------- Card layer model ---------- */

.image-card {
  min-width: 0;
}

.card-link {
  position: relative;
  isolation: isolate;
  min-height: 420px;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  display: block;
  border-radius: var(--radius);
  background: #ddd;
}

.card-link::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  background:
    linear-gradient(
      to top,
      rgba(0, 0, 0, .72) 0%,
      rgba(0, 0, 0, .30) 45%,
      rgba(0, 0, 0, .05) 78%
    );
  opacity: .72;
  transition: opacity 320ms ease;
}

.card-image {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scale(1);
  transition: transform 520ms cubic-bezier(.2,.75,.2,1);
}

.card-content {
  position: absolute;
  inset-inline: 0;
  bottom: 0;
  z-index: 2;
  padding: clamp(22px, 4vw, 34px);
  color: #fff;
}

.card-meta {
  margin: 0 0 8px;
  font-size: .74rem;
  font-weight: 800;
  letter-spacing: .12em;
  opacity: .78;
}

.card-content h3 {
  margin: 0;
  max-width: 85%;
  font-size: clamp(1.5rem, 3vw, 2.8rem);
  line-height: 1.08;
  letter-spacing: -.035em;
}

.card-action {
  margin-top: 18px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: .9rem;
  font-weight: 750;
  opacity: 0;
  transform: translateY(10px);
  transition:
    opacity 240ms ease,
    transform 240ms ease;
}

.card-action b {
  font-weight: 700;
  transition: transform 180ms ease;
}

/*
 * 只在真正支持 hover 的设备上启用 hover 隐藏/显示逻辑。
 * 避免触控设备出现“必须先点一次才能看到按钮”的问题。
 */
@media (hover: hover) and (pointer: fine) {
  .card-link::before {
    opacity: .58;
  }

  .card-link:hover::before,
  .card-link:focus-visible::before {
    opacity: .88;
  }

  .card-link:hover .card-image,
  .card-link:focus-visible .card-image {
    transform: scale(1.055);
  }

  .card-link:hover .card-action,
  .card-link:focus-visible .card-action {
    opacity: 1;
    transform: translateY(0);
  }

  .card-link:hover .card-action b,
  .card-link:focus-visible .card-action b {
    transform: translateX(4px);
  }
}

/* 触控设备：信息默认可见 */
@media (hover: none), (pointer: coarse) {
  .card-action {
    opacity: 1;
    transform: none;
  }

  .card-link::before {
    opacity: .82;
  }
}

/* ---------- Layers section ---------- */

.layers {
  padding: 0 0 clamp(90px, 11vw, 140px);
}

.layers-grid {
  padding: clamp(30px, 6vw, 64px);
  display: grid;
  grid-template-columns: minmax(0, .85fr) minmax(320px, 1.15fr);
  align-items: center;
  gap: clamp(36px, 7vw, 90px);
  border-radius: 28px;
  background: var(--soft);
}

.layers-grid > div:first-child > p:last-child {
  margin-top: 22px;
}

.layer-stack {
  display: grid;
  gap: 10px;
  perspective: 900px;
}

.layer {
  min-height: 82px;
  padding: 18px 20px;
  display: flex;
  align-items: center;
  gap: 14px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: #fff;
  transform: skewY(-1.5deg);
}

.layer span {
  color: #999;
  font-size: .76rem;
  font-weight: 800;
}

.layer strong {
  font-size: 1rem;
}

.layer-content {
  margin-left: 44px;
}

.layer-overlay {
  margin-left: 22px;
}

/* ---------- Compare ---------- */

.compare {
  padding: 0 0 clamp(90px, 11vw, 140px);
}

.compare-grid {
  display: grid;
  grid-template-columns: minmax(0, .85fr) minmax(320px, 1.15fr);
  align-items: center;
  gap: clamp(36px, 7vw, 90px);
}

.compare-copy > p {
  margin-top: 22px;
}

.decision-list {
  display: grid;
  gap: 12px;
}

.decision-list > div {
  padding: 18px 20px;
  display: grid;
  gap: 4px;
  border-radius: 14px;
  background: var(--soft);
}

.decision-list strong {
  font-size: .94rem;
}

.decision-list span {
  color: var(--muted);
  font-size: .88rem;
}

/* ---------- Tips ---------- */

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

.tips-head {
  max-width: 780px;
}

.tips-grid {
  margin-top: 38px;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
}

.tips-grid article {
  min-height: 220px;
  padding: 24px;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line);
  border-radius: 18px;
}

.tips-grid span {
  color: #999;
  font-size: .78rem;
  font-weight: 800;
}

.tips-grid h3 {
  margin: auto 0 8px;
  font-size: 1.15rem;
}

.tips-grid p {
  margin: 0;
  color: var(--muted);
  font-size: .9rem;
}

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

@media (max-width: 900px) {
  .section-head,
  .layers-grid,
  .compare-grid {
    grid-template-columns: 1fr;
  }

  .tips-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

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

  .card-grid {
    grid-template-columns: 1fr;
  }

  .card-link {
    min-height: 0;
    aspect-ratio: 4 / 3;
  }

  .card-content h3 {
    max-width: 100%;
  }

  .layers-grid {
    padding: 24px;
  }

  .layer-content,
  .layer-overlay {
    margin-left: 0;
  }

  .tips-grid {
    grid-template-columns: 1fr;
  }

  .tips-grid article {
    min-height: 180px;
  }
}

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

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