/* ============================================================================
   Dive Tools — PWA install button + iOS instructions modal
   ----------------------------------------------------------------------------
   Loaded on every page (portal home, every calculator, privacy). The
   button is JS-injected by /shared/install.js into the existing page
   header, immediately to the LEFT of the hamburger button (when one is
   present). On the portal home there is no hamburger; the install
   button takes the rightmost position instead.
   ============================================================================ */

/* Position context. menu.css already sets these for hamburger pages,
   but the portal home doesn't load menu.css — so duplicate the rule
   here so the install button has a positioned ancestor everywhere. */
header.site-header .wrap,
header.app-header { position: relative; }

/* -------------------------------------------------------------------------
   Install button — base style
   ------------------------------------------------------------------------- */

.dt-install-btn {
  position: absolute;
  /* default: hamburger is at right:16px (44px wide) → install sits 4px
     to the left of the hamburger's left edge. */
  top: 16px;
  right: 64px;
  display: none;          /* shown by JS via .dt-install-show class */
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.10);
  border: 1px solid rgba(255, 255, 255, 0.30);
  color: #fff;
  padding: 0;
  border-radius: 4px;
  font: inherit;
  cursor: pointer;
  z-index: 5;
  width: 36px;
  height: 36px;
}
.dt-install-btn.dt-install-show { display: flex; }
.dt-install-btn:hover { background: rgba(255, 255, 255, 0.18); }
.dt-install-btn:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 2px;
}
/* Always icon-only — the text label was making the button too wide to
   fit comfortably alongside the hamburger; the download glyph by itself
   is recognisable and the button has aria-label / title for screen
   readers and tooltips. */
.dt-install-btn .dt-install-label { display: none; }
.dt-install-btn .dt-install-icon { display: flex; align-items: center; }
.dt-install-btn .dt-install-icon svg { display: block; }

/* On pages with NO hamburger (only the portal home in scope) the install
   button takes the rightmost slot. JS adds this class when no .dt-menu-trigger
   exists on the page. */
.dt-install-btn.dt-install-no-menu { right: 16px; }

/* The site-header (portal home, privacy) has slightly different vertical
   spacing — nudge the button to align with the back-link / title row. */
header.site-header .dt-install-btn { top: 8px; right: 48px; }
header.site-header .dt-install-btn.dt-install-no-menu { right: 0; }

/* -------------------------------------------------------------------------
   Desktop: hide entirely. Install via Chrome's URL-bar icon is the
   native path on desktop, and showing the button there clutters the
   header. Detect "real desktop" via mouse-primary input rather than
   viewport size (an iPad in landscape is wide but still touch-primary
   and benefits from the visible button).
   ------------------------------------------------------------------------- */

@media (hover: hover) and (pointer: fine) {
  .dt-install-btn { display: none !important; }
}

/* -------------------------------------------------------------------------
   iOS instructions modal (and android-fallback / ios-other-browser
   variants — they all share the same skeleton, only content differs)
   ------------------------------------------------------------------------- */

.dt-imodal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 1200;
  opacity: 0;
  transition: opacity 200ms ease;
}
.dt-imodal-backdrop.dt-open { opacity: 1; }

.dt-imodal {
  position: fixed;
  top: 50%;
  left: 50%;
  width: 90vw;
  max-width: 420px;
  max-height: calc(100vh - 32px);
  overflow-y: auto;
  background: #fff;
  border-radius: 8px;
  padding: 28px 28px 24px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  z-index: 1201;
  opacity: 0;
  transform: translate(-50%, -48%) scale(0.96);
  transition: opacity 200ms ease, transform 200ms ease;
}
.dt-imodal.dt-open {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

.dt-imodal-close {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 36px;
  height: 36px;
  background: transparent;
  border: 0;
  cursor: pointer;
  font-size: 24px;
  color: #888;
  border-radius: 4px;
  line-height: 1;
}
.dt-imodal-close:hover { background: #f0f0f0; color: #1a1a1a; }
.dt-imodal-close:focus-visible {
  outline: 2px solid #6b7280;
  outline-offset: -2px;
}

.dt-imodal h2 {
  margin: 0 0 14px;
  font-size: 18px;
  font-weight: 600;
  color: #374151;
  padding-right: 36px; /* clears the close button */
  text-align: center;
}
.dt-imodal p {
  margin: 0 0 12px;
  font-size: 14px;
  line-height: 1.55;
  color: #1a1a1a;
}
.dt-imodal p.center { text-align: center; }

/* "Steps card" — only appears in the iOS Safari instructions variant */
.dt-imodal-card {
  background: #f5f7fa;
  border: 1px solid #d0d7de;
  border-radius: 8px;
  padding: 16px;
  margin: 14px 0;
}
.dt-imodal-share-icon {
  display: flex;
  justify-content: center;
  margin: 4px 0 12px;
  color: #4a90e2; /* iOS-share blue */
}
.dt-imodal-step {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  color: #1a1a1a;
  margin: 8px 0;
}
.dt-imodal-step .step-num {
  font-weight: 700;
  color: #4a90e2;
  min-width: 18px;
}
.dt-imodal-step .inline-share {
  display: inline-flex;
  vertical-align: middle;
  width: 16px;
  height: 16px;
  color: #4a90e2;
  margin: 0 2px;
}
.dt-imodal-step .inline-share svg { display: block; width: 100%; height: 100%; }

.dt-imodal-confirm {
  display: block;
  margin: 16px auto 0;
  padding: 10px 24px;
  background: #6b7280;
  color: #fff;
  border: 0;
  border-radius: 6px;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.dt-imodal-confirm:hover { background: #374151; }
.dt-imodal-confirm:focus-visible {
  outline: 2px solid #6b7280;
  outline-offset: 2px;
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  .dt-imodal-backdrop,
  .dt-imodal { transition: none; }
}
