/* Landing Page Styles */
/* Base */
* { 
  box-sizing: border-box; 
}

body { 
  margin: 0; 
  background: #fff; 
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, "SF Arabic", sans-serif; 
}

.wrap { 
  min-height: 100dvh; 
  display: flex; 
  align-items: center; 
  justify-content: center; 
  padding: 16px; 
}

.box { 
  position: relative; 
  width: 100%; 
  max-width: 420px; 
  height: 100dvh; 
  display: flex; 
  flex-direction: column; 
  align-items: center; 
  justify-content: flex-start; 
  gap: 10px; 
  padding: 12px 0; 
}

/* Images (mobile-first) */
.top { 
  position: relative; 
  width: 84px; 
  height: auto; 
  min-height: 64px; 
  margin-top: 20px; 
}

.center { 
  position: relative; 
  width: 60%; 
  max-width: 260px; 
  height: auto; 
  min-height: 180px; 
  margin: 40px 0; 
}

.bottom { 
  position: relative; 
  width: 55px; 
  height: auto; 
  margin-top: auto; 
}

/* Skeleton shimmer */
.mid { 
  width: 100%; 
  display: flex; 
  flex-direction: column; 
  align-items: center; 
  justify-content: center; 
  gap: 6px; 
  padding: 0 16px; 
  margin-top: 20px; 
}

.spacer { 
  flex: 1 1 auto; 
}

.skeleton { 
  background: linear-gradient(90deg, #f2f2f2 25%, #e9e9e9 37%, #f2f2f2 63%); 
  background-size: 400% 100%; 
  animation: shimmer 1.2s ease-in-out infinite; 
  border-radius: 12px; 
}

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

/* Text blocks (mobile-first) */
.title { 
  position: relative; 
  width: 100%; 
  padding: 0 16px; 
  text-align: center !important; 
  font-weight: 700; 
  color: #1B1B1C; 
  font-size: 20px; 
  line-height: 30px; 
}

.title-web { 
  position: relative; 
  width: 100%; 
  padding: 0 24px; 
  text-align: center !important; 
  font-weight: 700; 
  color: #1B1B1C; 
  font-size: 22px; 
  line-height: 33px; 
}

.countdown-web {
  position: relative;
  width: 100%;
  text-align: center !important;
  color: #595A5B;
  font-size: 16px;
  line-height: 24px;
  padding: 8px 24px;
}

#countdown-timer {
  display: inline-block;
  min-width: 20px;
  text-align: center;
  font-weight: 700;
  color: #1B1B1C;
}

.mobile-text { 
  position: relative; 
  width: 100%; 
  padding: 0 16px; 
  text-align: center !important; 
  color: #595A5B; 
  font-size: 16px; 
  line-height: 24px; 
}

.web-text { 
  position: relative; 
  width: 100%; 
  padding: 0 24px; 
  text-align: center !important; 
  color: #595A5B; 
  font-size: 16px; 
  line-height: 24px; 
}

/* Button (mobile-first) */
.btn { 
  position: relative; 
  width: 100%; 
  max-width: 358px; 
  height: 48px; 
  border-radius: 8px; 
  background: #1B1B1C; 
  color: #fff; 
  display: flex; 
  flex-direction: column; 
  justify-content: center; 
  align-items: center; 
  padding: 10.5px 24px; 
  gap: 10px; 
  font-weight: 600; 
  font-size: 14px; 
  text-decoration: none; 
  border: 0; 
  outline: 0; 
  -webkit-tap-highlight-color: transparent; 
  margin: 8px auto 0 auto; 
}

.btn:hover { 
  background: #1B1B1C; 
}

.btn-label { 
  display: flex; 
  flex-direction: row; 
  justify-content: center; 
  align-items: center; 
  padding: 0; 
  gap: 4px; 
  width: 100%; 
  height: 24px; 
  text-align: center; 
}

.btn-secondary {
  background: #ffffff;
  color: #1B1B1C;
  border: 1px solid #E5E7EB;
}

.btn-secondary:hover {
  background: #f9fafb;
}

/* Loading/Disabled Button State */
.btn-loading {
  background: #9CA3AF !important;
  cursor: not-allowed;
  pointer-events: none;
  opacity: 0.8;
}

.btn-loading .btn-label {
  color: #E5E7EB;
}

.btn-spinner {
  display: none;
  width: 16px;
  height: 16px;
  border: 2px solid #E5E7EB;
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  position: absolute;
  right: 24px;
}

.btn-loading .btn-spinner {
  display: block;
}

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

/* Ready button state - enable with transition */
.btn[data-ready="true"] {
  background: #1B1B1C;
  cursor: pointer;
  pointer-events: auto;
  opacity: 1;
  transition: background 0.3s ease, opacity 0.3s ease;
}

.btn[data-ready="true"] .btn-spinner {
  display: none;
}

.btn[data-ready="true"] .btn-label {
  color: #fff;
}

/* Visibility - Always show mobile by default */
.mobile-only { 
  display: block; 
}

.web-only { 
  display: none; 
}

/* Desktop adjustments - Higher breakpoint to prevent mobile landscape from showing desktop UI
   IMPORTANT: JavaScript will override this for mobile devices via html[data-is-mobile] */
@media (min-width: 1024px) {
  .box { 
    max-width: 720px; 
    gap: 16px; 
  }
  
  .center { 
    width: 320px; 
    height: auto; 
    min-height: 220px; 
  }
  
  /* Only apply desktop visibility if NOT explicitly marked as mobile by JS */
  html:not([data-is-mobile="true"]) .mobile-only { 
    display: none; 
  }
  
  html:not([data-is-mobile="true"]) .web-only { 
    display: block; 
  }
}

/* Force mobile view for explicitly marked mobile devices (Android/iOS)
   This overrides any media query.
   .error-message is excluded: this !important used to defeat the error box's
   inline display:none, permanently showing the error to every mobile user. */
html[data-is-mobile="true"] .mobile-only:not(.error-message) {
  display: block !important;
}

html[data-is-mobile="true"] .web-only {
  display: none !important;
}

/* Skip-store mode on mobile: give phones the same "web" experience as desktop
   (countdown + auto-redirect to the article) while keeping the store button as
   an optional way to get the app. Triggered by ?skip_store=1 in the URL.
   Higher specificity (extra [data-skip-store] attribute) overrides the rules
   above. The store button (#downloadBtn) stays visible via the default mobile
   rule; only the sales pitch and the redundant "continue in browser" button
   are hidden. */
html[data-is-mobile="true"][data-skip-store="true"] .web-only {
  display: block !important;
}

html[data-is-mobile="true"][data-skip-store="true"] .title.mobile-only {
  display: none !important;
}

html[data-is-mobile="true"][data-skip-store="true"] #continueWebBtn {
  display: none !important;
}

/* Manual way to the article, under the countdown.
   Deliberately quiet: the automatic redirect is the happy path, this is only
   for when it does not fire. Visibility comes from .web-only, so it follows
   the countdown — desktop, and skip-store mode on mobile. */
.manual-fallback {
  padding: 0 24px 4px;
  text-align: center;
  color: #8A8B8C;
  font-size: 13px;
  line-height: 20px;
}

.manual-fallback a {
  color: #595A5B;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.manual-fallback a:hover {
  color: #1B1B1C;
}

/* Lazy loading for images */
img[data-src] {
  opacity: 0;
  transition: opacity 0.3s;
}

img[data-src].loaded {
  opacity: 1;
}

/* Error Message Styles
   Hidden by default everywhere; only shown when JS adds .is-visible */
.error-message {
  display: none;
  transition: opacity 0.3s ease-in-out;
}

.error-message.is-visible {
  display: block !important;
}

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