/* =================================================================
   WELCOME MODAL - CASUAL POPUP STYLES (PERFECT CENTERING + SCROLLBAR PRESERVATION)
   ================================================================= */

/* Modal Overlay - Full Screen Fixed with Flexbox Centering */
.welcome-modal {
  display: none;
  position: fixed;
  z-index: 10001;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.25);
  backdrop-filter: blur(2px);
  overflow: hidden;
  animation: fadeInModal 0.5s ease-out;
  /* Flexbox for perfect X and Y centering */
  justify-content: center;
  align-items: center;
  padding: 20px;
  box-sizing: border-box;
}

/* When modal is shown, apply flexbox */
.welcome-modal[style*="block"] {
  display: flex !important;
}

/* Modal Content Container - PERFECTLY CENTERED */
.welcome-modal-content {
  background: linear-gradient(135deg, #1a1a1a 0%, #2d2d2d 100%);
  margin: 0;
  padding: 0;
  border: 2px solid #d4af37;
  border-radius: 16px;
  width: 85%;
  max-width: 450px;
  box-shadow: 0 15px 50px rgba(0, 0, 0, 0.6);
  position: relative;
  overflow: hidden;
  animation: slideInModal 0.4s ease-out;
  box-sizing: border-box;
  /* Responsive sizing with viewport constraints */
  max-height: 90vh;
  max-width: min(450px, 90vw);
}

/* Shimmer Effect on Top Border */
.welcome-modal-content::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(90deg, #d4af37, #f4e49c, #d4af37);
  background-size: 200% 100%;
  animation: shimmer 3s infinite;
  border-radius: 14px 14px 0 0;
}

/* Subtle Glow Effect */
.welcome-modal-content::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: radial-gradient(circle, rgba(212, 175, 55, 0.05) 0%, transparent 70%);
  animation: rotate 15s linear infinite;
  pointer-events: none;
  border-radius: 16px;
}

/* =================================================================
   MODAL HEADER
   ================================================================= */

.welcome-modal-header {
  text-align: center;
  padding: 25px 20px 20px;
  background: linear-gradient(45deg, #d4af37, #f4e49c);
  color: #1a1a1a;
  position: relative;
  overflow: hidden;
  border-radius: 14px 14px 0 0;
}

.welcome-modal-header::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><defs><pattern id="stars" x="0" y="0" width="20" height="20" patternUnits="userSpaceOnUse"><circle cx="10" cy="10" r="1" fill="rgba(255,255,255,0.2)"/></pattern></defs><rect width="100" height="100" fill="url(%23stars)"/></svg>');
  opacity: 0.3;
  animation: twinkle 6s ease-in-out infinite;
  border-radius: 14px 14px 0 0;
}

.welcome-modal-logo {
  width: 50px;
  height: 50px;
  margin-bottom: 15px;
  border-radius: 50%;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
  position: relative;
  z-index: 1;
  transition: transform 0.3s ease;
}

.welcome-modal-logo:hover {
  transform: scale(1.05) rotate(3deg);
}

.welcome-modal-header h2 {
  margin: 0;
  font-family: 'Playfair Display', serif;
  font-size: 1.6rem;
  font-weight: 600;
  text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.2);
  position: relative;
  z-index: 1;
  letter-spacing: 0.5px;
  word-wrap: break-word;
}

/* =================================================================
   MODAL BODY
   ================================================================= */

.welcome-modal-body {
  padding: 25px 20px;
  text-align: center;
  color: #fff;
  position: relative;
  z-index: 1;
}

/* Offer Badge */
.offer-badge {
  background: linear-gradient(45deg, #d4af37, #f4e49c);
  border-radius: 12px;
  padding: 20px 15px;
  margin-bottom: 20px;
  transform: rotate(-1deg);
  box-shadow: 0 6px 20px rgba(212, 175, 55, 0.3);
  position: relative;
  overflow: hidden;
  transition: transform 0.3s ease;
}

.offer-badge:hover {
  transform: rotate(0deg) scale(1.01);
}

.offer-badge::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(45deg, transparent, rgba(255, 255, 255, 0.15), transparent);
  background-size: 200% 200%;
  animation: containedSweep 4s ease-in-out infinite;
  border-radius: 12px;
}

.discount-amount {
  display: block;
  font-size: 2.2rem;
  font-weight: 800;
  color: #1a1a1a;
  font-family: 'Playfair Display', serif;
  text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.15);
  position: relative;
  z-index: 1;
  word-wrap: break-word;
}

.offer-type {
  display: block;
  font-size: 1.1rem;
  color: #2d2d2d;
  font-weight: 600;
  margin-top: 6px;
  position: relative;
  z-index: 1;
  letter-spacing: 0.3px;
  word-wrap: break-word;
}

.offer-description {
  font-size: 1rem;
  line-height: 1.6;
  margin-bottom: 25px;
  color: #e8e8e8;
  font-weight: 400;
  text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.3);
  word-wrap: break-word;
}

/* =================================================================
   BUTTONS
   ================================================================= */

.welcome-modal-buttons {
  display: flex;
  flex-direction: column;
  gap: 15px;
  margin-bottom: 20px;
}

.claim-offer-btn {
  background: linear-gradient(45deg, #d4af37, #f4e49c);
  color: #1a1a1a;
  padding: 15px 30px;
  border: none;
  border-radius: 25px;
  font-size: 1rem;
  font-weight: 600;
  text-decoration: none;
  text-transform: uppercase;
  cursor: pointer;
  transition: all 0.3s ease;
  font-family: 'Playfair Display', serif;
  box-shadow: 0 4px 15px rgba(212, 175, 55, 0.4);
  display: inline-block;
  text-align: center;
  position: relative;
  overflow: hidden;
  letter-spacing: 0.5px;
  box-sizing: border-box;
}

.claim-offer-btn::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
  transition: left 0.5s ease;
}

.claim-offer-btn:hover::before {
  left: 100%;
}

.claim-offer-btn:hover,
.claim-offer-btn:focus {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(212, 175, 55, 0.6);
  background: linear-gradient(45deg, #f4e49c, #d4af37);
  text-decoration: none;
  color: #1a1a1a;
  outline: none;
}

.claim-offer-btn:active {
  transform: translateY(-1px);
  box-shadow: 0 3px 10px rgba(212, 175, 55, 0.5);
}

.maybe-later-btn {
  background: transparent;
  color: #ccc;
  padding: 12px 25px;
  border: 2px solid #555;
  border-radius: 20px;
  font-size: 0.95rem;
  cursor: pointer;
  transition: all 0.3s ease;
  font-weight: 500;
  backdrop-filter: blur(10px);
  box-sizing: border-box;
}

.maybe-later-btn:hover,
.maybe-later-btn:focus {
  color: #fff;
  border-color: #888;
  background: rgba(255, 255, 255, 0.05);
  transform: translateY(-1px);
  outline: none;
}

/* =================================================================
   CLOSE BUTTON
   ================================================================= */

.welcome-close-btn {
  color: #d4af37;
  position: absolute;
  right: 12px;
  top: 12px;
  font-size: 24px;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.3s ease;
  z-index: 100;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(10px);
  user-select: none;
  font-family: Arial, sans-serif;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.welcome-close-btn:hover,
.welcome-close-btn:focus {
  background: rgb(0, 0, 0, 0.6);
  transform: scale(1.1) rotate(90deg);
  border-color: rgba(0, 0, 0, 0.25);
  outline: none;
}

/* =================================================================
   TERMS TEXT
   ================================================================= */

.offer-terms {
  font-size: 0.8rem;
  color: #aaa;
  line-height: 1.4;
  margin: 0;
  font-style: italic;
  text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.4);
  word-wrap: break-word;
}

/* =================================================================
   ANIMATIONS
   ================================================================= */

@keyframes fadeInModal {
  from { 
    opacity: 0;
    backdrop-filter: blur(0);
    background: rgba(0, 0, 0, 0);
  }
  to { 
    opacity: 1;
    backdrop-filter: blur(2px);
    background: rgba(0, 0, 0, 0.25);
  }
}

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

@keyframes shimmer {
  0%, 100% { 
    background-position: -100% 0; 
  }
  50% { 
    background-position: 100% 0; 
  }
}

@keyframes rotate {
  from { 
    transform: rotate(0deg);
  }
  to { 
    transform: rotate(360deg);
  }
}

@keyframes twinkle {
  0%, 100% { 
    opacity: 0.2; 
  }
  50% { 
    opacity: 0.4; 
  }
}

@keyframes containedSweep {
  0% { 
    background-position: -200% -200%;
    opacity: 0;
  }
  50% { 
    background-position: 0% 0%;
    opacity: 1;
  }
  100% { 
    background-position: 200% 200%;
    opacity: 0;
  }
}

/* =================================================================
   BODY SCROLL PREVENTION - WITH SCROLLBAR PRESERVATION
   ================================================================= */

/* Modern browsers with scrollbar-gutter support */
@supports (scrollbar-gutter: stable) {
  body.modal-open {
    overflow: hidden !important;
    scrollbar-gutter: stable both-edges !important;
  }
  
  html.modal-open {
    scrollbar-gutter: stable !important;
  }
}

/* Fallback for browsers without scrollbar-gutter */
@supports not (scrollbar-gutter: stable) {
  body.modal-open {
    overflow: hidden !important;
    /* Add padding to compensate for missing scrollbar */
    padding-right: calc(100vw - 100%) !important;
  }
  
  html.modal-open {
    overflow-y: auto !important;
  }
}

/* Ensure modal overlay covers the compensated space */
body.modal-open .welcome-modal {
  width: 100vw !important;
  left: 0 !important;
  right: 0 !important;
}

/* =================================================================
   RESPONSIVE DESIGN - PERFECT CENTERING AT ALL SIZES
   ================================================================= */

/* Large Desktop */
@media (min-width: 1200px) {
  .welcome-modal-content {
    width: 75%;
    max-width: 500px;
  }
}

/* Tablet */
@media (max-width: 768px) {
  .welcome-modal-content {
    width: 90%;
    max-width: 400px;
  }
  
  .welcome-modal-header {
    padding: 20px 15px 15px;
  }
  
  .welcome-modal-header h2 {
    font-size: 1.4rem;
  }
  
  .welcome-modal-body {
    padding: 20px 15px;
  }
  
  .discount-amount {
    font-size: 1.9rem;
  }
  
  .offer-description {
    font-size: 0.95rem;
  }
  
  .claim-offer-btn {
    padding: 14px 25px;
    font-size: 0.95rem;
  }
}

/* Mobile */
@media (max-width: 480px) {
  .welcome-modal-content {
    width: 95%;
    max-width: 350px;
    border-radius: 12px;
  }
  
  .welcome-modal-header {
    padding: 18px 12px 12px;
    border-radius: 10px 10px 0 0;
  }
  
  .welcome-modal-header h2 {
    font-size: 1.3rem;
  }
  
  .welcome-modal-body {
    padding: 18px 12px;
  }
  
  .discount-amount {
    font-size: 1.7rem;
  }
  
  .offer-type {
    font-size: 1rem;
  }
  
  .welcome-close-btn {
    width: 28px;
    height: 28px;
    font-size: 20px;
    right: 10px;
    top: 10px;
  }
  
  .claim-offer-btn {
    padding: 12px 20px;
    font-size: 0.9rem;
  }
  
  .offer-badge {
    padding: 15px 12px;
    margin-bottom: 15px;
  }
}

/* Small Mobile */
@media (max-width: 360px) {
  .welcome-modal-content {
    width: 96%;
    max-width: 320px;
  }
  
  .welcome-modal-buttons {
    gap: 12px;
  }
  
  .discount-amount {
    font-size: 1.5rem;
  }
  
  .welcome-modal-header h2 {
    font-size: 1.2rem;
  }
}

/* Extra Small Mobile */
@media (max-width: 320px) {
  .welcome-modal-content {
    width: 98%;
    max-width: 300px;
  }
  
  .welcome-modal-header {
    padding: 15px 10px 10px;
  }
  
  .welcome-modal-body {
    padding: 15px 10px;
  }
  
  .discount-amount {
    font-size: 1.3rem;
  }
  
  .welcome-modal-header h2 {
    font-size: 1.1rem;
  }
  
  .claim-offer-btn {
    padding: 10px 15px;
    font-size: 0.85rem;
  }
}

/* =================================================================
   LANDSCAPE ORIENTATION ADJUSTMENTS
   ================================================================= */

@media (orientation: landscape) and (max-height: 600px) {
  .welcome-modal-content {
    max-height: 85vh;
    width: 80%;
    max-width: 500px;
  }
  
  .welcome-modal-header {
    padding: 15px 20px 12px;
  }
  
  .welcome-modal-body {
    padding: 15px 20px;
  }
  
  .offer-badge {
    padding: 15px 12px;
    margin-bottom: 15px;
  }
  
  .welcome-modal-buttons {
    gap: 10px;
    margin-bottom: 15px;
  }
}

/* Short landscape devices */
@media (orientation: landscape) and (max-height: 400px) {
  .welcome-modal-content {
    max-height: 95vh;
    width: 75%;
    max-width: 600px;
  }
  
  .welcome-modal-header {
    padding: 10px 15px 8px;
  }
  
  .welcome-modal-body {
    padding: 10px 15px;
  }
  
  .welcome-modal-header h2 {
    font-size: 1.3rem;
  }
  
  .discount-amount {
    font-size: 1.8rem;
  }
}

/* =================================================================
   ACCESSIBILITY & PREFERENCES
   ================================================================= */

/* Focus States */
.welcome-modal:focus-within .welcome-modal-content {
  outline: 2px solid #d4af37;
  outline-offset: 2px;
}

.claim-offer-btn:focus,
.maybe-later-btn:focus,
.welcome-close-btn:focus {
  outline: 2px solid #d4af37;
  outline-offset: 2px;
}

/* High Contrast Mode */
@media (prefers-contrast: high) {
  .welcome-modal {
    background: rgba(0, 0, 0, 0.9);
  }
  
  .welcome-modal-content {
    border-width: 3px;
    background: #000;
  }
  
  .welcome-modal-header {
    background: #d4af37;
  }
  
  .welcome-close-btn {
    background: #fff;
    color: #000;
    font-weight: 900;
  }
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
  .welcome-modal-content,
  .welcome-modal,
  .offer-badge,
  .welcome-modal-logo,
  .claim-offer-btn,
  .maybe-later-btn,
  .welcome-close-btn {
    animation: none !important;
    transition: none !important;
  }
  
  .welcome-modal-content::before,
  .welcome-modal-content::after,
  .welcome-modal-header::before,
  .offer-badge::before,
  .claim-offer-btn::before {
    animation: none !important;
  }
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
  .welcome-modal-content {
    background: linear-gradient(135deg, #0a0a0a 0%, #1a1a1a 100%);
    border-color: #d4af37;
  }
}

/* =================================================================
   PRINT STYLES
   ================================================================= */

@media print {
  .welcome-modal {
    display: none !important;
  }
  
  /* Reset body for printing */
  body.modal-open {
    overflow: visible !important;
    padding-right: 0 !important;
    position: static !important;
  }
}

/* =================================================================
  SAFETY MEASURES
   ================================================================= */

/* Ensure no element causes overflow */
.welcome-modal *,
.welcome-modal *::before,
.welcome-modal *::after {
  box-sizing: border-box !important;
}

/* Prevent transforms from breaking centering */
.welcome-modal-content,
.offer-badge,
.claim-offer-btn {
  transform-origin: center center !important;
}

/* Fallback centering for older browsers */
@supports not (display: flex) {
  .welcome-modal-content {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    margin: 0;
  }
}