/* ═══════════════════════════════════════
   AUTH DIALOG — Sign In / Sign Up tabs (authModal.js)
   Built on css/styles.css theme vars. All .auth-* rules below used to live
   in signIn.css / signUp.css, which went away with those pages.
═══════════════════════════════════════ */

.auth-modal {
  position: fixed;
  inset: 0;
  z-index: 1400; /* above .navbar (1100) and .editor-modal-overlay (1000) */
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.auth-modal[hidden] { display: none; }

.auth-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(8, 12, 30, 0.7);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
}

html.auth-modal-open { overflow: hidden; }

/* ═══════ Card ═══════ */
.auth-card {
  width: 100%;
  max-width: 440px;
  background: rgba(20, 29, 66, 0.97);
  border: 2px solid rgba(255, 255, 255, 0.15);
  border-top: 4px solid var(--coral);
  border-radius: 20px;
  padding: 46px 28px 32px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.45);
}

.auth-modal-dialog {
  position: relative;
  max-height: calc(100vh - 40px);
  overflow-y: auto;
  outline: none;
}

.auth-modal-close {
  position: absolute;
  top: 10px;
  right: 12px;
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: rgba(255, 255, 255, 0.75);
  font-size: 1.6rem;
  line-height: 1;
  cursor: pointer;
}

.auth-modal-close:hover,
.auth-modal-close:focus-visible {
  background: rgba(255, 255, 255, 0.12);
  color: var(--white);
}

/* ═══════ Tabs ═══════ */
.auth-tabs {
  display: flex;
  gap: 6px;
  margin: 0 0 22px;
  padding: 4px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 999px;
}

.auth-tab {
  flex: 1;
  padding: 10px 12px;
  border: none;
  border-radius: 999px;
  background: transparent;
  color: rgba(255, 255, 255, 0.75);
  font-family: 'Luckiest Guy', cursive;
  font-size: 0.95rem;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}

.auth-tab:hover { color: var(--white); }

.auth-tab.is-active,
.auth-tab[aria-selected="true"] {
  background: var(--coral);
  color: var(--white);
}

.auth-tab:focus-visible,
.auth-field input:focus-visible {
  outline: 2px solid var(--white);
  outline-offset: 2px;
}

.auth-card-title {
  font-family: 'Luckiest Guy', cursive;
  font-size: 1.5rem;
  text-align: center;
  color: var(--white);
  -webkit-text-stroke: 1px rgba(0, 0, 0, 0.18);
  paint-order: stroke fill;
  text-shadow: 2px 3px 0 rgba(0, 0, 0, 0.25);
  letter-spacing: 0.03em;
}

.auth-card-sub {
  margin-top: 8px;
  font-size: 0.85rem;
  font-weight: 500;
  line-height: 1.4;
  color: rgba(255, 255, 255, 0.75);
  text-align: center;
}

/* ═══════ Form ═══════ */
.auth-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-top: 20px;
}

.auth-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.auth-field label {
  font-family: 'Luckiest Guy', cursive;
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.7);
  letter-spacing: 0.02em;
}

.auth-field input {
  width: 100%;
  padding: 12px 14px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.12);
  color: var(--white);
  font-family: 'Fira Sans Condensed', sans-serif;
  font-size: 0.95rem;
  font-weight: 500;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  box-sizing: border-box;
}

.auth-field input::placeholder {
  color: rgba(255, 255, 255, 0.5);
}

.auth-field input:focus {
  border-color: var(--white);
  box-shadow: 0 0 0 3px rgba(235, 66, 41, 0.3);
}

.auth-field input:disabled {
  opacity: 0.6;
}

/* Autofill (Chrome) keeps our dark theme instead of flashing white */
.auth-field input:-webkit-autofill {
  -webkit-text-fill-color: var(--white);
  -webkit-box-shadow: 0 0 0px 1000px rgba(30, 40, 80, 0.9) inset;
  transition: background-color 9999s ease-in-out 0s;
}

/* ═══════ Links / secondary actions ═══════ */
.auth-links-row {
  display: flex;
  justify-content: flex-end;
  margin-top: -4px;
}

.auth-link-btn {
  background: none;
  border: none;
  padding: 0;
  color: rgba(255, 255, 255, 0.75);
  font-family: 'Fira Sans Condensed', sans-serif;
  font-size: 0.82rem;
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
}

.auth-link-btn:hover {
  color: var(--white);
}

.auth-resend-btn {
  align-self: center;
  margin-top: 2px;
}

.auth-back-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: none;
  border: none;
  padding: 0;
  margin-bottom: 14px;
  color: rgba(255, 255, 255, 0.75);
  font-family: 'Fira Sans Condensed', sans-serif;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
}

.auth-back-btn:hover {
  color: var(--white);
}

.auth-switch {
  margin-top: 20px;
  text-align: center;
  font-size: 0.85rem;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.75);
}

.auth-switch a {
  color: var(--white);
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* ═══════ Submit button ═══════ */
.auth-submit-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 14px;
  margin-top: 4px;
  background: var(--coral);
  color: var(--white);
  font-family: 'Luckiest Guy', cursive;
  font-size: 0.95rem;
  letter-spacing: 0.04em;
  border: none;
  border-radius: 30px;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s, background 0.2s;
}

.auth-submit-btn:hover:not(:disabled) {
  background: var(--coral-dark);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
}

.auth-submit-btn:disabled {
  opacity: 0.65;
  cursor: not-allowed;
  transform: none;
}

.auth-btn-spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.4);
  border-top-color: var(--white);
  border-radius: 50%;
  animation: auth-spin 0.7s linear infinite;
}

@keyframes auth-spin {
  to { transform: rotate(360deg); }
}

/* ═══════ Status messages ═══════ */
.auth-message {
  margin-top: 16px;
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 0.85rem;
  font-weight: 600;
  line-height: 1.4;
  text-align: center;
}

.auth-message--error {
  background: rgba(235, 66, 41, 0.18);
  border: 1px solid rgba(235, 66, 41, 0.5);
  color: #ffd4cc;
}

.auth-message--success {
  background: rgba(46, 204, 113, 0.15);
  border: 1px solid rgba(46, 204, 113, 0.45);
  color: #bdf2d3;
}

/* ═══════ View switching ═══════ */
.is-hidden {
  display: none !important;
}

/* ═══════ Toast (mirrors level.html's #levelToast) ═══════ */
.auth-toast {
  position: fixed;
  left: 50%;
  bottom: 32px;
  transform: translate(-50%, 12px);
  background: rgba(20, 29, 66, 0.95);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: var(--white);
  font-family: 'Fira Sans Condensed', sans-serif;
  font-weight: 600;
  font-size: 0.9rem;
  padding: 12px 22px;
  border-radius: 999px;
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.35);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s, transform 0.25s;
  z-index: 500;
  max-width: 90vw;
  text-align: center;
}

.auth-toast.visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* Inline "way out" button inside an error message — e.g. email_taken pointing
   at the Sign In tab right where the error is. */
.auth-inline-link {
  background: none;
  border: none;
  padding: 0;
  color: inherit;
  font: inherit;
  font-weight: 800;
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
}

/* ═══════ Responsive ═══════ */
@media (max-width: 520px) {
  .auth-card {
    padding: 20px 20px 26px;
    border-radius: 16px;
  }

  .auth-card-title {
    font-size: 1.3rem;
  }
}

/* Pages with their own generic `button` / `input` / `body.dark ...` styles
   (the feedback dashboards) must not restyle the dialog's controls — these
   repeat the key properties at higher specificity. */
.auth-modal .auth-submit-btn {
  height: auto;
  padding: 14px;
  border: none;
  border-radius: 30px;
  background: var(--coral);
  color: var(--white);
  font-size: 0.95rem;
  font-weight: 400;
}
.auth-modal .auth-submit-btn:hover:not(:disabled) { background: var(--coral-dark); }

.auth-modal .auth-tab {
  height: auto;
  padding: 10px 12px;
  border: none;
  border-radius: 999px;
  background: transparent;
  color: rgba(255, 255, 255, 0.75);
  font-size: 0.95rem;
  font-weight: 400;
}
.auth-modal .auth-tab.is-active,
.auth-modal .auth-tab[aria-selected="true"] {
  background: var(--coral);
  color: var(--white);
}

.auth-modal .auth-modal-close {
  height: 32px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: rgba(255, 255, 255, 0.75);
  font-size: 1.6rem;
}
.auth-modal .auth-modal-close:hover { background: rgba(255, 255, 255, 0.12); color: var(--white); }

.auth-modal .auth-link-btn,
.auth-modal .auth-back-btn,
.auth-modal .auth-inline-link {
  height: auto;
  padding: 0;
  border: none;
  background: none;
  color: rgba(255, 255, 255, 0.75);
}

.auth-modal .auth-field input {
  height: auto;
  padding: 12px 14px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.12);
  color: var(--white);
}

/* "New here? Sign up" / "Already have an account? Sign in" under the forms */
.auth-switch {
  margin: 4px 0 0;
  text-align: center;
  font-family: 'Fira Sans Condensed', sans-serif;
  font-size: 0.9rem;
  color: rgba(255, 255, 255, 0.75);
}

.auth-switch .auth-link-btn { font-size: 0.9rem; color: var(--white); }

/* ═══════════════════════════════════════
   GAME-UI SKIN — matches the in-game BUILD OPTIONS panel: yellow header bar
   with a coral title, coral body, yellow rounded buttons with coral text.
   (Kept last so it wins over the earlier dark-navy rules.)
═══════════════════════════════════════ */
.auth-modal .auth-modal-backdrop {
  background: rgba(20, 29, 66, 0.55);
}

.auth-modal .auth-card {
  --auth-pad: 28px;
  background: var(--coral);
  border: 0;
  border-radius: 18px;
  padding: 0 var(--auth-pad) 30px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}

/* The title is the header bar: it bleeds out to the card's edges. */
.auth-modal .auth-card-title {
  margin: 0 calc(-1 * var(--auth-pad));
  padding: 20px 56px 12px;
  background: var(--yellow-card);
  color: var(--coral);
  font-size: 1.6rem;
  text-transform: uppercase;
  -webkit-text-stroke: 0;
  text-shadow: none;
}

.auth-modal .auth-card-sub {
  margin-top: 18px;
  color: var(--white);
}

.auth-modal .auth-switch {
  color: var(--white);
}

.auth-modal .auth-field label {
  color: var(--yellow-card);
  font-size: 0.85rem;
  text-transform: uppercase;
}

.auth-modal .auth-field input {
  background: var(--white);
  border: 3px solid var(--yellow-card);
  border-radius: 14px;
  color: var(--text-dark);
}

.auth-modal .auth-field input::placeholder { color: #8a97b8; }

.auth-modal .auth-field input:focus {
  border-color: var(--white);
  box-shadow: 0 0 0 3px rgba(255, 244, 78, 0.55);
}

.auth-modal .auth-field input:focus-visible,
.auth-modal .auth-tab:focus-visible {
  outline: 2px solid var(--white);
}

.auth-modal .auth-field input:-webkit-autofill {
  -webkit-text-fill-color: var(--text-dark);
  -webkit-box-shadow: 0 0 0px 1000px #ffffff inset;
}

.auth-modal .auth-submit-btn {
  margin-top: 6px;
  padding: 16px 14px 13px;
  background: var(--yellow-card);
  color: var(--coral);
  border: 0;
  border-radius: 16px;
  font-size: 1.1rem;
  text-transform: uppercase;
  box-shadow: none;
}

.auth-modal .auth-submit-btn:hover:not(:disabled) {
  background: #fff87a;
  box-shadow: 0 5px 0 rgba(0, 0, 0, 0.2);
}

.auth-modal .auth-submit-btn:focus-visible {
  outline: 2px solid var(--white);
  outline-offset: 2px;
}

.auth-modal .auth-btn-spinner {
  border-color: rgba(235, 66, 41, 0.35);
  border-top-color: var(--coral);
}

/* Links on the coral body (Forgot password / Resend / Sign up / Log in) */
.auth-modal .auth-link-btn,
.auth-modal .auth-inline-link,
.auth-modal .auth-switch .auth-link-btn {
  color: var(--yellow-card);
  font-weight: 800;
  text-shadow: none;
}

.auth-modal .auth-link-btn:hover,
.auth-modal .auth-switch .auth-link-btn:hover {
  color: var(--white);
}

/* Error/success boxes are light, so their inline link stays dark */
.auth-modal .auth-message .auth-inline-link { color: inherit; }

/* Header-bar controls: back arrow on the left (as in the game panel), close
   on the right. The back button keeps its text for screen readers via
   aria-label; visually it is just the arrow. */
.auth-modal .auth-back-btn,
.auth-modal .auth-modal-close {
  position: absolute;
  top: 12px;
  width: 36px;
  height: 36px;
  margin: 0;
  border-radius: 10px;
  color: var(--coral);
}

.auth-modal .auth-back-btn {
  left: 12px;
  display: block;
  font-size: 0;
}

.auth-modal .auth-back-btn::before {
  content: '';
  position: absolute;
  inset: 4px;
  background: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M9 4 3 9.5 9 15'/%3E%3Cpath d='M4 9.5h11a5 5 0 0 1 0 10H7'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M9 4 3 9.5 9 15'/%3E%3Cpath d='M4 9.5h11a5 5 0 0 1 0 10H7'/%3E%3C/svg%3E") center / contain no-repeat;
}

.auth-modal .auth-modal-close {
  right: 12px;
  z-index: 1;
  font-size: 2rem;
  font-weight: 800;
}

.auth-modal .auth-back-btn:hover,
.auth-modal .auth-back-btn:focus-visible,
.auth-modal .auth-modal-close:hover,
.auth-modal .auth-modal-close:focus-visible {
  background: rgba(235, 66, 41, 0.15);
  color: var(--coral);
}

.auth-modal .auth-message--error {
  background: #ffe3de;
  border: 2px solid var(--white);
  color: #a3210f;
}

.auth-modal .auth-message--success {
  background: #dcf5e6;
  border: 2px solid var(--white);
  color: #1d6b3f;
}

.auth-toast {
  background: var(--yellow-card);
  border: 0;
  color: var(--coral);
  font-weight: 800;
}

@media (max-width: 520px) {
  .auth-modal .auth-card {
    --auth-pad: 20px;
    padding-bottom: 26px;
    border-radius: 16px;
  }

  .auth-modal .auth-card-title { font-size: 1.35rem; }
}
