/*
 * Edit Profile (EditProfile.js) — the page behind the account hero's button.
 *
 * The account page's shell (account.css) one tier up: fixed at z-index 71 so
 * it rises over the account page and sits under everything that page sits
 * under; fading while its sheet lifts; its own scroller; a footer pinned
 * under the scroller for the one action. That is the seventh copy of the
 * tool-page shell and one more vote for a shared `.tool-page`.
 *
 * The page is the portrait. It takes the account hero's ringed photo, a
 * size up, and wears the camera badge on its corner — the accent, since the
 * badge is the page's one control and the ring is the whole reason to be
 * here. The name and handle sit under it as text, not fields: they are not
 * editable, and a field that cannot be typed into is a broken field.
 */

/* --- Shell -------------------------------------------------------------------- */

.edit-profile {
  --enter-y: 12px;

  position: fixed;
  inset: 0;
  z-index: 71;
  display: flex;
  max-width: var(--app-max-width);
  margin-inline: auto;
  background: var(--bg);
  opacity: 0;
  transition: opacity var(--duration) var(--easing);
}

.edit-profile[hidden] {
  display: none;
}

.edit-profile [hidden] {
  display: none !important;
}

.edit-profile[data-open="true"] {
  --enter-y: 0px;

  opacity: 1;
}

.edit-profile__sheet {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding-top: var(--safe-top);
  transform: translateY(var(--enter-y));
  transition: transform var(--duration) var(--easing);
}

.edit-profile__body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior-y: contain;
  -webkit-overflow-scrolling: touch;
}

.edit-profile-page {
  display: flex;
  flex-direction: column;
  gap: var(--space-6);
  padding: 0 var(--space-4) var(--space-6);
}

/* The picker's input: in the document so `.click()` opens the sheet, out of
   the layout and the tab order so nothing else knows it is there. */
.edit-profile__input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

/* Toasts above the footer, where the eye already is after a Save. */
.edit-profile .slip-toasts {
  position: absolute;
  right: 0;
  bottom: calc(52px + var(--space-6) + var(--safe-bottom));
  left: 0;
}

/* --- Top row -------------------------------------------------------------------- */

.edit-profile-top {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-inline: calc(var(--space-1) * -1);
  padding-top: var(--space-4);
}

.edit-profile-top__title {
  color: var(--text);
  font-size: var(--text-lg);
  font-weight: var(--weight-bold);
  letter-spacing: -0.2px;
}

/* --- Portrait -------------------------------------------------------------------- */

.edit-profile-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-1);
  padding-top: var(--space-4);
  text-align: center;
}

/*
 * The account hero's ring, as a button. The press scale comes from
 * [data-pressable] in interactions.css; the transition here is for it.
 */
.edit-profile-portrait {
  position: relative;
  display: grid;
  place-items: center;
  margin-bottom: var(--space-4);
  border-radius: var(--radius-full);
  transition: transform var(--spring-duration) var(--spring);
}

.edit-profile-portrait:disabled {
  cursor: default;
}

.edit-profile-portrait__avatar {
  display: grid;
  place-items: center;
  padding: 4px;
  background: var(--surface);
  border-radius: var(--radius-full);
  box-shadow: var(--shadow-card);
}

.edit-profile-portrait__avatar .logo--monogram {
  background: var(--accent-tint);
  color: var(--accent);
  font-size: var(--text-2xl);
  letter-spacing: 0;
}

/* A decode in flight: the ring dims until the preview replaces it. */
.edit-profile-portrait:disabled .edit-profile-portrait__avatar {
  opacity: 0.6;
}

/*
 * The one control, on the ring's corner. Accent fill with the page's surface
 * as its own ring, so it reads as sitting on the photo rather than in it.
 */
.edit-profile-portrait__badge {
  position: absolute;
  right: 4px;
  bottom: 4px;
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  background: var(--accent);
  border: 3px solid var(--bg);
  border-radius: var(--radius-full);
  color: var(--accent-text);
  box-shadow: var(--shadow-accent);
}

.edit-profile__name {
  color: var(--text);
  font-size: var(--text-xl);
  font-weight: var(--weight-bold);
  letter-spacing: -0.3px;
  line-height: 1.2;
}

.edit-profile__handle {
  color: var(--text-muted);
  font-size: var(--text-md);
  font-weight: var(--weight-medium);
  overflow-wrap: anywhere;
}

.edit-profile__note {
  max-width: 30ch;
  margin-top: var(--space-3);
  color: var(--text-muted);
  font-size: var(--text-sm);
  line-height: 1.4;
}

/* --- Actions ---------------------------------------------------------------------- */

.edit-profile-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
}

.edit-profile__choose {
  width: 100%;
  height: 52px;
  justify-content: center;
  gap: var(--space-2);
  font-size: var(--text-sm);
}

.edit-profile__choose:disabled {
  opacity: 0.6;
}

/* Taking the photo away is the destructive one: the sign-out row's colour.
   Scoped to outrank `.ob-later`, which onboarding.css declares later. */
.edit-profile .edit-profile__remove {
  color: var(--error-strong);
}

.edit-profile .edit-profile__remove:disabled {
  opacity: 0.6;
}

/* --- Footer ------------------------------------------------------------------------- */

.edit-profile-footer {
  flex: none;
  padding: var(--space-3) var(--space-4) calc(var(--space-4) + var(--safe-bottom));
  background: var(--bg);
}

/* Nothing pending, nothing to save: the button waits, quiet, the onboarding
   CTA's own way of saying so. */
.edit-profile__save:disabled {
  background: var(--surface-pressed);
  color: var(--text-muted);
  box-shadow: none;
  cursor: default;
}

/* While the save is up, the spinner keeps the accent under it. */
.edit-profile__save[data-loading="true"]:disabled {
  background: var(--accent);
  color: var(--accent-text);
}

/* --- Reduced motion ------------------------------------------------------------------ */

@media (prefers-reduced-motion: reduce) {
  .edit-profile,
  .edit-profile__sheet,
  .edit-profile-portrait {
    transition: none;
  }
}
