/* ==========================================================================
   NEPLEARN - APPLE ACTION SHEET PWA DRAWER (iOS HIG COMPLIANT)
   Design: Apple Human Interface Guidelines, Frosted Glass, Anti-Text Drop
   Zero AI Emojis: 100% Vector Stroke SVGs & Pure Typography
   ========================================================================== */

/* Safe Area Insets cho iPhone màn hình tai thỏ / Dynamic Island */
:root {
  --sat: env(safe-area-inset-top, 0px);
  --sar: env(safe-area-inset-right, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px);
}

/* 1. Backdrop Overlay */
.ios-pwa-drawer-backdrop,
.ios-install-drawer-backdrop {
  position: fixed;
  inset: 0;
  z-index: 99990;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.32s cubic-bezier(0.32, 0.72, 0, 1), visibility 0.32s;
  pointer-events: none;
}

.ios-pwa-drawer-backdrop.active,
.ios-install-drawer-backdrop.active,
.ios-pwa-drawer-backdrop.open,
.ios-install-drawer-backdrop.open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  display: flex;
}

/* 2. Action Sheet Drawer (Slide up from bottom) */
.ios-pwa-drawer,
.ios-install-drawer {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 99995;
  width: 100%;
  max-width: 520px;
  margin: 0 auto;
  background: rgba(20, 20, 24, 0.95);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 24px 24px 0 0;
  padding: 12px 20px calc(24px + env(safe-area-inset-bottom, 16px)) 20px;
  box-shadow: 0 -12px 48px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(255, 255, 255, 0.05);
  transform: translateY(100%);
  transition: transform 0.38s cubic-bezier(0.32, 0.72, 0, 1);
  will-change: transform;
  touch-action: pan-y;
  box-sizing: border-box;
  color: #F8FAFC;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  user-select: none;
  -webkit-user-select: none;
}

.ios-pwa-drawer.active,
.ios-install-drawer.active,
.ios-pwa-drawer.open,
.ios-install-drawer.open {
  transform: translateY(0);
}

/* 3. Drag Handle Indicator */
.ios-drawer-handle-bar {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  padding: 4px 0 12px 0;
  cursor: grab;
}

.ios-drawer-handle {
  width: 36px;
  height: 4px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.28);
  transition: background 0.2s ease, width 0.2s ease;
}

.ios-pwa-drawer:active .ios-drawer-handle,
.ios-install-drawer:active .ios-drawer-handle {
  background: rgba(255, 255, 255, 0.45);
}

/* 4. Drawer Header */
.ios-drawer-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 20px;
}

.ios-drawer-header-content {
  flex: 1;
  min-width: 0;
}

.ios-drawer-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 9px;
  border-radius: 999px;
  background: rgba(0, 102, 255, 0.14);
  border: 1px solid rgba(0, 102, 255, 0.3);
  color: #60A5FA;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  margin-bottom: 8px;
  white-space: nowrap;
}

.ios-drawer-title {
  margin: 0 0 4px 0;
  font-size: 19px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: #FFFFFF;
  line-height: 1.3;
  text-wrap: balance;
}

.ios-drawer-subtitle {
  margin: 0;
  font-size: 13px;
  font-weight: 400;
  line-height: 1.4;
  color: #94A3B8;
  text-wrap: balance;
}

.ios-drawer-close-btn,
.ios-drawer-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #94A3B8;
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
  transition: all 0.2s ease;
}

.ios-drawer-close-btn:hover,
.ios-drawer-close:hover {
  background: rgba(255, 255, 255, 0.16);
  color: #FFFFFF;
  transform: scale(1.05);
}

.ios-drawer-close-btn:active,
.ios-drawer-close:active {
  transform: scale(0.95);
}

/* 5. Steps Container */
.ios-drawer-steps,
.ios-step-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 22px;
}

.ios-step-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 14px;
  transition: background 0.2s ease, border-color 0.2s ease;
}

.ios-step-item:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.12);
}

.ios-step-icon-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  border-radius: 12px;
  flex-shrink: 0;
}

.ios-step-icon-wrap.step-1 {
  background: rgba(0, 102, 255, 0.14);
  border: 1px solid rgba(0, 102, 255, 0.28);
  color: #38BDF8;
}

.ios-step-icon-wrap.step-2 {
  background: rgba(167, 139, 250, 0.14);
  border: 1px solid rgba(167, 139, 250, 0.28);
  color: #C084FC;
}

.ios-step-icon-wrap.step-3 {
  background: rgba(16, 185, 129, 0.14);
  border: 1px solid rgba(16, 185, 129, 0.28);
  color: #34D399;
}

.ios-step-text-wrap,
.ios-step-text {
  flex: 1;
  min-width: 0;
}

.ios-step-head {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 2px;
}

.ios-step-number,
.ios-step-num {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #94A3B8;
  white-space: nowrap;
}

.ios-step-title {
  font-size: 14px;
  font-weight: 600;
  color: #FFFFFF;
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ios-step-desc {
  font-size: 12px;
  font-weight: 400;
  color: #94A3B8;
  margin: 0;
  line-height: 1.35;
  text-wrap: balance;
}

/* 6. Footer Actions */
.ios-drawer-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.btn-ios-primary {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 13px 18px;
  background: #0066FF;
  color: #FFFFFF;
  font-size: 15px;
  font-weight: 600;
  border-radius: 12px;
  border: none;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 0 4px 16px rgba(0, 102, 255, 0.3);
  white-space: nowrap;
}

.btn-ios-primary:hover {
  background: #0052CC;
  box-shadow: 0 6px 20px rgba(0, 102, 255, 0.4);
  transform: translateY(-1px);
}

.btn-ios-primary:active {
  transform: scale(0.98);
}

.ios-drawer-standalone-tip {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 11px;
  color: #64748B;
  text-align: center;
  margin-top: 4px;
  white-space: nowrap;
}

/* Responsive adjustments for narrow iPhones (iPhone SE / mini) */
@media (max-width: 375px) {
  .ios-pwa-drawer,
  .ios-install-drawer {
    padding: 10px 14px calc(20px + env(safe-area-inset-bottom, 12px)) 14px;
  }
  .ios-drawer-title {
    font-size: 17px;
  }
  .ios-step-item {
    padding: 10px 12px;
    gap: 10px;
  }
  .ios-step-icon-wrap {
    width: 36px;
    height: 36px;
  }
}
