/* =========================================================
   Tasty Cakes - motion layer (v6)
   Mobile first: everything here is tuned for phones, with
   desktop extras inside the hover/fine-pointer queries.
   Works with js/motion.js. If JS or GSAP fails, nothing
   here hides content (all hidden states need html.fx).
   ========================================================= */

/* ---------- Opening curtain (first page of a visit only) ---------- */
html.intro body::before,
html.intro body::after {
  content: "";
  position: fixed;
  z-index: 9999;
  pointer-events: none;
}
html.intro body::before {
  inset: 0;
  background:
    radial-gradient(120% 70% at 50% 40%, #4a2a1f 0%, var(--ganache) 70%);
  clip-path: ellipse(160% 120% at 50% 0%);
}
html.intro.intro-go body::before {
  animation: tcCurtain 0.85s cubic-bezier(0.76, 0, 0.24, 1) 0.3s forwards;
}
html.intro body::after {
  left: 50%;
  top: 50%;
  width: 104px;
  height: 104px;
  margin: -52px 0 0 -52px;
  border-radius: 50%;
  background: #fff url(../images/logo-tasty.jpg) center / cover no-repeat;
  box-shadow:
    0 0 0 6px rgba(243, 217, 164, 0.18),
    0 30px 60px -20px #000;
  animation: tcLogoIn 0.55s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}
html.intro.intro-go body::after {
  animation: tcLogoOut 0.5s cubic-bezier(0.76, 0, 0.24, 1) 0.3s both;
}
@keyframes tcCurtain {
  to {
    clip-path: ellipse(160% 0% at 50% 0%);
  }
}
@keyframes tcLogoIn {
  from {
    opacity: 0;
    transform: scale(0.5) rotate(-12deg);
  }
}
@keyframes tcLogoOut {
  from {
    opacity: 1;
    transform: none;
  }
  to {
    opacity: 0;
    transform: translateY(-60px) scale(0.8);
  }
}

/* ---------- Scroll progress line ---------- */
.scroll-prog {
  position: fixed;
  left: 0;
  right: 0;
  top: 0;
  height: 3px;
  z-index: 70;
  background: linear-gradient(90deg, var(--rasp), var(--gold));
  transform: scaleX(0);
  transform-origin: 0 50%;
  pointer-events: none;
}

/* ---------- Touch feedback: everything tappable answers the finger ---------- */
@media (hover: none) {
  .btn,
  .cart-btn,
  .menu-btn,
  .weights button,
  .add-btn,
  .reel-btn,
  .reel-arrow,
  .tabs button,
  .wa-float {
    transition:
      transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1),
      background-color 0.3s,
      color 0.3s,
      border-color 0.3s;
    -webkit-tap-highlight-color: transparent;
  }
  .btn:active,
  .cart-btn:active,
  .menu-btn:active,
  .add-btn:active,
  .reel-btn:active,
  .reel-arrow:active {
    transform: scale(0.94);
    transition-duration: 0.12s;
  }
  .weights button:active,
  .tabs button:active {
    transform: scale(0.9);
    transition-duration: 0.12s;
  }
  .col-item,
  .cel,
  .cake,
  .insta a,
  .menu-list li {
    -webkit-tap-highlight-color: transparent;
  }
  .col-item:active .photo img,
  .cake:active .cake-photo img {
    transform: scale(1.06);
    transition: transform 0.25s;
  }
}

/* ---------- Primary button sheen ---------- */
.hero .btn-rasp,
.cart .btn-wa,
.custom .btn-wa {
  position: relative;
  overflow: hidden;
  isolation: isolate;
}
.hero .btn-rasp::after,
.cart .btn-wa::after,
.custom .btn-wa::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background: linear-gradient(
    105deg,
    transparent 30%,
    rgba(255, 255, 255, 0.38) 48%,
    transparent 66%
  );
  transform: translateX(-120%);
  animation: tcSheen 4.2s ease-in-out 2.2s infinite;
}
@keyframes tcSheen {
  0%,
  62% {
    transform: translateX(-120%);
  }
  100% {
    transform: translateX(120%);
  }
}

/* ---------- Mobile menu: links slide in one by one ---------- */
.mobile-nav a,
.mobile-nav p {
  opacity: 0;
  transform: translateY(34px);
  transition:
    opacity 0.5s var(--ease),
    transform 0.7s var(--ease);
}
.menu-open .mobile-nav a,
.menu-open .mobile-nav p {
  opacity: 1;
  transform: none;
}
.menu-open .mobile-nav > :nth-child(1) { transition-delay: 0.12s; }
.menu-open .mobile-nav > :nth-child(2) { transition-delay: 0.17s; }
.menu-open .mobile-nav > :nth-child(3) { transition-delay: 0.22s; }
.menu-open .mobile-nav > :nth-child(4) { transition-delay: 0.27s; }
.menu-open .mobile-nav > :nth-child(5) { transition-delay: 0.32s; }
.menu-open .mobile-nav > :nth-child(6) { transition-delay: 0.4s; }
.mobile-nav a::after {
  content: "";
  display: block;
  height: 1px;
  margin-top: 6px;
  background: rgba(247, 230, 226, 0.14);
}

/* ---------- WhatsApp button: arrives after the hero, with a one-time tip ---------- */
html.fx .wa-float {
  transform: scale(0) rotate(-40deg);
  transition: transform 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}
html.fx .wa-float.wa-in {
  transform: none;
}
html.fx .wa-float.wa-in:hover {
  transform: scale(1.08);
}
.wa-tip {
  position: fixed;
  right: 84px;
  bottom: 26px;
  z-index: 46;
  background: var(--milk);
  color: var(--ganache);
  font-size: 13.5px;
  font-weight: 600;
  line-height: 1.3;
  padding: 10px 14px;
  border-radius: 16px 16px 4px 16px;
  box-shadow: 0 16px 34px -14px rgba(43, 23, 18, 0.55);
  opacity: 0;
  transform: translateX(16px) scale(0.9);
  transform-origin: 100% 100%;
  transition:
    opacity 0.4s var(--ease),
    transform 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
  pointer-events: none;
}
.wa-tip.show {
  opacity: 1;
  transform: none;
  pointer-events: auto;
}
.wa-tip small {
  display: block;
  font-weight: 500;
  color: var(--muted);
  font-size: 12px;
}
@media (max-width: 640px) {
  .wa-tip {
    right: 76px;
    bottom: 20px;
  }
}

/* ---------- Image wipes (set by JS, cleared when done) ---------- */
html.fx .wipe {
  will-change: clip-path;
}

/* ---------- Custom order steps: a line that draws as you scroll ---------- */
.steps {
  position: relative;
}
.steps-line {
  position: absolute;
  left: 23px;
  top: 42px;
  bottom: 42px;
  width: 2px;
  background: var(--butter);
  transform: scaleY(0);
  transform-origin: 50% 0;
  border-radius: 2px;
}
.steps li::before {
  position: relative;
  z-index: 1;
  transition:
    transform 0.6s cubic-bezier(0.34, 1.56, 0.64, 1),
    background-color 0.4s,
    color 0.4s,
    box-shadow 0.4s;
}
html.fx .steps li.on::before {
  background: var(--rasp);
  color: #fff;
  transform: scale(1.12);
  box-shadow: 0 0 0 6px rgba(194, 48, 79, 0.22);
}

/* ---------- Photo cake sticker: gentle wobble ---------- */
html.fx .ps-sticker {
  animation: tcWobble 3.6s ease-in-out infinite alternate;
}
@keyframes tcWobble {
  from {
    rotate: 6deg;
  }
  to {
    rotate: 18deg;
  }
}

/* ---------- Review stars fill in ---------- */
.stars .st {
  display: inline-block;
}

/* ---------- Desktop cursor bubble ---------- */
.cur-bubble {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 80;
  width: 84px;
  height: 84px;
  margin: -42px 0 0 -42px;
  border-radius: 50%;
  background: var(--rasp);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.02em;
  pointer-events: none;
  transform: scale(0);
  transition: transform 0.45s cubic-bezier(0.34, 1.56, 0.64, 1);
  box-shadow: 0 14px 30px -12px rgba(163, 36, 63, 0.7);
}
.cur-bubble.on {
  transform: scale(1);
}

/* =========================================================
   PHONE LAYOUT UPGRADES (only when animations are running)
   ========================================================= */
@media (max-width: 899px) {
  /* Hero cards: JS deals them from a pile into the grid */
  html.fx .sc {
    will-change: transform;
  }
  html.fx .sc .sc-img {
    box-shadow: 0 26px 40px -24px rgba(43, 23, 18, 0.6);
  }

  /* Bestsellers row: coverflow depth */
  html.fx .sig-track {
    perspective: 900px;
  }
  html.fx .sig .cake-photo {
    transform-origin: 50% 60%;
    will-change: transform;
  }

  /* Celebrations: cards stack on top of each other as you scroll */
  html.fx .celebrate {
    gap: 0;
    padding-bottom: 10px;
  }
  html.fx .cel {
    position: sticky;
    top: 86px;
    margin-bottom: 26px;
    padding: 12px 12px 20px;
    background: var(--milk);
    border-radius: 32px;
    box-shadow:
      0 -10px 30px -18px rgba(43, 23, 18, 0.35),
      0 30px 50px -36px rgba(43, 23, 18, 0.6);
    transform-origin: 50% 0;
    isolation: isolate;
  }
  html.fx .cel:nth-child(2) {
    top: 100px;
  }
  html.fx .cel:nth-child(3) {
    top: 114px;
  }
  html.fx .cel::after {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    background: var(--ganache);
    opacity: var(--dim, 0);
    pointer-events: none;
    z-index: 2;
  }
  html.fx .cel .cel-img {
    aspect-ratio: 4 / 3.7;
    margin-bottom: 16px;
    border-radius: 999px 999px 20px 20px;
  }
  html.fx .cel h3,
  html.fx .cel p {
    padding: 0 8px;
  }

  /* Reviews: a swipe row instead of a long stack */
  html.fx .review-row {
    display: flex;
    gap: 14px;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    scrollbar-width: none;
    margin: 0 calc(var(--pad) * -1);
    padding: 10px var(--pad) 30px;
    scroll-padding-left: var(--pad);
    perspective: 900px;
  }
  html.fx .review-row::-webkit-scrollbar {
    display: none;
  }
  html.fx .review {
    flex: 0 0 min(84vw, 340px);
    scroll-snap-align: start;
    padding: 28px 26px;
    will-change: transform;
  }
  .rv-dots {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-top: 4px;
  }
  .rv-dots i {
    width: 7px;
    height: 7px;
    border-radius: 99px;
    background: rgba(43, 23, 18, 0.2);
    transition:
      width 0.4s var(--ease),
      background-color 0.4s;
  }
  .rv-dots i.on {
    width: 26px;
    background: var(--rasp);
  }

  /* Swipe hint pill on the bestsellers row */
  .swipe-hint {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-top: 14px;
    font-size: 13px;
    font-weight: 600;
    color: var(--rasp);
  }
  .swipe-hint svg {
    width: 18px;
    height: 18px;
    animation: tcNudge 1.4s ease-in-out infinite;
  }
  @keyframes tcNudge {
    0%,
    100% {
      transform: translateX(0);
    }
    50% {
      transform: translateX(7px);
    }
  }
}
@media (min-width: 900px) {
  .swipe-hint,
  .rv-dots {
    display: none;
  }
}

/* Reduced motion: switch it all off */
@media (prefers-reduced-motion: reduce) {
  html.intro body::before,
  html.intro body::after,
  .scroll-prog,
  .wa-tip,
  .cur-bubble {
    display: none !important;
  }
  .mobile-nav a,
  .mobile-nav p {
    opacity: 1;
    transform: none;
  }
}

/* =========================================================
   RESPONSIVE FIXES (v6.1 bug hunt)
   ========================================================= */

/* Wide decorative pieces (tilted ribbon, cards waiting to slide in)
   must never make the page pan sideways */
@supports (overflow: clip) {
  main {
    overflow-x: clip;
  }
}

/* Footer: grid column could not shrink below the newsletter form,
   so on small phones the whole footer was wider than the screen */
.footer-top > * {
  min-width: 0;
}
.news input {
  width: 100%;
}
.news button {
  flex-shrink: 0;
}
@media (max-width: 640px) {
  .footer-top {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* Long button labels may wrap instead of being cut off */
.btn {
  max-width: 100%;
}
@media (max-width: 420px) {
  .btn {
    padding: 0 20px;
    white-space: normal;
    line-height: 1.25;
  }
  .btn-wa {
    font-size: 15px;
    gap: 8px;
  }
  .btn-wa svg {
    flex-shrink: 0;
  }
  /* hero buttons: one per line, full width */
  .hero-btns .btn {
    flex: 1 1 100%;
  }
}

/* Announcement bar: one line on small phones (two lines slid under the header) */
@media (max-width: 420px) {
  .announce {
    font-size: 12px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    padding: 0 12px;
    display: block;
    line-height: 38px;
  }
}

/* Everyday menu card: prices ran past the card edge on 320-400px phones */
@media (max-width: 420px) {
  .menu-card {
    padding: 30px 16px;
    border-radius: 30px;
  }
  .menu-list.compact .m-name {
    font-size: 17.5px;
  }
  .menu-list.compact .m-price {
    width: 54px;
    font-size: 14.5px;
  }
  .m-row {
    gap: 8px;
  }
  .col-title {
    grid-template-columns: 1fr 54px 54px;
    column-gap: 8px;
  }
}

/* Products page, very small phones: narrower photo, price under the name */
@media (max-width: 400px) {
  .cake-grid .cake {
    grid-template-columns: 96px minmax(0, 1fr);
    gap: 0 12px;
  }
  .cake-grid .cake-top {
    flex-direction: column;
    gap: 2px;
  }
  .cake-grid .cake-top h3 {
    font-size: 17.5px;
  }
  .cake-grid .add-btn {
    font-size: 14px;
    padding-left: 12px;
  }
  #sortBy {
    width: 118px;
  }
}

/* Tablets in portrait (600-899px): keep hero photos and stacking cards a sensible size */
@media (min-width: 600px) and (max-width: 899px) {
  .hero .stack {
    max-width: 560px;
    margin: 0 auto;
  }
  html.fx .celebrate {
    max-width: 540px;
    margin: 0 auto;
  }
  .review-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* Touch screens: comfortable tap sizes */
@media (hover: none) {
  .weights button {
    min-height: 40px;
  }
  .reel-dots button::after {
    content: "";
    position: absolute;
    inset: -14px -6px;
  }
}

/* Phone turned sideways: cards are taller than the screen, so no stacking */
@media (max-width: 899px) and (max-height: 599px) {
  html.fx .cel {
    position: relative;
    top: auto !important;
  }
  html.fx .celebrate {
    max-width: 480px;
    margin: 0 auto;
  }
}

/* =========================================================
   CART + POPUP SCROLL FIX (v6.2)
   ========================================================= */
/* the item list could not shrink, so it never scrolled */
.cart-items {
  min-height: 0;
}
.cart,
.popup-box,
.mobile-nav {
  -webkit-overflow-scrolling: touch;
}
/* Phones and short screens: the whole cart scrolls as one page
   (list, delivery details and the order button), header stays on top */
@media (max-width: 640px), (max-height: 760px) {
  .cart {
    overflow-y: auto;
    overscroll-behavior: contain;
    display: block;
  }
  .cart-head {
    position: sticky;
    top: 0;
    z-index: 2;
    background: var(--milk);
  }
  .cart-items {
    overflow: visible;
    min-height: 120px;
  }
}
