/* Profiles: the profile page (#/@/handle) and the editor (#/profile/edit) */

/* Photo avatars inside clickable avatar links (Forum posts, Who to follow) */
a.avatar.has-photo { padding: 0; overflow: hidden; background: var(--surface-2); }
a.avatar.has-photo img { width: 100%; height: 100%; object-fit: cover; border-radius: inherit; display: block; }
img.avatar.photo { display: inline-block; flex: none; }

/* ---------- shared card bits ---------- */
.pf-card { background: var(--surface); border-radius: 20px; box-shadow: var(--shadow); overflow: hidden; }
.pf-banner { aspect-ratio: 3 / 1; width: 100%; background: var(--surface-2); overflow: hidden; }
.pf-banner img { width: 100%; height: 100%; object-fit: cover; display: block; }
.pf-banner.empty { background: linear-gradient(120deg, var(--left) 0%, var(--center) 50%, var(--right) 100%); opacity: .85; }
.pf-banner.empty[data-b="left"] { background: linear-gradient(120deg, var(--left), color-mix(in srgb, var(--left) 45%, var(--center))); }
.pf-banner.empty[data-b="right"] { background: linear-gradient(120deg, color-mix(in srgb, var(--right) 45%, var(--center)), var(--right)); }
.pf-banner.empty[data-b="center"] { background: linear-gradient(120deg, color-mix(in srgb, var(--center) 55%, var(--left)), var(--center), color-mix(in srgb, var(--center) 55%, var(--right))); }
.pf-banner.mini { aspect-ratio: auto; height: 100%; }

.pf-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; padding: 0 18px; margin-top: -48px; }
.avatar.pf-av { width: 104px; height: 104px; font-size: 36px; border: 5px solid var(--surface); box-shadow: var(--shadow); flex: none; position: relative; z-index: 1; }
img.avatar.pf-av { background: var(--surface-2); }
.pf-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; padding-bottom: 6px; }
.pf-actions .btn { min-height: 44px; }
.pf-iconbtn { width: 44px; justify-content: center; padding: 0; font-size: 18px; }
.pf-soon { opacity: .55; cursor: default; }
.pf-soon small { font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; margin-left: 2px; }

.pf-id { padding: 10px 18px 0; min-width: 0; }
.pf-id h1, .pf-id h2 { font-size: clamp(24px, 6vw, 32px); font-weight: 800; overflow-wrap: anywhere; display: flex; align-items: center; flex-wrap: wrap; gap: 4px; margin: 0; }
.pf-handle-line, .pf-id p { margin: 4px 0 0; color: var(--ink-2); display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: 15px; }
.pf-verified { padding: 0 18px; margin: 8px 0 0; }
.pf-bio { padding: 0 18px; margin: 12px 0 0; font-size: 16px; line-height: 1.5; overflow-wrap: anywhere; white-space: pre-wrap; }
.pf-bio a { color: var(--center); font-weight: 600; }
.pf-meta { display: flex; flex-wrap: wrap; gap: 6px 16px; padding: 0 18px; margin-top: 10px; color: var(--ink-2); font-size: 14px; align-items: center; }
.pf-links { display: flex; flex-wrap: wrap; gap: 8px; padding: 0 18px; margin-top: 12px; }
.pf-link {
  display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 6px 12px; border-radius: 999px;
  background: var(--surface-2); color: var(--ink); font-weight: 600; font-size: 14px; text-decoration: none; max-width: 100%;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.pf-link:hover { background: color-mix(in srgb, var(--center) 14%, var(--surface-2)); }
.pf-link-ico { font-size: 13px; width: 18px; text-align: center; color: var(--ink-2); flex: none; }
.pf-issues { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 18px; margin-top: 10px; }
.pf-issue { font-size: 13px; font-weight: 700; color: var(--center); background: var(--center-soft); padding: 4px 10px; border-radius: 999px; text-decoration: none; }
.pf-stats { display: flex; flex-wrap: wrap; gap: 6px 20px; padding: 14px 18px 18px; font-size: 15px; color: var(--ink-2); }
.pf-stats b { color: var(--ink); font-family: var(--display); font-size: 17px; }
.pf-stats a { color: inherit; text-decoration: none; }
.pf-owner-row { display: flex; flex-wrap: wrap; gap: 4px 16px; padding: 12px 18px 16px; border-top: 1px solid var(--line); font-size: 14px; font-weight: 600; }
.pf-owner-row a { color: var(--ink-2); text-decoration: none; min-height: 32px; display: inline-flex; align-items: center; }
.pf-owner-row a:hover { color: var(--ink); }

/* ---------- profile page ---------- */
.pf-page { display: grid; gap: 14px; }
.pf-top .pf-head { margin-top: -52px; }
.pf-lean { display: grid; gap: 18px; padding: 16px 18px; }
@media (min-width: 640px) { .pf-lean { grid-template-columns: 1fr 1fr; } }
.pf-lean h3 { font: 800 17px/1.2 var(--display); margin: 0; }
.pf-lean p { margin: 4px 0 10px; }
.pf-bar { display: flex; height: 14px; border-radius: 999px; overflow: hidden; background: var(--surface-2); }
.pf-bar i { display: block; height: 100%; transition: width .5s; }
.pf-bar i[data-b="left"] { background: var(--left); } .pf-bar i[data-b="center"] { background: var(--center); } .pf-bar i[data-b="right"] { background: var(--right); }
.pf-bar-legend { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-top: 8px; font-size: 13px; font-weight: 600; color: var(--ink-2); }
.pf-bar-legend span[data-b="left"] b { color: var(--left); } .pf-bar-legend span[data-b="center"] b { color: var(--center); } .pf-bar-legend span[data-b="right"] b { color: var(--right); }
.pf-bar-legend b { font-family: var(--mono); }
.pf-bar-empty { margin: 0; padding: 10px 12px; background: var(--surface-2); border-radius: 10px; }
.pf-tabs { margin-top: 2px; }
.pf-tab-n { margin-left: 6px; font: 600 12px var(--mono); color: var(--ink-2); background: var(--surface-2); padding: 2px 7px; border-radius: 999px; }
.sq-main.pf-page { margin-left: auto; margin-right: auto; width: 100%; }
.sq-shell.single:has(.pf-page) { justify-content: center; }
.pf-tabs a { min-height: 48px; }
.pf-pinned-label { font-size: 13px; font-weight: 800; color: var(--ink-2); margin: 4px 0 -4px 4px; }

@media (max-width: 520px) {
  .pf-head { padding: 0 14px; margin-top: -40px; }
  .pf-top .pf-head { margin-top: -42px; }
  .avatar.pf-av { width: 84px; height: 84px; font-size: 30px; border-width: 4px; }
  .pf-id, .pf-bio, .pf-meta, .pf-links, .pf-issues, .pf-verified { padding-left: 14px; padding-right: 14px; }
  .pf-stats { padding: 12px 14px 16px; }
  .pf-owner-row { padding: 12px 14px 14px; }
  .pf-actions .btn { padding: 8px 12px; font-size: 14px; }
  .pf-soon small { display: none; }
}

/* ---------- editor ---------- */
.pf-wrap { max-width: 1080px; margin: 0 auto; }
.pf-edit-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; margin: 6px 0 16px; }
.pf-edit-head h1 { font-size: clamp(28px, 6vw, 40px); font-weight: 800; }
.pf-grid { display: grid; gap: 18px; align-items: start; }
@media (min-width: 900px) {
  .pf-grid { grid-template-columns: minmax(0, 1fr) 380px; }
  .pf-preview-col { order: 2; position: sticky; top: 120px; }
}
.pf-preview-box { background: transparent; }
.pf-preview-box > summary { cursor: pointer; font: 700 12px var(--mono); text-transform: uppercase; letter-spacing: .08em; color: var(--ink-2); padding: 10px 2px; min-height: 44px; display: flex; align-items: center; list-style: none; }
.pf-preview-box > summary::-webkit-details-marker { display: none; }
.pf-preview-box > summary::before { content: '▸'; margin-right: 8px; transition: transform .15s; }
.pf-preview-box[open] > summary::before { transform: rotate(90deg); }
.pf-preview { padding-bottom: 16px; }
.pf-preview .avatar.pf-av { width: 88px; height: 88px; font-size: 30px; }
.pf-preview .pf-head { margin-top: -44px; }

.pf-form { display: grid; gap: 14px; min-width: 0; }
.pf-sec { background: var(--surface); border-radius: 18px; box-shadow: var(--shadow); padding: 16px; display: grid; gap: 12px; }
.pf-sec h2 { font: 800 18px/1.2 var(--display); margin: 0; }
.pf-sec label { display: grid; gap: 6px; font-weight: 600; font-size: 14px; }
.pf-sec input:not([type=checkbox]):not([type=file]), .pf-sec textarea {
  width: 100%; min-height: 46px; border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; background: var(--bg); font-size: 16px; font-weight: 400;
}
.pf-sec textarea { resize: vertical; min-height: 92px; line-height: 1.45; }
.pf-sec small { font-weight: 500; }
.pf-handle { display: flex; align-items: center; border: 1px solid var(--line); border-radius: 12px; background: var(--bg); padding-left: 12px; }
.pf-handle > span { color: var(--ink-2); font-weight: 700; }
.pf-handle input { border: 0 !important; background: transparent !important; padding-left: 4px !important; }
.pf-handle:focus-within { outline: 3px solid var(--center); outline-offset: 2px; }

.pf-photos { display: grid; gap: 16px; }
.pf-photo { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 14px; align-items: center; }
.pf-photo-preview { flex: none; overflow: hidden; background: var(--surface-2); }
.pf-photo-preview.round { width: 72px; height: 72px; border-radius: 50%; }
.pf-photo-preview.wide { width: 144px; height: 48px; border-radius: 10px; }
.pf-photo-preview img { width: 100%; height: 100%; object-fit: cover; display: block; }
.avatar.pf-av-sm { width: 72px; height: 72px; font-size: 24px; }
.pf-photo-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; min-width: 0; }
.pf-photo-actions > b { width: 100%; }
.pf-photo-actions > .muted { width: 100%; margin-bottom: 4px; }
.pf-photo-actions .btn { min-height: 40px; cursor: pointer; }
.pf-progress { font-size: 13px; font-weight: 600; color: var(--ink-2); width: 100%; }
@media (max-width: 420px) { .pf-photo-preview.wide { width: 96px; height: 32px; } }

.pf-linkrow { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 3fr) 44px; gap: 8px; align-items: center; }
@media (max-width: 520px) { .pf-linkrow { grid-template-columns: minmax(0, 1fr) 44px; } .pf-linkrow [name=link-url] { grid-column: 1; } .pf-linkrow .pf-x { grid-row: 1 / span 2; grid-column: 2; } }
.pf-x { width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--line); background: var(--surface); font-size: 22px; cursor: pointer; color: var(--ink-2); }
.pf-x:hover { color: var(--right); border-color: var(--right); }
.pf-addlink { justify-self: start; }

.pf-toggle { display: flex !important; grid-template-columns: none; align-items: flex-start; gap: 12px !important; cursor: pointer; min-height: 44px; }
.pf-toggle input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.pf-toggle .sw { width: 46px; height: 28px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); position: relative; flex: none; margin-top: 2px; transition: background .2s; }
.pf-toggle .sw::after { content: ''; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: var(--ink-2); transition: transform .2s, background .2s; }
.pf-toggle input:checked + .sw { background: var(--center); border-color: var(--center); }
.pf-toggle input:checked + .sw::after { transform: translateX(18px); background: #fff; }
.pf-toggle input:focus-visible + .sw { outline: 3px solid var(--center); outline-offset: 2px; }
.pf-toggle > span:last-child { display: grid; gap: 2px; }
.pf-toggle small a { color: var(--center); }

.pf-pinrow { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 12px; border-radius: 12px; background: var(--bg); border: 1px solid var(--line); }
.pf-pinrow.on { border-color: var(--center); background: var(--center-soft); }
.pf-pintext { min-width: 0; font-size: 14px; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.pf-pinrow .btn { flex: none; min-height: 40px; }

.pf-save { position: sticky; bottom: calc(68px + env(safe-area-inset-bottom)); z-index: 3; background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); padding: 10px 0; display: grid; gap: 6px; }
@media (min-width: 1024px) { .pf-save { bottom: 0; } }
.pf-save .btn { width: 100%; justify-content: center; }
.pf-ok { margin: 0; font-weight: 700; color: var(--verified, #0f9d76); }
.pf-ok a { color: inherit; margin-left: 6px; }

/* Account page shortcut */
.account-profile-cta {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 14px; align-items: center; text-decoration: none; color: inherit;
  background: var(--surface); border-radius: 18px; box-shadow: var(--shadow); padding: 14px 16px; margin: 0 0 16px; border: 2px solid transparent;
}
.account-profile-cta:hover { border-color: var(--center); }
.account-profile-cta b { display: block; font: 800 18px/1.2 var(--display); }
.account-profile-cta small { display: block; margin-top: 2px; }
@media (max-width: 520px) { .account-profile-cta { grid-template-columns: auto minmax(0, 1fr); } .account-profile-cta .btn { grid-column: 1 / -1; justify-content: center; } }

@media (prefers-reduced-motion: reduce) { .pf-bar i, .pf-toggle .sw, .pf-toggle .sw::after { transition: none; } }
