/* =====================================================================
   XCO.IR - Hero 3D (صفحه اصلی)
   - تیتر سه‌بعدی (اکستروژن + براق‌شدن + ورود کلمه‌به‌کلمه + تیلت با ماوس/ژیروسکوپ)
   - مدال سه‌بعدی با لوگوی واقعی اکسکو، حلقه‌های مداری و آیکون‌های شناور در عمق‌های مختلف
   فقط CSS transform/opacity (سبک برای موبایل) - بدون کتابخانه و بدون درخواست شبکه‌ی اضافه.
   رعایت prefers-reduced-motion. متغیرهای --hx-px/--hx-py (بین -1 و 1) را JS تنظیم می‌کند.
   ===================================================================== */

.home-hero { --hx-px: 0; --hx-py: 0; }

/* ---------- تیتر ---------- */
.hx-title-wrap {
    perspective: 900px;
    perspective-origin: 50% 40%;
}

.hx-title {
    display: block;
    transform-style: preserve-3d;
    transform: rotateY(calc(var(--hx-px) * 5deg)) rotateX(calc(var(--hx-py) * -4deg));
    transition: transform .25s ease-out;
    line-height: 1.55;
    font-weight: 800;
    text-wrap: balance;
}

.hx-line { display: block; }

.hx-word {
    display: inline-block;
    transform-origin: 50% 100%;
    opacity: 0;
    transform: translateY(.5em) rotateX(-80deg) translateZ(0);
    animation: hx-word-in .85s cubic-bezier(.2, .9, .25, 1.1) forwards;
    animation-delay: calc(var(--i, 0) * 110ms + 150ms);
}

/* کلمات سفید: اکستروژن آبی‌-مایل به سفید برای عمق */
.hx-line-main .hx-word {
    color: #fff;
    text-shadow:
        0 1px 0 #dfe7f8, 0 2px 0 #c9d6f3, 0 3px 0 #b3c3ea, 0 4px 0 #9db1e0,
        0 5px 0 #8aa0d6, 0 6px 0 #7790cc,
        0 10px 14px rgba(0, 8, 32, .45), 0 18px 28px rgba(0, 8, 32, .28);
}

/* بخش دوم شعار: نارنجی با اکستروژن گرم + براق‌شدن متحرک */
.hx-line-accent .hx-word {
    position: relative;
    color: #ffb066;
    text-shadow:
        0 1px 0 #ff9a3d, 0 2px 0 #f2801a, 0 3px 0 #e06c0a, 0 4px 0 #cc5c00,
        0 5px 0 #b34f00, 0 6px 0 #994300,
        0 10px 14px rgba(0, 8, 32, .5), 0 18px 28px rgba(255, 98, 0, .28);
}

.hx-line-accent .hx-word::after {
    content: attr(data-text);
    position: absolute;
    inset: 0;
    text-shadow: none;
    background: linear-gradient(105deg, transparent 38%, rgba(255, 255, 255, .95) 50%, transparent 62%);
    background-size: 250% 100%;
    background-position: 160% 0;
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    color: transparent;
    pointer-events: none;
    animation: hx-shine 4.2s ease-in-out 1.6s infinite;
}

@keyframes hx-word-in {
    0%   { opacity: 0; transform: translateY(.5em) rotateX(-80deg) translateZ(0); }
    100% { opacity: 1; transform: translateY(0) rotateX(0) translateZ(0); }
}

@keyframes hx-shine {
    0%, 55% { background-position: 160% 0; }
    100%    { background-position: -60% 0; }
}

/* ---------- چرخانندهٔ خدمات (flip سه‌بعدی) ---------- */
.hx-rotor-line {
    display: inline-flex;
    align-items: center;
    gap: .6rem;
    flex-wrap: wrap;
    justify-content: center;
    color: rgba(255, 255, 255, .88);
    font-weight: 600;
    font-size: clamp(1rem, 2.6vw, 1.2rem);
    margin-bottom: 1.1rem;
    opacity: 0;
    animation: hx-fade-up .7s ease 1s forwards;
}

.hx-rotor {
    position: relative;
    display: inline-block;
    min-width: 9.5em;
    height: 2.35em;
    perspective: 600px;
    text-align: center;
}

.hx-rotor-item {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding-inline: 1em;
    border-radius: 999px;
    background: linear-gradient(135deg, rgba(255, 255, 255, .2), rgba(255, 255, 255, .07));
    border: 1px solid rgba(255, 255, 255, .3);
    box-shadow: 0 .5rem 1.2rem rgba(0, 12, 40, .3), inset 0 1px 0 rgba(255, 255, 255, .35);
    color: #fff;
    font-weight: 800;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    transform-origin: 50% 50%;
    opacity: 0;
    transform: rotateX(-90deg) translateZ(1.1em);
    transition: transform .6s cubic-bezier(.3, .9, .3, 1), opacity .45s ease;
}

.hx-rotor-item.is-active {
    opacity: 1;
    transform: rotateX(0) translateZ(0);
}

.hx-rotor-item.is-leaving {
    opacity: 0;
    transform: rotateX(90deg) translateZ(1.1em);
}

@keyframes hx-fade-up {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ---------- صحنهٔ سه‌بعدی لوگو ---------- */
.home-hero-visual.hx3d {
    max-width: 380px;
    perspective: 1100px;
    perspective-origin: 50% 45%;
}

.hx3d-stage {
    position: absolute;
    inset: 0;
    transform-style: preserve-3d;
    transform: rotateY(calc(var(--hx-px) * 18deg)) rotateX(calc(var(--hx-py) * -14deg));
    transition: transform .2s ease-out;
    will-change: transform;
}

.hx3d-glow {
    position: absolute;
    inset: 4%;
    border-radius: 50%;
    background:
        radial-gradient(circle at 50% 45%, rgba(255, 138, 61, .55), rgba(255, 98, 0, 0) 62%),
        radial-gradient(circle at 50% 60%, rgba(120, 165, 255, .45), rgba(26, 75, 184, 0) 70%);
    filter: blur(22px);
    transform: translateZ(-120px);
    animation: hx3d-pulse 4.5s ease-in-out infinite;
}

@keyframes hx3d-pulse {
    0%, 100% { opacity: .75; transform: translateZ(-120px) scale(1); }
    50%      { opacity: 1;   transform: translateZ(-120px) scale(1.08); }
}

/* حلقه‌های مداری */
.hx3d-ring {
    position: absolute;
    inset: 2%;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, .28);
    transform-style: preserve-3d;
}

.hx3d-ring::before {
    content: '';
    position: absolute;
    top: -.45rem;
    inset-inline-start: 50%;
    width: .9rem;
    height: .9rem;
    margin-inline-start: -.45rem;
    border-radius: 50%;
    background: var(--xco-secondary, #ff6200);
    box-shadow: 0 0 .9rem 2px rgba(255, 138, 61, .85);
}

.hx3d-ring-1 {
    transform: rotateX(72deg) rotateZ(0deg);
    animation: hx3d-spin-a 14s linear infinite;
}

.hx3d-ring-2 {
    inset: 10%;
    border-color: rgba(255, 255, 255, .18);
    border-style: dashed;
    transform: rotateX(72deg) rotateY(38deg) rotateZ(0deg);
    animation: hx3d-spin-b 20s linear infinite reverse;
}

.hx3d-ring-2::before { background: #7fb0ff; box-shadow: 0 0 .9rem 2px rgba(127, 176, 255, .85); }

@keyframes hx3d-spin-a {
    to { transform: rotateX(72deg) rotateZ(360deg); }
}

@keyframes hx3d-spin-b {
    to { transform: rotateX(72deg) rotateY(38deg) rotateZ(360deg); }
}

/* مدال لوگو */
.hx3d-medal {
    position: absolute;
    inset: 17%;
    transform-style: preserve-3d;
    animation: hx3d-sway 9s ease-in-out infinite;
}

@keyframes hx3d-sway {
    0%, 100% { transform: rotateY(-14deg) rotateX(4deg) translateY(0); }
    50%      { transform: rotateY(14deg) rotateX(-3deg) translateY(-.55rem); }
}

/* ضخامت مدال: چند لایه‌ی پشت‌سرهم در محور Z */
.hx3d-edge {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    background: linear-gradient(145deg, #1a4bb8, #001f5c);
    transform: translateZ(calc(var(--d) * -1px));
}

.hx3d-edge:nth-child(1) { --d: 2; }
.hx3d-edge:nth-child(2) { --d: 5; }
.hx3d-edge:nth-child(3) { --d: 8; }
.hx3d-edge:nth-child(4) { --d: 11; }
.hx3d-edge:nth-child(5) { --d: 14; background: #001440; box-shadow: 0 0 0 1px rgba(255, 255, 255, .08); }

.hx3d-face {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    background:
        radial-gradient(circle at 32% 26%, #ffffff 0%, #f4f7ff 45%, #dfe8fb 100%);
    border: 4px solid rgba(255, 255, 255, .9);
    box-shadow:
        inset 0 -1.2rem 2rem rgba(0, 48, 135, .14),
        inset 0 .5rem 1rem rgba(255, 255, 255, .9),
        0 0 0 6px rgba(255, 255, 255, .14);
    display: flex;
    align-items: center;
    justify-content: center;
    transform: translateZ(6px);
    overflow: hidden;
}

.hx3d-logo {
    width: 66%;
    height: auto;
    display: block;
    transform: translateZ(26px);
    filter: drop-shadow(0 .5rem .45rem rgba(0, 31, 92, .28));
    user-select: none;
    -webkit-user-drag: none;
}

/* براقی که روی مدال می‌گذرد */
.hx3d-shine {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    background: linear-gradient(115deg, transparent 35%, rgba(255, 255, 255, .75) 50%, transparent 65%);
    background-size: 260% 100%;
    background-position: 170% 0;
    mix-blend-mode: soft-light;
    animation: hx3d-glint 5.5s ease-in-out 1.2s infinite;
    transform: translateZ(8px);
    pointer-events: none;
}

@keyframes hx3d-glint {
    0%, 50% { background-position: 170% 0; }
    100%    { background-position: -70% 0; }
}

/* آیکون‌های خدمات: شناور در عمق‌های مختلف */
.hx3d-chip {
    position: absolute;
    width: 3.5rem;
    height: 3.5rem;
    border-radius: 1.1rem;
    background: linear-gradient(145deg, #fff, #e8eefb);
    box-shadow:
        0 .9rem 1.6rem rgba(0, 12, 40, .35),
        inset 0 -.25rem .4rem rgba(0, 48, 135, .1),
        inset 0 .15rem .3rem #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.55rem;
    color: var(--xco-primary, #003087);
    transform: translateZ(var(--z, 60px));
    animation: hx3d-bob 5.5s ease-in-out infinite;
    animation-delay: var(--delay, 0s);
}

@keyframes hx3d-bob {
    0%, 100% { translate: 0 0; }
    50%      { translate: 0 -.7rem; }
}

.hx3d-chip-1 { top: 4%;  inset-inline-start: -2%; color: var(--xco-secondary, #ff6200); --z: 90px; --delay: 0s; }
.hx3d-chip-2 { top: 14%; inset-inline-end: -4%;   color: #0ea5e9;                          --z: 60px; --delay: .9s; }
.hx3d-chip-3 { bottom: 12%; inset-inline-end: -2%; color: #16a34a;                         --z: 110px; --delay: 1.8s; }
.hx3d-chip-4 { bottom: 4%; inset-inline-start: 8%; color: var(--xco-primary, #003087);     --z: 70px; --delay: 2.7s; }
.hx3d-chip-5 { top: 46%; inset-inline-start: -9%; color: #eab308;                          --z: 40px; --delay: 3.6s; width: 3rem; height: 3rem; font-size: 1.3rem; }

/* سایهٔ کف */
.hx3d-floor {
    position: absolute;
    left: 14%;
    right: 14%;
    bottom: -7%;
    height: 12%;
    border-radius: 50%;
    background: radial-gradient(ellipse at center, rgba(0, 8, 32, .5), rgba(0, 8, 32, 0) 70%);
    filter: blur(6px);
    transform: translateZ(-160px) rotateX(75deg);
    animation: hx3d-floor 9s ease-in-out infinite;
}

@keyframes hx3d-floor {
    0%, 100% { transform: translateZ(-160px) rotateX(75deg) scale(1); opacity: .9; }
    50%      { transform: translateZ(-160px) rotateX(75deg) scale(.86); opacity: .6; }
}

/* ---------- ریسپانسیو ---------- */
@media (max-width: 991.98px) {
    .home-hero-visual.hx3d { max-width: 300px; margin-top: .5rem; }
    .hx3d-chip { width: 3rem; height: 3rem; font-size: 1.3rem; border-radius: .95rem; }
    .hx3d-chip-5 { width: 2.6rem; height: 2.6rem; font-size: 1.1rem; }
    .hx-rotor { min-width: 8.5em; }
}

@media (max-width: 575.98px) {
    .home-hero-visual.hx3d { max-width: 260px; }
    .hx-title { line-height: 1.6; }
}

/* ---------- کاهش حرکت ---------- */
@media (prefers-reduced-motion: reduce) {
    .hx-word { animation: none; opacity: 1; transform: none; }
    .hx-line-accent .hx-word::after { animation: none; display: none; }
    .hx-rotor-line { animation: none; opacity: 1; }
    .hx-rotor-item { transition: none; }
    .hx3d-stage, .hx-title { transform: none !important; transition: none; }
    .hx3d-glow, .hx3d-ring-1, .hx3d-ring-2, .hx3d-medal, .hx3d-shine, .hx3d-chip, .hx3d-floor { animation: none; }
    .hx3d-medal { transform: rotateY(-8deg) rotateX(3deg); }
}

/* وقتی hero خارج از دید است، انیمیشن‌ها متوقف می‌شوند (صرفه‌جویی باتری) */
.home-hero.hx-paused .hx3d-glow,
.home-hero.hx-paused .hx3d-ring,
.home-hero.hx-paused .hx3d-medal,
.home-hero.hx-paused .hx3d-shine,
.home-hero.hx-paused .hx3d-chip,
.home-hero.hx-paused .hx3d-floor,
.home-hero.hx-paused .hx-word::after {
    animation-play-state: paused;
}
