@property --wipe {
  syntax: '<length>';
  inherits: true;
  initial-value: 0px;
}

:root {
  --ink: #131718;
  --muted: #6b7072;
  --line: #e4e6e7;
  --soft: #f4f5f5;
  --ease-out: cubic-bezier(.16, 1, .3, 1);
  --ease-wipe: cubic-bezier(.77, 0, .18, 1);
  --edge: 160px;
  --ui-font: 'Helvetica Neue', Helvetica, Arial, system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #fff;
  color: var(--ink);
  font-family: var(--ui-font);
  -webkit-font-smoothing: antialiased;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  overscroll-behavior: none;
}

body.hide-cursor, body.hide-cursor * { cursor: none !important; }

/* ------------------------------------------------------------ stage */

#viewport {
  position: fixed;
  inset: 0;
  overflow: hidden;
  background: #fff;
}

#stage {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 1920px;
  height: 1080px;
  transform-origin: 50% 50%;
  overflow: hidden;
  background: #fff;
}

/* ------------------------------------------------------------ layers + wipe */

.layer {
  position: absolute;
  inset: 0;
  --wipe: 0px;
}

.page {
  position: absolute;
  inset: 0;
  overflow: hidden;
  background: #fff;
}

.layer.wiping .page {
  -webkit-mask-image: linear-gradient(90deg, #000 calc(var(--wipe) - var(--edge)), transparent var(--wipe));
  mask-image: linear-gradient(90deg, #000 calc(var(--wipe) - var(--edge)), transparent var(--wipe));
}

.sweep {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: var(--edge);
  pointer-events: none;
  transform: translateX(calc(var(--wipe) - var(--edge)));
  background: linear-gradient(90deg,
    rgba(19, 23, 24, 0) 0%,
    rgba(19, 23, 24, .04) 55%,
    rgba(19, 23, 24, .12) 96%,
    rgba(19, 23, 24, 0) 100%);
  transition: opacity .35s ease;
}

.layer:not(.wiping) .sweep,
.layer.frozen .sweep { opacity: 0; }

/* ------------------------------------------------------------ product page */

.page .el {
  position: absolute;
  display: block;
  max-width: none;
  -webkit-user-drag: none;
}

.page svg.vec {
  position: absolute;
  inset: 0;
  width: 1920px;
  height: 1080px;
  overflow: visible;
  pointer-events: none;
}

.page svg text {
  font-variant-ligatures: none;
  font-kerning: none;
  white-space: pre;
}

/* Every element has its own entrance; --d is set per element from where the wipe edge is. */
.page .fx {
  animation-delay: var(--d, 0s);
  animation-fill-mode: both;
}

.page svg .fx {
  transform-box: fill-box;
  transform-origin: 50% 50%;
}

/* liquid swatch spreads out like a drop landing */
.fx-swatch {
  transform-origin: 50% 55%;
  animation: swatch-in 1.6s var(--ease-out);
}

@keyframes swatch-in {
  from { opacity: 0; transform: scale(.3) rotate(-35deg); filter: blur(14px); }
  45% { opacity: 1; filter: blur(0); }
  to { opacity: 1; transform: none; filter: none; }
}

/* bottle rises into place with a slight overshoot */
.fx-product {
  transform-origin: 50% 100%;
  animation: product-in 1.35s cubic-bezier(.2, 1.25, .35, 1);
}

@keyframes product-in {
  from { opacity: 0; transform: translateY(220px) rotate(-9deg) scale(.9); }
  40% { opacity: 1; }
  to { opacity: 1; transform: none; }
}

/* ingredient panel unrolls from the top */
.fx-block {
  animation: block-in 1.7s var(--ease-out);
}

@keyframes block-in {
  from { opacity: 0; clip-path: inset(0 0 100% 0); transform: translateY(40px); }
  25% { opacity: 1; }
  to { opacity: 1; clip-path: inset(0 0 0 0); transform: none; }
}

/* benefit icons spin in */
.fx-icon {
  animation: icon-in .95s cubic-bezier(.3, 1.5, .5, 1);
}

@keyframes icon-in {
  from { opacity: 0; transform: scale(.2) rotate(-160deg); }
  50% { opacity: 1; }
  to { opacity: 1; transform: none; }
}

/* title and heading words rise from behind their baseline */
.fx-word {
  animation: word-in .9s var(--ease-out);
}

@keyframes word-in {
  from { transform: translateY(120%); }
  to { transform: none; }
}

.fx-fade-up {
  animation: fade-up .8s var(--ease-out);
}

@keyframes fade-up {
  from { opacity: 0; transform: translateY(26px); }
  to { opacity: 1; transform: none; }
}

/* benefit lines slide out from their icon */
.fx-slide {
  animation: slide-in .8s var(--ease-out);
}

@keyframes slide-in {
  from { opacity: 0; transform: translateX(-60px); }
  to { opacity: 1; transform: none; }
}

.fx-slide.fx-rise {
  animation-name: fade-up;
}

/* logo lines rise from behind their baseline */
.fx-letter {
  animation: letter-in .9s var(--ease-out);
}

@keyframes letter-in {
  from { transform: translateY(var(--rise, 60px)); }
  to { transform: none; }
}

/* gentle idle motion once the page has settled */
.float {
  animation: drift 6s ease-in-out var(--fd, 0s) infinite alternate;
}

@keyframes drift {
  from { transform: translate3d(0, 0, 0) rotate(0deg); }
  to { transform: translate3d(0, -12px, 0) rotate(.6deg); }
}

.breathe {
  animation: breathe 9s ease-in-out var(--fd, 0s) infinite alternate;
}

@keyframes breathe {
  from { transform: scale(1) rotate(0deg); }
  to { transform: scale(1.035) rotate(-1.5deg); }
}

/* ------------------------------------------------------------ landing */

.landing .blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(40px);
  opacity: .9;
  will-change: transform;
}

.landing .blob.b1 {
  width: 900px; height: 760px; left: -220px; top: -260px;
  background: radial-gradient(closest-side, #eef0f1, rgba(238, 240, 241, 0));
  animation: blob1 22s ease-in-out infinite alternate;
}

.landing .blob.b2 {
  width: 1000px; height: 860px; right: -300px; bottom: -340px;
  background: radial-gradient(closest-side, #edeff0, rgba(237, 239, 240, 0));
  animation: blob2 26s ease-in-out infinite alternate;
}

@keyframes blob1 { to { transform: translate(260px, 160px) scale(1.15); } }
@keyframes blob2 { to { transform: translate(-280px, -120px) scale(1.1); } }

.landing .bubbles {
  position: absolute;
  inset: 0;
  overflow: hidden;
}

.landing .bubble {
  position: absolute;
  bottom: -40px;
  border-radius: 50%;
  border: 1.5px solid rgba(19, 23, 24, .16);
  background: radial-gradient(circle at 35% 30%, rgba(255, 255, 255, .95), rgba(255, 255, 255, 0) 55%);
  opacity: 0;
  animation: rise var(--t, 14s) linear var(--d, 0s) infinite;
}

@keyframes rise {
  0% { opacity: 0; transform: translate3d(0, 0, 0); }
  12% { opacity: 1; }
  80% { opacity: 1; }
  100% { opacity: 0; transform: translate3d(var(--sway, 30px), -1180px, 0); }
}

.landing svg.logo {
  position: absolute;
  inset: 0;
  width: 1920px;
  height: 1080px;
  overflow: visible;
}

.landing .logo-float {
  animation: logo-float 6s ease-in-out 2.2s infinite alternate;
}

@keyframes logo-float {
  from { transform: translate(0, 0); }
  to { transform: translate(0, -14px); }
}

.landing .ltr {
  transform-box: fill-box;
  transform-origin: 50% 100%;
  animation: ltr-in 1.1s var(--ease-out) calc(.25s + var(--i) * .065s) both;
}

@keyframes ltr-in {
  from { transform: translateY(115%) rotate(4deg); opacity: 0; }
  40% { opacity: 1; }
  to { transform: none; opacity: 1; }
}

.landing .shine {
  animation: shine 1.6s var(--ease-wipe) 1.45s both;
}

@keyframes shine {
  from { transform: translateX(-900px); }
  to { transform: translateX(900px); }
}

/* ------------------------------------------------------------ hotspots + toast */

.hotspot {
  position: fixed;
  top: 0;
  width: 150px;
  height: 150px;
  z-index: 20;
  touch-action: manipulation;
}

.hotspot-tl { left: 0; }
.hotspot-tr { right: 0; }

#toast {
  position: fixed;
  left: 50%;
  bottom: 5vh;
  z-index: 40;
  max-width: 80vw;
  padding: 14px 26px;
  border-radius: 999px;
  background: rgba(19, 23, 24, .88);
  color: #fff;
  font-size: clamp(14px, 1.4vw, 20px);
  letter-spacing: .01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  opacity: 0;
  transform: translate(-50%, 16px);
  transition: opacity .3s ease, transform .4s var(--ease-out);
  pointer-events: none;
}

#toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* ------------------------------------------------------------ menu */

.menu {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 3vh 3vw;
  background: rgba(19, 23, 24, .32);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  animation: fade-in .3s ease both;
  -webkit-user-select: text;
  user-select: text;
}

.menu[hidden], .sheet[hidden] { display: none; }

@keyframes fade-in { from { opacity: 0; } }
@keyframes pop-in { from { opacity: 0; transform: translateY(18px) scale(.98); } }

.menu-panel {
  display: flex;
  flex-direction: column;
  width: min(1100px, 100%);
  max-height: 100%;
  background: #fff;
  border-radius: 22px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, .18);
  overflow: hidden;
  animation: pop-in .45s var(--ease-out) both;
}

.menu-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  padding: 28px 32px 20px;
  border-bottom: 1px solid var(--line);
}

.menu-head h1 {
  margin: 0 0 6px;
  font-weight: 600;
  font-size: 28px;
}

.menu-head p { margin: 0; color: var(--muted); font-size: 16px; line-height: 1.45; }
.menu-head strong { color: var(--ink); font-weight: 600; }

.icon-btn {
  flex: none;
  width: 48px;
  height: 48px;
  border: 0;
  border-radius: 50%;
  background: var(--soft);
  color: var(--ink);
  font-size: 30px;
  line-height: 1;
  cursor: pointer;
}

.icon-btn:hover { background: var(--line); }

.menu-settings {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  padding: 16px 32px;
  background: var(--soft);
  font-size: 16px;
  color: var(--muted);
}

.menu-settings input {
  width: 90px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: 18px;
  text-align: center;
}

.plist {
  flex: 1;
  margin: 0;
  padding: 8px 20px;
  list-style: none;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.prow {
  display: grid;
  grid-template-columns: 72px 1fr auto;
  align-items: center;
  gap: 18px;
  padding: 14px 12px;
  border-bottom: 1px solid var(--line);
  border-radius: 14px;
  transition: background .4s ease;
}

.prow:last-child { border-bottom: 0; }
.prow.flash { background: #eef6ee; }

.prow .thumb {
  width: 72px;
  height: 72px;
  object-fit: contain;
  background: var(--soft);
  border-radius: 12px;
}

.prow .pname {
  margin: 0 0 8px;
  font-weight: 600;
  font-size: 18px;
}

.prow .actions { display: flex; gap: 8px; }

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 4px 4px 12px;
  border-radius: 999px;
  background: var(--soft);
  border: 1px solid var(--line);
  font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  font-size: 13px;
  color: var(--ink);
}

.chip button {
  width: 24px;
  height: 24px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  font-size: 17px;
  line-height: 1;
  cursor: pointer;
}

.chip button:hover { background: #e7d6d6; color: #8a1f1f; }
.chips .empty { color: var(--muted); font-size: 14px; padding: 4px 0; }

.btn {
  padding: 12px 20px;
  border: 1px solid var(--ink);
  border-radius: 999px;
  background: var(--ink);
  color: #fff;
  font: inherit;
  font-weight: 600;
  font-size: 15px;
  white-space: nowrap;
  cursor: pointer;
}

.btn.ghost { background: #fff; color: var(--ink); border-color: var(--line); }
.btn:hover { filter: brightness(1.15); }
.btn.ghost:hover { background: var(--soft); filter: none; }

.menu-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 32px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 15px;
}

.sheet {
  position: fixed;
  inset: 0;
  z-index: 35;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(19, 23, 24, .35);
  animation: fade-in .25s ease both;
}

#confirmSheet { z-index: 36; }

.sheet-card {
  width: min(520px, 100%);
  padding: 36px 36px 30px;
  border-radius: 22px;
  background: #fff;
  text-align: center;
  box-shadow: 0 30px 80px rgba(0, 0, 0, .25);
  animation: pop-in .4s var(--ease-out) both;
}

.sheet-card h2 {
  margin: 0 0 8px;
  font-weight: 600;
  font-size: 24px;
}

.sheet-sub { margin: 0 0 14px; color: var(--muted); font-size: 16px; line-height: 1.5; }
.sheet-sub strong { color: var(--ink); font-weight: 600; }
.sheet-msg { min-height: 24px; margin: 0 0 12px; font-size: 16px; color: var(--ink); }
.sheet-msg.ok { color: #2f6b34; }
.sheet-msg.warn { color: #8a5a12; }
.sheet-card .chips { justify-content: center; margin-bottom: 22px; }
.sheet-actions { display: flex; justify-content: center; gap: 12px; margin-top: 10px; }

.pulse {
  position: relative;
  width: 120px;
  height: 120px;
  margin: 0 auto 22px;
}

.pulse span {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2px solid var(--ink);
  opacity: 0;
  animation: ping 2.4s var(--ease-out) infinite;
}

.pulse span:nth-child(2) { animation-delay: .8s; }
.pulse span:nth-child(3) { animation-delay: 1.6s; }

.pulse::after {
  content: '';
  position: absolute;
  inset: 38px;
  border-radius: 50%;
  background: var(--ink);
}

@keyframes ping {
  from { transform: scale(.35); opacity: .9; }
  to { transform: scale(1); opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .landing .bubble, .landing .blob, .float, .breathe, .landing .logo-float { animation: none; }
}
