/*
 * App window: a real Sphen.ai screen inside the Shopify admin frame it lives
 * in. Shared by the homepage and every generated product page.
 *
 * The screens are captures of the live app (demo store, sample data). The
 * frame around them is plain HTML so it stays sharp at any width, and the
 * motion layer (src/motion/screen-stage.ts) drives pan, cursor, spotlight and
 * state changes through the `[data-screen-stage]` attributes. Without script,
 * or under reduced motion, the first frame simply sits still.
 */

.app-window {
  --stage-ratio: 1.56;
  --app-nav-width: 188px;
  position: relative;
  margin: 0;
  color: var(--color-text-primary);
}

.app-window__frame {
  overflow: hidden;
  border: 1px solid var(--color-border-default);
  border-radius: 14px;
  background: var(--color-surface-raised);
  box-shadow:
    0 1px 0 var(--color-overlay-white-80) inset,
    0 30px 80px -32px var(--color-shadow-strong),
    0 12px 28px -18px var(--color-shadow-medium);
}

.app-window__topbar {
  display: flex;
  min-height: 40px;
  align-items: center;
  gap: 12px;
  padding: 0 14px;
  background: var(--color-surface-inverse);
  color: var(--color-text-inverse-muted);
  font-size: 12px;
}

.app-window__search {
  display: flex;
  min-width: 0;
  height: 26px;
  flex: 0 1 320px;
  align-items: center;
  gap: 8px;
  margin: 0 auto;
  padding: 0 10px;
  border: 1px solid var(--color-border-inverse-subtle);
  border-radius: 8px;
  background: var(--color-overlay-white-06);
  color: var(--color-text-inverse-subtle);
  white-space: nowrap;
}

.app-window__search::before {
  width: 9px;
  height: 9px;
  flex: none;
  border: 1.5px solid currentColor;
  border-radius: 50%;
  content: "";
}

.app-window__store {
  display: inline-flex;
  flex: none;
  align-items: center;
  gap: 8px;
  color: var(--color-text-inverse);
  font-weight: 600;
  white-space: nowrap;
}

.app-window__avatar {
  display: inline-grid;
  width: 22px;
  height: 22px;
  place-items: center;
  border-radius: 6px;
  background: var(--color-glacier-blue);
  color: var(--color-text-inverse);
  font-size: 10px;
  font-weight: 750;
}

.app-window__body {
  display: grid;
  grid-template-columns: var(--app-nav-width) minmax(0, 1fr);
}

.app-window__nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 14px 10px;
  border-right: 1px solid var(--color-border-subtle);
  background: var(--color-surface-subtle);
  font-size: 12.5px;
}

.app-window__nav-app {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 8px;
  padding: 6px 8px;
  color: var(--color-text-primary);
  font-weight: 700;
}

.app-window__nav-app img {
  width: 20px;
  height: 20px;
  border-radius: 5px;
}

.app-window__nav-item {
  display: flex;
  min-height: 30px;
  align-items: center;
  padding: 0 10px;
  border-radius: 8px;
  color: var(--color-text-secondary);
  transition:
    background-color var(--duration-base) var(--ease-out),
    color var(--duration-base) var(--ease-out);
}

.app-window__nav-item.is-active {
  background: var(--color-surface-raised);
  color: var(--color-text-primary);
  font-weight: 650;
  box-shadow: 0 1px 2px var(--color-shadow-subtle);
}

.app-window__viewport {
  position: relative;
  overflow: hidden;
  aspect-ratio: var(--stage-ratio);
  background: var(--color-neutral-75);
  isolation: isolate;
}

.app-window__screen {
  position: absolute;
  inset: 0 0 auto;
  width: 100%;
  height: auto;
  max-width: none;
  opacity: 0;
  transform: translate3d(0, 0, 0);
  transition: opacity 520ms var(--ease-out);
  will-change: transform, opacity;
}

.app-window__screen.is-active {
  opacity: 1;
}

.app-window__viewport::after {
  position: absolute;
  inset: auto 0 0;
  z-index: 3;
  height: 48px;
  background: linear-gradient(
    180deg,
    var(--color-overlay-white-02) 0%,
    var(--color-neutral-75) 100%
  );
  content: "";
  pointer-events: none;
  opacity: 0.55;
}

.app-window__cursor {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 5;
  width: 22px;
  height: 22px;
  opacity: 0;
  transform: translate3d(-40px, -40px, 0);
  pointer-events: none;
  filter: drop-shadow(0 2px 3px var(--color-shadow-medium));
}

.app-window__cursor svg {
  display: block;
  width: 100%;
  height: 100%;
}

.app-window__cursor path {
  fill: var(--color-polar-ink);
  stroke: var(--color-white);
  stroke-width: 1.5;
}

.app-window__cursor.is-visible {
  opacity: 1;
}

.app-window__cursor.is-pressing svg {
  transform: scale(0.86);
  transform-origin: 3px 3px;
}

.app-window__ripple {
  position: absolute;
  z-index: 4;
  width: 34px;
  height: 34px;
  margin: -17px 0 0 -17px;
  border: 2px solid var(--color-emperor-orange);
  border-radius: 50%;
  opacity: 0;
  pointer-events: none;
}

.app-window__ripple.is-firing {
  animation: app-window-ripple 620ms var(--ease-out) forwards;
}

@keyframes app-window-ripple {
  0% {
    opacity: 0.9;
    transform: scale(0.35);
  }
  100% {
    opacity: 0;
    transform: scale(1.6);
  }
}

.app-window__spot {
  position: absolute;
  z-index: 3;
  border: 2px solid var(--color-emperor-orange);
  border-radius: 12px;
  box-shadow:
    0 0 0 4px var(--color-overlay-signal-24),
    0 0 0 100vmax var(--color-overlay-ink-10);
  opacity: 0;
  pointer-events: none;
  transition:
    opacity 360ms var(--ease-out),
    top 520ms var(--ease-out),
    left 520ms var(--ease-out),
    width 520ms var(--ease-out),
    height 520ms var(--ease-out);
}

.app-window__spot.is-visible {
  opacity: 1;
}

.app-window__label {
  position: absolute;
  z-index: 6;
  max-width: min(260px, 70%);
  padding: 8px 11px;
  border-radius: 10px;
  background: var(--color-surface-inverse);
  color: var(--color-text-inverse);
  font-size: 12.5px;
  font-weight: 600;
  line-height: 1.35;
  box-shadow: 0 10px 24px -12px var(--color-shadow-strong);
  opacity: 0;
  transform: translate3d(0, 6px, 0);
  transition:
    opacity 280ms var(--ease-out),
    transform 280ms var(--ease-out);
  pointer-events: none;
}

.app-window__label.is-visible {
  opacity: 1;
  transform: translate3d(0, 0, 0);
}

.app-window__caption {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 12px;
  color: var(--color-text-tertiary);
  font-size: var(--text-caption);
}

.app-window__caption span:first-child {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.app-window__caption span:first-child::before {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--color-emperor-orange);
  content: "";
}

.app-window__progress {
  position: relative;
  width: 72px;
  height: 2px;
  overflow: hidden;
  border-radius: 2px;
  background: var(--color-border-subtle);
}

.app-window__progress i {
  position: absolute;
  inset: 0;
  background: var(--color-text-primary);
  transform: scaleX(var(--stage-progress, 0));
  transform-origin: left;
}

/* The frame itself is not interactive, but it can sit inside a link card. */
.app-window a:focus-visible,
a:focus-visible > .app-window .app-window__frame {
  outline: 3px solid var(--color-focus-ring);
  outline-offset: 2px;
  box-shadow: 0 0 0 5px var(--color-focus-contrast);
}

.app-window--compact .app-window__body {
  grid-template-columns: minmax(0, 1fr);
}

.app-window--compact .app-window__nav {
  display: none;
}

.app-window--compact .app-window__topbar {
  min-height: 32px;
}

.app-window--compact .app-window__search {
  display: none;
}

@media (max-width: 900px) {
  .app-window__body {
    grid-template-columns: minmax(0, 1fr);
  }

  .app-window__nav {
    display: none;
  }
}

@media (max-width: 560px) {
  .app-window__search {
    display: none;
  }

  .app-window__store {
    margin-left: auto;
  }
}

@media (prefers-reduced-motion: reduce) {
  .app-window__screen,
  .app-window__spot,
  .app-window__label,
  .app-window__nav-item {
    transition: none;
  }

  .app-window__cursor,
  .app-window__ripple {
    display: none;
  }
}
