/* Profilseite: Wappen-Kopf (Profilbild mit EXP-Rand, Name als Titel, Siegel),
   Schmiede zum Bearbeiten, Vitrine mit Erfolgen und die Reiter.
   Farben wie ueberall: Gold = Rang/aktuell, Teal = geschafft, Rosé = EXP.
   Partien stehen in profile-games.css; Reiter, Knoepfe, Erfolge, Freunde und
   Konto in profile-panels.css. */

.profilePage { width: 100%; }
.pf-root {
  position: relative;
  z-index: 1;
  box-sizing: border-box;
  width: 100%;
  max-width: calc(1240px + 112px);
  margin: 0 auto;
  padding: clamp(72px, 10vh, 112px) 56px 80px;
  container-type: inline-size;
}
.pf-root > * { position: relative; }
.profileTabPanel[hidden], .pf-forge[hidden], .pf-level[hidden], .pf-exp-left[hidden],
.pf-inline-err[hidden], .pf-tab-new[hidden], .ptMemberChip[hidden] { display: none; }

/* Gaeste (nur nach Abmelden auf der Seite): nur die Anmeldekarte. */
#profilePage:not(.is-registered) .registeredOnly { display: none; }
#profilePage:not(.is-registered) .profileTabPanel[data-tab-panel="account"][hidden] { display: block; }
#profilePage:not(.is-registered) :is(.pf-level, .pf-exp-left, .pf-exp-fill) { display: none; }

/* ── Kopf ── */
.pf-head {
  display: grid;
  grid-template-columns: 232px minmax(0, 1fr);
  grid-template-areas: "crest id" "crest seals";
  column-gap: 56px;
  row-gap: 24px;
  align-items: center;
  margin-bottom: 30px;
}
.pf-id { grid-area: id; position: relative; min-width: 0; align-self: end; overflow-x: clip; }
.pf-dateline { margin-bottom: 16px; padding-right: 150px; }
.pf-dateline-text { display: inline-flex; align-items: center; min-width: 0; white-space: nowrap; }
.pf-dateline .ptMemberChip { color: var(--mp-gold-1); font-weight: 700; }
.pf-dateline .ptMemberChip.is-supporter { color: var(--mp-teal-1); }
.pf-dateline .ptMemberChip::after { content: "\00b7"; margin: 0 .7em; color: var(--mp-ink-dim); }
.pf-name {
  white-space: nowrap;
  overflow-wrap: normal;
  font-size: var(--pf-fs, clamp(48px, 7vw, 112px));
  margin: 0 0 14px;
}
.pf-name.is-wrap { white-space: normal; overflow-wrap: anywhere; }
.pf-name.is-swap { animation: pfSwap .32s ease both; }
@keyframes pfSwap { from { opacity: 0; } }
.pf-bio { margin: 0; max-width: 640px; overflow-wrap: anywhere; }

.pf-edit {
  position: absolute;
  top: -7px;
  right: 0;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px 7px 10px;
  font-family: var(--mp-mono);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 2.4px;
  text-transform: uppercase;
  color: var(--mp-gold-1);
  background: transparent;
  border: 1px solid rgba(216, 177, 90, .28);
  cursor: var(--mp-cur-pointer);
  transition: border-color .16s ease, background .16s ease;
}
.pf-edit svg { width: 13px; height: 13px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; transition: rotate .36s cubic-bezier(.22, .8, .24, 1); }
.pf-edit:hover, .pf-edit:focus-visible, .pf-edit[aria-expanded="true"] { border-color: rgba(216, 177, 90, .62); background: rgba(216, 177, 90, .06); }
.pf-edit[aria-expanded="true"] svg { rotate: -12deg; }

/* ── Wappen: Profilbild als Raute, aussen der EXP-Rand, unten das Level ── */
.pf-crest { grid-area: crest; position: relative; width: 232px; aspect-ratio: 1; }
.pf-exp { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.pf-exp polygon { fill: none; }
.pf-exp-track { stroke: rgba(216, 177, 90, .3); stroke-width: .6; }
.pf-exp-fill {
  stroke: var(--mp-aura-1);
  stroke-width: 1;
  stroke-dasharray: 100;
  stroke-dashoffset: calc(100 - var(--exp, 0) * 100);
}
.pf-crest.is-drawing .pf-exp-fill { transition: stroke-dashoffset .9s cubic-bezier(.2, .7, .2, 1); }
.pf-crest .ptAvatar {
  position: absolute;
  inset: 9%;
  width: auto;
  height: auto;
  display: grid;
  place-items: center;
  scale: none;
  --av-rim: 2px;
  background: var(--mp-gold-2);
  font-size: 62px;
  font-weight: 700;
  letter-spacing: 2px;
  line-height: 1;
}
/* Patron: eine zweite feine Goldlinie innen, der Rand bleibt Gold. */
body.is-patron .pf-crest .ptAvatar::after {
  content: "";
  position: absolute;
  inset: 7px;
  z-index: 2;
  clip-path: polygon(50% 0, 100% 50%, 50% 100%, 0 50%);
  background: linear-gradient(135deg, #f3d88a, #ad8230);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  padding: 1px;
  pointer-events: none;
}
.pf-crest-hit {
  position: absolute;
  inset: 9%;
  clip-path: polygon(50% 0, 100% 50%, 50% 100%, 0 50%);
  background: transparent;
  border: 0;
  cursor: var(--mp-cur-pointer);
}
.pf-crest-pen {
  position: absolute;
  top: 50%;
  right: 3%;
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  translate: 0 -50%;
  clip-path: polygon(50% 0, 100% 50%, 50% 100%, 0 50%);
  background: rgba(8, 10, 14, .88);
  color: var(--mp-gold-1);
  opacity: 0;
  transition: opacity .18s ease;
}
.pf-crest-pen svg { width: 13px; height: 13px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
@media (hover: hover) {
  .pf-crest-hit:hover .pf-crest-pen { opacity: 1; }
}
.pf-crest-hit:focus-visible .pf-crest-pen { opacity: 1; }
.pf-level {
  position: absolute;
  left: 50%;
  bottom: -2px;
  z-index: 3;
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  translate: -50% 0;
  isolation: isolate;
  clip-path: polygon(50% 0, 100% 50%, 50% 100%, 0 50%);
  background: var(--mp-aura-1);
}
.pf-level::before {
  content: "";
  position: absolute;
  inset: 1.5px;
  z-index: -1;
  clip-path: inherit;
  background: #0b0d12;
}
.pf-level b { font-family: var(--mp-serif); font-size: 17px; font-weight: 700; color: var(--mp-aura-1); line-height: 1; }
.pf-level.is-stamping b { animation: dgStamp .55s cubic-bezier(.2, .9, .3, 1.25) var(--stamp, 0ms) both; }
.pf-exp-left {
  position: absolute;
  left: 50%;
  top: calc(100% + 12px);
  translate: -50% 0;
  font-family: var(--mp-mono);
  font-size: 10px;
  letter-spacing: 1.6px;
  text-transform: uppercase;
  color: color-mix(in srgb, var(--mp-aura-1) 70%, var(--mp-ink-dim));
  white-space: nowrap;
}
/* Gespeichert: eine Goldraute laeuft einmal vom Bild nach aussen. */
.pf-crest::after {
  content: "";
  position: absolute;
  inset: 22%;
  rotate: 45deg;
  border: 2px solid var(--mp-gold-1);
  opacity: 0;
  pointer-events: none;
}
.pf-crest.is-saved::after { animation: dgRing .9s ease-out both; }

/* ── Siegel: Rang und Bilanz ── */
.pf-seals {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr);
  padding-top: 22px;
  border-top: 1px solid rgba(216, 177, 90, .14);
}
.pf-seal {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 18px;
  min-width: 0;
  padding: 2px 24px;
  text-align: left;
  color: inherit;
  background: transparent;
  border: 0;
  border-left: 1px solid rgba(216, 177, 90, .14);
  cursor: var(--mp-cur-pointer);
}
.pf-seal:first-child { padding-left: 0; border-left: 0; }
.pf-seal .rk-emblem { width: 70px; }
.pf-seal-k {
  display: block;
  margin-bottom: 4px;
  font-family: var(--mp-sans);
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 2.4px;
  text-transform: uppercase;
  color: var(--mp-ink-dim);
  transition: color .16s ease;
}
.pf-seal-meta { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.pf-seal .rk-elo b, .pf-seal .rk-elo.is-ghost { font-size: 34px; }
.pf-seal .rk-id-row { margin-top: 5px; }
.pf-seal-icon {
  position: relative;
  display: grid;
  place-items: center;
  width: 62px;
  aspect-ratio: 1;
  color: var(--mp-gold-1);
}
.pf-seal-icon::before {
  content: "";
  position: absolute;
  inset: 15%;
  rotate: 45deg;
  border: 1px solid rgba(216, 177, 90, .42);
  background: rgba(216, 177, 90, .05);
  transition: border-color .16s ease;
}
.pf-seal-icon svg { position: relative; width: 22px; height: 22px; }
.pf-record { display: flex; align-items: baseline; gap: 16px; font-family: var(--mp-serif); font-size: 26px; font-weight: 700; line-height: 1.1; font-variant-numeric: tabular-nums; }
.pf-record span { display: inline-flex; align-items: center; gap: 8px; }
.pf-record i { width: 7px; height: 7px; rotate: 45deg; translate: 0 -4px; }
.pf-record .is-win { color: #84e8b0; } .pf-record .is-win i { background: #84e8b0; }
.pf-record .is-loss { color: #ef958a; } .pf-record .is-loss i { background: #ef958a; }
.pf-record .is-draw { color: rgba(240, 232, 210, .55); } .pf-record .is-draw i { background: rgba(240, 232, 210, .35); }
.pf-record.is-ghost { color: var(--mp-ink-dim); }
.pf-seal-sub { margin-top: 6px; font-family: var(--mp-mono); font-size: 10px; letter-spacing: 1.8px; text-transform: uppercase; color: var(--mp-ink-dim); }
@media (hover: hover) {
  .pf-seal:hover .pf-seal-k { color: var(--mp-bone); }
  .pf-seal:hover .pf-seal-icon::before { border-color: var(--mp-gold-1); }
}
.pf-seal:focus-visible .pf-seal-k { color: var(--mp-bone); }

/* ── Schmiede: Bio und Profilbild ── */
.pf-forge {
  display: grid;
  grid-template-rows: 1fr;
  margin: 0 0 30px;
  transition: grid-template-rows .36s cubic-bezier(.22, .8, .24, 1), opacity .36s ease;
}
.pf-forge.is-closing { grid-template-rows: 0fr; opacity: 0; }
.pf-forge.is-opening { animation: pfOpen .36s cubic-bezier(.22, .8, .24, 1) both; }
@keyframes pfOpen { from { grid-template-rows: 0fr; opacity: 0; } }
.pf-forge-form {
  min-height: 0;
  overflow: hidden;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr);
  gap: 18px 34px;
  padding: 24px 26px 20px;
  background: linear-gradient(180deg, rgba(13, 16, 22, .62), rgba(8, 9, 13, .86));
  border: 1px solid rgba(216, 177, 90, .18);
}
.pf-forge-col { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.pf-k {
  display: block;
  line-height: 1.4;
  font-family: var(--mp-sans);
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 2.4px;
  text-transform: uppercase;
  color: var(--mp-ink-dim);
}
.pf-bio-input {
  box-sizing: border-box;
  width: 100%;
  min-height: 112px;
  padding: 12px 14px;
  resize: vertical;
  font-family: var(--mp-serif-body);
  font-size: 18px;
  line-height: 1.45;
  color: var(--mp-bone);
  background: rgba(5, 6, 9, .6);
  border: 1px solid rgba(216, 177, 90, .18);
  border-radius: 0;
}
.pf-bio-input:focus { outline: none; border-color: rgba(216, 177, 90, .55); }
.pf-bio-count { align-self: flex-end; font-family: var(--mp-mono); font-size: 10.5px; color: var(--mp-ink-dim); }
.pf-picker { display: flex; flex-wrap: wrap; gap: 10px; max-height: 136px; overflow-y: auto; padding: 4px 2px; }
.pf-picker .profileAvatarOption {
  position: relative;
  display: grid;
  place-items: center;
  width: 58px;
  height: 58px;
  padding: 0;
  clip-path: polygon(50% 0, 100% 50%, 50% 100%, 0 50%);
  background: rgba(216, 177, 90, .32);
  border: 0;
  cursor: var(--mp-cur-pointer);
  transition: background .16s ease;
}
.pf-picker .profileAvatarOptionArt {
  position: absolute;
  inset: 1.5px;
  display: grid;
  place-items: center;
  clip-path: inherit;
  background: linear-gradient(135deg, #2a313e, #14171f);
  font-family: var(--mp-serif);
  font-size: 15px;
  font-weight: 700;
  color: var(--mp-gold-1);
}
.pf-picker .profileAvatarOptionImg { width: 100%; height: 100%; object-fit: cover; }
.pf-picker .profileAvatarOption:hover { background: rgba(216, 177, 90, .65); }
.pf-picker .profileAvatarOption.selected { background: var(--mp-gold-1); }
.pf-picker .profileAvatarOption.selected .profileAvatarOptionArt { inset: 2.5px; }
.pf-picker .profileAvatarUpload .profileAvatarOptionArt { font-family: var(--mp-sans); font-size: 20px; font-weight: 400; background: rgba(8, 10, 14, .9); }
.pf-forge-actions { grid-column: 1 / -1; display: flex; align-items: center; justify-content: flex-end; gap: 10px; }
.pf-forge-actions .pf-inline-err { margin: 0 auto 0 0; }
/* Schmiede unveraendert: der Speichern-Knopf wartet still als Umriss. */
.pf-forge:not([data-dirty]) #profilePersonalizeSubmit { color: var(--mp-gold-1); background: transparent; border-color: rgba(216, 177, 90, .32); box-shadow: none; transform: none; }

/* ── Vitrine: Erfolge stehen auf der Goldlinie ── */
.pf-shelf {
  display: flex;
  align-items: flex-end;
  gap: 14px;
  min-height: 62px;
  margin-bottom: 26px;
  padding: 0 2px 9px;
}
.pf-shelf-items { display: flex; align-items: flex-end; gap: 14px; min-width: 0; }
.pf-shelf::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 1px;
  background: linear-gradient(90deg, rgba(216, 177, 90, .42), rgba(216, 177, 90, .42) 70%, transparent);
}
.pf-trophy, .pf-shelf-next, .pf-shelf-slot {
  position: relative;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  padding: 0;
  color: var(--mp-gold-1);
  background: transparent;
  border: 0;
}
.pf-trophy, .pf-shelf-next { cursor: var(--mp-cur-pointer); }
.pf-trophy::before, .pf-shelf-slot::before {
  content: "";
  position: absolute;
  inset: 15%;
  rotate: 45deg;
  border: 1px solid var(--mp-gold-3);
  background: linear-gradient(135deg, rgba(216, 177, 90, .16), rgba(216, 177, 90, .04));
  transition: border-color .16s ease;
}
.pf-trophy svg { position: relative; }
.pf-trophy:hover::before, .pf-trophy:focus-visible::before { border-color: var(--mp-gold-1); }
.pf-shelf-slot::before { border-style: dashed; border-color: rgba(216, 177, 90, .3); background: none; }
.pf-shelf-next { color: var(--mp-ink-faint); }
.pf-shelf-next .pf-rim { position: absolute; inset: 0; }
.pf-shelf-next svg:last-child { position: relative; }
.pf-trophy.is-fresh::before { animation: dgStamp .55s cubic-bezier(.2, .9, .3, 1.25) var(--stamp, 0ms) both; }
.pf-trophy.is-fresh svg { animation: dgStamp .55s cubic-bezier(.2, .9, .3, 1.25) var(--stamp, 0ms) both; }
.pf-shelf-all {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
  padding: 6px 2px 10px 12px;
  font-family: var(--mp-mono);
  font-size: 13px;
  font-weight: 700;
  color: var(--mp-gold-1);
  background: transparent;
  border: 0;
  cursor: var(--mp-cur-pointer);
}
.pf-shelf-all small { font-size: inherit; font-weight: 400; color: var(--mp-ink-dim); }
.pf-shelf-all svg { width: 14px; height: 14px; transition: transform .16s ease; }
.pf-shelf-all:hover svg, .pf-shelf-all:focus-visible svg { transform: translateX(3px); }

/* ── Schmaler (Container < 900px) ── */
@container (max-width: 899px) {
  .pf-head { grid-template-columns: 176px minmax(0, 1fr); column-gap: 32px; }
  .pf-crest { width: 176px; }
  .pf-crest .ptAvatar { font-size: 48px; }
  .pf-seal { padding: 2px 14px; gap: 12px; }
  .pf-seal .rk-emblem { width: 58px; }
  .pf-seal-icon { width: 52px; }
  .pf-forge-form { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 820px) {
  .pf-root { padding: 64px 14px 60px; }
}

/* ── Handy und sehr schmal: Wappen neben gestapelten Siegeln ── */
@container (max-width: 640px) {
  .pf-head { grid-template-columns: 116px minmax(0, 1fr); grid-template-areas: "id id" "crest seals"; column-gap: 16px; row-gap: 18px; margin-bottom: 22px; }
  .pf-crest { width: 116px; align-self: start; }
  .pf-crest .ptAvatar { font-size: 32px; --av-rim: 1.5px; }
  .pf-level { width: 34px; height: 34px; bottom: -4px; }
  .pf-level b { font-size: 13px; }
  .pf-exp-left { top: calc(100% + 8px); font-size: 9px; letter-spacing: 1px; }
  .pf-dateline { padding-right: 44px; letter-spacing: 2.4px; gap: 10px; }
  .pf-dateline .line { display: none; }
  .pf-dateline-text { overflow: hidden; text-overflow: ellipsis; }
  .pf-edit { padding: 8px; }
  .pf-edit span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .pf-seals { grid-template-columns: minmax(0, 1fr); padding-top: 0; border-top: 0; }
  .pf-seal { padding: 9px 0; border-left: 0; border-top: 1px solid rgba(216, 177, 90, .12); gap: 12px; }
  .pf-seal:first-child { padding-top: 0; border-top: 0; }
  .pf-seal .rk-emblem { width: 50px; }
  .pf-seal-icon { width: 46px; }
  .pf-seal-icon svg { width: 18px; height: 18px; }
  .pf-seal .rk-elo b, .pf-seal .rk-elo.is-ghost { font-size: 26px; }
  .pf-record { font-size: 21px; gap: 12px; }
  .pf-forge-form { padding: 18px 16px 16px; }
  .pf-forge-actions { flex-wrap: wrap; }
  .pf-forge-actions button { flex: 1 1 0; padding-inline: 10px; letter-spacing: 1.6px; white-space: nowrap; }
  .pf-forge-actions .pf-inline-err { flex-basis: 100%; }
  .pf-shelf { gap: 6px; }
  .pf-shelf-items {
    flex: 1 1 auto;
    gap: 8px;
    padding-top: 8px;
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-mask-image: linear-gradient(90deg, #000 calc(100% - 26px), transparent);
    mask-image: linear-gradient(90deg, #000 calc(100% - 26px), transparent);
  }
  .pf-shelf-items::-webkit-scrollbar { display: none; }
  .pf-trophy, .pf-shelf-next, .pf-shelf-slot { width: 40px; height: 40px; }
  .pf-shelf-all { flex: none; padding-left: 4px; }
}
body.mp-phone .pf-root { padding: 28px 14px 56px; }
body.mp-phone .pf-seal .rk-emblem { width: 50px; }
body.mp-phone .pf-name { overflow-wrap: normal; letter-spacing: 2px; }

@media (prefers-reduced-motion: reduce) {
  .pf-trophy.is-fresh::before, .pf-trophy.is-fresh svg,
  .pf-level.is-stamping b, .pf-crest.is-saved::after, .pf-forge.is-opening, .pf-name.is-swap { animation: none; }
  .pf-crest.is-drawing .pf-exp-fill, .pf-forge, .pf-edit svg { transition: none; }
}
