/*
 * New design — the sign-in and sign-up windows on the menu page: #auth_dialog.modal, #login, #register (body.nd-menu).
 * Look and motion only: js/menu.js keeps every submit, code and check. Stands alone: nothing here needs
 * the account layer, and the account layer needs nothing from here. See docs/new-design-auth.md.
 * Same weight as the menu layer: `:not(#\9)` is one id of weight, it beats the Sites' class rules.
 */
body.nd-menu {
  --nd-auth-mut: #6b6b6b;
  --nd-auth-field: #fafafa;
  --nd-auth-field-line: #c9c9c9;
  --nd-auth-divider: rgba(0, 0, 0, .08);
  --nd-auth-ink: #0d0d0d;
  --nd-auth-danger: #b42318;
  /* the script swaps these on a very light brand: white text on it would not read */
  --nd-auth-on-primary: var(--nd-on-primary, #fff); /* measured once, in new-design-menu.js */
  --nd-auth-accent: var(--primary);
  --nd-auth-fill-line: transparent;
  --nd-auth-tint: color-mix(in srgb, var(--primary) 9%, transparent);
  --nd-auth-primary-hover: color-mix(in srgb, var(--primary) 78%, #000);
  --nd-auth-e-soft: cubic-bezier(.16, 1, .3, 1);
  --nd-auth-e-out: cubic-bezier(.32, .72, 0, 1);
  /* the window stands from the top and grows down: its top does not move when the form changes */
  --nd-auth-top: clamp(16px, 8vh, 72px);
  --nd-auth-max-h: calc(100vh - var(--nd-auth-top) - 16px - var(--nd-cookie-h, 0px));
  --nd-auth-ico-close: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='1.7' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M18 6 6 18M6 6l12 12'/%3E%3C/svg%3E");
}

@supports (height: 100svh) {
  body.nd-menu {
    --nd-auth-max-h: calc(100svh - var(--nd-auth-top) - 16px - var(--nd-cookie-h, 0px));
  }
}

/* ───────────── Motion: the backdrop and the window go together ───────────── */
/* Bootstrap reads only the FIRST transition duration and waits for it: 0s there starts the window
   with the backdrop (not after it) and lets a close land at any moment of the opening. */
body.nd-menu.nd-auth-open .modal-backdrop:not(#\9) {
  transition: outline-color 0s, opacity .5s var(--nd-auth-e-soft);
}

/* the window's own backdrop; a bootbox above it keeps a plain one */
body.nd-menu.nd-auth-open .modal-backdrop:not(.modal-backdrop ~ .modal-backdrop):not(#\9) {
  background: rgba(0, 0, 0, .55);
  -webkit-backdrop-filter: blur(9px) saturate(115%);
  backdrop-filter: blur(9px) saturate(115%);
}

body.nd-menu.nd-auth-open .modal-backdrop.show:not(.modal-backdrop ~ .modal-backdrop):not(#\9) {
  opacity: 1;
}

body.nd-menu.nd-auth-closing .modal-backdrop.show:not(.modal-backdrop ~ .modal-backdrop):not(#\9) {
  opacity: 0;
  transition: outline-color 0s, opacity .45s var(--nd-auth-e-soft);
}

/* #login ↔ #register swap two windows and two backdrops: the page's dimness must not move */
body.nd-menu.nd-auth-swap .modal-backdrop:not(#\9) {
  opacity: 1;
  transition: none;
}

body.nd-menu.nd-auth-swap .modal-backdrop ~ .modal-backdrop:not(#\9) {
  background: transparent;
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
}

body.nd-menu :is(#auth_dialog.modal, #login, #register).fade:not(#\9) {
  transition: opacity .45s var(--nd-auth-e-soft);
}

/* as in the prototype the window only fades in where it stands, at every width: no travel, no scale
   (Bootstrap's own slide is cancelled too) */
body.nd-menu :is(#auth_dialog.modal, #login, #register).fade .modal-dialog:not(#\9) {
  transform: none;
  transition: none;
}

/* one window replaces another (#login ↔ #register, «forgot password»): as the prototype's single card,
   the old one goes and the new one stands at once, its content fades in. With 0s Bootstrap also ends
   the old window's hide at once, so a quick click back is not dropped mid-fade */
body.nd-menu.nd-auth-swap :is(#auth_dialog.modal, #login, #register).fade:not(#\9) {
  transition-duration: 0s;
}

body.nd-menu :is(#login, #register).nd-auth-in.show .modal-body:not(#\9) {
  animation: nd-auth-fade .4s var(--nd-auth-e-out);
}

/* ───────────── The window ───────────── */
/* a bootbox over the windows («forgot password», the phone's prompt) ends above the cookie notice too */
body.nd-menu.nd-auth-open .bootbox:not(#\9) {
  height: calc(100% - var(--nd-cookie-h, 0px));
}

body.nd-menu :is(#auth_dialog.modal, #login, #register):not(#\9) {
  width: 100%;
  /* the cookie notice stays over everything (front.css): while it is there the window ends above it */
  height: calc(100% - var(--nd-cookie-h, 0px));
  padding: 0 !important;
  background: none;
  text-align: start;
  inset-inline: 0;
}

body.nd-menu :is(#auth_dialog.modal, #login, #register) .modal-dialog:not(#\9) {
  width: min(420px, calc(100vw - 40px));
  max-width: none;
  min-height: calc(100% - var(--nd-auth-top) - 16px);
  margin: var(--nd-auth-top) auto 16px;
  padding: 0;
  /* .modal-dialog-centered: from the top, not the middle */
  align-items: flex-start;
}

/* Bootstrap's strut for centring is taller than this window's own margins allow on a phone */
body.nd-menu :is(#auth_dialog.modal, #login, #register) .modal-dialog:not(#\9)::before {
  content: none;
}

body.nd-menu :is(#auth_dialog.modal, #login, #register) .modal-content:not(#\9) {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 100%;
  height: auto;
  min-height: 0;
  max-height: var(--nd-auth-max-h);
  padding: 0;
  overflow: hidden;
  background: #fff;
  border: none;
  border-radius: 24px;
  box-shadow: 0 40px 90px -30px rgba(0, 0, 0, .5), 0 8px 24px -12px rgba(0, 0, 0, .2);
  color: var(--nd-auth-ink);
}

body.nd-menu :is(#auth_dialog.modal, #login, #register) .modal-header:not(#\9) {
  display: block;
  flex: none;
  height: auto;
  margin: 0;
  padding: 30px 60px 0;
  background: none;
  border: none;
  border-radius: 0;
}

/* the design's title: #login and #register have one, #auth_dialog.modal gets one from its active tab */
body.nd-menu :is(#login, #register) .modal-title:not(#\9),
body.nd-menu #auth_dialog.modal .nd-auth-title:not(#\9) {
  margin: 0;
  color: var(--nd-auth-ink);
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -.6px;
  line-height: 1.25;
  text-align: center;
}

body.nd-menu #auth_dialog.modal .nav-tabs:not(#\9) {
  display: none;
}

body.nd-menu :is(#auth_dialog.modal, #login, #register) .modal-header .close:not(#\9),
body.nd-menu.nd-auth-open .bootbox .bootbox-close-button:not(#\9) {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  float: none;
  width: 36px;
  height: 36px;
  margin: 0;
  padding: 0;
  background: var(--nd-auth-tint);
  border: none;
  border-radius: 50%;
  color: var(--nd-auth-accent);
  font-size: 0;
  line-height: 1;
  opacity: 1;
  text-shadow: none;
  transition: background .35s var(--nd-auth-e-soft), color .35s var(--nd-auth-e-soft), transform .4s var(--nd-auth-e-out);
}

body.nd-menu :is(#auth_dialog.modal, #login, #register) .modal-header .close:not(#\9) {
  position: absolute;
  top: 16px;
  right: auto;
  left: auto;
  inset-inline-end: 16px;
  z-index: 2;
}

body.nd-menu :is(#auth_dialog.modal, #login, #register) .modal-header .close > span:not(#\9) {
  display: block;
  width: 17px;
  height: 17px;
  background: currentColor;
  font-size: 0;
  -webkit-mask: var(--nd-auth-ico-close) center / contain no-repeat;
  mask: var(--nd-auth-ico-close) center / contain no-repeat;
}

body.nd-menu.nd-auth-open .bootbox .bootbox-close-button:not(#\9)::before {
  content: "";
  display: block;
  width: 17px;
  height: 17px;
  background: currentColor;
  -webkit-mask: var(--nd-auth-ico-close) center / contain no-repeat;
  mask: var(--nd-auth-ico-close) center / contain no-repeat;
}

/* the one scroll of a tall form on a low screen */
body.nd-menu :is(#auth_dialog.modal, #login, #register) .modal-body:not(#\9) {
  flex: 1 1 auto;
  min-height: 0;
  padding: 20px 28px 26px;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: rgba(13, 13, 13, .2) transparent;
}

body.nd-menu #auth_dialog.modal :is(.tab-content, .tab-pane):not(#\9) {
  margin: 0;
  padding: 0;
  background: none;
  border: none;
}

body.nd-menu #auth_dialog.modal .tab-pane.active:not(#\9) {
  animation: nd-auth-fade .4s var(--nd-auth-e-out);
}

/* ───────────── The form: one column, the action last ───────────── */
body.nd-menu :is(#auth_dialog.modal, #login, #register) form:not(#\9) {
  display: flex;
  flex-direction: column;
  margin: 0;
  text-align: start;
}

body.nd-menu :is(#auth_dialog.modal, #login, #register) form > br:not(#\9) {
  display: none;
}

body.nd-menu #auth_dialog.modal .tab-pane > br:not(#\9) {
  display: none;
}

body.nd-menu :is(#auth_dialog.modal, #login, #register) .form-group:not(#\9),
body.nd-menu :is(#auth_dialog.modal, #login, #register) .d_code:not(#\9) {
  margin: 0 0 14px;
  padding: 0;
}

body.nd-menu :is(#auth_dialog.modal, #login, #register) :is(.form-group, .d_code) > label:not(#\9) {
  position: static;
  display: block;
  width: auto;
  height: auto;
  margin: 0 0 6px;
  overflow: visible;
  clip: auto;
  color: var(--nd-auth-mut);
  font-size: 12.8px;
  font-weight: 700;
  line-height: 1.3;
  text-align: start;
  white-space: normal;
}

/* an SMS code field stays hidden until the code is sent (menu.js shows it): its label waits with it */
body.nd-menu :is(#auth_dialog.modal, #login, #register) .form-group:has(> input:is([style*="display:none"], [style*="display: none"])):not(#\9) {
  display: none;
}

body.nd-menu :is(#auth_dialog.modal, #login, #register) :is(input[type="text"], input[type="tel"], input[type="password"], input[type="email"], input[type="date"], input[type="number"]):not(#\9) {
  display: block;
  width: 100%;
  height: 45px;
  margin: 0;
  padding: 12px 14px;
  background-color: var(--nd-auth-field);
  border: 1.5px solid var(--nd-auth-field-line);
  border-radius: 12px;
  box-shadow: none;
  color: var(--nd-auth-ink);
  font-size: 15.68px;
  text-align: start;
  transition: border-color .25s var(--nd-auth-e-soft), background-color .25s var(--nd-auth-e-soft);
}

/* the field now has its label above: the same words inside it would repeat them */
body.nd-menu #auth_dialog.modal input#phone:not(#\9)::placeholder {
  color: transparent;
}

body.nd-menu :is(#auth_dialog.modal, #login, #register) input:focus:not(#\9) {
  background-color: #fff;
  border-color: var(--nd-auth-ink);
  outline: none;
}

body.nd-menu :is(#auth_dialog.modal, #login, #register) input.error:not(#\9) {
  border-color: var(--nd-auth-danger);
}

/* «* required» sits after the fields, as in the design */
body.nd-menu #auth_dialog.modal form > p:not(#\9) {
  order: 1;
  margin: -4px 0 14px;
  color: var(--nd-auth-mut);
  font-size: 12.48px;
  text-align: start !important;
}

body.nd-menu :is(#auth_dialog.modal, #register) .checkboxes:not(#\9) {
  order: 2;
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin: 0 0 18px;
  text-align: start;
}

body.nd-menu :is(#auth_dialog.modal, #register) .checkboxes label:not(#\9),
body.nd-menu :is(#auth_dialog.modal, #register) .checkboxes label a:not(#\9) {
  color: var(--nd-auth-mut);
  font-size: 13.12px;
  font-weight: 400;
  line-height: 1.45;
}

/* a block, not flex: as a flex row the words and the link to the terms became separate columns */
body.nd-menu :is(#auth_dialog.modal, #register) .checkboxes label:not(#\9) {
  position: relative;
  display: block;
  margin: 0;
  padding-inline-start: 28px;
  cursor: pointer;
  text-align: start;
}

body.nd-menu :is(#auth_dialog.modal, #register) .checkboxes label a:not(#\9) {
  text-decoration: underline;
}

body.nd-menu :is(#auth_dialog.modal, #register) .checkboxes input[type="checkbox"]:not(#\9) {
  position: absolute;
  top: 0;
  inset-inline-start: 0;
  width: 18px;
  height: 18px;
  margin: 1px 0 0;
  accent-color: var(--primary);
  cursor: pointer;
}

/* #login and #register: the row of link and submit dissolves, its parts are ordered in the column */
body.nd-menu :is(#login, #register) form > .row:not(#\9),
body.nd-menu :is(#login, #register) form > .row > .col:not(#\9) {
  display: contents;
}

body.nd-menu :is(#auth_dialog.modal, #login, #register) input[type="submit"]:not(#\9) {
  order: 3;
  display: block;
  width: 100%;
  height: 48px;
  margin: 0;
  padding: 0 18px;
  background: var(--primary);
  border: 1.5px solid var(--primary);
  border-radius: 999px;
  box-shadow: inset 0 0 0 1px var(--nd-auth-fill-line);
  color: var(--nd-auth-on-primary);
  cursor: pointer;
  font-size: 15.36px;
  font-weight: 800;
  transition: background .3s var(--nd-auth-e-soft), border-color .3s var(--nd-auth-e-soft), transform .18s ease;
}

body.nd-menu :is(#auth_dialog.modal, #login, #register) #reset_password:not(#\9) {
  order: 4;
  display: block;
  align-self: center;
  width: auto;
  height: auto;
  margin: 12px auto 0;
  padding: 0;
  background: none;
  border: none;
  color: var(--nd-auth-mut);
  font-size: 13.6px;
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 2px;
  transition: color .2s var(--nd-auth-e-soft);
}

/* the way to the other form: at the window's foot under a hairline, as the prototype's .auth-switch;
   the script puts it last in the DOM too */
body.nd-menu :is(#login, #register) form > p:not(#\9),
body.nd-menu #auth_dialog.modal .nd-auth-switch:not(#\9) {
  margin: 18px 0 0;
  padding: 16px 0 0;
  border-top: 1px solid var(--nd-auth-divider);
  text-align: center;
}

/* the forms of #login and #register are flex: the way out stands last there too */
body.nd-menu :is(#login, #register) form > p:not(#\9) {
  order: 5;
}

body.nd-menu :is(#login, #register) form > p > button:not(#\9),
body.nd-menu #auth_dialog.modal .nd-auth-switch > a:not(#\9) {
  display: inline;
  width: auto;
  height: auto;
  padding: 0;
  background: none;
  border: none;
  border-radius: 0;
  box-shadow: none;
  color: var(--nd-auth-accent);
  cursor: pointer;
  font-size: 14.08px;
  font-weight: 800;
  line-height: 1.4;
  text-decoration: none;
  text-underline-offset: 2px;
}

body.nd-menu :is(#login, #register) form > p > button > i:not(#\9) {
  display: none;
}

/* ───────────── A bootbox over the window (a wrong password, a code that failed) ───────────── */
body.nd-menu.nd-auth-open .bootbox .modal-content:not(#\9) {
  padding: 8px;
  background: #fff;
  border: none;
  border-radius: 24px;
  box-shadow: 0 40px 90px -30px rgba(0, 0, 0, .5);
  color: var(--nd-auth-ink);
}

body.nd-menu.nd-auth-open .bootbox .modal-header:not(#\9),
body.nd-menu.nd-auth-open .bootbox .modal-footer:not(#\9) {
  background: none;
  border: none;
}

body.nd-menu.nd-auth-open .bootbox .modal-header:not(#\9) {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: auto;
  color: var(--nd-auth-ink);
}

body.nd-menu.nd-auth-open .bootbox .bootbox-close-button:not(#\9) {
  position: static;
  order: 2;
  margin-inline-start: auto;
}

body.nd-menu.nd-auth-open .bootbox .modal-title:not(#\9) {
  color: var(--nd-auth-ink);
  font-size: 20px;
  font-weight: 800;
}

body.nd-menu.nd-auth-open .bootbox .modal-body:not(#\9) {
  color: var(--nd-auth-ink);
  font-size: 15px;
}

body.nd-menu.nd-auth-open .bootbox .bootbox-input:not(#\9) {
  width: 100%;
  height: 45px;
  padding: 12px 14px;
  background: var(--nd-auth-field);
  border: 1.5px solid var(--nd-auth-field-line);
  border-radius: 12px;
  box-shadow: none;
  font-size: 15.68px;
}

body.nd-menu.nd-auth-open .bootbox .modal-footer .btn:not(#\9) {
  width: auto;
  height: auto;
  padding: 10px 22px;
  border-radius: 999px;
  font-size: 14.72px;
  font-weight: 700;
  line-height: 1.3;
}

body.nd-menu.nd-auth-open .bootbox .modal-footer .btn-primary:not(#\9) {
  background: var(--primary);
  border: 1.5px solid var(--primary);
  box-shadow: inset 0 0 0 1px var(--nd-auth-fill-line);
  color: var(--nd-auth-on-primary);
}

body.nd-menu.nd-auth-open .bootbox .modal-footer :is(.btn-default, .btn-secondary):not(#\9) {
  background: #fff;
  border: 1.5px solid #bdbdbd;
  color: var(--nd-auth-ink);
}

/* ───────────── Hover (mouse only), press, focus ───────────── */
@media (hover: hover) {
  body.nd-menu :is(#auth_dialog.modal, #login, #register) .modal-header .close:hover:not(#\9),
  body.nd-menu.nd-auth-open .bootbox .bootbox-close-button:hover:not(#\9) {
    background: var(--nd-auth-ink);
    color: #fff;
    transform: rotate(90deg);
  }

  body.nd-menu :is(#auth_dialog.modal, #login, #register) input[type="submit"]:hover:not(#\9),
  body.nd-menu.nd-auth-open .bootbox .modal-footer .btn-primary:hover:not(#\9) {
    background: var(--nd-auth-primary-hover);
    border-color: var(--nd-auth-primary-hover);
  }

  body.nd-menu :is(#auth_dialog.modal, #login, #register) input[type="submit"]:hover:not(#\9) {
    transform: translateY(-1px);
  }

  body.nd-menu :is(#auth_dialog.modal, #login, #register) #reset_password:hover:not(#\9) {
    color: var(--nd-auth-ink);
  }

  body.nd-menu :is(#login, #register) form > p > button:hover:not(#\9),
  body.nd-menu #auth_dialog.modal .nd-auth-switch > a:hover:not(#\9) {
    text-decoration: underline;
  }

  body.nd-menu.nd-auth-open .bootbox .modal-footer :is(.btn-default, .btn-secondary):hover:not(#\9) {
    background: #f0f0f0;
    border-color: #9c9c9c;
  }
}

body.nd-menu :is(#auth_dialog.modal, #login, #register) input[type="submit"]:active:not(#\9) {
  transform: scale(.99);
}

/* on touch: the press, no rotation */
body.nd-menu :is(#auth_dialog.modal, #login, #register) .modal-header .close:active:not(#\9),
body.nd-menu.nd-auth-open .bootbox .bootbox-close-button:active:not(#\9) {
  transform: scale(.92);
}

@media (hover: hover) {
  body.nd-menu :is(#auth_dialog.modal, #login, #register) .modal-header .close:hover:active:not(#\9),
  body.nd-menu.nd-auth-open .bootbox .bootbox-close-button:hover:active:not(#\9) {
    transform: rotate(90deg) scale(.92);
  }
}

/* a mouse press leaves no ring (the platform's :focus outline) */
body.nd-menu :is(#auth_dialog.modal, #login, #register) :is(a, button):focus:not(:focus-visible):not(#\9) {
  outline: none;
}

body.nd-menu :is(#auth_dialog.modal, #login, #register) :is(a, button, input[type="submit"], input[type="checkbox"]):focus-visible:not(#\9) {
  outline: 2px solid var(--nd-auth-accent);
  outline-offset: 2px;
}

/* the platform's button sits over the window from 768px up: under the backdrop while it is open */
body.nd-menu.nd-auth-open:not(#\9) .a11y_floating_button {
  z-index: 1039;
}

/* ───────────── Phone ───────────── */
/* below 16px iOS zooms the page on focus: a phone on its side is wider than 767px, still a touch screen */
@media (max-width: 767px), (pointer: coarse) {
  body.nd-menu :is(#auth_dialog.modal, #login, #register) :is(input[type="text"], input[type="tel"], input[type="password"], input[type="email"], input[type="date"], input[type="number"]):not(#\9),
  body.nd-menu.nd-auth-open .bootbox .bootbox-input:not(#\9) {
    font-size: 16px;
  }
}

@media (max-width: 767px) {
  body.nd-menu {
    --nd-auth-top: 16px;
  }

  body.nd-menu :is(#auth_dialog.modal, #login, #register) .modal-body:not(#\9) {
    padding: 18px 28px calc(22px + env(safe-area-inset-bottom));
  }

  /* the prototype's phone close: a larger white disc with a shadow, the ink cross */
  body.nd-menu :is(#auth_dialog.modal, #login, #register) .modal-header .close:not(#\9) {
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, .92);
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
    box-shadow: 0 4px 16px -4px rgba(0, 0, 0, .35);
    color: var(--nd-auth-ink);
  }

  body.nd-menu :is(#auth_dialog.modal, #login, #register) .modal-header .close > span:not(#\9) {
    width: 18px;
    height: 18px;
  }

  body.nd-menu :is(#auth_dialog.modal, #login, #register) .modal-header .close:active:not(#\9) {
    background: var(--nd-auth-ink);
    color: #fff;
  }
}

/* ───────────── Keyframes and less motion ───────────── */
@keyframes nd-auth-fade {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  body.nd-menu :is(#auth_dialog.modal, #login, #register),
  body.nd-menu :is(#auth_dialog.modal, #login, #register) *,
  body.nd-menu.nd-auth-open .modal-backdrop,
  body.nd-menu.nd-auth-open .bootbox * {
    animation-duration: .01ms !important;
    transition-duration: 0s !important;
  }

  body.nd-menu :is(#auth_dialog.modal, #login, #register) .modal-header .close:not(#\9),
  body.nd-menu :is(#auth_dialog.modal, #login, #register) .modal-header .close:hover:not(#\9),
  body.nd-menu :is(#auth_dialog.modal, #login, #register) .modal-header .close:active:not(#\9),
  body.nd-menu.nd-auth-open .bootbox .bootbox-close-button:not(#\9),
  body.nd-menu.nd-auth-open .bootbox .bootbox-close-button:hover:not(#\9),
  body.nd-menu.nd-auth-open .bootbox .bootbox-close-button:active:not(#\9) {
    transform: none;
  }
}
