/* The install walkthrough at /help/install (TEA-718).
 *
 * The animation is CSS on a mock-up, not a GIF or a video: an email client
 * strips animation, so the moving picture has to live on a page, and an
 * external asset would be one more thing to load on a phone at a field with
 * one bar of signal.
 *
 * One 8s cycle drives every element, each with its own percentages, so the
 * taps, the sheet and the icon stay in step with each other. The BASE state
 * of every piece is the LAST frame -- home screen showing, icon in place,
 * sheet away -- so prefers-reduced-motion only has to switch the animations
 * off to leave a correct still picture beside the numbered steps.
 */

.install-guide {
  max-width: 900px;
  margin: 0 auto;
  padding: var(--space-6) var(--space-4) var(--space-10);
}
.install-guide-header { margin-bottom: var(--space-6); }
.install-guide-title {
  margin: 0 0 var(--space-2);
  font-size: var(--text-2xl);
  font-weight: var(--weight-semibold);
  color: var(--color-text);
}
.install-guide-lead {
  margin: 0;
  font-size: var(--text-md);
  line-height: 1.6;
  color: var(--color-text-muted);
}
.install-guide-panel { padding-top: var(--space-5); }
.install-guide-panel[hidden] { display: none; }
.install-guide-split {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: var(--space-6);
  align-items: start;
}
.install-guide-split > * { min-width: 0; }
.install-guide-steps {
  margin: 0;
  padding-left: var(--space-5);
  display: grid;
  gap: var(--space-3);
  font-size: var(--text-md);
  line-height: 1.6;
  color: var(--color-text-body);
}
.install-guide-steps strong {
  color: var(--color-text);
  font-weight: var(--weight-semibold);
}
.install-guide-cta { margin: var(--space-8) 0 0; }
.install-guide-help {
  margin: var(--space-4) 0 0;
  font-size: var(--text-sm);
  color: var(--color-text-muted);
}

/* --- the phone ------------------------------------------------------- */

.install-phone {
  --install-cycle: 8s;
  justify-self: center;
  width: 240px;
  max-width: 100%;
  padding: var(--space-2);
  background: var(--color-primary);
  border: 1px solid var(--color-border);
  border-radius: var(--space-6);
  box-shadow: var(--color-shadow);
}
.install-phone-screen {
  position: relative;
  overflow: hidden;
  height: 420px;
  display: flex;
  flex-direction: column;
  background: var(--color-bg);
  border-radius: var(--space-5);
}
.install-phone-notch {
  position: absolute;
  top: var(--space-1);
  left: 50%;
  width: 64px;
  height: 6px;
  margin-left: -32px;
  border-radius: var(--radius-pill);
  background: var(--color-primary-light);
}

/* The page behind: a suggestion of content, never real copy. */
.install-phone-page {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  padding: var(--space-5) var(--space-3) var(--space-3);
}
.install-phone-line {
  height: 8px;
  border-radius: var(--radius-pill);
  background: var(--color-border);
}
.install-phone-line-short { width: 60%; }
.install-phone-card {
  height: 56px;
  border-radius: var(--radius-md);
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
}

/* The browser chrome. */
.install-phone-bar {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  background: var(--color-surface);
  border-top: 1px solid var(--color-border);
}
.install-phone-bar-top {
  border-top: 0;
  border-bottom: 1px solid var(--color-border);
  margin-top: var(--space-4);
}
.install-phone-url {
  flex: 1;
  overflow: hidden;
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-pill);
  background: var(--color-bg-card);
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  white-space: nowrap;
}
.install-phone-control {
  flex: none;
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  font-size: var(--text-md);
  color: var(--color-text);
}

/* The share sheet / the Chrome menu. Base state: away. */
.install-phone-sheet {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  padding: var(--space-3);
  background: var(--color-bg-card);
  border-top: 1px solid var(--color-border);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  opacity: 0;
  transform: translateY(100%);
}
.install-phone-menu {
  top: var(--space-8);
  right: var(--space-2);
  bottom: auto;
  left: auto;
  width: 150px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  transform: translateY(-8px) scale(0.9);
  transform-origin: top right;
}
.install-phone-grab {
  align-self: center;
  width: 36px;
  height: 4px;
  border-radius: var(--radius-pill);
  background: var(--color-border);
}
.install-phone-row {
  padding: var(--space-2);
  border-radius: var(--radius-sm);
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}
.install-phone-row-target {
  color: var(--color-text);
  font-weight: var(--weight-semibold);
  background: var(--color-accent-subtle);
}

/* The home screen, revealed at the end. Base state: the final frame. */
.install-phone-home {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  align-content: start;
  gap: var(--space-4);
  padding: var(--space-8) var(--space-4);
  background: var(--color-surface);
}
.install-phone-app {
  aspect-ratio: 1;
  border-radius: var(--radius-lg);
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
}
.install-phone-app-tc {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-accent);
  border-color: var(--color-accent);
  color: var(--color-on-accent);
  font-size: var(--text-sm);
  font-weight: var(--weight-bold);
}

/* The tap. Base state: gone. */
.install-phone-tap {
  position: absolute;
  width: 26px;
  height: 26px;
  border-radius: var(--radius-full);
  border: 2px solid var(--color-accent);
  opacity: 0;
}
.install-phone-tap-ios-share { right: var(--space-3); bottom: var(--space-3); }
.install-phone-tap-android-menu { right: var(--space-3); top: var(--space-5); }
.install-phone-tap-row { left: 50%; bottom: 96px; margin-left: -13px; }
.install-phone-android .install-phone-tap-row { left: auto; right: var(--space-4); top: 88px; bottom: auto; margin-left: 0; }

/* --- the cycle -------------------------------------------------------- */

@keyframes install-tap {
  0%, 10% { opacity: 0; transform: scale(0.4); }
  13% { opacity: 1; transform: scale(1); }
  22% { opacity: 0; transform: scale(1.6); }
  100% { opacity: 0; transform: scale(1.6); }
}
@keyframes install-tap-late {
  0%, 40% { opacity: 0; transform: scale(0.4); }
  43% { opacity: 1; transform: scale(1); }
  52% { opacity: 0; transform: scale(1.6); }
  100% { opacity: 0; transform: scale(1.6); }
}
@keyframes install-sheet-cycle {
  0%, 18% { opacity: 0; transform: translateY(100%); }
  28%, 58% { opacity: 1; transform: translateY(0); }
  66%, 100% { opacity: 0; transform: translateY(100%); }
}
@keyframes install-menu-cycle {
  0%, 18% { opacity: 0; transform: translateY(-8px) scale(0.9); }
  28%, 58% { opacity: 1; transform: translateY(0) scale(1); }
  66%, 100% { opacity: 0; transform: translateY(-8px) scale(0.9); }
}
@keyframes install-page-cycle {
  0%, 58% { opacity: 1; }
  68%, 100% { opacity: 0; }
}
@keyframes install-home-cycle {
  0%, 60% { opacity: 0; }
  70%, 100% { opacity: 1; }
}
@keyframes install-icon-cycle {
  0%, 70% { opacity: 0; transform: scale(0.4); }
  78% { opacity: 1; transform: scale(1.15); }
  84%, 100% { opacity: 1; transform: scale(1); }
}

.install-phone-sheet { animation: install-sheet-cycle var(--install-cycle) infinite; }
.install-phone-menu { animation-name: install-menu-cycle; }
.install-phone-home { animation: install-home-cycle var(--install-cycle) infinite; }
.install-phone-app-tc { animation: install-icon-cycle var(--install-cycle) infinite; }
.install-phone-tap-ios-share,
.install-phone-tap-android-menu { animation: install-tap var(--install-cycle) infinite; }
.install-phone-tap-row { animation: install-tap-late var(--install-cycle) infinite; }
/* The browser chrome and the page it shows go with the home screen. */
.install-phone-page,
.install-phone-bar { animation: install-page-cycle var(--install-cycle) infinite; }

/* A still picture of the last frame, beside the steps, which say the same
   thing in words. */
@media (prefers-reduced-motion: reduce) {
  .install-phone-sheet,
  .install-phone-menu,
  .install-phone-home,
  .install-phone-app-tc,
  .install-phone-tap,
  .install-phone-page,
  .install-phone-bar { animation: none; }
  .install-phone-home { opacity: 1; }
  .install-phone-app-tc { opacity: 1; transform: none; }
  .install-phone-page,
  .install-phone-bar { opacity: 0; }
}
