/* Sign-in and Register pop-ups on the public pages
   (templates/accounts/partials/_auth_modals.html, app/js/auth-modal.js).
   The fields inside reuse the .ax-* styles from auth.css. */

.am-backdrop {
  position: fixed; inset: 0; z-index: 300;
  display: grid; place-items: center; overflow-y: auto;
  padding: 24px calc(16px + env(safe-area-inset-right)) calc(24px + env(safe-area-inset-bottom)) calc(16px + env(safe-area-inset-left));
  background: color-mix(in srgb, #0b1a13 58%, transparent);
  backdrop-filter: blur(8px);
  opacity: 0; transition: opacity .22s ease;
}
.am-backdrop[hidden] { display: none; }
.am-backdrop.is-open { opacity: 1; }
body.am-open { overflow: hidden; }

/* The dialog scrolls inside itself (the Register form is tall); the tab
   row with Sign in | Register café and the close button stays on top. */
.am-dialog {
  position: relative; width: min(460px, 100%); max-height: calc(100dvh - 48px); overflow-y: auto; overscroll-behavior: contain;
  padding: 0 30px 26px;
  border: 1px solid var(--line); border-radius: 26px;
  background: var(--surface); color: var(--ink);
  box-shadow: 0 40px 100px rgba(5, 15, 11, .38);
  scrollbar-width: thin;
  transform: translateY(18px) scale(.96); opacity: 0;
  transition: transform .32s cubic-bezier(.2, .9, .3, 1.12), opacity .22s ease, width .25s ease;
}
.am-backdrop.is-open .am-dialog { transform: none; opacity: 1; }
.am-dialog.is-wide { width: min(700px, 100%); }
.am-dialog h1, .am-dialog h2 { margin: 0 0 6px; font-size: clamp(21px, 2.4vw, 25px); letter-spacing: -.03em; line-height: 1.2; }
.am-dialog .ax-lead { margin-bottom: 18px; }

.am-top {
  position: sticky; top: 0; z-index: 3;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin: 0 -30px 20px; padding: 16px 16px 14px 30px;
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.am-tabs { display: inline-flex; gap: 4px; padding: 4px; border-radius: 14px; background: var(--surface-2); }
.am-tab {
  min-height: 38px; padding: 0 14px; display: inline-flex; align-items: center; gap: 8px;
  border: 0; border-radius: 10px; background: transparent; color: var(--muted);
  font: inherit; font-size: 13.5px; font-weight: 750; white-space: nowrap; cursor: pointer;
  transition: background-color .18s ease, color .18s ease, box-shadow .18s ease;
}
.am-tab i { font-size: 12px; }
.am-tab:hover { color: var(--ink); }
.am-tab.is-active { background: var(--surface); color: var(--brand); box-shadow: 0 1px 2px rgba(0, 0, 0, .06), 0 4px 12px color-mix(in srgb, var(--ink) 8%, transparent); }
.am-tab:focus-visible, .am-close:focus-visible { outline: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 30%, transparent); }

.am-close {
  width: 38px; height: 38px; flex: 0 0 auto;
  display: grid; place-items: center; border: 0; border-radius: 12px;
  background: var(--surface-2); color: var(--ink); cursor: pointer; font-size: 15px;
  transition: transform .2s ease, background .2s ease;
}
.am-close:hover { transform: rotate(90deg); background: color-mix(in srgb, var(--ink) 8%, var(--surface)); }

/* Header: icon beside the kicker and title, the lead underneath. */
.am-head { display: grid; grid-template-columns: auto minmax(0, 1fr); column-gap: 14px; align-items: center; }
.am-head[hidden] { display: none; }
.am-head .am-icon { grid-row: span 2; margin: 0; }
.am-head .ax-kicker { align-self: end; margin: 0 0 3px; }
.am-head h2 { align-self: start; margin: 0; }
.am-head .ax-lead { grid-column: 1 / -1; margin: 12px 0 18px; }

.am-icon {
  width: 50px; height: 50px; margin-bottom: 16px; display: grid; place-items: center; border-radius: 16px;
  background: linear-gradient(145deg, color-mix(in srgb, var(--accent) 78%, #fff), var(--accent));
  color: #fff; font-size: 20px; box-shadow: 0 12px 26px color-mix(in srgb, var(--accent) 30%, transparent);
}
.am-icon.brand {
  background: linear-gradient(145deg, var(--brand-2), var(--brand));
  box-shadow: 0 12px 26px color-mix(in srgb, var(--brand) 30%, transparent);
}
.ax-card .am-icon { margin-top: -4px; }

.am-view[hidden] { display: none; }
.am-view .ax-alt { margin-top: 16px; }
.am-done h1 { font-size: clamp(22px, 2.6vw, 27px); }

/* Loading dots while the Register form arrives. */
.am-loading { display: flex; justify-content: center; gap: 8px; padding: 50px 0; }
.am-loading span { width: 10px; height: 10px; border-radius: 50%; background: var(--brand); animation: am-bounce 1s ease-in-out infinite; }
.am-loading span:nth-child(2) { animation-delay: .15s; }
.am-loading span:nth-child(3) { animation-delay: .3s; }
@keyframes am-bounce { 0%, 80%, 100% { transform: scale(.5); opacity: .4; } 40% { transform: none; opacity: 1; } }

.ax-submit.is-busy { pointer-events: none; opacity: .75; }
.ax-submit.is-busy i { animation: am-spin .8s linear infinite; }
.ax-submit.is-busy i::before { content: "\f110"; }
@keyframes am-spin { to { transform: rotate(360deg); } }

.am-shake { animation: am-shake .4s ease; }
@keyframes am-shake { 20%, 60% { transform: translateX(-6px); } 40%, 80% { transform: translateX(6px); } }

/* The register grid is two columns inside the wide pop-up, whatever the screen. */
.am-dialog.is-wide .ax-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.am-dialog.is-wide .ax-grid .full { grid-column: 1 / -1; }

@media (max-width: 640px) {
  .am-backdrop { place-items: end center; padding: 0; }
  .am-dialog, .am-dialog.is-wide {
    width: 100%; max-height: 94dvh; overflow-y: auto;
    padding: 0 18px calc(22px + env(safe-area-inset-bottom));
    border-radius: 24px 24px 0 0; transform: translateY(40px);
  }
  .am-dialog.is-wide .ax-grid { grid-template-columns: 1fr; }
  /* Bottom sheet: a grab handle above the tabs. */
  .am-top { margin: 0 -18px 18px; padding: 20px 12px 12px 18px; }
  .am-top::before { content: ""; position: absolute; top: 7px; left: 50%; width: 38px; height: 4px; margin-left: -19px; border-radius: 999px; background: color-mix(in srgb, var(--ink) 16%, transparent); }
  .am-tabs { flex: 1; }
  .am-tab { flex: 1; justify-content: center; padding: 0 10px; }
  .am-icon { width: 44px; height: 44px; border-radius: 14px; font-size: 18px; }
}

@media (prefers-reduced-motion: reduce) {
  .am-backdrop, .am-dialog { transition: none; }
  .am-loading span, .am-shake { animation: none; }
}
