/* Live product demo: iPhone/Android toggle over the real /feed/demo endpoint.
   Device bezels come from assets/vendor/devices.css; everything below is the
   screen content, toggle control, and section layout that sit on top of it. */

.live-demo {
  scroll-margin-top: 88px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(340px, 470px);
  gap: clamp(36px, 7vw, 92px);
  align-items: center;
  width: min(var(--max), calc(100% - 40px));
  margin: 0 auto;
  padding: clamp(56px, 8vw, 96px) 0;
}

.live-demo-copy {
  max-width: 640px;
}

.live-demo-copy .dek {
  font-size: clamp(17px, 1.6vw, 20px);
}

.live-demo-status {
  margin: 22px 0 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.live-demo-status[data-state="live"] {
  color: var(--green);
}

.live-demo-status[data-state="error"] {
  color: var(--rose);
}

/* --- Device toggle: a segmented pill with a sliding thumb --- */

.device-toggle {
  position: relative;
  display: inline-grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(96px, 1fr);
  margin-top: 30px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
}

.device-toggle-thumb {
  position: absolute;
  top: 4px;
  left: 4px;
  width: calc(50% - 4px);
  height: calc(100% - 8px);
  border-radius: 999px;
  background: var(--button);
  transition: transform .28s cubic-bezier(.4, 0, .2, 1);
}

.device-toggle[data-active="android"] .device-toggle-thumb {
  transform: translateX(100%);
}

.device-toggle-btn {
  position: relative;
  z-index: 1;
  padding: 10px 20px;
  border: 0;
  background: transparent;
  color: rgba(248, 251, 245, .68);
  font: inherit;
  font-size: 14px;
  font-weight: 800;
  cursor: pointer;
}

.device-toggle-btn[aria-selected="true"] {
  color: var(--button-ink);
}

.device-toggle-btn:focus-visible {
  outline: 2px solid var(--green);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  .device-toggle-thumb {
    transition: none;
  }
}

/* --- Phone stage: sizes and centers whichever device frame is visible --- */

.demo-stage {
  --phone-scale: .72;
  position: relative;
  width: calc(428px * var(--phone-scale));
  height: calc(868px * var(--phone-scale));
  margin: 0 auto;
  filter: drop-shadow(0 30px 70px rgba(0, 0, 0, .5));
}

.demo-stage .device {
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%) scale(var(--phone-scale));
  transform-origin: top center;
}

/* devices.css sets `display: block` on `.device` as a normal author rule, which otherwise
   always wins over the UA `[hidden]{display:none}` default regardless of specificity. */
.demo-stage .device[hidden] {
  display: none;
}

.demo-stage .device-screen {
  overflow: hidden;
  background: #060706;
}

/* --- Screen content: status bar + scroll-snapped card feed --- */

.demo-screen-inner {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  background: #0b0c0c;
  color: #f8fbf5;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.demo-status-bar {
  display: flex;
  flex: none;
  align-items: center;
  justify-content: space-between;
  height: 34px;
  padding: 0 20px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .02em;
}

.demo-status-icons {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.demo-status-icons .bars {
  display: inline-flex;
  align-items: flex-end;
  gap: 1.5px;
  height: 8px;
}

.demo-status-icons .bars span {
  width: 2.5px;
  background: currentColor;
  border-radius: 1px;
}

.demo-status-icons .bars span:nth-child(1) { height: 35%; }
.demo-status-icons .bars span:nth-child(2) { height: 60%; }
.demo-status-icons .bars span:nth-child(3) { height: 80%; }
.demo-status-icons .bars span:nth-child(4) { height: 100%; }

.demo-status-icons .battery {
  position: relative;
  width: 20px;
  height: 10px;
  border: 1px solid currentColor;
  border-radius: 2px;
  padding: 1.5px;
}

.demo-status-icons .battery::before {
  content: "";
  display: block;
  width: 78%;
  height: 100%;
  background: currentColor;
  border-radius: 1px;
}

.demo-status-icons .battery::after {
  content: "";
  position: absolute;
  top: 3px;
  right: -3px;
  width: 1.5px;
  height: 4px;
  background: currentColor;
  border-radius: 0 1px 1px 0;
}

.demo-feed {
  flex: 1;
  overflow-y: auto;
  scroll-snap-type: y mandatory;
  scrollbar-width: none;
}

.demo-feed::-webkit-scrollbar {
  display: none;
}

.demo-card {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  height: 100%;
  padding: 20px 18px 26px;
  background-color: #14231f;
  background-position: center;
  background-size: cover;
  scroll-snap-align: start;
  scroll-snap-stop: always;
}

.demo-card::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(6, 8, 7, 0) 38%, rgba(6, 8, 7, .78) 76%, rgba(6, 8, 7, .94) 100%);
}

.demo-card-top,
.demo-card-bottom {
  position: relative;
  z-index: 1;
}

.demo-card-top {
  position: absolute;
  top: 14px;
  left: 18px;
  right: 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.demo-chip {
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--green-soft);
  color: var(--green);
  font-size: 10px;
  font-weight: 900;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.demo-source {
  color: rgba(248, 251, 245, .72);
  font-size: 11px;
  font-weight: 800;
}

.demo-card-bottom h3 {
  margin: 0 0 8px;
  font-size: 20px;
  line-height: 1.2;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.demo-card-bottom p {
  margin: 0 0 16px;
  color: rgba(248, 251, 245, .78);
  font-size: 13.5px;
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.demo-card-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.demo-play {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border: 1px solid rgba(255, 255, 255, .3);
  border-radius: 50%;
  background: rgba(9, 10, 10, .55);
  backdrop-filter: blur(6px);
  color: #fff;
  cursor: pointer;
  flex: none;
}

.demo-play:focus-visible {
  outline: 2px solid var(--green);
  outline-offset: 2px;
}

.demo-play .icon-play {
  width: 0;
  height: 0;
  margin-left: 3px;
  border-style: solid;
  border-width: 6px 0 6px 10px;
  border-color: transparent transparent transparent currentColor;
}

.demo-play .icon-pause {
  display: none;
  gap: 3px;
}

.demo-play .icon-pause span {
  width: 3px;
  height: 13px;
  background: currentColor;
  border-radius: 1px;
}

.demo-play[data-playing="true"] .icon-play {
  display: none;
}

.demo-play[data-playing="true"] .icon-pause {
  display: flex;
}

.demo-duration {
  color: rgba(248, 251, 245, .68);
  font-size: 12px;
  font-weight: 700;
}

.demo-save-hint {
  margin-left: auto;
  color: rgba(248, 251, 245, .45);
  font-size: 11px;
  font-weight: 600;
}

/* --- Skeleton, empty, and error states --- */

.demo-card.demo-skeleton {
  background: linear-gradient(160deg, #14181a, #0d0f10);
}

.demo-skel-line {
  height: 14px;
  margin-bottom: 10px;
  border-radius: 6px;
  background: linear-gradient(90deg, rgba(255, 255, 255, .06), rgba(255, 255, 255, .14), rgba(255, 255, 255, .06));
  background-size: 200% 100%;
  animation: demo-shimmer 1.6s ease-in-out infinite;
}

.demo-skel-line.short { width: 58%; }
.demo-skel-line.medium { width: 82%; }

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

.demo-card.demo-message {
  align-items: center;
  text-align: center;
  padding: 40px 26px;
  background: linear-gradient(160deg, #151b19, #0c0e0d);
}

.demo-card.demo-message h3 {
  -webkit-line-clamp: unset;
}

.demo-card.demo-message p {
  -webkit-line-clamp: unset;
}

.demo-retry {
  padding: 10px 18px;
  border: 1px solid rgba(255, 255, 255, .28);
  border-radius: 999px;
  background: transparent;
  color: #fff;
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
}

/* --- Locked CTA card after the tenth story --- */

.demo-card.demo-locked {
  align-items: center;
  text-align: center;
  padding: 30px 24px;
  background-size: cover;
  background-position: center;
}

.demo-card.demo-locked::before {
  background: rgba(6, 8, 7, .82);
  backdrop-filter: blur(14px);
}

.demo-lock-icon {
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  margin-bottom: 16px;
  border-radius: 50%;
  background: var(--green-soft);
  color: var(--green);
}

.demo-card.demo-locked h3,
.demo-card.demo-locked p {
  position: relative;
  z-index: 1;
}

.demo-card.demo-locked h3 {
  -webkit-line-clamp: unset;
  font-size: 19px;
}

.demo-card.demo-locked p {
  -webkit-line-clamp: unset;
  font-size: 13px;
}

.demo-locked-stores {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
  margin-top: 6px;
}

.demo-store-link {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px;
  border: 1px solid rgba(255, 255, 255, .28);
  border-radius: 8px;
  background: var(--button);
  color: var(--button-ink);
  text-decoration: none;
  font-size: 13px;
  font-weight: 800;
}

.demo-store-link svg {
  width: 16px;
  height: 16px;
  fill: currentColor;
}

@media (max-width: 920px) {
  .live-demo {
    grid-template-columns: 1fr;
  }

  .demo-stage {
    margin-top: 12px;
  }
}

@media (max-width: 620px) {
  .live-demo {
    scroll-margin-top: 72px;
    width: min(100% - 28px, var(--max));
    padding: 44px 0;
  }

  .demo-stage {
    --phone-scale: .58;
  }

  .device-toggle {
    width: 100%;
    max-width: 280px;
  }
}
