/* The install page (web/index.html, install/install.js). Riva's own palette
   (lib/ui/theme/riva_colors.dart, dark) and typeface; the phone below draws
   Safari in its dark appearance. No inline styles anywhere: the page runs
   under style-src 'self'. */

@font-face {
  font-family: 'IRANYekanX';
  src: url('../assets/assets/fonts/IRANYekanX-Regular.ttf') format('truetype');
  font-weight: 400;
  font-display: swap;
}

@font-face {
  font-family: 'IRANYekanX';
  src: url('../assets/assets/fonts/IRANYekanX-DemiBold.ttf') format('truetype');
  font-weight: 600;
  font-display: swap;
}

@font-face {
  font-family: 'IRANYekanX';
  src: url('../assets/assets/fonts/IRANYekanX-Bold.ttf') format('truetype');
  font-weight: 700;
  font-display: swap;
}

:root {
  --bg: #001324;
  --bg-weak: #092033;
  --bg-soft: #12283c;
  --stroke: #1a3145;
  --text: #ffffff;
  --text-base: #d4d4d4;
  --text-sub: #8e8e93;
  --primary: #6895ff;
  --primary-a10: rgba(104, 149, 255, 0.1);
  --primary-a24: rgba(104, 149, 255, 0.24);
  --ice: #c7d9ff;
  --ios-sheet: #1c1c1e;
  --ios-row: #2c2c2e;
  --ios-text: #f2f2f7;
  --ios-sub: #8e8e93;
  --ios-blue: #0a84ff;
  --ios-green: #30d158;
}

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'IRANYekanX', -apple-system, system-ui, sans-serif;
}

.install {
  box-sizing: border-box;
  max-width: 460px;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 28px) 20px calc(env(safe-area-inset-bottom) + 40px);
}

.install[hidden],
.case[hidden] {
  display: none;
}

.sprite {
  display: none;
}

/* ── the page ───────────────────────────────────────────────────────── */

.brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 28px;
}

.brand__mark {
  width: 40px;
  height: 40px;
}

.brand__name {
  font-size: 22px;
  font-weight: 700;
}

h1 {
  margin: 0 0 12px;
  font-size: 22px;
  font-weight: 700;
  line-height: 1.6;
  text-align: center;
}

.lead {
  margin: 0;
  color: var(--text-base);
  font-size: 15px;
  line-height: 1.9;
  text-align: center;
}

/* An iOS label inside Persian text: kept whole, in iOS's own face. */
.ui {
  font-family: -apple-system, system-ui, sans-serif;
  font-weight: 600;
  white-space: nowrap;
  direction: ltr;
  unicode-bidi: isolate;
}

bdi.host {
  font-family: -apple-system, system-ui, sans-serif;
  direction: ltr;
  unicode-bidi: isolate;
}

.steps {
  margin: 0;
  padding: 0;
  list-style: none;
}

.step {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  margin-bottom: 10px;
  padding: 14px 16px;
  border: 1px solid var(--stroke);
  border-radius: 16px;
  background: var(--bg-weak);
  cursor: pointer;
  transition: border-color 0.3s, background-color 0.3s;
}

.step:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.step[aria-current='step'] {
  border-color: var(--primary);
  background: var(--primary-a10);
}

.step__num {
  flex: none;
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--bg-soft);
  color: var(--text-base);
  font-weight: 700;
  transition: background-color 0.3s, color 0.3s;
}

.step[aria-current='step'] .step__num {
  background: var(--primary);
  color: var(--bg);
}

.step strong {
  display: block;
  margin: 3px 0 4px;
  font-size: 16px;
  font-weight: 700;
}

.step p {
  margin: 0;
  color: var(--text-base);
  font-size: 14px;
  line-height: 1.85;
}

/* Safari 26 hides Share behind •••; Safari 18 shows it in the bar. Each
   step has both wordings, and only the one for this Safari shows. */
:root:not([data-ios='26']) .ios-26,
:root[data-ios='26'] .ios-18 {
  display: none !important;
}

.notes {
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid var(--stroke);
}

.notes p,
.hint {
  margin: 0 0 10px;
  color: var(--text-sub);
  font-size: 13px;
  line-height: 1.9;
}

.notes bdi.host {
  color: var(--text-base);
}

.address {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 24px 0 16px;
  padding: 12px 14px;
  border: 1px solid var(--stroke);
  border-radius: 14px;
  background: var(--bg-weak);
}

.address__host {
  overflow-wrap: anywhere;
  font-size: 15px;
}

.button {
  flex: none;
  padding: 10px 18px;
  border: 0;
  border-radius: 999px;
  background: var(--primary);
  color: var(--bg);
  font: inherit;
  font-size: 14px;
  font-weight: 700;
}

/* ── the phone ──────────────────────────────────────────────────────── */
/* A 210 × 438 screen. Every target a tap lands on sits at a fixed point,
   and the taps below are placed on those points, scene by scene. */

.phone {
  box-sizing: border-box;
  width: 228px;
  height: 456px;
  margin: 28px auto 26px;
  padding: 9px;
  border: 1px solid var(--stroke);
  border-radius: 40px;
  background: #000d18;
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.45), 0 0 0 6px rgba(104, 149, 255, 0.06);
}

.phone__screen {
  position: relative;
  overflow: hidden;
  width: 210px;
  height: 438px;
  border-radius: 31px;
  background: #000;
  direction: ltr;
  font-family: -apple-system, system-ui, sans-serif;
  color: var(--ios-text);
}

.scene {
  position: absolute;
  inset: 0;
}

.glyph {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.glyph--more {
  fill: currentColor;
  stroke: none;
}

/* Scene 1: Safari, showing this page. */

.page {
  position: absolute;
  inset: 0 0 60px;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-top: 92px;
  background: var(--bg);
}

.page__icon {
  width: 54px;
  height: 54px;
  margin-bottom: 18px;
  border-radius: 13px;
}

.page__line {
  width: 96px;
  height: 7px;
  margin-bottom: 9px;
  border-radius: 4px;
  background: var(--bg-soft);
}

.page__line--wide {
  width: 132px;
  height: 9px;
  background: #23405c;
}

.page__button {
  width: 150px;
  height: 26px;
  margin-top: 36px;
  border-radius: 13px;
  background: var(--primary);
  opacity: 0.85;
}

/* Safari 26's address bar floats over the page. */
:root[data-ios='26'] .page {
  bottom: 0;
}

.bar {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 60px;
  display: flex;
  align-items: center;
  background: rgba(30, 30, 32, 0.96);
  color: var(--ios-blue);
}

.bar--18 {
  justify-content: space-around;
  padding-bottom: 8px;
  box-sizing: border-box;
}

.bar--26 {
  display: none;
  gap: 8px;
  padding: 0 10px 10px;
  box-sizing: border-box;
  background: transparent;
}

:root[data-ios='26'] .bar--18 {
  display: none;
}

:root[data-ios='26'] .bar--26 {
  display: flex;
}

.bar--26 .glyph {
  flex: none;
  width: 34px;
  height: 34px;
  padding: 7px;
  box-sizing: border-box;
  border-radius: 50%;
  background: rgba(58, 58, 60, 0.95);
  color: var(--ios-text);
}

.pill {
  flex: 1;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 17px;
  background: rgba(58, 58, 60, 0.95);
  color: var(--ios-text);
  font-size: 11px;
}

.menu {
  position: absolute;
  right: 10px;
  bottom: 58px;
  width: 150px;
  overflow: hidden;
  border-radius: 14px;
  background: rgba(44, 44, 46, 0.98);
  opacity: 0;
  transform: scale(0.85);
  transform-origin: 90% 100%;
}

.menu__row {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 34px;
  padding: 0 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  font-size: 12px;
}

.menu__row .glyph {
  width: 16px;
  height: 16px;
}

/* Scene 2: the share sheet. */

.scene--sheet {
  top: 46px;
  padding: 12px 10px 0;
  border-radius: 16px 16px 0 0;
  background: var(--ios-sheet);
  transform: translateY(105%);
}

.sheet__head {
  display: flex;
  align-items: center;
  gap: 9px;
  height: 46px;
}

.sheet__icon {
  width: 34px;
  height: 34px;
  border-radius: 8px;
}

.sheet__title {
  display: flex;
  flex-direction: column;
  font-family: 'IRANYekanX', sans-serif;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.4;
}

.sheet__host {
  color: var(--ios-sub);
  font-size: 10px;
  font-weight: 400;
}

.sheet__apps {
  display: flex;
  gap: 12px;
  height: 56px;
  align-items: center;
  padding-left: 4px;
}

.sheet__apps i {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: #3a3a3c;
}

.sheet__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 36px;
  margin-top: 6px;
  padding: 0 12px;
  border-radius: 10px;
  background: var(--ios-row);
  font-size: 12px;
}

.sheet__row .glyph {
  width: 17px;
  height: 17px;
}

/* Scene 3: Add to Home Screen. */

.scene--add {
  top: 46px;
  border-radius: 16px 16px 0 0;
  background: var(--ios-sheet);
  transform: translateY(105%);
}

.add__nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  height: 44px;
  padding: 0 8px 0 12px;
  font-size: 11px;
  color: var(--ios-blue);
}

.add__nav b {
  color: var(--ios-text);
  font-size: 10px;
  white-space: nowrap;
}

.add__add {
  font-weight: 700;
  padding: 4px 6px;
  border-radius: 8px;
}

.add__card {
  display: flex;
  gap: 10px;
  align-items: center;
  margin: 0 10px;
  padding: 12px;
  border-radius: 12px;
  background: var(--ios-row);
}

.add__icon {
  width: 52px;
  height: 52px;
  border-radius: 12px;
}

.add__fields {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.add__name {
  font-family: 'IRANYekanX', sans-serif;
  font-size: 13px;
  font-weight: 700;
}

.add__host {
  color: var(--ios-sub);
  font-size: 10px;
}

.add__toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 40px;
  margin: 12px 10px 0;
  padding: 0 12px;
  border-radius: 12px;
  background: var(--ios-row);
  font-size: 12px;
}

.switch {
  position: relative;
  width: 36px;
  height: 22px;
  border-radius: 11px;
  background: var(--ios-green);
}

.switch::after {
  content: '';
  position: absolute;
  top: 2px;
  right: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
}

/* Scene 4: the Home Screen. */

.scene--home {
  opacity: 0;
  background:
    radial-gradient(circle at 20% 15%, #1d3b66 0, transparent 55%),
    radial-gradient(circle at 85% 80%, #2b1f4d 0, transparent 50%),
    #0b1424;
}

.home {
  display: grid;
  grid-template-columns: repeat(4, 40px);
  gap: 24px 6px;
  justify-content: space-between;
  padding: 50px 17px 0;
}

.home i,
.home__riva {
  width: 40px;
  height: 40px;
  border-radius: 10px;
}

.home i {
  background: rgba(255, 255, 255, 0.14);
}

.home__riva {
  transform: scale(0);
}

/* ── the scenes in turn ─────────────────────────────────────────────── */
/* Entering a scene animates; leaving it is instant, so the loop restarts
   cleanly from the first scene. */

.phone[data-scene='2'] .scene--sheet,
.phone[data-scene='3'] .scene--sheet {
  transform: none;
}

.phone[data-scene='2'] .scene--sheet {
  transition: transform 0.55s cubic-bezier(0.2, 0.8, 0.2, 1) 0.15s;
}

.phone[data-scene='3'] .scene--add {
  transform: none;
  transition: transform 0.55s cubic-bezier(0.2, 0.8, 0.2, 1) 0.15s;
}

.phone[data-scene='4'] .scene--home {
  opacity: 1;
  transition: opacity 0.45s ease 0.1s;
}

.phone[data-scene='4'] .home__riva {
  animation: pop 0.6s cubic-bezier(0.3, 1.6, 0.5, 1) 0.6s both;
}

:root[data-ios='26'] .phone[data-scene='1'] .menu {
  animation: menu-in 0.3s ease-out 1.35s both;
}

.phone[data-scene='1'] .bar--18 .glyph--share {
  animation: glow 0.8s ease 1.1s both;
}

:root[data-ios='26'] .phone[data-scene='1'] .menu__row--target {
  animation: flash 0.8s ease 2.6s both;
}

.phone[data-scene='2'] .sheet__row--target {
  animation: flash 0.8s ease 1.9s both;
}

.phone[data-scene='3'] .switch {
  animation: ring 1.2s ease 0.7s both;
}

.phone[data-scene='3'] .add__add {
  animation: flash-text 0.8s ease 2.3s both;
}

/* ── the taps ───────────────────────────────────────────────────────── */

.tap {
  position: absolute;
  z-index: 10;
  left: calc(var(--x, 0px) - 17px);
  top: calc(var(--y, 0px) - 17px);
  width: 34px;
  height: 34px;
  box-sizing: border-box;
  border: 2px solid rgba(255, 255, 255, 0.9);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.28);
  opacity: 0;
  pointer-events: none;
}

/* Scene 1, Safari 18: the share button. */
.phone[data-scene='1'] .tap--a {
  --x: 105px;
  --y: 404px;
  animation: tap-1 1.3s ease 0.5s both;
}

/* Scene 1, Safari 26: •••, then Share in its menu. */
:root[data-ios='26'] .phone[data-scene='1'] .tap--a {
  --x: 182px;
  --y: 404px;
  animation: tap-1 1.3s ease 0.2s both;
}

:root[data-ios='26'] .phone[data-scene='1'] .tap--b {
  --x: 110px;
  --y: 294px;
  animation: tap-1b 1.3s ease 2.1s both;
}

/* Scene 2: Add to Home Screen. */
.phone[data-scene='2'] .tap--a {
  --x: 105px;
  --y: 270px;
  animation: tap-2 1.3s ease 1.4s both;
}

/* Scene 3: Add. */
.phone[data-scene='3'] .tap--a {
  --x: 182px;
  --y: 70px;
  animation: tap-3 1.3s ease 1.8s both;
}

/* Scene 4: Riva's icon. */
.phone[data-scene='4'] .tap--a {
  --x: 173px;
  --y: 198px;
  animation: tap-4 1.3s ease 1.6s both;
}

/* One name per scene: an animation restarts only when its name changes. */
@keyframes tap-1 {
  0% { opacity: 0; transform: scale(1.7); }
  25% { opacity: 1; transform: scale(1); }
  40% { transform: scale(0.82); }
  55% { transform: scale(1); }
  100% { opacity: 0; transform: scale(1); }
}

@keyframes tap-1b {
  0% { opacity: 0; transform: scale(1.7); }
  25% { opacity: 1; transform: scale(1); }
  40% { transform: scale(0.82); }
  55% { transform: scale(1); }
  100% { opacity: 0; transform: scale(1); }
}

@keyframes tap-2 {
  0% { opacity: 0; transform: scale(1.7); }
  25% { opacity: 1; transform: scale(1); }
  40% { transform: scale(0.82); }
  55% { transform: scale(1); }
  100% { opacity: 0; transform: scale(1); }
}

@keyframes tap-3 {
  0% { opacity: 0; transform: scale(1.7); }
  25% { opacity: 1; transform: scale(1); }
  40% { transform: scale(0.82); }
  55% { transform: scale(1); }
  100% { opacity: 0; transform: scale(1); }
}

@keyframes tap-4 {
  0% { opacity: 0; transform: scale(1.7); }
  25% { opacity: 1; transform: scale(1); }
  40% { transform: scale(0.82); }
  55% { transform: scale(1); }
  100% { opacity: 0; transform: scale(1); }
}

@keyframes menu-in {
  from { opacity: 0; transform: scale(0.85); }
  to { opacity: 1; transform: none; }
}

@keyframes flash {
  0%, 100% { background-color: var(--ios-row); }
  40% { background-color: rgba(104, 149, 255, 0.45); }
}

@keyframes flash-text {
  0%, 100% { background-color: transparent; }
  40% { background-color: rgba(104, 149, 255, 0.45); }
}

@keyframes glow {
  0%, 100% { color: var(--ios-blue); transform: none; }
  45% { color: #fff; transform: scale(1.25); }
}

@keyframes ring {
  0%, 100% { box-shadow: 0 0 0 0 rgba(48, 209, 88, 0); }
  40% { box-shadow: 0 0 0 6px rgba(48, 209, 88, 0.35); }
}

@keyframes pop {
  from { transform: scale(0); }
  to { transform: scale(1); }
}

/* No motion: the scene a step shows, still, and only on a tap. */
@media (prefers-reduced-motion: reduce) {
  .phone *,
  .step,
  .step__num {
    animation: none !important;
    transition: none !important;
  }

  .tap {
    display: none;
  }

  :root[data-ios='26'] .phone[data-scene='1'] .menu,
  .home__riva {
    opacity: 1;
    transform: none;
  }
}
