﻿:root {
    --myst-icon-radius: 12px;
    --myst-duration: 0.3s;
    --myst-ease: cubic-bezier(0.4, 0, 0.2, 1);
    --myst-ease-pop: cubic-bezier(0.34, 1.56, 0.64, 1);
    --myst-light-x: 30%;
    --myst-light-y: 22%;
    --myst-highlight-strength: 0.55;
}

.myst-icon-wrapper,
.rz-stack.myst-icon-wrapper {
    --myst-icon-src: var(--myst-auto, var(--rz-primary));
    --myst-icon-color: color-mix(in srgb, var(--myst-icon-src) 85%, var(--rz-text-color));
    --myst-icon-bg: color-mix(in srgb, var(--myst-icon-src) 14%, transparent);
    --myst-icon-border: color-mix(in srgb, var(--myst-icon-src) 30%, transparent);
    --myst-icon-glow: color-mix(in srgb, var(--myst-icon-src) 38%, transparent);
    --myst-icon-highlight: color-mix(in srgb, var(--myst-icon-src) 15%, white);
    --myst-icon-shine: color-mix(in srgb, var(--myst-icon-src) 20%, white);
    --myst-icon-ao: rgb(0 0 0 / 0.45);
    --myst-icon-hi: rgb(255 255 255 / 0.35);
    position: relative;
    display: inline-flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    width: 48px;
    height: 48px;
    border-radius: var(--myst-icon-radius);
    color: var(--myst-icon-color);
    background: var(--myst-icon-bg);
    border: 1px solid var(--myst-icon-border);
    overflow: hidden;
    isolation: isolate;
    contain: layout paint style;
    transform: perspective(600px) translateZ(0); 
    box-shadow: 0 1px 2px rgb(0 0 0 / 0.10), 0 3px 6px rgb(0 0 0 / 0.08), 0 0 0 transparent, inset 0 1px 1px var(--myst-icon-hi), inset 0 -2px 3px var(--myst-icon-ao);
    transition: transform var(--myst-duration) var(--myst-ease-pop), box-shadow var(--myst-duration) var(--myst-ease);
}

    .myst-icon-wrapper::before {
        content: "";
        position: absolute;
        inset: 0;
        border-radius: inherit;
        background: radial-gradient(120% 120% at var(--myst-light-x) var(--myst-light-y), color-mix(in srgb, var(--myst-icon-highlight) 70%, transparent) 0%, color-mix(in srgb, var(--myst-icon-src) 25%, transparent) 28%, transparent 55%);
        opacity: var(--myst-highlight-strength);
        pointer-events: none;
        transition: opacity var(--myst-duration) var(--myst-ease);
    }

    .myst-icon-wrapper::after {
        content: "";
        position: absolute;
        inset: -1px;
        border-radius: inherit;
        background: linear-gradient(75deg, transparent 0%, var(--myst-icon-shine) 45%, transparent 60%);
        opacity: 0;
        pointer-events: none;
        transform: rotate(20deg) translateX(-140%);
        transition: opacity var(--myst-duration) var(--myst-ease), transform var(--myst-duration) var(--myst-ease);
    }

.myst-icon-element {
    position: relative;
    z-index: 1;
    display: inline-block;
    color: inherit;
    font-size: inherit;
    font-variation-settings: 'FILL' var(--myst-fill, 1);
    text-shadow: 0 1px 1px rgb(0 0 0 / 0.18); /* جایگزین filter: drop-shadow که هر فریم repaint می‌کرد */
    transition: transform var(--myst-duration) var(--myst-ease-pop);
}

/* ---------- تم تیره ---------- */
.rz-dark .myst-icon-wrapper,
[data-theme="dark"] .myst-icon-wrapper {
    --myst-icon-hi: rgb(255 255 255 / 0.14);
    --myst-icon-ao: rgb(0 0 0 / 0.60);
    --myst-highlight-strength: 0.35;
}

/* ---------- Variantها ---------- */
.myst-icon--primary {
    --myst-icon-src: var(--rz-primary);
}

.myst-icon--secondary {
    --myst-icon-src: var(--rz-secondary);
}

.myst-icon--info {
    --myst-icon-src: var(--rz-info);
}

.myst-icon--success {
    --myst-icon-src: var(--rz-success);
}

.myst-icon--warning {
    --myst-icon-src: var(--rz-warning);
}

.myst-icon--danger,
.myst-icon--error {
    --myst-icon-src: var(--rz-danger);
}

.myst-icon--neutral {
    --myst-icon-src: var(--rz-base-500);
}

.myst-icon--base {
    --myst-icon-src: var(--rz-base-400);
}

/* ---------- پالت خودکار (specificity صفر) ---------- */
:where(.myst-icon-group:not(.single-color) > .myst-icon-wrapper, .shortcut-tile:not(.single-color)):nth-child(8n+1) {
    --myst-auto: var(--rz-primary);
}

:where(.myst-icon-group:not(.single-color) > .myst-icon-wrapper, .shortcut-tile:not(.single-color)):nth-child(8n+2) {
    --myst-auto: var(--rz-warning);
}

:where(.myst-icon-group:not(.single-color) > .myst-icon-wrapper, .shortcut-tile:not(.single-color)):nth-child(8n+3) {
    --myst-auto: var(--rz-success);
}

:where(.myst-icon-group:not(.single-color) > .myst-icon-wrapper, .shortcut-tile:not(.single-color)):nth-child(8n+4) {
    --myst-auto: var(--rz-danger);
}

:where(.myst-icon-group:not(.single-color) > .myst-icon-wrapper, .shortcut-tile:not(.single-color)):nth-child(8n+5) {
    --myst-auto: var(--rz-secondary);
}

:where(.myst-icon-group:not(.single-color) > .myst-icon-wrapper, .shortcut-tile:not(.single-color)):nth-child(8n+6) {
    --myst-auto: var(--rz-info);
}

:where(.myst-icon-group:not(.single-color) > .myst-icon-wrapper, .shortcut-tile:not(.single-color)):nth-child(8n+7) {
    --myst-auto: var(--rz-base-600);
}

:where(.myst-icon-group:not(.single-color) > .myst-icon-wrapper, .shortcut-tile:not(.single-color)):nth-child(8n+8) {
    --myst-auto: var(--rz-base-400);
}

/* ---------- هاور سه‌بعدی ---------- */
@media (hover: hover) {
    .myst-card--clickable:hover .myst-icon-wrapper,
    .myst-icon-wrapper:hover {
        will-change: transform; /* فقط هنگام hover لایه جداگانه می‌گیرد، نه برای همه آیکون‌ها */
        transform: perspective(600px) translate3d(0, -3px, 14px) rotateX(8deg) rotateY(-10deg) scale(1.08);
        box-shadow: 0 1px 2px rgb(0 0 0 / 0.10), 0 10px 18px rgb(0 0 0 / 0.16), 0 0 20px var(--myst-icon-glow), inset 0 1px 1px var(--myst-icon-hi), inset 0 -2px 3px var(--myst-icon-ao);
    }

        .myst-card--clickable:hover .myst-icon-wrapper::before,
        .myst-icon-wrapper:hover::before {
            opacity: calc(var(--myst-highlight-strength) + 0.35);
        }

        .myst-card--clickable:hover .myst-icon-wrapper::after,
        .myst-icon-wrapper:hover::after {
            opacity: 1;
            transform: rotate(20deg) translateX(140%);
        }

        .myst-card--clickable:hover .myst-icon-element,
        .myst-icon-wrapper:hover .myst-icon-element {
            transform: translate3d(0, -1px, 4px) scale(1.12);
        }
}

@media (max-width: 768px) {
    .myst-icon-wrapper,
    .rz-stack.myst-icon-wrapper {
        width: 40px;
        height: 40px;
        border-radius: 10px;
    }
}

@media (hover: none) {
    .myst-icon-wrapper::after {
        display: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    .myst-icon-wrapper,
    .myst-icon-element,
    .myst-icon-wrapper::before,
    .myst-icon-wrapper::after {
        transition: none !important;
    }

        .myst-icon-wrapper:hover {
            transform: scale(1.04);
        }
}

/* ---------- shortcut-tile (بدون تغییر) ---------- */
.shortcut-tile:focus:not(:focus-visible) {
    outline: none !important;
    outline-offset: 0 !important;
    box-shadow: none !important;
    border-color: transparent !important;
}

.shortcut-tile:hover,
.shortcut-tile:focus:not(:focus-visible),
.shortcut-tile:active {
    background: transparent !important;
    box-shadow: none !important;
    border-color: transparent !important;
    outline: none !important;
}

.shortcut-tile::before,
.shortcut-tile::after {
    display: none !important;
    content: none !important;
}

.shortcut-tile::-moz-focus-inner {
    border: 0 !important;
}

.shortcut-tile:focus-visible {
    outline: 2px solid var(--rz-primary) !important;
    outline-offset: 3px !important;
    border-radius: 12px;
}
