/* =========================================================
   CSS Development Lab 08
   Responsive Tables
   ========================================================= */

:root {
  --page-max: 1200px;
  --text: #171717;
  --muted: #686868;
  --line: #e4e4df;
  --surface: #ffffff;
  --soft: #f5f5f1;
  --head: #f0f0eb;
  --radius: 20px;
}

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

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.6;
}

.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,
.sticky-head h2,
.strategy-copy h2,
.mini-head h2 {
  margin: 0;
  line-height: 1.04;
  letter-spacing: -.045em;
}

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

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

.lab,
.sticky-demo {
  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,
.sticky-head h2,
.strategy-copy h2,
.mini-head h2 {
  font-size: clamp(2rem, 4.5vw, 4.5rem);
}

.section-head > p,
.sticky-head > p,
.strategy-copy > p {
  margin: 0;
  color: var(--muted);
}

/* ---------- Responsive Table Shell ---------- */

.table-shell {
  margin-top: clamp(38px, 6vw, 58px);
  max-width: 100%;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  overscroll-behavior-inline: contain;
  -webkit-overflow-scrolling: touch;
}

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

table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
}

.spec-table {
  min-width: 920px;
}

th,
td {
  padding: 16px 18px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
  white-space: nowrap;
}

tr > *:last-child {
  border-right: 0;
}

tbody tr:last-child > * {
  border-bottom: 0;
}

thead th {
  background: var(--head);
  font-size: .84rem;
  font-weight: 800;
  letter-spacing: .03em;
}

tbody th {
  background: #fafaf8;
  font-weight: 760;
}

tbody td {
  color: #505050;
  font-size: .92rem;
}

.status {
  display: inline-flex;
  padding: 5px 9px;
  border-radius: 999px;
  background: var(--soft);
  font-size: .76rem;
  font-weight: 750;
}

.table-hint {
  display: none;
  margin: 12px 0 0;
  color: #888;
  font-size: .82rem;
}

/* ---------- Sticky demo ---------- */

.sticky-demo {
  background: #fafaf8;
}

.sticky-head {
  max-width: 820px;
}

.sticky-head > p {
  margin-top: 20px;
  max-width: 720px;
}

.table-shell.tall {
  max-height: 370px;
}

.data-table {
  min-width: 1050px;
}

/* sticky header */
.data-table thead th {
  position: sticky;
  top: 0;
  z-index: 3;
}

/* sticky first column */
.data-table th:first-child {
  position: sticky;
  left: 0;
  z-index: 2;
  box-shadow: 1px 0 0 var(--line);
}

/* top-left intersection must sit above both */
.data-table thead th:first-child {
  z-index: 4;
  background: #e9e9e4;
}

.data-table tbody th:first-child {
  background: #f8f8f5;
}

/* ---------- Strategy ---------- */

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

.strategy-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);
}

.strategy-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: #fff;
}

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

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

/* ---------- Optional card mode ---------- */

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

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

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

.record-card {
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 18px;
}

.record-card h3 {
  margin: 0 0 18px;
  font-size: 1.3rem;
}

.record-card dl {
  margin: 0;
  display: grid;
  gap: 0;
}

.record-card dl > div {
  padding: 12px 0;
  display: grid;
  grid-template-columns: 90px minmax(0, 1fr);
  gap: 16px;
  border-top: 1px solid var(--line);
}

.record-card dt {
  color: #888;
  font-size: .84rem;
}

.record-card dd {
  margin: 0;
  overflow-wrap: anywhere;
}

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

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

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

  .table-hint {
    display: block;
  }
}

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

  .strategy-grid {
    padding: 24px;
  }

  th,
  td {
    padding: 14px 16px;
  }

  .record-card dl > div {
    grid-template-columns: 78px minmax(0, 1fr);
  }
}
