/* The Lab: interactive 3D collection.
   Drag a ring of products, flip the tier (the whole stage changes mood), then fly products onto your shelf. */

.lab { position: relative; padding: clamp(70px, 10vw, 130px) 0; background: linear-gradient(180deg, rgba(249,248,246,0), rgba(227,229,223,.55) 12%, rgba(227,229,223,.55) 88%, rgba(249,248,246,0)); }
.lab-head { text-align: center; margin-bottom: clamp(28px, 4vw, 48px); }
.lab-head .h2 { max-width: 16ch; margin-inline: auto; }
.lab-head .muted { margin-inline: auto; }
.lab-grid { display: grid; gap: 28px; grid-template-columns: 1fr; align-items: start; }
@media (min-width: 960px) { .lab-grid { grid-template-columns: 7fr 5fr; gap: 36px; } }

/* ---------- Stage ---------- */
.lab-stage { --mx: 50%; --my: 40%; position: relative; height: min(72vh, 620px); min-height: 440px; border-radius: 34px; overflow: hidden; perspective: 1200px; touch-action: pan-y; user-select: none; -webkit-user-select: none; outline: none; box-shadow: 0 60px 100px -56px rgba(26,26,26,.55); isolation: isolate; }
.lab-stage:focus-visible { box-shadow: 0 0 0 2px var(--gold), 0 60px 100px -56px rgba(26,26,26,.55); }
.lab-bg { position: absolute; inset: 0; z-index: -3; transition: opacity .9s var(--ease); }
.lab-bg.g { background: radial-gradient(circle at var(--mx) var(--my), #4a4132 0%, #1b1710 52%, #0a0907 100%); }
.lab-bg.s { background: radial-gradient(circle at var(--mx) var(--my), #fffaf1 0%, #efe0cb 52%, #d8c1a2 100%); opacity: 0; }
.lab-stage[data-tier="S"] .lab-bg.s { opacity: 1; }
.lab-spot { position: absolute; inset: 0; z-index: -2; pointer-events: none; background: radial-gradient(420px circle at var(--mx) var(--my), rgba(255,236,170,.22), transparent 65%); transition: background .3s; }
.lab-stage[data-tier="S"] .lab-spot { background: radial-gradient(420px circle at var(--mx) var(--my), rgba(255,255,255,.7), transparent 65%); }
.lab-dust { position: absolute; inset: 0; z-index: -1; pointer-events: none; overflow: hidden; }
.lab-dust i { position: absolute; width: 4px; height: 4px; border-radius: 50%; background: #E9C766; opacity: 0; animation: dust var(--t, 9s) linear infinite; animation-delay: var(--dl, 0s); left: var(--x, 50%); bottom: -10px; }
.lab-stage[data-tier="S"] .lab-dust i { background: #b98f3c; }
@keyframes dust { 0% { transform: translate3d(0,0,0) scale(.6); opacity: 0; } 15% { opacity: .85; } 100% { transform: translate3d(var(--dx, 20px), -560px, 0) scale(1.2); opacity: 0; } }

/* glowing floor rings in perspective */
.lab-floor { position: absolute; left: 50%; bottom: 7%; width: 74%; aspect-ratio: 1; transform: translateX(-50%) rotateX(74deg); transform-style: preserve-3d; pointer-events: none; z-index: -1; }
.lab-floor i { position: absolute; inset: 0; border-radius: 50%; border: 1px solid rgba(212,175,55,.55); box-shadow: 0 0 40px rgba(212,175,55,.25), inset 0 0 40px rgba(212,175,55,.12); }
.lab-floor i:nth-child(2) { inset: 12%; border-style: dashed; border-color: rgba(212,175,55,.4); animation: spin 40s linear infinite; }
.lab-floor i:nth-child(3) { inset: 26%; border-color: rgba(212,175,55,.3); }
.lab-stage[data-tier="S"] .lab-floor i { border-color: rgba(138,106,42,.45); box-shadow: 0 0 40px rgba(138,106,42,.15), inset 0 0 40px rgba(138,106,42,.08); }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Orbit and cards ---------- */
.lab-orbit { position: absolute; left: 50%; top: 45%; width: 0; height: 0; transform-style: preserve-3d; will-change: transform; }
.lab-card { position: absolute; left: 0; top: 0; width: var(--cw, 200px); height: var(--ch, 190px); margin: calc(var(--ch, 190px) / -2) 0 0 calc(var(--cw, 200px) / -2); transform-style: preserve-3d; cursor: grab; will-change: opacity; }
.lab-stage.grabbing .lab-card { cursor: grabbing; }
.lab-art { width: 100%; height: 100%; animation: bob 5.5s ease-in-out infinite; animation-delay: var(--bd, 0s); filter: drop-shadow(0 22px 22px rgba(0,0,0,.35)); }
.lab-art svg { width: 100%; height: 100%; overflow: visible; pointer-events: none; }
.lab-stage[data-tier="S"] .lab-art { filter: drop-shadow(0 22px 20px rgba(80,50,20,.28)); }
@keyframes bob { 0%, 100% { transform: translate3d(0,0,0); } 50% { transform: translate3d(0,-9px,0); } }

.lab-name { position: absolute; left: 0; right: 0; bottom: 22px; text-align: center; pointer-events: none; color: #fff; transition: color .6s; }
.lab-name span { display: block; font-family: var(--serif); font-size: clamp(1.4rem, 2.6vw, 2rem); line-height: 1.1; }
.lab-name small { display: block; margin-top: 4px; font-size: 11px; letter-spacing: .22em; text-transform: uppercase; opacity: .6; }
.lab-stage[data-tier="S"] .lab-name { color: #33251A; }

.lab-arrow { position: absolute; top: 45%; z-index: 4; width: 46px; height: 46px; margin-top: -23px; border-radius: 50%; display: grid; place-items: center; border: 1px solid rgba(255,255,255,.25); color: #fff; background: rgba(255,255,255,.06); transition: background .25s, transform .3s var(--ease), color .6s, border-color .6s; }
.lab-arrow:hover { background: rgba(212,175,55,.3); transform: scale(1.08); }
.lab-arrow.prev { left: 16px; } .lab-arrow.next { right: 16px; }
.lab-stage[data-tier="S"] .lab-arrow { color: #33251A; border-color: rgba(51,37,26,.25); background: rgba(255,255,255,.4); }
.lab-hint { position: absolute; top: 18px; left: 0; right: 0; text-align: center; pointer-events: none; font-size: 11px; letter-spacing: .22em; text-transform: uppercase; color: rgba(255,255,255,.6); transition: opacity .5s, color .6s; }
.lab-stage[data-tier="S"] .lab-hint { color: rgba(51,37,26,.6); }
.lab-stage.touched .lab-hint { opacity: 0; }

/* ---------- Side panel ---------- */
.lab-side { display: grid; gap: 18px; }
.lab-card-panel, .lab-shelf { border-radius: 28px; background: rgba(255,255,255,.85); border: 1px solid var(--accent); padding: 24px 26px; box-shadow: 0 40px 70px -50px rgba(26,26,26,.35); }
.lab-kicker { font-size: 11px; font-weight: 600; letter-spacing: .2em; text-transform: uppercase; color: var(--muted); margin-bottom: 10px; }
.lab-title { font-family: var(--serif); font-size: clamp(1.8rem, 3vw, 2.4rem); line-height: 1.05; color: var(--dark); }
.lab-desc { margin: 10px 0 0; color: var(--muted); font-size: .92rem; min-height: 3em; }

.lab-tier { position: relative; display: grid; grid-template-columns: 1fr 1fr; margin: 18px 0; padding: 4px; border-radius: 999px; background: #EFECE4; border: 1px solid var(--accent); }
.lab-tier button { position: relative; z-index: 1; padding: 11px 8px; border-radius: 999px; font-size: 13px; font-weight: 500; color: var(--muted); transition: color .35s; text-align: center; }
.lab-tier button b { display: block; font-size: 10px; letter-spacing: .16em; text-transform: uppercase; font-weight: 600; opacity: .7; }
.lab-tier button.on { color: #fff; }
.lab-tier[data-tier="S"] button.on { color: #33251A; }
.lab-tier-pill { position: absolute; z-index: 0; top: 4px; bottom: 4px; left: 4px; width: calc(50% - 4px); border-radius: 999px; background: linear-gradient(135deg, #2a251b, #0d0c0a); box-shadow: 0 8px 18px -8px rgba(0,0,0,.6); transition: transform .5s var(--ease), background .5s; }
.lab-tier[data-tier="S"] .lab-tier-pill { transform: translateX(100%); background: linear-gradient(135deg, #f1d7b6, #d8b494); box-shadow: 0 8px 18px -8px rgba(138,106,42,.6); }

.lab-buyrow { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.lab-price { font-family: var(--serif); font-size: 2.6rem; line-height: 1; color: var(--dark); font-variant-numeric: tabular-nums; }
.lab-save { font-size: 12px; color: var(--muted); }
.lab-save b { color: #8a6a2a; }
.lab-add { width: 100%; margin-top: 16px; padding: 16px; border-radius: 999px; background: var(--dark); color: #fff; font-size: 14px; font-weight: 500; position: relative; overflow: hidden; transition: transform .3s var(--ease), background .3s, box-shadow .3s; }
.lab-add::before { content: ""; position: absolute; inset: 0; background: linear-gradient(110deg, transparent 30%, rgba(255,255,255,.25) 50%, transparent 70%); transform: translateX(-120%); transition: transform .7s var(--ease); }
.lab-add:hover::before { transform: translateX(120%); }
.lab-add:hover { transform: translateY(-2px); box-shadow: 0 18px 30px -16px rgba(0,0,0,.5); }
.lab-add:active { transform: scale(.98); }
.lab-add.in { background: #2f5d46; }

/* ---------- Shelf ---------- */
.lab-shelf-top { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 14px; }
.lab-shelf-top h3 { font-size: 1.3rem; }
.lab-shelf-top span { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.lab-slots { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.lab-slot { position: relative; aspect-ratio: 1; border-radius: 16px; border: 1px dashed #d4cdbf; background: rgba(243,241,236,.7); display: grid; place-items: center; overflow: hidden; transition: border-color .3s, background .3s, transform .3s var(--ease); }
.lab-slot em { font-style: normal; font-size: 9.5px; letter-spacing: .1em; text-transform: uppercase; color: #b3ada0; text-align: center; padding: 0 4px; line-height: 1.25; }
.lab-slot.full { border-style: solid; border-color: var(--beige); background: #fff; }
.lab-slot.full.g { background: linear-gradient(160deg, #3a342a, #14110c); border-color: #8a6a2a; }
.lab-slot svg { width: 86%; height: 86%; }
.lab-slot img.ph { display: block; }
.lab-slot.pop { animation: slotpop .7s var(--ease); }
@keyframes slotpop { 0% { transform: scale(.82); } 55% { transform: scale(1.1); } 100% { transform: scale(1); } }
.lab-slot .x { position: absolute; top: 3px; right: 3px; width: 20px; height: 20px; border-radius: 50%; background: rgba(0,0,0,.55); color: #fff; font-size: 13px; line-height: 20px; text-align: center; opacity: 0; transition: opacity .2s; }
.lab-slot.full:hover .x, .lab-slot.full:focus-within .x { opacity: 1; }
@media (hover: none) { .lab-slot .x { opacity: 1; } }
.lab-total { display: flex; align-items: baseline; justify-content: space-between; margin-top: 16px; padding-top: 14px; border-top: 1px dashed var(--accent); font-size: 13px; color: var(--muted); }
.lab-total b { font-family: var(--serif); font-size: 2rem; color: var(--dark); font-variant-numeric: tabular-nums; }
.lab-actions { display: flex; gap: 8px; margin-top: 12px; }
.lab-actions button { flex: 1; padding: 13px; border-radius: 999px; border: 1px solid var(--accent); background: #fff; font-size: 13px; font-weight: 500; transition: border-color .2s, background .2s, opacity .2s; }
.lab-actions button:hover:not(:disabled) { border-color: var(--dark); }
.lab-actions button.solid { background: var(--beige); border-color: var(--beige); color: #33251A; }
.lab-actions button:disabled { opacity: .45; cursor: not-allowed; }
.lab-links { display: none; margin-top: 12px; gap: 6px; }
.lab-links.on { display: grid; }
.lab-links a { display: flex; justify-content: space-between; gap: 10px; padding: 10px 14px; border-radius: 14px; background: #FBFAF7; border: 1px solid var(--accent); font-size: 13px; transition: border-color .2s, transform .2s; }
.lab-links a:hover { border-color: var(--dark); transform: translateX(2px); }
.lab-links a span { color: var(--muted); font-variant-numeric: tabular-nums; }

/* flying product clone */
.lab-fly { position: fixed; z-index: 90; pointer-events: none; will-change: transform; }
.lab-fly svg { width: 100%; height: 100%; filter: drop-shadow(0 16px 18px rgba(0,0,0,.3)); }

@media (max-width: 959px) {
    .lab-stage { height: 54svh; min-height: 400px; border-radius: 26px; }
    .lab-arrow { width: 40px; height: 40px; }
    .lab-arrow.prev { left: 8px; } .lab-arrow.next { right: 8px; }
    .lab-card-panel, .lab-shelf { padding: 20px 18px; border-radius: 24px; }
    .lab-floor { width: 96%; }
}
@media (prefers-reduced-motion: reduce) {
    .lab-art, .lab-dust i, .lab-floor i { animation: none !important; }
}
