/* mobile-profile-fab.css — ONE global mobile profile control
 * ──────────────────────────────────────────────────────────────────────
 * A single fixed, pixel-identical profile cluster (theme toggle + avatar)
 * pinned top-right on every authenticated MOBILE page. Replaces the
 * per-surface avatars that drifted in position/size page-to-page (the
 * teacher My Day hero `.mdp-avatar`, the student My Day `.md-av-st`, and
 * the base.html navbar's floating avatar). Markup: partials/
 * _mobile_profile_fab.html, included by base.html (normal + rail-shell +
 * av2 admin pages) AND the standalone own-shell My Day faces.
 *
 * Mobile-only: shown ≤1023px, HIDDEN ≥1024px where the desktop left rail /
 * av2 sidebar already carry the profile, so we never double up.
 *
 * Accent ring is palette-driven (`--brand-teal`, injected per-user
 * appearance) via color-mix — a palette swap re-tints the ring with no
 * edit here, never a hardcoded brand hex. The unread red dot uses the
 * semantic alert red (#ef4444), matching the existing navbar avatar dot.
 * z-index 60: above page content + bottom-tabs (40), below the profile
 * slider / modals (90). The full-width sticky alert banners (z-30/31) sit at
 * the very top, so when one is present the FAB is offset DOWN to clear it
 * (see the banner rule below) instead of painting over it.
 * ──────────────────────────────────────────────────────────────────── */

.mpf {
  /* Palette-driven accent for the avatar ring + initial tint, resolved for
     BOTH page types: `--brand-teal` (brand.css, base.html pages) → `--accent`
     (the My Day token layer on the standalone faces, which don't load
     brand.css) → a literal last resort. A palette / RGB-picker swap re-tints
     the ring on every surface with no edit here — never a hardcoded brand hex. */
  --mpf-accent: var(--brand-teal, var(--accent, #5B7AB8));
  position: fixed;
  top: max(env(safe-area-inset-top, 0px), 12px);
  right: max(env(safe-area-inset-right, 0px), 12px);
  z-index: 60;
  display: flex;
  align-items: center;
  gap: 8px;
  /* The cluster itself is just a layout anchor; only the buttons take
     pointer events so taps fall through the gap to page content. */
  pointer-events: none;
}
.mpf > * { pointer-events: auto; }

/* ── Shared button chrome — circular glass, hairline, backdrop blur ──── */
.mpf-toggle,
.mpf-avatar {
  box-sizing: border-box;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border-radius: 50%;
  cursor: pointer;
  font-family: inherit;
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  backdrop-filter: blur(20px) saturate(180%);
  /* Light page default — translucent white pill (matches the existing
     floating navbar chrome). Dark-mode override below. */
  background: rgba(255, 255, 255, 0.85);
  border: 1px solid rgba(15, 23, 42, 0.08);
  box-shadow: 0 4px 14px -4px rgba(15, 23, 42, 0.18);
  color: #0f172a;
  transition: transform 0.15s ease;
}
.mpf-toggle:active,
.mpf-avatar:active { transform: scale(0.94); }
/* Visible keyboard focus on the circular buttons (a11y — Gemini Jun 6). */
.mpf-toggle:focus-visible,
.mpf-avatar:focus-visible {
  outline: 2px solid color-mix(in srgb, var(--mpf-accent) 90%, transparent);
  outline-offset: 2px;
}

/* Theme toggle — 44px tap target (CLAUDE.md: every interactive ≥ 44px). */
.mpf-toggle {
  width: 44px;
  height: 44px;
}
.mpf-ic { width: 20px; height: 20px; color: inherit; }
/* Icon swap driven off html.dark (Tailwind-independent — the standalone My
   Day faces don't load Tailwind, so the toggle can't lean on dark: variants).
   Light page: moon visible, sun hidden. Dark page: the reverse. */
.mpf-ic--sun  { display: none; }
.mpf-ic--moon { display: inline-block; }
html.dark .mpf-ic--sun  { display: inline-block; }
html.dark .mpf-ic--moon { display: none; }

/* Profile avatar — 48px, palette-driven accent ring. The ring is a 2px
   inset box-shadow in the brand accent so it reads as a coloured halo on
   any page background without an extra wrapper element. */
.mpf-avatar {
  position: relative;       /* anchor for the unread dot */
  width: 48px;
  height: 48px;
  overflow: visible;        /* never clip the unread dot */
  font-weight: 650;
  font-size: 15px;
  letter-spacing: 0.02em;
  box-shadow:
    0 4px 14px -4px rgba(15, 23, 42, 0.18),
    0 0 0 2px color-mix(in srgb, var(--mpf-accent) 80%, transparent);
}
/* The avatar image fills the round button; inherit the radius so the
   photo stays circular (and the dot, which sits outside, isn't clipped). */
.mpf-avatar-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: inherit;
  display: block;
}
.mpf-avatar-initial {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  /* Soft accent tint behind the initial fallback. */
  background: color-mix(in srgb, var(--mpf-accent) 16%, transparent);
  color: color-mix(in srgb, var(--mpf-accent) 50%, #0f172a);
  border-radius: inherit;
}

/* Unread-notifications red dot — rides the avatar BUTTON (not the <img>,
   which is replaced content + can't render ::after). overflow:visible above
   keeps it from being clipped. Semantic alert red, matching the navbar dot. */
.mpf-avatar.has-notif::after {
  content: '';
  position: absolute;
  top: -1px;
  right: -1px;
  width: 12px;
  height: 12px;
  background: #ef4444;
  border-radius: 50%;
  /* Ring punched in the page colour so the dot reads as a separate badge.
     env-agnostic: --brand-page-deep in dark, white otherwise. */
  border: 2px solid #ffffff;
  pointer-events: none;
}

/* ── Dark mode — translucent slate glass + light glyphs (mirrors the
   existing floating navbar chrome's dark treatment). ────────────────── */
html.dark .mpf-toggle,
html.dark .mpf-avatar {
  background: rgba(51, 65, 85, 0.92);
  border-color: rgba(255, 255, 255, 0.18);
  color: #e2e8f0;
}
html.dark .mpf-ic { color: #e2e8f0; }
html.dark .mpf-avatar-initial {
  background: color-mix(in srgb, var(--mpf-accent) 22%, transparent);
  color: #e2e8f0;
}
/* On dark pages the dot's punch-out ring matches the deep page navy so the
   badge separates cleanly from the avatar instead of haloing white. */
html.dark .mpf-avatar.has-notif::after {
  border-color: var(--brand-page-deep, #060B17);
}

/* ── Gate 1 — hide where the desktop rail / av2 sidebar already show the
   profile (≥1024px), so the FAB never double-ups there. ─────────────── */
@media (min-width: 1024px) {
  .mpf { display: none; }
}

/* ── Gate 2 — base.html pages carry the top navbar, which becomes a full
   horizontal bar (with its OWN avatar) at ≥768px and the av2 sidebar shows
   its profile at ≥768px too. So on any page that renders the navbar (every
   base.html-derived page: normal, rail-shell, av2 admin), hide the FAB from
   768px up — its avatar is superseded by the navbar / sidebar there.
   The standalone own-shell My Day faces render NO .navbar, so this rule
   doesn't match them and the FAB stays through their whole ≤1023px phone
   face (they have no other profile control until the ≥1024px rail).
   Below 768px the existing floating-chrome treatment hides the navbar's own
   avatar (custom.css) and the FAB is the single profile control.
   (`:has()` is already used across this codebase — admin-v2.css, base.html.) */
@media (min-width: 768px) {
  body:has(.navbar) .mpf { display: none; }
}

/* Gate 3 — av2 admin pages carry the av2 sidebar (with its OWN avatar +
   toggle), which STACKS (not hidden) at phone width too — so suppress the FAB
   on av2-body entirely, mirroring the rail-body suppression. Without this,
   admins saw two avatars + two theme toggles below 768px (independent review,
   Jun 6). */
body.av2-body .mpf { display: none; }

/* Keep the FAB clear of the full-width sticky alert banners (emergency z-31 /
   maintenance z-30) rather than painting over them — the FAB is fixed at z-60,
   so offset it DOWN by the banner height when one is present (independent
   review: was covering the safety-critical emergency banner's right edge). */
body:has(.emergency-banner) .mpf,
body:has(.maintenance-banner) .mpf {
  top: calc(max(env(safe-area-inset-top, 0px), 12px) + 40px);
}
