/* ============================================
 * Magic Darkroom · Auth Dialog
 *
 * In-page login / register popup with 麻薯 (mascot)
 * sitting beside the form, narrating tips through its
 * speech bubble. Built imperatively by auth-dialog.js.
 *
 * Structure (generated by auth-dialog.js):
 *   .auth-overlay[data-open]
 *     .auth-dialog
 *       .auth-dialog__aside        (mascot + cloud bubble)
 *       .auth-dialog__main
 *         .auth-dialog__head
 *           .auth-dialog__title
 *           .auth-dialog__close
 *         .auth-tabs > .auth-tab[aria-selected]
 *         form.auth-form[data-panel] ...
 *         .auth-foot
 *
 * Requires: theme/tokens.css, components/button.css,
 *           components/input.css, mascot/mascot.css
 * ============================================ */

/* ---- Overlay / backdrop ---- */
.auth-overlay {
  position: fixed;
  inset: 0;
  z-index: 1100;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(46, 33, 20, 0.46);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  animation: auth-fade-in var(--dur-normal) var(--ease-standard);
}
.auth-overlay[data-open="true"] {
  display: flex;
}

@keyframes auth-fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* ---- Dialog shell ---- */
.auth-dialog {
  position: relative;
  display: flex;
  width: min(760px, 100%);
  max-height: calc(100dvh - 40px);
  border-radius: 30px;
  background: var(--c-bg-content);
  box-shadow: 0 24px 60px rgba(46, 33, 20, 0.34);
  overflow: hidden;
  animation: auth-pop-in 0.34s var(--ease-pop);
}

@keyframes auth-pop-in {
  from { opacity: 0; transform: translateY(14px) scale(0.96); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

@media (prefers-reduced-motion: reduce) {
  .auth-overlay,
  .auth-dialog { animation: none; }
}

/* ---- Aside: mascot lives here ---- */
.auth-dialog__aside {
  flex: 0 0 268px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 28px 22px;
  background:
    radial-gradient(120% 90% at 50% 8%, rgba(255, 255, 255, 0.7), rgba(255, 255, 255, 0) 60%),
    linear-gradient(165deg, var(--c-mochi-soft) 0%, #fff 86%);
}

.auth-dialog__aside .md-mascot-stage {
  gap: 12px;
}
.auth-dialog__aside .md-mascot-wrap {
  width: 184px;
  height: 184px;
}
.auth-dialog__aside .md-mascot-cloud {
  font-size: 14px;
  padding: 12px 18px;
  max-width: 224px;
  min-height: 46px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ---- Main panel ---- */
.auth-dialog__main {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  padding: 26px 30px 24px;
  overflow-y: auto;
}

.auth-dialog__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 4px;
}
.auth-dialog__title {
  font-size: 22px;
  font-weight: 800;
  color: var(--c-text-h);
  line-height: 1.25;
}
.auth-dialog__subtitle {
  font-size: 12.5px;
  color: var(--c-text-2);
  margin-top: 3px;
}
.auth-dialog__close {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border: 0;
  background: transparent;
  font-size: 22px;
  line-height: 1;
  color: var(--c-text-3);
  border-radius: 50%;
  cursor: pointer;
  transition: background var(--dur-fast), color var(--dur-fast);
}
.auth-dialog__close:hover {
  background: rgba(121, 79, 39, 0.1);
  color: var(--c-text-h);
}

/* ---- Tabs ---- */
.auth-tabs {
  display: inline-flex;
  align-self: flex-start;
  gap: 4px;
  margin: 16px 0 18px;
  padding: 5px;
  border-radius: 999px;
  background: rgba(121, 79, 39, 0.08);
}
.auth-tab {
  border: 0;
  border-radius: 999px;
  background: transparent;
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  color: var(--c-text-2);
  padding: 8px 20px;
  cursor: pointer;
  transition: background var(--dur-normal) var(--ease-standard),
    color var(--dur-normal) var(--ease-standard),
    box-shadow var(--dur-normal) var(--ease-standard);
}
.auth-tab[aria-selected="true"] {
  background: #fff;
  color: var(--c-text-h);
  box-shadow: 0 3px 0 0 var(--sh-input);
}

/* ---- Form ---- */
.auth-form {
  display: grid;
  gap: 14px;
}
.auth-form[hidden] {
  display: none;
}

.auth-field {
  display: grid;
  gap: 7px;
}
.auth-field > label {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--c-text);
}

/* code row: input + send button */
.auth-field--code {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
}
.auth-field--code .auth-code-input {
  display: grid;
  gap: 7px;
}
.auth-field--code .md-btn {
  align-self: end;
  white-space: nowrap;
}

.auth-submit {
  margin-top: 4px;
}

.auth-foot {
  margin-top: 16px;
  font-size: 11.5px;
  line-height: 1.6;
  color: var(--c-text-3);
}

/* ---- Responsive: stack mascot on top ---- */
@media (max-width: 680px) {
  .auth-dialog {
    flex-direction: column;
    width: 100%;
    max-height: calc(100dvh - 24px);
  }
  .auth-dialog__aside {
    flex: 0 0 auto;
    flex-direction: row;
    justify-content: center;
    gap: 14px;
    padding: 18px 20px 14px;
  }
  .auth-dialog__aside .md-mascot-stage {
    flex-direction: row-reverse;
    align-items: center;
    gap: 12px;
  }
  .auth-dialog__aside .md-mascot-wrap {
    width: 96px;
    height: 96px;
  }
  .auth-dialog__aside .md-mascot-cloud {
    font-size: 13px;
    max-width: 200px;
    animation: none;
  }
  /* bubble tail points down-left toward the cat on the right */
  .auth-dialog__aside .md-mascot-cloud::before,
  .auth-dialog__aside .md-mascot-cloud::after {
    display: none;
  }
  .auth-dialog__main {
    padding: 18px 22px 22px;
  }
}
