/* Second Scoop — a gelato shop's home page, flown through in 3D as you scroll */

:root {
  --bg: #ff5c80;
  --fg: #fff5e6;
  --pill-bg: #ffe14d;
  --pill-fg: #3a0f1f;

  --display: "Shrikhand", "Georgia", serif;
  --sans: "Figtree", system-ui, sans-serif;

  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --gutter: clamp(16px, 2.6vw, 36px);
  --persp: 600px; /* keep in step with P in script.js */
}

/* One palette per stretch of the flight: strawberry → pistachio → mango → blueberry */
html[data-palette="1"] { --bg: #2fa36b; --fg: #fff5e6; --pill-bg: #ff5c80; --pill-fg: #fff5e6; }
html[data-palette="2"] { --bg: #ffc23d; --fg: #3b1a10; --pill-bg: #3b1a10; --pill-fg: #ffc23d; }
html[data-palette="3"] { --bg: #4335e8; --fg: #fff5e6; --pill-bg: #ffc23d; --pill-fg: #3b1a10; }

*,
*::before,
*::after { box-sizing: border-box; }

html.lenis, html.lenis body { height: auto; }
.lenis.lenis-smooth { scroll-behavior: auto !important; }

body {
  margin: 0;
  background-color: var(--bg);
  color: var(--fg);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  transition: background-color 0.6s ease, color 0.45s ease;
}

.track { height: 1100vh; }

/* ── Header ─────────────────────────────────────────── */

.bar {
  position: fixed;
  top: var(--gutter);
  left: var(--gutter);
  right: var(--gutter);
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.logo {
  color: var(--fg);
  text-decoration: none;
  font-family: var(--display);
  font-size: clamp(22px, 2.2vw, 30px);
  line-height: 1;
  transition: color 0.45s ease;
}

.cta {
  display: inline-flex;
  align-items: center;
  gap: 0.5em;
  padding: 0.7em 1.2em 0.75em;
  border-radius: 999px;
  background: var(--pill-bg);
  color: var(--pill-fg);
  text-decoration: none;
  font-weight: 900;
  font-size: 14px;
  letter-spacing: 0.01em;
  text-transform: uppercase;
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.16);
  transition: background-color 0.6s ease, color 0.45s ease, transform 0.35s var(--spring), box-shadow 0.35s var(--ease);
}

.cta:hover { transform: translateY(-2px) rotate(-2deg); box-shadow: 0 6px 0 rgba(0, 0, 0, 0.16); }
.cta:active { transform: translateY(2px); box-shadow: 0 1px 0 rgba(0, 0, 0, 0.16); }
.cta:focus-visible { outline: 3px solid var(--fg); outline-offset: 3px; }

/* ── The 3D space ───────────────────────────────────── */

.viewport {
  position: fixed;
  inset: 0;
  overflow: hidden;
  perspective: var(--persp);
  perspective-origin: var(--px, 50%) var(--py, 50%);
  pointer-events: none;
}

.scene {
  position: absolute;
  inset: 0;
  transform-style: preserve-3d;
  will-change: transform;
}

/* Everything in the scene is placed by script with a translate3d */
.item,
.slide {
  position: absolute;
  visibility: hidden;
  will-change: transform, opacity;
}

.item { top: 50%; left: 50%; translate: -50% -50%; }

.slide {
  inset: 0;
  display: grid;
  place-items: center;
  padding: 0 5vw;
  text-align: center;
}

.slide[data-live] { pointer-events: auto; }

/* ── Type ───────────────────────────────────────────── */

.hero,
.say,
.end__title {
  margin: 0;
  perspective: 900px;
  font-weight: 900;
  text-transform: uppercase;
}

/* Lines tip up into place, one after another */
.line {
  display: block;
  white-space: nowrap; /* a line never re-wraps, whatever word the pill shows */
  transform-origin: 50% 100%;
  transform: translateY(0.4em) rotateX(-85deg);
  opacity: 0;
  transition:
    transform 0.9s var(--spring) calc(var(--i, 0) * 80ms),
    opacity 0.35s ease calc(var(--i, 0) * 80ms);
}

.is-in .line { transform: none; opacity: 1; }

.kicker {
  font-size: clamp(1.5rem, 4.2vw, 4rem);
  line-height: 1;
  letter-spacing: -0.01em;
}

.big {
  margin-top: 0.05em;
  font-family: var(--display);
  font-weight: 400;
  text-transform: lowercase;
  font-size: clamp(4.6rem, 17vw, 17rem);
  line-height: 0.92;
  letter-spacing: -0.01em;
  text-shadow: 0 0.05em 0 rgba(0, 0, 0, 0.14);
}

.say {
  font-size: clamp(2.5rem, 7.4vw, 7.6rem);
  line-height: 0.96;
  letter-spacing: -0.025em;
}

/* Rotating word in a pill */
.pill {
  position: relative;
  display: inline-block;
  height: 1.08em;
  margin: 0 0.04em;
  padding: 0 0.32em;
  overflow: hidden;
  vertical-align: -0.12em;
  border-radius: 999px;
  background: var(--pill-bg);
  color: var(--pill-fg);
  font-family: var(--display);
  font-weight: 400;
  text-transform: lowercase;
  letter-spacing: 0;
  line-height: 1.08em;
  box-shadow: 0 0.06em 0 rgba(0, 0, 0, 0.16);
  transition: background-color 0.6s ease, color 0.45s ease;
}

/* The pill is sized once to its widest word (in script.js), so the line around
   it never moves; each word sits centred and slides through */
.pill__word {
  position: absolute;
  top: 0;
  left: 50%;
  translate: -50% 0;
  white-space: nowrap;
  opacity: 0;
  transform: translateY(140%);
  transition: transform 0.6s var(--spring), opacity 0.3s ease;
}

.pill__word[data-on] { transform: none; opacity: 1; }
.pill__word[data-off] { transform: translateY(-140%); opacity: 0; }

/* ── Photos ─────────────────────────────────────────── */

.photo {
  width: var(--w);
  aspect-ratio: var(--r);
  overflow: hidden;
  border-radius: clamp(14px, 2vw, 30px);
  background: rgba(255, 255, 255, 0.18);
  box-shadow: 0 30px 60px -28px rgba(30, 10, 10, 0.5);
  rotate: var(--tilt, 0deg);
}

.photo img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* ── Scoops, cones, sprinkles ───────────────────────── */

.bob {
  animation: bob var(--dur, 3s) ease-in-out var(--delay, 0s) infinite alternate;
}

@keyframes bob {
  from { transform: translate3d(0, 0, 0) rotate(0deg); }
  to { transform: translate3d(var(--bx, 0), var(--by, -10px), 0) rotate(var(--br, 8deg)); }
}

/* A prop slot: filled with a baked 3D render (art.js), or a CSS stand-in */
.art {
  display: block;
  opacity: 0;
  transition: opacity 0.8s ease;
}

.art[data-ready] { opacity: 1; }

.art img {
  display: block;
  width: 100%;
  height: auto;
  user-select: none;
  -webkit-user-drag: none;
}

.scoop {
  display: block;
  aspect-ratio: 1;
  border-radius: 50%;
  background:
    radial-gradient(circle at 33% 28%, rgba(255, 255, 255, 0.9) 0 5%, rgba(255, 255, 255, 0) 17%),
    radial-gradient(circle at 42% 38%, var(--c1) 0 42%, var(--c2) 100%);
  box-shadow: inset 0 -0.08em 0 rgba(0, 0, 0, 0.06);
}

.sprinkle {
  width: var(--s);
  height: calc(var(--s) * 0.3);
  border-radius: 999px;
  background: var(--c);
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.14);
}

.cherry,
.spark { display: block; width: var(--s); height: auto; overflow: visible; }

/* A double-scoop cone, drawn in CSS */
.cone {
  position: relative;
  width: var(--w);
  aspect-ratio: 0.62;
  filter: drop-shadow(0 30px 40px rgba(40, 10, 10, 0.25));
}

.cone__wafer {
  position: absolute;
  left: 13%;
  right: 13%;
  top: 47%;
  bottom: 0;
  clip-path: polygon(0 0, 100% 0, 52% 100%, 48% 100%);
  background:
    repeating-linear-gradient(58deg, transparent 0 10%, rgba(120, 58, 18, 0.32) 10% 12%),
    repeating-linear-gradient(-58deg, transparent 0 10%, rgba(120, 58, 18, 0.32) 10% 12%),
    linear-gradient(90deg, #e8a85a, #f6c47b 40%, #d98a3c);
}

.cone__low,
.cone__high { position: absolute; }
.cone__low { left: 6%; width: 88%; top: 27%; }
.cone__high { left: 15%; width: 70%; top: 2%; }

/* ── End section ────────────────────────────────────── */

.end {
  width: min(100%, 1040px);
  display: grid;
  justify-items: center;
  gap: clamp(14px, 2.4vh, 26px);
}

.eyebrow {
  margin: 0;
  font-size: 13px;
  font-weight: 900;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  opacity: 0.8;
}

.end__title {
  font-family: var(--display);
  font-weight: 400;
  text-transform: none;
  font-size: clamp(2.4rem, 6vw, 5.6rem);
  line-height: 0.95;
}

.end__title em { font-style: normal; color: var(--pill-bg); transition: color 0.6s ease; }

.flavours {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: clamp(10px, 1.4vw, 16px);
  width: 100%;
  margin: clamp(4px, 1vh, 12px) 0 0;
  padding: 0;
  list-style: none;
}

.flavour {
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-rows: auto auto;
  column-gap: 14px;
  align-items: center;
  padding: clamp(12px, 1.6vw, 18px);
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.1);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.14);
  text-align: left;
  opacity: 0;
  transform: translateY(24px) scale(0.94);
  transition: transform 0.7s var(--spring), opacity 0.4s ease, background-color 0.3s ease;
}

.slide--end.is-in .flavour { opacity: 1; transform: none; }
.slide--end.is-in .flavour:nth-child(2) { transition-delay: 60ms; }
.slide--end.is-in .flavour:nth-child(3) { transition-delay: 120ms; }
.slide--end.is-in .flavour:nth-child(4) { transition-delay: 180ms; }
.slide--end.is-in .flavour:nth-child(5) { transition-delay: 240ms; }
.slide--end.is-in .flavour:nth-child(6) { transition-delay: 300ms; }

.flavour:hover { background: rgba(255, 255, 255, 0.18); }
.flavour:hover .scoop { transform: translateY(-4px) rotate(-10deg) scale(1.06); }

.flavour .scoop {
  grid-row: span 2;
  width: clamp(44px, 4.6vw, 64px);
  transition: transform 0.5s var(--spring);
}

.flavour strong {
  font-family: var(--display);
  font-weight: 400;
  font-size: clamp(1.05rem, 1.6vw, 1.4rem);
  line-height: 1.1;
}

.flavour span:not(.scoop) { font-size: 13px; opacity: 0.78; }

.cta--big { margin-top: clamp(6px, 1.4vh, 14px); font-size: 15px; padding: 0.95em 1.6em 1em; }

/* ── Scroll hint ────────────────────────────────────── */

.hint {
  position: fixed;
  left: 50%;
  bottom: var(--gutter);
  z-index: 10;
  display: grid;
  justify-items: center;
  gap: 8px;
  margin: 0;
  translate: -50% 0;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  pointer-events: none;
  transition: opacity 0.4s ease;
}

.hint i {
  width: 2px;
  height: 26px;
  border-radius: 2px;
  background: currentColor;
  transform-origin: top;
  animation: drip 1.6s var(--ease) infinite;
}

@keyframes drip {
  0% { transform: scaleY(0); opacity: 1; }
  60% { transform: scaleY(1); opacity: 1; }
  100% { transform: scaleY(1) translateY(10px); opacity: 0; }
}

.hint[data-hide] { opacity: 0; }

/* ── Small screens ──────────────────────────────────── */

@media (max-width: 760px) {
  .cta { font-size: 12px; }
  .say { font-size: clamp(1.75rem, 8.3vw, 3.2rem); } /* lines don't wrap, so they must fit */
  .flavours { grid-template-columns: repeat(2, 1fr); }
  .flavour { column-gap: 10px; border-radius: 16px; }
  .flavour span:not(.scoop) { display: none; }
  .flavour .scoop { grid-row: auto; width: 36px; }
}

@media (prefers-reduced-motion: reduce) {
  .bob, .hint i { animation: none; }
  .line, .pill, .pill__word, .flavour { transition: none; }
}
