/* ==========================================================================
   AADOPS public site: app layer (WEB3)
   Mobile bottom navigation (partials/site-bottomnav) and the app install prompt (partials/site-install).
   Every value is a design token from aadops-site.css (spacing --sp-*, type --fs-*, radii --r-*, shadows --sh-*)
   or a theme token (--c-*); the numbers after the commas are fallbacks only.
   Lime (--c-accent) is decoration on dark only; in light the active state uses --c-brand.
   ========================================================================== */

:root {
  --s-bnav-h: 64px;            /* item row height; the bar adds its padding and the safe-area inset */
  --s-bnav-ease: cubic-bezier(.2, .7, .2, 1);
}

/* ---------- Bottom navigation (phones and tablets, below 1024px) ---------- */
.s-bnav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 90;
  padding: var(--sp-1, 4px) var(--sp-2, 8px) calc(var(--sp-1, 4px) + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--c-surface) 84%, transparent);
  -webkit-backdrop-filter: blur(16px) saturate(1.4); backdrop-filter: blur(16px) saturate(1.4);
  border-top: 1px solid color-mix(in srgb, var(--c-border) 80%, transparent);
  transform: translateY(0);
  transition: transform .28s var(--s-bnav-ease);
}
@supports not ((-webkit-backdrop-filter: blur(1px)) or (backdrop-filter: blur(1px))) {
  .s-bnav { background: var(--c-surface); }
}
.s-bnav.is-hidden { transform: translateY(calc(100% + 1px)); }
.s-bnav:focus-within { transform: translateY(0); }

.s-bnav__list {
  display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: var(--sp-1, 4px);
  max-width: 560px; margin: 0 auto; padding: 0; list-style: none;
}
.s-bnav__li { display: flex; min-width: 0; }

.s-bnav__item {
  position: relative; flex: 1; min-width: 44px; min-height: var(--s-bnav-h);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  padding: var(--sp-1, 4px) 2px; margin: 0; border: 0; border-radius: var(--r-md, 14px);
  background: transparent; color: var(--c-text_muted);
  font: inherit; font-size: var(--fs-xs, .75rem); font-weight: 600; line-height: 1.15; letter-spacing: .01em;
  text-align: center; text-decoration: none; cursor: pointer; -webkit-tap-highlight-color: transparent;
  transition: color .18s, background-color .18s;
}
.s-bnav__item:hover { color: var(--c-text); background: color-mix(in srgb, var(--c-text) 6%, transparent); }
.s-bnav__item:focus-visible { outline: 2px solid var(--c-focus); outline-offset: -2px; }

.s-bnav__icon { display: grid; place-items: center; width: 40px; height: 28px; border-radius: var(--r-pill, 999px); }
.s-bnav__icon svg {
  width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.75;
  stroke-linecap: round; stroke-linejoin: round;
}
.s-bnav__label {
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden;
  max-width: 100%; overflow-wrap: anywhere;
}

/* Active page: brand colour and a short indicator on top (light); lime indicator on dark. */
.s-bnav__item.is-current { color: var(--c-brand); }
.s-bnav__item.is-current::before {
  content: ""; position: absolute; top: 0; left: 50%; width: 24px; height: 3px; margin-left: -12px;
  border-radius: 0 0 var(--r-pill, 999px) var(--r-pill, 999px); background: var(--c-brand);
}
.s-bnav__item.is-current .s-bnav__icon { background: color-mix(in srgb, var(--c-brand) 10%, transparent); }

/* The emphasised centre action: the primary call to action. */
.s-bnav__item.is-cta { color: var(--c-text); font-weight: 700; }
.s-bnav__item.is-cta .s-bnav__icon {
  width: 48px; height: 32px; background: var(--c-action); color: var(--c-action_text);
  box-shadow: var(--sh-1, 0 1px 2px color-mix(in srgb, var(--c-text) 10%, transparent));
}
.s-bnav__item.is-cta:hover .s-bnav__icon { box-shadow: var(--sh-2, 0 4px 12px color-mix(in srgb, var(--c-text) 16%, transparent)); }
.s-bnav__item.is-cta.is-current::before { display: none; }

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .s-bnav__item.is-current { color: var(--c-text); }
  :root:not([data-theme="light"]) .s-bnav__item.is-current::before { background: var(--c-accent); }
  :root:not([data-theme="light"]) .s-bnav__item.is-current .s-bnav__icon { background: color-mix(in srgb, var(--c-text) 10%, transparent); }
}
:root[data-theme="dark"] .s-bnav__item.is-current { color: var(--c-text); }
:root[data-theme="dark"] .s-bnav__item.is-current::before { background: var(--c-accent); }
:root[data-theme="dark"] .s-bnav__item.is-current .s-bnav__icon { background: color-mix(in srgb, var(--c-text) 10%, transparent); }

/* The page keeps room for the bar at all times (it is fixed; hiding it never moves the content). */
.s-body:not(.s-is-soon):has(> .s-bnav) {
  padding-bottom: calc(var(--s-bnav-h) + 2 * var(--sp-1, 4px) + 1px + env(safe-area-inset-bottom));
}

@media (min-width: 1024px) {
  .s-bnav { display: none; }
  .s-body:not(.s-is-soon):has(> .s-bnav) { padding-bottom: 0; }
}

/* ---------- App install prompt ---------- */
.s-install {
  position: fixed; z-index: 95; left: 50%;
  bottom: calc(var(--s-bnav-h) + 2 * var(--sp-1, 4px) + var(--sp-3, 12px) + env(safe-area-inset-bottom));
  display: flex; align-items: center; gap: var(--sp-2, 8px);
  width: max-content; max-width: calc(100vw - 2 * var(--sp-4, 16px)); height: 48px;
  padding: 0 var(--sp-1, 4px) 0 var(--sp-2, 8px);
  background: var(--c-surface); color: var(--c-text);
  border: 1px solid var(--c-border); border-radius: var(--r-pill, 999px);
  box-shadow: var(--sh-2, 0 8px 24px color-mix(in srgb, var(--c-text) 16%, transparent));
  opacity: 0; transform: translate(-50%, var(--sp-3, 12px));
  transition: opacity .25s var(--s-bnav-ease), transform .25s var(--s-bnav-ease);
}
.s-install[hidden] { display: none; }
.s-install.is-in { opacity: 1; transform: translate(-50%, 0); }

.s-install__icon { flex: none; width: 28px; height: 28px; border-radius: var(--r-sm, 8px); border: 1px solid var(--c-border); }
.s-install__text {
  flex: 1; min-width: 0; margin: 0; font-size: var(--fs-sm, .875rem); font-weight: 600; line-height: 1.2;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.s-install__btn {
  flex: none; height: 36px; padding: 0 var(--sp-4, 16px); border: 0; border-radius: var(--r-pill, 999px);
  background: var(--c-action); color: var(--c-action_text);
  font: inherit; font-size: var(--fs-sm, .875rem); font-weight: 700; cursor: pointer;
}
.s-install__close {
  flex: none; display: grid; place-items: center; width: 40px; height: 40px; padding: 0; border: 0;
  border-radius: 50%; background: transparent; color: var(--c-text_muted); cursor: pointer;
}
.s-install__close:hover { color: var(--c-text); background: color-mix(in srgb, var(--c-text) 6%, transparent); }
.s-install__close svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; }
.s-install__btn:focus-visible, .s-install__close:focus-visible { outline: 2px solid var(--c-focus); outline-offset: 2px; }

/* Without the bottom navigation the prompt sits above the one-button action bar (74px in aadops-site.css). */
.s-body:not(:has(> .s-bnav)) .s-install { bottom: calc(74px + var(--sp-3, 12px) + env(safe-area-inset-bottom)); }

@media (min-width: 1024px) {
  /* Desktop: bottom right, above the floating call to action. */
  .s-body .s-install, .s-body:not(:has(> .s-bnav)) .s-install {
    left: auto; right: 28px; bottom: calc(28px + 52px + var(--sp-4, 16px));
    transform: translateY(var(--sp-3, 12px));
  }
  .s-body .s-install.is-in { transform: translateY(0); }
}

/* ---------- Motion and print ---------- */
@media (prefers-reduced-motion: reduce) {
  .s-bnav, .s-bnav__item, .s-install { transition: none; }
  .s-install, .s-install.is-in { transform: translate(-50%, 0); }
}
@media (prefers-reduced-motion: reduce) and (min-width: 1024px) {
  .s-body .s-install, .s-body .s-install.is-in { transform: none; }
}
@media print {
  .s-bnav, .s-install { display: none !important; }
}
