.lab-intro {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 340px);
  gap: 64px;
  align-items: start;
}
.lab-page .lead { max-width: 34ch; font-size: 24px; line-height: 1.4; }
.lab-page .page-intro p + p { margin-top: 16px; }

.gadget-figure { margin-top: 40px; width: 100%; max-width: 330px; justify-self: center; }
.gadget-man { position: relative; isolation: isolate; }
.gm-art { position: relative; }

.gm-frame {
  display: block;
  width: 100%;
  height: auto;
  opacity: 1;
  transition: opacity 1.2s ease;
}
.gm-1, .gm-2, .gm-3 { position: absolute; left: 0; top: 0; display: none; }
.lab-js .gm-1, .lab-js .gm-2, .lab-js .gm-3 { display: block; }
.gm-3 { z-index: 1; }
.gm-2 { z-index: 2; }
.gm-1 { z-index: 3; }
.gadget-man[data-stage="2"] .gm-1,
.gadget-man[data-stage="3"] :is(.gm-1, .gm-2),
.gadget-man[data-stage="4"] :is(.gm-1, .gm-2, .gm-3) { opacity: 0; }
.gadget-man[data-stage="1"] :is(.gm-2, .gm-3) { transition: opacity 0s linear 1.2s; }
.gm-instant .gm-frame, .gm-instant .gm-heart { transition: none !important; }

.gm-heart {
  position: absolute;
  z-index: 4;
  left: var(--hx);
  top: var(--hy);
  width: calc(var(--hw) * 2.6);
  aspect-ratio: 1;
  transform: translate(-50%, -50%);
  pointer-events: none;
  opacity: 0;
  transition: opacity .6s ease;
}
.gm-heart::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 210, 120, .7), rgba(240, 170, 60, .3) 40%, rgba(217, 164, 65, 0) 70%);
  opacity: .75;
  animation: gm-heart-pulse 2.8s ease-in-out infinite;
}
@keyframes gm-heart-pulse {
  0%, 100% { opacity: .45; transform: scale(.94); }
  50% { opacity: .95; transform: scale(1.06); }
}
.gadget-man:not([data-stage]) .gm-heart,
.gadget-man[data-stage="4"] .gm-heart { opacity: 1; transition: opacity .8s ease .9s; }

.gm-tap {
  position: absolute;
  inset: 0;
  z-index: 5;
  width: 100%;
  height: 100%;
  min-height: 0;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  cursor: pointer;
}
.gm-tap:hover { box-shadow: none; }
.gm-tap:focus-visible { outline: 3px solid var(--blue); outline-offset: 4px; }
.gm-caption { margin-top: 12px; text-align: center; max-width: none; }
body:not(.lab-js) .gm-caption { display: none; }

.cabinet-layout {
  display: grid;
  grid-template-columns: minmax(0, 540px) minmax(0, 1fr);
  grid-template-rows: auto 1fr;
  grid-template-areas: "picture head" "picture index";
  gap: 0 56px;
  align-items: start;
}
.cabinet-head { grid-area: head; }
.cabinet-frame { grid-area: picture; position: relative; }
.cabinet-index { grid-area: index; }
.cabinet-head h2 { margin-top: 0; }
.cabinet-art { position: relative; isolation: isolate; container-type: inline-size; }
.cabinet-img { width: 100%; height: auto; }

.bottles { position: absolute; inset: 0; pointer-events: none; }
.bottle {
  --cycle: 20s;
  --delay: calc(1.5s + var(--b) * 4s);
  position: absolute;
  left: var(--x);
  top: var(--y);
  width: var(--w);
  height: var(--h);
  transform-origin: var(--ox) var(--oy);
  isolation: isolate;
  animation: bottle-wobble var(--cycle) ease-in-out var(--delay) infinite;
}
.bottle-glass, .bottle-tint { position: absolute; left: 0; top: 0; width: 100%; height: 100%; }
.bottle-tint, .bottle-halo { opacity: 0; animation: bottle-light var(--cycle) ease-in-out var(--delay) infinite; }
.bottle-tint { mix-blend-mode: multiply; }
.bottle-halo {
  position: absolute;
  inset: 22% -12% -3%;
  border-radius: 50%;
  background: radial-gradient(closest-side, var(--halo), rgba(255, 255, 255, 0));
}
@keyframes bottle-light {
  0%, 17%, 100% { opacity: 0; }
  4%, 11% { opacity: .85; }
}
@keyframes bottle-wobble {
  0%, 3%, 15%, 100% { transform: rotate(0deg); }
  5% { transform: rotate(-3deg); }
  7% { transform: rotate(2.4deg); }
  9% { transform: rotate(-1.6deg); }
  11% { transform: rotate(.9deg); }
  13% { transform: rotate(-.4deg); }
}
.motion-off .bottle, .motion-off .bottle > * { animation: none !important; }
@media (prefers-reduced-motion: reduce) {
  .bottle, .bottle > * { animation: none !important; }
}

.bottle-word {
  position: absolute;
  left: var(--lx);
  top: var(--ly);
  width: var(--lw);
  height: var(--lh);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #3a2a1f;
  font: italic 400 var(--fsp) / 1 "Times New Roman", Times, serif;
  white-space: nowrap;
}
.bottle-word > span { display: block; transform: scaleX(var(--sq)); }

.shelf-tag {
  position: absolute;
  left: var(--tx);
  top: var(--ty);
  z-index: 1;
  transform: translate(-50%, -50%);
  padding: .04em .3em .1em;
  border: 1px solid #a07a3c;
  border-radius: 1px;
  background: #fbf7ef;
  box-shadow: 0 1px 2px rgba(43, 32, 25, .35);
  color: var(--text);
  font: italic 400 10.5px / 1.2 "Times New Roman", Times, serif;
  white-space: nowrap;
}
@supports (width: 1cqw) {
  .bottle-word { font-size: var(--fs); }
  .shelf-tag { font-size: var(--tag-font); }
}

.hotspot {
  position: absolute;
  left: var(--x);
  top: var(--y);
  width: var(--w);
  height: var(--h);
  min-height: 44px;
  border-radius: 12px;
  color: inherit;
  text-decoration: none;
}
.hotspot-value { z-index: 1; border-radius: 42% 42% 12px 12px / 26% 26% 12px 12px; }
.hotspot::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  opacity: 0;
  background: radial-gradient(closest-side, rgba(255, 222, 150, .5), rgba(217, 164, 65, .22) 70%, rgba(217, 164, 65, .05));
  box-shadow: inset 0 0 0 2px rgba(217, 164, 65, .9), 0 0 22px 6px rgba(217, 164, 65, .45);
  transition: opacity .25s ease;
}
.hotspot:hover::before,
.hotspot:focus-visible::before,
.hotspot.is-carrier::before { opacity: 1; }
.hotspot:focus-visible { outline: 3px solid var(--blue); outline-offset: 2px; }

.cabinet-list { list-style: none; margin: 24px 0 0; padding: 0; }
.cabinet-projects { display: grid; gap: 10px; }
.cabinet-projects .button { justify-content: flex-start; width: 100%; text-align: left; }
.cabinet-values { display: flex; flex-wrap: wrap; gap: 10px; }

.bottle-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 6px 15px 6px 11px;
  border: 1px solid var(--brass);
  border-radius: 20px 20px 7px 7px;
  background: #fff;
  color: var(--text);
  font-size: 17px;
  line-height: 1.3;
  text-decoration: none;
}
.bottle-chip:hover { background: #fffaf0; box-shadow: inset 0 0 0 1px var(--brass); text-decoration: underline; }
.bottle-icon { flex: 0 0 auto; color: #9a6a1d; }

.lab-notes { display: grid; gap: 28px; max-width: 760px; margin-top: 56px; }
.lab-panel-ready .lab-notes { display: none; }

.note {
  padding: 26px 28px 26px;
  border: 1px solid #e6dccb;
  border-left: 6px solid var(--brass);
  border-radius: 2px 8px 8px 2px;
  background-color: #fbf7ef;
  background-image: repeating-linear-gradient(to bottom, rgba(30, 77, 140, 0) 0 33px, rgba(30, 77, 140, .07) 33px 34px);
  box-shadow: 0 10px 30px rgba(43, 32, 25, .08);
}
.note-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 6px;
}
.note h3 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 28px;
  font-weight: 400;
  line-height: 1.2;
  text-wrap: pretty;
}
.note h3[tabindex="-1"]:focus { outline: none; }
.note-picture { flex: 0 0 auto; width: 156px; height: auto; mix-blend-mode: multiply; }
.note-bottle { flex: 0 0 auto; width: 44px; height: auto; color: #9a6a1d; }

.note-row { margin-top: 18px; }
.note-label {
  margin: 0 0 3px;
  color: var(--quiet);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: .06em;
  line-height: 1.35;
  text-transform: uppercase;
}
.note p { max-width: none; font-size: 19px; line-height: 1.55; }
.note p + p { margin-top: 10px; }
.note-quote { font-family: Georgia, "Times New Roman", serif; font-style: italic; }
.note-line { margin-top: 10px; }

.bottle-list { list-style: none; margin: 6px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.note-links { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 6px; }
.note-links .button { min-height: 44px; padding: 8px 16px; font-size: 17px; }
.note-link-arrow { margin-left: 6px; text-decoration: none; display: inline-block; }

.note-projects { list-style: none; margin: 18px 0 0; padding: 0; display: grid; gap: 10px; }
.note-projects .button { justify-content: flex-start; width: 100%; text-align: left; }

.lab-turn { text-align: center; }
.lab-turn > p { margin-inline: auto; }
.lab-turn .question { margin-bottom: 18px; }

.lab-panel {
  position: fixed;
  inset: 0 0 0 auto;
  width: min(480px, 100%);
  max-width: 100%;
  height: 100%;
  max-height: 100%;
  margin: 0;
  padding: 0;
  overflow: hidden;
  border: 0;
  border-left: 6px solid var(--brass);
  background: #fbf7ef;
  color: var(--text);
  box-shadow: -18px 0 44px rgba(43, 32, 25, .2);
  transform: translateX(100%);
  transition: transform .38s cubic-bezier(.2, .7, .2, 1), overlay .38s allow-discrete, display .38s allow-discrete;
}
.lab-panel[open] { transform: none; }
@starting-style { .lab-panel[open] { transform: translateX(100%); } }
.lab-panel::backdrop {
  background-color: rgba(43, 32, 25, 0);
  transition: background-color .38s ease, overlay .38s allow-discrete, display .38s allow-discrete;
}
.lab-panel[open]::backdrop { background-color: rgba(43, 32, 25, .28); }
@starting-style { .lab-panel[open]::backdrop { background-color: rgba(43, 32, 25, 0); } }

.lab-panel-inner {
  height: 100%;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 0 32px 48px 30px;
  background-image: repeating-linear-gradient(to bottom, rgba(30, 77, 140, 0) 0 33px, rgba(30, 77, 140, .07) 33px 34px);
  background-attachment: local;
}
.lab-panel-bar {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  justify-content: flex-end;
  padding: 14px 0 12px;
  background: linear-gradient(#fbf7ef 72%, rgba(251, 247, 239, 0));
}
.lab-panel-close { min-height: 44px; padding: 6px 18px; font-size: 17px; }
.lab-panel .note { padding: 0; border: 0; border-radius: 0; background: none; box-shadow: none; }

@media (max-width: 899px) {
  .lab-intro { grid-template-columns: minmax(0, 1fr); gap: 28px; }
  .gadget-figure { margin-top: 0; max-width: 300px; }
  .cabinet-layout {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto;
    grid-template-areas: "head" "picture" "index";
    gap: 8px;
  }
  .cabinet-frame { width: 100%; max-width: 560px; justify-self: center; margin-top: 8px; }
}

@media (max-width: 600px) {
  .gadget-figure { max-width: 260px; }

  .cabinet-frame {
    overflow: hidden;
    justify-self: stretch;
    width: auto;
    max-width: none;
    margin-inline: max(-20px, calc((100% - 440px) / 2));
  }
  .cabinet-art {
    width: calc(100% / var(--crop-w));
    margin: -10% 0 -14% calc(-100% * var(--crop-x0) / var(--crop-w));
  }
  .note { padding: 20px 18px 22px; }
  .note h3 { font-size: 24px; }
  .note-picture { width: 112px; }
  .note p { font-size: 18px; }

  .lab-panel {
    inset: auto 0 0 0;
    width: 100%;
    height: auto;
    max-height: 88vh;
    max-height: 88dvh;
    border-left: 0;
    border-top: 6px solid var(--brass);
    border-radius: 14px 14px 0 0;
    box-shadow: 0 -14px 40px rgba(43, 32, 25, .2);
    transform: translateY(100%);
  }
  @starting-style { .lab-panel[open] { transform: translateY(100%); } }
  .lab-panel-inner {
    height: auto;
    max-height: calc(88vh - 6px);
    max-height: calc(88dvh - 6px);
    padding: 0 20px 32px;
  }
}

@media (max-width: 359px) {
  .cabinet-frame { margin-inline: -16px; }
}
