/* =============================================================================
   LAMHA — PROFILE
   Identity-first profile layout with dedicated entry points to personal libraries
   ============================================================================= */

.profile-section--owner {
    position: relative;
    isolation: isolate;
    min-height: 100vh;
    padding: 118px 0 88px;
    overflow: clip;
    background: var(--bg-primary);
    color: var(--text-primary);
}

.profile-section--owner::before,
.profile-section--owner::after {
    content: '';
    position: absolute;
    z-index: -1;
    width: min(48vw, 680px);
    aspect-ratio: 1;
    border-radius: var(--radius-full);
    pointer-events: none;
    filter: blur(28px);
}

.profile-section--owner::before {
    top: -240px;
    right: -210px;
    background: radial-gradient(circle, rgba(101, 123, 137, .15), transparent 68%);
}

.profile-section--owner::after {
    top: 480px;
    left: -320px;
    background: radial-gradient(circle, rgba(130, 150, 161, .08), transparent 70%);
}

.profile-owner-wrap {
    width: min(calc(100% - 48px), 1320px);
    margin-inline: auto;
}

.profile-owner-hero {
    position: relative;
    padding: clamp(24px, 3.2vw, 44px);
    border: 1px solid var(--border-subtle);
    border-radius: clamp(24px, 3vw, 34px);
    background: color-mix(in srgb, var(--bg-surface) 72%, transparent);
    box-shadow: var(--shadow-lg);
    -webkit-backdrop-filter: blur(20px) saturate(120%);
    backdrop-filter: blur(20px) saturate(120%);
    animation: profile-enter .5s var(--ease-out) both;
}

.profile-owner-hero::before {
    content: '';
    position: absolute;
    top: 0;
    right: clamp(28px, 4vw, 54px);
    width: 68px;
    height: 1px;
    background: var(--gradient-brand);
    opacity: .55;
}

.profile-owner-hero__top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: clamp(24px, 4vw, 56px);
}

.profile-owner-identity {
    display: flex;
    align-items: flex-start;
    gap: clamp(18px, 2.5vw, 30px);
    min-width: 0;
}

.profile-owner-avatar {
    position: relative;
    width: clamp(86px, 9vw, 116px);
    height: clamp(86px, 9vw, 116px);
    flex: 0 0 auto;
    display: grid;
    place-items: center;
    border: 1px solid var(--border-default);
    border-radius: 30%;
    background: linear-gradient(145deg, var(--bg-elevated), var(--bg-secondary));
    color: var(--text-primary);
    font-size: clamp(28px, 3vw, 40px);
    font-weight: var(--font-semibold);
    box-shadow: var(--shadow-md);
}

.profile-owner-avatar > img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: inherit;
}

.profile-owner-avatar__edit {
    position: absolute;
    inset-inline-end: -5px;
    bottom: -5px;
    width: 34px;
    height: 34px;
    display: grid;
    place-items: center;
    border: 1px solid var(--border-default);
    border-radius: var(--radius-full);
    background: var(--bg-elevated);
    color: var(--text-secondary);
    box-shadow: var(--shadow-md);
    transition: var(--transition-fast);
}

.profile-owner-avatar__edit:hover {
    border-color: var(--border-focus);
    color: var(--text-primary);
    transform: translateY(-1px);
}

.profile-owner-avatar__edit :is(svg, i) {
    width: 15px;
    height: 15px;
}

.profile-owner-copy {
    min-width: 0;
    padding-top: 4px;
}

.profile-owner-name-row {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    min-width: 0;
}

.profile-owner-name {
    margin: 0;
    color: var(--text-primary);
    font-size: clamp(30px, 4vw, 46px);
    font-weight: var(--font-semibold);
    line-height: 1.08;
    letter-spacing: -.04em;
}

.profile-owner-pro-icon {
    position: relative;
    width: 28px;
    height: 28px;
    flex: 0 0 28px;
    display: grid;
    place-items: center;
    border: 1px solid color-mix(in srgb, var(--accent-secondary) 42%, transparent);
    border-radius: var(--radius-full);
    background: var(--accent-secondary-muted);
    color: var(--accent-secondary);
    cursor: help;
}

.profile-owner-pro-icon :is(svg, i) {
    width: 14px;
    height: 14px;
}

.profile-owner-pro-icon::after {
    content: attr(data-tooltip);
    position: absolute;
    z-index: 12;
    bottom: calc(100% + 9px);
    right: 50%;
    width: max-content;
    max-width: 190px;
    padding: 7px 10px;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    background: var(--bg-navbar);
    color: var(--text-secondary);
    font-size: 11px;
    box-shadow: var(--shadow-lg);
    opacity: 0;
    visibility: hidden;
    transform: translate(50%, 4px);
    transition: var(--transition-fast);
    pointer-events: none;
}

.profile-owner-pro-icon:is(:hover, :focus-visible)::after {
    opacity: 1;
    visibility: visible;
    transform: translate(50%, 0);
}

.profile-owner-handle {
    margin: var(--space-1) 0 0;
    color: var(--text-muted);
    direction: ltr;
    text-align: right;
    font-size: var(--text-sm);
}

.profile-owner-bio {
    max-width: 650px;
    margin: var(--space-4) 0 0;
    color: var(--text-secondary);
    font-size: var(--text-base);
    line-height: var(--line-height-relaxed);
}

.profile-owner-bio--empty { color: var(--text-muted); }

.profile-owner-meta {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
    margin-top: var(--space-4);
}

.profile-owner-meta__item {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    min-height: 32px;
    padding-inline: 11px;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-full);
    background: var(--profile-soft-surface, rgba(255, 255, 255, .018));
    color: var(--text-muted);
    font-size: var(--text-xs);
}

.profile-owner-meta__item :is(svg, i) {
    width: 13px;
    height: 13px;
}

.profile-owner-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: var(--space-2);
    flex-wrap: wrap;
    flex: 0 0 auto;
}

.profile-owner-action,
.profile-owner-privacy > summary {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    padding: 0 var(--space-4);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-full);
    background: var(--profile-control-surface, rgba(15, 19, 22, .68));
    color: var(--text-secondary);
    font-family: inherit;
    font-size: var(--text-sm);
    font-weight: var(--font-medium);
    text-decoration: none;
    cursor: pointer;
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
    transition: var(--transition-fast);
}

.profile-owner-action:is(:hover, :focus-visible),
.profile-owner-privacy > summary:is(:hover, :focus-visible) {
    border-color: var(--border-focus);
    background: var(--bg-secondary);
    color: var(--text-primary);
    transform: translateY(-1px);
}

.profile-owner-action :is(svg, i),
.profile-owner-privacy > summary :is(svg, i) {
    width: 16px;
    height: 16px;
}

.profile-owner-action--primary {
    border-color: transparent;
    background: var(--gradient-brand);
    color: var(--text-inverse);
    box-shadow: var(--shadow-accent);
}

.profile-owner-action--primary:is(:hover, :focus-visible) {
    border-color: transparent;
    background: var(--gradient-brand);
    color: var(--text-inverse);
    filter: brightness(1.035);
}

.profile-owner-privacy { position: relative; }
.profile-owner-privacy > summary { list-style: none; user-select: none; }
.profile-owner-privacy > summary::-webkit-details-marker { display: none; }
.profile-owner-privacy[open] > summary {
    border-color: var(--border-focus);
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.profile-owner-privacy__menu {
    position: absolute;
    z-index: 40;
    top: calc(100% + 10px);
    inset-inline-end: 0;
    width: min(310px, calc(100vw - 32px));
    padding: var(--space-2);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-xl);
    background: var(--bg-navbar);
    box-shadow: var(--shadow-xl);
    -webkit-backdrop-filter: blur(22px) saturate(120%);
    backdrop-filter: blur(22px) saturate(120%);
    animation: profile-popover .18s var(--ease-out) both;
}

.profile-owner-privacy__title {
    padding: var(--space-2) var(--space-3) var(--space-1);
    color: var(--text-primary);
    font-size: var(--text-sm);
    font-weight: var(--font-semibold);
}

.profile-owner-privacy__hint {
    margin: 0;
    padding: 0 var(--space-3) var(--space-2);
    color: var(--text-muted);
    font-size: 11px;
    line-height: 1.6;
}

.profile-owner-privacy__option {
    width: 100%;
    min-height: 58px;
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-2) var(--space-3);
    border: 0;
    border-radius: var(--radius-lg);
    background: transparent;
    color: var(--text-secondary);
    text-align: right;
    cursor: pointer;
    transition: var(--transition-fast);
}

.profile-owner-privacy__option:hover {
    background: var(--bg-elevated);
    color: var(--text-primary);
}

.profile-owner-privacy__option.is-current {
    background: var(--accent-secondary-muted);
    color: var(--text-primary);
}

.profile-owner-privacy__option > :is(svg, i) {
    width: 18px;
    height: 18px;
    flex: 0 0 18px;
}

.profile-owner-privacy__option-copy { min-width: 0; flex: 1; }
.profile-owner-privacy__option-copy strong,
.profile-owner-privacy__option-copy small { display: block; }
.profile-owner-privacy__option-copy strong { font-size: 13px; font-weight: var(--font-medium); }
.profile-owner-privacy__option-copy small { margin-top: 2px; color: var(--text-muted); font-size: 10px; }
.profile-owner-privacy__check { width: 15px !important; height: 15px !important; color: var(--accent-secondary); }

.profile-section--owner .profile-stats {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: var(--space-2);
    margin-top: clamp(24px, 3vw, 38px);
    padding-top: clamp(20px, 2.4vw, 30px);
    border-top: 1px solid var(--border-subtle);
}

.profile-section--owner .stat-item {
    min-width: 0;
    padding: var(--space-3) var(--space-4);
    border-radius: var(--radius-lg);
    background: var(--profile-soft-surface, rgba(255, 255, 255, .018));
}

.profile-section--owner .stat-number,
.profile-section--owner .stat-label { display: block; }
.profile-section--owner .stat-number { color: var(--text-primary); font-size: clamp(20px, 2vw, 26px); font-weight: var(--font-semibold); line-height: 1.1; }
.profile-section--owner .stat-label { margin-top: 5px; color: var(--text-muted); font-size: var(--text-xs); }

.profile-library-links {
    padding-top: clamp(42px, 6vw, 78px);
    animation: profile-enter .55s .08s var(--ease-out) both;
}

.profile-library-links__head {
    max-width: 690px;
    margin-bottom: 24px;
}

.profile-library-links__head > span,
.profile-library-card__eyebrow {
    color: var(--text-muted);
    font-size: var(--text-xs);
    font-weight: var(--font-medium);
}

.profile-library-links__head h2 {
    margin: 8px 0 0;
    color: var(--text-primary);
    font-size: clamp(28px, 4vw, 46px);
    font-weight: var(--font-medium);
    letter-spacing: -.035em;
}

.profile-library-links__head p {
    margin: 12px 0 0;
    color: var(--text-secondary);
    line-height: 1.8;
}

.profile-library-links__grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}

.profile-library-links__grid.is-single { grid-template-columns: minmax(0, 1fr); }

.profile-library-card {
    position: relative;
    min-height: 230px;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: start;
    gap: 18px;
    padding: clamp(22px, 3vw, 32px);
    overflow: hidden;
    border: 1px solid var(--border-subtle);
    border-radius: clamp(22px, 2.4vw, 30px);
    background: var(--bg-surface);
    color: var(--text-primary);
    text-decoration: none;
    box-shadow: var(--shadow-sm);
    transition: transform var(--duration-normal) var(--ease-out), border-color var(--duration-fast) var(--ease-default), box-shadow var(--duration-normal) var(--ease-out);
}

.profile-library-card::before {
    content: '';
    position: absolute;
    width: 220px;
    height: 220px;
    inset-inline-end: -90px;
    bottom: -120px;
    border-radius: var(--radius-full);
    background: radial-gradient(circle, color-mix(in srgb, var(--accent-primary) 15%, transparent), transparent 68%);
    pointer-events: none;
}

.profile-library-card:is(:hover, :focus-visible) {
    transform: translateY(-3px);
    border-color: var(--border-focus);
    box-shadow: var(--shadow-lg);
}

.profile-library-card__icon {
    width: 46px;
    height: 46px;
    display: grid;
    place-items: center;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    background: var(--bg-elevated);
    color: var(--text-secondary);
}

.profile-library-card__icon :is(svg, i) { width: 20px; height: 20px; }
.profile-library-card h3 { margin: 7px 0 0; font-size: clamp(20px, 2.4vw, 28px); font-weight: var(--font-medium); }
.profile-library-card p { max-width: 500px; margin: 10px 0 0; color: var(--text-secondary); font-size: var(--text-sm); line-height: 1.75; }
.profile-library-card__count { position: relative; z-index: 1; min-width: 34px; text-align: center; color: var(--text-muted); font-size: var(--text-sm); }
.profile-library-card__arrow { position: absolute; inset-inline-end: 26px; bottom: 24px; width: 18px; height: 18px; color: var(--text-muted); transition: transform var(--duration-fast) var(--ease-out), color var(--duration-fast) var(--ease-default); }
.profile-library-card:hover .profile-library-card__arrow { color: var(--text-primary); transform: translateX(-3px); }

@keyframes profile-enter {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes profile-popover {
    from { opacity: 0; transform: translateY(-4px) scale(.98); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

@media (max-width: 900px) {
    .profile-owner-hero__top { flex-direction: column; }
    .profile-owner-actions { width: 100%; justify-content: flex-start; }
    .profile-library-links__grid { grid-template-columns: 1fr; }
}

@media (max-width: 767.98px) {
    .profile-section--owner { padding-top: 92px; padding-bottom: 54px; }
    .profile-owner-wrap { width: min(calc(100% - 28px), 1320px); }
    .profile-owner-identity { flex-direction: column; }
    .profile-owner-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .profile-owner-action, .profile-owner-privacy > summary { width: 100%; }
    .profile-owner-privacy__menu { inset-inline-start: 0; inset-inline-end: auto; }
    .profile-section--owner .profile-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .profile-library-card { min-height: 0; grid-template-columns: auto minmax(0, 1fr); }
    .profile-library-card__count { position: absolute; inset-inline-end: 22px; top: 22px; }
}

@media (max-width: 520px) {
    .profile-owner-actions { grid-template-columns: 1fr; }
    .profile-library-card { padding: 20px; }
    .profile-library-card__icon { width: 40px; height: 40px; }
}

@media (prefers-reduced-motion: reduce) {
    .profile-section--owner *,
    .profile-section--owner *::before,
    .profile-section--owner *::after {
        animation: none !important;
        transition: none !important;
    }
}
