/* ==========================================================================
   MATRI JEWELLERS - auth.css
   Account popup (log in / sign up). Uses the theme tokens, so Gold, Silver
   and Dark all work without extra rules.
   ========================================================================== */

/* Header account button (same look as the other header icons) */
button.header__icon {
  border: 0;
  background: none;
  padding: 0;
  cursor: pointer;
  font: inherit;
}
/* Keep it visible on phones (earlier rules hide most header icons) */
.header__actions .header__icon.header__account,
.header__actions .header__icon.header__wishlist { display: grid; }

.header__wishlist { position: relative; }
.header__badge {
  position: absolute;
  top: 2px;
  right: 0;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: var(--radius-full);
  background: var(--color-crimson);
  color: var(--color-white);
  font: 600 10px/16px var(--font-body);
  text-align: center;
}
.header__badge[hidden] { display: none; }

/* Lock page scroll while the popup is open */
html:has(dialog.auth[open]) { overflow: hidden; }

.auth {
  border: 0;
  padding: 0;
  margin: auto;
  background: transparent;
  color: var(--color-ink);
  width: min(420px, calc(100% - 2rem));
  max-width: none;
  max-height: none;
  overflow: visible;
}
.auth::backdrop {
  background: rgba(20, 5, 5, 0.6);
  backdrop-filter: blur(3px);
}
[data-metal="silver"] .auth::backdrop { background: rgba(9, 15, 22, 0.65); }

.auth__panel {
  position: relative;
  padding: 2.25rem 2rem 2rem;
  background: var(--color-white);
  border: 1px solid var(--color-gold);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  max-height: calc(100dvh - 2rem);
  overflow-y: auto;
}
/* Thin inner gold frame, like the product popup */
.auth__panel::before {
  content: "";
  position: absolute;
  inset: 6px;
  border: 1px solid var(--color-gold);
  border-radius: calc(var(--radius-lg) - 6px);
  opacity: 0.35;
  pointer-events: none;
}
.auth[open] .auth__panel { animation: authIn 0.25s ease; }
@keyframes authIn {
  from { opacity: 0; transform: translateY(10px) scale(0.98); }
  to   { opacity: 1; transform: none; }
}
@media (prefers-reduced-motion: reduce) {
  .auth[open] .auth__panel { animation: none; }
}

.auth__close {
  position: absolute;
  top: 0.6rem;
  right: 0.8rem;
  z-index: 1;
  width: 36px;
  height: 36px;
  border: 0;
  background: none;
  font-size: 1.7rem;
  line-height: 1;
  color: var(--color-charcoal);
  cursor: pointer;
  border-radius: var(--radius-full);
}
.auth__close:hover { color: var(--color-crimson); background: var(--color-crimson-soft); }

.auth__title {
  font-family: var(--font-heading);
  font-size: 2rem;
  font-weight: var(--fw-semibold);
  color: var(--color-maroon);
  margin: 0 0 0.25rem;
}
.auth__sub {
  margin: 0 0 1.25rem;
  font-size: var(--fs-sm);
  color: var(--color-charcoal);
}

.auth__tabs {
  display: flex;
  gap: 0.25rem;
  border-bottom: 1px solid var(--color-crimson-soft);
  margin-bottom: 0.5rem;
}
.auth__tab {
  background: none;
  border: 0;
  border-bottom: 2px solid transparent;
  padding: 0.6rem 1rem;
  font-family: var(--font-body);
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  color: var(--color-charcoal);
  cursor: pointer;
}
.auth__tab.is-active {
  color: var(--color-crimson);
  border-bottom-color: var(--color-gold);
}

.auth__form[hidden] { display: none; }
.auth__label {
  display: block;
  margin: 0.9rem 0 0.35rem;
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  color: var(--color-charcoal);
}
.auth__input {
  width: 100%;
  padding: 0.75rem 1rem;
  border: 1px solid var(--color-rose-gold);
  border-radius: var(--radius-sm);
  background: var(--color-ivory);
  color: var(--color-ink);
  font-family: var(--font-body);
  font-size: 1rem;              /* 16px stops iOS zooming into the field */
}
.auth__input:focus-visible {
  outline: 2px solid var(--color-gold);
  outline-offset: 1px;
}
.auth__hint {
  margin: 0.3rem 0 0;
  font-size: var(--fs-xs);
  color: var(--color-charcoal);
}
.auth__error {
  margin: 0.75rem 0 0;
  font-size: var(--fs-sm);
  color: #b3261e;
}
[data-theme="dark"] .auth__error { color: #ff9d94; }
.auth__error[hidden] { display: none; }

.auth__submit { width: 100%; margin: 1.25rem 0 0; }

/* ---- Signed-in state ---- */
.auth__tabs[hidden],
.auth__account[hidden] { display: none; }

.auth__who {
  margin: 1rem 0 0;
  font-size: var(--fs-sm);
  color: var(--color-charcoal);
  overflow-wrap: anywhere;
}
.auth__who strong { color: var(--color-maroon); }

.auth__submit[disabled] { opacity: 0.6; cursor: wait; }

.header__account { position: relative; }
.header__account.is-signed-in::after {
  content: "";
  position: absolute;
  top: 6px;
  right: 6px;
  width: 10px;
  height: 10px;
  border-radius: var(--radius-full);
  background: var(--color-gold);
  border: 2px solid var(--color-ivory);
}

/* ---- Profile form + logout ---- */
.auth__ok {
  margin: 0.75rem 0 0;
  font-size: var(--fs-sm);
  color: #2e7d32;
}
[data-theme="dark"] .auth__ok { color: #8fd19e; }
.auth__ok[hidden] { display: none; }

.auth__logout {
  display: block;
  width: 100%;
  margin: 0.75rem 0 0;
  padding: 0.8rem 1rem;
  background: none;
  border: 1px solid var(--color-rose-gold);
  border-radius: 100px;
  color: var(--color-charcoal);
  font-family: var(--font-body);
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  cursor: pointer;
}
.auth__logout:hover {
  color: var(--color-crimson);
  border-color: var(--color-crimson);
}

/* ---- Wishlist panel ---- */
.wishlist-dialog { width: min(480px, calc(100% - 2rem)); }
.wishlist-list {
  list-style: none;
  margin: 1rem 0 0;
  padding: 0;
  max-height: min(60vh, 460px);
  overflow-y: auto;
  display: grid;
  gap: 0.75rem;
}
.wishlist-item {
  display: grid;
  grid-template-columns: 64px 1fr auto;
  gap: 0.75rem;
  align-items: center;
  padding: 0.5rem;
  border: 1px solid var(--color-crimson-soft);
  border-radius: var(--radius-md, 12px);
  background: var(--color-white);
}
.wishlist-item__img {
  width: 64px;
  height: 64px;
  object-fit: cover;
  border-radius: var(--radius-sm, 8px);
  background: var(--color-ivory);
}
.wishlist-item__cat {
  margin: 0;
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-charcoal);
}
.wishlist-item__name {
  margin: 0.1rem 0;
  font-family: var(--font-heading);
  font-size: 1rem;
  color: var(--color-ink);
}
.wishlist-item__price { margin: 0; font-size: 0.9rem; color: var(--color-maroon); }
.wishlist-item__remove {
  border: 0;
  background: none;
  cursor: pointer;
  font: inherit;
  font-size: 0.8rem;
  color: var(--color-crimson);
  padding: 0.4rem 0.6rem;
  border-radius: var(--radius-full);
}
.wishlist-item__remove:hover { background: var(--color-crimson-soft); }
.wishlist-empty { margin: 1.5rem 0 0.5rem; text-align: center; color: var(--color-charcoal); }