/**
 * Phase 2 hydration — anti-flash visibility.
 *
 * Elements are hidden when the current member state does NOT match, using
 * the `html:not(.glue-*)` form so the element keeps its own (author/Elementor)
 * display value when it IS shown — we never override display on the element
 * itself. The bootstrap sets `glue-out` synchronously as the optimistic
 * default (most visitors are logged out, and those pages are cache HITs), so
 * logged-out content shows immediately with no flash; logged-in content is
 * revealed once hydration confirms the session.
 */

/* Hide items that do not match the current state; matching items keep their
   own (author/Elementor) display value. The bootstrap defaults to the
   logged-out state, so the "not logged in" item (e.g. Login) shows
   immediately and the rest stay hidden until /me confirms — then the DOM is
   corrected (non-matching menu items are removed) on the authoritative state.
   Chairs/Journal items stay hidden until confirmed (never shown optimistically). */
html:not(.glue-in)    .glue-vis-logged     { display: none !important; }
html:not(.glue-out)   .glue-vis-not-logged { display: none !important; }
html:not(.glue-chair) .glue-vis-chairs     { display: none !important; }
html:not(.glue-jhem)  .glue-vis-jhem       { display: none !important; }

/* Login/Logout swap in the top bar: give both the same width so swapping one
   for the other never shifts the layout, and drop the theme's item separator
   so neither shows a trailing right border. */
.elementor-nav-menu li.glue-vis-logged > a,
.elementor-nav-menu li.glue-vis-not-logged > a {
    min-width: 80px;
    text-align: center;
    justify-content: center;
}
.elementor-nav-menu li.glue-vis-logged::after,
.elementor-nav-menu li.glue-vis-not-logged::after {
    content: none !important;
    display: none !important;
    border: 0 !important;
}

/* Member photo widget: show the default icon until /me supplies the member's
   photo (the .has-photo class is added on hydration). !important beats the
   theme's `.glue-user-photo img { display: … }`. */
.glue-user-photo:not(.has-photo) .glue-user-photo-img { display: none !important; }
.glue-user-photo.has-photo .glue-user-photo-default { display: none !important; }
/* Fixed box so swapping the default icon for the photo never shifts layout. */
.glue-user-photo { display: flex; align-items: center; justify-content: center; width: 30px; height: 30px; }
.glue-user-photo .glue-user-photo-img { width: 30px; height: 30px; object-fit: cover; border-radius: 50%; }
.glue-user-photo .glue-user-photo-default { width: 30px; height: 30px; }
/* Kill any theme transition/animation so the photo appears without a blink. */
.glue-user-photo,
.glue-user-photo .glue-user-photo-img,
.glue-user-photo .glue-user-photo-default { transition: none !important; animation: none !important; }

/* Opt-in loading placeholder: shown only while hydration is in flight. */
.glue-while-loading { display: none; }
html.glue-hydrating .glue-while-loading { display: revert; }

/* Opt-in error notice: shown only when hydration could not confirm state. */
.glue-on-error { display: none; }
html.glue-error .glue-on-error { display: revert; }

/* Minimal spinner for loading placeholders that want one. */
.glue-spinner {
    display: inline-block;
    width: 1em;
    height: 1em;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    vertical-align: -0.15em;
    animation: glue-spin 0.6s linear infinite;
}

@keyframes glue-spin {
    to { transform: rotate(360deg); }
}
