/*
 * The experiment page reuses the shared paper shell from article.css and adds
 * only the block-wall grid on top. Every size below is relative so the wall
 * reflows from three columns to one without a fixed breakpoint per card count.
 */
:root {
  --lab-index-max: 72.5rem;
  --lab-card-min: 17.5rem;
  --lab-gap: clamp(1rem, 2.4vw, 1.75rem);
  --lab-radius: 14px;
}

.experiment-page .lab-index {
  inline-size: min(var(--lab-index-max), 100%);
  margin: clamp(2rem, 4vw, 3.125rem) auto var(--article-decoration-reserve);
  container: lab-index / inline-size;
}

/* Heading */
.lab-heading {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: clamp(1.5rem, 5cqi, 3.25rem);
  padding: clamp(1.75rem, 3.5vw, 2.375rem) 0 1.75rem;
  border-bottom: 1px solid var(--line);
}
.lab-heading-copy { min-inline-size: 0; }
.lab-kicker { color: var(--orange); font-weight: 800; letter-spacing: .16em; font-size: .75rem; }
.lab-heading h1 { margin: .4375rem 0 .5rem; font-size: clamp(2.25rem, 4.3vw, 2.875rem); line-height: 1.2; overflow-wrap: anywhere; }
.lab-heading p { margin: 0; max-inline-size: 34rem; color: var(--muted); overflow-wrap: anywhere; }
.lab-heading-stack {
  flex: 0 0 auto;
  inline-size: clamp(6.5rem, 13cqi, 9rem);
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 3px;
  opacity: .82;
  transform: rotate(-2deg);
}
.lab-heading-stack i { aspect-ratio: 1 / 1; border-radius: 2px; box-shadow: inset 0 0 0 1px rgba(255,255,255,.3); }
.lab-heading-stack .stack-0 { background: rgba(23,143,214,.82); }
.lab-heading-stack .stack-1 { background: rgba(240,138,23,.82); }
.lab-heading-stack .stack-2 { background: rgba(71,169,92,.8); }
.lab-heading-stack .stack-3 { background: rgba(143,88,215,.76); }
.lab-heading-stack .stack-4 { background: rgba(241,185,39,.82); }
.lab-heading-stack .stack-5 { background: rgba(238,91,63,.78); }

.lab-count { margin: 1.5rem 0 .875rem; color: var(--muted); font-size: .8125rem; }

/* The block wall: three columns on a wide shell, two on a tablet, one on a phone. */
.lab-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, var(--lab-card-min)), 1fr));
  gap: var(--lab-gap);
  align-items: stretch;
}
.lab-grid > .lab-empty { grid-column: 1 / -1; }

.lab-card {
  --accent: var(--blue);
  --accent-soft: rgba(23, 143, 214, .12);
  position: relative;
  min-inline-size: 0;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line);
  border-radius: var(--lab-radius);
  overflow: hidden;
  background: rgba(255, 252, 246, .62);
  box-shadow: 0 16px 46px rgba(86, 63, 34, .035);
  text-decoration: none;
  color: inherit;
  transition: transform .28s ease, box-shadow .28s ease, border-color .28s ease;
}
.lab-card::before {
  content: "";
  position: absolute;
  inset-block-start: 0;
  inset-inline: 0;
  block-size: 4px;
  background: var(--accent);
  z-index: 3;
}
.lab-card:hover,
.lab-card:focus-visible {
  transform: translateY(-4px);
  border-color: var(--line-strong);
  box-shadow: 0 24px 60px rgba(86, 63, 34, .1);
}
.lab-card:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

.lab-card-order {
  position: absolute;
  z-index: 3;
  inset-block-start: .75rem;
  inset-inline-end: .75rem;
  min-inline-size: 1.75rem;
  padding: .0625rem .375rem;
  border-radius: 6px;
  background: rgba(21, 35, 49, .58);
  color: #fff;
  font-size: .6875rem;
  letter-spacing: .06em;
  text-align: center;
  backdrop-filter: blur(4px);
}

.lab-card-shot {
  position: relative;
  display: grid;
  place-items: center;
  aspect-ratio: 16 / 10;
  overflow: hidden;
  background: linear-gradient(135deg, var(--accent-soft), rgba(240, 138, 23, .08));
  border-block-end: 1px solid var(--line);
}
.lab-card-shot img {
  inline-size: 100%;
  block-size: 100%;
  object-fit: cover;
  transition: transform .4s ease;
  contain: paint;
}
.lab-card:hover .lab-card-shot img { transform: scale(1.04); }
.lab-card-glow {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, transparent 52%, rgba(21, 35, 49, .12));
  opacity: 0;
  transition: opacity .3s ease;
}
.lab-card:hover .lab-card-glow { opacity: 1; }

/* Placeholder used when a card has no picture yet. */
.lab-card-blocks {
  inline-size: min(56%, 9rem);
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 4px;
  transform: rotate(-3deg);
}
.lab-card-blocks i {
  aspect-ratio: 1 / 1;
  border-radius: 2px;
  border: 1px solid rgba(223, 132, 25, .28);
}
.lab-card-blocks i.on {
  border-color: transparent;
  background: var(--accent);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .3);
}

.lab-card-text {
  flex: 1 1 auto;
  min-inline-size: 0;
  display: flex;
  flex-direction: column;
  gap: .375rem;
  padding: clamp(1rem, 2.4cqi, 1.375rem) clamp(1rem, 2.4cqi, 1.375rem) .75rem;
}
.lab-card-tag {
  align-self: flex-start;
  max-inline-size: 100%;
  padding: .0625rem .5rem;
  border-radius: 12px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: .6875rem;
  font-weight: 700;
  letter-spacing: .04em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.lab-card-title { font-size: 1.25rem; line-height: 1.4; overflow-wrap: anywhere; }
.lab-card-note {
  color: #5b6874;
  font-size: .875rem;
  line-height: 1.7;
  overflow-wrap: anywhere;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.lab-card-go {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  margin-block-start: auto;
  padding: .75rem clamp(1rem, 2.4cqi, 1.375rem) 1rem;
  color: var(--accent);
  font-size: .8125rem;
  font-weight: 700;
}
.lab-card-go i { font-style: normal; transition: transform .25s ease; }
.lab-card:hover .lab-card-go i { transform: translateX(4px); }

/* Accents mirror the block palette used across the site. */
.lab-card.accent-blue { --accent: #178fd6; --accent-soft: rgba(23,143,214,.12); }
.lab-card.accent-cyan { --accent: #2ba3bd; --accent-soft: rgba(69,184,216,.14); }
.lab-card.accent-orange { --accent: #e07b0c; --accent-soft: rgba(240,138,23,.13); }
.lab-card.accent-red { --accent: #e04f33; --accent-soft: rgba(238,91,63,.12); }
.lab-card.accent-yellow { --accent: #c98f08; --accent-soft: rgba(241,185,39,.16); }
.lab-card.accent-purple { --accent: #8f58d7; --accent-soft: rgba(143,88,215,.12); }
.lab-card.accent-green { --accent: #3d9a51; --accent-soft: rgba(71,169,92,.13); }
.lab-card.accent-pink { --accent: #d9558c; --accent-soft: rgba(235,109,162,.13); }

.lab-empty {
  min-block-size: 22.5rem;
  display: grid;
  place-items: center;
  text-align: center;
  padding: 2rem;
  border: 1px dashed var(--line-strong);
  border-radius: var(--lab-radius);
}
.lab-empty > div { display: grid; justify-items: center; }
.lab-empty h2 { margin: 1.125rem 0 .25rem; }
.lab-empty p { margin: 0; max-inline-size: 26rem; color: var(--muted); }

@container lab-index (max-width: 46rem) {
  .lab-heading { grid-template-columns: minmax(0, 1fr); gap: 1.5rem; }
  .lab-heading-stack { justify-self: start; }
}

@container lab-index (max-width: 30rem) {
  .lab-heading h1 { font-size: 2.25rem; }
  .lab-card-title { font-size: 1.1875rem; }
}

/* Viewport fallbacks mirror the container rules for older layout engines. */
@media (max-width: 53.75rem) {
  .lab-heading { grid-template-columns: minmax(0, 1fr); gap: 1.5rem; }
  .lab-heading-stack { justify-self: start; }
}

@media (max-width: 35rem) {
  .lab-heading h1 { font-size: 2.25rem; }
  .lab-card-title { font-size: 1.1875rem; }
}
