/* whybother Labs: shared components. Loads after /styles.css (tokens, fonts, .brand, .skip, .footer, .btn).
   Dark by default; .lab-real and .lab-doc switch to the paper palette (--h-*). */

body.lab {
  display: flex;
  flex-direction: column;
}

body.lab .footer {
  margin-top: auto;
}

/* header: the landing .nav (styles.css) plus a Labs row. Markup: docs/superpowers/plans/2026-10-15-labs-integration.md */

html {
  scroll-padding-top: calc(var(--nav-h) + 44px + 16px + env(safe-area-inset-top, 0px));
}

.nav--labs {
  height: auto;
  margin-bottom: 0;
  background: rgba(9, 9, 11, 0.72);
  -webkit-backdrop-filter: blur(16px) saturate(150%);
  backdrop-filter: blur(16px) saturate(150%);
  border-bottom-color: var(--line);
}

.nav--labs .nav__inner {
  height: auto;
  min-height: var(--nav-h);
}

@media (min-width: 861px) {
  .nav--labs .nav__links a[aria-current="true"] {
    background: rgba(255, 176, 32, 0.08);
  }
}

/* The open mobile menu covers the Labs row: opaque (a nested backdrop blur does not hide it) and above its masked links. */
@media (max-width: 860px) {
  .nav--labs .nav__links {
    z-index: 1;
    background: var(--bg);
  }
}

.lab-subnav {
  display: flex;
  align-items: center;
  gap: 2px;
  max-width: var(--max);
  height: 44px;
  margin-inline: auto;
  padding-inline: var(--pad-l) var(--pad-r);
}

.lab-subnav__tag {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin-right: 14px;
  font-family: var(--font-mono);
  font-size: 11.5px;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
}

.lab-subnav__tag::before {
  content: "";
  width: 18px;
  height: 1px;
  background: currentColor;
  opacity: 0.6;
}

.lab-subnav__links {
  display: flex;
  gap: 2px;
  min-width: 0;
}

.lab-subnav__links a {
  padding: 5px 10px;
  border-radius: var(--r-sm);
  font-size: 13.5px;
  color: var(--text-2);
  white-space: nowrap;
  transition: color var(--dur-fast), background var(--dur-fast);
}

.lab-subnav__links a:hover,
.lab-subnav__links a[aria-current] {
  color: var(--text);
  background: var(--bg-hover);
}

.lab-subnav__status {
  flex: none;
  padding: 4px 12px;
}

.lab-subnav__status .status__dot,
.lab-subnav__status .status__dot::after {
  background: var(--warn);
}

@media (max-width: 560px) {
  .lab-subnav__tag {
    display: none;
  }

  /* Narrow screens: the section links scroll inside their own row; the page never does. */
  .lab-subnav__links {
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-mask-image: linear-gradient(90deg, #000 85%, transparent);
    mask-image: linear-gradient(90deg, #000 85%, transparent);
  }

  .lab-subnav__links::-webkit-scrollbar {
    display: none;
  }

  .lab-subnav__links a {
    padding-inline: 8px;
  }

  .lab-subnav__status {
    margin-left: 8px;
  }
}

/* page */

.lab-main {
  width: 100%;
  max-width: var(--max);
  margin-inline: auto;
  padding: clamp(40px, 7vw, 80px) var(--pad-r) clamp(64px, 10vw, 112px) var(--pad-l);
}

.lab-main > * + * {
  margin-top: 20px;
}

.lab-main h1 {
  font-size: clamp(2.2rem, 6vw, 3.8rem);
  font-weight: 600;
  line-height: 1.06;
  letter-spacing: -0.04em;
  text-wrap: balance;
}

.lab-main h2 {
  margin-top: 56px;
  font-size: clamp(1.35rem, 3vw, 1.75rem);
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: -0.025em;
  scroll-margin-top: 24px;
}

/* Generic rules sit in :where() (specificity 0) so .lab-lede, .lab-note, .lab-real and .lab-doc always win. */
.lab-main :where(p) {
  max-width: 68ch;
  color: var(--text-2);
}

.lab-main :where(a:not(.lab-card, .btn)) {
  color: var(--accent-hi);
  text-decoration: underline;
  text-decoration-color: rgba(255, 199, 90, 0.35);
  text-underline-offset: 3px;
}

.lab-main :where(a:not(.lab-card, .btn)):hover {
  text-decoration-color: currentColor;
}

.lab-kicker {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
}

.lab-main > .lab-kicker + h1 {
  margin-top: 12px;
}

.lab-lede {
  max-width: 56ch;
  font-size: clamp(1.1rem, 2.2vw, 1.3rem);
  line-height: 1.5;
  color: var(--text-2);
  text-wrap: pretty;
}

.lab-note {
  max-width: 68ch;
  font-size: 13px;
  line-height: 1.6;
  color: var(--text-3);
}

/* link cards */

.lab-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr));
  gap: 14px;
  padding: 0;
  list-style: none;
}

.lab-grid > li {
  display: flex;
  margin: 0;
}

.lab-card {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 6px;
  padding: 20px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r);
  background: var(--bg-elev);
  transition: border-color var(--dur-fast), background var(--dur-fast);
}

.lab-card:hover {
  border-color: var(--accent-lo);
  background: var(--bg-elev-2);
}

.lab-card__name {
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
}

.lab-card__title {
  font-size: 1.1rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text);
}

.lab-card__line {
  font-size: 14.5px;
  line-height: 1.5;
  color: var(--text-2);
}

/* stats */

.lab-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 28px 48px;
}

.lab-stat {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.lab-stat__value {
  font-family: var(--font-mono);
  font-size: clamp(1.8rem, 5vw, 2.8rem);
  font-weight: 500;
  line-height: 1.1;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}

.lab-stat__label {
  font-size: 13.5px;
  color: var(--text-3);
}

/* data table: <div class="lab-table" role="region" aria-label="…" tabindex="0"><table>…</table></div>.
   The div is the scroll container, so pages must give it role, a label and tabindex="0" (keyboard scroll). */

.lab-table {
  position: relative; /* keeps .visually-hidden cells inside the scroll box */
  overflow-x: auto;
  border: 1px solid var(--line-strong);
  border-radius: var(--r);
  background: var(--bg-elev);
}

.lab-table table {
  width: 100%;
  min-width: 480px;
  border-collapse: collapse;
  font-size: 14.5px;
}

.lab-table caption {
  padding: 12px 16px;
  text-align: left;
  font-size: 13px;
  color: var(--text-3);
}

.lab-table th,
.lab-table td {
  padding: 11px 16px;
  text-align: left;
  vertical-align: top;
  border-top: 1px solid var(--line);
}

.lab-table thead th {
  border-top: 0;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-3);
  background: var(--bg-elev-2);
}

.lab-table tbody th {
  font-weight: 500;
  color: var(--text);
}

.lab-table td {
  color: var(--text-2);
}

.lab-table .num {
  text-align: right;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

.lab-table tbody tr:hover {
  background: var(--bg-hover);
}

/* chart frame */

.lab-figure {
  padding: clamp(14px, 3vw, 24px);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-lg);
  background: var(--bg-elev);
}

.lab-figure svg,
.lab-figure img {
  width: 100%;
  height: auto;
}

.lab-figure figcaption {
  margin-top: 14px;
  font-size: 13px;
  line-height: 1.6;
  color: var(--text-3);
}

/* dialog */

.lab-dialog {
  width: min(520px, calc(100% - 32px));
  padding: 24px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-lg);
  background: var(--bg-elev-2);
  color: var(--text);
  box-shadow: var(--shadow-lg);
}

.lab-main > .lab-dialog {
  margin: auto;
}

.lab-dialog::backdrop {
  background: rgba(0, 0, 0, 0.65);
}

.lab-dialog h2 {
  margin: 0 0 8px;
  font-size: 1.25rem;
}

.lab-dialog p {
  color: var(--text-2);
}

/* In reality: the sincere half, always on paper */

.lab-real {
  max-width: 68ch;
  margin-top: 64px;
  padding: 22px 24px;
  border-radius: var(--r);
  background: var(--h-bg);
  color: var(--h-body);
  font-size: 16px;
  line-height: 1.65;
}

.lab-real .lab-real__title {
  margin-bottom: 8px;
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--h-mute);
}

.lab-real p {
  max-width: none;
  color: var(--h-body);
}

.lab-real p + p {
  margin-top: 10px;
}

.lab-real a {
  color: var(--h-ink);
  text-decoration: underline;
  text-decoration-color: var(--h-mute);
  text-underline-offset: 3px;
}

.lab-real a:hover {
  text-decoration-color: var(--h-ink);
}

.lab-real :focus-visible,
.lab-doc :focus-visible {
  outline-color: var(--h-ink);
}

/* paper document mode: <article class="lab-doc"> for long documents */

.lab-doc {
  max-width: 70ch;
  margin-inline: auto;
  padding: clamp(24px, 5vw, 56px);
  border-radius: var(--r);
  background: var(--h-bg);
  color: var(--h-body);
  font-size: 17px;
  line-height: 1.7;
  counter-reset: lab-sec;
}

.lab-doc > * + * {
  margin-top: 16px;
}

.lab-doc h1,
.lab-doc h2,
.lab-doc h3 {
  color: var(--h-ink);
}

.lab-doc h2 {
  counter-increment: lab-sec;
  margin-top: 44px;
  font-size: 1.35rem;
}

.lab-doc h2::before {
  content: counter(lab-sec) ". ";
  color: var(--h-mute);
}

.lab-doc p,
.lab-doc li {
  max-width: none;
  color: var(--h-body);
}

.lab-doc a {
  color: var(--h-ink);
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* tables and notes inside a paper document */
.lab-doc .lab-note {
  color: var(--h-mute);
}

.lab-doc .lab-table {
  border-color: var(--h-line);
  background: transparent;
}

.lab-doc .lab-table th,
.lab-doc .lab-table td {
  border-top-color: var(--h-line);
  color: var(--h-body);
}

.lab-doc .lab-table thead th {
  color: var(--h-body);
  background: rgba(29, 25, 19, 0.06);
}

@media (prefers-reduced-motion: reduce) {
  .lab-card,
  .lab-subnav__links a {
    transition: none;
  }
}

@media print {
  .skip,
  .nav,
  .footer {
    display: none;
  }

  body.lab,
  .lab-doc,
  .lab-doc :is(h1, h2, h3, p, li, a),
  .lab-real {
    background: #fff;
    color: #000;
  }

  body.lab::before {
    display: none;
  }

  .lab-main,
  .lab-doc,
  .lab-real {
    max-width: none;
    padding: 0;
  }
}
