/* ══════════════════════════════════════════════════════════════════════════
   भारत पन्ना — install invitation
   Styles for the one element assets/js/pwa.js may insert. Nothing else.

   · Every colour and spacing value is a token from assets/css/main.css, so
     light mode, dark mode and the reader's अ+ text-size control all follow
     automatically. No new colour values are invented here.
   · position:fixed means the element is outside the document flow: it can
     never push content around, so it contributes nothing to CLS.
   · Nothing in this file applies until pwa.js adds .pwa-invite to the page.
   ══════════════════════════════════════════════════════════════════════════ */

.pwa-invite {
  position: fixed;
  z-index: 60; /* above the sticky share bar (z-index 5), below nothing else */
  left: 0;
  right: 0;
  /* --pwa-bottom-offset is set by pwa.js to the height of the sticky mobile
     share bar, so the invitation sits above it instead of covering it. */
  bottom: calc(var(--pwa-bottom-offset, 0px) + env(safe-area-inset-bottom, 0px));

  background: var(--surface);
  border-top: 1px solid var(--rule);
  box-shadow: 0 -6px 24px rgb(0 0 0 / 0.10);

  /* Off-screen until pwa.js adds .is-in on the next frame. */
  transform: translateY(110%);
  opacity: 0;
  pointer-events: none; /* not clickable until it has actually arrived */
  transition: transform 260ms cubic-bezier(0.22, 0.61, 0.36, 1), opacity 200ms ease;
  will-change: transform;
}

.pwa-invite.is-in {
  transform: translateY(0);
  opacity: 1;
  pointer-events: auto;
}

.pwa-invite-in {
  position: relative;
  max-width: var(--measure);
  margin: 0 auto;
  padding: var(--s4) var(--s7) var(--s4) var(--s4); /* right padding clears the × */
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-areas:
    'mark copy'
    'act  act';
  align-items: start;
  gap: var(--s3) var(--s3);
}

.pwa-invite-mark {
  grid-area: mark;
  display: flex;
  align-items: center;
  justify-content: center;
  padding-top: 2px;
}
.pwa-invite-mark svg {
  display: block;
}

.pwa-invite-copy {
  grid-area: copy;
  min-width: 0;
}

.pwa-invite-title {
  margin: 0;
  font-family: 'Martel', serif;
  font-size: 17px;
  font-weight: 600;
  line-height: 1.45;
  letter-spacing: 0; /* Devanagari: never track. design-system.md §4 */
  color: var(--ink);
}

.pwa-invite-text {
  margin: var(--s1) 0 0;
  font-size: 15px;
  line-height: 1.65;
  letter-spacing: 0;
  color: var(--ink-muted);
}
.pwa-invite-text b {
  font-weight: 600;
  color: var(--ink);
}

/* the iOS Share glyph sits on the text baseline, not above it */
.pwa-invite-text .pwa-ios-icon {
  vertical-align: -2px;
  margin: 0 1px;
}

.pwa-invite-actions {
  grid-area: act;
  display: flex;
  gap: var(--s2);
}

/* 44px minimum touch target, per design-system.md §5 */
.pwa-invite-go,
.pwa-invite-ok {
  flex: 1;
  min-height: 44px;
  padding: 0 var(--s5);
  border-radius: 99px;
  font: inherit;
  font-size: 15px;
  font-weight: 600;
  line-height: 1;
  letter-spacing: 0;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.pwa-invite-go {
  background: var(--brand);
  border: 1px solid var(--brand);
  color: var(--paper);
}
.pwa-invite-go:hover {
  background: var(--brand-deep);
  border-color: var(--brand-deep);
}

.pwa-invite-ok {
  background: var(--surface);
  border: 1px solid var(--rule);
  color: var(--ink-muted);
}
.pwa-invite-ok:hover {
  border-color: var(--brand);
  color: var(--brand);
}

.pwa-invite-close {
  position: absolute;
  top: var(--s2);
  right: var(--s2);
  width: 40px;
  height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--ink-muted);
  cursor: pointer;
  font: inherit;
  line-height: 1;
}
.pwa-invite-close:hover {
  color: var(--ink);
  background: var(--paper);
}

.pwa-invite :focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
  border-radius: 99px;
}

/* ── reader's text-size control (अ+ sets data-size on <html>) ───────────── */
:root[data-size='lg'] .pwa-invite-title {
  font-size: 18px;
}
:root[data-size='lg'] .pwa-invite-text {
  font-size: 16px;
}
:root[data-size='xl'] .pwa-invite-title {
  font-size: 20px;
}
:root[data-size='xl'] .pwa-invite-text {
  font-size: 17px;
  line-height: 1.7;
}

/* ── wider screens: a floating card, not a full-width bar ───────────────── */
@media (min-width: 700px) {
  .pwa-invite {
    left: auto;
    right: var(--s5);
    bottom: calc(var(--s5) + env(safe-area-inset-bottom, 0px));
    width: min(420px, calc(100vw - var(--s6)));
    border: 1px solid var(--rule);
    border-radius: 10px;
    box-shadow: 0 10px 32px rgb(0 0 0 / 0.14);
  }
  .pwa-invite-in {
    padding: var(--s4) var(--s7) var(--s4) var(--s4);
  }
  .pwa-invite-go,
  .pwa-invite-ok {
    flex: 0 0 auto;
  }
}

/* Dark mode needs a heavier shadow to separate the card from the ground. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) .pwa-invite {
    box-shadow: 0 -6px 24px rgb(0 0 0 / 0.5);
  }
  @media (min-width: 700px) {
    :root:not([data-theme='light']) .pwa-invite {
      box-shadow: 0 10px 32px rgb(0 0 0 / 0.55);
    }
  }
}
:root[data-theme='dark'] .pwa-invite {
  box-shadow: 0 -6px 24px rgb(0 0 0 / 0.5);
}
@media (min-width: 700px) {
  :root[data-theme='dark'] .pwa-invite {
    box-shadow: 0 10px 32px rgb(0 0 0 / 0.55);
  }
}

/* ── motion ─────────────────────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  .pwa-invite {
    transform: none;
    transition: opacity 120ms linear;
  }
  .pwa-invite.is-in {
    transform: none;
  }
}

/* Never print the invitation. */
@media print {
  .pwa-invite {
    display: none !important;
  }
}
