/* ==========================================================================
   TXB × MomentScience — Post-Purchase Demo
   ========================================================================== */

:root {
  --txb-orange: #E8581A;
  --txb-orange-dark: #C04A12;
  --txb-black: #1C1C1C;
  --txb-gray-bg: #F2F2F2;
  --txb-gray-border: #DDDDDD;
  --txb-text-dark: #2A2A2A;
  --txb-text-mid: #6B6B6B;
  --txb-text-light: #9A9A9A;
  --sheet-radius: 24px;
  --transition-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --transition-ease: cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

/* --------------------------------------------------------------------------
   Reset & base
   -------------------------------------------------------------------------- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  -webkit-text-size-adjust: 100%;
}

body, .demo-body {
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  min-height: 100vh;
  min-height: 100dvh;
  background: #0D0D0D;
  margin: 0;
  padding: 0;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow: hidden;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

/* --------------------------------------------------------------------------
   Desktop layout — centers the phone bezel
   -------------------------------------------------------------------------- */
@media (min-width: 768px) {
  .demo-body {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 20px;
    padding: 2rem;
    background: radial-gradient(ellipse at center, #1a1a1a 0%, #0D0D0D 100%);
    overflow: hidden;
  }
}

/* --------------------------------------------------------------------------
   Desktop label
   -------------------------------------------------------------------------- */
.desktop-label {
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  text-align: center;
  pointer-events: none;
  user-select: none;
}

@media (min-width: 768px) {
  .desktop-label {
    display: flex;
  }
}

.desktop-label-title {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.55);
}

.desktop-label-sub {
  font-size: 11px;
  font-weight: 400;
  letter-spacing: 0.04em;
  color: rgba(255, 255, 255, 0.28);
}

/* --------------------------------------------------------------------------
   iPhone frame — bezel on desktop, full-screen on mobile
   -------------------------------------------------------------------------- */
.iphone-frame {
  position: relative;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  display: flex;
  align-items: stretch;
  justify-content: center;
}

@media (min-width: 768px) {
  .iphone-frame {
    width: calc(375px + 28px);
    height: calc(812px + 28px);
    max-height: min(90vh, 840px);
    max-height: min(90dvh, 840px);
    padding: 14px;
    background: #1c1c1e;
    border-radius: 50px;
    box-shadow:
      0 0 0 1px rgba(255,255,255,0.08),
      0 40px 80px -20px rgba(0,0,0,0.7),
      0 20px 40px -10px rgba(0,0,0,0.5);
    align-items: center;
    flex-shrink: 0;
  }
}

@media (max-width: 767px) {
  .iphone-frame {
    border-radius: 0;
    background: #fff;
  }

  .dynamic-island {
    display: none !important;
  }
}

/* --------------------------------------------------------------------------
   Dynamic Island — desktop only
   -------------------------------------------------------------------------- */
.dynamic-island {
  display: none;
  position: absolute;
  top: 22px;
  left: 50%;
  transform: translateX(-50%);
  width: 120px;
  height: 34px;
  background: #000;
  border-radius: 20px;
  z-index: 200;
  pointer-events: none;
}

@media (min-width: 768px) {
  .dynamic-island {
    display: block;
  }
}

/* --------------------------------------------------------------------------
   Screen content container
   -------------------------------------------------------------------------- */
.screen-content {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--txb-gray-bg);
}

@media (min-width: 768px) {
  .screen-content {
    width: 375px;
    height: 812px;
    max-height: calc(min(90dvh, 840px) - 28px);
    border-radius: 38px;
    overflow: hidden;
  }
}

/* --------------------------------------------------------------------------
   Screens
   -------------------------------------------------------------------------- */
.screen {
  position: absolute;
  inset: 0;
  overflow: hidden;
}

.screen.hidden {
  display: none !important;
}

.screen.active {
  display: block;
}

@media (max-width: 767px) {
  .screen {
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overflow-x: hidden;
  }
}

/* --------------------------------------------------------------------------
   Screen images
   -------------------------------------------------------------------------- */
.screen-img-wrap {
  position: relative;
  width: 100%;
  height: 100%;
}

@media (max-width: 767px) {
  .screen-img-wrap {
    height: auto;
    min-height: 100dvh;
  }
}

.screen-img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top center;
  pointer-events: none;
  user-select: none;
  -webkit-user-drag: none;
}

@media (max-width: 767px) {
  .screen-img {
    height: auto;
    min-height: 100dvh;
  }
}

/* --------------------------------------------------------------------------
   Tap hotspots
   -------------------------------------------------------------------------- */
.hotspot {
  position: absolute;
  background: transparent;
  border: none;
  z-index: 10;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  min-width: 44px;
  min-height: 44px;
}

/* PLACE ORDER button — bottom strip of Screen 1 */
.hotspot-place-order {
  left: 0;
  right: 0;
  bottom: 0;
  height: 14%;
  width: 100%;
  z-index: 15;
}

/* Advance hotspot — covers bottom area of Screen 2 */
.hotspot-advance {
  left: 50%;
  transform: translateX(-50%);
  bottom: 24px;
  width: 60px;
  height: 60px;
  z-index: 35;
}

@media (max-width: 767px) {
  .hotspot-advance {
    bottom: calc(24px + env(safe-area-inset-bottom, 0px));
  }
}

/* Restart hotspot — full screen on Screen 3 */
.hotspot-restart {
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 10;
}

/* --------------------------------------------------------------------------
   Dim overlay
   -------------------------------------------------------------------------- */
.sheet-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s var(--transition-ease), visibility 0.3s;
  z-index: 20;
}

.sheet-overlay.visible {
  opacity: 1;
  visibility: visible;
}

/* --------------------------------------------------------------------------
   MomentScience bottom sheet
   -------------------------------------------------------------------------- */
.offers-sheet {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  background: #fff;
  border-radius: var(--sheet-radius) var(--sheet-radius) 0 0;
  box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.12);
  transform: translateY(102%);
  transition: transform 0.4s var(--transition-spring);
  display: flex;
  flex-direction: column;
  max-height: 60%;
  padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  will-change: transform;
}

@media (min-width: 768px) {
  .offers-sheet {
    max-height: 60%;
  }
}

.offers-sheet.open {
  transform: translateY(0);
}

/* Sheet handle */
.sheet-handle {
  width: 36px;
  height: 4px;
  background: var(--txb-gray-border);
  border-radius: 2px;
  margin: 10px auto 0;
  flex-shrink: 0;
}

/* Close button */
.sheet-close-btn {
  position: absolute;
  top: 14px;
  right: 16px;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--txb-gray-bg);
  border-radius: 50%;
  color: var(--txb-text-mid);
  flex-shrink: 0;
  z-index: 2;
}

@media (hover: hover) {
  .sheet-close-btn:hover {
    background: var(--txb-gray-border);
  }
}

.sheet-close-btn svg {
  width: 14px;
  height: 14px;
}

/* --------------------------------------------------------------------------
   Sheet header
   -------------------------------------------------------------------------- */
.sheet-header {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 16px 20px 12px;
  flex-shrink: 0;
}

.sheet-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--txb-text-dark);
  line-height: 1.25;
  letter-spacing: -0.02em;
}

.sheet-order-meta {
  font-size: 12px;
  color: var(--txb-text-light);
  font-weight: 400;
}

.points-counter {
  font-variant-numeric: tabular-nums;
  transition: color 0.15s;
  display: inline;
}

.points-counter.pulse {
  color: var(--txb-orange);
}

/* --------------------------------------------------------------------------
   Offer carousel
   -------------------------------------------------------------------------- */
.carousel-wrapper {
  flex-shrink: 0;
  overflow: hidden;
  position: relative;
}

.offers-carousel {
  display: flex;
  gap: 10px;
  height: 240px;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-snap-type: x mandatory;
  -webkit-scroll-snap-type: x mandatory;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
  padding: 4px 20px 4px;
  scroll-padding: 0 20px;
  -webkit-scroll-padding: 0 20px;
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
  touch-action: pan-x;
  overscroll-behavior-x: contain;
  -webkit-overscroll-behavior-x: contain;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.offers-carousel::-webkit-scrollbar {
  display: none;
}

.offers-carousel.dragging {
  scroll-snap-type: none;
  scroll-behavior: auto;
  cursor: grabbing;
}

/* Loading state */
.carousel-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  height: 100%;
  color: var(--txb-text-light);
  font-size: 13px;
  font-weight: 500;
}

.loading-spinner {
  width: 18px;
  height: 18px;
  border: 2px solid var(--txb-gray-border);
  border-top-color: var(--txb-orange);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  flex-shrink: 0;
}

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

/* --------------------------------------------------------------------------
   Offer card
   Card width = 100% - (2 × side padding) - peek = calc(100% - 72px)
   -------------------------------------------------------------------------- */
.offer-card {
  flex: 0 0 calc(100% - 72px);
  min-width: calc(100% - 72px);
  max-width: calc(100% - 72px);
  scroll-snap-align: center;
  scroll-snap-stop: always;
  height: 100%;
  background: #fff;
  border-radius: 14px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 2px 12px rgba(0,0,0,0.09), 0 0 0 1px rgba(0,0,0,0.05);
  flex-shrink: 0;
  transition: transform 0.15s var(--transition-ease), box-shadow 0.15s;
}

.offer-card:first-child {
  scroll-snap-align: start;
}

.offer-card:last-child {
  scroll-snap-align: end;
}

.offer-card:only-child {
  flex: 0 0 calc(100% - 40px);
  min-width: calc(100% - 40px);
  max-width: calc(100% - 40px);
  scroll-snap-align: center;
}

@media (hover: hover) {
  .offer-card:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(0,0,0,0.12), 0 0 0 1px rgba(0,0,0,0.05);
  }
}

/* Card hero image */
.offer-card-hero {
  width: 100%;
  height: 96px;
  flex-shrink: 0;
  background: var(--txb-gray-bg);
  overflow: hidden;
  position: relative;
}

.offer-card-hero img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center;
  display: block;
}

.offer-card-hero-fallback {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #f5f5f5 0%, #ebebeb 100%);
}

.offer-card-hero-fallback span {
  font-size: 28px;
}

/* Card body */
.offer-card-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 10px 12px 12px;
  gap: 4px;
  min-height: 0;
}

.offer-card-top-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.offer-card-advertiser {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--txb-text-mid);
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.offer-points-badge {
  display: flex;
  align-items: center;
  gap: 3px;
  background: rgba(232, 88, 26, 0.08);
  color: var(--txb-orange-dark);
  border-radius: 20px;
  padding: 3px 7px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.01em;
  white-space: nowrap;
  flex-shrink: 0;
}

.offer-points-badge svg {
  width: 9px;
  height: 9px;
  flex-shrink: 0;
}

.offer-card-headline {
  font-size: 13px;
  font-weight: 700;
  color: var(--txb-text-dark);
  line-height: 1.3;
  letter-spacing: -0.01em;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.offer-card-desc {
  font-size: 11px;
  color: var(--txb-text-mid);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  flex: 1;
}

/* Card footer: full-width single CTA */
.offer-card-footer {
  padding-top: 8px;
  border-top: 1px solid var(--txb-gray-bg);
  flex-shrink: 0;
}

.offer-cta-btn {
  background: var(--txb-black);
  color: #fff;
  border-radius: 8px;
  padding: 11px 14px;
  min-height: 44px;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  white-space: nowrap;
  transition: background 0.15s, opacity 0.15s;
}

@media (hover: hover) {
  .offer-cta-btn:hover {
    background: #333;
  }
}

.offer-cta-btn:active {
  opacity: 0.8;
}

.offer-cta-btn.loading {
  pointer-events: none;
  opacity: 0.7;
}

.offer-cta-btn .btn-spinner {
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

/* --------------------------------------------------------------------------
   Carousel dot indicators
   -------------------------------------------------------------------------- */
.carousel-dots {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 6px 20px 2px;
  flex-shrink: 0;
  min-height: 16px;
}

.carousel-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--txb-gray-border);
  transition: background 0.2s, transform 0.2s;
}

.carousel-dot.active {
  background: var(--txb-orange);
  transform: scale(1.3);
}

/* --------------------------------------------------------------------------
   Success toast
   -------------------------------------------------------------------------- */
.success-toast {
  position: absolute;
  top: 16px;
  left: 16px;
  right: 16px;
  background: var(--txb-black);
  color: #fff;
  border-radius: 12px;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  z-index: 50;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-8px);
  transition: opacity 0.25s var(--transition-ease), transform 0.25s var(--transition-ease), visibility 0.25s;
  box-shadow: 0 4px 20px rgba(0,0,0,0.25);
}

@media (max-width: 767px) {
  .success-toast {
    top: calc(16px + env(safe-area-inset-top, 0px));
  }
}

.success-toast.visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.toast-icon {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--txb-orange);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.toast-icon svg {
  width: 13px;
  height: 13px;
  color: #fff;
}

.toast-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.toast-primary {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.toast-secondary {
  font-size: 10px;
  color: rgba(255, 255, 255, 0.55);
  font-weight: 500;
  letter-spacing: 0.01em;
}

/* --------------------------------------------------------------------------
   Redeem screen points overlay
   -------------------------------------------------------------------------- */
.redeem-points-overlay {
  position: absolute;
  top: 13.5%;
  right: 0;
  left: 0;
  display: flex;
  justify-content: flex-end;
  padding-right: 6%;
  pointer-events: none;
  z-index: 5;
}

.redeem-points-value {
  font-size: 38px;
  font-weight: 900;
  color: #5A5A5A;
  letter-spacing: -0.04em;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

/* --------------------------------------------------------------------------
   Landscape guard
   -------------------------------------------------------------------------- */
.landscape-guard {
  display: none;
  position: fixed;
  inset: 0;
  background: #0D0D0D;
  z-index: 9999;
  align-items: center;
  justify-content: center;
}

@media (orientation: landscape) and (max-height: 500px) {
  .landscape-guard {
    display: flex;
  }
}

.landscape-guard-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  text-align: center;
  padding: 0 32px;
}

.landscape-icon {
  width: 48px;
  height: 48px;
  color: rgba(255,255,255,0.4);
}

.landscape-guard-inner p {
  font-size: 15px;
  color: rgba(255,255,255,0.5);
  font-weight: 500;
  line-height: 1.4;
  max-width: 240px;
}

/* --------------------------------------------------------------------------
   Points counter pulse animation
   -------------------------------------------------------------------------- */
@keyframes points-pulse {
  0% { transform: scale(1); }
  40% { transform: scale(1.12); }
  100% { transform: scale(1); }
}

.points-counter.animating {
  animation: points-pulse 0.3s var(--transition-spring);
}

/* --------------------------------------------------------------------------
   Reduced motion
   -------------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  .offers-sheet,
  .sheet-overlay,
  .success-toast,
  .offer-card,
  .points-counter {
    transition: none !important;
    animation: none !important;
  }

  .loading-spinner {
    animation: none;
    opacity: 0.5;
  }
}
