/* ============================================
   PWA Install — banner + guide overlay
   Cowch dark-brutalism, coral accent
   ============================================ */

/* ---------- Banner ---------- */
.cowch-install-banner {
  position: fixed;
  left: 0;
  right: 0;
  bottom: calc(var(--tab-bar-height, 80px) + env(safe-area-inset-bottom, 0px) + var(--space-md, 16px));
  z-index: 9998;
  padding: 0 var(--space-md, 16px);
  pointer-events: none;
  transform: translateY(140%);
  opacity: 0;
  transition: transform var(--transition-smooth, 0.3s cubic-bezier(0.4, 0, 0.2, 1)),
              opacity var(--transition-smooth, 0.3s cubic-bezier(0.4, 0, 0.2, 1));
}
.cowch-install-banner.is-visible {
  transform: translateY(0);
  opacity: 1;
}

.cowch-install-banner__inner {
  pointer-events: auto;
  max-width: 460px;
  margin: 0 auto;
  background: var(--bg-card, #2d2825);
  border: var(--border-thin, 2px) solid var(--coral, #D4896A);
  border-radius: var(--radius-medium, 24px);
  padding: 12px 12px 12px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  box-shadow: 6px 6px 0 0 var(--bg-dark, #0D0B09), 0 8px 24px rgba(0, 0, 0, 0.5);
  font-family: var(--font-family);
}

.cowch-install-banner__left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.cowch-install-banner__icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-xs, 8px);
  background: var(--bg-elevated, #3a3228);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  flex-shrink: 0;
}
.cowch-install-banner__icon img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.cowch-install-banner__icon-fallback {
  font-size: 26px;
  line-height: 1;
}

.cowch-install-banner__text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.cowch-install-banner__title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary, #F5F0E8);
  white-space: nowrap;
}
.cowch-install-banner__subtitle {
  font-size: 12px;
  color: var(--text-muted, #b0a499);
  white-space: nowrap;
}

.cowch-install-banner__actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.cowch-install-banner__cta {
  background: var(--coral, #D4896A);
  color: var(--text-on-coral, #1a1512);
  border: none;
  padding: 9px 18px;
  border-radius: var(--radius-xs, 8px);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  transition: background var(--transition-fast, 0.15s ease), transform 0.08s ease;
  touch-action: manipulation;
}
.cowch-install-banner__cta:hover { background: var(--coral-light, #E39B7F); }
.cowch-install-banner__cta:active { transform: scale(0.96); }

.cowch-install-banner__close {
  background: transparent;
  border: none;
  color: var(--text-muted, #b0a499);
  cursor: pointer;
  padding: 8px;
  border-radius: var(--radius-full);
  display: flex;
  transition: color var(--transition-fast, 0.15s ease), background var(--transition-fast, 0.15s ease);
  touch-action: manipulation;
}
.cowch-install-banner__close:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.06);
}

/* ---------- Overlay ---------- */
.cowch-install-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  font-family: var(--font-family);
  color: var(--text-primary);
  opacity: 0;
  transition: opacity var(--transition-smooth, 0.3s cubic-bezier(0.4, 0, 0.2, 1));
}
.cowch-install-overlay.is-visible { opacity: 1; }

.cowch-install-overlay__bg {
  position: absolute;
  inset: 0;
  background: rgba(13, 11, 9, 0.78);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.cowch-install-overlay__sheet {
  position: absolute;
  inset: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: calc(env(safe-area-inset-top, 0px) + 24px) 20px calc(env(safe-area-inset-bottom, 0px) + 24px);
  transform: translateY(16px);
  transition: transform var(--transition-smooth, 0.3s cubic-bezier(0.4, 0, 0.2, 1));
}
.cowch-install-overlay.is-visible .cowch-install-overlay__sheet {
  transform: translateY(0);
}

.cowch-install-overlay__close {
  position: fixed;
  top: calc(env(safe-area-inset-top, 0px) + 14px);
  right: 14px;
  background: rgba(255, 255, 255, 0.08);
  border: none;
  color: var(--text-primary);
  width: 40px;
  height: 40px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 1;
  transition: background var(--transition-fast);
  touch-action: manipulation;
}
.cowch-install-overlay__close:hover {
  background: rgba(255, 255, 255, 0.14);
}

/* ---------- Section / shared ---------- */
.cowch-install-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 16px;
  width: 100%;
  max-width: 380px;
  background: var(--bg-card, #2d2825);
  border: var(--border-thin, 2px) solid var(--coral, #D4896A);
  border-radius: var(--radius-medium, 24px);
  padding: 32px 24px calc(24px + env(safe-area-inset-bottom, 0px));
  box-shadow: 8px 8px 0 0 var(--bg-dark, #0D0B09);
}
.cowch-install-section--ios {
  padding-top: 28px;
  gap: 14px;
}

.cowch-install-app-icon {
  border-radius: var(--radius-small, 16px);
  overflow: hidden;
  background: var(--bg-elevated);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
  flex-shrink: 0;
}
.cowch-install-app-icon img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.cowch-install-app-icon__fallback {
  font-size: 56px;
  line-height: 1;
}
.cowch-install-app-icon-raw {
  border-radius: 12px;
  flex-shrink: 0;
}
.cowch-install-app-icon--small {
  margin-bottom: -4px;
}

.cowch-install-h1 {
  font-size: 26px;
  font-weight: 900;
  margin: 0;
  line-height: 1.15;
  letter-spacing: -0.01em;
  color: var(--text-primary);
}
.cowch-install-h1--small {
  font-size: 22px;
}

.cowch-install-subtitle {
  font-size: 16px;
  color: var(--text-muted, #b0a499);
  margin: 0;
  line-height: 1.4;
}
.cowch-install-muted {
  font-size: 13px;
  color: var(--text-muted);
  margin: 0;
}
.cowch-install-desktop-hint {
  font-size: 13px;
  line-height: 1.4;
}

/* ---------- Bullets ---------- */
.cowch-install-bullets {
  list-style: none;
  padding: 0;
  margin: 4px 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  text-align: left;
  width: 100%;
}
.cowch-install-bullets li {
  font-size: 15px;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 10px;
}
.cowch-install-bullet-tick {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--coral);
  flex-shrink: 0;
  position: relative;
}
.cowch-install-bullet-tick::after {
  content: '';
  position: absolute;
  left: 50%;
  top: 48%;
  width: 5px;
  height: 9px;
  border: solid var(--text-on-coral);
  border-width: 0 2px 2px 0;
  transform: translate(-50%, -55%) rotate(45deg);
}

/* ---------- Primary install button ---------- */
.cowch-install-btn {
  background: var(--coral, #D4896A);
  color: var(--text-on-coral, #1a1512);
  border: none;
  padding: 14px 40px;
  border-radius: var(--radius-small, 16px);
  font-size: 17px;
  font-weight: 800;
  cursor: pointer;
  font-family: inherit;
  letter-spacing: 0.01em;
  box-shadow: 4px 4px 0 0 var(--bg-dark, #0D0B09);
  transition: transform 0.08s ease, background var(--transition-fast), box-shadow var(--transition-fast);
  touch-action: manipulation;
}
.cowch-install-btn:hover {
  background: var(--coral-light);
  transform: translate(-1px, -1px);
  box-shadow: 5px 5px 0 0 var(--bg-dark);
}
.cowch-install-btn:active {
  transform: translate(2px, 2px);
  box-shadow: 2px 2px 0 0 var(--bg-dark);
}

.cowch-install-skip {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 14px;
  cursor: pointer;
  padding: 8px;
  font-family: inherit;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.cowch-install-skip:hover { color: var(--text-primary); }

.cowch-install-prompt-slot {
  min-height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ---------- Loading dots ---------- */
.cowch-install-dots-loader {
  display: flex;
  gap: 6px;
  padding: 14px 0;
}
.cowch-install-dots-loader span {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--coral);
  animation: cowchDot 1.2s ease-in-out infinite;
}
.cowch-install-dots-loader span:nth-child(2) { animation-delay: 0.18s; }
.cowch-install-dots-loader span:nth-child(3) { animation-delay: 0.36s; }
@keyframes cowchDot {
  0%, 80%, 100% { opacity: 0.3; transform: scale(0.8); }
  40% { opacity: 1; transform: scale(1); }
}

/* ---------- Manual fallback steps (Android) ---------- */
.cowch-install-fallback {
  width: 100%;
  margin-top: 4px;
}
.cowch-install-steps {
  display: flex;
  flex-direction: column;
  gap: 14px;
  text-align: left;
}
.cowch-install-step {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 15px;
  line-height: 1.4;
  color: var(--text-primary);
}
.cowch-install-step__num {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--coral);
  color: var(--text-on-coral);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 14px;
  flex-shrink: 0;
}
.cowch-install-inline-icon {
  vertical-align: middle;
  margin: 0 2px;
  opacity: 0.85;
}

/* ---------- iOS dot indicator ---------- */
.cowch-install-dots {
  display: flex;
  gap: 8px;
  justify-content: center;
}
.cowch-install-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgba(245, 240, 232, 0.18);
  transition: background var(--transition-fast), transform var(--transition-fast);
}
.cowch-install-dot.is-active {
  background: var(--coral);
  transform: scale(1.35);
}

/* ---------- iOS step area ---------- */
.cowch-install-step-area {
  width: 100%;
  min-height: 240px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.cowch-install-step-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  width: 100%;
  animation: cowchFade 0.25s ease;
}
@keyframes cowchFade {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.cowch-install-step-instruction {
  font-size: 17px;
  line-height: 1.4;
  color: var(--text-primary);
}
.cowch-install-step-instruction--done {
  font-size: 19px;
}
.cowch-install-step-hint {
  font-size: 13px;
  color: var(--text-muted);
  margin: -6px 0 0;
}

.cowch-install-share-icon {
  vertical-align: -5px;
  margin-left: 4px;
  color: var(--coral);
}

/* Pointer (animated arrow) */
.cowch-install-pointer {
  position: relative;
  width: 60px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--coral);
}
.cowch-install-pointer--down { animation: cowchBounceDown 1.4s ease-in-out infinite; }
.cowch-install-pointer--up   { animation: cowchBounceUp   1.4s ease-in-out infinite; }
.cowch-install-pulse {
  position: absolute;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 2px solid var(--coral);
  animation: cowchPulse 1.4s ease-out infinite;
}
@keyframes cowchBounceDown {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(8px); }
}
@keyframes cowchBounceUp {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}
@keyframes cowchPulse {
  0%   { transform: scale(0.8); opacity: 1; }
  100% { transform: scale(1.65); opacity: 0; }
}

/* iOS mock share sheet */
.cowch-mock-sheet {
  background: var(--bg-elevated, #3a3228);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-small, 16px);
  padding: 4px 0;
  width: 100%;
  overflow: hidden;
}
.cowch-mock-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  font-size: 15px;
  color: var(--text-primary);
}
.cowch-mock-row--faded { opacity: 0.4; }
.cowch-mock-row--highlight {
  background: rgba(var(--coral-rgb, 201, 123, 99), 0.10);
}
.cowch-mock-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-primary);
  flex-shrink: 0;
}
.cowch-mock-icon--highlight {
  color: var(--coral);
  background: rgba(var(--coral-rgb, 201, 123, 99), 0.18);
}
.cowch-mock-label--highlight {
  color: var(--coral);
  font-weight: 700;
}

/* iOS mock confirm dialog */
.cowch-mock-confirm {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-small);
  width: 100%;
  overflow: hidden;
}
.cowch-mock-confirm__head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-subtle);
  font-size: 14px;
}
.cowch-mock-cancel { color: var(--text-muted); }
.cowch-mock-title { font-weight: 700; font-size: 13px; color: var(--text-primary); }
.cowch-mock-add { color: var(--coral); font-weight: 800; font-size: 15px; }
.cowch-mock-confirm__body {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px;
  text-align: left;
}
.cowch-mock-app-name {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
}
.cowch-mock-app-url {
  font-size: 12px;
  color: var(--text-muted);
}

/* Bounce on done */
.cowch-install-bounce {
  animation: cowchBounceIcon 2s ease-in-out infinite;
}
@keyframes cowchBounceIcon {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.07); }
}

/* iOS nav */
.cowch-install-nav {
  display: flex;
  justify-content: space-between;
  width: 100%;
  gap: 10px;
  margin-top: 4px;
}
.cowch-install-nav-btn {
  flex: 1;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text-primary);
  padding: 12px 24px;
  border-radius: var(--radius-small);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: background var(--transition-fast), transform 0.08s ease;
  touch-action: manipulation;
}
.cowch-install-nav-btn:hover { background: rgba(255, 255, 255, 0.09); }
.cowch-install-nav-btn:active { transform: scale(0.98); }
.cowch-install-nav-btn--primary {
  background: var(--coral);
  border-color: transparent;
  color: var(--text-on-coral);
  font-weight: 800;
}
.cowch-install-nav-btn--primary:hover { background: var(--coral-light); }

/* Small phones */
@media (max-height: 640px) {
  .cowch-install-section { padding: 24px 20px; gap: 12px; }
  .cowch-install-h1 { font-size: 22px; }
  .cowch-install-step-area { min-height: 200px; }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  .cowch-install-banner,
  .cowch-install-overlay,
  .cowch-install-overlay__sheet,
  .cowch-install-step-card,
  .cowch-install-pointer,
  .cowch-install-pulse,
  .cowch-install-bounce,
  .cowch-install-dots-loader span {
    transition: none !important;
    animation: none !important;
  }
}
