/* ============================================================
   Profile (#home-tab-profile, js/profile.js): your brands and platforms,
   their products, your avatars and places. Opened from your name in the rail.
   ============================================================ */

/* The page frame every library page uses (.ws-page, .sl-page): 30px top,
   40px sides, 48px bottom, starting at the rail, not a centred column. */
.pf-page {
    width: 100%;
    max-width: 1560px;
    margin: 0 auto;
    padding: 30px 40px 48px;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.pf-head { display: flex; align-items: center; gap: 16px; }

.pf-me {
    width: 56px;
    height: 56px;
    flex: none;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: var(--sl-accent-tint);
    color: var(--sl-accent-text);
    font-size: 20px;
    font-weight: 700;
}

.pf-head-text { flex: 1; min-width: 0; }
.pf-name { margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pf-email { margin-top: 2px; font-size: 12.5px; color: var(--sl-text-3); }
.pf-setup-link { flex: none; }

/* Page sections are one row of .sl-tabs under the header. */
.pf-tabs { align-self: stretch; }
.pf-tabs .sl-tab { display: inline-flex; align-items: center; gap: 6px; }


/* A section: its one action top right ("New avatar"), then cards — a picture,
   a name and one data line. Products stay on their brand's page. */
.pf-section { display: flex; flex-direction: column; gap: 16px; }
.pf-actions { display: flex; align-items: center; justify-content: flex-end; gap: 8px; }
.pf-new { gap: 6px; }
.pf-empty { margin: 0; font-size: 13px; color: var(--sl-text-3); }

.pf-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 16px;
    align-items: start;
}

.pf-card {
    display: flex;
    flex-direction: column;
    min-width: 0;
    padding: 0;
    overflow: hidden;
    color: inherit;
    font: inherit;
    text-align: left;
    cursor: pointer;
    outline: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.pf-card:hover { box-shadow: var(--sl-shadow-card); }
.pf-card:focus-visible { border-color: var(--sl-focus); box-shadow: 0 0 0 1px var(--sl-focus); }

.pf-card-photo {
    aspect-ratio: 4 / 3;
    display: grid;
    place-items: center;
    overflow: hidden;
    background: var(--sl-quiet);
    color: var(--sl-text-3);
}

.pf-card-photo img { display: block; width: 100%; height: 100%; object-fit: cover; }
.pf-card[data-pf-id] .pf-card-photo img { object-position: center 25%; }

.pf-card-body { display: flex; flex-direction: column; gap: 3px; min-width: 0; padding: 10px 12px 12px; }

.pf-card-name {
    font-size: 13.5px;
    font-weight: 600;
    color: var(--sl-text-1);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.pf-card-meta { display: flex; align-items: center; gap: 5px; font-family: var(--sl-font-mono); font-size: 11px; color: var(--sl-data); }

.pf-card-initials { font-size: 26px; font-weight: 700; color: var(--sl-text-2); letter-spacing: 0.02em; }
.pf-card-brands { color: var(--sl-text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pf-md-btn { flex: none; gap: 6px; }
.pf-links-btn { flex: none; gap: 6px; }

/* This account uses another account's Profile (js/profile.js ownerBanner). */
.pf-owner {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border: 1px solid var(--sl-accent-line);
    border-radius: var(--sl-r-10);
    background: var(--sl-accent-tint);
    color: var(--sl-text-1);
    font-size: 13px;
}
.pf-owner-text { flex: 1; min-width: 0; }
.pf-owner-stop { flex: none; }

/* Profile → Other accounts: who uses this Profile, and asking for another's. */
.pf-links { display: flex; flex-direction: column; gap: 10px; }
.pf-links-label { margin-top: 6px; font-size: 12px; font-weight: 600; color: var(--sl-text-2); }
.pf-links-empty { margin: 0; font-size: 13px; color: var(--sl-text-3); }
.pf-links-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border: 1px solid var(--sl-border);
    border-radius: var(--sl-r-8);
}
.pf-links-row.is-pending { border-color: var(--sl-accent-line); }
.pf-links-who { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; color: var(--sl-text-1); }
.pf-links-state { flex: none; font-size: 12px; color: var(--sl-text-3); }
.pf-links-row.is-declined .pf-links-state { color: var(--sl-danger-text); }
.pf-links-ask { display: flex; gap: 8px; }
.pf-links-ask .pf-field-input { flex: 1; min-width: 0; }
.pf-field-error { margin: 0; font-size: 12px; color: var(--sl-danger-text); }

/* One brand / platform: name, context and guidelines, avatars, products. */
.pf-brand { display: flex; flex-direction: column; gap: 18px; }
.pf-back { align-self: flex-start; gap: 4px; margin-left: -6px; }
.pf-brand-top { display: flex; align-items: center; gap: 12px; }
.pf-brand-name {
    flex: 1;
    min-width: 0;
    height: 44px;
    font-size: 20px;
    font-weight: 700;
    background: transparent;
    border-color: transparent;
}
.pf-brand-name:hover { border-color: var(--sl-border); }
.pf-brand-name:focus { background: var(--sl-panel); }
.pf-sub-head { display: flex; align-items: center; gap: 8px; margin-top: 6px; }
.pf-sub-title { margin: 0; font-size: 15px; }
.pf-brand-foot { display: flex; justify-content: flex-start; padding-top: 8px; border-top: 1px solid var(--sl-hairline); }

/* Avatar chips on a brand; brand toggles on an avatar. */
.pf-chips { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }

.pf-chip {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    height: 32px;
    padding: 0 6px 0 4px;
    border-radius: 16px;
    background: var(--sl-quiet);
    font-size: 12.5px;
    font-weight: 600;
    color: var(--sl-text-1);
}

.pf-chip img,
.pf-chip-initials {
    width: 24px;
    height: 24px;
    flex: none;
    border-radius: 50%;
    object-fit: cover;
}

.pf-chip-initials { display: grid; place-items: center; background: var(--sl-accent-tint); color: var(--sl-accent-text); font-size: 10px; }

.pf-chip-x {
    width: 20px;
    height: 20px;
    padding: 0;
    display: grid;
    place-items: center;
    border: none;
    border-radius: 50%;
    background: none;
    color: var(--sl-text-3);
    cursor: pointer;
}

.pf-chip-x:hover { background: var(--sl-danger-wash); color: var(--sl-danger-text); }

.pf-toggle {
    height: 30px;
    padding: 0 12px;
    border-radius: 15px;
    border: 1px solid var(--sl-border);
    background: none;
    color: var(--sl-text-2);
    font: inherit;
    font-size: 12.5px;
    font-weight: 600;
    cursor: pointer;
}

.pf-toggle:hover { border-color: var(--sl-border-strong); color: var(--sl-text-1); }
.pf-toggle.is-on { background: var(--sl-accent-tint); border-color: var(--sl-accent-line); color: var(--sl-accent-text); }

/* The agent file (Markdown) viewer. */
.pf-dialog.pf-dialog-wide { width: min(760px, calc(100vw - 32px)); }
.pf-md-where { margin: 0; word-break: break-all; }

.pf-md {
    margin: 0;
    max-height: 60vh;
    overflow: auto;
    padding: 12px 14px;
    border-radius: var(--sl-r-8);
    background: var(--sl-panel);
    border: 1px solid var(--sl-hairline);
    font-family: var(--sl-font-mono);
    font-size: 11.5px;
    line-height: 1.55;
    color: var(--sl-text-1);
    white-space: pre-wrap;
    word-break: break-word;
}

/* The avatar / product editor: above #home-screen (9999) and the home mark (10150),
   below the app's confirm (10300), which Delete asks through. */
.pf-scrim { z-index: 10200; }

.pf-dialog {
    width: min(540px, calc(100vw - 32px));
    max-height: calc(100vh - 48px);
    display: flex;
    flex-direction: column;
}

.pf-dialog-body { display: flex; flex-direction: column; gap: 16px; overflow-y: auto; }
.pf-dialog-note { font-size: 12px; line-height: 1.4; color: var(--sl-warning); }
.pf-dialog-note:empty { display: none; }
.pf-flex { flex: 1; }

.pf-field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.pf-field-label { font-size: 12px; font-weight: 600; color: var(--sl-text-2); }
.pf-field-head { position: relative; display: inline-flex; align-items: center; gap: 4px; align-self: flex-start; }
/* (i): help on demand, never a line under a field. */
.pf-info {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    color: var(--sl-text-3);
    cursor: help;
    outline: none;
}
.pf-info:is(:hover, :focus-within) { color: var(--sl-text-1); }
.pf-info:focus-visible { box-shadow: 0 0 0 2px var(--sl-focus); }
.pf-info-pop {
    display: none;
    position: absolute;
    left: 0;
    top: calc(100% + 6px);
    z-index: 30;
    width: max-content;
    max-width: min(320px, calc(100vw - 48px));
    padding: 10px 12px;
    background: var(--sl-raised);
    border: 1px solid var(--sl-border-strong);
    border-radius: var(--sl-r-10);
    box-shadow: var(--sl-shadow-pop);
    font-size: 12px;
    font-weight: 400;
    line-height: 1.55;
    color: var(--sl-text-2);
    white-space: normal;
}
.pf-info:is(:hover, :focus-within) > .pf-info-pop { display: block; }
.pf-field-input { width: 100%; }

.pf-photos { display: flex; flex-wrap: wrap; gap: 12px; }

.pf-photo {
    position: relative;
    width: 76px;
    height: 76px;
    flex: none;
    border-radius: var(--sl-r-8);
    background: var(--sl-quiet);
    box-shadow: inset 0 0 0 1px oklch(1 0 0 / 0.1);
}

.pf-photo img { display: block; width: 100%; height: 100%; object-fit: cover; border-radius: inherit; }
.pf-photo.is-loading { display: grid; place-items: center; }

.pf-photo-x {
    position: absolute;
    top: -7px;
    right: -7px;
    width: 18px;
    height: 18px;
    padding: 0;
    display: grid;
    place-items: center;
    border-radius: 50%;
    border: 1px solid var(--sl-border-strong);
    background: var(--sl-segment-on);
    color: var(--sl-text-1);
    cursor: pointer;
}

.pf-photo-x:hover { background: var(--sl-danger-wash); color: var(--sl-danger-text); }

.pf-photo-add {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    border: 1px dashed var(--sl-border-strong);
    background: none;
    box-shadow: none;
    color: var(--sl-text-2);
    font: inherit;
    font-size: 11px;
    cursor: pointer;
}

.pf-photo-add:hover { border-color: var(--sl-accent-line); color: var(--sl-text-1); }

.pf-spinner {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 2px solid var(--sl-border-strong);
    border-top-color: var(--sl-link);
    animation: pf-spin 0.8s linear infinite;
}

@keyframes pf-spin { to { transform: rotate(360deg); } }

.pf-voice { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; }

@container home-main (max-width: 599px) {
    .pf-page { padding: 24px 16px 32px; }
    .pf-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
    .pf-actions .pf-new { flex: 1; justify-content: center; }
    .pf-head { flex-wrap: wrap; }
    .pf-owner { flex-wrap: wrap; }
    .pf-links-row { flex-wrap: wrap; }
}

body.pw-mobile .pf-page { padding: 18px 14px 32px; }
/* Phone: the section tabs scroll sideways on one row, never wrap to a second. */
@container home-main (max-width: 599px) {
    .pf-tabs { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
    .pf-tabs .sl-tab { flex: none; margin-bottom: 0; }
}
body.pw-mobile .pf-tabs { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
body.pw-mobile .pf-tabs .sl-tab { flex: none; margin-bottom: 0; }
.pf-tabs::-webkit-scrollbar { display: none; }
.pw-desktop:not(.pw-desktop-mac) .pf-page { padding-top: 54px; }

/* ── Personalization (js/profile-me.js): your picture left, your details right ── */
.pf-me-form {
    display: grid;
    grid-template-columns: max-content minmax(0, 560px);
    justify-content: start;
    gap: 40px;
    align-items: start;
}
.pf-me-pic-col { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.pf-me-pic {
    position: relative;
    width: 128px;
    height: 128px;
    padding: 0;
    flex: none;
    display: grid;
    place-items: center;
    border: none;
    border-radius: 50%;
    background: var(--sl-accent-tint);
    color: var(--sl-accent-text);
    font: inherit;
    font-size: 40px;
    font-weight: 700;
    cursor: pointer;
    outline: none;
}
.pf-me-pic:focus-visible { box-shadow: 0 0 0 3px var(--sl-focus); }
.pf-me-pic.is-drop { box-shadow: 0 0 0 3px var(--sl-accent); }
.pf-me-pic:disabled { cursor: progress; opacity: 0.7; }
.pf-me-pic.has-photo { background: var(--sl-quiet); }
.pf-me-pic.has-photo > img { width: 100%; height: 100%; display: block; object-fit: cover; border-radius: 50%; }
.pf-me-pic.is-empty { cursor: default; color: var(--sl-text-3); background: var(--sl-quiet); }
.pf-me-pic-badge {
    position: absolute;
    right: 4px;
    bottom: 4px;
    width: 28px;
    height: 28px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: var(--sl-raised);
    border: 1px solid var(--sl-border-strong);
    color: var(--sl-text-1);
}
.pf-me-pic-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.pf-me-pic-actions button { gap: 6px; }
.pf-me-fields { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.pf-me-fields textarea { resize: vertical; min-height: 96px; }
.pf-me-foot { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.pf-me-foot > [hidden] { display: none; }
.pf-me-status { font-size: 12.5px; color: var(--sl-text-3); }
.pf-me-out { display: flex; flex-direction: column; align-items: flex-start; gap: 16px; }

@container home-main (max-width: 599px) {
    .pf-me-form { grid-template-columns: minmax(0, 1fr); gap: 20px; }
}
body.pw-mobile .pf-me-form { grid-template-columns: minmax(0, 1fr); gap: 20px; }

/* ── Other people (js/people.js): a name or picture that opens a profile, and the profile dialog ── */
.pw-person-link { cursor: pointer; outline: none; }
.pw-person-link:not(.ws-avatar):not(.tpl-avatar):not(.pw-share-av):hover { text-decoration: underline; text-underline-offset: 2px; }
.pw-person-link:focus-visible { box-shadow: 0 0 0 2px var(--sl-focus); border-radius: var(--sl-r-6); }
:is(.ws-avatar, .tpl-avatar, .pw-share-av).pw-person-link:focus-visible { border-radius: 50%; }

/* Above the home screen and the Profile's own dialogs (.pf-scrim 10200), below Report a bug (10600). */
.pw-person-scrim { z-index: 10300; }
.pw-person-dialog { position: relative; width: min(440px, calc(100vw - 32px)); }
.pw-person-x { position: absolute; top: 10px; right: 10px; }
.pw-person-body { display: flex; flex-direction: column; align-items: center; gap: 8px; padding-top: 28px; text-align: center; }
.pw-person-av {
    width: 96px;
    height: 96px;
    margin-bottom: 6px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: var(--sl-accent-tint);
    color: var(--sl-accent-text);
    font-size: 32px;
    font-weight: 700;
}
.pw-person-name { margin: 0; font-size: 20px; font-weight: 700; color: var(--sl-text-1); overflow-wrap: anywhere; }
.pw-person-headline { margin: 0; font-size: 13.5px; color: var(--sl-text-2); overflow-wrap: anywhere; }
.pw-person-meta { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 16px; font-size: 12.5px; color: var(--sl-text-3); }
.pw-person-meta > * { display: inline-flex; align-items: center; gap: 5px; min-width: 0; }
.pw-person-web { color: var(--sl-link, var(--sl-accent-text)); text-decoration: none; overflow-wrap: anywhere; }
.pw-person-web:hover { text-decoration: underline; }
.pw-person-bio { margin: 8px 0 0; align-self: stretch; text-align: left; font-size: 13px; line-height: 1.55; color: var(--sl-text-1); white-space: pre-wrap; overflow-wrap: anywhere; }
.pw-person-note { margin: 4px 0 0; font-size: 13px; color: var(--sl-text-3); }
.pw-person-grow { flex: 1; }
