/* Copyright 2025-2026 Renofy Ltd. All rights reserved. */
/* iOS App Install Promo Bar (RENO-920)
   Mobile-only banner shown on iOS devices to promote the native app.
   Visibility gated by `html.app-install-bar-active` class set in base.html. */

.app-install-bar {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: calc(var(--z-index-header) + 1);
  height: calc(var(--height-app-install-bar) + env(safe-area-inset-top, 0px));
  /* Tighter left padding to optically balance the centred X glyph against
     the right-aligned OPEN pill (whose background reaches its padding edge). */
  padding: env(safe-area-inset-top, 0px) 0.75rem 0 0.25rem;
  align-items: center;
  gap: 0.625rem;
  background: var(--color-white);
  border-bottom: 1px solid var(--color-border);
}

.app-install-bar__dismiss {
  flex-shrink: 0;
  position: relative;
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: none;
  color: var(--color-text-secondary);
  border-radius: 50%;
  cursor: pointer;
  padding: 0;
  /* Cancel the X glyph's right centring offset so the next element sits a
     uniform gap from the glyph, not from the button's invisible edge.
     Derived from: (button 32px − icon 18px) / 2 = 7px dead space on the right. */
  margin-right: -7px;
  transition: background var(--transition-fast);
}

/* Extend the tap target to ~44×44 per Apple HIG without enlarging the
   visual circle. The pseudo-element's pointer events bubble to the button. */
.app-install-bar__dismiss::before {
  content: "";
  position: absolute;
  inset: -6px;
}

.app-install-bar__dismiss:hover,
.app-install-bar__dismiss:focus {
  background: var(--color-bg-light);
}

.app-install-bar__icon {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  border: 1px solid var(--color-border);
  border-radius: 9px;
  object-fit: cover;
  box-sizing: border-box;
}

.app-install-bar__text {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  line-height: 1.2;
  overflow: hidden;
}

.app-install-bar__title {
  /* Apple HIG spec: 15px. Can't use --font-size-sm (12px on mobile). */
  font-size: 15px;
  font-weight: var(--font-weight-semibold);
  color: var(--color-text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.app-install-bar__subtitle {
  /* Apple HIG spec: 12px. Matches --font-size-xs on desktop but not mobile. */
  font-size: 12px;
  font-weight: var(--font-weight-regular);
  color: var(--color-text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* iOS-blue capsule matching the App Store's GET/OPEN button styling. */
.app-install-bar__open {
  flex-shrink: 0;
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 30px;
  padding: 0 1rem;
  font-size: 14px;
  font-weight: var(--font-weight-semibold);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--color-white);
  text-decoration: none;
  background: var(--color-blue);
  border-radius: var(--radius-full);
  transition: opacity var(--transition-fast);
}

/* Extend tap target to ~44×44 per Apple HIG without enlarging the pill.
   Same pattern as .app-install-bar__dismiss above. */
.app-install-bar__open::before {
  content: "";
  position: absolute;
  inset: -7px -4px;
}

.app-install-bar__open:active {
  opacity: 0.7;
}

/* === Activation: only show on mobile when JS has detected iOS + not dismissed === */
@media (max-width: 820px) {
  html.app-install-bar-active .app-install-bar {
    display: flex;
  }

  /* Push the fixed mobile header below the promo bar */
  html.app-install-bar-active .header__mobile-top {
    top: var(--height-app-install-bar);
  }

  /* Push main content below promo bar + header. The existing
     `.section--bleed-under-header` rule (margin-top: -var(--height-header))
     still works correctly — it pulls the hero up under the header but not
     under the opaque promo bar, which is the desired behaviour. */
  html.app-install-bar-active main {
    margin-top: calc(var(--height-header) + var(--height-app-install-bar) + env(safe-area-inset-top, 0px));
  }

  /* AI chat widget sizes itself with 100dvh math (see chat_widget.css), so the
     `main` margin-top above is not enough — we also need to shrink its height
     by the bar's height, otherwise the input bar is pushed below the viewport. */
  html.app-install-bar-active .chat-widget {
    height: calc(100dvh - var(--height-header) - var(--height-app-install-bar) - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
  }
}
