/* ==========================================================
   ACERSMP PROFILE PAGE
   Loads after nav.css / icons.css / light-theme.css.
   ========================================================== */

/*
 * border-box for this page only.
 *
 * Without it a field is width:100% PLUS its padding, because the
 * default is content-box: 100% of the card plus 42px of icon space and
 * 14px of breathing room, so every input hangs 56px out past the card
 * edge. nav.css sets this for .site-header alone, which does not cover
 * anything down here.
 *
 * .profile-page is listed FIRST on purpose: a `.foo *` rule matches
 * descendants, never the element itself. So the wrapper was still
 * content-box, and since it is a width:100% block with horizontal
 * padding, its padding was added on top and the whole page scrolled
 * sideways by exactly that amount. Measured at 1100px wide it declared
 * 1069px and rendered 1117px.
 */
.profile-page,
.profile-page *,
.profile-page *::before,
.profile-page *::after {
  box-sizing: border-box;
}

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

:root {
  --panel: rgba(12, 23, 39, .82);
  --line: rgba(138, 207, 255, .13);
  --blue: #59caff;
  --blue-bright: #8be0ff;
  --text: #eff8ff;
  --muted: #91a7bd;
  --green: #50dfa0;
  --amber: #ffc46b;
  --rose: #ff8f99;
  --violet: #a5abf8;
  --ease: cubic-bezier(.2, .8, .2, 1);
}

.profile-page {
  width: 100%;
  max-width: 1080px;
  margin: 0 auto;
  padding: 40px 24px 70px;
}

/*
 * A rule that sets `display` beats the browser default for [hidden],
 * so the toggle below needs its own line or the sign-in gate would
 * never actually hide.
 */
.profile-page [hidden] { display: none !important; }

/* ---------- Gate ---------- */

.gate {
  display: grid;
  place-items: center;
  min-height: 62vh;
}

.gate-card {
  width: min(100%, 420px);
  padding: 40px 36px;
  text-align: center;

  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 22px;

  box-shadow: 0 28px 70px rgba(0, 0, 0, .45);
}

.gate-icon {
  display: grid;
  place-items: center;
  width: 62px;
  height: 62px;
  margin: 0 auto 22px;

  border-radius: 18px;
  background: rgba(88, 101, 242, .16);
  border: 1px solid rgba(124, 133, 255, .4);
  color: var(--violet);
}

.gate-icon .ic { width: 28px; height: 28px; }

.gate-card h1 {
  margin: 0 0 12px;
  font-size: clamp(22px, 4vw, 27px);
  font-weight: 900;
  letter-spacing: -1px;
}

.gate-card p {
  margin: 0 0 26px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.75;
}

.gate-button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 11px;

  min-height: 48px;
  padding: 0 18px;

  border-radius: 11px;
  background: linear-gradient(120deg, #5865f2, #4752c4);
  border: 1px solid rgba(124, 133, 255, .55);
  color: #fff;

  font-size: 13px;
  font-weight: 800;

  transition: transform .2s var(--ease), filter .2s ease;
}

.gate-button img { border-radius: 6px; }
.gate-button:hover { transform: translateY(-2px); filter: brightness(1.08); }

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

.identity {
  display: flex;
  align-items: center;
  gap: 22px;
  flex-wrap: wrap;

  padding: 26px;

  margin-bottom: 22px;

  background:
    linear-gradient(120deg, rgba(89, 202, 255, .07), transparent 55%),
    var(--panel);

  border: 1px solid var(--line);
  border-radius: 20px;
}

.avatar-wrap {
  position: relative;
  flex: 0 0 96px;
  width: 96px;
  height: 96px;
}

.avatar {
  display: block;
  width: 96px;
  height: 96px;

  object-fit: cover;

  border-radius: 28px;
  border: 2px solid rgba(89, 202, 255, .3);

  background: #081321;
}

.avatar-ring {
  position: absolute;
  inset: -7px;

  border-radius: 33px;
  border: 1px solid rgba(89, 202, 255, .16);

  pointer-events: none;
}

.identity-text {
  flex: 1 1 240px;
  min-width: 0;
}

.identity-text h1 {
  margin: 0 0 10px;

  /* A very long display name must not push the badges off the card. */
  min-width: 0;
  overflow-wrap: anywhere;

  font-size: clamp(23px, 4vw, 31px);
  font-weight: 900;
  letter-spacing: -1.1px;
}

.badges {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 9px;
}

.role-badge,
.rank-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;

  padding: 5px 11px;

  border-radius: 999px;

  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: .5px;
  text-transform: uppercase;

  white-space: nowrap;
}

.role-badge .ic,
.rank-badge .ic { width: 13px; height: 13px; }

.role-badge[hidden] { display: none; }

.owner-badge {
  background: rgba(255, 196, 107, .14);
  border: 1px solid rgba(255, 196, 107, .38);
  color: var(--amber);
}

.admin-badge {
  background: rgba(88, 101, 242, .16);
  border: 1px solid rgba(124, 133, 255, .4);
  color: var(--violet);
}

.rank-badge {
  background: rgba(89, 202, 255, .12);
  border: 1px solid rgba(89, 202, 255, .3);
  color: var(--blue-bright);
}

.identity-handle {
  margin: 0;
  color: var(--muted);
  font-size: 12.5px;
}

.admin-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;

  min-height: 40px;
  padding: 0 16px;

  border-radius: 10px;
  border: 1px solid rgba(255, 196, 107, .35);
  background: rgba(255, 196, 107, .09);

  color: var(--amber);

  font-size: 12px;
  font-weight: 800;

  transition: background .2s ease, transform .2s var(--ease);
}

.admin-link[hidden] { display: none; }

.admin-link .ic { width: 15px; height: 15px; }

.admin-link:hover {
  background: rgba(255, 196, 107, .16);
  transform: translateY(-2px);
}

/* ---------- Grid ---------- */

.profile-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.card {
  padding: 24px;

  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;

  /* Prevents a long unbroken value from widening the grid track. */
  min-width: 0;
}

.card.wide { grid-column: 1 / -1; }

.card-head { margin-bottom: 20px; }

.card-head h2 {
  margin: 0 0 6px;
  font-size: 16px;
  font-weight: 800;
  letter-spacing: -.3px;
}

.card-head p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}

/* ---------- Fields ---------- */

.field { margin-bottom: 16px; min-width: 0; }

.field label {
  display: block;
  margin-bottom: 8px;
  color: #dbe6f5;
  font-size: 12px;
  font-weight: 700;
}

.input-wrap {
  position: relative;
  min-width: 0;
}

.field-icon {
  position: absolute;
  top: 14px;
  left: 14px;

  width: 16px;
  height: 16px;

  color: #6f8299;

  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;

  pointer-events: none;
  transition: color .2s ease;
}

.input-wrap input,
.input-wrap textarea {
  width: 100%;

  padding: 0 14px 0 42px;

  color: var(--text);
  background: #081321;

  border: 1px solid rgba(135, 180, 220, .17);
  border-radius: 10px;

  font-size: 13px;

  transition: border-color .2s ease, box-shadow .2s ease;
}

.input-wrap input { height: 46px; }

.input-wrap textarea {
  min-height: 100px;
  padding: 12px 14px;

  font-family: inherit;
  line-height: 1.65;
  resize: vertical;
}

.textarea-wrap .field-icon { display: none; }

.input-wrap input:hover,
.input-wrap textarea:hover { border-color: rgba(89, 202, 255, .45); }

.input-wrap input:focus,
.input-wrap textarea:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(89, 202, 255, .12);
}

.input-wrap:focus-within .field-icon { color: var(--blue); }

.field-note {
  margin: 7px 0 0;
  color: #64748b;
  font-size: 10.5px;
  text-align: right;
}

.form-message {
  margin: 0 0 14px;
  color: var(--rose);
  font-size: 12px;
  line-height: 1.6;
  overflow-wrap: anywhere;
}

.form-message:empty { display: none; }
.form-message.success { color: var(--green); }

.card-actions {
  display: flex;
  justify-content: flex-end;
}

.submit-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;

  min-height: 44px;
  padding: 0 18px;

  border: 0;
  border-radius: 10px;

  background: linear-gradient(120deg, #91e4ff, #49b9ff);
  color: #04111d;

  font-size: 12px;
  font-weight: 800;

  cursor: pointer;

  transition: transform .2s var(--ease), filter .2s ease;
}

.submit-button .ic { width: 15px; height: 15px; }
.submit-button:hover:not(:disabled) { transform: translateY(-2px); filter: brightness(1.05); }

.submit-button:disabled {
  opacity: .6;
  cursor: not-allowed;
  transform: none;
}

.ghost-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;

  min-height: 44px;
  padding: 0 16px;

  border: 1px solid var(--line);
  border-radius: 10px;

  background: transparent;
  color: var(--muted);

  font-size: 12px;
  font-weight: 700;

  cursor: pointer;

  transition: color .2s ease, border-color .2s ease;
}

.ghost-button .ic { width: 15px; height: 15px; }
.ghost-button:hover { color: var(--blue); border-color: rgba(89, 202, 255, .4); }

.danger-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;

  min-height: 38px;
  padding: 0 14px;

  border: 1px solid rgba(255, 143, 153, .32);
  border-radius: 9px;

  background: rgba(255, 143, 153, .07);
  color: var(--rose);

  font-size: 11.5px;
  font-weight: 800;

  cursor: pointer;

  transition: background .2s ease;
}

.danger-button .ic { width: 14px; height: 14px; }
.danger-button:hover { background: rgba(255, 143, 153, .14); }

/* ---------- Link box ---------- */

.link-hint {
  margin: 0 0 16px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.75;
}

.link-hint code {
  padding: 2px 6px;
  border-radius: 5px;
  background: rgba(89, 202, 255, .1);
  border: 1px solid rgba(89, 202, 255, .22);
  color: var(--blue-bright);
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 11px;
}

.link-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.code-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;

  padding: 20px;

  margin-bottom: 16px;

  border: 1px dashed rgba(89, 202, 255, .4);
  border-radius: 13px;
  background: rgba(89, 202, 255, .06);
}

.code-box[hidden] { display: none; }

.code-label {
  color: var(--muted);
  font-size: 9.5px;
  font-weight: 800;
  letter-spacing: 1.2px;
  text-transform: uppercase;
}

.code-value {
  color: var(--blue-bright);
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: clamp(22px, 6vw, 30px);
  font-weight: 800;
  letter-spacing: 3px;
}

.code-timer {
  color: #64748b;
  font-size: 11px;
}

.linked-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;

  padding: 16px;

  border: 1px solid rgba(80, 223, 160, .26);
  border-radius: 13px;
  background: rgba(80, 223, 160, .06);
}

.linked-box[hidden] { display: none; }

.linked-info {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.linked-icon {
  display: grid;
  place-items: center;
  flex: 0 0 40px;
  width: 40px;
  height: 40px;

  border-radius: 11px;
  background: rgba(80, 223, 160, .13);
  color: var(--green);
}

.linked-icon .ic { width: 19px; height: 19px; }

.linked-info strong {
  display: block;
  min-width: 0;
  overflow-wrap: anywhere;

  color: var(--text);
  font-size: 14px;
  font-weight: 800;
}

.linked-info span {
  display: block;
  min-width: 0;

  color: var(--muted);
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 10.5px;
  overflow-wrap: anywhere;
}

/* ---------- Log out ---------- */

.account-foot {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;

  margin-top: 18px;
  padding-top: 18px;

  border-top: 1px solid var(--line);
}

.logout-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;

  min-height: 42px;
  padding: 0 18px;

  border: 1px solid rgba(255, 143, 153, .32);
  border-radius: 10px;

  background: rgba(255, 143, 153, .07);
  color: var(--rose);

  font-size: 12px;
  font-weight: 800;

  cursor: pointer;

  transition: background .2s ease, border-color .2s ease, transform .2s var(--ease);
}

.logout-button .ic {
  width: 15px;
  height: 15px;

  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.logout-button:hover:not(:disabled) {
  background: rgba(255, 143, 153, .14);
  border-color: rgba(255, 143, 153, .5);
  transform: translateY(-2px);
}

.logout-button:active:not(:disabled) {
  transform: translateY(0);
}

.logout-button:disabled {
  opacity: .6;
  cursor: not-allowed;
  transform: none;
}

.logout-note {
  margin: 0;

  color: var(--muted);
  font-size: 11.5px;
  line-height: 1.6;
}

/* ---------- Facts ---------- */

.facts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 14px;
  margin: 0;
}

.fact {
  min-width: 0;
  padding: 14px 15px;

  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(4, 9, 20, .3);
}

.fact dt {
  display: flex;
  align-items: center;
  gap: 6px;

  margin: 0 0 6px;

  color: var(--muted);
  font-size: 9.5px;
  font-weight: 800;
  letter-spacing: 1px;
  text-transform: uppercase;
}

/*
 * The label icon inherits the label colour so it stays quiet, and sits
 * at 12px because the label itself is only 9.5px. Sizing lives here
 * rather than as width/height on the svg, per the shared icon rule.
 */
.fact dt .ic {
  width: 12px;
  height: 12px;
  color: var(--blue-light, #72a5ff);
}

.fact dd {
  margin: 0;
  min-width: 0;

  color: var(--text);
  font-size: 13.5px;
  font-weight: 700;

  overflow-wrap: anywhere;
}

/* ---------- Light theme ---------- */

body.light-theme {
  --panel: rgba(255, 255, 255, .9);
  --line: rgba(15, 40, 70, .12);
  --text: #0b1b2c;
  --muted: #4a5f75;
}

body.light-theme .input-wrap input,
body.light-theme .input-wrap textarea { background: #fff; }

body.light-theme .fact { background: rgba(15, 40, 70, .03); }
body.light-theme .field label { color: #1d3346; }

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

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

@media (max-width: 560px) {
  .profile-page { padding: 24px 15px 50px; }

  .identity { padding: 20px 16px; gap: 16px; }
  .card { padding: 18px 15px; }

  .card-actions,
  .link-actions { flex-direction: column; }

  .card-actions > *,
  .link-actions > * { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: .01ms !important;
    transition-duration: .01ms !important;
  }
}