:root {
    --sky: #38bdf8;
    --sky-dim: rgba(56,189,248,0.12);
    --sky-glow: rgba(56,189,248,0.35);
    --bg: #060b14;
    --bg2: #0c1422;
    --bg3: #101c2e;
    --text: #e2eaf4;
    --muted: #7a93b0;
    --border: rgba(56,189,248,0.12);
    --card: rgba(16,28,46,0.85);
    --green: #34d399;
    --red: #f87171;
    --orange: #fbbf24;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; overflow-x: hidden; }

body {
    background: var(--bg);
    color: var(--text);
    font-family: 'Vazirmatn','Tahoma', sans-serif;
    min-height: 100vh;
    overflow-x: hidden;
    line-height: 1.75;
}

body::before {
    content: "";
    position: fixed; inset: 0;
    background-image:
        linear-gradient(rgba(56,189,248,0.025) 1px, transparent 1px),
        linear-gradient(90deg, rgba(56,189,248,0.025) 1px, transparent 1px);
    background-size: 55px 55px;
    z-index: 0; pointer-events: none;
}

section, nav, footer, header { position: relative; z-index: 1; }

/* ── NAV ── */
.navbar {
    position: fixed; top: 0; left: 0; right: 0; z-index: 1000;
    background: rgba(6,11,20,0.9);
    backdrop-filter: blur(18px);
    border-bottom: 1px solid var(--border);
}
.nav-inner {
    max-width: 1100px; margin: 0 auto;
    padding: 0 24px; height: 64px;
    display: flex; align-items: center; justify-content: space-between;
}
.nav-brand {
    display: flex; align-items: center; gap: 10px;
    font-family: 'Space Mono', monospace;
    font-size: 1.1rem; font-weight: 700;
    color: var(--sky); text-decoration: none;
}
.nav-lock {
    width: 30px; height: 30px;
    background: var(--sky-dim); border: 1px solid rgba(56,189,248,0.3);
    border-radius: 7px; display: flex; align-items: center; justify-content: center;
}
.nav-right { display: flex; align-items: center; gap: 16px; }
.nav-back {
    color: var(--muted); text-decoration: none; font-size: 0.88rem;
    display: flex; align-items: center; gap: 6px;
    padding: 6px 14px; border-radius: 8px; border: 1px solid var(--border);
    transition: all 0.2s;
}
.nav-back:hover { color: var(--sky); border-color: rgba(56,189,248,0.3); background: var(--sky-dim); }

.lang-btn {
    background: var(--sky-dim); border: 1px solid var(--border);
    color: var(--sky); padding: 5px 14px; border-radius: 20px;
    cursor: pointer; font-family: 'Vazirmatn','Tahoma', sans-serif;
    font-size: 0.82rem; transition: all 0.2s;
}
.lang-btn:hover { background: rgba(56,189,248,0.22); border-color: var(--sky); }

/* ── PAGE HERO ── */
.page-hero {
    padding: 120px 24px 70px;
    text-align: center;
    background: radial-gradient(ellipse at 50% 0%, rgba(56,189,248,0.09) 0%, transparent 65%);
}
.page-tag {
    display: inline-flex; align-items: center; gap: 8px;
    background: var(--sky-dim); border: 1px solid rgba(56,189,248,0.25);
    color: var(--sky); padding: 5px 16px; border-radius: 20px;
    font-size: 0.78rem; font-family: 'Space Mono', monospace;
    margin-bottom: 24px;
}
.page-hero h1 {
    font-size: clamp(2rem, 5vw, 3.4rem);
    font-weight: 800; color: #fff; line-height: 1.2;
    margin-bottom: 20px;
}
.page-hero h1 .sky { color: var(--sky); }
.page-hero p.lead {
    font-size: 1.05rem; color: var(--muted);
    max-width: 640px; margin: 0 auto 36px;
}

.toc {
    display: flex; flex-wrap: wrap; justify-content: center;
    gap: 10px; margin-top: 10px;
}
.toc a {
    color: var(--muted); text-decoration: none; font-size: 0.82rem;
    padding: 6px 14px; border-radius: 20px;
    border: 1px solid var(--border); transition: all 0.2s;
}
.toc a:hover { color: var(--sky); border-color: rgba(56,189,248,0.3); background: var(--sky-dim); }

/* ── LAYOUT ── */
.container { max-width: 1100px; margin: 0 auto; padding: 0 24px; }
.section { padding: 72px 24px; }
.section-alt { background: var(--bg2); }

.section-label {
    display: inline-flex; align-items: center; gap: 8px;
    font-family: 'Space Mono', monospace; font-size: 0.72rem;
    color: var(--sky); letter-spacing: 1px; text-transform: uppercase;
    margin-bottom: 14px;
}
.section-label::before { content: ""; width: 20px; height: 1px; background: var(--sky); }

h2.sec-title {
    font-size: clamp(1.5rem, 3vw, 2.2rem);
    font-weight: 800; color: #fff; margin-bottom: 14px;
}
p.sec-desc {
    color: var(--muted); font-size: 0.97rem;
    max-width: 640px; margin-bottom: 48px; line-height: 1.85;
}

/* ── CARDS ── */
.card {
    background: var(--card); border: 1px solid var(--border);
    border-radius: 16px; padding: 28px;
    transition: all 0.3s; position: relative; overflow: hidden;
}
.card:hover {
    border-color: rgba(56,189,248,0.25);
    box-shadow: 0 12px 40px rgba(56,189,248,0.07);
    transform: translateY(-4px);
}
.card-icon {
    width: 48px; height: 48px;
    background: var(--sky-dim); border: 1px solid var(--border);
    border-radius: 12px; display: flex; align-items: center;
    justify-content: center; color: var(--sky); margin-bottom: 18px;
    font-size: 1.2rem;
}
.card h4 { font-size: 1rem; font-weight: 700; color: #fff; margin-bottom: 10px; }
.card p { font-size: 0.88rem; color: var(--muted); line-height: 1.75; }

.grid-3 { display: grid; grid-template-columns: repeat(3,1fr); gap: 20px; min-width: 0; }
.grid-2 { display: grid; grid-template-columns: repeat(2,1fr); gap: 20px; min-width: 0; }
.grid-2 > * { min-width: 0; overflow: hidden; }

/* ── WHO KNOWS WHAT ── */
.know-grid { display: grid; grid-template-columns: repeat(3,1fr); gap: 16px; margin-top: 36px; }
.know-card {
    background: var(--card); border: 1px solid var(--border);
    border-radius: 14px; padding: 22px; text-align: center;
}
.know-card .actor { font-size: 2rem; margin-bottom: 10px; }
.know-card h5 { font-size: 0.92rem; font-weight: 700; color: #fff; margin-bottom: 14px; }
.know-row {
    display: flex; align-items: center; justify-content: space-between;
    padding: 6px 0; border-bottom: 1px solid rgba(255,255,255,0.05);
    font-size: 0.78rem;
}
.know-row:last-child { border-bottom: none; }
.know-row .label { color: var(--muted); }
.tick-yes { color: var(--green); font-weight: 700; }
.tick-no  { color: var(--red);   font-weight: 700; }

/* ── FLOW DIAGRAM ── */
.flow-wrap {
    background: var(--card); border: 1px solid var(--border);
    border-radius: 20px; padding: 36px; overflow-x: auto;
}
.flow { display: flex; align-items: center; gap: 0; }
.flow-node {
    display: flex; flex-direction: column; align-items: center;
    gap: 10px; flex: 1;
}
.flow-box {
    background: var(--bg3); border: 1px solid var(--border);
    border-radius: 12px; padding: 14px 18px; text-align: center;
    width: 100%; max-width: 160px; transition: border-color 0.3s;
}
.flow-box:hover { border-color: rgba(56,189,248,0.4); }
.flow-box .fb-icon { font-size: 1.5rem; margin-bottom: 6px; }
.flow-box .fb-label { font-size: 0.72rem; color: var(--muted); }
.flow-box .fb-title { font-size: 0.82rem; font-weight: 700; color: #fff; }
.flow-box.highlight { border-color: rgba(56,189,248,0.5); background: rgba(56,189,248,0.07); }
.flow-box.highlight .fb-title { color: var(--sky); }

.flow-arrow {
    display: flex; flex-direction: column; align-items: center;
    gap: 4px; flex-shrink: 0; padding: 0 4px;
}
.flow-arrow .arr-line {
    width: 40px; height: 2px;
    background: linear-gradient(90deg, var(--border), rgba(56,189,248,0.4));
}
.flow-arrow .arr-head { font-size: 0.7rem; color: var(--sky); }
.flow-arrow .arr-label { font-size: 0.6rem; color: var(--muted); white-space: nowrap; }

/* ── STEP LIST ── */
.steps { display: flex; flex-direction: column; gap: 16px; }
.step {
    display: flex; gap: 18px; align-items: flex-start;
    background: var(--card); border: 1px solid var(--border);
    border-radius: 14px; padding: 20px 22px; transition: all 0.25s;
}
.step:hover { border-color: rgba(56,189,248,0.25); }
.step-num {
    width: 34px; height: 34px; flex-shrink: 0;
    background: var(--sky-dim); border: 1px solid rgba(56,189,248,0.3);
    border-radius: 9px; display: flex; align-items: center; justify-content: center;
    font-family: 'Space Mono', monospace; font-size: 0.78rem; color: var(--sky); font-weight: 700;
}
.step-content h5 { font-size: 0.96rem; font-weight: 700; color: #fff; margin-bottom: 5px; }
.step-content p { font-size: 0.85rem; color: var(--muted); line-height: 1.7; }

/* ── CODE BLOCK ── */
.code-block {
    background: #050c18; border: 1px solid rgba(56,189,248,0.15);
    border-radius: 14px; padding: 24px; overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    font-family: 'Space Mono', monospace; font-size: 0.78rem;
    line-height: 1.9; color: #a0c4e0;
    max-width: 100%; word-break: break-word;
}
.code-block .c-comment { color: #4a7a9b; }
.code-block .c-key     { color: var(--sky); }
.code-block .c-val     { color: var(--green); }
.code-block .c-fn      { color: #c084fc; }
.code-block .c-warn    { color: var(--orange); }

/* ── COMPARE TABLE ── */
.compare-table {
    width: 100%; border-collapse: collapse; margin-top: 36px;
}
.compare-table th {
    background: var(--bg3); color: var(--sky);
    font-family: 'Space Mono', monospace; font-size: 0.78rem;
    padding: 14px 18px; text-align: right; border-bottom: 1px solid var(--border);
    font-weight: 700;
}
.compare-table th:first-child { border-radius: 12px 0 0 0; }
.compare-table th:last-child  { border-radius: 0 12px 0 0; }
.compare-table td {
    padding: 13px 18px; font-size: 0.85rem; color: var(--text);
    border-bottom: 1px solid rgba(255,255,255,0.04);
    white-space: nowrap;
}
.compare-table tr:hover td { background: rgba(56,189,248,0.03); }
.compare-table td:first-child { color: var(--muted); font-size: 0.82rem; white-space: normal; }
.badge-yes  { color: var(--green);  font-weight: 700; font-size: 0.8rem; }
.badge-no   { color: var(--red);    font-weight: 700; font-size: 0.8rem; }
.badge-part { color: var(--orange); font-weight: 700; font-size: 0.8rem; }

/* ── ANALOGY BOX ── */
.analogy {
    background: rgba(56,189,248,0.05); border: 1px solid rgba(56,189,248,0.2);
    border-right: 3px solid var(--sky);
    border-radius: 12px; padding: 20px 24px; margin: 24px 0;
}
.analogy .anl-label {
    font-size: 0.72rem; color: var(--sky); font-family: 'Space Mono', monospace;
    font-weight: 700; margin-bottom: 8px; letter-spacing: 1px;
}
.analogy p { font-size: 0.9rem; color: var(--text); line-height: 1.8; }

/* ── HIGHLIGHT / WARN BOXES ── */
.highlight-box {
    background: rgba(52,211,153,0.06); border: 1px solid rgba(52,211,153,0.2);
    border-radius: 12px; padding: 18px 22px; margin-top: 20px;
    display: flex; gap: 12px; align-items: flex-start;
}
.warn-box {
    background: rgba(251,191,36,0.06); border: 1px solid rgba(251,191,36,0.2);
    border-radius: 12px; padding: 18px 22px; margin-top: 20px;
    display: flex; gap: 12px; align-items: flex-start;
}
.highlight-box .hb-icon,
.warn-box .hb-icon { font-size: 1.2rem; flex-shrink: 0; margin-top: 2px; }
.highlight-box p,
.warn-box p { font-size: 0.88rem; color: var(--text); line-height: 1.75; }

/* ── CRYPTO PIPELINE ── */
.pipeline {
    background: var(--card); border: 1px solid var(--border);
    border-radius: 20px; padding: 32px; margin-top: 36px;
}
.pipeline-title {
    font-family: 'Space Mono', monospace; font-size: 0.78rem;
    color: var(--sky); margin-bottom: 24px; font-weight: 700;
    display: flex; align-items: center; gap: 8px;
}
.pipeline-title::after {
    content: ""; flex: 1; height: 1px;
    background: linear-gradient(90deg, var(--border), transparent);
}
.pipe-row { display: flex; align-items: stretch; gap: 0; margin-bottom: 12px; }
.pipe-step {
    flex: 1; background: var(--bg3); border: 1px solid var(--border);
    border-radius: 10px; padding: 14px 16px; position: relative;
}
.pipe-step + .pipe-step { margin-right: 8px; }
.pipe-step .ps-num {
    font-family: 'Space Mono', monospace; font-size: 0.65rem;
    color: var(--sky); margin-bottom: 4px; font-weight: 700;
}
.pipe-step .ps-title { font-size: 0.82rem; font-weight: 700; color: #fff; }
.pipe-step .ps-algo  { font-family: 'Space Mono', monospace; font-size: 0.68rem; color: var(--sky); margin-top: 4px; }
.pipe-step .ps-desc  { font-size: 0.72rem; color: var(--muted); margin-top: 4px; line-height: 1.6; }
.pipe-step.enc { border-color: rgba(56,189,248,0.3); }
.pipe-step.dec { border-color: rgba(52,211,153,0.3); }

/* ── FAQ ACCORDION ── */
.faq-list { display: flex; flex-direction: column; gap: 10px; margin-top: 36px; }
.faq-item {
    background: var(--card); border: 1px solid var(--border);
    border-radius: 12px; overflow: hidden; transition: border-color 0.25s;
}
.faq-item.open { border-color: rgba(56,189,248,0.3); }
.faq-q {
    padding: 18px 22px; cursor: pointer;
    display: flex; align-items: center; justify-content: space-between;
    gap: 12px; user-select: none;
}
.faq-q span { font-size: 0.95rem; font-weight: 600; color: #fff; }
.faq-icon {
    width: 24px; height: 24px; flex-shrink: 0;
    background: var(--sky-dim); border-radius: 6px;
    display: flex; align-items: center; justify-content: center;
    color: var(--sky); font-size: 0.9rem; transition: transform 0.3s;
}
.faq-item.open .faq-icon { transform: rotate(45deg); }
.faq-a { max-height: 0; overflow: hidden; transition: max-height 0.4s cubic-bezier(0.4,0,0.2,1); }
.faq-item.open .faq-a { max-height: 400px; }
.faq-a-inner {
    padding: 16px 22px 18px; font-size: 0.88rem;
    color: var(--muted); line-height: 1.8;
    border-top: 1px solid var(--border);
}

/* ── FOOTER ── */
footer {
    background: rgba(6,11,20,0.95); border-top: 1px solid var(--border);
    padding: 36px 24px; text-align: center;
}
.footer-brand {
    font-family: 'Space Mono', monospace; font-size: 1.2rem;
    font-weight: 700; color: var(--sky); margin-bottom: 8px;
}
.footer-sub { font-size: 0.8rem; color: var(--muted); }

/* ── REVEAL ANIMATION ── */
.reveal { opacity: 0; transform: translateY(24px); transition: all 0.55s cubic-bezier(0.4,0,0.2,1); }
.reveal.visible { opacity: 1; transform: translateY(0); }

/* ── RESPONSIVE ── */
@media (max-width: 860px) {
    .grid-3 { grid-template-columns: 1fr 1fr; }
    .know-grid { grid-template-columns: 1fr; }

    .flow-wrap { overflow-x: hidden; padding: 24px 16px; }
    .flow { flex-direction: column; align-items: center; min-width: unset; gap: 0; }
    .flow-node { width: 100%; max-width: 280px; }
    .flow-box  { max-width: 100%; }
    .flow-arrow { flex-direction: row; padding: 6px 0; gap: 6px; }
    .flow-arrow .arr-line { width: 2px; height: 28px; background: linear-gradient(180deg, var(--border), rgba(56,189,248,0.4)); }
    .flow-arrow .arr-head { transform: rotate(90deg); }

    .pipe-row { flex-direction: column; gap: 10px; }
    .pipe-step + .pipe-step { margin-right: 0; }

    .code-block { font-size: 0.7rem; }
}

@media (max-width: 600px) {
    .grid-3, .grid-2 { grid-template-columns: 1fr; }
    .page-hero { padding: 100px 16px 50px; }
    .section { padding: 56px 16px; }
    .container { padding: 0 16px; }
    .toc { gap: 6px; }
    .toc a { font-size: 0.75rem; padding: 5px 10px; }
    .pipeline { padding: 20px 16px; }
    .code-block { padding: 16px; font-size: 0.66rem; }
    .flow-node { max-width: 240px; }
    .highlight-box, .warn-box { flex-direction: column; gap: 8px; }
    .step { flex-direction: column; gap: 10px; }
    h2.sec-title { font-size: 1.4rem; }
    .compare-table th, .compare-table td { padding: 10px 12px; font-size: 0.78rem; }
}

/* ── LTR OVERRIDES ── */
html[dir="ltr"] .section-label::before { display: none; }
html[dir="ltr"] .section-label::after  { content: ""; width: 20px; height: 1px; background: var(--sky); }
html[dir="ltr"] .analogy { border-right: none; border-left: 3px solid var(--sky); }
html[dir="ltr"] .flow-arrow .arr-line  { background: linear-gradient(90deg, rgba(56,189,248,0.4), var(--border)); }
html[dir="ltr"] .compare-table th      { text-align: left; }
html[dir="ltr"] .pipe-step + .pipe-step { margin-right: 0; margin-left: 8px; }
