/**
 * TheBrainSnack login modal — premium, accessible, theme-isolated.
 */

/* Closed state (open via .thebrainsnack-login-overlay--open) */
.thebrainsnack-login-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(7, 22, 30, 0.66);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 180ms ease-out, visibility 180ms ease-out;
}

.thebrainsnack-login-overlay.thebrainsnack-login-overlay--open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  animation: tbsFadeIn 180ms ease-out;
}

.thebrainsnack-login-modal {
  position: relative;
  width: min(100%, 460px);
  background: #ffffff;
  color: #1f2937;
  color-scheme: light;
  border: 1px solid rgba(15, 23, 42, 0.08);
  border-radius: 22px;
  box-shadow:
    0 18px 40px rgba(15, 23, 42, 0.14),
    0 8px 18px rgba(15, 23, 42, 0.08);
  padding: 30px 30px 28px;
  font-family: inherit;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  animation: tbsModalUp 220ms cubic-bezier(0.16, 1, 0.3, 1);
}

/* Prevent homepage/theme light text from bleeding into the card */
.thebrainsnack-login-modal,
.thebrainsnack-login-modal h2,
.thebrainsnack-login-modal p,
.thebrainsnack-login-modal label,
.thebrainsnack-login-modal input,
.thebrainsnack-login-modal button {
  font-family: inherit;
}

.thebrainsnack-login-modal h2.thebrainsnack-login-title {
  color: #111827;
}

.thebrainsnack-login-modal p.thebrainsnack-login-subtitle,
.thebrainsnack-login-modal .thebrainsnack-login-footer p {
  color: #4b5563;
}

.thebrainsnack-login-close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 38px;
  height: 38px;
  border: 0;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  color: #111827;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  transition: background-color 160ms ease, color 160ms ease, transform 160ms ease;
}

.thebrainsnack-login-close:hover {
  background: #f3f4f6;
  color: #0f172a;
  transform: scale(1.03);
}

.thebrainsnack-login-close:focus-visible {
  outline: 3px solid rgba(43, 184, 200, 0.35);
  outline-offset: 2px;
}

.thebrainsnack-login-header {
  margin-bottom: 22px;
  padding-right: 36px;
}

.thebrainsnack-login-title {
  margin: 0 0 8px;
  color: #111827;
  font-size: 1.75rem;
  line-height: 1.15;
  font-weight: 750;
  letter-spacing: -0.02em;
}

.thebrainsnack-login-subtitle {
  margin: 0;
  color: #4b5563;
  font-size: 0.98rem;
  line-height: 1.55;
}

.thebrainsnack-login-form {
  display: grid;
  gap: 16px;
}

.thebrainsnack-login-field {
  display: grid;
  gap: 7px;
}

.thebrainsnack-login-label {
  color: #374151;
  font-size: 0.92rem;
  font-weight: 600;
  line-height: 1.4;
}

.thebrainsnack-login-input {
  width: 100%;
  min-height: 52px;
  padding: 14px 16px;
  border: 1px solid #cfd8e3;
  border-radius: 12px;
  background: #ffffff;
  color: #111827;
  font-size: 1rem;
  line-height: 1.5;
  box-sizing: border-box;
  box-shadow: inset 0 1px 2px rgba(15, 23, 42, 0.03);
  -webkit-text-fill-color: #111827;
  transition:
    border-color 160ms ease,
    box-shadow 160ms ease,
    background-color 160ms ease;
}

.thebrainsnack-login-input:hover {
  border-color: #b8c5d6;
}

.thebrainsnack-login-input:focus {
  border-color: #2bb8c8;
  box-shadow:
    0 0 0 4px rgba(43, 184, 200, 0.18),
    inset 0 1px 2px rgba(15, 23, 42, 0.03);
  outline: none;
}

.thebrainsnack-login-input::placeholder {
  color: #6b7280;
  opacity: 1;
}

.thebrainsnack-login-input:-webkit-autofill,
.thebrainsnack-login-input:-webkit-autofill:hover,
.thebrainsnack-login-input:-webkit-autofill:focus {
  -webkit-text-fill-color: #111827;
  -webkit-box-shadow: 0 0 0 1000px #ffffff inset;
  transition: background-color 9999s ease-in-out 0s;
}

.thebrainsnack-login-help,
.thebrainsnack-login-error,
.thebrainsnack-login-success {
  font-size: 0.9rem;
  line-height: 1.45;
  margin: 2px 0 0;
}

.thebrainsnack-login-help {
  color: #6b7280;
}

.thebrainsnack-login-error {
  color: #b42318;
  font-weight: 500;
}

.thebrainsnack-login-error[hidden] {
  display: none;
}

.thebrainsnack-login-success {
  color: #166534;
}

.thebrainsnack-login-actions {
  margin-top: 6px;
  display: grid;
  gap: 12px;
}

.thebrainsnack-login-submit {
  width: 100%;
  min-height: 52px;
  border: 0;
  border-radius: 12px;
  padding: 14px 18px;
  background: linear-gradient(180deg, #38c3d2 0%, #25b2c1 100%);
  color: #08242d;
  font-size: 1rem;
  font-weight: 800;
  letter-spacing: 0.01em;
  cursor: pointer;
  -webkit-text-fill-color: #08242d;
  box-shadow:
    0 10px 20px rgba(37, 178, 193, 0.18),
    inset 0 1px 0 rgba(255, 255, 255, 0.35);
  transition:
    transform 160ms ease,
    box-shadow 160ms ease,
    filter 160ms ease;
}

.thebrainsnack-login-submit:hover {
  transform: translateY(-1px);
  box-shadow:
    0 14px 26px rgba(37, 178, 193, 0.22),
    inset 0 1px 0 rgba(255, 255, 255, 0.35);
  filter: saturate(1.03);
}

.thebrainsnack-login-submit:active {
  transform: translateY(0);
  box-shadow:
    0 8px 16px rgba(37, 178, 193, 0.18),
    inset 0 1px 0 rgba(255, 255, 255, 0.35);
}

.thebrainsnack-login-submit:focus-visible {
  outline: 3px solid rgba(43, 184, 200, 0.3);
  outline-offset: 3px;
}

.thebrainsnack-login-submit[disabled] {
  cursor: not-allowed;
  opacity: 0.7;
  transform: none;
  box-shadow: none;
}

.thebrainsnack-login-footer {
  margin-top: 14px;
  text-align: center;
}

.thebrainsnack-login-footer p {
  margin: 0;
  color: #6b7280;
  font-size: 0.88rem;
  line-height: 1.45;
}

.thebrainsnack-login-footer a {
  color: #0f766e;
  text-decoration: none;
  font-weight: 600;
}

.thebrainsnack-login-footer a:hover {
  text-decoration: underline;
}

@keyframes tbsFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes tbsModalUp {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.985);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@media (max-width: 640px) {
  .thebrainsnack-login-overlay {
    padding: 16px;
    align-items: flex-end;
  }

  .thebrainsnack-login-modal {
    width: 100%;
    border-radius: 20px 20px 16px 16px;
    padding: 24px 20px 22px;
  }

  .thebrainsnack-login-title {
    font-size: 1.45rem;
  }

  .thebrainsnack-login-input,
  .thebrainsnack-login-submit {
    min-height: 50px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .thebrainsnack-login-overlay,
  .thebrainsnack-login-modal,
  .thebrainsnack-login-close,
  .thebrainsnack-login-input,
  .thebrainsnack-login-submit {
    animation: none;
    transition: none;
  }
}

/* Header sign-out — visible on all pages when client is logged in */
.header__actions .tbs-header-logout {
  margin-left: 8px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.2;
  padding: 8px 14px;
  border-radius: 8px;
  cursor: pointer;
  vertical-align: middle;
}

.header__actions .tbs-header-logout:hover {
  background: rgba(255, 255, 255, 0.16);
  color: #ffffff;
}

.header.scrolled .header__actions .tbs-header-logout,
.header__actions .tbs-header-logout:focus-visible {
  border-color: #cfd8dc;
  background: #eef3f4;
  color: #1f2937;
}

.header.scrolled .header__actions .tbs-header-logout:hover {
  background: #e3ecef;
  color: #111827;
}
