/* =========================================================================
   صفحه پیگیری سفارش (track.php)
   استایل و انیمیشن‌های اختصاصی، هم‌راستا با تم تیره/طلایی فروشگاه
   ========================================================================= */

.track-card {
    position: relative;
    overflow: hidden;
    padding: 24px 22px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: linear-gradient(160deg, var(--card) 0%, var(--card2) 100%);
    box-shadow: var(--shadow);
}

.track-card::before {
    content: "";
    position: absolute;
    inset-inline: 0;
    top: 0;
    height: 3px;
    background: var(--grad-gold);
}

/* ------------------------------------------------------------- فرم ورود کد */

.track-form { margin-top: 6px; }

.track-input {
    display: flex;
    gap: 10px;
    align-items: stretch;
}

.track-input input {
    flex: 1 1 auto;
    min-width: 0;
    padding: 14px 16px;
    border: 1px solid var(--line2);
    border-radius: 14px;
    background: var(--card2);
    color: var(--text);
    font-family: "JetBrains Mono", Consolas, monospace;
    font-size: 16px;
    letter-spacing: 1.5px;
    text-align: center;
    transition: border-color .2s ease, box-shadow .2s ease, background .2s ease;
}

.track-input input::placeholder { color: var(--faint); letter-spacing: 2px; }

.track-input input:focus {
    outline: none;
    border-color: var(--gold-2);
    background: #fff;
    box-shadow: 0 0 0 4px var(--gold-glow);
}

.track-input .btn {
    flex: 0 0 auto;
    width: auto;
    margin-top: 0;
    padding-inline: 26px;
}

.track-hint {
    margin: 16px 0 0;
    font-size: 12.5px;
    line-height: 2;
    color: var(--muted);
}

.track-card .alert { margin-top: 16px; margin-bottom: 0; }

/* ------------------------------------------------------------- کارت نتیجه */

.track-result {
    position: relative;
    overflow: hidden;
    margin-top: 20px;
    padding: 22px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: linear-gradient(160deg, var(--card) 0%, var(--card2) 100%);
    box-shadow: var(--shadow);
}

/* --------------------------------------------------------- بنر وضعیت فعلی */

.status-hero {
    position: relative;
    overflow: hidden;
    padding: 22px 18px 20px;
    border: 1px solid var(--line2);
    border-radius: 18px;
    text-align: center;
    background:
        radial-gradient(120% 140% at 50% -30%, rgba(197, 160, 89, .22), rgba(197, 160, 89, 0) 70%),
        linear-gradient(160deg, var(--card2), var(--bg2));
}

.status-hero::after {
    content: "";
    position: absolute;
    top: 0;
    bottom: 0;
    width: 45%;
    pointer-events: none;
    background: linear-gradient(90deg, rgba(255, 255, 255, 0) 0%, rgba(255, 255, 255, .7) 50%, rgba(255, 255, 255, 0) 100%);
    transform: translateX(-220%) skewX(-18deg);
    animation: sheen 4s ease-in-out 1s infinite;
}

.status-kicker {
    display: block;
    margin-bottom: 6px;
    font-size: 12px;
    letter-spacing: .4px;
    color: var(--muted);
}

.status-value {
    display: block;
    font-size: 23px;
    font-weight: 900;
    line-height: 1.6;
    color: var(--gold);
}

.status-code {
    display: inline-block;
    margin-top: 12px;
    padding: 4px 14px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: rgba(255, 255, 255, .75);
    font-family: "JetBrains Mono", Consolas, monospace;
    font-size: 12.5px;
    letter-spacing: 2px;
    color: var(--muted);
}

.status-hero.is-pending {
    border-color: rgba(183, 121, 31, .4);
    background:
        radial-gradient(120% 140% at 50% -30%, rgba(240, 180, 41, .2), rgba(240, 180, 41, 0) 70%),
        linear-gradient(160deg, #fffaf0, #fbf2dc);
}
.status-hero.is-pending .status-value { color: var(--warn); }

.status-hero.is-bad {
    border-color: rgba(238, 43, 43, .35);
    background:
        radial-gradient(120% 140% at 50% -30%, rgba(238, 43, 43, .14), rgba(238, 43, 43, 0) 70%),
        linear-gradient(160deg, #fff7f7, #fdeeee);
}
.status-hero.is-bad .status-value { color: var(--err); }
.status-hero.is-bad::after { background: linear-gradient(90deg, rgba(255, 255, 255, 0), rgba(255, 255, 255, .7), rgba(255, 255, 255, 0)); }

/* ---------------------------------------------------------- خط زمانی ارسال */

.timeline {
    list-style: none;
    margin: 26px 0 4px;
    padding: 0;
}

.timeline .step {
    position: relative;
    padding-inline-start: 40px;
    padding-bottom: 24px;
    animation: fadeUp .55s cubic-bezier(.2, .7, .2, 1) both;
    animation-delay: calc(var(--i, 0) * 110ms + 240ms);
}

/* تاخیر پله‌ای بدون استایل اینلاین (سازگار با CSP) */
.timeline .step:nth-child(1) { --i: 0; }
.timeline .step:nth-child(2) { --i: 1; }
.timeline .step:nth-child(3) { --i: 2; }
.timeline .step:nth-child(4) { --i: 3; }
.timeline .step:nth-child(5) { --i: 4; }

.timeline .step:last-child { padding-bottom: 0; }

.timeline .step::before {
    content: "";
    position: absolute;
    inset-inline-start: 13px;
    top: 32px;
    bottom: -2px;
    width: 2px;
    border-radius: 2px;
    background: var(--line);
}

.timeline .step:last-child::before { display: none; }

.timeline .step.done::before {
    background: linear-gradient(180deg, var(--gold-2), var(--gold));
    transform-origin: top;
    animation: lineIn .5s ease both;
    animation-delay: calc(var(--i, 0) * 110ms + 340ms);
}

.timeline .dot {
    position: absolute;
    inset-inline-start: 0;
    top: 2px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border: 2px solid var(--line);
    border-radius: 50%;
    background: var(--card);
    box-sizing: border-box;
}

.timeline .step.todo .dot { opacity: .65; }

.timeline .step.done .dot {
    border-color: var(--gold);
    background: var(--grad-gold);
}

.timeline .step.done .dot::after {
    content: "";
    width: 9px;
    height: 5px;
    border-left: 2px solid #fff;
    border-bottom: 2px solid #fff;
    transform: rotate(-45deg) translate(1px, -1px);
}

.timeline .step.active .dot {
    border-color: var(--gold-2);
    background: var(--card);
    animation: pulseRing 2.2s ease-out infinite;
}

.timeline .step.active .dot::after {
    content: "";
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: var(--gold);
}

.step-title {
    display: block;
    font-size: 14.5px;
    font-weight: 600;
}

.timeline .step.todo .step-title { color: var(--muted); font-weight: 400; }
.timeline .step.active .step-title { color: var(--gold); font-weight: 800; }

.step-time {
    display: block;
    margin-top: 2px;
    font-size: 12px;
    color: var(--muted);
    direction: ltr;
    text-align: right;
}

/* ----------------------------------------------------------- جزئیات و پانوشت */

.track-result .summary { margin-top: 22px; }

.mono-ltr {
    font-family: "JetBrains Mono", Consolas, monospace;
    direction: ltr;
}

.track-note {
    margin: 18px 0 0;
    font-size: 13px;
    line-height: 2;
    color: var(--muted);
}

.track-foot-note {
    margin: 14px 0 0;
    font-size: 11.5px;
    text-align: center;
    color: var(--faint);
}

/* ------------------------------------------------------------------ پویانمایی */

[data-animate] {
    animation: fadeUp .6s cubic-bezier(.2, .7, .2, 1) both;
}

@keyframes fadeUp {
    from { opacity: 0; transform: translateY(14px); }
    to   { opacity: 1; transform: none; }
}

@keyframes lineIn {
    from { transform: scaleY(0); }
    to   { transform: scaleY(1); }
}

@keyframes pulseRing {
    0%   { box-shadow: 0 0 0 0 rgba(197, 160, 89, .5); }
    70%  { box-shadow: 0 0 0 11px rgba(197, 160, 89, 0); }
    100% { box-shadow: 0 0 0 0 rgba(197, 160, 89, 0); }
}

@keyframes sheen {
    0%   { transform: translateX(-220%) skewX(-18deg); }
    60%  { transform: translateX(320%) skewX(-18deg); }
    100% { transform: translateX(320%) skewX(-18deg); }
}

/* --------------------------------------------------------------- واکنش‌گرا */

@media (max-width: 600px) {
    .track-card,
    .track-result { padding: 20px 16px; }

    .track-input { flex-direction: column; }

    .track-input input { text-align: center; }

    .track-input .btn { width: 100%; margin-top: 0; }
}

@media (prefers-reduced-motion: reduce) {
    [data-animate],
    .timeline .step,
    .timeline .step.done::before,
    .status-hero::after,
    .timeline .step.active .dot {
        animation: none !important;
    }
}

/* ==========================================================================
   پیشرفت سفارش، ورود پله‌ای و جزئیات تکمیلی
   ========================================================================== */

.progress {
    position: relative;
    height: 8px;
    margin: 18px auto 2px;
    max-width: 320px;
    border-radius: 99px;
    background: rgba(197, 160, 89, .22);
    overflow: hidden;
}

.progress-fill {
    position: relative;
    display: block;
    height: 100%;
    border-radius: 99px;
    background: var(--grad-gold);
    animation: barGrow 1.1s cubic-bezier(.2, .8, .2, 1) .5s both;
}

.progress-fill::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, rgba(255, 255, 255, 0), rgba(255, 255, 255, .6), rgba(255, 255, 255, 0));
    transform: translateX(-100%);
    animation: barShine 2.6s ease-in-out 1.6s infinite;
}

.pr-0   { width: 8%; }
.pr-25  { width: 25%; }
.pr-33  { width: 33.4%; }
.pr-50  { width: 50%; }
.pr-67  { width: 66.7%; }
.pr-75  { width: 75%; }
.pr-100 { width: 100%; }

@keyframes barGrow { from { transform: scaleX(0); transform-origin: right; } to { transform: scaleX(1); transform-origin: right; } }
@keyframes barShine { to { transform: translateX(100%); } }

/* ردیف‌های جزئیات سفارش */
.track-result .summary .row { animation: fadeUp .5s ease both; }
.track-result .summary .row:nth-child(1) { animation-delay: .7s; }
.track-result .summary .row:nth-child(2) { animation-delay: .78s; }
.track-result .summary .row:nth-child(3) { animation-delay: .86s; }
.track-result .summary .row:nth-child(4) { animation-delay: .94s; }
.track-result .summary .row:nth-child(5) { animation-delay: 1.02s; }
.track-result .summary .row:nth-child(n+6) { animation-delay: 1.1s; }

/* کارت جست‌وجو */
.track-card:focus-within { box-shadow: var(--shadow), 0 0 0 4px rgba(197, 160, 89, .12); transition: box-shadow .3s; }

.track-input .btn.is-loading {
    position: relative;
    overflow: hidden;
    cursor: progress;
}

.track-input .btn.is-loading::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, rgba(255, 255, 255, 0), rgba(255, 255, 255, .35), rgba(255, 255, 255, 0));
    transform: translateX(-100%);
    animation: barShine 1.1s linear infinite;
}

/* کارت وضعیت: ورود با اسکیل ملایم */
.status-hero { animation: heroIn .7s cubic-bezier(.2, .9, .3, 1.1) .15s both; }
@keyframes heroIn { from { opacity: 0; transform: scale(.96) translateY(10px); } to { opacity: 1; transform: none; } }

.track-hint, .track-note, .track-foot-note { animation: fadeUp .6s ease .4s both; }

@media (prefers-reduced-motion: reduce) {
    .progress-fill, .progress-fill::after, .status-hero, .track-result .summary .row,
    .track-hint, .track-note, .track-foot-note, .track-input .btn.is-loading::after {
        animation: none !important;
    }
}