/* Profile V2 — scoped after the established Dashboard/Progress V2 layers. */
body[data-route="profile"],
body[data-route="profile"] .app-shell,
body[data-route="profile"] #page-profile {
  background: var(--academy-page);
}

body[data-route="profile"] #page-profile {
  width: min(var(--academy-content-standard), calc(100% - 48px));
  padding: 32px 0 48px;
}

.profile-v2 {
  --profile-primary: var(--academy-primary);
  --profile-primary-hover: var(--academy-primary-hover);
  --profile-primary-soft: var(--academy-primary-soft);
  --profile-text: var(--academy-text);
  --profile-secondary: var(--academy-secondary);
  --profile-muted: var(--academy-muted);
  --profile-border: var(--academy-border);
  --profile-surface: var(--academy-surface);
  color: var(--profile-text);
  font-family: var(--academy-font-sans);
}

body[data-route="profile"] .profile-v2 :is(h1, h2, h3, h4) {
  margin: 0;
  color: var(--profile-text);
  font-family: inherit;
  font-style: normal;
  letter-spacing: -0.025em;
}

.profile-v2 :is(button, a):focus-visible {
  outline: 3px solid rgba(104, 101, 216, 0.3);
  outline-offset: 2px;
}

.profile-v2-hero {
  position: relative;
  min-height: 220px;
  display: grid;
  grid-template-columns: 142px minmax(0, 1fr);
  gap: clamp(24px, 4vw, 42px);
  align-items: center;
  overflow: hidden;
  padding: clamp(28px, 4vw, 48px);
  border: 1px solid var(--profile-border);
  border-radius: var(--academy-radius-hero);
  background:
    radial-gradient(circle at 86% 18%, rgba(104, 101, 216, 0.14), transparent 31%),
    linear-gradient(115deg, #ffffff 0%, #ffffff 58%, #f3f2fb 100%);
  box-shadow: var(--academy-shadow-elevated);
}

.profile-v2-hero::after {
  position: absolute;
  right: -30px;
  bottom: -76px;
  width: 250px;
  height: 250px;
  border: 1px solid rgba(104, 101, 216, 0.11);
  border-radius: 50%;
  box-shadow: 0 0 0 34px rgba(104, 101, 216, 0.035), 0 0 0 68px rgba(104, 101, 216, 0.025);
  pointer-events: none;
  content: "";
}

.profile-v2-hero-avatar {
  position: relative;
  z-index: 1;
  width: 142px;
  height: 142px;
  overflow: hidden;
  border: 5px solid var(--profile-surface);
  border-radius: 38px;
  background: var(--profile-primary-soft);
  box-shadow: 0 12px 28px rgba(70, 67, 155, 0.17), 0 0 0 1px rgba(104, 101, 216, 0.14);
}

.profile-v2-hero-avatar .account-avatar-media,
.profile-v2-hero-avatar .account-avatar-img,
.profile-avatar-preview-art .account-avatar-media,
.profile-avatar-preview-art .account-avatar-img,
body[data-route="profile"] .profile-avatar-choice > span .account-avatar-media,
body[data-route="profile"] .profile-avatar-choice > span .account-avatar-img {
  width: 100%;
  height: 100%;
}

.profile-v2-hero-copy {
  position: relative;
  z-index: 1;
  min-width: 0;
}

.profile-v2-kicker {
  margin: 0 0 9px;
  color: var(--profile-primary);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.profile-v2-hero h1 {
  max-width: 760px;
  font-size: clamp(2.25rem, 5vw, 4rem);
  font-weight: 800;
  line-height: 1.02;
  overflow-wrap: anywhere;
}

.profile-v2-context {
  min-height: 30px;
  display: inline-flex;
  align-items: center;
  margin-top: 14px;
  padding: 0 11px;
  color: var(--profile-primary);
  border: 1px solid rgba(104, 101, 216, 0.18);
  border-radius: 999px;
  background: var(--profile-primary-soft);
  font-size: 0.78rem;
  font-weight: 800;
}

.profile-v2-hero-copy > p:last-child {
  max-width: 680px;
  margin: 14px 0 0;
  color: var(--profile-secondary);
  font-size: 1rem;
  line-height: 1.6;
}

.profile-v2-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.7fr) minmax(300px, 0.85fr);
  gap: 18px;
  align-items: start;
  margin-top: 18px;
}

.profile-v2-panel {
  min-width: 0;
  padding: clamp(20px, 2.6vw, 30px);
  color: var(--profile-text);
  border: 1px solid var(--profile-border);
  border-radius: var(--academy-radius-card);
  background: var(--profile-surface);
  box-shadow: var(--academy-shadow-subtle);
}

.profile-v2-avatar-panel {
  box-shadow: var(--academy-shadow-elevated);
}

.profile-v2-billing {
  box-shadow: none;
}

.profile-v2-learning {
  border-left: 3px solid var(--profile-primary);
}

.profile-v2-sidebar {
  display: grid;
  gap: 18px;
}

body[data-route="profile"] .profile-avatar-studio {
  display: grid;
  gap: 20px;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
}

.profile-avatar-studio-heading {
  display: flex;
  justify-content: space-between;
  gap: 22px;
  align-items: center;
}

.profile-avatar-studio-heading h3 {
  font-size: clamp(1.45rem, 2.4vw, 1.85rem);
  font-weight: 800;
}

.profile-avatar-studio-heading div:first-child > p:last-child {
  max-width: 410px;
  margin: 8px 0 0;
  color: var(--profile-secondary);
  line-height: 1.5;
}

.profile-avatar-preview {
  min-width: 210px;
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 10px 13px;
  color: var(--profile-text);
  border: 1px solid var(--profile-border);
  border-radius: 16px;
  background: var(--academy-surface-soft);
}

.profile-avatar-preview-art {
  position: relative;
  width: 60px;
  height: 60px;
  flex: 0 0 60px;
  display: block;
  overflow: hidden;
  border-radius: 16px;
  background: var(--profile-primary-soft);
}

.profile-avatar-preview > span:last-child {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.profile-avatar-preview strong {
  overflow-wrap: anywhere;
}

.profile-avatar-preview small,
body[data-route="profile"] .profile-avatar-choice small {
  color: var(--profile-muted);
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: capitalize;
}

.profile-avatar-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

body[data-route="profile"] .profile-avatar-filters button {
  min-height: 44px;
  padding: 0 15px;
  color: var(--profile-secondary);
  border: 1px solid var(--profile-border);
  border-radius: 999px;
  background: var(--profile-surface);
  cursor: pointer;
  font: inherit;
  font-size: 0.78rem;
  font-weight: 750;
}

body[data-route="profile"] .profile-avatar-filters button:hover,
body[data-route="profile"] .profile-avatar-filters button.selected {
  color: var(--profile-primary);
  border-color: rgba(104, 101, 216, 0.34);
  background: var(--profile-primary-soft);
}

.profile-avatar-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(118px, 1fr));
  gap: 11px;
}

body[data-route="profile"] .profile-avatar-choice {
  min-height: 156px;
  display: grid;
  grid-template-rows: minmax(82px, 1fr) auto auto;
  gap: 7px;
  padding: 9px;
  color: var(--profile-text);
  border: 1px solid var(--profile-border);
  border-radius: var(--academy-radius-card);
  background: var(--profile-surface);
  box-shadow: none;
  cursor: pointer;
}

body[data-route="profile"] .profile-avatar-choice > span {
  position: relative;
  overflow: hidden;
  border: 0;
  border-radius: 12px;
  background: var(--profile-primary-soft);
  box-shadow: none;
}

body[data-route="profile"] .profile-avatar-choice b {
  color: var(--profile-text);
  font-size: 0.78rem;
  overflow-wrap: anywhere;
}

body[data-route="profile"] .profile-avatar-choice:hover {
  color: var(--profile-text);
  border-color: rgba(104, 101, 216, 0.34);
  background: var(--academy-surface-soft);
  box-shadow: var(--academy-shadow-subtle);
}

body[data-route="profile"] .profile-avatar-choice.selected {
  color: var(--profile-text);
  border-color: var(--profile-primary);
  background: var(--profile-primary-soft);
  box-shadow: inset 0 0 0 1px var(--profile-primary), 0 8px 18px rgba(75, 72, 159, 0.1);
}

.profile-v2-save-row {
  min-height: 54px;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid var(--profile-border);
}

.profile-v2-save-row .form-message {
  margin: 0;
}

.profile-v2-primary,
.profile-v2-secondary,
body[data-route="profile"] .profile-billing-actions :is(.primary-button, .ghost-button) {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 17px;
  border-radius: var(--academy-radius-control);
  cursor: pointer;
  font: inherit;
  font-size: 0.82rem;
  font-weight: 800;
}

.profile-v2-primary,
body[data-route="profile"] .profile-billing-actions .primary-button {
  color: #fff;
  border: 1px solid var(--profile-primary);
  background: var(--profile-primary);
  box-shadow: none;
}

.profile-v2-primary:hover,
body[data-route="profile"] .profile-billing-actions .primary-button:hover {
  color: #fff;
  background: var(--profile-primary-hover);
  border-color: var(--profile-primary-hover);
}

.profile-v2-secondary,
body[data-route="profile"] .profile-billing-actions .ghost-button {
  color: var(--profile-secondary);
  border: 1px solid var(--profile-border);
  background: var(--profile-surface);
  box-shadow: none;
}

.profile-v2-secondary:hover,
body[data-route="profile"] .profile-billing-actions .ghost-button:hover {
  color: var(--profile-primary);
  border-color: rgba(104, 101, 216, 0.34);
  background: var(--profile-primary-soft);
}

.profile-v2 :is(button:disabled, .primary-button:disabled, .ghost-button:disabled) {
  cursor: wait;
  opacity: 0.62;
}

.profile-v2-billing h2,
.profile-v2-learning h2 {
  font-size: clamp(1.3rem, 2vw, 1.62rem);
  font-weight: 800;
}

.profile-v2-billing > p:not(.profile-v2-kicker):not(.form-message),
.profile-v2-learning > p:not(.profile-v2-kicker) {
  margin: 11px 0 0;
  color: var(--profile-secondary);
  line-height: 1.55;
}

.profile-v2-plan-status {
  font-size: 0.86rem;
  font-weight: 700;
}

.profile-billing-actions,
.profile-v2-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
  margin-top: 18px;
}

.profile-v2-actions > * {
  flex: 1 1 130px;
}

.profile-v2 .form-message {
  color: var(--profile-secondary);
  line-height: 1.4;
}

.profile-v2 .form-message.success {
  color: var(--academy-success);
}

.profile-v2 .form-message.error {
  color: var(--academy-error);
}

@media (max-width: 900px) {
  .profile-v2-layout {
    grid-template-columns: 1fr;
  }

  .profile-v2-sidebar {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 680px) {
  body[data-route="profile"] #page-profile {
    width: min(100% - 28px, 1180px);
    padding: 20px 0 36px;
  }

  .profile-v2-hero {
    min-height: 0;
    grid-template-columns: 88px minmax(0, 1fr);
    gap: 18px;
    padding: 22px;
    border-radius: var(--academy-radius-card);
  }

  .profile-v2-hero-avatar {
    width: 88px;
    height: 88px;
    border-width: 4px;
    border-radius: 25px;
  }

  .profile-v2-hero h1 {
    font-size: clamp(1.75rem, 9vw, 2.5rem);
  }

  .profile-v2-sidebar {
    grid-template-columns: 1fr;
  }

  .profile-avatar-studio-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .profile-avatar-preview {
    min-width: 0;
  }

  .profile-avatar-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .profile-v2-save-row {
    align-items: stretch;
    flex-direction: column;
  }

  .profile-v2-save-row .profile-v2-primary {
    width: 100%;
  }
}

@media (max-width: 430px) {
  .profile-v2-hero {
    grid-template-columns: 76px minmax(0, 1fr);
    padding: 18px;
  }

  .profile-v2-hero-avatar {
    width: 76px;
    height: 76px;
    border-radius: 22px;
  }

  .profile-v2-panel {
    padding: 18px;
    border-radius: var(--academy-radius-card);
  }

  .profile-avatar-grid {
    gap: 9px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .profile-v2 *,
  .profile-v2 *::before,
  .profile-v2 *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}
