/* Floating pill tab bar — one bar at the bottom on mobile */

:root {
  --app-tab-bar-h: 52px;
  --app-tab-bar-pad: 6px;
  --app-tab-bar-bg: rgba(18, 18, 20, 0.55);
  --app-tab-bar-active-bg: rgba(255, 255, 255, 0.14);
  --app-tab-bar-active-fg: #ffffff;
  --app-tab-bar-idle: #ffffff;
}

@media (max-width: 768px) {
  html.has-bm-cabin .app-tab-bar:not(.app-tab-bar--cabin),
  body.has-bm-cabin .app-tab-bar:not(.app-tab-bar--cabin) {
    display: none !important;
  }

  body.has-app-tab-bar .header,
  body.has-app-tab-bar .mobile-menu-overlay,
  body.has-app-tab-bar .mobile-menu {
    display: none !important;
  }

  body.has-app-tab-bar {
    --mobile-brand-bar-h: 44px;
    --top-nav-clearance: calc(var(--mobile-brand-bar-h) + max(8px, env(safe-area-inset-top, 0px)));
    --bottom-nav-clearance: calc(12px + var(--app-tab-bar-h) + 16px + env(safe-area-inset-bottom, 0px));
  }

  body.has-app-tab-bar .mobile-brand-bar {
    display: flex;
  }

  body.has-app-tab-bar .main-container {
    padding-top: var(--top-nav-clearance) !important;
    padding-bottom: var(--bottom-nav-clearance) !important;
  }

  body.has-app-tab-bar .player-container {
    bottom: calc(var(--bottom-nav-clearance) + 8px);
  }

  html.has-bm-cabin .bm-shell,
  body.has-bm-cabin .bm-shell {
    padding-bottom: var(--bottom-nav-clearance) !important;
  }

  html.has-bm-cabin .app-more-sheet__panel,
  body.has-bm-cabin .app-more-sheet__panel {
    bottom: calc(12px + var(--app-tab-bar-h) + 12px + env(safe-area-inset-bottom, 0px));
  }
}

.app-tab-bar {
  display: none;
}

@media (max-width: 768px) {
  .app-tab-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 2px;
    position: fixed;
    left: 50%;
    bottom: calc(12px + env(safe-area-inset-bottom, 0px));
    transform: translateX(-50%);
    z-index: 220;
    width: calc(100vw - 24px);
    max-width: 480px;
    min-height: var(--app-tab-bar-h);
    padding: var(--app-tab-bar-pad);
    margin: 0;
    box-sizing: border-box;
    background: var(--app-tab-bar-bg);
    backdrop-filter: saturate(180%) blur(20px);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    border-radius: 999px;
    box-shadow: none;
    border: none;
  }

  .app-tab-bar__item {
    position: relative;
    flex: 1 1 0;
    min-width: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0;
    height: calc(var(--app-tab-bar-h) - var(--app-tab-bar-pad) * 2);
    min-height: calc(var(--app-tab-bar-h) - var(--app-tab-bar-pad) * 2);
    padding: 0 10px;
    border: none;
    border-radius: 999px;
    background: transparent;
    color: var(--app-tab-bar-idle);
    text-decoration: none;
    cursor: pointer;
    font-family: inherit;
    line-height: 1;
    overflow: hidden;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    box-sizing: border-box;
    transition:
      color 180ms ease,
      background-color 220ms cubic-bezier(0.22, 1, 0.36, 1),
      flex-grow 220ms cubic-bezier(0.22, 1, 0.36, 1),
      padding 220ms cubic-bezier(0.22, 1, 0.36, 1),
      gap 220ms cubic-bezier(0.22, 1, 0.36, 1);
  }

  .app-tab-bar__item.is-active {
    flex: 1.85 1 0;
    background: var(--app-tab-bar-active-bg);
    color: var(--app-tab-bar-active-fg);
    padding: 0 14px 0 12px;
    gap: 8px;
  }

  /* Cart badge sits outside the pill — don't clip it */
  .app-tab-bar__item:has(.app-tab-bar__cart-badge),
  #tabBarCartLink {
    overflow: visible;
  }

  .app-tab-bar__icon,
  .app-tab-bar__icon svg.lucide,
  .app-tab-bar__item > [data-lucide]:first-child {
    width: 22px;
    height: 22px;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    stroke-width: 1.75;
  }

  .app-tab-bar__item.is-active .app-tab-bar__icon svg.lucide,
  .app-tab-bar__item.is-active > [data-lucide]:first-child svg.lucide {
    stroke-width: 2;
    color: inherit;
  }

  .app-tab-bar__label {
    display: none;
    max-width: 0;
    opacity: 0;
    margin: 0;
    padding: 0;
    font-size: 14px;
    font-weight: 600;
    letter-spacing: -0.02em;
    line-height: 1;
    white-space: nowrap;
    overflow: hidden;
    transition:
      opacity 180ms ease,
      max-width 220ms cubic-bezier(0.22, 1, 0.36, 1);
  }

  .app-tab-bar__item.is-active .app-tab-bar__label {
    display: inline;
    max-width: 120px;
    opacity: 1;
  }
}

.app-more-sheet {
  display: none;
}

@media (max-width: 768px) {
  .app-more-sheet {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 320;
    pointer-events: none;
    visibility: hidden;
    opacity: 0;
    transition: opacity 200ms ease, visibility 200ms ease;
  }

  .app-more-sheet.is-open {
    pointer-events: auto;
    visibility: visible;
    opacity: 1;
  }

  .app-more-sheet__backdrop {
    position: absolute;
    inset: 0;
    border: none;
    padding: 0;
    margin: 0;
    background: rgba(0, 0, 0, 0.4);
    cursor: pointer;
  }

  .app-more-sheet__panel {
    position: absolute;
    left: 8px;
    right: 8px;
    bottom: calc(12px + var(--app-tab-bar-h) + 8px + env(safe-area-inset-bottom, 0px));
    display: flex;
    flex-direction: column;
    gap: 8px;
    transform: translateY(16px);
    transition: transform 260ms cubic-bezier(0.22, 1, 0.36, 1);
  }

  .app-more-sheet.is-open .app-more-sheet__panel {
    transform: translateY(0);
  }

  .app-more-sheet__group {
    background: var(--fill-elevated, #2c2c2e);
    border-radius: 14px;
    overflow: hidden;
  }

  .app-more-sheet__row {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    min-height: 52px;
    padding: 0 16px;
    border: none;
    background: transparent;
    color: var(--label-primary, var(--text));
    font-size: 17px;
    font-weight: 400;
    font-family: inherit;
    text-decoration: none;
    text-align: left;
    cursor: pointer;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
  }

  .app-more-sheet__row + .app-more-sheet__row {
    border-top: 0.33px solid color-mix(in srgb, var(--text) 10%, transparent);
  }

  .app-more-sheet__row:active {
    background: color-mix(in srgb, var(--text) 6%, transparent);
  }

  .app-more-sheet__row [data-lucide],
  .app-more-sheet__row svg.lucide {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    opacity: 0.9;
  }

  .app-more-sheet__row--lang {
    justify-content: flex-start;
  }

  .app-more-sheet__select {
    margin-left: auto;
    min-width: 108px;
    border: none;
    background: var(--fill-tertiary, #3a3a3c);
    color: var(--label-primary, var(--text));
    border-radius: 8px;
    padding: 6px 10px;
    font-size: 15px;
    font-family: inherit;
  }

  .app-more-sheet__cancel {
    width: 100%;
    min-height: 56px;
    border: none;
    border-radius: 14px;
    background: var(--fill-elevated, #2c2c2e);
    color: var(--system-blue, #0a84ff);
    font-size: 17px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
  }

  .app-more-sheet__cancel:active {
    background: color-mix(in srgb, var(--text) 6%, var(--fill-elevated));
  }

  body.app-more-open {
    overflow: hidden;
  }
}

/* Mobile top brand bar — logo centered */
.mobile-brand-bar {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1040;
  align-items: center;
  justify-content: center;
  height: calc(44px + env(safe-area-inset-top, 0px));
  padding-top: env(safe-area-inset-top, 0px);
  box-sizing: border-box;
  pointer-events: none;
  background: color-mix(in srgb, var(--bg, #0a0a0a) 72%, transparent);
  backdrop-filter: blur(16px) saturate(1.2);
  -webkit-backdrop-filter: blur(16px) saturate(1.2);
}

.mobile-brand-bar__link {
  pointer-events: auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 40px;
  max-width: min(120px, 50vw);
  padding: 0 6px;
  border-radius: 0;
  text-decoration: none;
}

.mobile-brand-bar__logo {
  width: auto;
  height: 22px;
  max-width: 100%;
  display: block;
  border-radius: 0;
  object-fit: contain;
}

@media (min-width: 769px) {
  .mobile-brand-bar {
    display: none !important;
  }
}
