/**
 * Trimzio account popup.
 *
 * Layered on assets/style.css, which already provides `.modal` (the fixed
 * scrim + centring) and `.modal-card` (the raised panel). Only the parts
 * that are specific to a form live here.
 *
 * Every colour is a custom property from style.css, never a literal. The
 * editor flips to a light theme via :root[data-theme="light"] and anything
 * hard-coded here would survive that flip and come out unreadable.
 */

/* The popup hides its own pieces by setting the `hidden` attribute from JS
 * (the remember row, the forgot-password link, the whole footer when
 * sign-ups are closed). `hidden` only carries display:none from the UA
 * sheet, so any rule below giving those elements display:flex or
 * display:block would silently beat it and leave a login form showing a
 * "Create an account" link that does nothing. */
.trz-auth [hidden] { display: none !important; }

/* ---------- the card ---------- */

.trz-auth-card {
  position: relative;
  width: 400px;
  max-width: min(400px, calc(100vw - 32px));
  text-align: left;
  padding: 26px 28px 22px;
  /* Five fields plus a footer can outgrow a short window (a laptop in a
   * meeting, a phone in landscape). The card scrolls inside itself rather
   * than letting the submit button fall off the bottom of the screen. */
  max-height: calc(100vh - 40px);
  overflow-y: auto;
}

.trz-auth-card h2 {
  margin: 0 0 6px;
  font-size: 19px;
  /* Room for the close control, which is absolutely positioned over the
   * top-right corner. */
  padding-right: 28px;
}

.trz-auth-blurb {
  color: var(--text-dim);
  font-size: 12px;
  line-height: 1.6;
  margin: 0 0 16px;
}

/* Close control. Sized to a comfortable target rather than to the glyph:
 * a 12px "×" is a hard thing to hit with a trackpad. */
.trz-auth-x {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  line-height: 1;
  color: var(--text-dim);
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: color .15s var(--ease), background .15s var(--ease);
}
.trz-auth-x:hover { color: var(--text); background: var(--panel-2); }

/* ---------- fields ---------- */

.trz-auth-fields { display: flex; flex-direction: column; gap: 12px; }

.trz-auth-row { display: flex; flex-direction: column; gap: 5px; }

.trz-auth-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-dim);
  letter-spacing: .01em;
}

.trz-auth-input-wrap {
  position: relative;
}

.trz-auth-input {
  width: 100%;
  padding: 9px 11px;
  font: inherit;
  font-size: 13px;
  color: var(--text);
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  transition: border-color .15s var(--ease), box-shadow .15s var(--ease);
}
.trz-auth-input.has-password-toggle { padding-right: 42px; }
.trz-auth-input::placeholder { color: var(--text-dim); opacity: .7; }
.trz-auth-input:hover:not(:disabled) { border-color: var(--border-strong); }
.trz-auth-input:focus-visible { outline: none; border-color: var(--accent); box-shadow: var(--ring); }
.trz-auth-input:disabled { opacity: .55; cursor: not-allowed; }

.trz-auth-password-toggle {
  position: absolute;
  top: 50%;
  right: 4px;
  display: grid;
  width: 32px;
  height: 32px;
  padding: 0;
  place-items: center;
  color: var(--text-dim);
  background: transparent;
  border: 0;
  border-radius: calc(var(--radius-sm) - 2px);
  cursor: pointer;
  transform: translateY(-50%);
  transition: color .15s var(--ease), background .15s var(--ease);
}
.trz-auth-password-toggle:hover:not(:disabled) {
  color: var(--text);
  background: color-mix(in srgb, var(--text) 7%, transparent);
}
.trz-auth-password-toggle:focus-visible {
  outline: none;
  color: var(--accent);
  box-shadow: inset 0 0 0 2px var(--accent);
}
.trz-auth-password-toggle:disabled { opacity: .45; cursor: not-allowed; }

.trz-auth-eye {
  position: relative;
  display: block;
  width: 17px;
  height: 11px;
  border: 1.7px solid currentColor;
  border-radius: 50% / 65%;
}
.trz-auth-eye::before {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 5px;
  height: 5px;
  content: '';
  background: currentColor;
  border-radius: 50%;
  transform: translate(-50%, -50%);
}
.trz-auth-password-toggle.is-revealed .trz-auth-eye::after {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 22px;
  height: 1.7px;
  content: '';
  background: currentColor;
  border-radius: 999px;
  box-shadow: 0 0 0 2px var(--panel-2);
  transform: translate(-50%, -50%) rotate(-42deg);
}

/* A rejected field is marked three ways — border, message, aria-invalid —
 * because colour alone is not a message. */
.trz-auth-row.is-bad .trz-auth-input {
  border-color: color-mix(in srgb, var(--danger) 65%, var(--border-strong));
}

.trz-auth-err {
  margin: 0;
  font-size: 11.5px;
  line-height: 1.5;
  /* Flat var(--danger) measures ~3.4:1 on the light theme, which fails at
   * this size. Mixing toward the text colour is the same treatment every
   * other danger-tinted label in the editor uses. */
  color: color-mix(in srgb, var(--danger) 70%, var(--text));
}

/* ---------- whole-form alert ---------- */

.trz-auth-alert {
  margin: 0 0 14px;
  padding: 9px 11px;
  font-size: 12px;
  line-height: 1.5;
  color: color-mix(in srgb, var(--danger) 70%, var(--text));
  background: color-mix(in srgb, var(--danger) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--danger) 35%, transparent);
  border-radius: var(--radius-sm);
}

/* ---------- remember / submit / status ---------- */

.trz-auth-remember {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  font-size: 12px;
  color: var(--text-dim);
  cursor: pointer;
  user-select: none;
}
.trz-auth-remember input { accent-color: var(--accent); cursor: pointer; }

.trz-auth-go {
  width: 100%;
  margin-top: 16px;
  justify-content: center;
}

.trz-auth-status {
  margin: 10px 0 0;
  min-height: 16px;      /* holds its row, so the card does not jump */
  font-size: 12px;
  text-align: center;
  color: var(--text-dim);
}

.trz-auth-card.is-busy { cursor: progress; }

/* ---------- footer ---------- */

.trz-auth-foot {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  flex-wrap: wrap;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-dim);
}

.trz-auth-link {
  padding: 0;
  font: inherit;
  font-weight: 600;
  color: var(--accent);
  background: none;
  border: 0;
  border-radius: 4px;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.trz-auth-link:hover { color: color-mix(in srgb, var(--accent) 75%, var(--text)); }
.trz-auth-link:disabled { opacity: .5; cursor: not-allowed; }

.trz-auth-lost {
  display: block;
  margin-top: 10px;
  font-size: 11.5px;
  text-align: center;
  color: var(--text-dim);
  text-decoration: none;
}
.trz-auth-lost:hover { color: var(--text); text-decoration: underline; }

/* ---------- focus rings ---------- */

/* The card clips its overflow when it scrolls, so an outset ring would
 * lose its left and right edges on the inputs. The inputs get their ring
 * from the border-colour change above plus --ring, which is only 3px and
 * survives; the small controls take an inset ring instead. */
.trz-auth .trz-auth-x:focus-visible,
.trz-auth .trz-auth-link:focus-visible,
.trz-auth .trz-auth-lost:focus-visible {
  outline: none;
  box-shadow: inset 0 0 0 2px var(--accent);
}

/* ---------- topbar ---------- */

/* The account button sits with Pricing at the far right of the topbar. It
 * carries the signed-in name, which can be long, so it is capped and
 * ellipsised rather than allowed to push Pricing off the bar. */
#btnAccount .trz-acct-name {
  display: inline-block;
  max-width: 110px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  vertical-align: bottom;
}

.trz-acct-anchor { position: relative; display: inline-flex; }

#accountMenu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 60;
  min-width: 180px;
  padding: 6px;
  background: var(--panel);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  box-shadow: var(--shadow-2);
}
#accountMenu[hidden] { display: none; }

#accountMenu .trz-acct-who {
  padding: 7px 10px 9px;
  margin-bottom: 4px;
  font-size: 11.5px;
  line-height: 1.4;
  color: var(--text-dim);
  border-bottom: 1px solid var(--border);
  word-break: break-word;
}

#accountMenu a,
#accountMenu button {
  display: block;
  width: 100%;
  padding: 8px 10px;
  font-family: inherit;
  font-size: 12.5px;
  text-align: left;
  color: var(--text);
  background: transparent;
  border: 0;
  text-decoration: none;
  border-radius: var(--radius-sm);
  white-space: nowrap;
  cursor: pointer;
}
#accountMenu a:hover,
#accountMenu button:hover { background: var(--elev); }
#accountMenu a:focus-visible,
#accountMenu button:focus-visible { outline: none; box-shadow: inset 0 0 0 2px var(--accent); }

/* ---------- small screens ---------- */

/* Below the editor's mobile breakpoint the card gives up its fixed width
 * and its generous padding, and the scrim stops centring vertically so a
 * software keyboard cannot push the submit button under itself. */
@media (max-width: 520px) {
  .trz-auth { align-items: flex-start; padding: 16px 12px; overflow-y: auto; }
  .trz-auth-card {
    width: 100%;
    max-width: none;
    padding: 22px 18px 18px;
    max-height: none;
  }
}
