/* ClearMath Academy — account control + auth modal (Phase 1 of the paid
   pivot). All classes are scoped with the cm-auth- prefix so they can't
   collide with existing site styles. Uses the site's design tokens
   (--teal, --ink, --line, etc.) with hardcoded fallbacks. */

/* ---- Topbar account control ---------------------------------------- */
.cm-auth-control {
  position: relative;
  display: inline-flex;
  align-items: center;
  margin-left: 4px;
}

.cm-auth-signin-btn {
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  color: #fff;
  background: var(--teal, #178f86);
  border: 1px solid var(--teal, #178f86);
  border-radius: 8px;
  padding: 10px 16px;
}
.cm-auth-signin-btn:hover {
  background: var(--focus, #125e59);
  border-color: var(--focus, #125e59);
}

.cm-auth-account-trigger {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: 220px;
  font: inherit;
  font-weight: 700;
  color: var(--ink, #263241);
  background: transparent;
  border: 1px solid var(--line, #dce3ec);
  border-radius: 999px;
  padding: 6px 12px 6px 6px;
  cursor: pointer;
}
.cm-auth-account-trigger:hover {
  background: #eef3f6;
}
.cm-auth-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--teal, #178f86);
  color: #fff;
  font-size: 13px;
  font-weight: 800;
  flex: 0 0 auto;
}
.cm-auth-account-email {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 140px;
  font-size: 14px;
}
.cm-auth-caret {
  font-size: 10px;
  color: var(--muted, #657181);
}

.cm-auth-account-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 60;
  min-width: 220px;
  padding: 8px;
  background: #fff;
  border: 1px solid var(--line, #dce3ec);
  border-radius: 10px;
  box-shadow: 0 20px 40px rgba(38, 50, 65, 0.12);
}
.cm-auth-account-menu[hidden] {
  display: none !important;
}
.cm-auth-account-meta {
  margin: 4px 8px 8px;
  font-size: 13px;
  line-height: 1.4;
  color: var(--muted, #657181);
}
.cm-auth-account-meta strong {
  color: var(--ink, #263241);
  word-break: break-all;
}
.cm-auth-menu-item {
  display: block;
  width: 100%;
  text-align: left;
  font: inherit;
  font-weight: 700;
  color: var(--ink, #263241);
  background: transparent;
  border: none;
  border-radius: 8px;
  padding: 10px 12px;
  cursor: pointer;
}
.cm-auth-menu-item:hover {
  background: #eef3f6;
}

/* ---- Modal --------------------------------------------------------- */
.cm-auth-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(38, 50, 65, 0.45);
}
.cm-auth-overlay[hidden] {
  display: none !important;
}
body.cm-auth-open {
  overflow: hidden;
}

.cm-auth-modal {
  position: relative;
  width: 100%;
  max-width: 420px;
  background: #fff;
  border-radius: 14px;
  padding: 28px 26px 24px;
  box-shadow: 0 24px 60px rgba(38, 50, 65, 0.28);
}
.cm-auth-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 34px;
  height: 34px;
  font-size: 24px;
  line-height: 1;
  color: var(--muted, #657181);
  background: transparent;
  border: none;
  border-radius: 8px;
  cursor: pointer;
}
.cm-auth-close:hover {
  background: #eef3f6;
  color: var(--ink, #263241);
}
.cm-auth-title {
  margin: 0 0 4px;
  font-size: 22px;
  color: var(--ink, #263241);
}
.cm-auth-sub {
  margin: 0 0 18px;
  font-size: 14px;
  color: var(--muted, #657181);
}

.cm-auth-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 18px;
  padding: 4px;
  background: var(--paper, #f8fafc);
  border: 1px solid var(--line, #dce3ec);
  border-radius: 10px;
}
.cm-auth-tabs[hidden] {
  display: none !important;
}
.cm-auth-tab {
  flex: 1;
  font: inherit;
  font-weight: 700;
  font-size: 14px;
  color: var(--muted, #657181);
  background: transparent;
  border: none;
  border-radius: 7px;
  padding: 9px 10px;
  cursor: pointer;
}
.cm-auth-tab.is-active {
  background: #fff;
  color: var(--ink, #263241);
  box-shadow: 0 1px 2px rgba(38, 50, 65, 0.12);
}

.cm-auth-field {
  display: block;
  margin-bottom: 14px;
}
.cm-auth-field[hidden] {
  display: none !important;
}
.cm-auth-field span {
  display: block;
  margin-bottom: 6px;
  font-size: 13px;
  font-weight: 700;
  color: var(--ink, #263241);
}
.cm-auth-field input {
  width: 100%;
  font: inherit;
  font-size: 15px;
  color: var(--ink, #263241);
  background: #fff;
  border: 1px solid var(--line, #dce3ec);
  border-radius: 8px;
  padding: 11px 12px;
}
.cm-auth-field input:focus {
  outline: none;
  border-color: var(--teal, #178f86);
  box-shadow: 0 0 0 3px rgba(23, 143, 134, 0.15);
}

.cm-auth-msg {
  margin: 0 0 14px;
  padding: 10px 12px;
  font-size: 14px;
  border-radius: 8px;
}
.cm-auth-msg[hidden] {
  display: none !important;
}
.cm-auth-msg-error {
  background: #fbeceb;
  color: var(--coral, #b4473f);
}
.cm-auth-msg-success {
  background: #e8f3f1;
  color: var(--focus, #125e59);
}

.cm-auth-submit {
  width: 100%;
  font: inherit;
  font-weight: 800;
  font-size: 15px;
  color: #fff;
  background: var(--teal, #178f86);
  border: none;
  border-radius: 9px;
  padding: 13px 16px;
  cursor: pointer;
}
.cm-auth-submit:hover {
  background: var(--focus, #125e59);
}
.cm-auth-submit:disabled {
  opacity: 0.7;
  cursor: default;
}

.cm-auth-forgot {
  display: block;
  margin: 12px auto 0;
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  color: var(--teal, #178f86);
  background: transparent;
  border: none;
  cursor: pointer;
}
.cm-auth-forgot[hidden] {
  display: none !important;
}
.cm-auth-forgot:hover {
  text-decoration: underline;
}

.cm-auth-foot {
  margin: 16px 0 0;
  text-align: center;
  font-size: 12px;
  color: var(--muted, #657181);
}

/* ---- Mobile (matches the topnav drawer breakpoint) ----------------- */
@media (max-width: 680px) {
  .cm-auth-control {
    width: 100%;
    margin: 8px 0 0;
  }
  .cm-auth-signin-btn,
  .cm-auth-account-trigger {
    width: 100%;
    justify-content: center;
  }
  .cm-auth-account-menu {
    right: auto;
    left: 0;
    width: 100%;
  }
}
