/* Phone Mode on a desktop browser (ls-phone-stage.js): the phone layout runs in an <iframe>
   inside a phone frame, centred on a soft animated stage. Real phones never get these classes. */

/* ---- Inside the phone frame ---------------------------------------------- */
html.ls-in-phone,
html.ls-in-phone body {
  scrollbar-width: none;
}

html.ls-in-phone::-webkit-scrollbar,
html.ls-in-phone body::-webkit-scrollbar {
  display: none;
}

/* ---- The stage page ------------------------------------------------------- */
html.ls-phone-staged {
  --ps-bg: #050b14;
  --ps-bg-2: #0a1830;
  --ps-glow-1: rgba(41, 121, 255, 0.34);
  --ps-glow-2: rgba(0, 200, 190, 0.22);
  --ps-glow-3: rgba(124, 92, 255, 0.24);
  --ps-line: rgba(140, 175, 230, 0.07);
  --ps-ring: rgba(120, 170, 255, 0.16);
  --ps-text: #eef3fa;
  --ps-muted: #8ea3bb;
  --ps-chip: rgba(255, 255, 255, 0.06);
  --ps-chip-line: rgba(255, 255, 255, 0.12);
  --ps-body: #1a1f27;
  --ps-body-edge: #3a4250;
  --ps-screen: #070f1a;
  --ps-status: #eef3fa;
  --ps-shadow: 0 40px 90px -20px rgba(0, 0, 0, 0.75), 0 0 0 1px rgba(255, 255, 255, 0.05);
  overflow: hidden;
  height: 100%;
  background: var(--ps-bg);
  color-scheme: dark;
}

html.ls-phone-staged[data-cp-theme="light"] {
  --ps-bg: #eaf0f8;
  --ps-bg-2: #d9e5f5;
  --ps-glow-1: rgba(31, 102, 242, 0.22);
  --ps-glow-2: rgba(0, 170, 160, 0.16);
  --ps-glow-3: rgba(124, 92, 255, 0.16);
  --ps-line: rgba(27, 40, 64, 0.06);
  --ps-ring: rgba(31, 102, 242, 0.14);
  --ps-text: #1b2840;
  --ps-muted: #5d6f87;
  --ps-chip: rgba(255, 255, 255, 0.7);
  --ps-chip-line: rgba(27, 40, 64, 0.1);
  --ps-body: #20252d;
  --ps-body-edge: #4a5262;
  --ps-screen: #f4f7fb;
  --ps-status: #1b2840;
  --ps-shadow: 0 40px 80px -24px rgba(20, 40, 80, 0.45), 0 0 0 1px rgba(27, 40, 64, 0.08);
  color-scheme: light;
}

/* The stage page never runs the app itself: everything but the stage stays hidden. */
html.ls-phone-staged body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--ps-bg);
}

html.ls-phone-staged body > :not(.ls-stage) {
  display: none !important;
}

.ls-stage {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 32px 24px;
  box-sizing: border-box;
  overflow: hidden;
  font-family: "Vazir", "Segoe UI", system-ui, -apple-system, sans-serif;
  color: var(--ps-text);
  background: radial-gradient(120% 90% at 50% 110%, var(--ps-bg-2) 0%, var(--ps-bg) 60%);
}

/* ---- Background ----------------------------------------------------------- */
.ls-stage-bg {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}

.ls-stage-glow {
  position: absolute;
  width: 46vmax;
  height: 46vmax;
  border-radius: 50%;
  filter: blur(70px);
  opacity: 0.9;
  animation: ps-drift 26s ease-in-out infinite alternate;
}

.ls-stage-glow.g1 { background: var(--ps-glow-1); top: -14vmax; inset-inline-start: -10vmax; }
.ls-stage-glow.g2 { background: var(--ps-glow-2); bottom: -18vmax; inset-inline-end: -12vmax; animation-duration: 32s; animation-delay: -8s; }
.ls-stage-glow.g3 { background: var(--ps-glow-3); top: 30%; inset-inline-end: 18%; width: 28vmax; height: 28vmax; animation-duration: 38s; animation-delay: -16s; }

.ls-stage-grid {
  position: absolute;
  inset: -2px;
  background-image:
    linear-gradient(var(--ps-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--ps-line) 1px, transparent 1px);
  background-size: 44px 44px;
  background-position: center center;
  -webkit-mask-image: radial-gradient(ellipse 70% 65% at 50% 50%, #000 30%, transparent 78%);
  mask-image: radial-gradient(ellipse 70% 65% at 50% 50%, #000 30%, transparent 78%);
}

/* Signal rings spreading out from behind the phone: the "sensor" idea of LSense. */
.ls-stage-ring {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 520px;
  height: 520px;
  margin: -260px 0 0 -260px;
  border-radius: 50%;
  border: 1px solid var(--ps-ring);
  opacity: 0;
  animation: ps-ring 9s cubic-bezier(0.2, 0.6, 0.3, 1) infinite;
}

.ls-stage-ring.r2 { animation-delay: -3s; }
.ls-stage-ring.r3 { animation-delay: -6s; }

.ls-stage-dot {
  position: absolute;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--ps-glow-1);
  box-shadow: 0 0 14px 4px var(--ps-glow-1);
  animation: ps-float 12s ease-in-out infinite alternate;
}

.ls-stage-dot.d1 { top: 22%; left: 18%; }
.ls-stage-dot.d2 { top: 68%; left: 78%; background: var(--ps-glow-2); box-shadow: 0 0 14px 4px var(--ps-glow-2); animation-delay: -4s; }
.ls-stage-dot.d3 { top: 80%; left: 24%; background: var(--ps-glow-3); box-shadow: 0 0 14px 4px var(--ps-glow-3); animation-delay: -8s; }

@keyframes ps-drift {
  0% { transform: translate3d(0, 0, 0) scale(1); }
  100% { transform: translate3d(6vmax, 4vmax, 0) scale(1.12); }
}

@keyframes ps-ring {
  0% { transform: scale(0.75); opacity: 0; }
  15% { opacity: 1; }
  100% { transform: scale(2.4); opacity: 0; }
}

@keyframes ps-float {
  0% { transform: translate3d(0, 0, 0); opacity: 0.5; }
  100% { transform: translate3d(18px, -26px, 0); opacity: 1; }
}

/* ---- Corner captions ------------------------------------------------------ */
.ls-stage-brand {
  position: absolute;
  top: 24px;
  inset-inline-start: 28px;
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: calc(50% - 250px);
  z-index: 1;
}

.ls-stage-brand img {
  width: 46px;
  height: 46px;
  padding: 6px;
  box-sizing: border-box;
  flex: none;
  border-radius: 14px;
  border: 1px solid var(--ps-chip-line);
  background: rgba(255, 255, 255, 0.92);
}

.ls-stage-brand div {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.ls-stage-brand strong {
  font-size: 15px;
  font-weight: 700;
}

.ls-stage-brand span {
  font-size: 12.5px;
  color: var(--ps-muted);
  line-height: 1.6;
}

.ls-stage-exit {
  position: absolute;
  top: 26px;
  inset-inline-end: 28px;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 16px;
  border-radius: 999px;
  border: 1px solid var(--ps-chip-line);
  background: var(--ps-chip);
  color: var(--ps-text);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  transition: background-color 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
}

.ls-stage-exit:hover {
  border-color: var(--ps-glow-1);
  transform: translateY(-1px);
}

.ls-stage-exit:focus-visible {
  outline: 2px solid #4a9bff;
  outline-offset: 3px;
}

.ls-stage-exit svg {
  width: 18px;
  height: 18px;
}

/* Not enough room beside the phone for the caption: keep only the logo. */
@media (max-width: 1180px) {
  .ls-stage-brand div {
    display: none;
  }
}

/* ---- The phone ------------------------------------------------------------- */
.ls-phone {
  /* A 390 x 844 screen plus a 12px bezel, shorter when the window is. */
  position: relative;
  z-index: 1;
  box-sizing: border-box;
  width: 414px;
  height: min(868px, calc(100dvh - 64px));
  padding: 12px;
  border-radius: 56px;
  background: linear-gradient(145deg, var(--ps-body-edge), var(--ps-body) 18%, var(--ps-body) 82%, var(--ps-body-edge));
  box-shadow:
    var(--ps-shadow),
    inset 0 0 0 2px rgba(255, 255, 255, 0.08),
    inset 0 0 0 6px rgba(0, 0, 0, 0.55);
  animation: ps-rise 0.7s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

.ls-phone-key {
  position: absolute;
  width: 4px;
  border-radius: 2px;
  background: var(--ps-body-edge);
}

.ls-phone-key.k1 { left: -3px; top: 150px; height: 34px; }
.ls-phone-key.k2 { left: -3px; top: 200px; height: 62px; }
.ls-phone-key.k3 { right: -3px; top: 180px; height: 90px; }

.ls-phone-screen {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  overflow: hidden;
  border-radius: 44px;
  background: var(--ps-screen);
  /* Keeps the rounded clip on the iframe in Safari/Chrome compositing. */
  isolation: isolate;
  transform: translateZ(0);
}

.ls-phone-status {
  position: relative;
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 46px;
  padding: 4px 30px 0;
  box-sizing: border-box;
  direction: ltr;
  color: var(--ps-status);
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.ls-phone-status time {
  min-width: 54px;
  text-align: center;
}

.ls-phone-island {
  position: absolute;
  top: 10px;
  left: 50%;
  width: 112px;
  height: 31px;
  margin-left: -56px;
  border-radius: 999px;
  background: #000;
}

/* Front camera lens. */
.ls-phone-island::after {
  content: "";
  position: absolute;
  top: 50%;
  right: 12px;
  width: 9px;
  height: 9px;
  margin-top: -4.5px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #2c4a78 0%, #0d1830 55%, #05080f 100%);
}

.ls-phone-icons {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.ls-phone-icons svg {
  height: 11px;
  width: auto;
  fill: currentColor;
}

.ls-phone-battery {
  position: relative;
  width: 24px;
  height: 11px;
  border: 1.4px solid currentColor;
  border-radius: 3.5px;
  opacity: 0.95;
  box-sizing: border-box;
}

.ls-phone-battery::after {
  content: "";
  position: absolute;
  top: 2.5px;
  right: -4px;
  width: 2px;
  height: 4px;
  border-radius: 0 1px 1px 0;
  background: currentColor;
}

.ls-phone-battery i {
  position: absolute;
  inset: 1.4px;
  width: 72%;
  border-radius: 1.5px;
  background: currentColor;
}

.ls-phone-frame {
  flex: 1;
  display: block;
  width: 100%;
  min-height: 0;
  border: 0;
  background: var(--ps-screen);
}

.ls-phone-home {
  position: absolute;
  bottom: 8px;
  left: 50%;
  width: 128px;
  height: 5px;
  margin-left: -64px;
  border-radius: 3px;
  background: var(--ps-status);
  opacity: 0.55;
  pointer-events: none;
}

@keyframes ps-rise {
  from { opacity: 0; transform: translateY(24px) scale(0.98); }
  to { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  .ls-stage-glow,
  .ls-stage-ring,
  .ls-stage-dot,
  .ls-phone {
    animation: none;
  }

  .ls-stage-ring.r1 {
    opacity: 1;
    transform: scale(1.3);
  }
}
