/* --- 1. General Styles & Root Variables --- */
:root {
    --button-height: 52px;
    --animation-duration: 0.5s;
    --main-width: 300px;
}

body {
    font-family: 'Poppins', sans-serif;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    margin: 0;
    background: #000;
    user-select: none;
    opacity: 0;
    transition: opacity 0.5s ease;
    -webkit-tap-highlight-color: transparent;
    overflow: hidden; 
}

body.loaded {
    opacity: 1;
}

/* --- 2. Main Layout (Profile & Links) --- */
.profile-container, .links-container {
    transition: filter 0.4s ease, opacity 0.4s ease;
    /* به مرورگر اطلاع می‌دهد که این ویژگی‌ها تغییر خواهند کرد تا رندر بهینه‌تر شود */
    will-change: filter, opacity;
}

body.widget-active .profile-container,
body.widget-active .links-container {
    filter: blur(5px);
    opacity: 0.5;
    pointer-events: none; /* غیرفعال کردن تعامل با محتوای پشت ویجت */
}

.profile-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 30px;
    z-index: 2;
}

.image-wrapper {
    position: relative;
    width: 150px;
    height: 150px;
}

.profile-image {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    border: 3px solid rgba(255, 255, 255, 0.1);
    transition: opacity 0.3s ease;
}

.profile-image.hidden {
    opacity: 0;
}

.active-icon-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.active-icon {
    width: 70%;
    height: 70%;
    object-fit: contain;
    opacity: 0;
    transform: scale(0.8);
    transition: opacity 0.2s cubic-bezier(0.4, 0, 0.2, 1), transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    filter: brightness(0) invert(1) drop-shadow(0 4px 10px rgba(255, 255, 255, 0.1)); 
    will-change: transform, opacity;
}

h1.animated-title {
    direction: ltr;
    margin: 15px 0 0 0;
    font-size: 2.2em;
    color: #fff;
    display: flex;
}

h1.animated-title span {
    display: inline-block;
    opacity: 0;
    transform: translateY(30px) scale(0.8);
    animation: dropIn 0.8s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
    animation-delay: calc(var(--i) * 0.1s + 0.5s);
}

.links-container {
    display: flex;
    flex-direction: column;
    gap: 20px;
    width: var(--main-width);
    max-width: 90%;
    z-index: 2;
}

.link-button {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 12px 20px;
    box-sizing: border-box;
    width: 100%;
    height: var(--button-height);
    text-decoration: none;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 20px;
    color: #fff;
    font-weight: 600;
    position: relative;
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.15);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.3s ease, background-color 0.3s ease;
    will-change: transform, box-shadow;
}

.link-button:hover {
    transform: translateY(-5px) scale(1.05);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.25);
    background: rgba(255, 255, 255, 0.2);
}

.link-button span {
    margin-right: auto;
    transition: transform 0.2s ease;
}

.link-button:hover span {
    transform: translateX(-5px);
}

.social-icon-container {
    display: flex;
    align-items: center;
    margin-left: auto;
    margin-right: 10px;
    transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.link-button:hover .social-icon-container {
    transform: rotate(15deg) scale(1.2);
}

.social-icon {
    width: 20px;
    height: 20px;
    z-index: 1;
    filter: brightness(0) invert(1);
}

/* --- 3. Component: Telegram Drawer --- */
.telegram-drawer {
    position: relative;
    width: 100%;
    height: var(--button-height);
    display: flex;
    justify-content: center;
    align-items: center;
}

#telegramToggle {
    position: absolute;
    cursor: pointer;
    z-index: 10;
    transition: width var(--animation-duration) ease, border-radius var(--animation-duration) ease, transform var(--animation-duration) ease;
    will-change: width, border-radius, transform;
}

.telegram-drawer.open #telegramToggle {
    width: var(--button-height);
    border-radius: 50%;
    transform: scale(0.9);
}

#telegramContent {
    display: flex;
    align-items: center;
    width: 100%;
    justify-content: center;
    transition: opacity calc(var(--animation-duration) / 2) ease;
}

.telegram-drawer.open #telegramContent {
    opacity: 0;
}

#closeIcon {
    position: absolute;
    font-size: 28px;
    font-weight: bold;
    line-height: 1;
    color: #fff;
    opacity: 0;
    transition: opacity 0.1s ease;
}

.telegram-drawer.open #closeIcon {
    opacity: 1;
    transition-delay: calc(var(--animation-duration) / 2);
}

.bloom-button {
    position: absolute;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 130px;
    height: var(--button-height);
    text-decoration: none;
    color: #fff;
    font-weight: 600;
    font-size: 0.9em;
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 50px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.15);
    opacity: 0;
    pointer-events: none;
    transform: translate(0, 0) scale(0.4);
    transition: transform var(--animation-duration) cubic-bezier(0.34, 1.56, 0.64, 1), opacity calc(var(--animation-duration) / 1.5) ease, box-shadow 0.2s ease;
    will-change: transform, opacity, box-shadow;
}

.telegram-drawer.open .bloom-button {
    opacity: 1;
    pointer-events: auto;
}
.telegram-drawer.open .bloom-button.account { transform: translateX(95px) scale(1); }
.telegram-drawer.open .bloom-button.channel { transform: translateX(-95px) scale(1); }
.telegram-drawer.open .bloom-button:hover { transform: translateY(-5px) scale(1); box-shadow: 0 10px 22px rgba(0,0,0,0.25); }
.telegram-drawer.open .bloom-button.account:hover { transform: translateX(95px) translateY(-5px); }
.telegram-drawer.open .bloom-button.channel:hover { transform: translateX(-95px) translateY(-5px); }

/* --- 4. Component: Music Player Modal --- */
.music-note-btn {
    position: fixed;
    top: 20px;
    right: 20px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 50%;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 100;
    transition: all 0.2s ease;
}
.music-note-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.1);
}

.music-note-btn .music-note-img {
    width: 24px;
    height: 24px;
    filter: invert(1);
    object-fit: contain;
}

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(5px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}
.modal-overlay.show {
    opacity: 1;
    pointer-events: auto;
}

.modal-content {
    background: #1c1c1c;
    padding: 25px;
    border-radius: 15px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    width: 90%;
    max-width: 450px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    position: relative;
    transform: scale(0.95);
    transition: transform 0.3s ease;
}
.modal-overlay.show .modal-content {
    transform: scale(1);
}

.close-modal-btn {
    position: absolute;
    top: 10px;
    right: 15px;
    background: none;
    border: none;
    color: #888;
    font-size: 28px;
    cursor: pointer;
    transition: color 0.2s ease;
}
.close-modal-btn:hover {
    color: #fff;
}

.player-controls {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 20px;
    width: 100%;
    direction: ltr;
}

.control-btn {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #fff;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background-color 0.2s ease;
    flex-shrink: 0;
}
.control-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

.progress-container {
    width: 100%;
    height: 8px;
    background: #444;
    border-radius: 5px;
    cursor: pointer;
}

.progress-bar {
    width: 0%;
    height: 100%;
    background: #fff;
    border-radius: 5px;
}

.lyrics-container {
    color: #aaa;
    font-size: 0.9em;
    line-height: 1.6;
    overflow-y: auto;
    text-align: center;
    direction: ltr;
    padding-right: 10px;
}
.lyrics-container p {
    margin: 0;
    font-family: 'Poppins', sans-serif;
    font-weight: 600;
    opacity: 0;
    animation-fill-mode: forwards;
}
.lyrics-container p.spacer {
    height: 1.2em;
    animation: none;
}
.modal-overlay.show .lyrics-container p {
    animation-name: revealLine;
    animation-duration: 0.6s;
    animation-timing-function: cubic-bezier(0.2, 0.8, 0.2, 1);
    animation-delay: calc(var(--line) * 60ms + 200ms);
}
.lyrics-container::-webkit-scrollbar { width: 8px; }
.lyrics-container::-webkit-scrollbar-track { background: rgba(255, 255, 255, 0.05); border-radius: 10px; }
.lyrics-container::-webkit-scrollbar-thumb { background-color: #555; border-radius: 10px; border: 2px solid transparent; background-clip: content-box; }
.lyrics-container::-webkit-scrollbar-thumb:hover { background-color: #777; }
.lyrics-container { scrollbar-width: thin; scrollbar-color: #555 rgba(255, 255, 255, 0.05); }

/* --- 5. Component: Contact Widget --- */
.page-overlay {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 990;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.4s ease;
}
body.widget-active .page-overlay {
    opacity: 1;
    pointer-events: auto;
}

.contact-widget {
    position: fixed;
    bottom: 30px;
    right: 30px;
    z-index: 1000;
    /* START: مخفی کردن ویجت تماس وقتی موزیک پلیر باز است */
    transition: opacity 0.3s ease, visibility 0.3s ease; /* برای نمایش/مخفی شدن نرم */
}

body.music-player-active .contact-widget {
    opacity: 0;
    pointer-events: none;
    visibility: hidden; /* برای غیرفعال کردن کلیک و اطمینان از عدم دیده شدن */
}
/* END: مخفی کردن ویجت تماس وقتی موزیک پلیر باز است */


.contact-fab {
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #f0f0f0;
    color: #111;
    border: none;
    border-radius: 50px;
    padding: 0 15px;
    height: 38px;
    width: 160px;
    font-size: 12px;
    font-family: 'Poppins', sans-serif;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(255,255,255,0.1);
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
    direction: ltr;
}
.contact-fab:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(255,255,255,0.15);
}

.contact-fab .fab-question { transition: opacity 0.2s ease 0.3s; }
.contact-fab .fab-close {
    position: absolute;
    font-size: 24px;
    color: #111;
    opacity: 0;
    transition: opacity 0.1s ease;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}
body.widget-active .contact-fab {
    width: 38px;
}
body.widget-active .fab-question { opacity: 0; transition: opacity 0.1s ease; }
body.widget-active .fab-close { opacity: 1; transition: opacity 0.2s ease 0.3s; }

.contact-panel {
    position: absolute;
    bottom: calc(100% + 15px);
    right: 0;
    width: 280px;
    padding: 20px;
    background: rgba(30, 30, 30, 0.75);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 15px;
    box-shadow: 0 5px 25px rgba(0,0,0,0.2);
    opacity: 0;
    transform: translateY(20px) scale(0.95);
    transform-origin: bottom right;
    pointer-events: none;
    transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    will-change: transform, opacity;
    direction: ltr;
    text-align: left;
}
body.widget-active .contact-panel {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

#contactText {
    margin: 0;
    min-height: 45px;
    font-family: 'Poppins', sans-serif;
    font-weight: 600;
    font-size: 15px;
    line-height: 1.5;
    color: #eee;
    opacity: 0;
    will-change: opacity, clip-path;
}
body.widget-active #contactText {
    animation: revealText 0.8s cubic-bezier(0.25, 1, 0.5, 1) 0.3s forwards;
}

/* --- 6. Animations --- */
@keyframes dropIn {
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes revealLine {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes revealText {
    from {
        opacity: 0;
        clip-path: inset(0 100% 0 0);
    }
    to {
        opacity: 1;
        clip-path: inset(0 0 0 0);
    }
}

/* --- 7. Media Queries --- */
@media (max-width: 480px) {
    .links-container { 
        width: 95%;
        padding-bottom: 80px;
    }
    .contact-widget {
        bottom: 20px;
        right: 20px;
    }
}