/* ════════════════════════════════════════════════════════════════
   یک‌ریال — Design tokens (light + dark)
   ----------------------------------------------------------------
   رنگ‌ها فقط اینجا تعریف می‌شوند. بقیهٔ CSSها از var(--…) استفاده
   می‌کنند، پس با عوض شدن data-theme روی <html> همه‌چیز عوض می‌شود.
   - data-theme="light" | "dark"  (با دکمهٔ تم، در localStorage)
   - اگر کاربر چیزی انتخاب نکرده، از تنظیم سیستم پیروی می‌شود.
   ════════════════════════════════════════════════════════════════ */

:root,
:root[data-theme="light"] {
    color-scheme: light;

    /* Brand — Binance-style yellow */
    --brand-gold: #F0B90B;
    --brand-gold-2: #FCD535;
    --brand-navy: #181A20;

    /* Surfaces */
    --bg: #FAFAFA;
    --bg-2: #F5F5F5;
    --surface: #FFFFFF;
    --surface-2: #F5F5F5;
    --surface-3: #EAECEF;
    --surface-glass: rgb(255 255 255 / 0.86);
    --border: #EAECEF;
    --border-strong: #D8DCE1;

    /* Text */
    --text: #1E2329;
    --text-2: #474D57;
    --muted: #707A8A;
    --faint: #929AA5;

    /* Accent
       --accent: برای متن/حاشیه (در تم روشن طلایی تیره‌تر تا خوانا باشد)
       --accent-fill: رنگ دکمه‌های اصلی (زرد بایننسی) با متن --accent-ink */
    --accent: #B07F00;
    --accent-strong: #8A6400;
    --accent-soft: #FEF6D8;
    --accent-fill: #FCD535;
    --accent-fill-2: #F0B90B;
    --accent-ink: #181A20;
    --accent-2: #F0B90B;

    /* Market */
    --up: #03A66D;
    --up-soft: #E6F7F0;
    --down: #CF304A;
    --down-soft: #FDECEF;
    --gold: #C99400;

    /* Overlays & depth
       --ink: رنگ «روکش» — در تم تیره سفید، در تم روشن تیره.
       --shadow: رنگ سایه با آلفای پایه (color-mix آلفا را ضرب می‌کند). */
    --ink: rgb(30 35 41 / 0.9);
    --shadow: rgb(24 26 32 / 0.28);
    --elev-1: 0 1px 2px rgb(24 26 32 / 0.04), 0 2px 6px rgb(24 26 32 / 0.04);
    --elev-2: 0 2px 4px rgb(24 26 32 / 0.04), 0 12px 28px rgb(24 26 32 / 0.08);
    --elev-3: 0 8px 20px rgb(24 26 32 / 0.08), 0 28px 64px rgb(24 26 32 / 0.12);

    --aurora-1: rgb(252 213 53 / 0.10);
    --aurora-2: rgb(240 185 11 / 0.05);
    --aurora-3: transparent;

    --focus: #F0B90B;
}

:root[data-theme="dark"] {
    color-scheme: dark;

    /* Binance-style dark: near-black greys + yellow */
    --bg: #0B0E11;
    --bg-2: #12161C;
    --surface: #181A20;
    --surface-2: #1E2329;
    --surface-3: #2B3139;
    --surface-glass: rgb(24 26 32 / 0.82);
    --border: #2B3139;
    --border-strong: #3C434D;

    --text: #EAECEF;
    --text-2: #C4C9D1;
    --muted: #848E9C;
    --faint: #5E6673;

    --accent: #F0B90B;
    --accent-strong: #FCD535;
    --accent-soft: rgb(240 185 11 / 0.12);
    --accent-fill: #FCD535;
    --accent-fill-2: #F0B90B;
    --accent-ink: #181A20;
    --accent-2: #F8D12F;

    --up: #0ECB81;
    --up-soft: rgb(14 203 129 / 0.12);
    --down: #F6465D;
    --down-soft: rgb(246 70 93 / 0.12);
    --gold: #F0B90B;

    --ink: rgb(255 255 255);
    --shadow: rgb(0 0 0 / 1);
    --elev-1: 0 1px 2px rgb(0 0 0 / 0.25);
    --elev-2: 0 4px 6px rgb(0 0 0 / 0.2), 0 16px 40px rgb(0 0 0 / 0.35);
    --elev-3: 0 10px 24px rgb(0 0 0 / 0.35), 0 32px 72px rgb(0 0 0 / 0.5);

    --aurora-1: rgb(240 185 11 / 0.06);
    --aurora-2: rgb(240 185 11 / 0.03);
    --aurora-3: transparent;

    --focus: #FCD535;
}

/* بدون جاوااسکریپت: از تنظیم سیستم پیروی کن */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme]) {
    color-scheme: dark;

    /* Binance-style dark: near-black greys + yellow */
    --bg: #0B0E11;
    --bg-2: #12161C;
    --surface: #181A20;
    --surface-2: #1E2329;
    --surface-3: #2B3139;
    --surface-glass: rgb(24 26 32 / 0.82);
    --border: #2B3139;
    --border-strong: #3C434D;

    --text: #EAECEF;
    --text-2: #C4C9D1;
    --muted: #848E9C;
    --faint: #5E6673;

    --accent: #F0B90B;
    --accent-strong: #FCD535;
    --accent-soft: rgb(240 185 11 / 0.12);
    --accent-fill: #FCD535;
    --accent-fill-2: #F0B90B;
    --accent-ink: #181A20;
    --accent-2: #F8D12F;

    --up: #0ECB81;
    --up-soft: rgb(14 203 129 / 0.12);
    --down: #F6465D;
    --down-soft: rgb(246 70 93 / 0.12);
    --gold: #F0B90B;

    --ink: rgb(255 255 255);
    --shadow: rgb(0 0 0 / 1);
    --elev-1: 0 1px 2px rgb(0 0 0 / 0.25);
    --elev-2: 0 4px 6px rgb(0 0 0 / 0.2), 0 16px 40px rgb(0 0 0 / 0.35);
    --elev-3: 0 10px 24px rgb(0 0 0 / 0.35), 0 32px 72px rgb(0 0 0 / 0.5);

    --aurora-1: rgb(240 185 11 / 0.06);
    --aurora-2: rgb(240 185 11 / 0.03);
    --aurora-3: transparent;

    --focus: #FCD535;
    }
}

/* ── Shared scales ─────────────────────────────────── */
:root {
    --font: 'Vazirmatn', 'Yekan', system-ui, -apple-system, 'Segoe UI', Tahoma, sans-serif;
    --r-sm: 10px;
    --r-md: 14px;
    --r-lg: 20px;
    --r-xl: 26px;
    --ease: cubic-bezier(0.22, 1, 0.36, 1);
    --spring: cubic-bezier(0.34, 1.56, 0.64, 1);
    --page-max: 1240px;
}

/* ── Base ──────────────────────────────────────────── */
html {
    background-color: var(--bg);
    -webkit-text-size-adjust: 100%;
    scroll-behavior: smooth;
}

html, body {
    font-family: var(--font) !important;
    color: var(--text);
    margin: 0;
    width: 100%;
    overflow-x: clip;
}

body {
    background-color: var(--bg) !important;
    background-image:
        radial-gradient(60rem 36rem at 100% -8%, var(--aurora-1), transparent 60%),
        radial-gradient(48rem 30rem at -10% 18%, var(--aurora-2), transparent 62%),
        radial-gradient(50rem 40rem at 50% 115%, var(--aurora-3), transparent 60%) !important;
    background-attachment: fixed !important;
    font-feature-settings: "tnum";
    -webkit-font-smoothing: antialiased;
    transition: background-color .35s var(--ease), color .35s var(--ease);
}

::selection {
    background: color-mix(in srgb, var(--accent) 28%, transparent);
    color: var(--text);
}

:focus-visible {
    outline: 3px solid var(--focus);
    outline-offset: 2px;
    border-radius: 6px;
}

/* Scrollbar */
* { scrollbar-color: var(--border-strong) transparent; scrollbar-width: thin; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 10px; border: 2px solid var(--bg); }
::-webkit-scrollbar-track { background: transparent; }

/* ── Brand mark (logo) ─────────────────────────────── */
.yr-mark {
    --size: 40px;
    position: relative;
    width: var(--size);
    height: var(--size);
    border-radius: calc(var(--size) * 0.3);
    background: linear-gradient(145deg, var(--brand-gold-2), var(--brand-gold) 55%, #DEA200);
    color: var(--brand-navy);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-family: 'Vazirmatn', sans-serif;
    font-weight: 900;
    font-size: calc(var(--size) * 0.6);
    line-height: 1;
    flex-shrink: 0;
    overflow: hidden;
    box-shadow: 0 6px 18px rgb(240 185 11 / 0.3), inset 0 1px 0 rgb(255 255 255 / 0.55), inset 0 -2px 0 rgb(0 0 0 / 0.08);
    isolation: isolate;
}

.yr-mark > span { transform: translateY(4%); }

/* درخشش سکه‌ای که هر چند ثانیه از روی لوگو رد می‌شود */
.yr-mark::after {
    content: '';
    position: absolute;
    inset: -40% auto -40% -60%;
    width: 45%;
    background: linear-gradient(90deg, transparent, rgb(255 255 255 / 0.75), transparent);
    transform: skewX(-20deg) translateX(0);
    animation: yr-shine 5.5s var(--ease) 1.2s infinite;
    z-index: 1;
    pointer-events: none;
}

@keyframes yr-shine {
    0% { transform: skewX(-20deg) translateX(0); }
    22%, 100% { transform: skewX(-20deg) translateX(420%); }
}

.yr-wordmark {
    display: flex;
    flex-direction: column;
    line-height: 1.05;
}

.yr-wordmark-fa {
    font-size: 1.32rem;
    font-weight: 900;
    color: var(--text);
    letter-spacing: -0.01em;
}

.yr-wordmark-en {
    font-size: 0.62rem;
    font-weight: 700;
    letter-spacing: 0.24em;
    color: var(--muted);
    direction: ltr;
    text-align: right;
    margin-top: 2px;
}

/* ── Theme toggle ──────────────────────────────────── */
.yr-theme-toggle {
    --w: 40px;
    position: relative;
    width: var(--w);
    height: var(--w);
    border-radius: 12px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-2);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: var(--elev-1);
    transition: border-color .2s, background .2s, transform .25s var(--spring), color .2s;
    padding: 0;
    flex-shrink: 0;
}

.yr-theme-toggle:hover { border-color: color-mix(in srgb, var(--accent) 45%, transparent); color: var(--accent); }
.yr-theme-toggle:active { transform: scale(0.92); }

.yr-theme-toggle svg {
    position: absolute;
    width: 20px;
    height: 20px;
    transition: transform .5s var(--spring), opacity .3s var(--ease);
}

.yr-theme-toggle .yr-sun { opacity: 0; transform: rotate(-90deg) scale(0.4); }
.yr-theme-toggle .yr-moon { opacity: 1; transform: rotate(0) scale(1); }

:root[data-theme="dark"] .yr-theme-toggle .yr-sun { opacity: 1; transform: rotate(0) scale(1); color: var(--gold); }
:root[data-theme="dark"] .yr-theme-toggle .yr-moon { opacity: 0; transform: rotate(90deg) scale(0.4); }

@media (prefers-color-scheme: dark) {
    :root:not([data-theme]) .yr-theme-toggle .yr-sun { opacity: 1; transform: rotate(0) scale(1); color: var(--gold); }
    :root:not([data-theme]) .yr-theme-toggle .yr-moon { opacity: 0; transform: rotate(90deg) scale(0.4); }
}

/* انیمیشن دایره‌ای تعویض تم (View Transitions) */
::view-transition-old(root),
::view-transition-new(root) {
    animation: none;
    mix-blend-mode: normal;
}

/* ── Live dot ──────────────────────────────────────── */
.yr-live-dot {
    position: relative;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--up);
    flex-shrink: 0;
}

.yr-live-dot::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 50%;
    background: var(--up);
    animation: yr-ping 1.8s cubic-bezier(0, 0, 0.2, 1) infinite;
}

@keyframes yr-ping {
    75%, 100% { transform: scale(2.6); opacity: 0; }
}

/* ── Reveal on scroll ──────────────────────────────── */
.yr-reveal {
    opacity: 0;
    transform: translateY(18px);
    transition: opacity .7s var(--ease), transform .7s var(--ease);
}

.yr-reveal.is-in {
    opacity: 1;
    transform: none;
}

/* ── Generic helpers ───────────────────────────────── */
.yr-page {
    width: 100%;
    max-width: var(--page-max);
    margin: 0 auto;
    padding: 0 1rem;
}

.yr-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-xl);
    box-shadow: var(--elev-1);
}

.yr-num {
    font-variant-numeric: tabular-nums;
    font-feature-settings: "tnum";
}

/* Bootstrap/Tailwind resets that fight the theme */
a { color: var(--accent); }
a:hover { color: var(--accent-strong); }

@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;
    }

    .yr-reveal { opacity: 1; transform: none; }
}
