/* ============ DM Tavern — profiles & cosmetics ============ */

/* ---------- avatar sizes, emblems ---------- */
.av.xl { width: 96px; height: 96px; font-size: 38px; border-width: 3px; }
.av .av-sigil { width: 62%; height: 62%; color: #f3e6c8; filter: drop-shadow(0 1px 1px rgba(0,0,0,.6)); }
.av[data-uid] { cursor: pointer; }

/* ---------- frames (drawn around any avatar with .fr) ---------- */
.av.fr { overflow: visible; }
.av.fr::before, .av.fr::after { content: ""; position: absolute; border-radius: 50%; pointer-events: none; }
.av.fr::before { inset: -3px; }
.av.sm.fr::before { inset: -2px; }
.av.xl.fr::before { inset: -6px; }
.fr-bronze::before { border: 2px solid #a8703a; }
.fr-silver::before { border: 2px solid #c8ccd4; box-shadow: 0 0 0 1px rgba(0,0,0,.4) inset; }
.fr-gilded::before { border: 2px solid #e3c88f; box-shadow: 0 0 0 2px #7a5a2a, 0 0 8px rgba(227,200,143,.45); }
.fr-verdant::before { border: 2px dotted #6fbf7a; box-shadow: 0 0 0 2px #1f3a24, 0 0 8px rgba(111,191,122,.35); }
.fr-runic::before { border: 2px dashed #c9a45c; animation: spin 9s linear infinite; }
.fr-runic::after { inset: -6px; border: 1px solid rgba(201,164,92,.35); animation: spin 14s linear infinite reverse; }
.fr-ember::before { border: 2px solid #e0703a; animation: emberPulse 2.2s ease-in-out infinite; }
.fr-frost::before { border: 2px solid #9fd4ff; background: conic-gradient(from 0deg, transparent, rgba(190,230,255,.35), transparent 40%); -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 3px), #000 0); mask: radial-gradient(farthest-side, transparent calc(100% - 3px), #000 0); animation: spin 4s linear infinite; }
.fr-frost::after { inset: -3px; box-shadow: 0 0 10px rgba(159,212,255,.45); }
/* Legend frames: animated conic rings */
.fr-dragonfire::before, .fr-celestial::before, .fr-void::before, .fr-lich::before {
  inset: -5px; padding: 3px; -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0); -webkit-mask-composite: xor; mask-composite: exclude; animation: spin 3s linear infinite;
}
.av.sm.fr-dragonfire::before, .av.sm.fr-celestial::before, .av.sm.fr-void::before, .av.sm.fr-lich::before { inset: -3px; padding: 2px; }
.fr-dragonfire::before { background: conic-gradient(#ff3d1f, #ffb02e, #ff3d1f, #7a0f06, #ff6a1f, #ffd24a, #ff3d1f); }
.fr-dragonfire::after { inset: -8px; background: radial-gradient(circle, rgba(255,110,40,.35), transparent 65%); animation: flicker 1.3s ease-in-out infinite; }
.fr-celestial::before { background: conic-gradient(#fff6d8, #ffd98a, #fff, #c7b2ff, #fff6d8); animation-duration: 6s; }
.fr-celestial::after { inset: -12px; background: repeating-conic-gradient(rgba(255,240,200,.35) 0 4deg, transparent 4deg 20deg); -webkit-mask: radial-gradient(circle, transparent 52%, #000 56%, transparent 72%); mask: radial-gradient(circle, transparent 52%, #000 56%, transparent 72%); animation: spin 12s linear infinite; }
.fr-void::before { background: conic-gradient(#120022, #7a3cff, #120022, #000, #b06cff, #120022); animation-duration: 2.2s; }
.fr-void::after { inset: -9px; background: radial-gradient(circle, transparent 55%, rgba(122,60,255,.35) 62%, transparent 75%); animation: voidPulse 2.6s ease-in-out infinite; }
.fr-lich::before { background: conic-gradient(#7dffb0, #0f3a24, #7dffb0, #0b1f14, #b6ffd6, #7dffb0); animation-duration: 5s; }
.fr-lich::after { inset: -9px; background: radial-gradient(circle, rgba(125,255,176,.28), transparent 65%); animation: voidPulse 3s ease-in-out infinite; }
.fr-astral::before { inset: -5px; border: 1px solid rgba(199,178,255,.5); }
.fr-astral::after { inset: -9px; background:
    radial-gradient(circle at 50% 0%, #fff 0 2px, transparent 3px), radial-gradient(circle at 100% 50%, #c7b2ff 0 2px, transparent 3px),
    radial-gradient(circle at 50% 100%, #ffd98a 0 2px, transparent 3px), radial-gradient(circle at 0% 50%, #9fd4ff 0 1.5px, transparent 2.5px);
  animation: spin 5s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes emberPulse { 50% { box-shadow: 0 0 14px 2px rgba(224,112,58,.7); border-color: #ffb02e; } }
@keyframes flicker { 0%, 100% { opacity: .8; transform: scale(1); } 40% { opacity: 1; transform: scale(1.06); } 70% { opacity: .6; } }
@keyframes voidPulse { 50% { opacity: .5; transform: scale(1.08); } }

/* ---------- click effects ---------- */
.fx { position: fixed; z-index: 150; width: 0; height: 0; pointer-events: none; }
.fx .p { position: absolute; left: 0; top: 0; transform: translate(-50%, -50%); animation: burst .9s ease-out var(--d, 0s) forwards; opacity: 0; }
@keyframes burst { 0% { opacity: 1; transform: translate(-50%, -50%) scale(.6); } 100% { opacity: 0; transform: translate(calc(-50% + var(--x)), calc(-50% + var(--y))) scale(1); } }
.fx .dust { width: 4px; height: 4px; border-radius: 50%; background: #d8cfc0; }
.fx .star { color: #ffe39a; font-size: 14px; text-shadow: 0 0 6px #ffd24a; }
.fx .ember { width: 5px; height: 5px; border-radius: 50%; background: #ffb02e; box-shadow: 0 0 8px 2px #ff6a1f; animation-duration: 1.3s; }
.fx .flame { width: 14px; height: 14px; border-radius: 50%; background: radial-gradient(circle, #fff3b0, #ff8a1f 45%, rgba(255,40,10,0) 70%); animation-duration: 1s; }
.fx .dragon-core { position: absolute; left: 0; top: 0; width: 220px; height: 220px; transform: translate(-50%, -50%) scale(.2); border-radius: 50%;
  background: radial-gradient(circle, rgba(255,240,180,.95), rgba(255,120,30,.75) 35%, rgba(200,30,10,.35) 55%, transparent 70%); animation: blast .9s ease-out forwards; }
@keyframes blast { 60% { opacity: 1; } 100% { transform: translate(-50%, -50%) scale(1.3); opacity: 0; } }
.fx .rune-ring { position: absolute; left: 0; top: 0; width: 150px; height: 150px; transform: translate(-50%, -50%); border-radius: 50%; border: 2px solid rgba(201,164,92,.85);
  box-shadow: 0 0 18px rgba(201,164,92,.6), inset 0 0 18px rgba(201,164,92,.35); color: #ffe39a; font-size: 13px; letter-spacing: 4px; display: grid; place-items: center; text-align: center; padding: 18px; line-height: 1.6;
  animation: runeRing 1.4s ease-out forwards; }
.fx .rune-core { position: absolute; left: 0; top: 0; width: 40px; height: 40px; transform: translate(-50%, -50%); border-radius: 50%; background: radial-gradient(circle, #fff3c4, rgba(201,164,92,0) 70%); animation: blast 1s ease-out forwards; }
@keyframes runeRing { 0% { transform: translate(-50%, -50%) scale(.2) rotate(-90deg); opacity: 0; } 30% { opacity: 1; } 100% { transform: translate(-50%, -50%) scale(1.15) rotate(40deg); opacity: 0; } }
.fx .shoot { position: absolute; left: 0; top: 0; width: 90px; height: 2px; background: linear-gradient(90deg, transparent, #fff, #ffd98a); transform-origin: right center; border-radius: 2px;
  transform: translate(var(--sx), var(--sy)) rotate(38deg); opacity: 0; animation: shoot .7s ease-in var(--d) forwards; filter: drop-shadow(0 0 4px #fff); }
@keyframes shoot { 0% { opacity: 1; } 100% { transform: translate(-90px, 0) rotate(38deg); opacity: .2; } }
.fx .bolt { position: absolute; left: -30px; bottom: 0; width: 60px; filter: drop-shadow(0 0 8px #9fc4ff) drop-shadow(0 0 2px #fff); animation: boltFade .5s ease-out forwards; }
.fx .zap { position: absolute; left: 0; top: 0; width: 120px; height: 120px; transform: translate(-50%, -50%); border-radius: 50%; background: radial-gradient(circle, rgba(220,235,255,.95), rgba(120,170,255,.3) 40%, transparent 70%); animation: blast .5s ease-out forwards; }
@keyframes boltFade { 0%, 40% { opacity: 1; } 100% { opacity: 0; } }
.fx .soul { position: absolute; left: 0; top: 0; width: 18px; height: 28px; border-radius: 50% 50% 40% 40%; background: radial-gradient(ellipse at 50% 30%, rgba(210,255,230,.9), rgba(125,255,176,.2) 60%, transparent 75%);
  filter: blur(1px); opacity: 0; animation: soul 1.8s ease-out var(--d) forwards; }
@keyframes soul { 0% { opacity: 0; transform: translate(-50%, -50%) scale(.6); } 25% { opacity: .9; } 100% { opacity: 0; transform: translate(calc(-50% + var(--x)), calc(-50% - 160px)) rotate(var(--r)) scale(1.3); } }
body.warm-flash::after, body.flash-white::after { content: ""; position: fixed; inset: 0; z-index: 140; pointer-events: none; animation: fadeOut .7s forwards; }
body.warm-flash::after { background: radial-gradient(circle, rgba(255,120,40,.18), transparent 70%); }
body.flash-white::after { background: rgba(220,232,255,.18); animation-duration: .3s; }

/* ---------- banners ---------- */
.pbanner, .mini-banner { position: relative; overflow: hidden; }
.pbanner { height: 120px; }
.mini-banner { width: 100%; height: 44px; border-radius: 4px; }
.pbanner .scene, .mini-banner .scene { position: absolute; inset: 0; }
.mini-banner .scene .castle { display: none; }
[class*="banim-"] i { position: absolute; inset: 0; }
.banim-aurora { background: linear-gradient(180deg, #050812, #0c1424); }
.banim-aurora i { background: linear-gradient(100deg, transparent 20%, rgba(60,255,180,.35) 35%, rgba(120,140,255,.3) 50%, transparent 65%); filter: blur(10px); animation: aurora 9s ease-in-out infinite alternate; }
.banim-aurora i:nth-child(2) { animation-duration: 13s; animation-direction: alternate-reverse; opacity: .7; top: 20%; }
.banim-aurora i:nth-child(3) { background: radial-gradient(1px 1px at 20% 30%, #fff, transparent), radial-gradient(1px 1px at 70% 20%, #fff, transparent), radial-gradient(1px 1px at 45% 60%, #cfe, transparent); filter: none; animation: twinkle 4s infinite alternate; }
@keyframes aurora { from { transform: translateX(-20%) skewX(-10deg); } to { transform: translateX(20%) skewX(10deg); } }
.banim-starfield { background: radial-gradient(ellipse at 50% 120%, #2a1a4a, #07060d 70%); }
.banim-starfield i { background-image: radial-gradient(1.5px 1.5px at 10% 20%, #fff, transparent), radial-gradient(1px 1px at 30% 70%, #ffd98a, transparent), radial-gradient(1.5px 1.5px at 55% 35%, #fff, transparent),
  radial-gradient(1px 1px at 75% 80%, #c7b2ff, transparent), radial-gradient(1.5px 1.5px at 90% 15%, #fff, transparent); background-size: 200px 120px; animation: starDrift 8s linear infinite; }
.banim-starfield i:nth-child(2) { background-size: 140px 90px; animation-duration: 5s; opacity: .6; }
.banim-starfield i:nth-child(3) { background: linear-gradient(120deg, transparent 48%, rgba(255,255,255,.8) 50%, transparent 52%); background-size: 300px 300px; animation: meteor 3.5s linear infinite; }
@keyframes starDrift { to { background-position: -200px 120px; } }
@keyframes meteor { from { background-position: 300px -300px; } to { background-position: -300px 300px; } }
.banim-inferno { background: linear-gradient(0deg, #3a0a04, #0c0505); }
.banim-inferno i { background: radial-gradient(ellipse at 50% 120%, rgba(255,150,40,.7), rgba(200,40,10,.35) 40%, transparent 70%); animation: flicker 1.6s ease-in-out infinite; }
.banim-inferno i:nth-child(2) { background: radial-gradient(ellipse at 20% 130%, rgba(255,200,80,.5), transparent 60%); animation-duration: 2.3s; }
.banim-inferno i:nth-child(3) { background-image: radial-gradient(2px 2px at 20% 80%, #ffb02e, transparent), radial-gradient(2px 2px at 60% 90%, #ff6a1f, transparent), radial-gradient(1.5px 1.5px at 80% 70%, #ffd24a, transparent);
  background-size: 120px 120px; animation: emberRise 3s linear infinite; }
@keyframes emberRise { to { background-position: 0 -120px; } }

/* ---------- profile card ---------- */
.modal.modal-profile { padding: 0; max-width: 440px; overflow: hidden; }
.modal-profile .modal-actions { padding: 0 20px 18px; margin-top: 4px; border-top: 0; flex-wrap: wrap; justify-content: center; gap: 8px; }
.modal-profile .modal-actions > * { flex: 1 1 auto; justify-content: center; text-align: center; white-space: nowrap; }
.modal-profile .modal-actions > [data-act^="friend-"], .modal-profile .modal-actions > a[href^="#/friends"] { flex-basis: 100%; }
.pcard { position: relative; background: var(--surface); border-radius: 10px; overflow: hidden; border: 1px solid var(--border); }
.modal .pcard { border: 0; border-radius: 0; }
.pcard-body { padding: 0 22px 18px; text-align: center; }
.pcard-av { margin-top: -50px; display: flex; justify-content: center; position: relative; z-index: 2; }
.pcard-av .av { box-shadow: 0 0 0 4px var(--surface); }
.pname { font-family: var(--display); font-size: 24px; margin: 12px 0 2px; color: var(--ink); }
.legend-name { background: linear-gradient(90deg, #ffd98a, #fff6d8, #c7b2ff, #ffd98a); background-size: 300% 100%; -webkit-background-clip: text; background-clip: text; color: transparent; animation: shimmer 6s linear infinite; }
.ptitle { font-family: var(--prose); font-style: italic; color: var(--gold-2); font-size: 16px; }
.pmeta { font-size: 13px; color: var(--muted); margin: 6px 0 8px; }
.pbio { font-size: 14.5px; color: #d8cebf; margin: 10px 0 0; line-height: 1.5; }
.pshared { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; align-items: center; margin-top: 14px; font-size: 13px; }
.pshared a { padding: 2px 10px; border-radius: 99px; border: 1px solid var(--border-2); color: var(--ink); text-decoration: none; }
.pshared a:hover { border-color: var(--gold); }

/* ---------- profile page ---------- */
.profile-layout { display: grid; grid-template-columns: 340px minmax(0, 1fr); gap: 24px; align-items: start; }
.profile-preview { position: sticky; top: 76px; display: flex; flex-direction: column; gap: 16px; }
.tier-note p { margin: 6px 0 10px; }
.profile-save { position: sticky; bottom: 0; padding: 14px 0; background: linear-gradient(transparent, #121011 40%); display: flex; justify-content: flex-end; z-index: 5; }
@media (max-width: 900px) { .profile-layout { grid-template-columns: 1fr; } .profile-preview { position: static; } }
.swatches { display: flex; gap: 8px; flex-wrap: wrap; }
.swatches .sw { position: relative; inset: auto; overflow: visible; display: inline-block; }
.sw input { display: none; }
.sw span { display: block; width: 30px; height: 30px; border-radius: 50%; border: 2px solid transparent; cursor: pointer; box-shadow: inset 0 0 0 2px rgba(0,0,0,.3); }
.sw input:checked + span { border-color: var(--ink); box-shadow: 0 0 0 2px var(--gold); }
.pick-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 8px; }
.pick-grid.small { grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); }
.pick-grid.wide { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.pick input { display: none; }
.pick-box { position: relative; display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 12px 6px 8px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface-2); cursor: pointer; transition: border-color .15s; height: 100%; }
.pick-box em { font-style: normal; font-size: 12px; color: var(--muted); text-align: center; }
.pick:hover .pick-box { border-color: var(--border-2); }
.pick input:checked + .pick-box { border-color: var(--gold); box-shadow: inset 0 0 0 1px var(--gold); }
.pick input:checked + .pick-box em { color: var(--ink); }
.pick.locked .pick-box { opacity: .55; cursor: not-allowed; }
.lock-tag { position: absolute; top: 5px; right: 5px; font-size: 9.5px; font-weight: 600; padding: 0 5px; border-radius: 99px; line-height: 15px; }
.lock-tag.plus { color: #e3c88f; border: 1px solid rgba(201,164,92,.5); }
.lock-tag.legend { color: #e2d3ff; border: 1px solid rgba(157,123,216,.6); background: rgba(110,70,170,.25); }
.fx-try { padding: 8px 14px; border-radius: 6px; border: 1px solid var(--border-2); background: var(--surface-3); color: var(--ink); font-size: 13px; cursor: pointer; }
.fx-try:hover { border-color: var(--gold); }
.pick-box .av.lg { margin: 4px 0; }

/* thicker legend rings on large avatars */
.av.xl.fr-dragonfire::before, .av.xl.fr-celestial::before, .av.xl.fr-void::before, .av.xl.fr-lich::before { inset: -9px; padding: 5px; }
.av.lg.fr-dragonfire::before, .av.lg.fr-celestial::before, .av.lg.fr-void::before, .av.lg.fr-lich::before { inset: -6px; padding: 4px; }
.av.xl.fr-dragonfire::after { inset: -18px; }
.av.xl.fr-astral::after { inset: -14px; }

/* ---------- profile inventory: owned items only, in sections that fold away ---------- */
.inv-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin: 22px 2px 10px; }
.inv-head h2 { margin: 0; }
.inv-head p { margin: 4px 0 0; }
.inv-head .row-btns { display: flex; gap: 6px; flex-wrap: wrap; }
details.inv-sec { padding: 0; }
details.inv-sec + details.inv-sec { margin-top: 10px; }
details.inv-sec > summary { list-style: none; display: flex; align-items: center; gap: 12px; padding: 16px 20px; cursor: pointer; user-select: none; }
details.inv-sec > summary::-webkit-details-marker { display: none; }
details.inv-sec > summary h2 { margin: 0; flex: 1; min-width: 0; }
details.inv-sec > summary:hover { background: rgba(255, 255, 255, .03); }
details.inv-sec > summary:focus-visible { outline: 2px solid var(--gold, #d4a24c); outline-offset: -2px; }
.inv-count { font-size: 12px; color: var(--dim); white-space: nowrap; border: 1px solid var(--border); border-radius: 999px; padding: 2px 9px; }
.inv-chev { width: 10px; height: 10px; border-right: 2px solid var(--dim); border-bottom: 2px solid var(--dim); transform: rotate(45deg); transition: transform .2s; margin: 0 4px 4px 0; flex: none; }
details.inv-sec[open] > summary .inv-chev { transform: rotate(-135deg); margin-bottom: -4px; }
details.inv-sec[open] > summary { border-bottom: 1px solid var(--border); }
.inv-body { padding: 16px 20px 20px; }
#pf-free { margin-top: 22px; scroll-margin-top: 80px; }
@media (max-width: 560px) { details.inv-sec > summary .sub { display: none; } }

/* live preview while editing */
[data-pv] { position: relative; }
.pv-unsaved { position: absolute; top: 10px; right: 10px; z-index: 6; font-size: 11px; font-weight: 600; letter-spacing: .02em; padding: 3px 10px; border-radius: 999px; background: rgba(224,164,58,.92); color: #2a1a00; white-space: nowrap; }
.profile-save { align-items: center; gap: 10px; }
.profile-save .pv-note, .profile-save .pf-peek { display: none; }
.profile-save.dirty .pv-note { display: inline; color: #ffe2a8; font-size: 13px; margin-right: auto; }
@media (max-width: 900px) { .profile-save.dirty .pf-peek { display: inline-flex; } .profile-save.dirty .pv-note { display: none; } }
