/* ============================================================
   FS25 Portal — Auth pages & Profile
   Depends on: 01-tokens.css, 02-base.css, 03-layout.css, 04-components.css
   ------------------------------------------------------------
   Auth: the login/register card as a stamped equipment ID plate —
   an amber header band and rivet corners, .brand-icon.large
   carrying the model badge.

   Profile: an instrument panel. The level/XP block reads as a
   gauge cluster (mono numeral in a recessed socket, not a badge),
   and the stats row borrows the .spec-plate formula verbatim so
   member data (posts/comments/reactions/joined) reads the same
   way a mod's machine data does elsewhere in the portal.

   Scoping note: profile.ejs and admin-user.ejs share several
   class names (.profile-avatar*, .profile-username, .level-badge,
   .level-number/-label/-details, .xp-text, .perk-icon/-info,
   .stat-value/-label, .settings-form). admin-user.ejs belongs to
   another stylesheet, so every rule below that touches a shared
   name is scoped under a profile-only ancestor (.profile-page,
   .profile-level-section, .profile-stats, .profile-perks,
   .profile-card) rather than written as a bare selector.
   ============================================================ */

/* ============================================================
   Auth pages — login / register
   ============================================================ */

.auth-page {
  display: flex;
  justify-content: center;
  padding: var(--s8) var(--s4);
}

.auth-container {
  width: 100%;
  max-width: 420px;
}

/* The plate: an amber stamped band across the top edge, and two
   rivet heads sunk into the corners below it — a card bolted to
   the chassis rather than a floating panel. */
.auth-card {
  position: relative;
  overflow: hidden;
  padding: var(--s7) var(--s6) var(--s6);
  text-align: center;
  background-image:
    radial-gradient(circle 2.5px at 20px 20px, var(--border-strong) 99%, transparent 100%),
    radial-gradient(circle 2.5px at calc(100% - 20px) 20px, var(--border-strong) 99%, transparent 100%);
  background-repeat: no-repeat;
}

.auth-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: var(--plate-edge);
  background: var(--amber);
  border-radius: var(--r-lg) var(--r-lg) 0 0;
}

.auth-logo {
  display: flex;
  justify-content: center;
  margin-bottom: var(--s5);
}

.auth-card h1 {
  font-size: var(--fs-lg);
  text-transform: uppercase;
  letter-spacing: var(--track-caps);
  margin-bottom: var(--s2);
}

.auth-subtitle {
  font-size: var(--fs-sm);
  color: var(--text-dim);
  margin-bottom: var(--s6);
}

.auth-card .alert {
  text-align: left;
  margin-bottom: var(--s5);
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: var(--s4);
  text-align: left;
}

.auth-form .btn {
  margin-top: var(--s2);
}

.auth-footer {
  margin-top: var(--s6);
  padding-top: var(--s5);
  border-top: var(--hairline) solid var(--border);
  font-size: var(--fs-sm);
  color: var(--text-dim);
}

/* ============================================================
   Profile — page frame
   ============================================================ */

.profile-page {
  max-width: var(--container-narrow);
  margin: 0 auto;
}

.profile-card {
  padding: var(--s6);
}

.profile-header {
  display: flex;
  align-items: center;
  gap: var(--s5);
  margin-bottom: var(--s6);
  padding-bottom: var(--s5);
  border-bottom: var(--hairline) solid var(--border);
}

/* ---------- Avatar ----------
   Scoped: admin-user.ejs reuses the exact same avatar class names
   for its own (differently sized) preview. */

.profile-page .profile-avatar-wrapper {
  position: relative;
  flex-shrink: 0;
  width: 88px;
  height: 88px;
}

.profile-page .profile-avatar-img,
.profile-page .profile-avatar {
  width: 88px;
  height: 88px;
  border-radius: var(--r-lg);
  border: var(--hairline) solid var(--border-strong);
  object-fit: cover;
}

.profile-page .profile-avatar {
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-size: var(--fs-2xl);
  font-weight: 700;
  color: var(--bg);
  background: var(--amber);
}

.profile-page .avatar-upload-form {
  position: absolute;
  bottom: -4px;
  right: -4px;
}

.avatar-upload-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  background: var(--amber);
  color: var(--bg);
  border: var(--hairline) solid var(--bg-sunk);
  border-radius: var(--r);
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: background var(--t) var(--ease), transform var(--t-fast) var(--ease);
}

.avatar-upload-btn:hover { background: var(--amber-bright); }
.avatar-upload-btn:active { transform: translateY(1px); }

/* Clear (remove) avatar button — sits below the upload button. */
.profile-page .avatar-clear-form {
  position: absolute;
  bottom: -4px;
  right: 30px;
}

.avatar-clear-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  background: var(--red);
  color: var(--bg);
  border: var(--hairline) solid var(--bg-sunk);
  border-radius: var(--r);
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: background var(--t) var(--ease), transform var(--t-fast) var(--ease);
}

.avatar-clear-btn:hover { filter: brightness(1.25); }
.avatar-clear-btn:active { transform: translateY(1px); }

/* ---------- Identity ---------- */

.profile-info {
  min-width: 0;
}

.profile-info h1 {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: var(--s2);
}

.profile-page .profile-username {
  font-size: var(--fs-sm);
  color: var(--text-dim);
  margin: var(--s1) 0 var(--s2);
}

.profile-badge-icon {
  display: inline-block;
  font-size: var(--fs-md);
  margin-right: var(--s2);
  vertical-align: middle;
}

.custom-title {
  display: inline-flex;
  align-items: center;
  padding: 2px var(--s2);
  font-family: var(--font-mono);
  font-size: var(--fs-2xs);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: var(--track-plate);
  color: var(--amber);
  background: var(--amber-soft);
  border: var(--hairline) solid var(--amber-line);
  border-radius: var(--r-sm);
  vertical-align: middle;
}

.profile-role-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--s1);
  margin-top: var(--s1);
  padding: 2px var(--s2);
  font-family: var(--font-mono);
  font-size: var(--fs-2xs);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: var(--track-caps);
  color: var(--text-dim);
  background: var(--surface-2);
  border: var(--hairline) solid var(--border);
  border-radius: var(--r-sm);
}

.profile-role-badge svg { flex-shrink: 0; }

.profile-role-badge.superadmin {
  color: var(--amber);
  border-color: var(--amber-line);
  background: var(--amber-soft);
}

.profile-role-badge.admin {
  color: var(--steel);
  border-color: var(--steel-line);
  background: var(--steel-soft);
}

/* ============================================================
   Level / XP — instrument readout, not a badge pile
   ------------------------------------------------------------
   .xp-bar / .xp-fill / .xp-text already read as a recessed fuel
   gauge (04-components.css) and stay untouched at the base level.
   This wraps them in a gauge cluster: a large mono numeral in a
   recessed socket, the well and current/next reading beside it.

   admin-user.ejs reuses .level-badge/.level-number/.level-label/
   .level-details/.xp-text for its own layout, so every override
   here is scoped under .profile-level-section.
   ============================================================ */

.profile-level-section {
  display: flex;
  align-items: center;
  gap: var(--s5);
  margin: var(--s6) 0;
  padding: var(--s4) var(--s5);
  background: var(--surface-2);
  border: var(--hairline) solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--edge-light);
}

/* The dial socket. */
.profile-level-section .level-badge {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 72px;
  height: 72px;
  flex-shrink: 0;
  gap: 0;
  padding: 0;
  background: var(--bg-sunk);
  border: var(--hairline) solid var(--border-strong);
  border-radius: var(--r-lg);
}

.profile-level-section .level-number {
  font-family: var(--font-mono);
  font-size: var(--fs-2xl);
  font-weight: 700;
  line-height: 1;
  color: var(--amber);
  font-variant-numeric: tabular-nums;
}

.profile-level-section .level-label {
  font-family: var(--font-mono);
  font-size: var(--fs-2xs);
  text-transform: uppercase;
  letter-spacing: var(--track-plate);
  color: var(--text-faint);
  margin-top: 2px;
}

.profile-level-section .level-details {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: var(--s2);
}

.profile-level-section .xp-text {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--s2) var(--s4);
}

.profile-level-section .xp-text span:first-child {
  color: var(--text);
  font-weight: 600;
}

/* ============================================================
   Member stats — the spec-plate formula, applied to the actual
   markup (.profile-stats / .stat / .stat-value / .stat-label)
   rather than a parallel treatment.

   admin-user.ejs reuses .stat-value/.stat-label on its own
   .stat-mini rows, so those two are scoped under .profile-stats.
   ============================================================ */

.profile-stats {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s2) var(--s5);
  margin: var(--s6) 0;
  background: var(--surface-2);
  border: var(--hairline) solid var(--border);
  border-left: var(--plate-edge) solid var(--amber);
  border-radius: 0 var(--r) var(--r) 0;
  padding: var(--s4) var(--s5);
  box-shadow: var(--edge-light);
}

.profile-stats .stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.profile-stats .stat-value {
  font-family: var(--font-mono);
  font-size: var(--fs-lg);
  font-weight: 600;
  line-height: var(--lh-tight);
  color: var(--text);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.profile-stats .stat-link {
  cursor: pointer;
  transition: color var(--t) var(--ease);
}

.profile-stats .stat-link:hover,
.profile-stats .stat-link:hover .stat-label {
  color: var(--amber);
}

/* ============================================================
   Perks
   ------------------------------------------------------------
   admin-user.ejs reuses .perk-icon/.perk-info on a differently
   shaped card, so both are scoped under .profile-perks.
   ============================================================ */

.profile-perks {
  margin-top: var(--s6);
  padding-top: var(--s5);
  border-top: var(--hairline) solid var(--border);
}

.profile-perks h3 {
  font-size: var(--fs-sm);
  text-transform: uppercase;
  letter-spacing: var(--track-plate);
  color: var(--text-dim);
  margin-bottom: var(--s3);
}

.profile-perks .perks-list {
  display: flex;
  flex-direction: column;
  gap: var(--s2);
}

.profile-perks .perk-item {
  display: flex;
  align-items: center;
  gap: var(--s3);
  padding: var(--s2) var(--s3);
  background: var(--surface-2);
  border: var(--hairline) solid var(--border);
  border-left: var(--plate-edge) solid var(--text-faint);
  border-radius: 0 var(--r) var(--r) 0;
}

.profile-perks .perk-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  font-size: var(--fs-base);
  border-radius: var(--r);
}

.profile-perks .perk-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.profile-perks .perk-name {
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--text);
}

.profile-perks .perk-desc {
  font-size: var(--fs-xs);
  color: var(--text-dim);
}

/* ============================================================
   Settings sections
   ============================================================ */

.profile-section {
  margin-top: var(--s7);
  padding-top: var(--s6);
  border-top: var(--hairline) solid var(--border);
}

.profile-section h2 {
  font-size: var(--fs-md);
  text-transform: uppercase;
  letter-spacing: var(--track-caps);
  margin-bottom: var(--s4);
}

.profile-section h3 {
  font-size: var(--fs-base);
  font-weight: 500;
  color: var(--text-dim);
  margin: var(--s1) 0 var(--s3);
}

.profile-card .settings-form .form-group:last-of-type {
  margin-bottom: 0;
}

/* ============================================================
   Discord linking
   ------------------------------------------------------------
   Discord's own brand colour isn't a token, so the integration
   reads through --steel — the same "info" register the inline
   discord badges elsewhere in the portal already use.
   ============================================================ */

.discord-link-section {
  margin-top: var(--s7);
  padding-top: var(--s6);
  border-top: var(--hairline) solid var(--border);
}

.discord-link-section h2 {
  display: flex;
  align-items: center;
  font-size: var(--fs-md);
  text-transform: uppercase;
  letter-spacing: var(--track-caps);
  margin-bottom: var(--s4);
}

.discord-link-prompt {
  display: flex;
  flex-direction: column;
  gap: var(--s3);
  align-items: flex-start;
}

.discord-link-prompt p {
  font-size: var(--fs-sm);
  color: var(--text-dim);
  max-width: 52ch;
}

.discord-btn {
  background: var(--steel-soft);
  color: var(--steel);
  border-color: var(--steel-line);
}

.discord-btn:hover {
  background: var(--steel);
  color: var(--bg);
  border-color: var(--steel);
}

.discord-linked-info {
  display: flex;
  align-items: center;
  gap: var(--s3);
  padding: var(--s3);
  background: var(--surface-2);
  border: var(--hairline) solid var(--border);
  border-radius: var(--r);
}

.discord-linked-avatar {
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  border-radius: var(--r);
  overflow: hidden;
  border: var(--hairline) solid var(--border-strong);
}

.discord-avatar-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.discord-avatar-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-weight: 700;
  color: var(--bg);
  background: var(--steel);
}

.discord-linked-details {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.discord-linked-label {
  font-family: var(--font-mono);
  font-size: var(--fs-2xs);
  text-transform: uppercase;
  letter-spacing: var(--track-plate);
  color: var(--text-faint);
}

.discord-linked-name {
  font-size: var(--fs-base);
  font-weight: 600;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ============================================================
   Responsive — co-located, not in a global dumping ground
   ============================================================ */

@media (max-width: 600px) {
  .auth-page { padding: var(--s6) var(--s4); }
  .auth-card { padding: var(--s6) var(--s4) var(--s5); }

  .profile-card { padding: var(--s5) var(--s4); }

  .profile-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .profile-level-section {
    flex-direction: column;
    align-items: flex-start;
  }

  .profile-level-section .level-details { width: 100%; }

  .profile-stats {
    gap: var(--s3) var(--s5);
    padding: var(--s3) var(--s4);
  }

  .discord-linked-info { flex-wrap: wrap; }
}
