/* ================================================================
   LifeStyleMod – Base Layer (v5.6 – Twilight Sky)
   ----------------------------------------------------------------
   v5.6:
   ▸ 🐛 Fix: overflow-x: hidden → clip روی body
     — چرا: overflow-x: hidden در Chrome Android یک scroll container
       روی body می‌ساخت که position:sticky را می‌شکست
       (فیلترهای explore «میان پایین» می‌موندند)
     — راه‌حل: overflow-x: clip (بدون ساخت scroll container)
   ▸ حفظ همه‌ی تغییرات v5.5

   v5.5:
   ▸ 🐛 Fix: [hidden] display:none !important (سراسری)

   v5.4:
   ▸ اضافه شدن 12px فاصله بین navbar و محتوا (padding-top body)
   ▸ روی موبایل 10px اضافه

   شامل:
   ▸ Reset و box-sizing
   ▸ body و پس‌زمینه
   ▸ تایپوگرافی کامل
   ▸ Scrollbar
   ▸ انیمیشن‌های سبک
   ▸ Utility classes
   ================================================================ */

/* ═══════════════════════════════════════════════════════════
   1. RESET
   ═══════════════════════════════════════════════════════════ */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
    scroll-padding-top: calc(var(--nav-h) + 24px);
}

img, svg, video, canvas, audio, iframe, embed, object {
    display: block;
    max-width: 100%;
}

img, video {
    height: auto;
}

button, input, select, textarea {
    font: inherit;
    color: inherit;
}

button {
    background: none;
    border: none;
    cursor: pointer;
}

ul, ol {
    list-style: none;
}

table {
    border-collapse: collapse;
    border-spacing: 0;
}

/* ═══════════════════════════════════════════════════════════
   2. BODY (با فاصله‌ی درست از navbar)
   ═══════════════════════════════════════════════════════════ */
body {
    font-family: var(--font-main);
    font-size: var(--fs-base);
    font-weight: var(--fw-normal);
    line-height: var(--lh-base);
    color: var(--c-text);
    background-color: var(--c-bg);

    background-image:
        linear-gradient(rgba(109, 159, 201, 0.025) 1px, transparent 1px),
        linear-gradient(90deg, rgba(109, 159, 201, 0.025) 1px, transparent 1px);
    background-size: 64px 64px;
    background-position: -1px -1px;

    min-height: 100vh;

    /* ⚡ فاصله‌ی درست: ارتفاع navbar + 12px اضافه */
    padding-top: calc(var(--nav-h) + 12px);

    /* ═══════════════════════════════════════════════════════
       🐛 Fix v5.6: overflow-x: clip (به‌جای hidden)
       ═══════════════════════════════════════════════════════
       ▸ چرا: overflow-x: hidden روی body → مرورگر یک scroll container
         جدید می‌سازه → position: sticky روی descendantها می‌شکنه
         (مخصوصاً Chrome Android)
       ▸ clip: افقی رو clip می‌کنه ولی scroll container نمی‌سازه
       ▸ پشتیبانی: Chrome 90+, Firefox 81+, Safari 16+
       ▸ fallback: مرورگرهای قدیمی‌تر overflow-x: hidden رو نادیده
         می‌گیرن → شاید scroll افقی داشته باشن، ولی layout نمی‌شکنه
       ═══════════════════════════════════════════════════════ */
    overflow-x: clip;

    position: relative;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeSpeed;
}

/* fallback برای مرورگرهای قدیمی که clip رو پشتیبانی نمی‌کنن */
@supports not (overflow: clip) {
    body {
        overflow-x: hidden;
    }
    /* ⚠️ در این حالت، sticky روی Android ممکنه کار نکنه
       ولی حداقل layout نمی‌شکنه */
}

/* ═══════════════════════════════════════════════════════════
   3. TYPOGRAPHY
   ═══════════════════════════════════════════════════════════ */
h1, h2, h3, h4, h5, h6 {
    font-weight: var(--fw-black);
    line-height: var(--lh-tight);
    color: var(--c-text);
    letter-spacing: var(--ls-tight);
}

h1 {
    font-size: clamp(32px, 5vw, var(--fs-4xl));
    font-weight: var(--fw-black);
    letter-spacing: var(--ls-tighter);
}

h2 {
    font-size: clamp(24px, 4vw, var(--fs-2xl));
    font-weight: var(--fw-black);
    letter-spacing: var(--ls-tight);
}

h3 {
    font-size: clamp(19px, 3vw, var(--fs-xl));
    font-weight: var(--fw-bold);
}

h4 {
    font-size: var(--fs-lg);
    font-weight: var(--fw-bold);
}

h5 {
    font-size: var(--fs-md);
    font-weight: var(--fw-semi);
}

h6 {
    font-size: var(--fs-base);
    font-weight: var(--fw-semi);
}

p {
    color: var(--c-text-soft);
    line-height: var(--lh-base);
}

p + p { margin-top: var(--s-3); }

small, .text-sm { font-size: var(--fs-sm); }
.text-xs { font-size: var(--fs-xs); }
.text-lg { font-size: var(--fs-lg); }

strong, b {
    color: var(--c-text);
    font-weight: var(--fw-bold);
}

em, i { font-style: italic; }

/* ─── کد و mono ─── */
code, pre, kbd, samp, .mono {
    font-family: var(--font-mono);
    font-feature-settings: 'tnum' 1, 'zero' 1;
    font-variant-numeric: tabular-nums;
}

code {
    background: var(--c-surface-2);
    padding: 2px 7px;
    border-radius: var(--r-xs);
    color: var(--c-primary-light);
    font-size: 0.9em;
    border: 1px solid var(--c-border);
}

pre {
    background: var(--c-surface);
    border: 1px solid var(--c-border);
    border-radius: var(--r-md);
    padding: var(--s-4);
    overflow-x: auto;
    line-height: 1.7;
    font-size: var(--fs-sm);
}

pre code {
    background: none;
    padding: 0;
    border: none;
    color: var(--c-text);
}

/* ═══════════════════════════════════════════════════════════
   4. LABELS
   ═══════════════════════════════════════════════════════════ */
.label,
.label-upper {
    display: inline-block;
    font-size: var(--fs-xs);
    font-weight: var(--fw-semi);
    letter-spacing: var(--ls-wide);
    text-transform: uppercase;
    color: var(--c-text-muted);
    line-height: 1;
}

.label-primary { color: var(--c-primary-light); }
.label-success { color: var(--c-success); }
.label-warning { color: var(--c-warning); }
.label-danger  { color: var(--c-danger); }

/* ═══════════════════════════════════════════════════════════
   5. LINKS
   ═══════════════════════════════════════════════════════════ */
a {
    color: var(--c-primary-light);
    text-decoration: none;
    transition: color var(--t-fast), opacity var(--t-fast);
}

a:hover {
    color: var(--c-primary);
}

a:focus-visible {
    outline: 2px solid var(--c-border-focus);
    outline-offset: 3px;
    border-radius: var(--r-xs);
}

/* ═══════════════════════════════════════════════════════════
   6. SELECTION
   ═══════════════════════════════════════════════════════════ */
::selection {
    background: rgba(109, 159, 201, 0.35);
    color: var(--c-text);
}

::-moz-selection {
    background: rgba(109, 159, 201, 0.35);
    color: var(--c-text);
}

/* ═══════════════════════════════════════════════════════════
   7. SCROLLBAR
   ═══════════════════════════════════════════════════════════ */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(109, 159, 201, 0.20);
    border-radius: var(--r-full);
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(109, 159, 201, 0.35);
}

* {
    scrollbar-width: thin;
    scrollbar-color: rgba(109, 159, 201, 0.25) transparent;
}

/* ═══════════════════════════════════════════════════════════
   8. FOCUS & ACCESSIBILITY
   ═══════════════════════════════════════════════════════════ */
:focus { outline: none; }

:focus-visible {
    outline: 2px solid var(--c-border-focus);
    outline-offset: 2px;
    border-radius: var(--r-xs);
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ═══════════════════════════════════════════════════════════
   9. ANIMATIONS
   ═══════════════════════════════════════════════════════════ */

@keyframes fadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

@keyframes fadeUp {
    from { opacity: 0; transform: translate3d(0, 16px, 0); }
    to   { opacity: 1; transform: translate3d(0, 0, 0); }
}

@keyframes fadeDown {
    from { opacity: 0; transform: translate3d(0, -16px, 0); }
    to   { opacity: 1; transform: translate3d(0, 0, 0); }
}

@keyframes slideInLeft {
    from { opacity: 0; transform: translate3d(-20px, 0, 0); }
    to   { opacity: 1; transform: translate3d(0, 0, 0); }
}

@keyframes slideInRight {
    from { opacity: 0; transform: translate3d(20px, 0, 0); }
    to   { opacity: 1; transform: translate3d(0, 0, 0); }
}

@keyframes pulseDot {
    0%, 100% { opacity: 1; transform: scale(1); }
    50%      { opacity: 0.5; transform: scale(0.85); }
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

@keyframes shimmer {
    0%   { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

@keyframes rainbowShift {
    0%   { background-position: 0% 50%; }
    50%  { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

/* ═══════════════════════════════════════════════════════════
   10. ANIMATION UTILITIES
   ═══════════════════════════════════════════════════════════ */
.animate-in        { animation: fadeUp 0.35s var(--t-slow) both; }
.animate-fade      { animation: fadeIn 0.25s ease both; }
.animate-up        { animation: fadeUp 0.4s var(--t-slow) both; }
.animate-down      { animation: fadeDown 0.4s var(--t-slow) both; }
.animate-left      { animation: slideInLeft 0.4s var(--t-slow) both; }
.animate-right     { animation: slideInRight 0.4s var(--t-slow) both; }
.animate-spin      { animation: spin 0.8s linear infinite; }

.delay-1 { animation-delay: 0.04s; }
.delay-2 { animation-delay: 0.08s; }
.delay-3 { animation-delay: 0.12s; }
.delay-4 { animation-delay: 0.16s; }
.delay-5 { animation-delay: 0.20s; }
.delay-6 { animation-delay: 0.24s; }

/* ═══════════════════════════════════════════════════════════
   11. STATUS DOT
   ═══════════════════════════════════════════════════════════ */
.dot-live {
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: var(--r-full);
    background: var(--c-success);
    margin-left: 6px;
    vertical-align: middle;
    animation: pulseDot 2s ease-in-out infinite;
    box-shadow: 0 0 8px rgba(95, 184, 154, 0.6);
}

.dot-static {
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: var(--r-full);
    background: var(--c-text-muted);
    margin-left: 6px;
    vertical-align: middle;
}

/* ═══════════════════════════════════════════════════════════
   12. TEXT UTILITIES
   ═══════════════════════════════════════════════════════════ */
.text-center { text-align: center; }
.text-right  { text-align: right; }
.text-left   { text-align: left; }

.text-muted   { color: var(--c-text-muted); }
.text-dim     { color: var(--c-text-dim); }
.text-soft    { color: var(--c-text-soft); }
.text-primary { color: var(--c-primary); }
.text-success { color: var(--c-success); }
.text-warning { color: var(--c-warning); }
.text-danger  { color: var(--c-danger); }

.text-bold { font-weight: var(--fw-bold); }
.text-black { font-weight: var(--fw-black); }

.text-num {
    font-variant-numeric: tabular-nums;
    font-feature-settings: 'tnum' 1;
}

.truncate {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.line-clamp-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.line-clamp-3 {
    display: -webkit-box;
    -webkit-line-clamp: 3;
    line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* ═══════════════════════════════════════════════════════════
   13. GRADIENT TEXT
   ═══════════════════════════════════════════════════════════ */
.gradient-text {
    background: var(--g-text);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    color: transparent;
}

.text-rainbow {
    background: var(--g-rainbow);
    background-size: 200% 100%;
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    color: transparent;
    animation: rainbowShift 4s ease infinite;
}

/* ═══════════════════════════════════════════════════════════
   14. FLEX UTILITIES
   ═══════════════════════════════════════════════════════════ */
.flex         { display: flex; }
.flex-col     { display: flex; flex-direction: column; }
.flex-wrap    { flex-wrap: wrap; }
.items-center { align-items: center; }
.items-start  { align-items: flex-start; }
.items-end    { align-items: flex-end; }
.justify-center  { justify-content: center; }
.justify-between { justify-content: space-between; }
.justify-end     { justify-content: flex-end; }
.flex-1       { flex: 1; }
.gap-1 { gap: var(--s-1); }
.gap-2 { gap: var(--s-2); }
.gap-3 { gap: var(--s-3); }
.gap-4 { gap: var(--s-4); }
.gap-5 { gap: var(--s-5); }
.gap-6 { gap: var(--s-6); }

/* ═══════════════════════════════════════════════════════════
   15. SPACING UTILITIES
   ═══════════════════════════════════════════════════════════ */
.mt-1 { margin-top: var(--s-1); }
.mt-2 { margin-top: var(--s-2); }
.mt-3 { margin-top: var(--s-3); }
.mt-4 { margin-top: var(--s-4); }
.mt-5 { margin-top: var(--s-5); }
.mt-6 { margin-top: var(--s-6); }

.mb-1 { margin-bottom: var(--s-1); }
.mb-2 { margin-bottom: var(--s-2); }
.mb-3 { margin-bottom: var(--s-3); }
.mb-4 { margin-bottom: var(--s-4); }
.mb-5 { margin-bottom: var(--s-5); }
.mb-6 { margin-bottom: var(--s-6); }

.p-1 { padding: var(--s-1); }
.p-2 { padding: var(--s-2); }
.p-3 { padding: var(--s-3); }
.p-4 { padding: var(--s-4); }
.p-5 { padding: var(--s-5); }
.p-6 { padding: var(--s-6); }

/* ═══════════════════════════════════════════════════════════
   16. VISIBILITY
   ═══════════════════════════════════════════════════════════ */
.hidden { display: none !important; }
.invisible { visibility: hidden; }
.visible { visibility: visible; }

/* ═══════════════════════════════════════════════════════════
   🐛 Fix (v5.5): [hidden] attribute سراسری
   ═══════════════════════════════════════════════════════════
   ▸ چرا: بعضی CSS ruleها (مثل .packs-grid .pack-card { display: flex })
     با specificity بالاتر از [hidden] پیش‌فرض مرورگر، اون رو override
     می‌کنن و باعث می‌شن همه آیتم‌ها (پک/ماد/سازنده) همیشه نمایش داده
     بشن حتی وقتی hidden attribute دارن.
   ▸ راه‌حل: !important روی [hidden] سراسری
   ▸ تأثیر: fix pagination در:
     - templates/category.php
     - templates/explore.php
     - templates/mods_list.php
     - templates/profile.php
     - templates/creators.php
   ═══════════════════════════════════════════════════════════ */
[hidden] {
    display: none !important;
}

/* ═══════════════════════════════════════════════════════════
   17. LOADING SPINNER
   ═══════════════════════════════════════════════════════════ */
.spinner {
    width: 28px;
    height: 28px;
    border: 2px solid var(--c-border);
    border-top-color: var(--c-primary);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

.spinner-sm { width: 16px; height: 16px; border-width: 1.5px; }
.spinner-lg { width: 40px; height: 40px; border-width: 3px; }

/* ═══════════════════════════════════════════════════════════
   18. REDUCED MOTION
   ═══════════════════════════════════════════════════════════ */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* ═══════════════════════════════════════════════════════════
   19. PRINT
   ═══════════════════════════════════════════════════════════ */
@media print {
    body {
        background: white;
        color: black;
        padding-top: 0;
        background-image: none;
    }
    nav, footer, .fab-upload, #scrollTop {
        display: none !important;
    }
}

/* ═══════════════════════════════════════════════════════════
   20. RESPONSIVE BASE
   ═══════════════════════════════════════════════════════════ */
@media (max-width: 768px) {
    body {
        /* ⚡ فاصله‌ی درست روی موبایل: ارتفاع navbar + 10px */
        padding-top: calc(var(--nav-h-mobile) + 10px);
        font-size: 14px;
        background-image: none;
    }

    ::-webkit-scrollbar { width: 5px; height: 5px; }

    h1 { font-size: clamp(26px, 7vw, 34px); }
    h2 { font-size: clamp(20px, 5vw, 26px); }
    h3 { font-size: clamp(17px, 4vw, 21px); }
}