/* One account experience for MIX pages and the Studio: «Войти» and «Ещё» for a guest, the round photo and
 * its menu for a signed-in person, the sign-in window and card, the notice after a redirect, the photo
 * block of the settings page. Markup: partials/_account_menu.html, partials/_sign_in_dialog.html.
 * Behaviour: account_menu.js, reader_login_prompt.js, reader_account.js. Check at 388x631 and 256x420. */

/* The hidden attribute must win over the display set by the classes below. */
.mx-acc [hidden],
.mx-acc-panel [hidden],
.mx-signin [hidden],
.mx-signin-card [hidden],
[data-account-user][hidden],
[data-account-guest][hidden],
[data-account-brand][hidden],
[data-reader-login][hidden],
.mx-acc-notice[hidden],
.mx-profile-photo [hidden] {
  display: none !important;
}

/* ---------- bar: «Войти», «Ещё», photo ---------- */
.mx-acc {
  align-items: center;
  display: flex;
  gap: 0.5rem;
}

.mx-acc-shell {
  align-items: center;
  display: inline-flex;
  position: relative;
}

.mx-login-btn,
.mx-header a.mx-login-btn,
.mix-studio-header a.mx-login-btn,
a.mx-login-btn:visited {
  align-items: center;
  background: var(--mx-ink);
  border: 1px solid var(--mx-ink);
  border-radius: 999px;
  box-sizing: border-box;
  color: #fff;
  display: inline-flex;
  font-size: 0.95rem;
  font-weight: 600;
  justify-content: center;
  min-height: 44px;
  padding: 0 1.1rem;
  text-decoration: none;
}

.mx-login-btn:hover {
  opacity: 0.88;
}

.mx-acc-more,
.mx-acc-toggle {
  align-items: center;
  background: transparent;
  border: 0;
  border-radius: 999px;
  color: var(--mx-ink);
  cursor: pointer;
  display: inline-flex;
  height: 44px;
  justify-content: center;
  padding: 0;
  width: 44px;
}

.mx-acc-more {
  border: 1px solid var(--mx-line);
}

.mx-acc-more svg {
  fill: currentColor;
}

.mx-acc-more:hover,
.mx-acc-toggle:hover {
  background: rgba(17, 24, 39, 0.06);
}

.mx-login-btn:focus-visible,
.mx-acc-more:focus-visible,
.mx-acc-toggle:focus-visible,
.mx-acc-item:focus-visible,
.mx-signin-close:focus-visible,
.mx-signin-btn:focus-visible {
  outline: 3px solid var(--mx-ink);
  outline-offset: 2px;
}

.mx-avatar {
  align-items: center;
  background: #e5e7eb;
  border-radius: 50%;
  color: #111827;
  display: inline-flex;
  flex-shrink: 0;
  font-size: 0.85rem;
  font-weight: 800;
  height: 36px;
  justify-content: center;
  overflow: hidden;
  width: 36px;
}

.mx-avatar.is-large {
  font-size: 1.05rem;
  height: 48px;
  width: 48px;
}

.mx-avatar img {
  display: block;
  height: 100%;
  object-fit: cover;
  width: 100%;
}

/* Name not known yet (page drawn for a signed-in person before the answer): a plain person, never a wrong letter. */
.mx-avatar [data-account-initials]:empty {
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='12' cy='8' r='4'/%3E%3Cpath d='M4 21c.8-4 4-6 8-6s7.2 2 8 6'/%3E%3C/svg%3E") center / contain no-repeat;
  height: 60%;
  width: 60%;
}

/* ---------- menu: desktop dropdown ---------- */
.mx-acc-panel {
  background: #fff;
  border: 1px solid var(--mx-line);
  border-radius: 16px;
  box-shadow: var(--mx-shadow-xl, 0 10px 30px rgba(0, 0, 0, 0.13));
  box-sizing: border-box;
  max-height: calc(100vh - 90px);
  max-height: calc(100dvh - 90px);
  max-width: min(320px, calc(100vw - 1rem));
  min-width: 230px;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 6px;
  position: absolute;
  right: 0;
  top: calc(100% + 10px);
  width: max-content;
  z-index: 60;
}

.mx-acc-item {
  align-items: center;
  background: none;
  border: 0;
  border-radius: 10px;
  box-sizing: border-box;
  color: var(--mx-ink);
  cursor: pointer;
  display: flex;
  font: inherit;
  font-size: 0.97rem;
  font-weight: 600;
  gap: 0.6rem;
  min-height: 44px;
  padding: 0.55rem 0.85rem;
  text-align: left;
  text-decoration: none;
  width: 100%;
}

.mx-acc-item:hover,
.mx-acc-item:focus-visible {
  background: rgba(17, 24, 39, 0.06);
}

.mx-acc-item:focus:not(:focus-visible) {
  outline: none;
}

.mx-acc-item:focus-visible {
  outline-offset: -3px;
}

.mx-acc-head {
  align-items: center;
  border-bottom: 1px solid var(--mx-line);
  display: flex;
  gap: 0.75rem;
  margin-bottom: 4px;
  padding: 0.6rem 0.85rem 0.8rem;
}

.mx-acc-who {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.mx-acc-who strong {
  font-size: 1rem;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.mx-acc-who span {
  color: var(--mx-muted);
  font-size: 0.85rem;
}

.mx-acc-sep {
  background: var(--mx-line);
  height: 1px;
  margin: 4px 8px;
}

/* ---------- menu: phone bottom sheet ---------- */
.mx-menu-backdrop {
  display: none;
}

@media (max-width: 980px) {
  .mx-menu-backdrop:not([hidden]) {
    background: rgba(21, 24, 28, 0.45);
    display: block;
    inset: 0;
    position: fixed;
    z-index: 10000;
  }

  /* The sheet lies inside the post-page buttons: while it is open they must not slide (the sheet would fly in from above). */
  body.mx-menu-open .mx-header.is-post-reader .post-reader-mobile-controls {
    transition: none;
  }

  .mx-acc-panel {
    border: 0;
    border-radius: 20px 20px 0 0;
    bottom: 0;
    box-shadow: 0 -8px 32px rgba(15, 23, 42, 0.2);
    left: 0;
    max-height: 85vh;
    max-height: 85dvh;
    max-width: none;
    padding: 8px 8px calc(8px + env(safe-area-inset-bottom, 0px));
    position: fixed;
    right: 0;
    top: auto;
    width: auto;
    z-index: 60;
  }

  .mx-acc-item {
    font-size: 1.0625rem;
    min-height: 48px;
  }

  .mx-acc-item:active {
    background: rgba(17, 24, 39, 0.1);
  }
}

/* The sheet lies inside the sticky Studio bar: lift the bar above the backdrop while the menu is open. */
/* Above the cookie bar (9999) too, or it covers the sheet. */
body.mx-menu-open .mix-studio-header,
body.mx-menu-open .mx-header {
  z-index: 10001;
}

/* Very narrow window (Windows scaling 125-150 %): logo word goes, the bar still fits. */
@media (max-width: 340px) {
  .mx-header .mx-logo-word,
  .mix-studio-header .mx-logo-word {
    display: none;
  }

  .mx-login-btn {
    padding: 0 0.8rem;
  }

  .mx-acc {
    gap: 0.25rem;
  }
}

/* ---------- sign-in window and card ---------- */
.mx-signin {
  align-items: center;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  inset: 0;
  justify-content: center;
  padding: 0.75rem;
  position: fixed;
  /* Above the cookie bar (9999), or it covers the document links of the window. */
  z-index: 10000;
}

.mx-signin[hidden] {
  display: none;
}

.mx-signin-card {
  background: #fff;
  border-radius: 20px;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  max-height: 100%;
  max-width: 26rem;
  overflow-y: auto;
  padding: 1.25rem;
  position: relative;
  width: 100%;
}

.mx-signin-card.is-page {
  border: 1px solid var(--mx-line);
  box-shadow: var(--mx-shadow-md, 0 3px 12px rgba(0, 0, 0, 0.1));
  margin: 0 auto 1.5rem;
  max-height: none;
  overflow: visible;
}

.mx-signin-title {
  font-size: 1.35rem;
  line-height: 1.2;
  margin: 0;
  padding-right: 2.5rem;
}

.mx-signin-card.is-page .mx-signin-title {
  padding-right: 0;
}

.mx-signin-why,
.mx-signin-hint,
.mx-signin-help {
  color: var(--mx-muted);
  font-size: 0.95rem;
  line-height: 1.4;
  margin: 0;
}

.mx-signin-close {
  align-items: center;
  background: #f3f4f6;
  border: 0;
  border-radius: 50%;
  color: var(--mx-ink);
  cursor: pointer;
  display: inline-flex;
  height: 40px;
  justify-content: center;
  padding: 0;
  position: absolute;
  right: 0.7rem;
  top: 0.7rem;
  width: 40px;
}

.mx-signin-close svg {
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-width: 2.2;
}

.mx-signin-form {
  display: grid;
  gap: 0.6rem;
}

.mx-signin-consent {
  align-items: flex-start;
  display: flex;
  font-size: 0.9rem;
  gap: 0.6rem;
  line-height: 1.4;
}

.mx-signin-consent input {
  flex: none;
  height: 22px;
  margin: 1px 0 0;
  width: 22px;
}

.mx-signin-consent a,
.mx-signin-legal a,
.mx-signin-help a {
  color: var(--mx-link, #1d4ed8);
  text-decoration: underline;
}

.mx-signin-btn {
  align-items: center;
  border: 0;
  border-radius: 12px;
  box-sizing: border-box;
  cursor: pointer;
  display: flex;
  font: inherit;
  font-size: 1.05rem;
  font-weight: 600;
  gap: 0.75rem;
  justify-content: center;
  min-height: 52px;
  padding: 0.5rem 1rem;
  text-align: center;
  text-decoration: none;
  width: 100%;
}

.mx-signin-vk {
  background: #0077ff;
  color: #fff;
}

.mx-signin-yandex {
  background: #000;
  color: #fff;
}

a.mx-signin-max-btn,
a.mx-signin-max-btn:visited {
  background: #fff;
  border: 2px solid var(--mx-ink);
  color: var(--mx-ink);
}

.mx-signin-max {
  border-top: 1px solid var(--mx-line);
  display: grid;
  gap: 0.4rem;
  padding-top: 0.75rem;
}

.mx-signin-quiet {
  font-size: 0.95rem;
  text-align: center;
}

.mx-signin-legal {
  color: #666;
  font-size: 0.78rem;
  line-height: 1.4;
  margin: 0;
}

/* Bottom sheet on a phone; on a low window the one-line explanation goes so the buttons stay in view. */
@media (max-width: 480px) {
  .mx-signin {
    align-items: flex-end;
    padding: 0;
  }

  .mx-signin-card:not(.is-page) {
    border-radius: 20px 20px 0 0;
    max-width: none;
    padding: 1rem 1rem calc(1rem + env(safe-area-inset-bottom, 0px));
  }
}

@media (max-height: 560px) {
  .mx-signin-card {
    gap: 0.4rem;
    padding: 0.75rem;
  }

  .mx-signin-title {
    font-size: 1.15rem;
  }

  .mx-signin-why {
    display: none;
  }

  .mx-signin-btn {
    min-height: 46px;
  }
}

/* ---------- notice after a redirect ---------- */
.mx-acc-notice {
  align-items: flex-start;
  background: #ecfdf3;
  border: 1px solid #a7e3bd;
  border-radius: 12px;
  color: #14532d;
  display: flex;
  gap: 0.75rem;
  margin: 0.75rem auto;
  max-width: 920px;
  padding: 0.75rem 1rem;
}

.mx-acc-notice p {
  flex: 1;
  margin: 0;
}

.mx-acc-notice button {
  background: none;
  border: 0;
  color: inherit;
  cursor: pointer;
  font-size: 1.5rem;
  height: 32px;
  line-height: 1;
  padding: 0;
  width: 32px;
}

/* ---------- account pages in the public layout ---------- */
.mx-account-page {
  min-width: 0;
}

.mx-account-page .mix-native-card {
  margin-left: 0;
  margin-right: 0;
}

/* ---------- settings: photo ---------- */
.mx-profile-photo {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1rem;
}

.mx-profile-photo .mx-avatar {
  font-size: 1.6rem;
  height: 88px;
  width: 88px;
}

.mx-profile-photo-actions {
  display: grid;
  gap: 0.5rem;
}
