/* Nexys account popup — sits in the header, uses the tokens from style.css. */

/* Wrapper holding the button and the popup it anchors. */
.account-wrap { position: relative; }

.account-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  background: none;
  border: none;
  border-radius: 50%;
  line-height: 0;
  text-decoration: none;
  cursor: pointer;
}

/* Signed out: a plain person glyph inside a ring. */
.account-toggle__icon {
  width: 40px;
  height: 40px;
  padding: 9px;
  border: 1.5px solid var(--border);
  border-radius: 50%;
  background: var(--card);
  color: var(--blue-light);
  transition: border-color var(--ease), box-shadow var(--ease), transform var(--ease);
}
.account-toggle:hover .account-toggle__icon {
  border-color: var(--blue);
  box-shadow: 0 0 0 4px rgba(46, 125, 255, .12);
}
.account-toggle:active .account-toggle__icon { transform: scale(.94); }

/* Signed in: initials, or the picture the provider gave us. */
.account-toggle__avatar {
  display: flex;
  flex: 0 0 40px;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  aspect-ratio: 1 / 1;
  overflow: hidden;
  border-radius: 50%;
  background: var(--blue);
  box-shadow: 0 0 0 1.5px var(--border);
  color: #fff;
  font-size: .85rem;
  font-weight: 800;
  letter-spacing: .02em;
  transition: box-shadow var(--ease), transform var(--ease);
}
.account-toggle:hover .account-toggle__avatar { box-shadow: 0 0 0 2px var(--blue-light); }
.account-toggle:active .account-toggle__avatar { transform: scale(.94); }
.account-toggle__avatar { position: relative; }
.auth-me__avatar { position: relative; }

/* The picture is a lid over the initials: if it never loads, they are already there. */
.avatar__img {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
}

/* Author styles would otherwise beat the display:none that [hidden] carries. */
.account-toggle__icon[hidden],
.account-toggle__avatar[hidden] { display: none !important; }

/* ---- Popup ---- */

.auth-popup {
  position: absolute;
  top: calc(100% + 14px);
  right: 0;
  z-index: 60;
  width: 300px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: 0 24px 60px rgba(0, 0, 0, .55), 0 2px 8px rgba(0, 0, 0, .4);

  /* Never taller than the screen: "Esci" must stay reachable on a short window. */
  max-height: calc(100vh - 96px);
  max-height: calc(100dvh - 96px);
  overflow-y: auto;

  opacity: 0;
  transform: translateY(-6px) scale(.97);
  transform-origin: top right;
  pointer-events: none;
  transition: opacity 180ms ease, transform 180ms ease;
}
.auth-popup.is-open {
  opacity: 1;
  transform: none;
  pointer-events: auto;
}

/* ---- Tabs ---- */

.auth-tabs {
  display: flex;
  padding: 0 4px;
  border-bottom: 1px solid var(--border);
}
.auth-tab {
  flex: 1;
  padding: 14px 8px 12px;
  margin-bottom: -1px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  font: inherit;
  font-size: .875rem;
  font-weight: 600;
  cursor: pointer;
  transition: color var(--ease), border-color var(--ease);
}
.auth-tab:hover:not(.is-active) { color: var(--text-strong); }
.auth-tab.is-active { border-bottom-color: var(--blue); color: var(--text-strong); }

/* ---- Panels ---- */

.auth-panel { display: none; padding: 18px 20px 20px; }
.auth-panel.is-active { display: block; }

/* ---- Google ---- */

.auth-btn-google {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  width: 100%;
  height: 42px;
  padding: 0 14px;
  background: #fff;
  border: 1px solid #dadce0;
  border-radius: var(--radius);
  color: #1f2937;
  font: inherit;
  font-size: .875rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: background var(--ease), box-shadow var(--ease);
}
.auth-btn-google:hover { background: #f1f3f4; box-shadow: 0 1px 4px rgba(0, 0, 0, .35); color: #1f2937; }
.auth-btn-google svg { flex: none; }

.auth-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 16px 0;
  color: var(--muted);
  font-size: .8125rem;
}
.auth-divider::before,
.auth-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* ---- Fields ---- */

.auth-field { margin-bottom: 12px; }
.auth-field label {
  display: block;
  margin-bottom: 5px;
  color: var(--muted);
  font-size: .6875rem;
  font-weight: 700;
  letter-spacing: .055em;
  text-transform: uppercase;
}
.auth-field input {
  display: block;
  width: 100%;
  height: 40px;
  padding: 0 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-strong);
  font: inherit;
  font-size: .9375rem;
  transition: border-color var(--ease), box-shadow var(--ease);
}
.auth-field input::placeholder { color: var(--muted); opacity: .7; }
.auth-field input:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(46, 125, 255, .18);
}

.auth-btn-primary {
  width: 100%;
  height: 42px;
  margin-top: 6px;
  background: var(--blue);
  border: none;
  border-radius: var(--radius);
  color: #fff;
  font: inherit;
  font-size: .9375rem;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--ease), opacity var(--ease), transform var(--ease);
}
.auth-btn-primary:hover { background: var(--blue-light); }
.auth-btn-primary:active { transform: scale(.99); }
.auth-btn-primary[disabled] { opacity: .55; cursor: default; }

.auth-link {
  color: var(--muted);
  font-size: .8125rem;
  text-decoration: none;
  cursor: pointer;
  background: none;
  border: none;
  padding: 0;
  font-family: inherit;
}
.auth-link:hover { color: var(--blue-light); text-decoration: underline; }

.auth-row-right { margin: -4px 0 12px; text-align: right; }
.auth-foot { margin-top: 14px; color: var(--muted); font-size: .8125rem; text-align: center; }

/* ---- Messages ---- */

.auth-msg {
  display: none;
  margin-bottom: 14px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-left: 3px solid var(--crit);
  border-radius: var(--radius-sm);
  background: var(--card);
  color: var(--text);
  font-size: .8438rem;
  line-height: 1.45;
}
.auth-msg.is-shown { display: block; }
.auth-msg.is-ok { border-left-color: var(--ok); }

/* ---- Confirmation code ---- */

.auth-verify-info { padding: 2px 0 16px; text-align: center; }
.auth-verify-info svg { color: var(--blue-light); }
.auth-verify-info h3 { margin: 8px 0 4px; font-size: 1rem; }
.auth-verify-info p { color: var(--muted); font-size: .8125rem; }
.auth-verify-info strong { color: var(--text-strong); word-break: break-all; }

.auth-field input.auth-code-input {
  height: 58px;
  padding: 0 12px;
  font-family: var(--font-mono);
  font-size: 1.65rem;
  font-weight: 800;
  letter-spacing: .5em;
  text-align: center;
  text-indent: .5em;
}

/* ---- Signed in ---- */

.auth-me {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 6px 4px 18px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--border);
  text-align: center;
}
.auth-me__avatar {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  width: 64px;
  height: 64px;
  aspect-ratio: 1 / 1;
  margin-bottom: 12px;
  overflow: hidden;
  border-radius: 50%;
  background: var(--blue);
  box-shadow: 0 6px 18px rgba(46, 125, 255, .28);
  color: #fff;
  font-size: 1.4rem;
  font-weight: 800;
}

.auth-me__name {
  max-width: 100%;
  overflow: hidden;
  color: var(--text-strong);
  font-size: 1.02rem;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.auth-me__email {
  max-width: 100%;
  margin-top: 2px;
  overflow: hidden;
  color: var(--muted);
  font-size: .8rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.auth-me__badge {
  margin-top: 10px;
  padding: 3px 10px;
  border: 1px solid rgba(46, 125, 255, .35);
  border-radius: 999px;
  background: rgba(46, 125, 255, .12);
  color: var(--blue-light);
  font-size: .6563rem;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
}

.auth-me__actions { display: flex; flex-direction: column; gap: 9px; }

.auth-btn-admin,
.auth-btn-plain,
.auth-btn-logout {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  width: 100%;
  min-height: 46px;
  padding: 0 14px;
  border-radius: 11px;
  font: inherit;
  font-size: .9rem;
  font-weight: 700;
  line-height: 1;
  text-decoration: none;
  cursor: pointer;
  transition: background var(--ease), border-color var(--ease), color var(--ease);
}
.auth-btn-admin svg,
.auth-btn-plain svg,
.auth-btn-logout svg { flex: none; width: 18px; height: 18px; }

.auth-btn-admin { background: var(--blue); border: 1px solid var(--blue); color: #fff; }
.auth-btn-admin:hover { background: var(--blue-light); border-color: var(--blue-light); color: #fff; }

.auth-btn-plain { background: transparent; border: 1px solid var(--border); color: var(--text); }
.auth-btn-plain:hover { border-color: var(--blue); color: var(--blue-light); }

.auth-btn-logout { background: transparent; border: 1px solid var(--border); color: var(--muted); }
.auth-btn-logout:hover { border-color: var(--crit); color: var(--crit); }

/* Without scripting the popup can never open: the link to the page takes over. */
.auth-nojs { display: none; }
.no-js .auth-popup { display: none; }
.no-js .auth-nojs { display: inline-flex; }
.no-js .account-wrap { display: none; }

/* The account control sits beside the burger, never inside the menu it opens.
   The menu keeps hugging the right side, with the account after it. */
.site-header__side {
  display: flex;
  flex: none;
  align-items: center;
  gap: 12px;
}
.site-header__inner > .site-nav { margin-left: auto; }

/* ---- Responsive ---- */

@media (max-width: 720px) {
  /* Anchored to the icon, but never wider than the screen it drops onto. */
  .auth-popup {
    width: min(330px, calc(100vw - 22px));
    right: -4px;
  }
}
