/* ============================================================================================
 * "Install app" — the controls, the steps sheet (js/install.js) and the /install/ page.
 *
 * Loaded by every page that can be installed from: the welcome screen, the concierge, /install/
 * and both manager pages. Every rule is under an `av-install` class, so nothing here reaches into a
 * page's own styles, and every colour is one of the nine brand colours (Accent is the only action
 * colour). Type is inherited from the page, so Bengali and Devanagari keep each page's own faces.
 *
 * Touch targets are 44px. Focus is a visible 2px ring. Motion is one short rise of the sheet, and
 * none at all under `prefers-reduced-motion`.
 * ========================================================================================== */

.av-install-layer,
.av-install-page,
.av-install-trigger {
  --avi-page: #fdf4ee;
  --avi-card: #ffffff;
  --avi-wash: #ffe4d5;
  --avi-sky: #ffd9c4;
  --avi-accent: #c0492b; /* 4.97:1 against Card — AA for the button's white text */
  --avi-plum: #4a2340;
  --avi-ink: #2a1226;
  --avi-surface: var(--avi-card);
  --avi-text: var(--avi-ink);
  --avi-soft: var(--avi-plum);
  --avi-line: var(--avi-sky);
  --avi-chip: var(--avi-wash);
  --avi-on-accent: var(--avi-card);
  --avi-focus: var(--avi-plum);
}

:root[data-theme="dark"] .av-install-layer,
:root[data-theme="dark"] .av-install-trigger {
  --avi-surface: var(--avi-ink);
  --avi-text: var(--avi-page);
  --avi-soft: var(--avi-sky);
  --avi-line: var(--avi-plum);
  --avi-chip: var(--avi-plum);
  --avi-focus: var(--avi-sky);
}

.av-install-trigger[hidden],
.av-install-layer [hidden] {
  display: none !important;
}

.av-install-glyph {
  width: 20px;
  height: 20px;
  flex: none;
}

/* ── The quiet control: under the welcome screen's CTA and under the desk sign-in form ─────── */

.av-install-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  margin: 10px auto 0;
  padding: 0 14px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--avi-soft);
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

.av-install-link span {
  text-decoration: underline;
  text-decoration-color: color-mix(in srgb, currentColor 40%, transparent);
  text-underline-offset: 3px;
}

.av-install-link:hover {
  background: var(--avi-chip);
}

.av-install-link:focus-visible,
.av-install-desk:focus-visible,
.av-install-cta:focus-visible,
.av-install-layer button:focus-visible,
.av-install-page a:focus-visible {
  outline: 2px solid var(--avi-focus);
  outline-offset: 2px;
}

/* The welcome card centres its one action; this sits under it on its own line. */
.welcome-card .av-install-link {
  display: flex;
}

/* The desk sign-in form is left-aligned; so is its install line. */
.mlogin-form-inner .av-install-link {
  margin: 14px 0 0 -14px;
}

/* ── The desk's rail row: the dashboard's own "Dark mode" row (.side-theme), with a glyph where
 *    that row has its switch ────────────────────────────────────────────────────────────────── */

.av-install-desk .av-install-glyph {
  width: 18px;
  height: 18px;
}

.av-install-desk:focus-visible {
  outline-color: currentColor;
}

/* ── The page's own button (/install/) ───────────────────────────────────────────────────── */

.av-install-cta {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 48px;
  padding: 0 22px;
  border: 0;
  border-radius: 11px;
  background: var(--avi-accent);
  color: var(--avi-on-accent);
  font: inherit;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
}

/* Hover keeps the Accent fill — it is the only action colour — and lifts instead. */
.av-install-cta:hover {
  box-shadow: 0 6px 16px rgb(42 18 38 / 24%);
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* ── The sheet ───────────────────────────────────────────────────────────────────────────── */

:root.av-install-open {
  overflow: hidden;
}

.av-install-layer {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0;
  background: rgb(42 18 38 / 48%); /* Ink */
}

.av-install-sheet {
  box-sizing: border-box;
  width: 100%;
  max-height: calc(100dvh - 24px);
  overflow-y: auto;
  padding: 20px 20px calc(20px + env(safe-area-inset-bottom, 0px));
  border-radius: 20px 20px 0 0;
  background: var(--avi-surface);
  box-shadow: 0 -12px 40px rgb(42 18 38 / 24%);
  color: var(--avi-text);
  font-size: 16px;
  line-height: 1.5;
  animation: av-install-rise 220ms cubic-bezier(0.2, 0.7, 0.2, 1) both;
}

/* On a dark page the sheet's Ink would melt into the page behind it; a Plum edge keeps it a sheet. */
:root[data-theme="dark"] .av-install-sheet {
  box-shadow:
    0 0 0 1px var(--avi-plum),
    0 -12px 40px rgb(0 0 0 / 40%);
}

@media (min-width: 600px) {
  .av-install-layer {
    align-items: center;
    padding: 24px;
  }

  .av-install-sheet {
    max-width: 460px;
    padding: 24px;
    border-radius: 20px;
    box-shadow: 0 24px 60px rgb(42 18 38 / 28%);
  }
}

@keyframes av-install-rise {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
}

@media (prefers-reduced-motion: reduce) {
  .av-install-sheet {
    animation: none;
  }
}

.av-install-head {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.av-install-appicon {
  width: 44px;
  height: 44px;
  border-radius: 10px;
}

.av-install-title {
  margin: 0;
  color: var(--avi-text);
  font-size: 19px;
  font-weight: 700;
  line-height: 1.3;
}

.av-install-title:focus {
  outline: none;
}

.av-install-title:focus-visible {
  outline: 2px solid var(--avi-focus);
  outline-offset: 4px;
  border-radius: 4px;
}

.av-install-close {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  margin: -6px -6px 0 0;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--avi-soft);
  cursor: pointer;
}

.av-install-close:hover {
  background: var(--avi-chip);
}

.av-install-close-icon {
  width: 22px;
  height: 22px;
}

.av-install-body {
  margin: 0 0 12px;
  color: var(--avi-text);
}

.av-install-steps {
  display: grid;
  gap: 10px;
  margin: 0 0 12px;
  padding: 0;
  list-style: none;
}

.av-install-step {
  display: grid;
  grid-template-columns: 30px 1fr auto;
  align-items: start;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--avi-line);
  border-radius: 14px;
}

.av-install-num {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 999px;
  background: var(--avi-chip);
  color: var(--avi-text);
  font-size: 15px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.av-install-text {
  align-self: center;
}

.av-install-hint {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--avi-chip);
  color: var(--avi-text);
}

.av-install-note {
  margin: 0 0 16px;
  color: var(--avi-soft);
  font-size: 14px;
}

.av-install-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
}

.av-install-primary {
  min-height: 44px;
  padding: 0 22px;
  border: 0;
  border-radius: 11px;
  background: var(--avi-accent);
  color: var(--avi-on-accent);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.av-install-primary:hover {
  box-shadow: 0 6px 16px rgb(42 18 38 / 24%);
  text-decoration: underline;
  text-underline-offset: 3px;
}

:root[data-theme="dark"] .av-install-primary:hover {
  box-shadow: 0 6px 16px rgb(0 0 0 / 45%);
}

.av-install-quiet {
  min-height: 44px;
  padding: 0 8px;
  border: 0;
  background: transparent;
  color: var(--avi-soft);
  font: inherit;
  font-size: 14px;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}

.av-install-sr {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* ============================================================================================
 * THE /install/ PAGE — one column of cards on the Page colour. Light only, like the welcome
 * screen: a page read once, not an app surface someone lives in.
 * ========================================================================================== */

.av-install-page {
  margin: 0;
  min-height: 100dvh;
  background: var(--avi-page);
  color: var(--avi-ink);
  /* The guest app's own stack (css/tokens.css, as css/layout.css sets it on the concierge): the
     self-hosted Indic faces first for the scripts they cover, then the Latin sans. */
  font-family: var(--font-indic, "Noto Sans Bengali", "Noto Sans Devanagari", "Segoe UI", "Noto Sans", system-ui, sans-serif);
  font-size: 16px;
  line-height: 1.55;
}

.av-install-page *,
.av-install-page *::before,
.av-install-page *::after {
  box-sizing: border-box;
}

.avp-skip {
  position: absolute;
  left: 12px;
  top: -60px;
  padding: 10px 14px;
  border-radius: 11px;
  background: var(--avi-ink);
  color: var(--avi-card);
}

.avp-skip:focus {
  top: 12px;
}

.avp-wrap {
  width: min(100%, 760px);
  margin: 0 auto;
  padding: 20px 18px 56px;
}

.avp-top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 28px;
}

.avp-brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--avi-ink);
  text-decoration: none;
}

.avp-brand img {
  width: 40px;
  height: 40px;
}

.avp-word {
  font-family: var(--font-serif, "Cormorant Garamond", Georgia, serif);
  font-size: 26px;
  line-height: 1;
}

.avp-word .wm-a {
  font-weight: 600;
}

.avp-word .wm-v {
  color: var(--avi-accent);
  font-weight: 400;
}

/* The language switch (js/lang_choice.js): three toggle buttons in a pill. */
.avp-lang .lang-switch {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--avi-sky);
  border-radius: 999px;
  background: var(--avi-card);
}

.avp-lang .lang-switch-btn {
  min-width: 44px;
  min-height: 40px;
  padding: 0 14px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--avi-plum);
  font: inherit;
  font-size: 15px;
  cursor: pointer;
}

.avp-lang .lang-switch-btn[aria-pressed="true"] {
  background: var(--avi-plum);
  color: var(--avi-card);
}

.avp-lang .lang-switch-btn:focus-visible {
  outline: 2px solid var(--avi-plum);
  outline-offset: 2px;
}

.avp-title {
  margin: 0 0 8px;
  color: var(--avi-plum);
  font-family: var(--font-serif, "Cormorant Garamond", Georgia, serif);
  font-size: clamp(32px, 7vw, 44px);
  font-weight: 600;
  line-height: 1.1;
}

.avp-lead {
  max-width: 60ch;
  margin: 0 0 20px;
  font-size: 17px;
}

.avp-hero-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 16px;
  margin-bottom: 36px;
}

.avp-installed {
  margin: 0;
  padding: 10px 14px;
  border-radius: 11px;
  background: var(--avi-wash);
  color: var(--avi-plum);
  font-weight: 600;
}

.avp-section {
  margin: 0 0 36px;
}

.avp-h2 {
  margin: 0 0 6px;
  color: var(--avi-plum);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

/* Letter-spacing and capitals are for Latin only: spaced Devanagari or Bengali breaks its joins. */
html:not([lang="en"]) .avp-h2,
html:not([lang="en"]) .avp-here {
  font-size: 15px;
  letter-spacing: 0;
  text-transform: none;
}

.avp-section-lead {
  margin: 0 0 14px;
}

.avp-cards {
  display: grid;
  gap: 14px;
}

.avp-card {
  position: relative;
  padding: 18px;
  border: 1px solid var(--avi-sky);
  border-radius: 14px;
  background: var(--avi-card);
}

.avp-card[data-here="1"] {
  border-color: var(--avi-plum);
  box-shadow: 0 0 0 1px var(--avi-plum);
}

.avp-h3 {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 10px;
  margin: 0 0 10px;
  color: var(--avi-ink);
  font-size: 18px;
  font-weight: 700;
  line-height: 1.3;
}

.avp-here {
  padding: 2px 10px;
  border-radius: 999px;
  background: var(--avi-plum);
  color: var(--avi-card);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.avp-card p {
  margin: 0 0 10px;
}

.avp-card p:last-child {
  margin-bottom: 0;
}

.avp-card .av-install-steps {
  margin-bottom: 0;
}

.avp-card .av-install-step {
  --avi-line: var(--avi-wash);
  --avi-chip: var(--avi-wash);
}

.avp-note {
  color: var(--avi-plum);
  font-size: 14px;
}

.avp-link {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  color: var(--avi-accent);
  font-weight: 600;
  text-underline-offset: 3px;
  overflow-wrap: anywhere;
}

.avp-qr {
  display: grid;
  grid-template-columns: 160px 1fr;
  align-items: center;
  gap: 18px;
}

.avp-qr img {
  width: 160px;
  height: 160px;
  border-radius: 10px;
  background: var(--avi-card);
}

.avp-qr[data-qr="off"] {
  grid-template-columns: 1fr;
}

.avp-url {
  font-family: var(--font-mono, ui-monospace, Menlo, Consolas, monospace);
  font-size: 15px;
}

@media (max-width: 420px) {
  .avp-qr {
    grid-template-columns: 1fr;
    justify-items: start;
  }
}
