/*
 * Identity detail pass
 * Loaded after profile-reference.css and achievement-reference.css.
 * Keeps authentication, profile, and achievement layouts on one quiet grid.
 */

:where(.auth-wrap, .profile-page, .activity-page) {
  --identity-brand: var(--brand, #087454);
  --identity-brand-strong: var(--brand-hover, #066247);
  --identity-brand-soft: var(--brand-soft, #edf7f3);
  --identity-ink: var(--text, #18211d);
  --identity-muted: var(--text-2, #66736d);
  --identity-line: var(--border, #dfe7e3);
  --identity-surface: var(--surface, #fff);
  --identity-subtle: var(--surface-subtle, #f5f7f6);
  --identity-control-radius: 10px;
  --identity-panel-radius: 12px;
}

/* Authentication --------------------------------------------------------- */

.auth-wrap {
  display: grid;
  width: 100%;
  min-width: 0;
  min-height: 100dvh;
  max-height: none;
  justify-items: center;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior-y: contain;
  padding:
    max(24px, env(safe-area-inset-top))
    max(16px, env(safe-area-inset-right))
    max(28px, env(safe-area-inset-bottom))
    max(16px, env(safe-area-inset-left));
  background: #f6f8f7;
  -webkit-overflow-scrolling: touch;
}

.auth-wrap.auth-mode-login,
.auth-wrap.auth-login-only {
  align-items: center;
}

.auth-wrap.auth-mode-signup {
  align-items: start;
  scroll-padding-block: max(20px, env(safe-area-inset-top)) max(28px, env(safe-area-inset-bottom));
}

.auth-card,
.auth-card.auth-card-login-only {
  width: min(430px, 100%);
  min-width: 0;
  max-width: 100%;
  max-height: none;
  margin: 0;
  overflow: visible;
  border: 1px solid var(--identity-line);
  border-top: 1px solid var(--identity-line);
  border-radius: var(--identity-panel-radius);
  background: var(--identity-surface);
  padding: 26px;
  box-shadow: 0 14px 36px rgb(24 33 29 / 8%);
}

.auth-wrap.auth-mode-signup .auth-card {
  margin-block: 0 12px;
}

.auth-card .brand.auth-brand {
  position: relative;
  display: grid;
  width: max-content;
  min-width: 0;
  max-width: 100%;
  min-height: 48px;
  grid-template-columns: 46px max-content;
  align-items: center;
  justify-content: center;
  gap: 11px;
  margin: 0 auto 18px;
  padding: 0;
  overflow: visible;
  color: var(--identity-brand-strong);
}

.auth-card .brand.auth-brand::before,
.auth-card .brand.auth-brand::after {
  display: none;
  content: none;
}

.auth-card .auth-brand .brand-icons.school-brand-icons {
  position: relative;
  display: grid;
  width: 46px;
  min-width: 46px;
  height: 46px;
  place-items: center;
  overflow: visible;
}

.auth-card .auth-brand .brand-logo.school-logo-only {
  position: static;
  inset: auto;
  display: block;
  width: 44px !important;
  min-width: 44px;
  height: 44px !important;
  margin: 0;
  object-fit: contain;
  object-position: center;
  opacity: 1;
  transform: none;
}

.auth-card .auth-brand .brand-title.school-brand-title {
  position: static;
  display: flex !important;
  width: auto !important;
  min-width: 0;
  max-width: none;
  height: 46px;
  align-items: center;
  overflow: visible;
  padding: 1px 0 0;
  color: var(--identity-brand-strong);
  font-size: 21px;
  font-weight: 750;
  letter-spacing: 0;
  line-height: 1;
  transform: none;
}

.auth-card .auth-brand .brand-title-school.school-title-only {
  position: static !important;
  display: block !important;
  width: auto !important;
  height: auto !important;
  margin: 0;
  overflow: visible;
  color: inherit;
  font: inherit;
  line-height: 1;
  white-space: nowrap;
  opacity: 1;
  transform: none !important;
}

.auth-card .auth-heading,
.auth-card-login-only .auth-heading {
  display: grid;
  gap: 4px;
  margin: 0 0 17px;
  text-align: left;
}

.auth-card .auth-heading h1,
.auth-card-login-only .auth-heading h1 {
  margin: 0;
  color: var(--identity-ink);
  font-size: 24px;
  font-weight: 720;
  letter-spacing: 0;
  line-height: 1.3;
}

.auth-card .auth-heading p {
  margin: 0;
  color: var(--identity-muted);
  font-size: 13px;
  font-weight: 400;
  line-height: 1.5;
}

.auth-card .tabs {
  position: static;
  isolation: isolate;
  display: grid;
  width: 100%;
  min-width: 0;
  min-height: 46px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 3px;
  margin: 0 0 18px;
  overflow: hidden;
  border: 1px solid var(--identity-line);
  border-radius: var(--identity-control-radius);
  background: var(--identity-subtle);
  padding: 3px;
}

.auth-card .tabs button,
.auth-card .tabs button.active {
  position: relative;
  z-index: 1;
  width: 100%;
  min-width: 0;
  min-height: 38px;
  margin: 0;
  border: 0;
  border-radius: 7px;
  padding: 7px 10px;
  box-shadow: none;
  font-size: 14px;
  font-weight: 650;
  line-height: 1.2;
}

.auth-card .tabs button {
  background: transparent;
  color: var(--identity-muted);
}

.auth-card .tabs button.active {
  background: var(--identity-surface);
  color: var(--identity-brand-strong);
  box-shadow: 0 1px 3px rgb(24 33 29 / 8%);
}

.auth-card form[hidden],
.auth-card #loginForm[hidden],
.auth-card #signupForm[hidden] {
  display: none !important;
}

.auth-card .form {
  width: 100%;
  min-width: 0;
  gap: 13px;
}

.auth-card .form > *,
.auth-card .form label,
.auth-card .form .input,
.auth-card .form .select,
.auth-card .form .textarea {
  min-width: 0;
  max-width: 100%;
}

.auth-card .input,
.auth-card .select,
.auth-card .textarea {
  border-radius: var(--identity-control-radius);
}

.auth-card .signup-identity-fields {
  min-width: 0;
}

.auth-card .signup-student-number-preview,
.auth-card .signup-identity-warning,
.auth-card .signup-student-confirm,
.auth-card .legal-box,
.auth-card .signup-quiz-box {
  max-width: 100%;
  min-width: 0;
  overflow: hidden;
  border-radius: var(--identity-control-radius);
}

.auth-card .legal-box :where(p, span, strong, small),
.auth-card .signup-identity-warning :where(p, span, strong),
.auth-card .signup-student-confirm :where(span, strong, small) {
  min-width: 0;
  overflow-wrap: anywhere;
}

/* Profile --------------------------------------------------------------- */

.profile-page,
.profile-page * {
  min-width: 0;
}

.profile-page {
  width: 100%;
  max-width: 100%;
  overflow-x: clip;
}

.profile-page > .profile-cover {
  width: 100%;
  max-width: 100%;
  overflow: hidden;
  border: 1px solid var(--identity-line);
  border-radius: var(--identity-panel-radius);
  background: var(--identity-surface);
  box-shadow: none;
}

.profile-page .profile-cover-main {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  gap: 16px;
  padding: 20px 20px 18px;
}

.profile-page .profile-identity {
  display: grid;
  min-width: 0;
  grid-template-columns: 72px minmax(0, 1fr);
  align-items: center;
  gap: 15px;
}

.profile-page .profile-identity .avatar,
.profile-page .profile-cover .avatar,
.profile-page .profile-avatar-xl {
  display: grid;
  place-items: center;
  width: 72px;
  min-width: 72px;
  height: 72px;
  margin: 0;
  overflow: hidden;
  border: 1px solid var(--identity-line);
  border-radius: 50%;
  background: var(--identity-brand-soft);
  object-fit: cover;
  box-shadow: none;
  padding: 0;
  color: var(--identity-brand);
  font-size: 24px;
  font-weight: 750;
  line-height: 1;
  text-align: center;
}

.profile-page .profile-avatar-xl > img,
.profile-page .profile-identity .avatar > img,
.profile-page .profile-cover .avatar > img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.profile-page .profile-identity > div:last-child {
  display: grid;
  min-width: 0;
  gap: 4px;
}

.profile-page .profile-identity .badges {
  display: flex;
  min-width: 0;
  flex-wrap: wrap;
  gap: 5px;
  margin: 0 0 1px;
}

.profile-page .profile-identity h1 {
  max-width: 100%;
  margin: 0;
  overflow-wrap: anywhere;
  color: var(--identity-ink);
  font-size: 24px;
  font-weight: 720;
  letter-spacing: 0;
  line-height: 1.25;
}

.profile-page .profile-identity p {
  display: -webkit-box;
  max-width: 56ch;
  margin: 1px 0 0;
  overflow: hidden;
  color: var(--identity-muted);
  font-size: 13px;
  line-height: 1.5;
  overflow-wrap: anywhere;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.profile-page .profile-identity .meta {
  display: flex;
  min-width: 0;
  flex-wrap: wrap;
  gap: 3px 10px;
  margin-top: 1px;
  color: var(--identity-muted);
  font-size: 12px;
  line-height: 1.45;
}

.profile-page .profile-edit-button {
  align-self: start;
  min-height: 36px;
  border-radius: var(--identity-control-radius);
  padding: 7px 10px;
  white-space: nowrap;
}

.profile-page .profile-stat-grid {
  display: grid;
  width: 100%;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  overflow: hidden;
  border-top: 1px solid var(--identity-line);
  background: var(--identity-surface);
}

.profile-page .profile-stat-grid:has(> :nth-child(4)) {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.profile-page .profile-stat-grid > div {
  display: grid;
  min-width: 0;
  min-height: 68px;
  place-content: center;
  gap: 3px;
  border-right: 1px solid var(--identity-line);
  padding: 9px 6px;
  text-align: center;
}

.profile-page .profile-stat-grid > div:last-child {
  border-right: 0;
}

.profile-page .profile-stat-grid strong,
.profile-page .profile-stat-grid span {
  display: block;
  min-width: 0;
  max-width: 100%;
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.profile-page .profile-stat-grid strong {
  color: var(--identity-ink);
  font-size: 18px;
  font-weight: 720;
  line-height: 1.15;
}

.profile-page .profile-stat-grid span {
  color: var(--identity-muted);
  font-size: 11px;
  font-weight: 550;
  line-height: 1.25;
  white-space: nowrap;
}

.profile-page .profile-navigation-shell {
  width: 100%;
  max-width: 100%;
  overflow: visible;
  border-radius: var(--identity-panel-radius);
}

.profile-page .profile-primary-tabs button,
.profile-page .profile-more-menu > summary {
  min-width: 0;
  min-height: 52px;
  grid-template-columns: 22px minmax(0, 1fr) 12px;
  gap: 11px;
  padding: 8px 2px;
}

.profile-page .profile-primary-tabs button > span,
.profile-page .profile-more-menu > summary > span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Achievement cards ----------------------------------------------------- */

.trophy-grid,
.trophy-mini-row,
.trophy-strip,
.trophy-card,
.activity-latest-trophy {
  min-width: 0;
  max-width: 100%;
}

.trophy-grid,
.trophy-mini-row {
  align-items: stretch;
}

.trophy-card {
  display: grid;
  width: 100%;
  min-height: 82px;
  grid-template-columns: 58px minmax(0, 1fr);
  align-items: center;
  gap: 11px;
  overflow: hidden;
  border: 1px solid var(--identity-line, #dfe7e3);
  border-radius: var(--identity-control-radius);
  background: var(--identity-surface, #fff);
  padding: 11px;
  box-shadow: none;
  isolation: isolate;
}

.trophy-card:hover {
  border-color: #cbd8d2;
  box-shadow: none;
  transform: none;
}

.trophy-card > * {
  min-width: 0;
  max-width: 100%;
}

.trophy-card > div:last-child {
  position: relative;
  z-index: 1;
  grid-column: 2;
  grid-row: 1;
  display: grid;
  align-content: center;
  gap: 2px;
  overflow: hidden;
}

.trophy-card .trophy-art,
.trophy-card .trophy-image-art,
.trophy-card .trophy-svg-art {
  position: relative;
  inset: auto;
  grid-column: 1;
  grid-row: 1;
  align-self: center;
  justify-self: center;
  display: grid;
  width: 58px;
  min-width: 58px;
  max-width: 58px;
  height: 58px;
  place-items: center;
  aspect-ratio: 1;
  overflow: hidden;
  border: 1px solid rgb(8 116 84 / 12%);
  border-radius: 10px;
  background: var(--identity-subtle, #f5f7f6);
  box-shadow: none;
}

.badge.professional-badge {
  border-color: #9bd2bd;
  background: #edf8f3;
  color: #087454;
}

.badge.professional-badge.strong-professional-badge {
  border-color: #087454;
  background: #087454;
  color: #fff;
  box-shadow: none;
}

.badge.professional-badge .icon {
  color: currentColor;
}

.trophy-image-art .trophy-image,
.trophy-card img.trophy-image {
  display: block;
  width: 100%;
  min-width: 0;
  max-width: 100%;
  height: 100%;
  margin: 0;
  padding: 3px;
  object-fit: contain;
  object-position: center;
  border-radius: 8px;
}

.trophy-card .trophy-svg,
.trophy-image-art .trophy-svg-fallback .trophy-svg {
  width: 78%;
  max-width: 46px;
  height: 78%;
  max-height: 46px;
  object-fit: contain;
}

.trophy-card strong,
.trophy-card p,
.trophy-card span {
  display: block;
  width: 100%;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  overflow-wrap: anywhere;
}

.trophy-card strong {
  color: var(--identity-ink, #18211d);
  font-size: 14px;
  font-weight: 680;
  line-height: 1.35;
  white-space: nowrap;
}

.trophy-card p {
  display: -webkit-box;
  margin: 1px 0;
  color: var(--identity-muted, #66736d);
  font-size: 11px;
  line-height: 1.4;
  white-space: normal;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.trophy-card span {
  color: var(--identity-muted, #66736d);
  font-size: 10px;
  line-height: 1.35;
  white-space: nowrap;
}

.profile-achievement-card .trophy-mini-row,
.profile-page .trophy-grid {
  display: grid;
  width: 100%;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 210px), 1fr));
  gap: 9px;
}

.activity-page .activity-latest-trophy {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  overflow: hidden;
}

.activity-page .activity-latest-trophy .activity-trophy-art {
  width: 48px;
  min-width: 48px;
  max-width: 48px;
  height: 48px;
  padding: 2px;
}

.activity-page .activity-latest-trophy > div:last-child,
.activity-page .activity-latest-trophy strong,
.activity-page .activity-latest-trophy small {
  min-width: 0;
  max-width: 100%;
}

.activity-page .activity-latest-trophy strong,
.activity-page .activity-latest-trophy small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Responsive tuning ----------------------------------------------------- */

@media (max-width: 700px) {
  .auth-wrap {
    align-items: start;
    padding:
      max(18px, env(safe-area-inset-top))
      max(12px, env(safe-area-inset-right))
      max(24px, env(safe-area-inset-bottom))
      max(12px, env(safe-area-inset-left));
  }

  .auth-wrap.auth-mode-login,
  .auth-wrap.auth-login-only {
    align-items: center;
  }

  .auth-card,
  .auth-card.auth-card-login-only {
    padding: 22px 20px;
  }

  .profile-page .profile-cover-main {
    gap: 10px;
    padding: 16px 14px 15px;
  }

  .profile-page .profile-identity {
    grid-template-columns: 64px minmax(0, 1fr);
    gap: 12px;
  }

  .profile-page .profile-identity .avatar,
  .profile-page .profile-cover .avatar,
  .profile-page .profile-avatar-xl {
    width: 64px;
    min-width: 64px;
    height: 64px;
  }

  .profile-page .profile-identity h1 {
    font-size: 21px;
  }

  .profile-page .profile-edit-button {
    min-height: 34px;
    padding: 6px 8px;
    font-size: 11px;
  }

  .profile-page .profile-stat-grid > div {
    min-height: 62px;
    padding: 8px 3px;
  }

  .profile-page .profile-navigation-shell {
    padding-inline: 13px;
  }

  .profile-page .profile-primary-tabs button,
  .profile-page .profile-more-menu > summary {
    min-height: 51px;
  }

  .profile-achievement-card .trophy-mini-row,
  .profile-page .trophy-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 430px) {
  .auth-card,
  .auth-card.auth-card-login-only {
    width: 100%;
    padding: 20px 17px;
  }

  .auth-card .brand.auth-brand {
    grid-template-columns: 43px max-content;
    gap: 9px;
    margin-bottom: 16px;
  }

  .auth-card .auth-brand .brand-icons.school-brand-icons {
    width: 43px;
    min-width: 43px;
    height: 43px;
  }

  .auth-card .auth-brand .brand-logo.school-logo-only {
    width: 41px !important;
    min-width: 41px;
    height: 41px !important;
  }

  .auth-card .auth-brand .brand-title.school-brand-title {
    height: 43px;
    font-size: 20px;
  }

  .auth-card .auth-heading h1 {
    font-size: 22px;
  }

  .profile-page .profile-cover-main {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .profile-page .profile-stat-grid strong {
    font-size: 17px;
  }

  .profile-page .profile-stat-grid span {
    font-size: 10px;
  }

  .trophy-card {
    min-height: 78px;
    grid-template-columns: 54px minmax(0, 1fr);
    gap: 10px;
    padding: 10px;
  }

  .trophy-card .trophy-art,
  .trophy-card .trophy-image-art,
  .trophy-card .trophy-svg-art {
    width: 54px;
    min-width: 54px;
    max-width: 54px;
    height: 54px;
  }
}

@media (max-width: 390px) {
  .auth-wrap {
    padding-inline: max(10px, env(safe-area-inset-left));
  }

  .auth-card,
  .auth-card.auth-card-login-only {
    padding: 19px 15px;
  }

  .auth-card .signup-identity-fields {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 7px;
  }

  .profile-page .profile-cover-main {
    grid-template-columns: minmax(0, 1fr);
    padding: 14px 12px;
  }

  .profile-page .profile-identity {
    grid-template-columns: 60px minmax(0, 1fr);
    gap: 11px;
  }

  .profile-page .profile-identity .avatar,
  .profile-page .profile-cover .avatar,
  .profile-page .profile-avatar-xl {
    width: 60px;
    min-width: 60px;
    height: 60px;
  }

  .profile-page .profile-identity > div:last-child {
    padding-right: 68px;
  }

  .profile-page .profile-edit-button {
    position: absolute;
    top: 14px;
    right: 12px;
  }

  .profile-page .profile-stat-grid > div {
    min-height: 58px;
    padding-inline: 2px;
  }

  .profile-page .profile-stat-grid strong {
    font-size: 16px;
  }

  .profile-page .profile-stat-grid span {
    font-size: 9px;
  }
}

@media (min-width: 900px) {
  .auth-card,
  .auth-card.auth-card-login-only {
    padding: 28px;
  }

  .profile-page .profile-cover-main {
    padding: 22px 24px 20px;
  }

  .profile-page .profile-navigation-shell {
    max-width: 100%;
  }
}

@media (prefers-reduced-motion: reduce) {
  .auth-wrap *,
  .profile-page *,
  .activity-page * {
    scroll-behavior: auto !important;
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}
