/* ==========================================================================
   iOS PWA & Mobile App Experience Enhancements
   Eng. Abdullrahman Mayhoub Architectural Web App
   Handles: iPhone Notch/Dynamic Island Safe Areas, Native Tactile Feel,
   iOS Standalone Mode, and Apple Safari Install Sheet.
   ========================================================================== */

/* Safe Area Insets for Modern iPhones (iPhone X up to iPhone 16 Pro Max) */
:root {
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px);
  --sar: env(safe-area-inset-right, 0px);
}

/* Ensure body takes full screen properly without elastic jump */
html, body {
  -webkit-tap-highlight-color: transparent;
}

/* When launched as standalone iOS App (Home Screen) */
@media (display-mode: standalone) {
  body {
    user-select: none;
    -webkit-user-select: none;
    padding-top: var(--sat);
    padding-bottom: var(--sab);
  }

  /* Allow text selection inside articles and forms */
  p, span, h1, h2, h3, h4, h5, h6, input, textarea, td, th {
    user-select: text;
    -webkit-user-select: text;
  }

  /* Top dock fits below Dynamic Island / Notch */
  .header-global-dock {
    padding-top: max(var(--sat), 4px);
  }

  /* Hide the install trigger once already installed */
  .pwa-install-trigger-btn,
  .ios-install-banner {
    display: none !important;
  }
}

/* Smooth Touch Momentum */
* {
  -webkit-font-smoothing: antialiased;
}

/* Mobile Quick Install Button (Floating or Docked) */
.pwa-install-trigger-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: linear-gradient(135deg, rgba(166, 176, 139, 0.18), rgba(86, 129, 88, 0.28));
  border: 1px solid var(--border-medium, rgba(166, 176, 139, 0.35));
  color: var(--palette-c1, #DBD8CD);
  padding: 6px 14px;
  border-radius: 999px;
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
}

.pwa-install-trigger-btn:hover,
.pwa-install-trigger-btn:active {
  background: linear-gradient(135deg, rgba(166, 176, 139, 0.3), rgba(86, 129, 88, 0.45));
  border-color: var(--abak-gold, #A6B08B);
  transform: translateY(-1px) scale(1.02);
  color: #ffffff;
}

.pwa-install-trigger-btn svg {
  width: 14px;
  height: 14px;
  stroke: var(--abak-gold, #A6B08B);
}

/* ==========================================================================
   iOS Install Sheet (Apple-Styled Bottom Drawer)
   ========================================================================== */
.ios-install-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 18, 14, 0.65);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 99999;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.35s ease;
  padding: 0;
}

.ios-install-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.ios-install-sheet {
  background: rgba(28, 41, 33, 0.95);
  border: 1px solid rgba(166, 176, 139, 0.25);
  border-bottom: none;
  border-radius: 24px 24px 0 0;
  width: 100%;
  max-width: 520px;
  padding: 24px 24px calc(24px + var(--sab));
  box-shadow: 0 -12px 40px rgba(0, 0, 0, 0.55);
  transform: translateY(100%);
  transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
  color: #DBD8CD;
  position: relative;
  overflow: hidden;
}

.ios-install-overlay.active .ios-install-sheet {
  transform: translateY(0);
}

/* Handle indicator bar at top of sheet */
.ios-sheet-handle {
  width: 38px;
  height: 4px;
  background: rgba(219, 216, 205, 0.3);
  border-radius: 99px;
  margin: 0 auto 18px;
}

.ios-sheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.ios-app-identity {
  display: flex;
  align-items: center;
  gap: 14px;
}

.ios-app-icon {
  width: 54px;
  height: 54px;
  border-radius: 14px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(166, 176, 139, 0.3);
  object-fit: cover;
}

.ios-app-meta h3 {
  margin: 0 0 4px;
  font-size: 1.05rem;
  font-weight: 700;
  color: #ffffff;
  font-family: 'Alexandria', sans-serif;
}

.ios-app-meta p {
  margin: 0;
  font-size: 0.8rem;
  color: rgba(219, 216, 205, 0.7);
}

.ios-sheet-close {
  background: rgba(255, 255, 255, 0.08);
  border: none;
  color: #DBD8CD;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.2s;
}

.ios-sheet-close:hover {
  background: rgba(255, 255, 255, 0.18);
}

/* Instruction Steps */
.ios-steps-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-bottom: 22px;
}

.ios-step-item {
  display: flex;
  align-items: center;
  gap: 14px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(219, 216, 205, 0.08);
  border-radius: 14px;
  padding: 12px 14px;
}

.ios-step-badge {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(166, 176, 139, 0.15);
  border: 1px solid var(--abak-gold, #A6B08B);
  color: var(--abak-gold, #A6B08B);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  font-weight: 700;
  flex-shrink: 0;
}

.ios-step-content {
  flex: 1;
  font-size: 0.88rem;
  line-height: 1.45;
  color: #DBD8CD;
}

.ios-step-content strong {
  color: #ffffff;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.ios-icon-inline {
  display: inline-flex;
  vertical-align: middle;
  background: rgba(255, 255, 255, 0.12);
  padding: 3px 6px;
  border-radius: 6px;
  margin: 0 4px;
}

.ios-icon-inline svg {
  width: 14px;
  height: 14px;
  stroke: #ffffff;
}

.ios-sheet-btn-action {
  width: 100%;
  background: linear-gradient(135deg, #A6B08B, #568158);
  color: #17241d;
  font-weight: 700;
  font-size: 0.95rem;
  padding: 13px;
  border-radius: 14px;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: inherit;
  transition: transform 0.15s ease, filter 0.2s ease;
}

.ios-sheet-btn-action:active {
  transform: scale(0.98);
  filter: brightness(0.95);
}

/* Floating Install Pill for Mobile */
.ios-floating-pill {
  position: fixed;
  bottom: calc(18px + var(--sab));
  left: 18px;
  z-index: 9998;
  display: none;
}

@media (max-width: 768px) {
  .ios-floating-pill {
    display: block;
  }
}

/* Header Top-Bar Install Quick Action */
.top-bar-install-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: rgba(166, 176, 139, 0.22);
  border: 1px solid rgba(166, 176, 139, 0.45);
  color: #ffffff !important;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 9.5px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
}

.top-bar-install-btn:hover {
  background: rgba(166, 176, 139, 0.4);
  border-color: #DBD8CD;
  color: #ffffff;
}

.top-bar-install-btn svg {
  stroke: var(--abak-gold, #A6B08B);
}

