/* Install screen (/install), in the sign-in page's Home style, and its link card in settings. */
.install {
  gap: 0.85rem;
}

/* Longer than a phone screen: start below the back button instead of centring off the top. */
body.auth-page #main-content:has(> .install) {
  justify-content: safe center;
  padding-block-start: calc(var(--navbar-height) + 0.25rem);
}

.install .auth__header {
  margin-block-end: 0.5rem;
}

/* The default icon's tile matches the page, so outline it the way a home screen shows it. */
.install__icon {
  outline: 1px solid color-mix(in srgb, var(--foreground) 16%, transparent);
  outline-offset: -1px;
}

.install .auth__subtitle {
  max-inline-size: 21rem;
  text-wrap: pretty;
}

.install__guide {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.install a.auth__button {
  text-decoration: none;
}

/* Shown once the browser offers its own install prompt. */
.install__native {
  display: none;

  .install--promptable & {
    display: flex;
  }
}

.install__devices {
  background: var(--card);
  border: 0;
  border-radius: 999px;
  display: grid;
  gap: 0.25rem;
  grid-template-columns: repeat(3, 1fr);
  margin: 0;
  min-inline-size: 0;
  padding: 0.25rem;
}

.install__device {
  align-items: center;
  block-size: 2.5rem;
  border-radius: 999px;
  color: var(--muted-foreground);
  cursor: pointer;
  display: flex;
  font-size: 0.875rem;
  font-weight: 600;
  gap: 0.4rem;
  justify-content: center;
  min-inline-size: 0;
  position: relative;
  transition: background-color 150ms ease, color 150ms ease;

  & input {
    appearance: none;
    inset: 0;
    margin: 0;
    position: absolute;
  }

  &:has(input:checked) {
    background: var(--primary);
    color: var(--primary-foreground);
  }

  &:has(input:focus-visible) {
    outline: 2px solid var(--ring, var(--foreground));
    outline-offset: 2px;
  }

  @media (max-width: 23rem) {
    & .icon {
      display: none;
    }
  }
}

.install__panel {
  display: none;
  flex-direction: column;
  gap: 0.6rem;
}

.install:has(input[value="ios"]:checked) .install__panel--ios,
.install:has(input[value="android"]:checked) .install__panel--android,
.install:has(input[value="desktop"]:checked) .install__panel--desktop {
  display: flex;
}

.install__steps {
  counter-reset: install-step;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  list-style: none;
  margin: 0;
  padding: 0;

  & > li {
    background: var(--card);
    border-radius: 1.1rem;
    counter-increment: install-step;
    font-size: 0.95rem;
    line-height: 1.5;
    min-block-size: 1.75rem;
    padding: 0.85rem 1rem 0.85rem 3.25rem;
    position: relative;
    text-wrap: pretty;
  }

  & > li::before {
    align-items: center;
    background: var(--secondary);
    block-size: 1.75rem;
    border-radius: 50%;
    content: counter(install-step);
    display: flex;
    font-size: 0.8rem;
    font-weight: 650;
    inline-size: 1.75rem;
    inset: 0.8rem auto auto 0.9rem;
    justify-content: center;
    position: absolute;
  }

  & strong {
    font-weight: 650;
  }
}

/* A browser control drawn inline, such as the Share button. */
.install__key {
  align-items: center;
  background: var(--secondary);
  border-radius: 0.5rem;
  display: inline-flex;
  margin-block: -0.2rem;
  padding: 0.2rem 0.3rem;
  vertical-align: middle;
}

.install__note {
  color: var(--muted-foreground);
  font-size: 0.85rem;
  line-height: 1.5;
  margin: 0.15rem 0.5rem 0;
  text-wrap: pretty;

  & strong {
    color: var(--foreground);
    font-weight: 600;
  }

  & a {
    color: var(--foreground);
    text-underline-offset: 0.2em;
  }
}

.install__callout,
.install__qr {
  align-items: center;
  background: var(--card);
  border-radius: 1.35rem;
  display: flex;
  gap: 0.85rem;
  padding: 1rem;

  & p {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    margin: 0;
  }

  & p span {
    color: var(--muted-foreground);
    font-size: 0.85rem;
    line-height: 1.45;
  }
}

.install__callout {
  background: color-mix(in srgb, var(--live) 22%, var(--card));

  & .icon {
    color: color-mix(in srgb, var(--live) 45%, white);
  }
}

.install__qr {
  flex-direction: column;
  text-align: center;

  & img {
    background: #fff;
    block-size: auto;
    border-radius: 1rem;
    inline-size: min(11rem, 60vw);
    padding: 0.6rem;
  }
}

.install__copy {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-block-start: 0.5rem;

  & code {
    background: var(--secondary);
    border-radius: 0.6rem;
    flex: 1 1 100%;
    font-size: 0.8rem;
    min-inline-size: 0;
    overflow-wrap: anywhere;
    padding: 0.55rem 0.7rem;
  }

  & .auth__button {
    block-size: 2.35rem;
    flex-shrink: 0;
    font-size: 0.875rem;
    inline-size: auto;
    padding-inline: 1rem;
  }
}

.install__copy-done,
.install__copied .install__copy-label {
  display: none;
}

.install__copied .install__copy-done {
  display: inline;
}

/* Installed: in the app itself, or just now from this page. */
.install__done {
  align-items: center;
  background: var(--card);
  border-radius: 1.35rem;
  display: none;
  flex-direction: column;
  gap: 0.75rem;
  outline: 0;
  padding: 1.25rem 1rem 1rem;
  text-align: center;

  & p {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    margin: 0;
  }

  & p span {
    color: var(--muted-foreground);
    font-size: 0.9rem;
  }
}

.install__done .install__done-icon {
  color: hsl(142 60% 60%);
}

/* Which message shows: .install--standalone in the app, .install--installed just after installing. */
.install__done .install__done-standalone {
  display: none;
}

.install--installed {
  .install__done {
    display: flex;
  }

  .install__guide {
    display: none;
  }
}

.install--standalone {
  .install__done,
  .install__done .install__done-standalone {
    display: flex;
  }

  .install__done .install__done-installed,
  .install__guide {
    display: none;
  }
}

@media (display-mode: standalone) {
  .install__done,
  .install__done .install__done-standalone {
    display: flex;
  }

  .install__done .install__done-installed,
  .install__guide {
    display: none;
  }
}

/* Settings and notifications link to /install. */
a.install-link {
  color: inherit;
  margin-block-end: 0.75rem;
  text-decoration: none;

  .settings-row {
    border: 0;
  }
}

.install-link__text {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  min-inline-size: 0;
}

.install-link__title {
  font-weight: 600;
}

.install-link__note {
  color: var(--muted-foreground);
  font-size: 0.8rem;
  font-weight: 400;
  line-height: 1.4;
}
