/* Ensure padding is included in width so main container stays in viewport */
html {
    box-sizing: border-box;
}
*, *::before, *::after {
    box-sizing: inherit;
}

/* --- Design tokens (replacing Tailwind theme) --- */
:root {
    --kid-yellow: #FFD93D;
    --kid-pink: #FF6B6B;
    --kid-blue: #4D96FF;
    --kid-green: #6BCB77;
    --gray-300: #d1d5db;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-800: #1f2937;
    --sky-50: #f0f9ff;
    --purple-400: #c084fc;
    --yellow-400: #facc15;
}

/* Mobile-first: prevent horizontal scroll and full-height layout */
html { overflow-x: hidden; -webkit-text-size-adjust: 100%; }
body {
    font-family: 'Vazirmatn', sans-serif;
    background-color: #FFF9E6;
    overflow-x: hidden;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    padding-bottom: env(safe-area-inset-bottom, 0);
}

/* --- Page layout (static, no Tailwind) --- */
.page-header {
    position: relative;
    overflow: hidden;
    flex-shrink: 0;
    height: calc(32vh + 100px);
    min-height: 310px;
    border-radius: 0 0 28px 28px;
    box-shadow: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -2px rgba(0,0,0,0.05);
}
@media (min-width: 640px) {
    .page-header {
        height: calc(36vh + 100px);
        min-height: 350px;
        border-radius: 0 0 40px 40px;
    }
}
@media (min-width: 768px) {
    .page-header { border-radius: 0 0 50px 50px; }
}
.page-header img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: top;
}
.header-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(to top, rgba(0,0,0,0.3), transparent);
    border-radius: inherit;
    pointer-events: none;
}

.page-main {
    max-width: 64rem;
    margin: 0 auto;
    width: 100%;
    min-width: 0; /* allow flex child to shrink within viewport */
    flex-grow: 1;
    position: relative;
    z-index: 10;
    padding: 1rem 0.75rem 0;
    padding-left: max(0.75rem, env(safe-area-inset-left));
    padding-right: max(0.75rem, env(safe-area-inset-right));
    display: flex;
    flex-direction: column;
    gap: 2.5rem;
}
@media (min-width: 640px) {
    .page-main { padding: 1.5rem 1rem 0; gap: 4rem; }
}
@media (min-width: 768px) {
    .page-main { padding-top: 2rem; }
}

/* Hero section (title + pill) */
.hero-section {
    display: flex;
    justify-content: center;
    margin-top: -0.25rem;
}
@media (min-width: 640px) { .hero-section { margin-top: -0.5rem; } }
.hero-inner {
    font-family: 'Vazirmatn', sans-serif;
    padding: 0;
    max-width: 36rem;
    width: 100%;
    margin: 0 0.25rem;
    text-align: center;
}
.hero-title {
    font-family: 'Vazirmatn', sans-serif;
    font-size: 1.5rem;
    font-weight: 700; /* use loaded Bold; 900 would fall back to other font */
    margin-bottom: 0.5rem;
    color: var(--gray-800);
    line-height: 1.2;
}
@media (min-width: 640px) {
    .hero-title { font-size: 1.875rem; margin-bottom: 0.75rem; }
}
@media (min-width: 768px) {
    .hero-title { font-size: 3rem; }
}
.hero-subtitle {
    font-family: 'Vazirmatn', sans-serif;
    font-size: 1rem;
    font-weight: 700;
    color: var(--gray-600);
    margin-bottom: 1rem;
    line-height: 1.4;
}
@media (min-width: 640px) {
    .hero-subtitle { font-size: 1.125rem; margin-bottom: 1.5rem; }
}
@media (min-width: 768px) {
    .hero-subtitle { font-size: 1.25rem; }
}
.hero-pill {
    font-family: 'Vazirmatn', sans-serif;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--kid-blue);
    color: #fff;
    padding: 0.75rem 1rem;
    border-radius: 9999px;
    font-weight: 700;
    box-shadow: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -1px rgba(0,0,0,0.06);
    transform: rotate(2deg);
    min-height: 44px;
    font-size: 0.875rem;
}
@media (min-width: 640px) {
    .hero-pill { padding: 0.5rem 1.25rem; font-size: 1rem; }
}

/* Section titles (bar + h2) */
.section {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}
@media (min-width: 640px) { .section { gap: 1rem; } }
.section-head {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1rem;
    padding-right: 0.25rem;
}
@media (min-width: 640px) { .section-head { margin-bottom: 1.5rem; padding-right: 0.5rem; } }
.section-bar {
    width: 0.625rem;
    height: 2rem;
    border-radius: 9999px;
    flex-shrink: 0;
}
@media (min-width: 640px) {
    .section-bar { width: 0.75rem; height: 2.5rem; }
}
.section-bar.pink { background: var(--kid-pink); }
.section-bar.green { background: var(--kid-green); }
.section-title {
    font-family: 'Vazirmatn', sans-serif;
    font-size: 1.5rem;
    font-weight: 700; /* Vazirmatn Bold only; 900 not loaded */
    color: var(--gray-800);
    padding: 0.5rem 0;
    margin: 0;
}
@media (min-width: 640px) { .section-title { font-size: 1.875rem; } }
.section-title.blue { color: var(--kid-blue); }

/* Intro grid (2 cols on md) */
.intro-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
}
@media (min-width: 640px) { .intro-grid { gap: 1.5rem; } }
@media (min-width: 768px) {
    .intro-grid { grid-template-columns: repeat(2, 1fr); }
}

/* Video cards (intro: pink/purple) */
.video-card {
    position: relative;
    overflow: hidden;
    border-radius: 1rem;
    box-shadow: 0 20px 25px -5px rgba(0,0,0,0.1), 0 10px 10px -5px rgba(0,0,0,0.04);
    transition: transform 0.3s, box-shadow 0.3s;
    border: 4px solid #fff;
}
@media (min-width: 640px) {
    .video-card {
        border-radius: 1.5rem;
    }
    .video-card:hover {
        box-shadow: 0 25px 50px -12px rgba(0,0,0,0.25);
        transform: translateY(-0.5rem);
    }
}
.video-card:active { transform: scale(0.98); }
.video-card .video-fullscreen-wrapper {
    aspect-ratio: 16 / 9;
    background: #111827;
    width: 100%;
}
.video-card .video-fullscreen-wrapper video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    max-width: 100%;
}
.card-foot {
    padding: 0.75rem 1rem;
    margin: 0;
    text-align: center;
}
.card-foot.pink {
    background: var(--kid-pink);
    color: #fff;
    border: 1px solid rgba(253, 164, 175, 0.5);
}
.card-foot.purple {
    background: var(--purple-400);
    color: #fff;
    border: 1px solid rgba(196, 181, 253, 0.5);
}
.card-foot.white {
    background: #fff;
}
.card-title {
    font-size: 1rem;
    font-weight: 700;
    line-height: 1.4;
    color: #fff;
    padding: 0.25rem 0;
    margin: 0;
}
.card-foot.white .card-title { color: var(--gray-800); }
@media (min-width: 640px) { .card-title { font-size: 1.125rem; } }
.card-desc {
    font-size: 0.875rem;
    opacity: 0.9;
    margin-top: 0.25rem;
}

/* Education section box */
.education-section {
    background: var(--sky-50);
    padding: 1rem;
    border-radius: 1rem;
    border: 4px solid rgba(77, 150, 255, 0.3);
}
@media (min-width: 640px) {
    .education-section { padding: 1.5rem; border-radius: 1.875rem; }
}
@media (min-width: 768px) {
    .education-section { padding: 2.5rem; border-radius: 2.5rem; }
}
.education-head {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    text-align: center;
    flex-wrap: wrap;
}
@media (min-width: 640px) { .education-head { margin-bottom: 2rem; } }
.education-head .star-icon {
    color: var(--yellow-400);
    width: 1.5rem;
    height: 1.5rem;
    flex-shrink: 0;
}
@media (min-width: 640px) {
    .education-head .star-icon { width: 2rem; height: 2rem; }
}
.education-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
}
@media (min-width: 640px) {
    .education-grid { grid-template-columns: repeat(2, 1fr); gap: 1.5rem; }
}
@media (min-width: 768px) {
    .education-grid { grid-template-columns: repeat(3, 1fr); }
}
.video-card.education {
    border: 4px dashed var(--gray-300);
    background: #fff;
}

/* Footer */
.page-footer {
    text-align: center;
    margin-top: 0.75rem;
    margin-bottom: 0;
    padding: 1rem 0.75rem;
    padding-bottom: max(1rem, env(safe-area-inset-bottom));
    color: var(--gray-500);
    font-weight: 700;
    font-size: 0.875rem;
    flex-shrink: 0;
}
@media (min-width: 640px) {
    .page-footer { margin-top: 2rem; padding: 1.25rem 1rem; padding-bottom: 1.25rem; }
}
/* Persian numerals and inline SVG icons */
.persian-num, .comment-date, time { font-family: 'Vazirmatn', sans-serif; }
.inline-svg { vertical-align: -0.2em; margin-left: 0.15em; margin-right: 0.15em; }
.footer-heart { width: 1.6em; height: 1.6em; color: #e11d48; }
.comment-vote-svg { vertical-align: middle; display: inline-block; }
/* Custom scrollbar (desktop) - thinner on touch devices */
@media (pointer: fine) {
    ::-webkit-scrollbar { width: 12px; }
    ::-webkit-scrollbar-track { background: #FFF9E6; }
    ::-webkit-scrollbar-thumb { background: #FFD93D; border-radius: 10px; }
    ::-webkit-scrollbar-thumb:hover { background: #FF6B6B; }
}
/* Floating Animation - reduce motion on mobile for performance */
@keyframes float {
    0% { transform: translateY(0px); }
    50% { transform: translateY(-10px); }
    100% { transform: translateY(0px); }
}
.animate-float { animation: float 3s ease-in-out infinite; }
@media (prefers-reduced-motion: reduce) { .animate-float { animation: none; } }
/* Touch-friendly: ensure video and cards don't cause zoom on focus */
video { max-width: 100%; }
/* Fullscreen: video fits screen, landscape-friendly on mobile */
.video-fullscreen-wrapper {
    position: relative;
}
.video-fullscreen-wrapper:fullscreen,
.video-fullscreen-wrapper:-webkit-full-screen {
    width: 100% !important;
    height: 100% !important;
    max-width: 100vw;
    max-height: 100vh;
    background: #000;
    display: flex;
    align-items: center;
    justify-content: center;
}
.video-fullscreen-wrapper:fullscreen video,
.video-fullscreen-wrapper:-webkit-full-screen video {
    width: 100% !important;
    height: 100% !important;
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}
.video-fullscreen-btn {
    position: absolute;
    bottom: 8px;
    right: 8px;
    z-index: 5;
    width: 40px;
    height: 40px;
    min-width: 40px;
    min-height: 40px;
    border-radius: 8px;
    background: rgba(0,0,0,0.6);
    color: #fff;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}
.video-fullscreen-btn:hover { background: rgba(0,0,0,0.8); }
.video-fullscreen-btn svg { width: 22px; height: 22px; }

/* Comments section - main page block */
.comments-section-wrapper {
    padding: 1.5rem 0 0;
}
.comments-section {
    padding: 1.25rem 0;
}
.comments-form {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}
.comments-form-profile {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}
.comment-form-avatar-btn {
    flex-shrink: 0;
    padding: 0;
    border: 2px solid #e5e7eb;
    border-radius: 50%;
    background: #fff;
    cursor: pointer;
    overflow: hidden;
    transition: border-color 0.2s, box-shadow 0.2s;
    -webkit-tap-highlight-color: transparent;
}
.comment-form-avatar-btn:hover {
    border-color: #4D96FF;
    box-shadow: 0 2px 8px rgba(77, 150, 255, 0.25);
}
.comment-form-avatar-img {
    display: block;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    object-fit: cover;
}
.comments-form-profile .comments-input {
    flex: 1;
    min-width: 0;
}
.comments-form-text-wrap {
    display: block;
}
.comments-form-text-wrap .comments-textarea {
    width: 100%;
    box-sizing: border-box;
}
.comments-input,
.comments-textarea {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 2px solid #e5e7eb;
    border-radius: 12px;
    font-family: 'Vazirmatn', sans-serif;
    font-size: 1rem;
    background: #fff;
    transition: border-color 0.2s;
}
.comments-input:focus,
.comments-textarea:focus {
    outline: none;
    border-color: #4D96FF;
}
.comments-textarea {
    resize: vertical;
    min-height: 100px;
}
.comments-form-error {
    color: #dc2626;
    font-size: 0.875rem;
    font-weight: 700; /* 600 not loaded; use Bold */
}
.comments-submit {
    align-self: flex-end;
    padding: 0.625rem 1.25rem;
    background: #6BCB77;
    color: #fff;
    border: none;
    border-radius: 9999px;
    font-family: 'Vazirmatn', sans-serif;
    font-weight: 700;
    font-size: 1rem;
    cursor: pointer;
    transition: background 0.2s;
    -webkit-tap-highlight-color: transparent;
}
.comments-submit:hover:not(:disabled) {
    background: #5bb868;
}
.comments-submit:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}
.comments-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}
.comments-loading,
.comments-error,
.comments-empty {
    text-align: center;
    color: #6b7280;
    padding: 1rem;
    font-weight: 700; /* 600 not loaded; use Bold */
}
.comments-error { color: #dc2626; }
.comment-card {
    background: #fff;
    border: 2px solid #e5e7eb;
    border-radius: 16px;
    padding: 1rem 1.25rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}
.comment-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem 1rem;
    margin-bottom: 0.5rem;
}
.comment-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
    background: #e5e7eb;
}
.comment-meta {
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
}
.comment-author {
    font-weight: 700;
    color: #1f2937;
}
.comment-date {
    font-size: 0.875rem;
    color: #6b7280;
}
.comment-text {
    color: #374151;
    line-height: 1.6;
    margin: 0;
    white-space: pre-wrap;
    word-break: break-word;
}

/* Comment actions: پاسخ, لایک, دیسلایک — on the left end of the comment box (RTL) */
.comment-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end; /* RTL: pushes group to visual left */
    gap: 0.5rem 1rem;
    margin-top: 0.75rem;
    padding-top: 0.5rem;
    border-top: 1px solid #e5e7eb;
}
.comment-vote-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.35rem 0.6rem;
    border: 2px solid #e5e7eb;
    border-radius: 9999px;
    background: #fff;
    font-family: 'Vazirmatn', sans-serif;
    font-size: 0.875rem;
    cursor: pointer;
    color: #6b7280;
    transition: border-color 0.2s, background 0.2s;
    -webkit-tap-highlight-color: transparent;
}
.comment-vote-btn:hover {
    border-color: #4D96FF;
    color: #4D96FF;
}
.comment-vote-btn.active[data-vote="1"] {
    border-color: #6BCB77;
    background: #6BCB77;
    color: #fff;
}
.comment-vote-btn.active[data-vote="-1"] {
    border-color: #FF6B6B;
    background: #FF6B6B;
    color: #fff;
}
.comment-vote-count {
    min-width: 1.25rem;
    text-align: center;
}
.comment-reply-btn {
    padding: 0.35rem 0.75rem;
    border: 2px solid #4D96FF;
    border-radius: 9999px;
    background: transparent;
    color: #4D96FF;
    font-family: 'Vazirmatn', sans-serif;
    font-weight: 700;
    font-size: 0.875rem;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
    -webkit-tap-highlight-color: transparent;
}
.comment-reply-btn:hover {
    background: #4D96FF;
    color: #fff;
}

/* Reply form (inline under comment) */
.comment-reply-form {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-top: 0.75rem;
    padding: 0.75rem;
    background: #f9fafb;
    border-radius: 12px;
    border: 1px solid #e5e7eb;
}
.comment-reply-form .comments-input,
.comment-reply-form .comments-textarea {
    margin: 0;
}

/* Nested replies */
.comment-replies {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-top: 0.75rem;
    padding-right: 1rem;
    border-right: 3px solid #e5e7eb;
}
.comment-reply {
    background: #f9fafb;
    border-color: #e5e7eb;
}

/* Avatar picker modal */
.avatar-modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    box-sizing: border-box;
}
.avatar-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    cursor: pointer;
}
.avatar-modal-content {
    position: relative;
    background: #fff;
    border-radius: 20px;
    padding: 1.5rem;
    max-width: 360px;
    width: 100%;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    border: 2px solid #e5e7eb;
}
.avatar-modal-title {
    font-family: 'Vazirmatn', sans-serif;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--gray-800);
    margin: 0 0 1rem 0;
    text-align: center;
}
.avatar-modal-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.5rem;
    margin-bottom: 1rem;
}
.avatar-modal-item {
    padding: 0;
    border: 2px solid #e5e7eb;
    border-radius: 12px;
    background: #fff;
    cursor: pointer;
    overflow: hidden;
    transition: border-color 0.2s, transform 0.15s;
    -webkit-tap-highlight-color: transparent;
}
.avatar-modal-item:hover {
    border-color: #4D96FF;
    transform: scale(1.05);
}
.avatar-modal-item img {
    display: block;
    width: 100%;
    height: auto;
    aspect-ratio: 1;
    object-fit: cover;
}
.avatar-modal-close {
    display: block;
    width: 100%;
    padding: 0.625rem 1rem;
    background: #e5e7eb;
    color: var(--gray-800);
    border: none;
    border-radius: 9999px;
    font-family: 'Vazirmatn', sans-serif;
    font-weight: 700;
    font-size: 1rem;
    cursor: pointer;
    transition: background 0.2s;
    -webkit-tap-highlight-color: transparent;
}
.avatar-modal-close:hover {
    background: #d1d5db;
}
