/* ================== TOPBAR (FIXED / IMMERSIVE) ================== */
.topbar {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  z-index: 999;
  isolation: isolate;

  padding-top: calc(env(safe-area-inset-top) + var(--header-h));
  transform: translate3d(0, calc(var(--header-h) * -1 * var(--hdr-p)), 0);
  will-change: transform;
}




.topbar::before {
  content: "";
  position: absolute;
  inset: 0;

  background:
    linear-gradient(
      to bottom,
      var(--statusbar-top-color) 0,
      var(--statusbar-top-color) var(--statusbar-top-line),
      rgba(5, 5, 5, 0.99) calc(env(safe-area-inset-top) + 4px),
      rgba(6, 6, 8, 0.94) calc(env(safe-area-inset-top) + 18px),
      rgba(8, 8, 11, 0.78) calc(env(safe-area-inset-top) + 40px),
      rgba(10, 10, 13, 0.48) calc(env(safe-area-inset-top) + 76px),
      rgba(11, 11, 13, 0.18) calc(env(safe-area-inset-top) + 110px),
      rgba(11, 11, 13, 0) calc(env(safe-area-inset-top) + 142px)
    ),
    linear-gradient(
      180deg,
      rgba(26, 26, 32, 0.88) 0%,
      rgba(16, 16, 20, 0.82) 48%,
      rgba(10, 10, 13, 0.86) 100%
    );

  backdrop-filter: saturate(180%) blur(var(--glass-blur));
  -webkit-backdrop-filter: saturate(180%) blur(var(--glass-blur));

  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.18);
  pointer-events: none;
  z-index: -1;
  transform: translateZ(0);
}

.topbar::after {
  content: none;
}

.topbar.hdr-sweep::after {
  opacity: 0;
  animation: none;
}

@keyframes hdrSweep {
  0%   { opacity: 0; transform: translate3d(-18px,0,0); }
  40%  { opacity: 1; }
  100% { opacity: 0; transform: translate3d(18px,0,0); }
}

/* ================== HEADER ================== */
.header {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;

  height: calc(var(--header-h) + env(safe-area-inset-top));
  padding-top: env(safe-area-inset-top);

  opacity: calc(1 - (var(--hdr-p) * 1.5));
  pointer-events: none;
  will-change: opacity;
}

.header__inner {
  pointer-events: auto;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 18px 14px;
}

@media (min-width: 900px) {
  .header__inner {
    padding: 14px 28px 16px;
  }
}

.logo__text {
  transform: translate3d(0,0,0) scale(calc(1 - (var(--hdr-p) * 0.08)));
  transform-origin: 50% 50%;
  will-change: transform;
}


.logo {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100%;
  padding: 2px 12px 0;
  flex: 0 1 auto;
}

.logo__img {
  display: block;
  height: 90px;
  width: auto;
  object-fit: contain;
  object-position: center;
}

@media (min-width: 900px) {
  .logo__img {
    height: 100px;
  }
}

@media (max-width: 899px) {
  .header .logo__img {
    filter: brightness(1.2);
  }
}


.menu-btn-placeholder {
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  display: block;
}

@media (min-width: 900px) {
  .menu-btn-placeholder {
    width: 48px;
    height: 48px;
    flex-basis: 48px;
  }
}

@media (max-width: 899px) {
  #menuBtn {
    position: relative;
    z-index: 2;
    overflow: hidden;
    margin-top: 3px;
    margin-left: 10px;
  }
  #menuBtn .menu-btn__line {
    position: absolute;
    left: 50%;
    z-index: 2;
    width: 18px;
    height: 2px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.92);
    box-shadow: 0 0 10px rgba(255, 255, 255, 0.06);
    transform-origin: 50% 50%;
    transition:
      transform 0.34s cubic-bezier(0.22, 1, 0.36, 1),
      opacity 0.20s ease,
      width 0.26s ease,
      background 0.22s ease;
    will-change: transform, opacity;
  }

  #menuBtn .menu-btn__line:nth-child(1) {
    top: 13px;
    transform: translate3d(-50%, 0, 0);
  }

  #menuBtn .menu-btn__line:nth-child(2) {
    top: 20px;
    transform: translate3d(-50%, 0, 0);
  }

  #menuBtn .menu-btn__line:nth-child(3) {
    top: 27px;
    transform: translate3d(-50%, 0, 0);
  }

  #menuBtn.is-active .menu-btn__line:nth-child(1) {
    transform: translate3d(-50%, 7px, 0) rotate(45deg);
  }

  #menuBtn.is-active .menu-btn__line:nth-child(2) {
    opacity: 0;
    transform: translate3d(-50%, 0, 0) scaleX(0.45);
  }

  #menuBtn.is-active .menu-btn__line:nth-child(3) {
    transform: translate3d(-50%, -7px, 0) rotate(-45deg);
  }

  #menuBtn:active {
    transform: scale(0.98);
  }
}



/* ================== TABS ================== */
.tabs-bar {
  min-height: var(--tabs-h);
  display: flex;
  align-items: center;
  padding: 4px 0 2px;
  position: relative;
  z-index: 1001;
}

/* ================== PAGE SYNC ================== */
.page {
  width: 100%;
  min-height: 100vh;
  padding-top: calc(env(safe-area-inset-top) + var(--header-h) + var(--tabs-h) + 10px);
  transform: translate3d(0, calc(var(--header-h) * -1 * var(--hdr-p)), 0);
  will-change: transform;
}



body::before {
  content: "";
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: calc(env(safe-area-inset-top) + 22px);
  background: linear-gradient(
    to bottom,
    var(--statusbar-top-color) 0,
    var(--statusbar-top-color) var(--statusbar-top-line),
    rgba(5, 5, 7, 0.92) calc(env(safe-area-inset-top) + 4px),
    rgba(8, 8, 11, 0.36) calc(env(safe-area-inset-top) + 14px),
    rgba(11, 11, 13, 0) calc(env(safe-area-inset-top) + 22px)
  );
  pointer-events: none;
  z-index: 998;
}

/* Mobile header action buttons: matching warm glass surfaces. */
@media (max-width: 899px) {
  #menuBtn,
  #cartBtn {
    width: 48px;
    height: 48px;
    flex: 0 0 48px;
    padding: 0;
    border-radius: 16px;
    border: 1px solid rgba(214, 180, 107, 0.32);
    border-top-color: rgba(235, 206, 142, 0.52);
    color: #e2c37f;
    background-image: linear-gradient(155deg, rgba(255, 243, 211, 0.10), transparent 55%);
    background-color: rgba(201, 162, 77, 0.065);
    box-shadow:
      inset 0 1px 0 rgba(255, 235, 170, 0.13),
      inset 0 -1px 0 rgba(255, 255, 255, 0.035);
    backdrop-filter: saturate(145%) blur(14px);
    -webkit-backdrop-filter: saturate(145%) blur(14px);
  }

  #cartBtn {
    border-color: rgba(214, 180, 107, 0.32);
    border-top-color: rgba(235, 206, 142, 0.52);
    background-image: linear-gradient(155deg, rgba(255, 243, 211, 0.10), transparent 55%);
    background-color: rgba(201, 162, 77, 0.065);
  }

  #menuBtn::before,
  #cartBtn::before {
    inset: 1px;
    background: linear-gradient(155deg, rgba(255, 243, 211, 0.055), transparent 55%);
    opacity: 1;
  }

  #menuBtn::after,
  #cartBtn::after {
    box-shadow: inset 0 0 0 1px rgba(230, 194, 121, 0.045);
  }

  #menuBtn .menu-btn__line {
    width: 20px;
    height: 2px;
    background: currentColor;
    box-shadow: none;
  }

  #menuBtn .menu-btn__line:nth-child(1) {
    top: calc(50% - 8px);
  }

  #menuBtn .menu-btn__line:nth-child(2) {
    top: calc(50% - 1px);
  }

  #menuBtn .menu-btn__line:nth-child(3) {
    top: calc(50% + 6px);
  }

  #cartBtn svg {
    width: 26px;
    height: 26px;
    filter: none;
    transform-origin: 50% 50%;
  }

  #menuBtn:active,
  #cartBtn:active {
    transform: none;
    border-color: rgba(225, 188, 99, 0.50);
    background-color: rgba(201, 162, 77, 0.16);
    box-shadow:
      inset 0 1px 0 rgba(255, 235, 170, 0.13),
      inset 0 -1px 0 rgba(255, 255, 255, 0.035);
  }

  #menuBtn.is-active {
    color: #f0d299;
    border-color: rgba(226, 191, 121, 0.48);
  }

  #menuBtn:focus-visible,
  #cartBtn:focus-visible {
    outline: 2px solid rgba(226, 191, 121, 0.80);
    outline-offset: 4px;
  }
}
