{# auth-status kindergarten override — reproduces the builtin's hardcoded wiring: /login + /login?tab=register when logged out; /account, /account/reviews, and hx-post /api/auth/logout dropdown when logged in; hx-post /api/auth/resend-verification banner when unverified. State from context.*. #}
{% if not context.isPublicLoggedIn %}
<div class="auth-status flex items-center gap-2">
  <a href="/login" class="kg-mono rounded-2xl px-3 py-1.5 text-sm font-medium opacity-80 transition-colors hover:bg-primary/10 hover:opacity-100">Login</a>
  <a href="/login?tab=register" class="kg-mono rounded-2xl bg-accent px-3 py-1.5 text-sm font-medium text-accent-foreground hover:bg-accent/90">Sign Up</a>
</div>
{% else %}
{% if not context.publicEmailVerified %}<div class="fixed top-16 inset-x-0 z-40 border-y border-destructive/50 bg-destructive/15 px-4 py-2 text-center text-sm text-destructive">
  <span class="kg-mono">Verify your email address.</span> <button hx-post="/api/auth/resend-verification" hx-swap="outerHTML" class="underline font-medium">Resend verification email</button>
</div>{% endif %}
<div class="auth-status relative">
  <button type="button" onclick="this.nextElementSibling.classList.toggle('hidden')" class="flex items-center gap-2 rounded-2xl px-3 py-1.5 text-sm font-medium opacity-90 transition-colors hover:bg-primary/10 hover:opacity-100">
    <span class="flex h-7 w-7 items-center justify-center rounded-2xl bg-accent text-accent-foreground"><svg class="h-4 w-4" aria-hidden="true"><use href="/icons/lucide.svg#user"></use></svg></span>
    <span class="kg-mono">{{ context.publicDisplayName|default:context.publicUsername }}</span>
    <svg class="h-4 w-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 rounded-2xl border border-primary/40 bg-card py-1 text-card-foreground kg-crayon-shadow z-50">
    <a href="/account" class="kg-mono block px-4 py-2 text-sm text-card-foreground hover:bg-primary/10">My Profile</a>
    <a href="/account/reviews" class="kg-mono block px-4 py-2 text-sm text-card-foreground hover:bg-primary/10">My Reviews</a>
    <hr class="my-1 border-border"/>
    <button hx-post="/api/auth/logout" hx-swap="none" class="kg-mono block w-full px-4 py-2 text-left text-sm text-destructive hover:bg-primary/10">Logout</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>
{% endif %}
