/**
 * Profile page — Related profiles (isolated from homepage .profiles-grid / .profile-card)
 */
.kama-related {
    margin-top: 1.5rem;
    margin-bottom: 1rem;
    padding-top: 0.75rem;
    padding-bottom: 0.5rem;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
}

.kama-related[hidden] {
    display: none !important;
}

.kama-related__title {
    font-size: 1rem;
    font-weight: 700;
    margin: 0 0 1rem;
    color: var(--text-primary);
}

.kama-related__grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.75rem;
    margin: 0;
    padding: 0;
    list-style: none;
    width: 100%;
    max-width: 100%;
}

@media (min-width: 769px) {
    .kama-related__grid {
        grid-template-columns: repeat(5, minmax(0, 1fr));
        gap: 1.1rem 1.25rem;
    }
}

.kama-related-card {
    position: relative;
    margin: 0;
    padding: 0;
    min-width: 0;
    max-width: 100%;
    border-radius: 12px;
    overflow: hidden;
    background: var(--surface);
    border: 1px solid var(--border-color);
    isolation: isolate;
}

.kama-related-card__link {
    display: block;
    color: inherit;
    text-decoration: none;
    max-width: 100%;
}

/* padding-top portrait box — works even if external CSS partially fails */
.kama-related-card__media {
    position: relative;
    width: 100%;
    max-width: 100%;
    padding-top: 150%;
    height: 0;
    overflow: hidden;
    background: var(--surface-light);
}

@media (min-width: 769px) {
    .kama-related-card__media {
        padding-top: 145%;
    }
}

.kama-related-card__img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    max-width: 100%;
    object-fit: cover;
    object-position: center center;
    opacity: 0;
    transition: opacity 0.18s ease;
}

.kama-related-card__img.is-loaded {
    opacity: 1;
}

.kama-related-card__shade {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1;
    padding: 1.4rem 0.5rem 0.45rem;
    display: flex;
    flex-direction: column;
    gap: 0.12rem;
    color: #fff;
    font-weight: 600;
    text-align: left;
    background: linear-gradient(
        to top,
        rgba(0, 0, 0, 0.92) 0%,
        rgba(0, 0, 0, 0.82) 12%,
        rgba(0, 0, 0, 0.35) 48%,
        transparent 100%
    );
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.55);
    pointer-events: none;
}

.kama-related-card__name {
    margin: 0;
    font-size: 0.75rem;
    line-height: 1.25;
    color: #fff;
}

.kama-related-card__loc {
    margin: 0;
    font-size: 0.55rem;
    line-height: 1.2;
    display: inline-flex;
    align-items: center;
    gap: 0.2rem;
    color: rgba(255, 255, 255, 0.95);
}

.kama-related-card__loc svg {
    width: 0.65rem;
    height: 0.65rem;
    flex-shrink: 0;
}

.kama-related-card__badge {
    position: absolute;
    top: 0.45rem;
    left: 0.45rem;
    right: auto;
    z-index: 2;
    padding: 0.12rem 0.38rem;
    border-radius: 999px;
    font-size: 0.58rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    line-height: 1.2;
    color: #fff;
    pointer-events: none;
}

.kama-related-card__badge--top {
    background: linear-gradient(135deg, #f59e0b, #d97706);
}

.kama-related-card__badge--vip {
    background: linear-gradient(135deg, #a855f7, #7c3aed);
}

.kama-related-card__fav {
    position: absolute;
    top: 6px;
    right: 6px;
    left: auto;
    z-index: 3;
    width: 24px;
    height: 24px;
    padding: 0;
    border: none;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    background: rgba(0, 0, 0, 0.45);
    color: #fff;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.kama-related-card__fav.is-active {
    background: rgba(var(--primary-rgb), 0.85);
}

.kama-related-card__fav svg {
    width: 12px;
    height: 12px;
    fill: currentColor;
}

/* Safety: never let related imgs blow up the page */
#kamaRelatedGrid img {
    max-width: 100%;
}

/* Back to home — profile page bottom CTA */
.profile-back-home {
    margin: 1.35rem 0 2rem;
    padding: 0;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

.profile-back-home__btn {
    position: relative;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    width: 100%;
    min-height: 48px;
    padding: 0.58rem 0.85rem 0.58rem 0.72rem;
    border-radius: 16px;
    text-decoration: none;
    color: #fff;
    overflow: hidden;
    isolation: isolate;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    background:
        radial-gradient(120% 180% at 0% 0%, rgba(var(--secondary-rgb), 0.22) 0%, transparent 50%),
        linear-gradient(135deg, var(--primary-color) 0%, #6366f1 42%, var(--secondary-color) 100%);
    background-size: 100% 100%, 220% 220%;
    animation: profile-back-home-shift 6s ease-in-out infinite;
    border: 1px solid rgba(255, 255, 255, 0.14);
    box-shadow:
        0 8px 28px rgba(var(--primary-rgb), 0.38),
        0 2px 8px rgba(0, 0, 0, 0.22),
        inset 0 1px 0 rgba(255, 255, 255, 0.16);
    transition:
        transform 0.22s cubic-bezier(0.34, 1.25, 0.64, 1),
        box-shadow 0.22s ease;
}

.profile-back-home__shine {
    position: absolute;
    inset: 0;
    background: linear-gradient(
        105deg,
        transparent 38%,
        rgba(255, 255, 255, 0.12) 50%,
        transparent 62%
    );
    transform: translateX(-120%);
    animation: profile-back-home-shine 4.5s ease-in-out infinite;
    pointer-events: none;
    z-index: 0;
}

.profile-back-home__icon,
.profile-back-home__label,
.profile-back-home__arrow {
    position: relative;
    z-index: 1;
}

.profile-back-home__icon {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 34px;
    height: 34px;
    border-radius: 11px;
    background: rgba(255, 255, 255, 0.16);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.profile-back-home__icon svg {
    width: 17px;
    height: 17px;
    display: block;
}

.profile-back-home__label {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
    text-align: left;
}

.profile-back-home__text {
    font-size: 0.88rem;
    font-weight: 750;
    letter-spacing: 0.015em;
    line-height: 1.15;
}

.profile-back-home__sub {
    font-size: 0.65rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    opacity: 0.82;
    text-transform: uppercase;
}

.profile-back-home__arrow {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.12);
    transition: transform 0.22s cubic-bezier(0.34, 1.25, 0.64, 1);
}

.profile-back-home__arrow svg {
    width: 16px;
    height: 16px;
    display: block;
}

.profile-back-home__btn:hover {
    box-shadow:
        0 12px 36px rgba(var(--primary-rgb), 0.45),
        0 4px 12px rgba(0, 0, 0, 0.24),
        inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.profile-back-home__btn:hover .profile-back-home__arrow {
    transform: translateX(3px);
}

.profile-back-home__btn:active {
    transform: scale(0.975);
}

@keyframes profile-back-home-shift {
    0%, 100% { background-position: 0% 50%, 0% 50%; }
    50% { background-position: 0% 50%, 100% 50%; }
}

@keyframes profile-back-home-shine {
    0%, 72%, 100% { transform: translateX(-120%); }
    88% { transform: translateX(120%); }
}

@media (min-width: 769px) {
    .profile-back-home {
        display: none;
    }
}

@media (max-width: 768px) {
    .profile-back-home {
        margin-top: 1.5rem;
        /* Match profile-view-stats → back-home rhythm (header padding 0.75rem + 2rem margin) */
        margin-bottom: 2rem;
    }

    .profile-back-home__btn {
        min-height: 48px;
        border-radius: 16px;
    }

    /* Avoid scroll compositing flicker (same approach as homepage cards). */
    .kama-related-card__fav {
        -webkit-backdrop-filter: none;
        backdrop-filter: none;
        background: rgba(0, 0, 0, 0.55);
    }

    .kama-related-card__fav.is-active {
        background: rgba(var(--primary-rgb), 0.85);
    }
}

:root[data-theme="light"] .profile-back-home__btn {
    border-color: rgba(var(--primary-rgb), 0.22);
    box-shadow:
        0 6px 22px rgba(var(--primary-rgb), 0.22),
        0 2px 6px rgba(0, 0, 0, 0.08),
        inset 0 1px 0 rgba(255, 255, 255, 0.28);
}

@media (prefers-reduced-motion: reduce) {
    .profile-back-home__btn,
    .profile-back-home__shine {
        animation: none;
    }

    .profile-back-home__btn:active {
        transform: none;
    }
}
