*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
    background-color: var(--color-bg);
    color: var(--color-text);
    font-family: 'Vazirmatn', system-ui, sans-serif;
    direction: rtl;
    overflow-x: hidden;
}

/* ── Design tokens ── */
:root {
    --color-bg:        #080808;
    --color-surface:   #181818;
    --color-border:    #232323;
    --color-border-hi: #3c3c3c;
    --color-muted:     #505050;
    --color-secondary: #737373;
    --color-body:      #b8b8b8;
    --color-text:      #e2e2e2;
    --color-bright:    #f2f2f2;
    --color-white:     #ffffff;
}

/* ── Wave canvases ── */
#hero-canvas, #cta-canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    display: block;
}

/* ══════════════════════════════
    NAVBAR
══════════════════════════════ */
nav {
    position: fixed; top: 0; left: 0; right: 0; z-index: 100;
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 1.5rem; height: 64px;
    background-color: rgba(8,8,8,0.88);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border-bottom: 1px solid var(--color-border);
    gap: 1rem;
}
nav a {
    color: var(--color-body);
    font-size: 0.875rem;
    transition: color .2s;
    text-decoration: none;
    white-space: nowrap;
}
nav a:hover { color: var(--color-bright); }

/* Nav wordmark */
.nav-wordmark {
    font-family: ClashDisplay-SemiBold, sans-serif;
    font-weight: 700;
    letter-spacing: .12em;
    font-size: 1.15rem;
    color: var(--color-bright);
    white-space: nowrap;
}

/* Center links — hidden on mobile */
.nav-links {
    display: flex; gap: 1.75rem; align-items: center;
    flex: 1; justify-content: center;
}
@media (max-width: 767px) {
    .nav-links { display: none; }
}

.btn-nav {
    background-color: var(--color-bright);
    color: var(--color-bg);
    border-radius: 9999px;
    padding: 0.4rem 1.1rem;
    font-size: 0.875rem;
    font-weight: 700;
    text-decoration: none;
    white-space: nowrap;
    flex-shrink: 0;
    transition: background-color .2s;
}
.btn-nav:hover { background-color: var(--color-white); }

/* ══════════════════════════════
    BUTTONS
══════════════════════════════ */
.btn-primary {
    display: inline-flex; align-items: center; gap: 0.5rem;
    background-color: var(--color-bright);
    color: var(--color-bg);
    border-radius: 9999px;
    padding: 0.75rem 1.75rem;
    font-size: 1rem; font-weight: 700;
    text-decoration: none;
    transition: background-color .2s, transform .15s;
}
.btn-primary:hover { background-color: var(--color-white); transform: translateY(-1px); }

.btn-ghost {
    display: inline-flex; align-items: center; gap: 0.5rem;
    border: 1px solid var(--color-border-hi);
    color: var(--color-text);
    border-radius: 9999px;
    padding: 0.75rem 1.75rem;
    font-size: 1rem; font-weight: 500;
    text-decoration: none;
    transition: border-color .2s, color .2s, transform .15s;
}
.btn-ghost:hover {
    border-color: var(--color-body);
    color: var(--color-bright);
    transform: translateY(-1px);
}
@media (max-width: 480px) {
    .btn-primary, .btn-ghost { width: 100%; justify-content: center; }
}

/* ══════════════════════════════
    TYPOGRAPHY
══════════════════════════════ */
.eyebrow {
    font-size: 1rem;
    letter-spacing: 0.12em;
    color: var(--color-secondary);
    text-transform: uppercase;
    font-weight: 600;
}
.section-title {
    font-size: clamp(1.9rem, 5vw, 3.5rem);
    font-weight: 900;
    line-height: 1.2;
    color: var(--color-bright);
}
.section-title .muted { color: var(--color-secondary); }

/* ══════════════════════════════
    CARD
══════════════════════════════ */
.card {
    border: 1px solid var(--color-border);
    border-radius: 1rem;
    padding: 1.75rem;
    background-color: var(--color-surface);
    transition: border-color .25s, background-color .25s;
}
.card:hover {
    border-color: var(--color-border-hi);
    background-color: #1e1e1e;
}

/* ══════════════════════════════
    FEATURE ROWS
══════════════════════════════ */
.feature-row {
    border-top: 1px solid var(--color-border);
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    padding: 1.4rem 0;
    gap: 1.5rem;
}
.feature-row:last-child { border-bottom: 1px solid var(--color-border); }
.feature-row h3 { color: var(--color-bright); flex-shrink: 0; }
.feature-row p  { color: var(--color-body); }
@media (max-width: 600px) {
    .feature-row { flex-direction: column; gap: 0.4rem; align-items: flex-end; }
}

/* ══════════════════════════════
    FACES IMAGE
══════════════════════════════ */
.faces-img {
    width: 100%;
    max-width: 420px;
    border-radius: 0.5rem;
}
@media (max-width: 1023px) {
    .faces-img { max-width: 100%; }
}

/* ══════════════════════════════
    CHAT MOCKUP
══════════════════════════════ */
.chat-bubble-ai {
    background-color: #1e1e1e;
    border: 1px solid var(--color-border-hi);
    border-radius: 1rem;
    padding: 1rem 1.25rem;
    font-size: 0.9rem;
    line-height: 1.7;
    color: var(--color-text);
}
.suggestion-chip {
    display: flex; align-items: center; justify-content: space-between;
    border: 1px solid var(--color-border-hi);
    border-radius: 9999px;
    padding: 0.6rem 1.25rem;
    font-size: 0.85rem;
    color: var(--color-body);
    cursor: pointer;
    transition: border-color .2s, color .2s, background-color .2s;
}
.suggestion-chip:hover {
    border-color: var(--color-body);
    color: var(--color-bright);
    background-color: var(--color-surface);
}

/* ══════════════════════════════
    DOWNLOAD CARDS
══════════════════════════════ */
.dl-card {
    border: 1px solid var(--color-border);
    border-radius: 1rem;
    padding: 1.5rem;
    display: flex; flex-direction: column;
    gap: 0.75rem;
    cursor: pointer;
    background-color: var(--color-surface);
    text-decoration: none;
    transition: border-color .25s, background-color .25s;
}
.dl-card:hover {
    border-color: var(--color-border-hi);
    background-color: #1e1e1e;
}

/* ══════════════════════════════
    CTA SECTION
══════════════════════════════ */
#cta-section { position: relative; overflow: hidden; }

/* ══════════════════════════════
    FOOTER
══════════════════════════════ */
footer { border-top: 1px solid var(--color-border); }
.footer-inner {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 1.5rem;
    flex-wrap: wrap;
}
@media (max-width: 600px) {
    .footer-inner {
    flex-direction: column;
    align-items: flex-end;
    gap: 1.25rem;
    }
    .footer-copyright { align-self: flex-start; }
}

/* ══════════════════════════════
    SCROLL REVEAL
══════════════════════════════ */
.reveal {
    opacity: 0;
    transform: translateY(28px);
    transition: opacity 0.65s ease, transform 0.65s ease;
}
.reveal.visible { opacity: 1; transform: none; }

/* ══════════════════════════════
    LOGO MARK
    Black SVG → always on a light circle
══════════════════════════════ */
.logo-mark {
    border-radius: 9999px;
    background-color: var(--color-text);
    display: flex; align-items: center; justify-content: center;
    overflow: hidden; flex-shrink: 0;
    width: 40px; height: 40px; padding: 5px;
}
.logo-mark img { width: 100%; height: 100%; object-fit: contain; display: block; }
.logo-mark-lg { width: 56px; height: 56px; padding: 7px; }
.logo-mark-md { width: 44px; height: 44px; padding: 6px; }
.logo-mark-sm { width: 32px; height: 32px; padding: 4px; }

/* ══════════════════════════════
    TYPING DOT
══════════════════════════════ */
.typing-dot {
    width: 5px; height: 5px;
    background-color: var(--color-secondary);
    border-radius: 9999px;
    display: inline-block;
    animation: blink 1.2s infinite;
}
@keyframes blink { 0%,80%,100%{opacity:0} 40%{opacity:1} }

/* ══════════════════════════════
    ICON STROKE
══════════════════════════════ */
.icon-stroke { stroke: var(--color-secondary); }

/* ══════════════════════════════
    HERO
══════════════════════════════ */
#hero { position: relative; overflow: hidden; }

/* ══════════════════════════════
    SECTION PADDING — tighter on mobile
══════════════════════════════ */
.section-pad { padding-top: 6rem; padding-bottom: 6rem; }
@media (min-width: 768px) {
    .section-pad { padding-top: 8rem; padding-bottom: 8rem; }
}
.section-px { padding-left: 1.25rem; padding-right: 1.25rem; }
@media (min-width: 640px) {
    .section-px { padding-left: 2rem; padding-right: 2rem; }
}

/* ══════════════════════════════
    TWO-COLUMN GRID — stack on mobile
══════════════════════════════ */
.two-col {
    display: grid;
    grid-template-columns: 1fr;
    gap: 3rem;
}
@media (min-width: 1024px) {
    .two-col { grid-template-columns: 1fr 1fr; gap: 4rem; }
}

/* ══════════════════════════════
    MOBILE HAMBURGER MENU
══════════════════════════════ */
.hamburger {
    display: none;
    flex-direction: column; gap: 5px;
    cursor: pointer; padding: 4px;
    background: none; border: none;
}
.hamburger span {
    display: block; width: 22px; height: 1.5px;
    background-color: var(--color-body);
    transition: transform .25s, opacity .25s;
}
@media (max-width: 767px) { .hamburger { display: flex; } }

/* Mobile nav drawer */
.mobile-nav {
    display: none;
    position: fixed; top: 64px; left: 0; right: 0; z-index: 99;
    background-color: rgba(8,8,8,0.97);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--color-border);
    flex-direction: column;
    padding: 1.25rem 1.5rem 1.75rem;
    gap: 0;
}
.mobile-nav.open { display: flex; }
.mobile-nav a {
    color: var(--color-body);
    font-size: 1rem;
    text-decoration: none;
    padding: 0.85rem 0;
    border-bottom: 1px solid var(--color-border);
    transition: color .2s;
    text-align: right;
}
.mobile-nav a:last-child { border-bottom: none; }
.mobile-nav a:hover { color: var(--color-bright); }
.mobile-nav .btn-nav {
    margin-top: 1rem;
    display: block;
    text-align: center;
    padding: 0.65rem 1.5rem;
}

/* ══════════════════════════════
    MAZE SECTION
══════════════════════════════ */
.maze-section {
    position: relative;
    overflow: hidden;
}

/* Maze canvas */
#maze-canvas {
    display: block;
    width: 100%;
    border-radius: 1rem;
    border: 1px solid var(--color-border);
    background-color: var(--color-surface);
}

/* Animated text lines */
.search-lines {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.search-line {
    display: block;
    font-size: clamp(1.05rem, 2.5vw, 1.35rem);
    font-weight: 700;
    line-height: 1.6;
    color: var(--color-bright);
    opacity: 0;
    transform: translateY(16px);
    transition: opacity 0.55s ease, transform 0.55s ease, color 0.4s ease;
}
.search-line.line-visible {
    opacity: 1;
    transform: none;
}
/* Accent lines get a brighter treatment */
.search-line.accent {
    color: var(--color-white);
}
/* De-emphasized lines */
.search-line.soft {
    font-weight: 400;
    font-size: clamp(0.9rem, 2vw, 1.1rem);
    color: var(--color-body);
}

/* Pill tags row */
.maze-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 1.5rem;
    opacity: 0;
    transform: translateY(12px);
    transition: opacity 0.55s ease 0.9s, transform 0.55s ease 0.9s;
}
.maze-tags.tags-visible {
    opacity: 1;
    transform: none;
}
.maze-tag {
    font-size: 0.75rem;
    font-weight: 500;
    padding: 0.3rem 0.85rem;
    border-radius: 9999px;
    border: 1px solid var(--color-border-hi);
    color: var(--color-secondary);
    white-space: nowrap;
    animation: tagPulse 3s ease-in-out infinite;
}
.maze-tag:nth-child(2) { animation-delay: 0.4s; }
.maze-tag:nth-child(3) { animation-delay: 0.8s; }
.maze-tag:nth-child(4) { animation-delay: 1.2s; }
.maze-tag:nth-child(5) { animation-delay: 1.6s; }
.maze-tag:nth-child(6) { animation-delay: 2.0s; }

@keyframes tagPulse {
    0%, 100% { border-color: var(--color-border-hi); color: var(--color-secondary); }
    50%       { border-color: var(--color-body);     color: var(--color-body); }
}

.search-highlight {
    border: 1px solid var(--color-border-hi);
    border-radius: 0.875rem;
    padding: 1.1rem 1.35rem;
    background-color: var(--color-surface);
    font-size: clamp(0.95rem, 2vw, 1.15rem);
    font-weight: 500;
    line-height: 1.75;
    color: var(--color-body);
    position: relative;
    overflow: hidden;
}
/* Animated shimmer sweep */
.search-highlight::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(
    110deg,
    transparent 30%,
    rgba(242,242,242,0.04) 50%,
    transparent 70%
    );
    background-size: 200% 100%;
    animation: shimmer 3.5s ease-in-out infinite;
}
@keyframes shimmer {
    0%   { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}
.search-highlight-accent {
    color: var(--color-bright);
    font-weight: 700;
    font-size: 1.05em;
}

/* ══════════════════════════════
    FEATURE GRID 2×4
══════════════════════════════════════════ */
.feature-grid-2x4 {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
}
@media (min-width: 768px) {
    .feature-grid-2x4 {
    grid-template-columns: 1fr 1fr;
    gap: 1.25rem;
    }
}

.feature-box {
    display: flex;
    align-items: center;
    gap: 0.875rem;
    border: 1px solid var(--color-border);
    border-radius: 0.875rem;
    padding: 1rem 1.25rem;
    background-color: var(--color-surface);
    transition: border-color .25s, background-color .25s;
}
.feature-box:hover {
    border-color: var(--color-border-hi);
    background-color: #1e1e1e;
}
.feature-box .material-symbols-outlined {
    font-size: 1.5rem;
    color: var(--color-secondary);
    font-variation-settings: 'wght' 400;
    flex-shrink: 0;
}
.feature-box span:last-child {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--color-bright);
}

/* ══════════════════════════════
    HERO DEMO LAYOUT
══════════════════════════════ */

/* Demo panel: fades at top, fixed height, overflow hidden */
.hero-demo-panel {
    position: relative;
    height: 55vh;
    width: 100%;
}
/* Top fade mask */
.hero-demo-panel::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 72px;
    background: linear-gradient(to bottom, var(--color-bg) 0%, transparent 100%);
    z-index: 10;
    pointer-events: none;
}

#demo-chat-viewport {
    position: absolute;
    inset: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
}

#demo-chat-feed {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 1rem 0.25rem;
    /* Feed grows upward naturally; JS scrolls it */
}

/* ── User bubble ── */
.demo-user-msg {
    display: flex;
    justify-content: flex-start; /* RTL: user on left = visual right */
    opacity: 0;
    transform: translateX(-18px);
    transition: opacity 0.35s ease, transform 0.35s ease;
}
.demo-user-msg.visible {
    opacity: 1;
    transform: none;
}
.demo-user-bubble {
    background-color: var(--color-bright);
    color: var(--color-bg);
    border-radius: 18px 18px 4px 18px;
    padding: 0.6rem 1rem;
    font-size: 0.875rem;
    line-height: 1.6;
    max-width: 82%;
    font-weight: 500;
    direction: rtl;
}

/* ── Assistant bubble ── */
.demo-assistant-msg {
    display: flex;
    justify-content: flex-end; /* RTL: assistant on right = visual left */
    opacity: 0;
    transform: translateX(18px);
    transition: opacity 0.35s ease, transform 0.35s ease;
}
.demo-assistant-msg.visible {
    opacity: 1;
    transform: none;
}
.demo-assistant-bubble {
    background-color: var(--color-surface);
    border: 1px solid var(--color-border-hi);
    border-radius: 18px 18px 18px 4px;
    padding: 0.75rem 1rem;
    font-size: 0.8rem;
    line-height: 1.7;
    color: var(--color-text);
    max-width: 88%;
    direction: rtl;
    text-align: right;
}
/* Override markdown styles inside demo */
.demo-assistant-bubble p { margin: 0 0 0.35em; }
.demo-assistant-bubble p:last-child { margin-bottom: 0; }
.demo-assistant-bubble ul {
    margin: 0.25em 0;
    padding-right: 1.25em;
    padding-left: 0;
    list-style: disc;
}
.demo-assistant-bubble ol {
    margin: 0.25em 0;
    padding-right: 1.25em;
    padding-left: 0;
    list-style: decimal;
}
.demo-assistant-bubble li {
    margin: 0;
    padding: 0;
    line-height: 1.6;
}
.demo-assistant-bubble li + li { margin-top: 0; }
.demo-assistant-bubble h3 { font-size: 0.85em; margin: 0.6em 0 0.2em; color: var(--color-bright); font-weight: 700; }
.demo-assistant-bubble hr { border: none; border-top: 1px solid var(--color-border); margin: 0.5em 0; }
.demo-assistant-bubble table { font-size: 0.78em; border-collapse: collapse; width: 100%; margin: 0.4em 0; }
.demo-assistant-bubble th, .demo-assistant-bubble td { border: 1px solid var(--color-border); padding: 0.2em 0.5em; }
.demo-assistant-bubble strong { color: var(--color-bright); font-weight: 700; }
.demo-assistant-bubble code { font-family: monospace; font-size: 0.9em; background: rgba(255,255,255,0.06); padding: 0.1em 0.3em; border-radius: 3px; }

/* ── Action card ── */
.demo-action-card {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    border: 1px solid var(--color-border);
    border-radius: 10px;
    padding: 0.45rem 0.75rem;
    margin: 0.35rem 0;
    background-color: var(--color-bg);
    font-size: 0.78rem;
    color: var(--color-body);
    direction: rtl;
}
.demo-action-card .material-symbols-outlined {
    font-size: 1rem;
    color: var(--color-muted);
    font-variation-settings: 'wght' 300;
    flex-shrink: 0;
}
.demo-action-label { flex: 1; font-weight: 500; color: var(--color-secondary); }

/* Loading spinner */
.demo-action-spinner {
    width: 14px; height: 14px;
    border: 1.5px solid var(--color-border-hi);
    border-top-color: var(--color-body);
    border-radius: 50%;
    animation: demospin 0.7s linear infinite;
    flex-shrink: 0;
}
@keyframes demospin { to { transform: rotate(360deg); } }

/* Done checkmark */
.demo-action-done {
    flex-shrink: 0;
    color: #22c55e;
    font-size: 1rem;
    line-height: 1;
}

/* Streaming cursor */
.demo-stream-cursor::after {
    content: '▋';
    animation: blink 0.85s step-start infinite;
    color: var(--color-secondary);
    font-size: 0.75em;
}