/* Design is 1920px wide; 1rem = 10px at 1920 viewport, scales linearly with width */
html {
  font-size: calc(100vw / 192);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  background: #100403;
  font-family: "Lato", Arial, sans-serif;
  overflow-x: hidden;
}

img {
  display: block;
  max-width: 100%;
}

button {
  background: none;
  border: 0;
  cursor: pointer;
}

/* ---------- Page layers ---------- */
.page {
  position: relative;
  height: 277.4rem; /* body-bg height at 1920 */
  overflow: hidden;
}

.page__hero,
.page__bg {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
}

.page__content {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* ---------- Register CTA ---------- */
.btn-register {
  width: 36.7rem;
  margin-top: 56.6rem;
  transition: transform 0.2s, filter 0.2s;
}

.btn-register:hover {
  transform: scale(1.04);
  filter: brightness(1.1);
}

.section-title {
  width: 59.1rem;
}

/* ---------- Milestone ---------- */
.milestone,
.feature {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.milestone .section-title {
  margin-top: 2.5rem;
}

.milestone__info {
  position: relative;
  margin-top: 2rem;
}

.counter {
  position: relative;
  width: 37.4rem;
  height: 9.2rem;
  background: url("../images/counter-box.webp") center / 100% 100% no-repeat;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding-left: 12rem;
  padding-right: 1.5rem;
}

.counter__label {
  font-size: 1.4rem;
  font-weight: 700;
  color: #6b3a12;
  text-transform: uppercase;
  white-space: nowrap;
}

.counter__value {
  font-size: 3.8rem;
  font-weight: 900;
  line-height: 1.1;
  color: #8e0d0d;
}

.milestone__notice {
  position: absolute;
  top: 50%;
  left: calc(100% + 3.6rem);
  width: 32.7rem;
  transform: translateY(-50%);
}

.milestone__list {
  display: flex;
  align-items: flex-start;
  gap: 1.3rem;
  margin-top: 3.7rem;
}

.milestone-card {
  position: relative;
  width: 27rem;
  height: 68.8rem;
  background: var(--bg-pc) center top / 100% 100% no-repeat;
}

/* Even cards sit lower, zig-zag layout */
.milestone-card:nth-child(even) {
  margin-top: 6rem;
}

.milestone-card__slots {
  position: absolute;
  top: 9rem;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
}

.gift-slot {
  width: 12.4rem;
  height: 12.4rem;
  background: url("../images/gift-slot.webp") center / 100% 100% no-repeat;
}

/* Reward icon already includes its own frame, so it covers the slot */
.gift-slot__icon {
  width: 100%;
  height: 100%;
}

/* ---------- Feature carousel (layout shared with .milestone) ---------- */
.feature .section-title {
  margin-top: -2rem;
}

.carousel {
  position: relative;
  width: 192rem;
  height: 53.9rem;
  margin-top: 4rem;
}

.carousel__track {
  position: relative;
  height: 100%;
}

.carousel__slide {
  position: absolute;
  top: 0;
  left: 50%;
  width: 80.5rem;
  height: 53.9rem;
  margin-left: -40.25rem;
  opacity: 0;
  transform: scale(0.79);
  transition: transform 0.5s, opacity 0.5s, filter 0.5s;
  pointer-events: none;
}

.carousel__slide.is-active {
  opacity: 1;
  transform: none;
  z-index: 2;
}

.carousel__slide.is-prev,
.carousel__slide.is-next {
  opacity: 1;
  filter: brightness(0.45);
  z-index: 1;
}

.carousel__slide.is-prev {
  transform: translateX(-37.9rem) scale(0.79);
}

.carousel__slide.is-next {
  transform: translateX(37.9rem) scale(0.79);
}

.carousel__nav {
  position: absolute;
  top: 50%;
  z-index: 3;
  width: 9.1rem;
  transform: translateY(-50%);
  transition: filter 0.2s;
}

.carousel__nav:hover {
  filter: brightness(1.3);
}

.carousel__nav--prev {
  left: calc(50% - 52.4rem - 4.55rem);
}

.carousel__nav--next {
  left: calc(50% + 52.4rem - 4.55rem);
}

.carousel__dots {
  position: absolute;
  top: calc(100% + 2.5rem);
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 0.6rem;
}

.carousel__dot {
  width: 1.8rem;
  height: 1.8rem;
  background: url("../images/dot.webp") center / 100% 100% no-repeat;
}

.carousel__dot.is-active {
  background-image: url("../images/dot-active.webp");
}

/* ---------- Footer ---------- */
.footer {
  background: #5c0000;
}

.footer img {
  width: 100%;
}

/* ---------- Mobile layout ----------
   Design width 393px (assets are 3x = 1179px); 1rem = 10px at 393 viewport.
   Images swap to mobile versions via <picture> sources in index.html. */
@media (max-width: 767px) {
  html {
    font-size: calc(100vw / 39.3);
  }

  .page {
    height: 168.6rem; /* mb-body-bg height at 393 */
  }

  .btn-register {
    width: 17.9rem;
    margin-top: 57rem;
  }

  .section-title {
    width: 37.7rem;
  }

  .milestone .section-title {
    margin-top: 1rem;
  }

  /* Mobile mockup has no counter/notice row */
  .milestone__info {
    display: none;
  }

  .milestone__list {
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.5rem 1.4rem;
    max-width: 32rem;
    margin-top: 0.5rem;
  }

  .milestone-card {
    width: 9.6rem;
    height: 24.2rem;
    background-image: var(--bg-mb);
  }

  .milestone-card:nth-child(even) {
    margin-top: 0;
  }

  .milestone-card__slots {
    top: 3.1rem;
    gap: 0.45rem;
  }

  /* Reward icon includes its own frame, so no slot background needed */
  .gift-slot {
    width: 4.4rem;
    height: 4.4rem;
    background: none;
  }

  .feature .section-title {
    margin-top: 1rem;
  }

  .carousel {
    width: 39.3rem;
    height: 17.4rem;
    margin-top: 2.7rem;
  }

  .carousel__slide {
    width: 26rem;
    height: 17.4rem;
    margin-left: -13rem;
  }

  .carousel__slide.is-prev {
    transform: translateX(-9.4rem) scale(0.79);
  }

  .carousel__slide.is-next {
    transform: translateX(9.4rem) scale(0.79);
  }

  .carousel__nav {
    width: 2.8rem;
  }

  .carousel__nav--prev {
    left: 1.5rem;
  }

  .carousel__nav--next {
    left: auto;
    right: 1.5rem;
  }

  .carousel__dots {
    top: calc(100% + 1.8rem);
    gap: 0.5rem;
  }

  .carousel__dot {
    width: 1rem;
    height: 1rem;
    background-image: url("../images/mb-dot.webp");
  }

  .carousel__dot.is-active {
    background-image: url("../images/mb-dot-active.webp");
  }
}

/* ---------- Sticky side bar ----------
   Inner sizes use cqw (% of bar width) so PC and mobile share one layout. */
.sticky-bar {
  container-type: inline-size; /* cqw inside resolve against bar width */
  position: fixed;
  top: 50%;
  right: 2rem;
  z-index: 50;
  width: 16rem;
  transform: translateY(-50%);
  transition: transform 0.3s;
}

.sticky-bar__inner {
  aspect-ratio: 540 / 1029;
  padding-top: 5cqw;
  background: url("../images/sticky-bg.webp") center / 100% 100% no-repeat;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5cqw;
}

.sticky-bar__btn {
  display: block;
  width: 90cqw;
  aspect-ratio: 501 / 174;
  background: center / 100% 100% no-repeat;
  transition: filter 0.2s, transform 0.2s;
}

.sticky-bar__btn--download {
  aspect-ratio: 501 / 189;
  margin-bottom: 3cqw;
  background-image: url("../images/sticky-btn-download.webp");
}

.sticky-bar__btn--home {
  background-image: url("../images/sticky-btn-home.webp");
}

.sticky-bar__btn--topup {
  background-image: url("../images/sticky-btn-topup.webp");
}

.sticky-bar__btn--community {
  background-image: url("../images/sticky-btn-community.webp");
}

.sticky-bar__btn--fanpage {
  background-image: url("../images/sticky-btn-fanpage.webp");
}

.sticky-bar__top {
  width: 28cqw;
  aspect-ratio: 137 / 120;
  margin-top: 0;
  background: url("../images/sticky-btn-top.webp") center / 100% 100% no-repeat;
  transition: transform 0.2s;
}

.sticky-bar__btn:hover {
  filter: brightness(1.15);
  transform: scale(1.04);
}

.sticky-bar__top:hover {
  transform: translateY(-0.4rem);
}

/* Toggle tab only used on mobile */
.sticky-bar__toggle {
  display: none;
}

@media (max-width: 767px) {
  .sticky-bar {
    right: 0;
    width: 9rem;
  }

  /* Collapsed: slide bar off-screen, keep the toggle tab visible */
  .sticky-bar.is-collapsed {
    transform: translate(100%, -50%);
  }

  .sticky-bar__toggle {
    display: block;
    position: absolute;
    top: 50%;
    right: 90%;
    z-index: -1; /* tucked behind the bar background */
    width: 2.2rem;
    height: 5rem;
    border-radius: 0.8rem 0 0 0.8rem;
    background: linear-gradient(#f39a3c, #c9561c);
    border: 0.1rem solid #f6d27a;
    border-right: 0;
    transform: translateY(-50%);
  }

  /* Collapsed: tab sits fully outside the bar so it stays on-screen */
  .sticky-bar.is-collapsed .sticky-bar__toggle {
    right: 100%;
  }

  /* Chevron: points right (collapse) when open, left (expand) when collapsed */
  .sticky-bar__toggle::before {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0.7rem;
    height: 0.7rem;
    border-top: 0.2rem solid #fff;
    border-right: 0.2rem solid #fff;
    transform: translate(-65%, -50%) rotate(45deg);
  }

  .sticky-bar.is-collapsed .sticky-bar__toggle::before {
    transform: translate(-35%, -50%) rotate(-135deg);
  }
}

/* ---------- Popups (register / login / success) ----------
   Inner sizes use cqw (1cqw = 1% of dialog width) so the layout keeps
   the design proportions at any dialog size. */
body.is-popup-open {
  overflow: hidden;
}

.popup {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.7);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s, visibility 0.25s;
}

.popup.is-open {
  opacity: 1;
  visibility: visible;
}

.popup__dialog {
  container-type: inline-size;
  position: relative;
  width: 100rem;
  aspect-ratio: 1484 / 812;
  background: url("../images/popup-register-bg.webp") center / 100% 100% no-repeat;
  transform: scale(0.9);
  transition: transform 0.25s;
}

.popup--login .popup__dialog {
  background-image: url("../images/popup-login-bg.webp");
}

.popup.is-open .popup__dialog {
  transform: none;
}

.popup__close {
  position: absolute;
  top: -2cqw;
  right: -3.5cqw;
  width: 8cqw;
  aspect-ratio: 100 / 106;
  background: url("../images/popup-btn-close.webp") center / 100% 100% no-repeat;
  transition: filter 0.2s, transform 0.2s;
}

.popup__close:hover {
  filter: brightness(1.2);
  transform: rotate(45deg);
}

.popup__body {
  position: absolute;
  inset: 8.9cqw 9.4cqw 0 19.3cqw;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.popup--login .popup__body {
  top: 10.4cqw;
}

.popup--success .popup__body {
  inset: 9.3cqw 9cqw 0 16cqw;
}

/* ---------- Popup form ---------- */
.popup-form {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.7cqw;
}

.popup-form__row {
  width: 100%;
  display: flex;
  align-items: center;
}

.popup-form__label {
  flex: 0 0 18.9cqw;
  font-size: 2.4cqw;
  font-weight: 700;
  color: #000;
  white-space: nowrap;
}

.popup-form__input {
  flex: 1;
  min-width: 0;
  height: 4.6cqw;
  padding: 0 1.4cqw;
  border: 0.1cqw solid transparent;
  border-radius: 0.6cqw;
  background: #fff;
  font-family: inherit;
  font-size: 1.6cqw;
  color: #222;
  outline: none;
}

.popup-form__input::placeholder {
  color: #9a9a9a;
}

.popup-form__input:focus {
  border-color: #d08a2c;
}

.popup-form__input.is-invalid {
  border-color: #e60000;
}

/* Fixed-height slot so messages don't shift the layout */
.popup-form__message {
  height: 2cqw;
  margin: -0.7cqw 0;
  font-size: 1.4cqw;
  line-height: 2cqw;
  font-weight: 700;
  color: #e60000;
  text-align: center;
}

.popup-form__message.is-success {
  color: #1a7a1a;
}

.popup__btn-submit {
  width: 25cqw;
  aspect-ratio: 744 / 216;
  background: url("../images/popup-btn-register.webp") center / 100% 100% no-repeat;
  transition: filter 0.2s, transform 0.2s;
}

.popup--login .popup__btn-submit {
  background-image: url("../images/popup-btn-login.webp");
}

.popup__socials {
  display: flex;
  gap: 2.4cqw;
  margin-top: 1.3cqw;
}

.popup__btn-social {
  display: block;
  width: 18cqw;
  aspect-ratio: 570 / 171;
  background: center / 100% 100% no-repeat;
  transition: filter 0.2s, transform 0.2s;
}

.popup__btn-social--group {
  background-image: url("../images/popup-btn-group.webp");
}

.popup__btn-social--fanpage {
  background-image: url("../images/popup-btn-fanpage.webp");
}

.popup__btn-submit:hover,
.popup__btn-social:hover {
  filter: brightness(1.1);
  transform: scale(1.04);
}

.popup__switch {
  margin-top: 2.8cqw;
  font-size: 2.4cqw;
  font-weight: 700;
  color: #000;
  text-align: center;
}

.popup__switch-link {
  font: inherit;
  color: #e60000;
}

.popup__switch-link:hover {
  text-decoration: underline;
}

/* ---------- Success popup ---------- */
.popup__title {
  font-size: 3.6cqw;
  line-height: 5.2cqw;
  font-weight: 700;
  color: #000;
  text-align: center;
}

.popup__title--red {
  color: #ca0000;
}

.popup__giftcode {
  position: relative;
  width: 39cqw;
  aspect-ratio: 1233 / 150;
  margin-top: 2cqw;
  background: url("../images/popup-giftcode-bar.webp") center / 100% 100% no-repeat;
  font-family: inherit;
  font-size: 3.2cqw;
  font-weight: 700;
  color: #fff;
}

.popup--success .popup__socials {
  margin-top: 2.6cqw;
}

/* "Copied" feedback, positioned so it doesn't shift the layout */
.popup__giftcode.is-copied::after {
  content: "Đã sao chép!";
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  font-size: 1.4cqw;
  color: #1a7a1a;
  white-space: nowrap;
}

.mb-only {
  display: none;
}

/* Mobile popups: portrait backgrounds and their own proportions */
@media (max-width: 767px) {
  .popup__dialog {
    width: 92vw;
    max-width: 480px;
    aspect-ratio: 1047 / 1248;
    background-image: url("../images/mb-popup-register-bg.webp");
  }

  .popup--login .popup__dialog {
    background-image: url("../images/mb-popup-login-bg.webp");
  }

  .popup__close {
    top: -3cqw;
    right: -5cqw;
    width: 14cqw;
  }

  .popup__body,
  .popup--login .popup__body {
    inset: 21.3cqw 8cqw 0 18.4cqw;
  }

  .popup--success .popup__body {
    top: 24.8cqw;
  }

  .popup-form {
    gap: 4.2cqw;
  }

  .popup-form__label {
    flex-basis: 26.3cqw;
    font-size: 3.3cqw;
  }

  .popup-form__input {
    height: 6.1cqw;
    padding: 0 2cqw;
    border-radius: 1cqw;
    font-size: 3cqw;
  }

  .popup-form__message {
    height: 6.3cqw;
    margin: -4.2cqw 0;
    font-size: 2.8cqw;
    line-height: 6.3cqw;
  }

  .popup__btn-submit {
    width: 42.7cqw;
    aspect-ratio: 450 / 132;
    background-image: url("../images/mb-popup-btn-register.webp");
  }

  .popup--login .popup__btn-submit {
    background-image: url("../images/mb-popup-btn-login.webp");
  }

  .popup__socials {
    gap: 4cqw;
    margin-top: 1.6cqw;
  }

  .popup__btn-social {
    width: 30cqw;
  }

  .popup__btn-social--group {
    aspect-ratio: 330 / 99;
    background-image: url("../images/mb-popup-btn-group.webp");
  }

  .popup__btn-social--fanpage {
    aspect-ratio: 339 / 102;
    background-image: url("../images/mb-popup-btn-fanpage.webp");
  }

  .popup__switch {
    margin-top: 4.5cqw;
    font-size: 3.6cqw;
  }

  /* Mobile login mockup: switch text sits above the social buttons */
  .popup--login .popup__switch {
    order: 1;
    margin-top: 4.7cqw;
  }

  .popup--login .popup__socials {
    order: 2;
    margin-top: 5.5cqw;
  }

  .popup__title {
    font-size: 5.5cqw;
    line-height: 9cqw;
  }

  .popup__title--red {
    color: #ed0000;
  }

  .popup__giftcode {
    width: 71cqw;
    aspect-ratio: 765 / 93;
    margin-top: 1.5cqw;
    background-image: url("../images/mb-popup-giftcode-bar.webp");
    font-size: 5.5cqw;
  }

  .popup__giftcode.is-copied::after {
    font-size: 3cqw;
  }

  .popup--success .popup__socials {
    margin-top: 3.8cqw;
  }

  .mb-only {
    display: inline;
  }
}

/* Elements toggled with the hidden attribute (counter block, gift block) must
   win over the display rules above. */
[hidden] {
  display: none !important;
}
