/* ─────────────────────────────────────────────────────────────
   Homepage hero: "New in the lab". A fanned stack of the newest items
   from every section, then a "Latest across the lab" strip.
   Script: /assets/js/lab-hero.js. Data: section feeds + /assets/data/lab-standing.json.
   ───────────────────────────────────────────────────────────── */
:root {
  --sec-learn: var(--content, #2CCFB6);
  --sec-games: var(--games, #43C86B);
  --sec-articles: var(--articles, #F4A522);
  --sec-tools: var(--zumilabs, #3894FF);
  --sec-experiments: #A78BFA;
  --sec-art: var(--art, #F26D9D);
}

.lab-hero { width: var(--page); margin: 0 auto; padding: clamp(28px, 5vh, 56px) 0 32px; }
.lab-hero__intro { text-align: center; margin-bottom: clamp(20px, 3.5vh, 36px); }
.lab-hero__tag { font-size: clamp(1.25rem, 2.2vw, 1.75rem); line-height: 1.2; letter-spacing: -0.02em; font-weight: 700; margin: 0 0 10px; }
.lab-hero__tag + .lab-hero__sub { margin: -4px 0 12px; font-size: clamp(0.85rem, 1.1vw, 0.95rem); color: var(--muted); }
.lab-hero__live { display: inline-flex; align-items: center; gap: 8px; font-size: 0.85rem; color: var(--muted); flex-wrap: wrap; justify-content: center; min-height: 1.3em; }
.lab-hero__live .dot { width: 8px; height: 8px; border-radius: 50%; background: #43C86B; animation: lab-pulse 2s infinite; }
@keyframes lab-pulse { 0% { box-shadow: 0 0 0 0 rgba(67,200,107,0.6); } 70% { box-shadow: 0 0 0 8px rgba(67,200,107,0); } 100% { box-shadow: 0 0 0 0 rgba(67,200,107,0); } }

/* ── Stack ── */
.lab-stack { position: relative; min-width: 0; }
.lab-stack__stage {
  position: relative; height: min(600px, 70vh); min-height: 460px; perspective: 1400px;
  overflow-x: clip; overflow-y: visible;
  touch-action: pan-y; user-select: none; -webkit-user-select: none; cursor: grab;
}
.lab-stack__stage.is-dragging { cursor: grabbing; }
.lab-stack__stage img, .lab-stack__stage video { -webkit-user-drag: none; pointer-events: none; }

.lab-card {
  position: absolute; top: 0; left: 50%; width: min(400px, 88%); height: 100%;
  border-radius: 26px; overflow: hidden; color: #fff; text-decoration: none;
  background: #111;
  box-shadow: 0 30px 60px rgba(0,0,0,0.45), 0 0 0 1px rgba(255,255,255,0.08);
  transform-origin: 50% 100%;
  transform: translateX(-50%) scale(0.8); opacity: 0;
  transition: transform 0.6s cubic-bezier(0.2, 0.8, 0.2, 1), opacity 0.6s, filter 0.6s;
  will-change: transform;
}
.lab-card:hover, .lab-card:focus-visible { color: #fff; }
.lab-card:focus-visible { outline: 3px solid var(--c); outline-offset: 4px; }
/* data-pos: distance from the front card (0); negative = already seen. */
.lab-card[data-pos="0"] { transform: translateX(-50%) translateY(0) scale(1); opacity: 1; z-index: 5; }
.lab-card:not([data-pos="0"]) .lab-card__ui { opacity: 0; }
.lab-card:not([data-pos="0"]):hover { filter: brightness(0.85); }

@media (min-width: 901px) {
  .lab-stack { --fan1: clamp(170px, 19vw, 300px); --fan2: clamp(300px, 33vw, 520px); }
  .lab-card[data-pos="1"]  { transform: translateX(calc(-50% + var(--fan1))) translateY(26px) scale(0.86) rotate(5deg);  opacity: 1; z-index: 4; filter: brightness(0.62); }
  .lab-card[data-pos="-1"] { transform: translateX(calc(-50% - var(--fan1))) translateY(26px) scale(0.86) rotate(-5deg); opacity: 1; z-index: 4; filter: brightness(0.62); }
  .lab-card[data-pos="2"]  { transform: translateX(calc(-50% + var(--fan2))) translateY(62px) scale(0.72) rotate(10deg);  opacity: 1; z-index: 3; filter: brightness(0.42); }
  .lab-card[data-pos="-2"] { transform: translateX(calc(-50% - var(--fan2))) translateY(62px) scale(0.72) rotate(-10deg); opacity: 1; z-index: 3; filter: brightness(0.42); }
  .lab-card[data-pos="3"]  { transform: translateX(calc(-50% + var(--fan2) + 120px)) translateY(90px) scale(0.6) rotate(14deg);  opacity: 0; z-index: 2; pointer-events: none; }
  .lab-card[data-pos="-3"] { transform: translateX(calc(-50% - var(--fan2) - 120px)) translateY(90px) scale(0.6) rotate(-14deg); opacity: 0; z-index: 2; pointer-events: none; }
}
@media (max-width: 900px) {
  .lab-hero { padding-top: 22px; }
  .lab-stack__stage { height: 520px; min-height: 0; }
  .lab-card { width: min(340px, 82%); }
  .lab-card[data-pos="1"] { transform: translateX(calc(-50% + 34px)) translateY(14px) scale(0.92) rotate(3deg); opacity: 1; z-index: 4; filter: brightness(0.6); }
  .lab-card[data-pos="2"] { transform: translateX(calc(-50% + 62px)) translateY(28px) scale(0.85) rotate(6deg); opacity: 1; z-index: 3; filter: brightness(0.45); }
  .lab-card[data-pos="-1"] { transform: translateX(calc(-50% - 140%)) rotate(-10deg); opacity: 0; z-index: 6; pointer-events: none; }
  .lab-card[data-pos="3"], .lab-card[data-pos="-2"], .lab-card[data-pos="-3"] { transform: translateX(calc(-50% + 80px)) translateY(40px) scale(0.8) rotate(9deg); opacity: 0; z-index: 1; pointer-events: none; }
}

.lab-card__img, .lab-card__video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.lab-card__bg { display: none; }
/* Wide pictures: whole picture in the upper part, on a blurred copy of itself. */
.lab-card.is-wide .lab-card__bg { display: block; position: absolute; inset: -30px; width: calc(100% + 60px); height: calc(100% + 60px); object-fit: cover; filter: blur(26px) brightness(0.55); }
.lab-card.is-wide .lab-card__img { object-fit: contain; object-position: 50% 28%; padding: 64px 14px 0; height: 62%; }
.lab-card--fit .lab-card__img, .lab-card--fit .lab-card__video { object-fit: contain; background: #0c0d12; }
.lab-card__video { opacity: 0; transition: opacity 0.3s; }
.lab-card__video.is-playing { opacity: 1; }
.lab-card::after { content: ''; position: absolute; inset: 0; background: linear-gradient(to top, rgba(0,0,0,0.9) 0%, rgba(0,0,0,0.45) 38%, transparent 62%); pointer-events: none; }
.lab-card__ui { position: absolute; inset: 0; z-index: 2; display: flex; flex-direction: column; justify-content: space-between; padding: 20px; transition: opacity 0.4s; }
.lab-card__top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.lab-badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 11px; border-radius: 999px;
  font-size: 0.72rem; font-weight: 800; letter-spacing: 0.06em; text-transform: uppercase;
  color: #0b0c10; background: var(--c);
  box-shadow: 0 4px 14px rgba(0,0,0,0.35);
}
.lab-badge svg { width: 13px; height: 13px; }
.lab-card__kind { font-size: 0.72rem; font-weight: 700; padding: 4px 9px; border-radius: 999px; background: rgba(0,0,0,0.55); border: 1px solid rgba(255,255,255,0.2); max-width: 60%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lab-card__bottom h3 { font-size: 1.45rem; line-height: 1.15; margin: 0 0 8px; letter-spacing: -0.02em; text-shadow: 0 2px 10px rgba(0,0,0,0.5); color: #fff; }
.lab-card__bottom p { margin: 0 0 14px; font-size: 0.9rem; color: rgba(255,255,255,0.82); line-height: 1.45; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.lab-card__meta { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.lab-card__when { font-size: 0.8rem; color: var(--c); font-weight: 700; }
.lab-card__cta { display: inline-flex; align-items: center; gap: 6px; padding: 10px 16px; border-radius: 12px; font-weight: 800; font-size: 0.9rem; background: var(--c); color: #0b0c10; white-space: nowrap; }
.lab-card__progress { position: absolute; left: 0; right: 0; top: 0; height: 3px; z-index: 3; background: rgba(255,255,255,0.15); }
.lab-card__progress i { display: block; height: 100%; width: 0; background: var(--c); }

.lab-stack__controls { display: flex; align-items: center; justify-content: center; gap: 10px; margin-top: 26px; flex-wrap: wrap; }
.lab-stack__chips { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; width: 100%; }
.lab-chip {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 7px 12px; border-radius: 999px; font: inherit; font-size: 0.8rem; font-weight: 600;
  color: var(--muted); background: var(--panel); border: 1px solid var(--line); cursor: pointer;
}
.lab-chip i { width: 8px; height: 8px; border-radius: 50%; background: var(--c); }
.lab-chip.is-on { color: var(--text); border-color: var(--c); background: color-mix(in srgb, var(--c) 16%, transparent); }
.lab-icon-btn { width: 36px; height: 36px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font: inherit; color: var(--text); background: var(--panel); border: 1px solid var(--line); cursor: pointer; }

/* ── Latest strip ── */
.lab-latest { width: var(--page); margin: 8px auto 64px; }
.lab-latest__head { display: flex; align-items: end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.lab-latest__head h2 { margin: 0; font-size: 1.6rem; letter-spacing: -0.02em; }
.lab-latest__filters { display: flex; gap: 8px; flex-wrap: wrap; }
.lab-tiles { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(240px, 1fr); gap: 16px; overflow-x: auto; padding-bottom: 8px; scroll-snap-type: x mandatory; scrollbar-width: thin; }
@media (min-width: 1100px) { .lab-tiles { grid-auto-columns: calc((100% - 4 * 16px) / 5); } }
.lab-tile { scroll-snap-align: start; text-decoration: none; color: inherit; border-radius: 18px; overflow: hidden; background: var(--bg-soft); border: 1px solid var(--line); display: flex; flex-direction: column; transition: transform 0.2s, border-color 0.2s; }
.lab-tile:hover { transform: translateY(-3px); border-color: var(--c); color: inherit; }
.lab-tile[hidden] { display: none; }
.lab-tile__img { aspect-ratio: 16 / 10; background: #111; position: relative; overflow: hidden; }
.lab-tile__img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.lab-tile__img .lab-badge { position: absolute; left: 10px; top: 10px; font-size: 0.62rem; padding: 4px 8px; }
.lab-tile__body { padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 6px; }
.lab-tile__body b { font-size: 0.95rem; line-height: 1.3; }
.lab-tile__body span { font-size: 0.78rem; color: var(--muted); }

@media (prefers-reduced-motion: reduce) {
  .lab-card { transition: opacity 0.2s; }
  .lab-hero__live .dot { animation: none; }
}
