/* === GOOGLE FONTS === */
@import url('https://fonts.googleapis.com/css2?family=Vazirmatn:wght@300;400;500;600;700;800;900&display=swap');
@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700;800;900&display=swap');

/* === CSS VARIABLES === */
:root {
    font-family: Vazirmatn, sans-serif;
    --bg-color: #081b29;
    --second-bg-color: #112e42;
    --text-color: #ededed;
    --main-color: #00abf0;
    --accent-purple: #8A2BE2;
    --card-bg-color: #112e42;
    --border-color: rgba(0, 171, 240, 0.4);
}

body.light-mode {
    --bg-color: #f0f2f5;
    --second-bg-color: #ffffff;
    --text-color: #081b29;
    --main-color: #007bff;
    --accent-purple: #6f42c1;
    --card-bg-color: #ffffff;
    --border-color: rgba(0, 123, 255, 0.4);
}


/* === BASE & RESET === */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    text-decoration: none;
    border: none;
    outline: none;
    scroll-behavior: smooth;
    font-family: 'Vazirmatn', 'Poppins', sans-serif;
}

html {
    font-size: 62.5%;
    overflow-x: hidden;
}

body {
    background: var(--bg-color);
    color: var(--text-color);
    transition: background-color .3s, color .3s;
}

section {
    min-height: 100vh;
    padding: 10rem 9% 2rem;
}

/* === WEBSITES SECTION === */
.websites-section { text-align: center; }
.websites-title { font-size: 3.6rem; margin-bottom: 3.5rem; }
.websites-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 2rem;
}
.website-card {
    background: var(--card-bg-color);
    border: 1px solid var(--border-color);
    border-radius: 1.2rem;
    overflow: hidden;
    transition: transform .3s ease, box-shadow .3s ease, border-color .3s ease;
}
.website-card:hover { 
    transform: translateY(-6px); 
    box-shadow: 0 10px 30px rgba(0,0,0,.25); 
    border-color: var(--main-color); 
}

.website-preview { 
    position: relative; 
    height: 280px; /* ارتفاع ثابت برای همه */
    background: var(--second-bg-color); 
    overflow: hidden;
}

/* تنظیم iframe برای نمایش کامل سایت */
.website-iframe {
    position: absolute;
    top: 0;
    right: 0;
    width: 400%; /* 4 برابر عرض اصلی */
    height: 400%; /* 4 برابر ارتفاع اصلی */
    border: 0;
    display: block;
    transform: scale(0.25); /* مقیاس 1/4 */
    transform-origin: top right;
    pointer-events: none; /* جلوگیری از تعامل */
    -webkit-overflow-scrolling: touch;
}

.website-overlay { 
    position: absolute; 
    inset: 0; 
    pointer-events: none; 
    border-bottom: 1px solid var(--border-color);
    background: linear-gradient(to bottom, transparent 85%, rgba(0,0,0,0.05));
    z-index: 1;
}

.website-meta { 
    padding: 1.5rem; 
    text-align: right; 
}
.website-name { 
    font-size: 1.8rem; 
    margin-bottom: .5rem; 
    color: var(--text-color); 
    font-weight: 600;
}
.website-desc { 
    font-size: 1.3rem; 
    color: #b0bfcf; 
    line-height: 1.6; 
}

/* RTL adjustments */
[dir="rtl"] .websites-grid { direction: rtl; }
[dir="rtl"] .website-meta { text-align: right; }

@media (max-width: 1200px) {
    .website-preview { 
        height: 250px;
    }
    .website-iframe {
        width: 350%;
        height: 350%;
        transform: scale(0.285);
    }
}

@media (max-width: 992px) {
    .websites-grid { 
        grid-template-columns: repeat(2, minmax(0, 1fr)); 
    }
    .website-preview { 
        height: 220px;
    }
    .website-iframe {
        width: 300%;
        height: 300%;
        transform: scale(0.333);
    }
}

@media (max-width: 768px) {
    .websites-grid { 
        grid-template-columns: 1fr; 
    }
    .website-preview { 
        height: 200px;
    }
    .website-iframe {
        width: 250%;
        height: 250%;
        transform: scale(0.4);
    }
}

/* === HEADER === */
.header {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    padding: 2rem 9%;
    background: var(--bg-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 100;
    transition: background-color .3s, box-shadow .3s;
    box-shadow: 0 .1rem 1rem rgba(0,0,0, .1);
}
.logo {
    font-size: 2.5rem;
    color: var(--text-color);
    font-weight: 600;
}
.navbar a {
    font-size: 1.7rem;
    color: var(--text-color);
    margin: 0 1.5rem;
    transition: .3s;
}
.navbar a:hover,
.navbar a.active {
    color: var(--main-color);
}
.header-actions {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}
.lang-flag {
    width: 24px;
    cursor: pointer;
    border-radius: 50%;
    transition: transform .3s, box-shadow .3s;
}
.lang-flag:hover {
    transform: scale(1.15);
    box-shadow: 0 0 10px var(--main-color);
}
#mode-toggle {
    font-size: 2.4rem;
    color: var(--text-color);
    cursor: pointer;
    background: none;
}
#menu-icon {
    font-size: 3.6rem;
    color: var(--text-color);
    display: none;
    cursor: pointer;
}

/* === HOME SECTION === */
.home {
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.home-content {
    max-width: 600px;
}
.home-content h1 { font-size: 4.8rem; font-weight: 700; line-height: 1.2; }
.home-content h3 { font-size: 2.8rem; font-weight: 700; color: var(--main-color); }
.home-content p { font-size: 1.5rem; margin: 2rem 0 4rem; }
.btn-box { display: flex; gap: 1.5rem; }
.btn {
    display: inline-block;
    padding: 1rem 2.8rem;
    border-radius: .8rem;
    font-size: 1.6rem;
    font-weight: 600;
    transition: .3s;
}
.btn-primary { background: var(--main-color); color: var(--bg-color); }
.btn-outline { background: transparent; color: var(--main-color); border: 2px solid var(--main-color); }
.btn:hover { transform: translateY(-3px); box-shadow: 0 5px 15px rgba(0,0,0, .2); }
.home-sci { display: flex; gap: 1rem; margin-top: 3rem; }
.home-sci a {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    width: 4rem;
    height: 4rem;
    background: transparent;
    border: 2px solid var(--main-color);
    border-radius: 50%;
    font-size: 2rem;
    color: var(--main-color);
    transition: .3s;
}
.home-sci a:hover { background: var(--main-color); color: var(--bg-color); }
.home-img {
    width: 40vw;
    max-width: 500px;
    animation: floatImage 4s ease-in-out infinite;
}
.home-img img { width: 100%; border-radius: 50%; box-shadow: 0 0 25px var(--main-color); }

/* === ABOUT SECTION === */
.about-section { text-align: center; }
.about-title { font-size: 3.6rem; margin-bottom: 2.5rem; }
.about-main { color: var(--text-color); }
.about-highlight { color: var(--main-color); }
.about-img-frame { 
    display: flex;
    justify-content: center;
    margin-bottom: 2rem;
}
.about-img-border {
    width: 288px;
    height: 288px;
    border-radius: 50%;
    border: 4px solid var(--main-color);
    padding: 4px;
    box-shadow: 0 0 20px rgba(0, 171, 240, 0.3);
    transition: transform 0.3s ease;
}
.about-img-border:hover {
    transform: scale(1.05);
    box-shadow: 0 0 30px rgba(0, 171, 240, 0.5);
}
.about-img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
}
.about-role { font-size: 2.2rem; margin-bottom: 1.5rem; }
.about-desc { max-width: 700px; margin: 0 auto 2.5rem; font-size: 1.5rem; line-height: 1.8; }

/* === EDUCATION/JOURNEY SECTION === */
.journey-section { text-align: center; }
.journey-title { font-size: 3.6rem; margin-bottom: 3.5rem; }
.journey-main { color: var(--text-color); }
.journey-highlight { color: var(--main-color); }
.journey-columns { display: flex; gap: 3rem; justify-content: center; }
.journey-col { flex-basis: 50%; }
.journey-col-title { font-size: 2.1rem; text-align: left; }
.timeline { position: relative; }
.timeline::before { content: ''; position: absolute; left: 0; top: 0; width: 4px; height: 100%; background: var(--main-color); }
.timeline-item { position: relative; margin-bottom: 2.5rem; }
.timeline-marker { position: absolute; left: -9px; top: 0; width: 20px; height: 20px; border-radius: 50%; background: var(--main-color); }
.timeline-card { background: var(--card-bg-color); border: 1px solid var(--border-color); padding: 2rem; border-radius: 1rem; margin-left: 3rem; }
.timeline-card:hover { border-color: var(--main-color); transform: translateY(-5px); box-shadow: 0 5px 20px rgba(0,171,240,0.1); }
.timeline-date { font-size: 1.2rem; color: #b0bfcf; margin-bottom: .5rem; }
.timeline-title { font-size: 1.8rem; font-weight: 600; margin-bottom: .5rem; }
.timeline-desc { font-size: 1.4rem; }

/* === SKILLS SECTION === */
.skills-section { text-align: center; }
.skills-title { font-size: 3.6rem; margin-bottom: 3.5rem; }
.skills-main { color: var(--text-color); }
.skills-highlight { color: var(--main-color); }
.skills-columns { display: flex; gap: 3rem; justify-content: center; }
.skills-col { flex-basis: 50%; padding: 2rem; border: 2px solid var(--border-color); border-radius: 1rem; }
.skills-col-title { font-size: 2.1rem; margin-bottom: 2.2rem; }
.skill-list { display: flex; flex-direction: column; gap: 1.7rem; }
.skill-info { display: flex; justify-content: space-between; font-size: 1.6rem; }
.skill-bar { width: 100%; height: 1rem; background: var(--second-bg-color); border-radius: .5rem; overflow: hidden; }
.skill-bar-fill { 
    height: 100%; 
    width: 0%; 
    background: var(--main-color); 
    border-radius: .5rem; 
    transition: width 1.2s ease; 
}

/* Ensure skill bars are visible */
.skill-bar {
    background: var(--second-bg-color);
    border: 1px solid var(--border-color);
    position: relative;
}

.skill-percentage {
    font-weight: 600;
    color: var(--main-color);
    font-size: 1.4rem;
}

/* CSS-only fallback for skill bars - only if JS hasn't set them */
.skill-bar-fill[data-percentage="99"]:not([style*="width"]) { width: 99%; }
.skill-bar-fill[data-percentage="88"]:not([style*="width"]) { width: 88%; }
.skill-bar-fill[data-percentage="75"]:not([style*="width"]) { width: 75%; }
.skill-bar-fill[data-percentage="70"]:not([style*="width"]) { width: 70%; }
.skill-bar-fill[data-percentage="60"]:not([style*="width"]) { width: 60%; }
.skill-bar-fill[data-percentage="55"]:not([style*="width"]) { width: 55%; }
.skill-bar-fill[data-percentage="50"]:not([style*="width"]) { width: 50%; }
.skill-bar-fill[data-percentage="45"]:not([style*="width"]) { width: 45%; }
.skill-bar-fill[data-percentage="35"]:not([style*="width"]) { width: 35%; }

/* Show percentages on hover as fallback */
.skill-item:hover .skill-percentage {
    color: var(--text-color);
    font-weight: 700;
}

/* === CONTACT SECTION === */
.contact-section { text-align: center; }
.contact-title { font-size: 3.6rem; margin-bottom: 3.5rem; }
.contact-main { color: var(--text-color); }
.contact-highlight { color: var(--main-color); }
.contact-form { max-width: 700px; margin: 0 auto; display: flex; flex-direction: column; gap: 1.5rem; }
.form-row { display: flex; gap: 1.5rem; }
.form-input, .form-textarea { width: 100%; padding: 1.5rem; background: transparent; border: 2px solid var(--border-color); border-radius: .8rem; color: var(--text-color); font-size: 1.6rem; }
.form-input:focus, .form-textarea:focus { border-color: var(--main-color); box-shadow: 0 0 10px var(--main-color); }
.form-textarea { resize: vertical; min-height: 150px; }
.contact-btn { align-self: center; }

/* === ANIMATIONS === */
@keyframes floatImage {
    0% { transform: translateY(0); }
    50% { transform: translateY(-24px); }
    100% { transform: translateY(0); }
}

/* === RTL STYLES === */
[dir="rtl"] .header { flex-direction: row-reverse; }
[dir="rtl"] .navbar a { margin: 0 0 0 1.5rem; }
[dir="rtl"] .home { flex-direction: row-reverse; }
[dir="rtl"] .home-content, [dir="rtl"] .journey-col-title, [dir="rtl"] .skills-col-title { text-align: right; }
[dir="rtl"] .timeline::before { left: auto; right: 0; }
[dir="rtl"] .timeline-marker { left: auto; right: -9px; }
[dir="rtl"] .timeline-card { margin-left: 0; margin-right: 3rem; }
[dir="rtl"] .form-row { flex-direction: row-reverse; }
[dir="rtl"] .btn-box { flex-direction: row-reverse; }
[dir="rtl"] .home-sci { flex-direction: row-reverse; }
[dir="rtl"] .header-actions { flex-direction: row; }

/* Persian text styling */
body[data-lang="fa"] {
    font-family: 'Vazirmatn', sans-serif;
    direction: rtl;
    text-align: right;
}

body[data-lang="fa"] .home-content h1,
body[data-lang="fa"] .home-content h3,
body[data-lang="fa"] .about-title,
body[data-lang="fa"] .journey-title,
body[data-lang="fa"] .skills-title,
body[data-lang="fa"] .contact-title {
    font-family: 'Vazirmatn', sans-serif;
    font-weight: 700;
}

body[data-lang="fa"] .btn {
    font-family: 'Vazirmatn', sans-serif;
    font-weight: 600;
}

/* === RESPONSIVENESS === */
@media (max-width: 992px) {
    .header { padding: 2rem 3%; }
    section { padding: 10rem 3% 2rem; }
    .home { flex-direction: row; }
    .home-content { order: 2; text-align: right; flex: 1; }
    .home-img { order: 1; width: 40vw; max-width: 300px; margin: 0 2rem 0 0; display: block; }
    .journey-columns, .skills-columns { flex-direction: column; gap: 4rem; }
    .home-content h1 { font-size: 3.5rem; }
    .home-content h3 { font-size: 2.2rem; }
}
@media (max-width: 768px) {
    #menu-icon { display: block; }
    .navbar { position: absolute; top: 100%; left: -100%; width: 100%; padding: 1rem 3%; background: var(--second-bg-color); transition: .3s; }
    .navbar.active { left: 0; }
    .navbar a { display: block; font-size: 2rem; margin: 3rem 0; }
    .form-row { flex-direction: column; }
    .home { flex-direction: row; }
    .home-content { order: 2; text-align: right; flex: 1; }
    .home-img { order: 1; width: 45vw; max-width: 320px; margin: 0 1.5rem 0 0; }
    .home-content h1 { font-size: 2.8rem; }
    .home-content h3 { font-size: 1.8rem; }
    .home-content p { font-size: 1.3rem; }
    .btn-box { display: flex; flex-direction: row; gap: 1rem; flex-wrap: wrap; }
    .btn { width: auto; min-width: 140px; text-align: center; padding: 0.8rem 1.5rem; font-size: 1.4rem; }
}
@media (max-width: 480px) {
    .home { flex-direction: row; }
    .home-content { order: 2; text-align: right; flex: 1; }
    .home-img { order: 1; width: 40vw; max-width: 250px; margin: 0 1rem 0 0; }
    .home-content h1 { font-size: 2.2rem; }
    .home-content h3 { font-size: 1.5rem; }
    .home-content p { font-size: 1.2rem; }
    .btn-box { display: flex; flex-direction: row; gap: 0.8rem; flex-wrap: wrap; }
    .btn { width: auto; min-width: 120px; padding: 0.7rem 1.2rem; font-size: 1.3rem; }
}