{# auth-status (editorial) — header login state; small-caps links, hairline monogram and quiet editorial-panel dropdown. Driven by context.isPublicLoggedIn / context.publicDisplayName / context.publicUsername; logout posts /api/auth/logout. #}
{% if context.isPublicLoggedIn %}
<div data-block-override="editorial:auth-status" class="auth-status relative">
  <button type="button" onclick="this.nextElementSibling.classList.toggle('hidden')" class="editorial-caps flex items-center gap-2 text-xs opacity-90 hover:opacity-100 px-3 py-1.5 transition-colors">
    <span class="inline-flex h-7 w-7 items-center justify-center rounded-full text-[0.7rem] font-bold" style="border:1px solid hsl(var(--border));color:hsl(var(--accent));">{{ context.publicDisplayName|default:context.publicUsername|first|upper }}</span>
    <span>{{ context.publicDisplayName|default:context.publicUsername }}</span>
    <svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 9l-7 7-7-7"/></svg>
  </button>
  <div id="auth-dropdown-menu" class="hidden absolute right-0 top-full mt-1 w-48 editorial-panel bg-card py-1 z-50">
    <a href="/account" class="block px-4 py-2 text-sm text-foreground hover:bg-accent">My profile</a>
    <a href="/account/reviews" class="block px-4 py-2 text-sm text-foreground hover:bg-accent">My reviews</a>
    <hr class="my-1 editorial-rule"/>
    <button hx-post="/api/auth/logout" hx-swap="none" class="block w-full text-left px-4 py-2 text-sm text-destructive hover:bg-accent">Sign out</button>
  </div>
  <script>
  (function(){
    document.addEventListener('click', function(e) {
      var menu = document.getElementById('auth-dropdown-menu');
      var btn = document.querySelector('.auth-status > button');
      if (!menu || !btn) return;
      if (!btn.contains(e.target) && !menu.contains(e.target)) { menu.classList.add('hidden'); }
    });
  })();
  </script>
</div>
{% else %}
<div data-block-override="editorial:auth-status" class="auth-status flex items-center gap-2">
  <a href="/login" class="editorial-caps text-xs px-3 py-1.5 opacity-80 hover:opacity-100 hover:text-[hsl(var(--accent))] transition-colors">Sign in</a>
  <a href="/login?tab=register" class="editorial-button text-xs">Reserve</a>
</div>
{% endif %}
