/* ==========================================================================
   TBG 11.11 promo popup — campaign card with a poster slider (27 Oct, client feedback v2)
   Card: counter + close, big "11.11" with "JIMAT KAW KAW!" under it, a big
   "50% OFF" offer line, the poster slider (5 posters, each with a checkered
   strip; neighbours peek in, tilted, at the card's edges), campaign terms in a
   soft panel, a coupon-style voucher code (Copy) and ORDER SEKARANG.
   The card's colour follows the poster in the middle: each slide carries
   data-bg (colour) + data-theme (light = dark text, dark = white text);
   js/order-first.js blends --promo-bg between slides while swiping.
   ========================================================================== */
#order-welcome {
  --promo-ink:#192c3c;
  --promo-red:#d93823;
  --promo-yellow:#ffd23f;
  --promo-ease:cubic-bezier(.34,1.56,.64,1);
  --promo-bg:#f8ce30;
  --sheet:min(420px, calc(100vw - 28px));
  position:fixed; inset:0;
  width:var(--sheet); max-width:none; max-height:calc(100vh - 24px); max-height:calc(100dvh - 24px);
  margin:auto; padding:0; border:0; border-radius:28px; overflow:hidden auto; overscroll-behavior:contain;
  background:var(--promo-bg); color:var(--fg);
  box-shadow:0 26px 70px rgba(4,12,22,.5);
  scrollbar-width:none;
}
#order-welcome::-webkit-scrollbar { display:none; }
/* Fit-to-screen: the card is a column capped at the viewport height. Everything is fixed-size except the
   slider, which shrinks first (posters get smaller) so the ORDER button always stays on screen. */
#order-welcome[open] { display:flex; flex-direction:column; }
/* light theme: on the yellow card */
#order-welcome, #order-welcome[data-theme="light"] {
  --fg:var(--promo-ink); --accent:var(--promo-red); --muted:rgba(25,44,60,.82); --line:rgba(25,44,60,.16);
  --panel:rgba(255,255,255,.38); --dash:rgba(25,44,60,.45); --copy-fg:#fff; --cta-bg:var(--promo-red); --cta-fg:#fff; --cta-edge:var(--promo-ink);
}
/* dark theme: on the blue / red card */
#order-welcome[data-theme="dark"] {
  --fg:#fff; --accent:var(--promo-yellow); --muted:rgba(255,255,255,.9); --line:rgba(255,255,255,.22);
  --panel:rgba(255,255,255,.13); --dash:rgba(255,255,255,.6); --copy-fg:var(--promo-ink); --cta-bg:var(--promo-yellow); --cta-fg:var(--promo-ink); --cta-edge:var(--promo-ink);
}
/* plain dim, no blur: a live blur behind moving cards re-renders every frame and makes the slider stutter on phones */
#order-welcome::backdrop { background:rgba(8,24,37,.86); }
/* while the popup is open, freeze page animations behind it (marquee etc.) so all frame time goes to the slider */
html.order-welcome-open body *:not(#order-welcome, #order-welcome *) { animation-play-state:paused !important; }
#order-welcome:focus { outline:none; }

.promo-sr { position:absolute; width:1px; height:1px; overflow:hidden; clip:rect(0 0 0 0); white-space:nowrap; }
.promo-sheet { flex:1 1 auto; min-height:0; display:flex; flex-direction:column; align-items:center; padding:14px 0 18px; }
.promo-sheet > * { flex:none; }
/* text colours ease when the theme flips mid-swipe */
.promo-count, .promo-head, .promo-terms, .promo-code, .welcome-close, .welcome-order-cta { transition:color .3s ease, background-color .3s ease, border-color .3s ease; }

/* ---- Top row: counter + close ---- */
.promo-sheet { position:relative; }
/* counter + close sit in the top corners (not a row of their own), so the title starts at the top */
.promo-top { position:absolute; inset:12px 12px auto 20px; z-index:2; display:flex; align-items:center; justify-content:space-between; pointer-events:none; }
.promo-top > * { pointer-events:auto; }
.promo-count { font-family:"Fredoka", "DM Sans", Arial, sans-serif; font-size:15px; font-weight:600; letter-spacing:.06em; color:var(--fg); }
.promo-count b { font-weight:700; color:var(--accent); }
.welcome-close {
  display:grid; place-items:center; width:38px; height:38px; padding:0; cursor:pointer;
  border:2px solid var(--fg); border-radius:50%; background:transparent; color:var(--fg);
  transition:transform .3s var(--promo-ease), background-color .2s ease, color .2s ease, border-color .3s ease;
}
.welcome-close:hover { transform:rotate(90deg); background:var(--fg); color:var(--promo-bg); }
.welcome-close:focus-visible, .welcome-order-cta:focus-visible, .promo-code:focus-visible { outline:3px solid var(--fg); outline-offset:3px; }

/* ---- Title: big 11.11, smaller JIMAT KAW KAW!, then a big 50% OFF (all Lilita) ---- */
.promo-head { margin-top:6px; padding:0 52px; text-align:center; color:var(--fg); }
.promo-head h2, .promo-offer__pct { font-family:"Lilita Heading", "Fredoka", "DM Sans", Arial, sans-serif; font-weight:400; text-transform:uppercase; }
.promo-head h2 { margin:0; line-height:.9; }
.promo-head__date { display:block; font-size:clamp(40px, min(17vw, 8.2dvh), 74px); letter-spacing:-.01em; color:var(--accent); }
.promo-head__name { display:block; margin-top:2px; font-size:clamp(17px, min(6vw, 3dvh), 26px); letter-spacing:.01em; color:var(--fg); }
.promo-offer { margin:2px 0 0; }
/* same font and size as "11.11" (client feedback) */
.promo-offer__pct { display:block; font-size:clamp(40px, min(17vw, 8.2dvh), 74px); line-height:.9; letter-spacing:-.01em; color:var(--accent); white-space:nowrap; }

/* ---- Slider ---- */
.promo-sheet > .promo-carousel { flex:0 1 auto; min-height:120px; display:flex; flex-direction:column; align-items:center; align-self:stretch; }
.promo-track {
  contain:layout paint;                /* slider changes never trigger layout/paint outside it */
  --peek-offset:0px;                   /* + pushes side posters further out, − lets more of them show */
  /* ideal height = poster at 64% of the card width; shrinks (down to 150px) when the screen is short.
     container-type lets the posters size themselves from whatever height the slider ends up with. */
  flex:0 1 calc(var(--sheet) * .74 * 1.25 + 30px); min-height:120px; height:auto; container-type:size;
  position:relative; width:100%;
  overflow:hidden; touch-action:pan-y; user-select:none; -webkit-user-select:none; cursor:grab;
}
.promo-track.is-dragging { cursor:grabbing; }
.promo-card {
  --card:min(calc(var(--sheet) * .74), calc((100cqh - 30px) * .8));
  position:absolute; top:8px; left:50%; width:var(--card); margin:0 0 0 calc(var(--card) / -2);
  transform-origin:50% 50%; will-change:transform;
  /* moved by js/order-first.js (requestAnimationFrame), so no CSS transition here */
  backface-visibility:hidden;
  border-radius:18px; box-shadow:0 10px 24px rgba(10,20,35,.28);
}
.promo-card:not(.is-active) { cursor:pointer; }
.promo-card img {
  display:block; width:100%; height:auto; aspect-ratio:4 / 5;
  border-radius:18px 18px 0 0; object-fit:cover; background:var(--c1);
  pointer-events:none; -webkit-user-drag:none;
}
/* checkered strip along the bottom, full card width, in the poster's own colours.
   9.5 tiles so it starts and ends on the same colour. */
.promo-card__checker {
  display:block; height:16px; border-radius:0 0 18px 18px;
  background:linear-gradient(90deg, var(--c1) 50%, var(--c2) 50%) 0 0 / calc(100% / 9.5) 100% repeat-x;
}

/* ---- Campaign terms: collapsed behind "Terms & conditions" (client: keep the posters big); tap to open.
   Opening it simply takes room from the slider, so the posters shrink and ORDER stays on screen. ---- */
/* minimal: a small muted text link under ORDER (no box, no tint); the terms open as plain text */
.promo-details { width:calc(100% - 40px); margin-top:8px; color:var(--fg); }
.promo-details__toggle {
  display:flex; align-items:center; justify-content:center; gap:4px; min-height:44px; margin:-6px auto -10px; padding:0 16px; cursor:pointer;
  border:0; background:transparent; color:var(--muted);
  font-family:"DM Sans", Arial, sans-serif; font-size:11.5px; font-weight:600; letter-spacing:.01em;
  transition:color .2s ease;
}
.promo-details__toggle span { text-decoration:underline; text-decoration-thickness:1px; text-underline-offset:3px; text-decoration-color:var(--line); }
.promo-details__toggle:hover { color:var(--fg); }
.promo-details__toggle svg { flex:none; width:14px; height:14px; fill:none; stroke:currentColor; stroke-width:2; stroke-linecap:round; stroke-linejoin:round; }
.promo-details__chev { transition:transform .3s ease; }
.promo-details__toggle[aria-expanded="true"] .promo-details__chev { transform:rotate(180deg); }
.promo-details__toggle:focus-visible { outline:2px solid var(--fg); outline-offset:2px; border-radius:6px; }
.promo-details__body { display:grid; grid-template-rows:0fr; transition:grid-template-rows .32s cubic-bezier(.22,1,.36,1); }
.promo-details.is-open .promo-details__body { grid-template-rows:1fr; }
.promo-details__inner { min-height:0; overflow:hidden; }

.promo-terms {
  display:grid; grid-template-columns:1.2fr 1fr; gap:8px 14px;
  margin:6px 0 0; padding:11px 14px 12px; border-radius:14px; background:var(--panel); color:var(--fg);
  transition:background-color .3s ease;
}
.promo-terms div { min-width:0; }
.promo-terms .promo-terms__wide { grid-column:1 / -1; }
.promo-terms dt {
  margin:0 0 1px; font-family:"DM Sans", Arial, sans-serif; font-size:9.5px; font-weight:700;
  letter-spacing:.08em; text-transform:uppercase; color:var(--muted);
}
.promo-terms dd { margin:0; font-family:"DM Sans", Arial, sans-serif; font-size:11.5px; font-weight:600; line-height:1.25; text-wrap:balance; color:var(--fg); }
.promo-terms dd small { display:block; margin-top:0; font-size:10px; white-space:nowrap; font-weight:500; color:var(--muted); }

/* ---- Voucher: same width / radius / tint as the terms panel, marked by a dashed outline (no white block,
   no notches) so it reads as part of the card instead of competing with the CTA ---- */
.promo-voucher {
  display:flex; align-items:center; justify-content:space-between; gap:12px;
  width:auto; max-width:calc(100% - 40px); margin-top:6px; padding:6px 7px 6px 14px; gap:16px;
  border:1.5px dashed var(--dash); border-radius:16px; background:var(--panel); color:var(--fg);
  transition:background-color .3s ease, color .3s ease, border-color .3s ease;
}
.promo-voucher__text { display:flex; flex-direction:column; min-width:0; }
.promo-voucher__text small { font-family:"DM Sans", Arial, sans-serif; font-size:9.5px; font-weight:700; letter-spacing:.08em; text-transform:uppercase; color:var(--muted); }
.promo-voucher__text b { font-family:"Fredoka", "DM Sans", Arial, sans-serif; font-size:16px; font-weight:700; line-height:1.15; letter-spacing:.06em; }
/* the conditions that decide whether the code works stay visible (full terms are behind the link) */
.promo-voucher__terms { margin-top:1px; text-wrap:balance; font-family:"DM Sans", Arial, sans-serif; font-size:10.5px; font-weight:600; line-height:1.25; color:var(--muted); }
.promo-code {
  display:inline-flex; align-items:center; gap:5px; flex:none; padding:6px 11px; cursor:pointer;
  border:0; border-radius:999px; background:var(--fg); color:var(--copy-fg);
  font-family:"DM Sans", Arial, sans-serif; font-size:12px; font-weight:700;
  transition:transform .2s var(--promo-ease), background-color .2s ease;
}
.promo-code:hover { transform:translateY(-1px); }
.promo-code:active { transform:scale(.96); }
.promo-code.is-copied { background:#1f8a4c; color:#fff; }
.promo-code__icon { width:13px; height:13px; fill:none; stroke:currentColor; stroke-width:2.2; stroke-linecap:round; stroke-linejoin:round; }
.promo-code__icon--done { display:none; }
.promo-code.is-copied .promo-code__icon--copy { display:none; }
.promo-code.is-copied .promo-code__icon--done { display:block; }

/* voucher + ORDER share one column: as wide as the wider of the two, never wider than the card padding */
.promo-actions { display:grid; justify-items:stretch; width:max-content; max-width:calc(100% - 40px); }
.promo-actions .promo-voucher, .promo-actions .welcome-order-cta { width:auto; max-width:none; }
/* phones: voucher + ORDER are exactly as wide as the poster (min 236px so the code still fits);
   compact voucher — code + Copy on one row, conditions on one line underneath (fixed height) */
@media (max-width:600px) {
  .promo-actions { width:clamp(236px, var(--poster-w, 260px), calc(100% - 40px)); }
  .promo-voucher { display:grid; grid-template-columns:1fr auto; column-gap:8px; row-gap:0; align-items:center; margin-top:4px; padding:5px 5px 5px 12px; border-radius:12px; }
  .promo-voucher__text { display:contents; }
  .promo-voucher__text small { display:none; }   /* dashed coupon + Copy already say "voucher code" */
  .promo-voucher__text b { grid-column:1; grid-row:1; font-size:15px; line-height:1.1; }
  .promo-voucher .promo-code { grid-column:2; grid-row:1; padding:4px 9px; font-size:11px; }
  .promo-voucher .promo-code__icon { width:12px; height:12px; }
  .promo-voucher__terms { grid-column:1 / -1; grid-row:2; margin-top:2px; font-size:9.5px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; text-wrap:nowrap; }
  .welcome-order-cta { margin-top:8px; padding:10px 16px 9px; font-size:15.5px; }
}

/* ---- CTA ---- */
.welcome-order-cta {
  display:inline-flex; align-items:center; justify-content:center; gap:12px; margin-top:14px;
  width:auto; padding:12px 30px 11px;   /* hugs its label, centred */
  border:2px solid var(--cta-edge); border-radius:999px; background:var(--cta-bg); color:var(--cta-fg);
  box-shadow:0 4px 0 var(--cta-edge);
  font-family:"Fredoka", "DM Sans", Arial, sans-serif; font-size:17px; font-weight:700; letter-spacing:.05em; text-decoration:none;
  transition:transform .2s var(--promo-ease), box-shadow .2s ease, background-color .3s ease, color .3s ease;
}
.welcome-order-cta:hover { transform:translateY(-2px); box-shadow:0 6px 0 var(--cta-edge); }
.welcome-order-cta:active { transform:translateY(2px); box-shadow:0 2px 0 var(--cta-edge); }
.welcome-order-cta .tbg-icon { width:18px; height:18px; }

/* ---- Entrance ---- */
#order-welcome[open]::backdrop { animation:promo-fade .3s ease both; }
#order-welcome[open] { animation:promo-pop .5s var(--promo-ease) both; }
#order-welcome[open] .promo-head { animation:promo-rise .45s ease .12s both; }
#order-welcome[open] .promo-track { animation:promo-rise .55s cubic-bezier(.22,1,.36,1) .2s both; }
#order-welcome[open] .promo-details, #order-welcome[open] .promo-voucher { animation:promo-rise .45s ease .3s both; }
#order-welcome[open] .welcome-order-cta { animation:promo-rise .45s var(--promo-ease) .38s both; }
@keyframes promo-fade { from { opacity:0; } }
@keyframes promo-pop { from { opacity:0; transform:translateY(24px) scale(.94); } }
@keyframes promo-rise { from { opacity:0; transform:translateY(16px); } }

@media (max-width:360px) {
  .promo-terms { gap:10px 12px; padding:12px 14px; }
  .promo-terms dd { font-size:12.5px; }
  .promo-voucher__text b { font-size:18px; }
}
/* short screens (phones with browser bars, in-app browsers, small phones) */
@media (max-height:760px) {
  .promo-sheet { padding:8px 0 12px; }
  .promo-top { top:10px; }
  .promo-head { margin-top:4px; }
  .promo-head__date, .promo-offer__pct { font-size:clamp(36px, min(15vw, 6.8dvh), 64px); }
  .promo-head__name { font-size:clamp(15px, min(5.4vw, 2.6dvh), 22px); margin-top:1px; }
  .welcome-close { width:34px; height:34px; }
  .promo-terms { gap:5px 12px; margin-top:4px; padding:8px 12px 9px; }
  .promo-details { margin-top:4px; }
  .promo-terms dd { font-size:11.5px; }
  .promo-voucher { margin-top:6px; padding:5px 6px 5px 12px; }
  .promo-voucher__text b { font-size:15px; }
  .welcome-order-cta { margin-top:10px; padding:11px 20px 10px; font-size:16px; }
}
@media (max-height:620px) {
  .promo-head__date, .promo-offer__pct { font-size:clamp(32px, min(14vw, 6.4dvh), 56px); }
  .promo-terms { gap:4px 10px; padding:7px 11px 8px; }
  .promo-terms dt { font-size:9.5px; }
  .promo-voucher { padding:5px 6px 5px 12px; }
  .promo-voucher__text small { font-size:9.5px; }
  .promo-voucher__text b { font-size:15.5px; }
  .promo-terms dd { font-size:12px; }
  .promo-terms dd small { display:inline; margin-left:4px; }
  .promo-terms dd small::before { content:"· "; }
  .welcome-order-cta { padding:10px 18px 9px; font-size:15px; }
}
/* very narrow phones (iPhone SE 1st gen, small Androids) */
@media (max-width:340px) {
  .promo-voucher__terms { font-size:9.5px; }
  .promo-terms { grid-template-columns:1fr 1fr; gap:4px 8px; padding:7px 10px 8px; }
  .promo-terms dt { font-size:9px; letter-spacing:.05em; }
  .promo-terms dd { font-size:11.5px; }
  .promo-terms dd small { display:block; margin-left:0; font-size:10px; white-space:normal; }
  .promo-terms dd small::before { content:none; }
  .welcome-order-cta { font-size:14.5px; }
}
/* with the terms open, the slider may shrink further so ORDER still fits on the smallest screens */
#order-welcome.terms-open .promo-sheet > .promo-carousel, #order-welcome.terms-open .promo-track { min-height:84px; }
/* tiniest screens (iPhone SE 1st gen + Safari bars): the Promotion row repeats the 50% OFF title, drop it */
@media (max-height:520px) { .promo-terms .promo-terms__wide { display:none; } }
@media (prefers-reduced-motion:reduce) {
  #order-welcome[open], #order-welcome[open] .promo-head, #order-welcome[open] .promo-track,
  #order-welcome[open] .promo-details, #order-welcome[open] .promo-voucher, #order-welcome[open] .welcome-order-cta { animation:none; }
}
