/* =====================================================================
 * Public profile page (/@username).
 *
 * Brand-consistent with the auth + profile surfaces: it sits on the same
 * `.auth-stage` + `.auth-aura` backdrop (imported from auth/login.css) so
 * a visitor lands on the same iridescent, calm scene as the rest of the
 * member area. Every color flows from design tokens (DESIGN.md §2), so
 * dark mode is an automatic value-swap — there is intentionally NO
 * separate `prefers-color-scheme` codepath here.
 *
 * Layout: a centered narrow identity column (avatar · name · handle ·
 * headline · links · actions) above a borderless works grid. Hairlines
 * (rgba twin of --global-text-color) replace card frames, matching the
 * flat aesthetic of /profile.
 * ===================================================================== */

@import url('./auth/login.css');

/* The works grid can grow tall, so the stage needs to scroll and
   top-align rather than vertically center a single screen of content.
   `overflow: clip` keeps the aura clipped without creating a scroll
   container (same trick /profile uses). */
.auth-stage:has(#wrapper-public-profile) {
    align-items: flex-start;
    overflow: clip;
    padding-top: clamp(56px, 9vh, 104px);
}

#wrapper-public-profile {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 760px;
    margin: 0 auto;
    text-align: center;
    /* Mirror the auth-card entrance so the page resolves out of the aura
       rather than snapping in. */
    opacity: 0;
    transform: translateY(10px);
    animation: auth-fade-up 0.9s cubic-bezier(0.22, 0.61, 0.36, 1) 0.05s forwards;
}

/* ---------- Identity header ---------- */
.public-profile-head {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
}

.public-profile-avatar {
    width: 96px;
    height: 96px;
    border-radius: 50%;
    overflow: hidden;
    background: rgba(var(--global-text-color-rgb), 0.06);
    border: 1px solid var(--global-border-color);
    box-shadow:
        0 1px 0 rgba(255, 255, 255, 0.3) inset,
        0 14px 34px -12px rgba(var(--global-text-color-rgb), 0.28);
    flex-shrink: 0;
}

.public-profile-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.public-profile-name {
    margin: 4px 0 0;
    font-weight: 800;
    font-size: clamp(24px, 2.6vw, 30px);
    line-height: 1.2;
    letter-spacing: -0.02em;
    color: var(--global-text-color);
    word-break: keep-all;
    overflow-wrap: anywhere;
}

.public-profile-handle {
    margin: 0;
    font-size: 14px;
    font-weight: 500;
    color: var(--global-text-muted);
}

.public-profile-headline {
    margin: 6px 0 0;
    font-size: 15px;
    font-weight: 500;
    line-height: 1.55;
    color: var(--global-text-color);
    max-width: 480px;
    word-break: keep-all;
    overflow-wrap: anywhere;
}

.public-profile-bio {
    margin: 8px 0 0;
    font-size: 14.5px;
    line-height: 1.65;
    color: var(--global-text-muted);
    max-width: 440px;
    white-space: pre-wrap;
    word-break: keep-all;
    overflow-wrap: anywhere;
}

.public-profile-links {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 6px 14px;
    margin-top: 6px;
}

.public-profile-link {
    max-width: 240px;
    font-size: 13px;
    font-weight: 500;
    color: var(--global-text-color);
    text-decoration: none;
    border-bottom: 1px solid rgba(var(--global-text-color-rgb), 0.18);
    padding-bottom: 1px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    transition: border-color 140ms ease, color 140ms ease;
}

.public-profile-link:hover {
    border-bottom-color: var(--global-text-color);
}

.public-profile-link:focus-visible {
    outline: 2px solid var(--focus-outline-color);
    outline-offset: 3px;
    border-radius: 2px;
}

/* ---------- Action row (Share · Edit) ---------- */
.public-profile-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
    margin: 18px 0 4px;
}

/* Ghost pill — secondary action language (DESIGN.md §2.5 neutral states).
   Background is the card surface so it reads as a control over the aura;
   hover/active use neutral state tints, never brand color. */
.public-profile-share,
.public-profile-edit {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 9px 16px;
    font-size: 13px;
    font-weight: 600;
    line-height: 1;
    color: var(--global-text-color);
    background: var(--global-card-background);
    border: 1px solid var(--global-border-color);
    border-radius: 999px;
    text-decoration: none;
    cursor: pointer;
    transition: background 140ms ease, border-color 140ms ease, transform 140ms ease;
}

.public-profile-share:hover,
.public-profile-edit:hover {
    background: var(--state-hover-bg);
    border-color: rgba(var(--global-text-color-rgb), 0.28);
}

.public-profile-share:active,
.public-profile-edit:active {
    background: var(--state-active-bg);
    transform: translateY(1px);
}

.public-profile-share:focus-visible,
.public-profile-edit:focus-visible {
    outline: 2px solid var(--focus-outline-color);
    outline-offset: 2px;
}

.public-profile-share.is-copied {
    border-color: rgba(var(--global-text-color-rgb), 0.55);
}

.public-profile-share svg,
.public-profile-edit svg {
    flex: 0 0 auto;
}

/* Self-view banner — quietly tells the owner this is the public view. */
.public-profile-self-hint {
    display: inline-flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 6px 10px;
    margin: 22px auto 0;
    padding: 10px 16px;
    font-size: 13px;
    color: var(--global-text-muted);
    background: rgba(var(--global-text-color-rgb), 0.03);
    border: 1px solid var(--global-border-color);
    border-radius: 12px;
}

.public-profile-self-hint svg {
    flex: 0 0 auto;
    color: var(--global-text-muted);
}

/* =====================================================================
 * Works grid — featured public projects.
 * Card language matches the studio grid: card-surface tile, hairline
 * frame, subtle neutral lift on hover (no brand color on interaction).
 * ===================================================================== */
.public-profile-works {
    margin-top: 48px;
    text-align: left;
}

.public-profile-works-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 18px;
    padding-bottom: 12px;
    border-bottom: 1px solid rgba(var(--global-text-color-rgb), 0.08);
}

.public-profile-works-title {
    margin: 0;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    color: var(--global-text-muted);
}

.public-profile-works-count {
    font-weight: 500;
    color: rgba(var(--global-text-color-rgb), 0.4);
}

.public-profile-reorder-toggle {
    flex-shrink: 0;
    padding: 6px 13px;
    font-size: 12px;
    font-weight: 600;
    color: var(--global-text-color);
    background: var(--global-card-background);
    border: 1px solid var(--global-border-color);
    border-radius: 999px;
    cursor: pointer;
    transition: background 140ms ease, border-color 140ms ease;
}

.public-profile-reorder-toggle:hover {
    background: var(--state-hover-bg);
    border-color: rgba(var(--global-text-color-rgb), 0.28);
}

.public-profile-reorder-toggle[aria-pressed="true"] {
    background: var(--state-active-bg);
    border-color: rgba(var(--global-text-color-rgb), 0.55);
}

.public-profile-reorder-toggle:focus-visible {
    outline: 2px solid var(--focus-outline-color);
    outline-offset: 2px;
}

/* Reordering relies on HTML5 drag-and-drop, which does not fire on
   touch-primary devices — so the toggle would offer a mode where nothing
   can actually be dragged. Hide it there to avoid a dead affordance;
   ordering can still be curated from a pointer device. */
@media (pointer: coarse) {
    .public-profile-reorder-toggle {
        display: none;
    }
}

.public-profile-grid {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(232px, 1fr));
    gap: 18px;
}

/* Reorder mode — cards become draggable, the play link is inert. */
.public-profile-grid.is-reordering .pp-card {
    cursor: grab;
}
.public-profile-grid.is-reordering .pp-card-link {
    pointer-events: none;
}
.public-profile-grid.is-reordering .pp-card-link:hover {
    transform: none;
    box-shadow: none;
    border-color: var(--global-border-color);
}
.public-profile-grid .pp-card.is-dragging {
    opacity: 0.5;
    cursor: grabbing;
}

.pp-card {
    margin: 0;
}

.pp-card-link {
    display: flex;
    flex-direction: column;
    height: 100%;
    border: 1px solid var(--global-border-color);
    border-radius: 14px;
    overflow: hidden;
    background: var(--global-card-background);
    text-decoration: none;
    color: inherit;
    transition: border-color 160ms ease, transform 160ms ease, box-shadow 160ms ease;
}

.pp-card-link:hover {
    border-color: rgba(var(--global-text-color-rgb), 0.22);
    transform: translateY(-2px);
    box-shadow: 0 10px 28px -10px rgba(var(--global-text-color-rgb), 0.3);
}

.pp-card-link:focus-visible {
    outline: 2px solid var(--focus-outline-color);
    outline-offset: 2px;
}

.pp-card-thumb {
    display: block;
    aspect-ratio: 16 / 10;
    background: rgba(var(--global-text-color-rgb), 0.04);
    overflow: hidden;
}

.pp-card-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.pp-card-body {
    display: block;
    padding: 12px 14px 14px;
    border-top: 1px solid rgba(var(--global-text-color-rgb), 0.07);
}

.pp-card-title {
    display: block;
    font-size: 14px;
    font-weight: 600;
    letter-spacing: -0.005em;
    color: var(--global-text-color);
    line-height: 1.3;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.pp-card-desc {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin-top: 4px;
    font-size: 12.5px;
    line-height: 1.5;
    color: var(--global-text-muted);
    word-break: keep-all;
    overflow-wrap: anywhere;
}

/* ---------- Empty state (owner only) ---------- */
.public-profile-empty {
    margin: 40px auto 0;
    padding: 40px 24px;
    max-width: 460px;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    border: 1px dashed rgba(var(--global-text-color-rgb), 0.16);
    border-radius: 16px;
    color: var(--global-text-muted);
}

.public-profile-empty-icon {
    color: rgba(var(--global-text-color-rgb), 0.34);
    margin-bottom: 14px;
}

.public-profile-empty-title {
    margin: 0 0 6px;
    font-size: 15px;
    font-weight: 600;
    color: var(--global-text-color);
    letter-spacing: -0.01em;
}

.public-profile-empty-text {
    margin: 0 0 20px;
    font-size: 13px;
    line-height: 1.6;
    color: var(--global-text-muted);
    word-break: keep-all;
    overflow-wrap: anywhere;
}

/* Primary CTA — filled charcoal button (DESIGN.md §3.2: buttons are 600). */
.public-profile-empty-cta {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 20px;
    font-size: 13px;
    font-weight: 600;
    color: var(--global-button-text-color);
    background: var(--global-button-background-color);
    text-decoration: none;
    border: 1px solid var(--global-button-background-color);
    border-radius: 999px;
    transition: transform 140ms ease, opacity 140ms ease;
}

.public-profile-empty-cta:hover {
    transform: translateY(-1px);
    opacity: 0.92;
}

.public-profile-empty-cta:focus-visible {
    outline: 2px solid var(--focus-outline-color);
    outline-offset: 2px;
}

/* ---------- Footer brand line ---------- */
.public-profile-foot {
    margin-top: 48px;
    padding-top: 20px;
    border-top: 1px solid rgba(var(--global-text-color-rgb), 0.07);
    text-align: center;
}

.public-profile-foot-mark {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    font-weight: 500;
    color: var(--global-text-muted);
    text-decoration: none;
    transition: color 140ms ease;
}

.public-profile-foot-mark:hover {
    color: var(--global-text-color);
}

.public-profile-foot-mark .wordmark {
    font-family: 'Paperlogy', 'Pretendard Variable', sans-serif;
    font-weight: 900;
    letter-spacing: -0.045em;
    text-transform: uppercase;
    font-size: 13px;
    color: var(--global-text-color);
}

/* ---------- Narrow viewports ---------- */
@media (max-width: 520px) {
    .public-profile-avatar {
        width: 84px;
        height: 84px;
    }
    .public-profile-grid {
        grid-template-columns: 1fr;
    }
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
    #wrapper-public-profile {
        animation: none !important;
        opacity: 1 !important;
        transform: none !important;
    }
    .public-profile-share,
    .public-profile-edit,
    .public-profile-link,
    .public-profile-reorder-toggle,
    .pp-card-link,
    .public-profile-empty-cta,
    .public-profile-foot-mark {
        transition: none !important;
    }
}
