/* =========================================================
   CSS Development Lab 10
   Tabs
   ========================================================= */

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

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

button {
  font: inherit;
}

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: .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,
.lab-copy h2,
.explain h2,
.keyboard-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);
}

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

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

.lab-grid {
  display: grid;
  grid-template-columns: minmax(0, .7fr) minmax(460px, 1.3fr);
  align-items: start;
  gap: clamp(40px, 8vw, 110px);
}

.lab-copy {
  position: sticky;
  top: 32px;
}

.lab-copy h2,
.explain h2,
.keyboard-head h2 {
  font-size: clamp(2rem, 4.5vw, 4.5rem);
}

.lab-copy > p {
  margin: 22px 0 0;
  color: var(--muted);
}

.tips {
  margin-top: 30px;
  display: grid;
  gap: 10px;
}

.tips > div {
  padding: 16px 18px;
  display: grid;
  gap: 3px;
  border-radius: 14px;
  background: var(--soft);
}

.tips strong {
  font-size: .88rem;
}

.tips span {
  color: var(--muted);
  font-size: .84rem;
}

/* ---------- Tabs ---------- */

.tabs {
  min-width: 0;
}

.tab-list {
  max-width: 100%;
  display: flex;
  gap: 6px;
  overflow-x: auto;
  overflow-y: hidden;
  overscroll-behavior-x: contain;
  scrollbar-width: none;
  -ms-overflow-style: none;
  border-bottom: 1px solid var(--line);
}

.tab-list::-webkit-scrollbar {
  display: none;
}

.tab-button {
  position: relative;
  flex: 0 0 auto;
  min-height: 50px;
  padding: 0 16px;
  border: 0;
  color: #777;
  background: transparent;
  font-size: .92rem;
  font-weight: 720;
  white-space: nowrap;
  cursor: pointer;
  transition: color 180ms ease;
}

.tab-button::after {
  content: "";
  position: absolute;
  left: 16px;
  right: 16px;
  bottom: -1px;
  height: 2px;
  background: var(--dark);
  transform: scaleX(0);
  transform-origin: center;
  transition: transform 180ms ease;
}

.tab-button:hover {
  color: var(--text);
}

.tab-button.is-active {
  color: var(--text);
}

.tab-button.is-active::after {
  transform: scaleX(1);
}

.tab-panels {
  padding-top: 30px;
}

.tab-panel {
  min-width: 0;
}

.tab-panel[hidden] {
  display: none;
}

.panel-grid {
  padding: clamp(26px, 5vw, 46px);
  display: grid;
  grid-template-columns: minmax(0, .9fr) minmax(0, 1.1fr);
  gap: clamp(28px, 6vw, 60px);
  border-radius: var(--radius);
  background: var(--soft);
}

.panel-label {
  margin: 0 0 10px;
  color: #888;
  font-size: .74rem;
  font-weight: 800;
  letter-spacing: .12em;
}

.panel-grid h3 {
  margin: 0;
  font-size: clamp(1.65rem, 3vw, 2.8rem);
  line-height: 1.12;
  letter-spacing: -.035em;
}

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

.spec-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.spec-grid > div {
  padding: 22px;
  display: grid;
  gap: 6px;
  border-radius: 16px;
  background: var(--soft);
}

.spec-grid span {
  color: #888;
  font-size: .8rem;
}

.spec-grid strong {
  font-size: 1rem;
}

.download-list {
  display: grid;
  border-top: 1px solid var(--line);
}

.download-list a {
  padding: 18px 4px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  border-bottom: 1px solid var(--line);
}

.download-list span {
  font-weight: 720;
}

.download-list strong {
  color: #888;
  font-size: .82rem;
}

.steps {
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0;
  list-style: none;
  border-top: 1px solid var(--line);
}

.steps li {
  padding: 18px 0;
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  gap: 16px;
  border-bottom: 1px solid var(--line);
}

.steps span {
  color: #999;
  font-size: .8rem;
  font-weight: 800;
}

.steps p {
  margin: 0;
}

/* ---------- Explain ---------- */

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

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

.code-card {
  min-width: 0;
  overflow-x: auto;
  border-radius: 18px;
  background: #181818;
}

.code-card pre {
  margin: 0;
  padding: clamp(22px, 4vw, 34px);
}

.code-card code {
  color: #f2f2f2;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: clamp(.82rem, 1.5vw, .96rem);
  line-height: 1.75;
}

/* ---------- Keyboard ---------- */

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

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

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

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

.keyboard-grid span {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  align-self: flex-start;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
  font-size: .82rem;
  font-weight: 800;
}

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

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

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

@media (max-width: 920px) {
  .lab-grid,
  .explain-grid {
    grid-template-columns: 1fr;
  }

  .lab-copy {
    position: static;
  }

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

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

  .panel-grid,
  .spec-grid {
    grid-template-columns: 1fr;
  }

  .tab-list {
    margin-inline: -14px;
    padding-inline: 14px;
  }

  .explain-grid {
    padding: 24px;
  }

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

  .keyboard-grid article {
    min-height: 160px;
  }
}

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

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