html {
    scroll-behavior: smooth;
    overflow-x: hidden;
}

body {
    font-family: 'Vazirmatn', sans-serif;
    overflow-x: hidden;
}

/* Custom scrollbar */
::-webkit-scrollbar {
    width: 8px;
}
::-webkit-scrollbar-track {
    background: #0f172a;
}
::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, #1e3a8a, #3b82f6);
    border-radius: 4px;
}

/* Animations */
@keyframes twinkle {
    0%, 100% { opacity: 0.3; transform: scale(0.8); }
    50% { opacity: 1; transform: scale(1.2); }
}
.animate-twinkle {
    animation: twinkle 3s ease-in-out infinite;
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}
.animate-float {
    animation: float 4s ease-in-out infinite;
}

@keyframes gradient-shift {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}
.animate-gradient {
    background-size: 200% 200%;
    animation: gradient-shift 3s ease infinite;
}

/* Fallbacks for utilities missed by the Tailwind v4 content scanner */
.md\:flex { display: flex; }
.md\:hidden { display: none; }
.z-50 { z-index: 50; }

/* Markdown content links */
.markdown-content a {
    color: #60a5fa;
    text-decoration: underline;
    text-underline-offset: 2px;
    transition: color 0.2s;
}
.markdown-content a:hover {
    color: #93c5fd;
}
.markdown-content p code,
.markdown-content li code {
    background: rgba(255,255,255,0.08);
    padding: 0.15rem 0.35rem;
    border-radius: 0.25rem;
    font-size: 0.9em;
}
.markdown-content blockquote {
    border-right: 3px solid #3b82f6;
    padding-right: 1rem;
    color: rgba(255,255,255,0.8);
}
.markdown-content img {
    max-width: 100%;
    border-radius: 0.5rem;
    margin: 0.5rem 0;
}
.markdown-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 0.5rem 0;
}
.markdown-content th,
.markdown-content td {
    border: 1px solid rgba(255,255,255,0.15);
    padding: 0.5rem;
    text-align: right;
}
.markdown-content th {
    background: rgba(255,255,255,0.05);
}

/* Header */
.site-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 50;
    background: rgba(15, 23, 42, 0.95);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

/* Hide scrollbar utility */
.scrollbar-hide {
    scrollbar-width: none;
    -ms-overflow-style: none;
}
.scrollbar-hide::-webkit-scrollbar {
    display: none;
}

/* Mobile bottom nav */
.mobile-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 50;
    background: rgba(15, 23, 42, 0.95);
    backdrop-filter: blur(12px);
    border-top: 1px solid rgba(255,255,255,0.1);
    padding-bottom: env(safe-area-inset-bottom);
}
.char-scroll {
    display: flex;
    gap: 1rem;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 0.75rem 0.5rem;
    scroll-snap-type: x proximity;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
    scrollbar-width: none;
    -ms-overflow-style: none;
    position: relative;
    touch-action: pan-x;
    -webkit-tap-highlight-color: transparent;
    /* Critical: constrain width so overflow-x actually triggers */
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    /* Desktop: show grab cursor to hint it's scrollable */
    cursor: grab;
}
.char-scroll:active {
    cursor: grabbing;
}
.char-scroll::-webkit-scrollbar {
    display: none;
}
.char-circle {
    flex: 0 0 auto;
    width: 64px;
    height: 64px;
    border-radius: 50%;
    overflow: hidden;
    border: 2px solid rgba(255,255,255,0.15);
    transition: all 0.25s ease;
    scroll-snap-align: center;
    background: rgba(255,255,255,0.05);
    box-shadow: 0 4px 6px -1px rgba(0,0,0,0.3);
    cursor: pointer;
    text-decoration: none;
    display: flex;
    align-items: center;
    justify-content: center;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}
@media (min-width: 768px) {
    .char-circle {
        width: 96px;
        height: 96px;
    }
}
.char-circle:hover {
    border-color: #fbbf24;
    transform: translateY(-4px) scale(1.08);
    box-shadow: 0 20px 25px -5px rgba(0,0,0,0.4), 0 0 20px rgba(251,191,36,0.3);
}
.char-circle.ring-4 {
    border-color: #fbbf24;
    box-shadow: 0 0 0 4px rgba(251,191,36,0.4), 0 20px 25px -5px rgba(0,0,0,0.4);
}
.char-circle:active {
    transform: scale(0.95);
}

/* Desktop smooth-scroll override: snap feels jerky with mouse wheel */
@media (hover: hover) and (pointer: fine) {
    .char-scroll {
        scroll-snap-type: none;
    }
    .char-circle {
        scroll-snap-align: none;
    }
}

.char-circle img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    pointer-events: none;
    user-select: none;
    -webkit-user-drag: none;
}
.char-circle .fallback-icon {
    font-size: 1.75rem;
    line-height: 1;
}

/* Character menu overlay */
.char-menu-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.9);
    backdrop-filter: blur(12px);
    z-index: 200;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    gap: 1.5rem;
}
.char-menu-overlay .char-scroll {
    max-width: 95vw;
    justify-content: flex-start;
    padding: 1rem 0;
}
.char-menu-overlay .char-circle {
    width: 72px;
    height: 72px;
}
.char-menu-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    max-width: 95vw;
}
.char-menu-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: white;
    margin: 0;
}
.char-menu-close {
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.2);
    color: white;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1.25rem;
    transition: all 0.2s;
}
.char-menu-close:hover {
    background: rgba(255,255,255,0.2);
    border-color: #fbbf24;
    color: #fbbf24;
}
.char-menu-hint {
    color: rgba(255,255,255,0.5);
    font-size: 0.875rem;
    margin: 0;
}
