/* =====================================================================
   Affiliation offer (since 2026-11-03) — lib/offer-popup.php, js/offer.js
   Loaded only while an offer runs (or for the admin's preview).
   ---------------------------------------------------------------------
   1 the home page pop-up      2 the offer on the affiliation pages
   3 computers / phones upright / phones sideways      4 reduced motion
   Colours come from the website theme; every animation moves only
   transform / opacity (cheap for phones).
   ===================================================================== */

/* ---------- 1. Pop-up ---------- */
html.offer-open { overflow: hidden; }
.offer-pop { position: fixed; inset: 0; z-index: 240; display: grid; place-items: center; padding: 16px; }
.offer-pop[hidden] { display: none; }
.offer-pop-shade { position: absolute; inset: 0; background: rgba(var(--navy-900-rgb), .74); opacity: 0; transition: opacity .35s; }
.offer-pop.is-open .offer-pop-shade { opacity: 1; }

.offer-pop-card {
  position: relative; display: flex; flex-direction: column;
  width: min(440px, 100%); max-height: calc(100vh - 32px); max-height: calc(100dvh - 32px);
  border-radius: 22px; background: linear-gradient(180deg, #FFFFFF 0%, var(--ivory) 100%);
  box-shadow: 0 0 0 1.5px var(--gold), 0 0 0 6px rgba(255, 255, 255, .92), 0 0 0 7.5px rgba(var(--gold-rgb), .7), 0 30px 80px rgba(0, 0, 0, .45);
  opacity: 0; transform: translateY(30px) scale(.86);
}
.offer-pop.is-open .offer-pop-card { animation: offer-in .75s cubic-bezier(.2, 1.35, .35, 1) forwards; }
.offer-pop.is-closing .offer-pop-card { opacity: 1; transform: none; animation: offer-out .25s ease-in forwards; }
.offer-pop.is-closing .offer-pop-shade { opacity: 0; }
@keyframes offer-in { 0% { opacity: 0; transform: translateY(30px) scale(.86); } 55% { opacity: 1; } 100% { opacity: 1; transform: none; } }
@keyframes offer-out { to { opacity: 0; transform: translateY(16px) scale(.94); } }

.offer-pop-scroll { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; border-radius: inherit; }

/* a band of light that sweeps over the card now and then */
.offer-pop-shine { position: absolute; inset: 0; z-index: 2; overflow: hidden; border-radius: inherit; pointer-events: none; }
.offer-pop-shine::before {
  content: ""; position: absolute; top: -20%; bottom: -20%; left: 0; width: 45%;
  background: linear-gradient(100deg, transparent 0%, rgba(255, 255, 255, .55) 50%, transparent 100%);
  transform: translateX(-160%) skewX(-12deg); animation: offer-shine 5.5s 1.1s ease-in-out infinite;
}
@keyframes offer-shine { 0% { transform: translateX(-160%) skewX(-12deg); } 30%, 100% { transform: translateX(360%) skewX(-12deg); } }

/* gold sparkles around the card */
.offer-spark { position: absolute; z-index: 3; width: 18px; line-height: 0; pointer-events: none; opacity: 0; animation: offer-twinkle 2.6s ease-in-out infinite; }
.offer-spark svg { display: block; width: 100%; height: auto; fill: var(--gold); filter: drop-shadow(0 0 4px rgba(255, 214, 120, .9)); }
.offer-spark.s1 { top: -9px; left: 12%; }
.offer-spark.s2 { top: 18%; right: -9px; width: 14px; animation-delay: -.6s; }
.offer-spark.s3 { bottom: 26%; left: -9px; width: 22px; animation-delay: -1.2s; }
.offer-spark.s4 { bottom: -10px; right: 18%; animation-delay: -1.8s; }
.offer-spark.s5 { top: 46%; right: -7px; width: 11px; animation-delay: -2.2s; }
.offer-spark.s6 { top: -7px; right: 30%; width: 12px; animation-delay: -.3s; }
@keyframes offer-twinkle { 0%, 100% { opacity: 0; transform: scale(.4) rotate(0deg); } 45% { opacity: 1; transform: scale(1.1) rotate(25deg); } 70% { opacity: .6; transform: scale(.8) rotate(40deg); } }

.offer-pop-x {
  position: absolute; z-index: 4; top: 10px; right: 10px; width: 42px; height: 42px; padding: 0;
  display: grid; place-items: center; border: 0; border-radius: 50%; cursor: pointer;
  background: rgba(255, 255, 255, .95); color: var(--navy); font-size: 1.7rem; line-height: 1;
  box-shadow: 0 4px 14px rgba(0, 0, 0, .22);
}
.offer-pop-x:hover { background: #fff; color: var(--blue); }
.offer-pop-x:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }

/* the poster: a button — a tap shows it full size (.offer-zoom) */
.offer-pop-media {
  position: relative; display: flex; justify-content: center; width: 100%; margin: 0; padding: 0; border: 0; font: inherit; cursor: default;
  background: rgba(var(--gold-rgb), .14); border-radius: 22px 22px 0 0; overflow: hidden;
}
.offer-pop-media:focus-visible { outline: 3px solid var(--gold); outline-offset: -3px; }
.offer-pop-zoom-chip {
  position: absolute; right: 8px; bottom: 8px; display: none; align-items: center; gap: 5px; padding: 5px 10px 5px 8px;
  border-radius: 99px; background: rgba(0, 0, 0, .66); color: #fff; font-size: .78rem; font-weight: 700; line-height: 1.2;
}
.offer-pop-zoom-chip .ic { width: 1em; height: 1em; }
.offer-zoom { position: fixed; inset: 0; z-index: 5; display: grid; place-items: center; padding: 12px; background: rgba(0, 0, 0, .9); overflow: auto; cursor: zoom-out; }
.offer-zoom[hidden] { display: none; }
.offer-zoom img { display: block; width: auto; max-width: 100%; height: auto; max-height: calc(100vh - 24px); max-height: calc(100dvh - 24px); border-radius: 10px; }
.offer-zoom .offer-pop-x { position: fixed; top: 12px; right: 12px; }
.offer-zoom-hint { display: none; position: fixed; left: 50%; bottom: 14px; transform: translateX(-50%); width: max-content; max-width: calc(100% - 24px); margin: 0;
  padding: 6px 12px; border-radius: 99px; background: rgba(255, 255, 255, .92); color: var(--navy-900); font-size: .8rem; font-weight: 600; text-align: center; }
@media (hover: none) { .offer-zoom-hint { display: block; } }
.offer-pop-media img {
  display: block; width: auto; max-width: 100%; height: auto; object-fit: contain;
  max-height: clamp(150px, calc(100vh - 540px), 440px); max-height: clamp(150px, calc(100dvh - 540px), 440px);   /* the words below fit too */
}

.offer-pop-body { padding: 20px 22px 22px; text-align: center; }
.offer-pop:not(.has-pic) .offer-pop-body { padding-top: 30px; }
.offer-pop-eyebrow { margin: 0; font-size: .78rem; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: var(--gold-600); }
.offer-pop-eyebrow [lang="bn"] { font-family: "Noto Serif Bengali", var(--f-body); letter-spacing: .02em; text-transform: none; font-size: .9rem; }
.offer-pop-body h2 { margin: 6px 0 12px; font-family: var(--f-display); font-size: clamp(1.4rem, 4.6vw, 1.85rem); line-height: 1.2; color: var(--navy); }
.offer-pop-body h2[lang="bn"] { font-family: "Noto Serif Bengali", var(--f-display); }

.offer-pop-price { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 6px 12px; margin: 0 0 12px; }
.offer-pop-price strong {
  display: inline-block; padding: .08em .5em; border-radius: 14px;
  font-family: var(--f-display); font-size: clamp(2rem, 8vw, 2.6rem); line-height: 1.15; letter-spacing: .04em;
  color: #FFFFFF; background: linear-gradient(135deg, var(--blue), var(--navy-700));
  box-shadow: 0 0 0 3px #fff, 0 0 0 4.5px var(--gold), 0 10px 26px rgba(var(--navy-rgb), .3);
  transform: rotate(-3deg); opacity: 0;
}
.offer-pop.is-open .offer-pop-price strong { animation: offer-stamp .6s .45s cubic-bezier(.3, 1.6, .4, 1) forwards, offer-pulse 2.4s 1.4s ease-in-out infinite; }
.offer-pop-price strong::after {                     /* a gold ring that breathes out from the FREE stamp */
  content: ""; position: absolute; inset: -7px; border-radius: 18px; border: 2px solid var(--gold); opacity: 0; pointer-events: none;
}
.offer-pop-price strong { position: relative; }
@keyframes offer-ring { 0% { opacity: .9; transform: scale(.96); } 100% { opacity: 0; transform: scale(1.14); } }
@keyframes offer-stamp { 0% { opacity: 0; transform: rotate(-3deg) scale(2.2); } 100% { opacity: 1; transform: rotate(-3deg) scale(1); } }
@keyframes offer-pulse { 0%, 100% { opacity: 1; transform: rotate(-3deg) scale(1); } 50% { opacity: 1; transform: rotate(-3deg) scale(1.06); } }
.offer-pop-price s { font-size: 1.15rem; font-weight: 700; color: var(--muted); text-decoration-thickness: 2px; text-decoration-color: var(--bad); }
.offer-pop-price em { font-style: normal; font-size: .85rem; font-weight: 700; padding: 3px 10px; border-radius: 99px; background: var(--ok-50); color: var(--ok); }

.offer-pop-text { margin: 0 0 8px; font-size: 1.02rem; font-weight: 600; color: var(--ink); line-height: 1.45; }
.offer-pop-text[lang="bn"] { font-family: "Noto Serif Bengali", var(--f-body); }
.offer-pop-note { margin: 0 0 12px; font-size: .92rem; color: var(--muted); line-height: 1.45; }
/* computers: "Offer till …" as one line; phones: "58 days left · ৫৮ দিন বাকি" in a gold box (3b) */
.offer-pop-left { position: relative; margin: 0 0 8px; }
.offer-pop-left[hidden] { display: none; }
.offer-left-en, .offer-left-bn { display: none; }
.offer-pop-until { display: block; font-size: .95rem; color: var(--ink); }
.offer-pop-until strong { color: var(--blue); }

.offer-pop-count { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; max-width: 320px; margin: 0 auto 16px; }
.offer-pop-count span { display: flex; flex-direction: column; align-items: center; padding: 8px 4px 6px; border-radius: 12px; background: var(--navy); color: #fff; }
.offer-pop-count b { font-family: var(--f-display); font-size: 1.45rem; line-height: 1.1; font-variant-numeric: tabular-nums; }
.offer-pop-count small { margin-top: 2px; font-size: .68rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--gold-100); }
.offer-pop-ended { margin: 0 0 14px; font-weight: 700; color: var(--bad); }

/* the buttons stay in view at the bottom of the card while the rest scrolls (a tall poster on a phone) */
.offer-pop-cta {
  position: sticky; bottom: 0; z-index: 1; display: flex; flex-wrap: wrap; justify-content: center; gap: 10px;
  margin: 0 -22px -22px; padding: 14px 22px 18px; background: linear-gradient(to bottom, rgba(255, 255, 255, 0), var(--ivory) 32%);
}
.offer-pop-cta .btn { flex: 1 1 160px; min-height: 48px; }
.offer-pop-cta .btn-gold { position: relative; overflow: hidden; }
.offer-pop-cta .btn-gold::after {
  content: ""; position: absolute; top: 0; bottom: 0; left: 0; width: 40%; pointer-events: none;
  background: linear-gradient(100deg, transparent, rgba(255, 255, 255, .6), transparent);
  transform: translateX(-150%); animation: offer-btn 3.2s 1.6s ease-in-out infinite;
}
@keyframes offer-btn { 0% { transform: translateX(-150%); } 35%, 100% { transform: translateX(320%); } }
.offer-pop-preview { margin: 0; padding: 10px 16px; border-radius: 0 0 22px 22px; background: var(--navy-900); color: #fff; font-size: .85rem; text-align: center; }

/* ---------- 2. The offer on the affiliation pages (home, Affiliation, Apply) ---------- */
.offer-flag {
  display: inline-flex; align-items: center; gap: 6px; margin: 0 0 8px; padding: 4px 12px; border-radius: 99px;
  font-size: .82rem; font-weight: 700; background: var(--blue); color: #fff; box-shadow: 0 0 0 2px rgba(var(--gold-rgb), .7);
}
.offer-flag::before { content: "\2605"; color: #FFE08A; }
.offer-was { margin-left: 8px; font-size: .55em; font-weight: 700; opacity: .75; text-decoration: line-through; text-decoration-thickness: 2px; }
.offer-until { display: block; margin-top: 4px; font-size: .86rem; font-weight: 600; }
.fee-card.is-offer { box-shadow: 0 0 0 2px var(--gold), var(--shadow); }
.fee-card .offer-flag { position: relative; z-index: 1; background: rgba(255, 255, 255, .16); box-shadow: 0 0 0 1.5px rgba(255, 224, 138, .8); }
.pay-card .offer-flag { margin: 8px 0 0; }
.offer-free-card {
  position: relative; padding: 22px; border-radius: 18px; text-align: center; overflow: hidden;
  background: linear-gradient(160deg, #FFFFFF, var(--ivory)); border: 1.5px solid var(--gold); box-shadow: var(--shadow);
}
.offer-free-card p { margin: 10px auto 0; max-width: 56ch; color: var(--ink); }
.offer-free-card .offer-until { color: var(--blue); }
.offer-free-price { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 6px 12px; margin-top: 6px; }
.offer-free-price strong { font-family: var(--f-display); font-size: 2.4rem; line-height: 1.1; color: var(--blue); letter-spacing: .04em; }
.offer-free-price s { font-size: 1.1rem; font-weight: 700; color: var(--muted); text-decoration-color: var(--bad); text-decoration-thickness: 2px; }

/* ---------- 3a. Computers and big tablets: the poster big on the left, the words on the right ---------- */
@media (min-width: 900px) and (min-height: 561px) {
  .offer-pop.has-pic .offer-pop-card { width: min(1060px, 100%); }
  .offer-pop.has-pic .offer-pop-scroll { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); align-items: center; }
  .offer-pop.has-pic .offer-pop-media { border-radius: 22px 0 0 22px; align-self: stretch; align-items: center; }
  .offer-pop.has-pic .offer-pop-media img { width: 100%; max-height: calc(100vh - 34px); max-height: calc(100dvh - 34px); }
  .offer-pop.has-pic .offer-pop-body { padding: 26px 26px 22px; }
  .offer-pop.has-pic .offer-pop-body h2 { margin-right: 40px; }
  .offer-pop.has-pic .offer-pop-cta { margin: 0 -26px -22px; padding: 14px 26px 18px; }
}

/* ---------- 3p. Phones (upright or sideways) — Rahul 2026-11-03: computers keep the pop-up as it was ----------
   The poster opens full size on a tap ("See it big"), the FREE stamp breathes a gold ring, the days left stand
   in a gold box, the countdown boxes get a gold edge, the shade is lighter so the website shows behind. */
@media (orientation: portrait) and (max-width: 600px), (orientation: landscape) and (max-height: 560px) {
  .offer-pop-shade { background: rgba(var(--navy-900-rgb), .55); }
  .offer-pop-media { cursor: zoom-in; }
  .offer-pop-zoom-chip { display: inline-flex; }
  .offer-pop.is-open .offer-pop-price strong::after { animation: offer-ring 2.4s 1.4s ease-out infinite; }
  .offer-pop-left {
    display: flex; flex-wrap: wrap; align-items: baseline; justify-content: center; gap: 0 14px;
    max-width: 360px; margin: 0 auto 12px; padding: 7px 14px 8px; border-radius: 14px; color: var(--navy-900);
    background: linear-gradient(135deg, #FFF6D6 0%, #FFE08A 55%, #F7C948 100%); border: 1.5px solid var(--gold);
    box-shadow: 0 8px 20px rgba(var(--gold-rgb), .35);
  }
  .offer-pop-left::after { content: ""; position: absolute; inset: -5px; border-radius: 18px; border: 2px solid var(--gold); opacity: 0; pointer-events: none; }
  .offer-pop.is-open .offer-pop-left::after { animation: offer-ring 2.4s 2.6s ease-out infinite; }
  .offer-left-en { display: inline; font-size: 1rem; font-weight: 800; letter-spacing: .05em; text-transform: uppercase; }
  .offer-left-bn { display: inline; font-size: 1rem; font-weight: 700; }
  .offer-pop-left b { font-family: var(--f-display); font-size: 1.75rem; line-height: 1; color: var(--blue); }
  .offer-pop-until { flex-basis: 100%; margin-top: 2px; font-size: .84rem; font-weight: 600; }
  .offer-pop-count span { background: linear-gradient(180deg, var(--navy-700), var(--navy)); box-shadow: inset 0 0 0 1px rgba(var(--gold-rgb), .55); }
}

/* ---------- 3b. Phones held upright: a smaller card (the website shows around it), no scrolling ----------
   The poster says what the offer is, so with a poster only the fee, the days left, the countdown and the
   buttons are shown under it (the name stays for screen readers). */
@media (orientation: portrait) and (max-width: 600px) {
  .offer-pop { padding: 6vh 18px; padding: 6dvh 18px; }
  .offer-pop-card { width: min(400px, 100%); max-height: 88vh; max-height: 88dvh; }
  .offer-pop.has-pic .offer-pop-eyebrow, .offer-pop.has-pic .offer-pop-text, .offer-pop.has-pic .offer-pop-note { display: none; }
  .offer-pop.has-pic .offer-pop-body h2 { position: absolute; width: 1px; height: 1px; margin: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .offer-pop.has-pic .offer-pop-media img { width: 100%; max-height: calc(88vh - 330px); max-height: calc(88dvh - 330px); }
  .offer-pop-body { padding: 12px 14px 12px; }
  .offer-pop-price { margin-bottom: 10px; }
  .offer-pop-price strong { font-size: 2.3rem; }
  .offer-pop-left { margin-bottom: 10px; padding: 5px 10px 6px; }
  .offer-pop-left b { font-size: 1.55rem; }
  .offer-left-en, .offer-left-bn { font-size: .92rem; }
  .offer-pop-count { gap: 6px; margin-bottom: 2px; }
  .offer-pop-count span { padding: 5px 2px 4px; }
  .offer-pop-count b { font-size: 1.2rem; }
  .offer-pop-count small { font-size: .6rem; }
  .offer-pop-cta { position: static; gap: 2px; margin: 0; padding: 10px 0 0; background: none; }
  .offer-pop-cta .btn { flex-basis: 100%; }
  .offer-pop-cta .btn-gold { min-height: 46px; }
  .offer-pop-cta .btn-outline { --bd: transparent; --bg: transparent; min-height: 34px; padding: 4px; text-decoration: underline; text-underline-offset: 3px; }
}

/* ---------- 3. Phones held sideways: picture beside the words ---------- */
@media (orientation: landscape) and (max-height: 560px) {
  .offer-pop { padding: 10px; }
  .offer-pop-card { width: min(780px, 100%); max-height: calc(100vh - 20px); max-height: calc(100dvh - 20px); }
  .offer-pop.has-pic .offer-pop-scroll { display: grid; grid-template-columns: minmax(0, 42%) minmax(0, 1fr); align-items: start; }
  .offer-pop.has-pic .offer-pop-media { border-radius: 22px 0 0 22px; align-self: stretch; align-items: center; }
  .offer-pop.has-pic .offer-pop-media img { max-height: calc(100dvh - 20px); }
  .offer-pop-body { padding: 12px 18px 14px; }
  .offer-pop:not(.has-pic) .offer-pop-body { padding-top: 16px; }
  .offer-pop-eyebrow { font-size: .7rem; }
  .offer-pop-body h2 { margin: 2px 48px 6px; font-size: 1.2rem; }
  .offer-pop-price { margin-bottom: 6px; }
  .offer-pop-price strong { font-size: 1.6rem; }
  .offer-pop-text { margin-bottom: 4px; font-size: .9rem; line-height: 1.35; }
  .offer-pop-note { margin-bottom: 6px; font-size: .8rem; line-height: 1.35; }
  .offer-pop.has-pic .offer-pop-text, .offer-pop.has-pic .offer-pop-note { display: none; }
  .offer-pop-left { margin-bottom: 6px; padding: 3px 10px 4px; }
  .offer-pop-left b { font-size: 1.25rem; }
  .offer-left-en, .offer-left-bn { font-size: .82rem; }
  .offer-pop-until { font-size: .76rem; margin-top: 0; }
  .offer-pop-count { gap: 6px; max-width: 280px; margin-bottom: 0; }
  .offer-pop-count span { padding: 3px 4px; }
  .offer-pop-count b { font-size: 1rem; }
  .offer-pop-count small { font-size: .6rem; }
  .offer-pop-cta .btn { min-height: 40px; }
  .offer-pop-cta { margin: 0 -18px -14px; padding: 8px 18px 10px; }
}
@media (max-width: 380px) {
  .offer-pop-body { padding: 16px 16px 18px; }
  .offer-pop-cta { margin: 0 -16px -18px; padding: 12px 16px 16px; }
  .offer-pop-count { gap: 6px; }
  .offer-pop-count b { font-size: 1.2rem; }
}

/* ---------- 4. People who ask their device for less motion ---------- */
@media (prefers-reduced-motion: reduce) {
  .offer-pop-card, .offer-pop-price strong { opacity: 1; transform: none; }
  .offer-pop-price strong { transform: rotate(-3deg); }
  .offer-pop *, .offer-pop *::before, .offer-pop *::after, .offer-pop-card { animation: none !important; transition: none !important; }
  .offer-pop.is-open .offer-pop-card { opacity: 1; transform: none; }
  .offer-pop.is-open .offer-pop-price strong { opacity: 1; }
  .offer-spark { display: none; }
  .offer-pop-price strong::after, .offer-pop-left::after { display: none; }
}
