/* Popup Overlay */
.popup-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  height: 100dvh; /* Dynamic viewport height for mobile */
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  z-index: 9999;
  justify-content: center;
  align-items: center;
  padding: 1rem;
  box-sizing: border-box;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.popup-overlay.active {
  display: flex;
}

/* Popup Modal */
.popup-modal {
  background: linear-gradient(145deg, #1a1a1a 0%, #2d1f1f 100%);
  border-radius: 20px;
  max-width: 550px;
  width: 100%;
  max-height: 90vh;
  max-height: 90dvh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  position: relative;
  box-shadow:
    0 25px 80px rgba(214, 73, 51, 0.3),
    0 0 0 1px rgba(214, 73, 51, 0.2);
  animation: popupSlideIn 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
  margin: auto;
}

@keyframes popupSlideIn {
  from {
    opacity: 0;
    transform: scale(0.9) translateY(-30px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

/* Animated Top Border */
.popup-modal::before {
  content: '';
  position: sticky;
  top: 0;
  left: 0;
  right: 0;
  display: block;
  height: 4px;
  background: linear-gradient(90deg,
    var(--color-primary, #D64933),
    #f5a623,
    var(--color-primary, #D64933));
  background-size: 200% 100%;
  animation: gradientMove 2s linear infinite;
  z-index: 10;
}

@keyframes gradientMove {
  0% { background-position: 0% 50%; }
  100% { background-position: 200% 50%; }
}

/* Popup Header */
.popup-header {
  padding: 1.5rem 2rem 1rem;
  text-align: center;
}

.popup-alert-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: rgba(214, 73, 51, 0.2);
  border: 1px solid rgba(214, 73, 51, 0.4);
  color: #ff6b5b;
  padding: 0.5rem 1rem;
  border-radius: 50px;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 2px;
  margin-bottom: 1rem;
  animation: pulseBadge 2s infinite;
}

@keyframes pulseBadge {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.02); }
}

.popup-alert-badge svg {
  width: 16px;
  height: 16px;
  fill: currentColor;
  animation: shake 0.5s ease-in-out infinite;
}

@keyframes shake {
  0%, 100% { transform: rotate(0deg); }
  25% { transform: rotate(-5deg); }
  75% { transform: rotate(5deg); }
}

.popup-title {
  font-family: 'Oswald', sans-serif;
  font-size: clamp(1.3rem, 4vw, 2rem);
  color: white;
  text-transform: uppercase;
  line-height: 1.2;
  margin-bottom: 0.5rem;
}

.popup-title span {
  color: #D64933;
}

/* Large Number Display */
.popup-number-display {
  text-align: center;
  padding: 0.5rem 0;
}

.popup-big-number {
  font-family: 'Oswald', sans-serif;
  font-size: clamp(3rem, 10vw, 5rem);
  font-weight: 700;
  color: #D64933;
  line-height: 1;
  text-shadow: 0 0 60px rgba(214, 73, 51, 0.5);
}

.popup-big-number span {
  font-size: 0.4em;
  color: rgba(255, 255, 255, 0.7);
  vertical-align: middle;
}

.popup-number-label {
  font-size: clamp(0.7rem, 2vw, 0.9rem);
  color: rgba(255, 255, 255, 0.6);
  text-transform: uppercase;
  letter-spacing: 2px;
  margin-top: 0.25rem;
}

/* Popup Body */
.popup-modal-body {
  padding: 0 1.5rem 1rem;
}

.popup-modal-body p {
  color: rgba(255, 255, 255, 0.85);
  font-size: clamp(0.875rem, 2.5vw, 1rem);
  line-height: 1.6;
  text-align: center;
}

.popup-modal-body strong {
  color: white;
}

/* Stats Grid */
.popup-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
  margin: 1rem 0;
}

.popup-stat {
  text-align: center;
  padding: 0.75rem 0.5rem;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.popup-stat-number {
  font-family: 'Oswald', sans-serif;
  font-size: clamp(1.1rem, 3vw, 1.5rem);
  font-weight: 700;
  color: #f5a623;
}

.popup-stat-label {
  font-size: clamp(0.6rem, 1.5vw, 0.7rem);
  color: rgba(255, 255, 255, 0.6);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-top: 0.25rem;
}

/* Impact Icons Row */
.popup-impacts {
  display: flex;
  justify-content: center;
  gap: 1rem;
  margin: 1rem 0;
  flex-wrap: wrap;
}

.popup-impact {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
}

.popup-impact-icon {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(214, 73, 51, 0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(214, 73, 51, 0.3);
}

.popup-impact-icon svg {
  width: 22px;
  height: 22px;
  fill: #D64933;
}

.popup-impact-label {
  font-size: 0.65rem;
  color: rgba(255, 255, 255, 0.7);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Popup Footer */
.popup-modal-footer {
  padding: 1rem 1.5rem 1.5rem;
  display: flex;
  gap: 0.75rem;
  justify-content: center;
  flex-wrap: wrap;
}

.popup-btn {
  padding: 0.75rem 1.5rem;
  font-size: 0.9rem;
  font-weight: 600;
  border-radius: 50px;
  text-decoration: none;
  transition: all 0.3s ease;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  border: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.popup-btn-primary {
  background: linear-gradient(135deg, #D64933 0%, #b8362a 100%);
  color: white;
  box-shadow: 0 4px 20px rgba(214, 73, 51, 0.4);
}

.popup-btn-primary:hover,
.popup-btn-primary:active {
  transform: translateY(-2px);
  box-shadow: 0 6px 30px rgba(214, 73, 51, 0.5);
  background: linear-gradient(135deg, #e55a45 0%, #D64933 100%);
}

.popup-btn-primary svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
}

.popup-btn-secondary {
  background: transparent;
  color: rgba(255, 255, 255, 0.8);
  border: 1px solid rgba(255, 255, 255, 0.3);
}

.popup-btn-secondary:hover,
.popup-btn-secondary:active {
  background: rgba(255, 255, 255, 0.1);
  color: white;
  border-color: rgba(255, 255, 255, 0.5);
}

/* Close Button */
.popup-close-btn {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.15);
  border: none;
  color: rgba(255, 255, 255, 0.8);
  font-size: 1.75rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
  line-height: 1;
  z-index: 20;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.popup-close-btn:hover,
.popup-close-btn:active {
  background: rgba(255, 255, 255, 0.25);
  color: white;
}

/* Urgency Bar */
.popup-urgency {
  background: rgba(214, 73, 51, 0.1);
  padding: 0.75rem 1rem;
  text-align: center;
  border-top: 1px solid rgba(214, 73, 51, 0.2);
}

.popup-urgency p {
  color: rgba(255, 255, 255, 0.7);
  font-size: 0.75rem;
  margin: 0;
  line-height: 1.4;
}

.popup-urgency strong {
  color: #f5a623;
}

/* Mobile Responsive */
@media (max-width: 600px) {
  .popup-overlay {
    padding: 0.5rem;
    align-items: flex-start;
    padding-top: 2rem;
  }

  .popup-modal {
    border-radius: 16px;
    max-height: calc(100vh - 3rem);
    max-height: calc(100dvh - 3rem);
  }

  .popup-header {
    padding: 1.25rem 1.25rem 0.75rem;
    padding-right: 3rem; /* Space for close button */
  }

  .popup-alert-badge {
    padding: 0.4rem 0.75rem;
    font-size: 0.65rem;
    letter-spacing: 1px;
  }

  .popup-modal-body {
    padding: 0 1.25rem 0.75rem;
  }

  .popup-modal-body p {
    font-size: 0.85rem;
    line-height: 1.5;
  }

  .popup-modal-footer {
    padding: 0.75rem 1.25rem 1.25rem;
    flex-direction: column;
  }

  .popup-btn {
    width: 100%;
    justify-content: center;
    padding: 0.875rem 1.5rem;
  }

  .popup-stats {
    gap: 0.5rem;
  }

  .popup-stat {
    padding: 0.6rem 0.25rem;
  }

  .popup-stat-number {
    font-size: 1rem;
  }

  .popup-stat-label {
    font-size: 0.55rem;
    letter-spacing: 0.5px;
  }

  .popup-impacts {
    gap: 0.5rem;
    margin: 0.75rem 0;
  }

  .popup-impact-icon {
    width: 32px;
    height: 32px;
  }

  .popup-impact-icon svg {
    width: 14px;
    height: 14px;
  }

  .popup-impact-label {
    font-size: 0.5rem;
  }

  .popup-impact {
    gap: 0.25rem;
  }

  .popup-number-display {
    padding: 0.25rem 0;
  }

  .popup-big-number {
    font-size: clamp(2.5rem, 15vw, 4rem);
  }

  .popup-close-btn {
    top: 0.5rem;
    right: 0.5rem;
    width: 36px;
    height: 36px;
    font-size: 1.5rem;
  }

  .popup-urgency {
    padding: 0.6rem 1rem;
  }

  .popup-urgency p {
    font-size: 0.7rem;
  }
}

/* Very small screens */
@media (max-width: 400px) {
  .popup-impacts {
    gap: 0.4rem;
  }

  .popup-impact-icon {
    width: 28px;
    height: 28px;
  }

  .popup-impact-icon svg {
    width: 12px;
    height: 12px;
  }

  .popup-impact-label {
    font-size: 0.45rem;
    letter-spacing: 0;
  }
}

@media (max-width: 360px) {
  .popup-header {
    padding: 1rem 1rem 0.5rem;
    padding-right: 2.5rem;
  }

  .popup-modal-body {
    padding: 0 1rem 0.5rem;
  }

  .popup-modal-footer {
    padding: 0.5rem 1rem 1rem;
  }

  .popup-big-number {
    font-size: 2.5rem;
  }

  .popup-impacts {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.3rem;
    justify-items: center;
  }

  .popup-impact-icon {
    width: 26px;
    height: 26px;
  }

  .popup-impact-icon svg {
    width: 11px;
    height: 11px;
  }

  .popup-impact-label {
    font-size: 0.4rem;
  }
}

/* Animation for popup closing */
.popup-modal.closing {
  animation: popupSlideOut 0.3s ease forwards;
}

@keyframes popupSlideOut {
  from {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
  to {
    opacity: 0;
    transform: scale(0.95) translateY(20px);
  }
}

/* Prevent body scroll when popup is open */
body.popup-open {
  overflow: hidden;
  position: fixed;
  width: 100%;
  height: 100%;
}
