/* Perfil personalizable: portada, foto con marco, color del perfil, recorte de fotos y edición.
   El color del perfil llega como --accent en la vista (.pf-page); lo derivado se recalcula aquí. */
.pf-page {
  --accent-soft: color-mix(in srgb, var(--accent) 13%, transparent);
  --accent-ink: color-mix(in srgb, var(--accent) 80%, #000);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) .pf-page { --accent-ink: color-mix(in srgb, var(--accent) 65%, #fff); }
}
:root[data-theme='dark'] .pf-page { --accent-ink: color-mix(in srgb, var(--accent) 65%, #fff); }

/* --- Cabecera: portada, foto, nombre --- */
.pf-hero { padding: 0; overflow: hidden; }
.pf-cover { aspect-ratio: 3 / 1; background-color: var(--accent); background-size: cover; background-position: center; position: relative; }
.pf-cover::after { content: ''; position: absolute; inset: auto 0 0; height: 45%; background: linear-gradient(transparent, rgb(0 0 0 / 22%)); }
.pf-head { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 8px; padding: 0 16px; margin-top: -58px; position: relative; z-index: 1; }
.pf-id { min-width: 0; max-width: 100%; }
.pf-name { margin: 0; font: 800 1.9rem/1.05 var(--display); overflow-wrap: anywhere; }
.pf-check { font-size: 1rem; margin-left: 6px; vertical-align: middle; }
.pf-meta { margin: 4px 0 0; overflow-wrap: anywhere; }
.pf-pills { justify-content: center; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.pf-body { padding: 12px 16px 18px; }
.pf-bio { margin: 0; text-align: center; white-space: pre-line; overflow-wrap: anywhere; }
.pf-body .pf-pills { margin-top: 0; }
.pf-actions { justify-content: center; flex-wrap: wrap; gap: 8px; }
.pf-actions .btn { min-height: 42px; padding: 0 16px; font-size: .92rem; }
.pf-follow:empty { display: none; }
@media (min-width: 720px) {
  /* La foto se monta sobre la portada; el nombre queda debajo de ella (no encima de la imagen). */
  .pf-head { flex-direction: row; align-items: flex-start; text-align: left; gap: 18px; padding: 0 24px; margin-top: -64px; }
  .pf-head .pf-pills { justify-content: flex-start; }
  .pf-id { padding-top: 74px; }
  .pf-preview .pf-id { padding-top: 60px; }
  .pf-body { padding: 14px 24px 22px; }
  .pf-bio { text-align: left; }
  .pf-body .pf-pills, .pf-body .pf-actions, .pf-body .pf-socials { justify-content: flex-start; }
}

/* --- Números --- */
.pf-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.pf-stat { background: var(--surface-2); border-radius: 14px; padding: 10px 6px; text-align: center; min-width: 0; }
.pf-stat b { display: block; font: 800 1.45rem/1 var(--display); color: var(--accent-ink); overflow-wrap: anywhere; }
.pf-stat span { display: block; font-size: .72rem; color: var(--ink-3); margin-top: 4px; text-transform: uppercase; letter-spacing: .03em; }
@media (min-width: 720px) { .pf-stats { grid-template-columns: repeat(6, 1fr); } }

/* --- Redes --- */
.pf-socials { justify-content: center; gap: 8px; flex-wrap: wrap; }
.pf-social { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 999px; text-decoration: none; font-weight: 600; font-size: .85rem; color: var(--ink); box-shadow: inset 0 0 0 1.5px var(--line); max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
.pf-social.ig { color: #c13584; }
.pf-social.strava { color: #fc4c02; }

/* --- Deportes con el color de su liga --- */
.pf-sports .pf-sport { border-left: 5px solid var(--tier-c, var(--line)); }
.tier-edge-bronce { --tier-c: #b8733a; }
.tier-edge-plata { --tier-c: #9aa3ae; }
.tier-edge-oro { --tier-c: #e0a100; }
.tier-edge-diamante { --tier-c: #1fb3e0; }
.tier-edge-leyenda { --tier-c: #ff7a1a; }
.pf-ficha { display: grid; place-items: center; }
.pf-ficha .ficha-canvas { max-width: 260px; }
.pf-nudge { margin-top: 12px; gap: 10px; flex-wrap: wrap; align-items: center; }
.pf-join { margin-top: 12px; }

/* --- Marco de la foto (grande) --- */
.pf-frame { --ring: var(--accent); position: relative; display: inline-grid; place-items: center; padding: 6px; border-radius: 50%; background: var(--ring); box-shadow: 0 0 0 4px var(--surface); flex: none; isolation: isolate; }
.pf-frame > .avatar { position: relative; z-index: 1; box-shadow: 0 0 0 3px var(--surface); }
.avatar.pf-avatar { width: 108px; height: 108px; font-size: 2.3rem; }
.pf-frame.frame-none { background: var(--surface); padding: 2px; }
.pf-frame.frame-none > .avatar { box-shadow: none; }
.pf-frame.frame-gold, .pf-frame.frame-fire, .pf-frame.frame-neon, .pf-frame.frame-rainbow { background: none; }
.pf-frame.frame-gold::before, .pf-frame.frame-fire::before, .pf-frame.frame-neon::before, .pf-frame.frame-rainbow::before {
  content: ''; position: absolute; inset: 0; border-radius: 50%; z-index: 0; }
.pf-frame.frame-gold::before { background: conic-gradient(from 0deg, #fff6d5, #e0a100, #8a6400, #f7d774, #fff6d5, #c9971c, #fff6d5); animation: pf-spin 6s linear infinite; }
.pf-frame.frame-gold { box-shadow: 0 0 0 4px var(--surface), 0 0 22px rgb(224 161 0 / 55%); }
.pf-frame.frame-fire::before { background: conic-gradient(from 0deg, #ff2d00, #ff8a00, #ffd000, #ff5a00, #ff2d00); animation: pf-spin 2.4s linear infinite; filter: blur(.4px); }
.pf-frame.frame-fire { box-shadow: 0 0 0 4px var(--surface), 0 0 26px rgb(255 90 0 / 60%); animation: pf-flicker 1.6s ease-in-out infinite; }
.pf-frame.frame-neon::before { background: conic-gradient(from 0deg, #ff2bd6, #38e8ff, #7dff8a, #ff2bd6); animation: pf-spin 3.5s linear infinite; }
.pf-frame.frame-neon { box-shadow: 0 0 0 4px var(--surface), 0 0 24px rgb(56 232 255 / 65%); animation: pf-glow 2.2s ease-in-out infinite; }
.pf-frame.frame-rainbow::before { background: conic-gradient(from 0deg, #ff3b3b, #ff9f1a, #ffe14d, #3ddc84, #2fa7ff, #8f5bff, #ff3b3b); animation: pf-spin 4s linear infinite; }
@keyframes pf-spin { to { transform: rotate(1turn); } }
@keyframes pf-flicker { 50% { box-shadow: 0 0 0 4px var(--surface), 0 0 34px rgb(255 140 0 / 75%); } }
@keyframes pf-glow { 50% { box-shadow: 0 0 0 4px var(--surface), 0 0 34px rgb(255 43 214 / 60%); } }
@media (prefers-reduced-motion: reduce) {
  .pf-frame, .pf-frame::before { animation: none !important; }
}

/* --- Anillo chico en listas, ranking y duelos (personAvatar en ui.js) --- */
.avatar.ring { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--ring, var(--accent)); }
.avatar.ring-gold { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px #e0a100, 0 0 8px 3px rgb(224 161 0 / 45%); }
.avatar.ring-fire { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px #ff6a00, 0 0 9px 3px rgb(255 90 0 / 50%); }
.avatar.ring-neon { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px #38e8ff, 0 0 9px 3px rgb(255 43 214 / 45%); }
.avatar.ring-rainbow { box-shadow: 0 0 0 2px var(--surface), 0 0 0 3px #ff3b3b, 0 0 0 4px #ffe14d, 0 0 0 5px #2fa7ff; }

/* --- Edición --- */
.pf-preview .pf-head { padding-bottom: 16px; }
.pf-preview .avatar.pf-avatar { width: 88px; height: 88px; font-size: 1.9rem; }
.pf-preview .pf-name { font-size: 1.5rem; }
.pf-btns { flex-wrap: wrap; gap: 8px; }
.pf-covers { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
@media (min-width: 560px) { .pf-covers { grid-template-columns: repeat(3, 1fr); } }
.pf-cover-tile { appearance: none; border: 0; cursor: pointer; aspect-ratio: 3 / 1; border-radius: 12px; background-size: cover; background-position: center; position: relative; overflow: hidden; padding: 0; box-shadow: inset 0 0 0 1px rgb(0 0 0 / 8%); }
.pf-cover-tile span { position: absolute; left: 6px; bottom: 5px; font: 700 .72rem var(--sans); color: #fff; background: rgb(0 0 0 / 45%); padding: 2px 8px; border-radius: 999px; }
.pf-cover-tile[aria-checked='true'] { outline: 3px solid var(--accent); outline-offset: 2px; }
.pf-cover-tile:focus-visible { outline: 3px solid var(--accent-2); outline-offset: 2px; }
.pf-swatches { display: flex; flex-wrap: wrap; gap: 10px; }
.pf-swatch { appearance: none; border: 0; cursor: pointer; width: 38px; height: 38px; border-radius: 50%; background: var(--sw); box-shadow: 0 0 0 2px var(--surface), 0 0 0 3px var(--line); }
.pf-swatch[aria-checked='true'] { box-shadow: 0 0 0 3px var(--surface), 0 0 0 6px var(--sw); }
.pf-swatch[aria-checked='true']::after { content: '✓'; color: #fff; font-weight: 800; }
.pf-frames { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 8px; }
.pf-frame-opt { appearance: none; cursor: pointer; display: grid; justify-items: center; gap: 8px; padding: 12px 4px 8px; border-radius: 14px; border: 1.5px solid var(--line); background: var(--surface); color: var(--ink-2); font: 600 .78rem var(--sans); }
.pf-frame-opt .avatar { width: 46px; height: 46px; font-size: 1rem; }
.pf-frame-opt .pf-frame { padding: 4px; box-shadow: none; }
.pf-frame-opt .pf-frame > .avatar { box-shadow: 0 0 0 2px var(--surface); }
.pf-frame-opt[aria-checked='true'] { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-ink); }
.pf-frame-opt.locked { opacity: .7; }
.pf-frame-opt.locked .pf-frame { filter: grayscale(.4); }
.pf-two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.pf-two .field { min-width: 0; }
.pf-count { display: block; text-align: right; font-size: .75rem; margin-top: 2px; }
.pf-radio { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border-radius: 14px; border: 1.5px solid var(--line); cursor: pointer; }
.pf-radio input { margin-top: 3px; accent-color: var(--accent); }
.pf-radio.on { border-color: var(--accent); background: var(--accent-soft); }
.pf-radio.off { opacity: .55; cursor: not-allowed; }
.pf-save { position: sticky; bottom: 0; padding: 12px 0 calc(12px + env(safe-area-inset-bottom)); margin-top: 18px; background: linear-gradient(transparent, var(--bg) 30%); z-index: 5; }
input.invalid { box-shadow: 0 0 0 2px var(--bad); }

/* --- Recortar foto --- */
.crop-sheet { max-width: 520px; }
.crop-stage { position: relative; width: 100%; border-radius: 14px; overflow: hidden; background: #0b1220; touch-action: none; cursor: grab; user-select: none; -webkit-user-select: none; }
.crop-stage:active { cursor: grabbing; }
.crop-stage:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.crop-canvas { display: block; }
.crop-mask { position: absolute; inset: 0; pointer-events: none; box-shadow: inset 0 0 0 2px rgb(255 255 255 / 80%); border-radius: 14px; }
.crop-stage.round .crop-mask { border-radius: 0; box-shadow: none; background: radial-gradient(circle closest-side, transparent calc(100% - 2px), rgb(255 255 255 / 85%) calc(100% - 2px), rgb(255 255 255 / 85%) 100%, rgb(0 0 0 / 55%) 100%); }
.crop-tools { align-items: center; gap: 8px; }
.crop-tools .icon-btn { font-size: 1.4rem; width: 40px; height: 40px; }
.crop-tools input[type='range'] { accent-color: var(--accent); min-width: 0; }
.pf-share-url { font: 600 .85rem var(--sans); padding: 10px 12px; border-radius: 12px; background: var(--surface-2); overflow-wrap: anywhere; user-select: all; }
