* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* Arabic font face */
@font-face {
    font-family: 'SamirKhouajaMaghribi';
    src: url('media/fonts/Samir.Khouaja.Maghribi.ttf') format('truetype');
    font-weight: normal;
    font-style: normal;
    font-display: swap;
}

:root {
    --primary: #C3262E;
    --primary-light: #ce7175;
    --secondary: #F3F4F6;
    --secondary-dark: #E5E7EB;
    --background: #F8F8F7;
    --sidebar-bg: #EBEBEB;
    --text-dark: #1F2937;
    --text-light: #6B7280;
    --border-color: #D1D5DB;
    --card-bg: #FFFFFF;
    --accent: #0EA5E9;
    --green-morocco: #006334;
    --arabic-font: 'SamirKhouajaMaghribi', 'Noto Naskh Arabic', 'Scheherazade New', serif;
}

body.dark-mode {
    --background: #1F2937;
    --sidebar-bg: #111827;
    --text-dark: #F3F4F6;
    --text-light: #D1D5DB;
    --border-color: #374151;
    --card-bg: #2D3748;
    --secondary: #374151;
}

body {
    font-family: 'candara', sans-serif;
    background-color: var(--background);
    color: var(--text-dark);
    line-height: 1.6;
    transition: background-color 0.3s, color 0.3s;
}

/* Use Arabic font for Arabic-language content or RTL spans */
:lang(ar), [dir="rtl"], .font-arabic {
    font-family: var(--arabic-font);
}

.container {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 256px;
    background-color: var(--sidebar-bg);
    border-right: 1px solid var(--border-color);
    padding: 24px;
    position: fixed;
    height: 100vh;
    overflow-y: auto;
    left: 0;
    top: 0;
    transition: transform 0.3s ease;
    z-index: 1000;
}

.sidebar.mobile-hidden {
    transform: translateX(-100%);
}

.sidebar-header {
    text-align: center;
    margin-bottom: 24px;
    padding-bottom: 24px;
    border-bottom: 1px solid var(--border-color);
}

.profile-avatar {
    width: 96px;
    height: 96px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 27px;
    font-weight: bold;
    margin: 0 auto 16px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
}

.profile-name {
    font-size: 23px;
    font-weight: bold;
    margin-bottom: 8px;
}

.profile-title {
    font-size: 17px;
    color: var(--text-light);
}

.nav-menu {
    list-style: none;
    margin-bottom: 24px;
}

.nav-item {
    margin-bottom: 8px;
}

.nav-link {
    display: block;
    padding: 5px 16px;
    color: var(--text-dark);
    text-decoration: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
    background: none;
    font-size: 19px;
    width: 100%;
    text-align: left;
    font-family: 'candara', sans-serif;
}

.nav-link:hover {
    background-color: var(--secondary);
}

.nav-link.active {
    background-color: var(--primary);
    color: white;
}

.social-links {
    display: flex;
    gap: 12px;
    margin-bottom: 24px;
    padding-bottom: 24px;
    border-bottom: 1px solid var(--border-color);
}

.social-link {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    background-color: var(--secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    color: var(--text-dark);
    transition: all 0.2s;
    border: none;
    cursor: pointer;
    font-size: 21px;
}

.social-link:hover {
    background-color: var(--primary);
    color: white;
}

/* Icon sizing inside social buttons */
.social-link img {
    width: 22px;
    height: 22px;
    display: block;
}

.theme-toggle {
    width: 100%;
    padding: 12px;
    background-color: var(--secondary);
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 17px;
    font-weight: 600;
    color: var(--text-dark);
    transition: all 0.2s;
    font-family: 'candara', sans-serif;
}

.theme-toggle:hover {
    background-color: var(--primary);
    color: white;
}

/* Main Content */
.main-content {
    margin-left: 256px;
    flex: 1;
    background-color: var(--background);
}

.mobile-menu-btn {
    display: none;
    position: fixed;
    top: 16px;
    left: 16px;
    z-index: 1001;
    background: var(--sidebar-bg);
    border: none;
    padding: 8px;
    border-radius: 8px;
    cursor: pointer;
    width: 40px;
    height: 40px;
    font-size: 23px;
}

@media (max-width: 1024px) {
    .sidebar {
        width: 100%;
        max-width: 256px;
    }

    .main-content {
        margin-left: 0;
    }

    .mobile-menu-btn {
        display: flex;
        align-items: center;
        justify-content: center;
    }
}

/* Page Sections */
.page {
    display: none;
}

.page.active {
    display: block;
}

.page-content {
    padding: 48px 32px;
    max-width: 1024px;
    margin: 0 auto;
}

.page-title {
    font-size: 51px;
    font-weight: bold;
    font-family: 'candara', sans-serif;
    margin-bottom: 21px;
    color: var(--text-dark);
}

/* Hero Section */

/* People section: justify names and avoid flex alignment issues */

.hero {
    padding: 2em 32px;
    max-width: 1024px;
    margin: 0 auto;
}

.hero-title {
    font-size: 75px;
    font-weight: bold;
    font-family: 'candara', sans-serif;
    margin-bottom: 16px;
    color: var(--text-dark);
}

.hero-subtitle {
    font-size: 27px;
    color: var(--text-light);
    margin-bottom: 32px;
    font-weight: 500;
}

.hero-text {
    font-size: 21px;
    color: var(--text-dark);
    line-height: 1.8;
    margin-bottom: 24px;
    text-align: justify;
}

.cta-buttons {
    display: flex;
    gap: 16px;
    margin-top: 32px;
    flex-wrap: wrap;
}

.btn {
    padding: 12px 24px;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    font-size: 19px;
    font-weight: 600;
    transition: all 0.2s;
    font-family: 'candara', sans-serif;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.btn-primary {
    background-color: var(--primary);
    color: white;
}

.btn-primary:hover {
    background-color: var(--primary-light);
    transform: translateY(-2px);
}

.btn-secondary {
    background-color: var(--secondary);
    color: var(--text-dark);
}

.btn-secondary:hover {
    background-color: var(--secondary-dark);
}

/* Highlights Section */
.highlights {
    background-color: var(--secondary);
    padding: 48px 32px;
    margin-top: 48px;
}

.highlights-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 24px;
    max-width: 1024px;
    margin: 0 auto;
}

.highlight-card {
    background-color: var(--card-bg);
    padding: 24px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    text-align: center;
}

.highlight-number {
    font-size: 39px;
    font-weight: bold;
    color: var(--primary);
    margin-bottom: 8px;
}

.highlight-label {
    font-size: 19px;
    font-weight: 600;
    margin-bottom: 8px;
}

.highlight-desc {
    font-size: 17px;
    color: var(--text-light);
}

/* Explore Grid */
.explore-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 24px;
    margin-top: 32px;
}

.explore-card {
    background-color: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 24px;
    cursor: pointer;
    transition: all 0.2s;
}

.explore-card:hover {
    border-color: var(--primary);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.explore-card h3 {
    font-size: 21px;
    font-weight: bold;
    margin-bottom: 12px;
    color: var(--text-dark);
}

.explore-card p {
    font-size: 17px;
    color: var(--text-light);
}

/* Publication/Project Cards */
.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 24px;
    margin-top: 32px;
}

/* Publications: two cards per row on desktop/tablet */
#publications .cards-grid {
    grid-template-columns: repeat(2, 1fr);
}

/* Publications: justify titles, avoid last-line gaps */
#publications .card-title .card-title-text {
    flex: 1;
    display: block;
    text-align: justify;
    text-align-last: left; /* do not justify the final line */
}

/* Projects & Grants: two cards per row on desktop/tablet */
#projectsContainer,
#grantsContainer {
    grid-template-columns: repeat(2, 1fr);
}

/* People: four cards per row on desktop/tablet */
#people .cards-grid {
    grid-template-columns: repeat(4, 1fr);
}

.card {
    background-color: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 24px;
    transition: all 0.2s;
    display: flex;
    flex-direction: column;
    position: relative;
}


#people .card {
    padding: 11px 24px;
}

#people .card-title {
    margin: 0px;
}

.card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.card-title {
    font-size: 19px;
    font-weight: bold;
    margin-bottom: 12px;
    color: var(--text-dark);
    display: flex;
    align-items: center;
    gap: 8px;
    position: relative; /* layout for title + logo */
}

/* Center the names for Projects & Grants cards */
#projectsContainer .card-title,
#grantsContainer .card-title {
    align-items: center;
}

/* Right-side brand/logo inside the title; square equals title height */
/* Title text: justify across lines */
#projectsContainer .card-title .card-title-text,
#grantsContainer .card-title .card-title-text {
    flex: 1;
    width: auto;
    display: block;
    text-align: justify;
    text-align-last: left; /* do not justify the last line to avoid gaps */
}

/* Remove the extra 80/20 split; full-width title text now */

/* Remove logo box and image styles since logo appears on hover as background */

.card-description {
    font-size: 14px;
    color: var(--text-light);
    margin-bottom: 16px;
    line-height: 1.6;
    text-align: justify;
}

/* Card logo placeholder/image shown left of title */
.card-logo {
    width: 2em;
    border-radius: 2px;
    flex: 0 0 28px;
    background-color: var(--secondary);
    border: 1px solid var(--border-color);
}

.card-title img.card-logo {
    object-fit: contain;
    background: none;
    border: none;
}

.card-meta {
    font-size: 15px;
    color: var(--text-light);
    margin-bottom: 16px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border-color);
}

.card-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
    margin-top: auto;
}

.badge {
    display: inline-block;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 15px;
    font-weight: 600;
}

.badge-pi {
    background-color: rgba(30, 64, 175, 0.1);
    color: var(--primary);
}

.badge-copi {
    background-color: rgba(14, 165, 233, 0.1);
    color: var(--accent);
}

.badge-member {
    background-color: var(--secondary);
    color: var(--text-dark);
}

.action-btn {
    padding: 6px 12px;
    border-radius: 6px;
    border: 1px solid var(--border-color);
    background-color: var(--secondary);
    color: var(--text-dark);
    cursor: pointer;
    font-size: 13px;
    transition: all 0.2s;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-family: 'candara', sans-serif;
}

.action-btn:hover {
    background-color: var(--primary);
    color: white;
    border-color: var(--primary);
}

.section-title {
    font-size: 31px;
    font-weight: bold;
    margin-bottom: 0px;
    padding-bottom: 0px;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-dark);
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 24px;
    margin-top: 32px;
    background-color: var(--secondary);
    padding: 32px;
    border-radius: 8px;
}

/* Stats sections (Projects / Grants) */
.stat-group {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.group-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-dark);
    text-align: center;
}

.group-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 16px;
}

.stat {
    text-align: center;
}

.stat-number {
    font-size: 35px;
    font-weight: bold;
    color: var(--primary);
    margin-bottom: 8px;
}

.stat-label {
    font-size: 17px;
    color: var(--text-light);
}

/* Timeline */
.timeline {
    position: relative;
    margin-top: 32px;
    padding-left: 24px;
    border-left: 2px solid var(--border-color);
}

.timeline-item {
    position: relative;
    margin-bottom: 24px;
    padding-left: 16px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.timeline-dot {
    position: absolute;
    left: -7px;
    top: 0.59em;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background-color: var(--primary);
    box-shadow: 0 0 0 4px var(--card-bg);
}

.timeline-content h4 {
    font-size: 19px;
    font-weight: bold;
    color: var(--text-dark);
    margin-bottom: 4px;
}

.timeline-meta {
    font-size: 17px;
    color: var(--text-light);
    margin-bottom: 8px;
}

/* Right-aligned logo inside timeline items */
.timeline-content {
    flex: 1;
}

.timeline-logo {
    width: 10em;              /* fixed rectangular width */
    height: 5em;             /* fixed rectangular height */
    flex: 0 0 10em;           /* reserve fixed space equal to width */
    object-fit: contain;     /* adapt logo to the box */
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background-color: var(--card-bg);
    padding: 0.25em;         /* slight inner padding for aesthetics */
}

@media (max-width: 480px) {
    .timeline-logo {
        width: 200px;         /* smaller rectangular size on mobile */
        height: 100px;
        flex-basis: 200px;
        border-radius: 6px;
        padding: 0.25em;
    }
}

/* Responsive */
@media (max-width: 768px) {
    .page-content {
        padding: 32px 16px;
    }

    .hero {
        padding: 32px 16px;
    }

    .hero-title {
        font-size: 41px;
    }

    .hero-subtitle {
        font-size: 21px;
    }

    .page-title {
        font-size: 35px;
    }

    .cards-grid {
        grid-template-columns: 1fr;
    }

    /* Ensure publications are single column on small screens */
    #publications .cards-grid {
        grid-template-columns: 1fr;
    }

    /* Ensure people is single column on small screens */
    #people .cards-grid {
        grid-template-columns: 1fr;
    }

    .explore-grid {
        grid-template-columns: 1fr;
    }

    /* Projects & Grants: one card per row on mobile */
    #projectsContainer,
    #grantsContainer {
        grid-template-columns: 1fr;
    }

    /* One highlight card per row on mobile */
    .highlights-grid {
        grid-template-columns: 1fr !important;
    }


/* Ensure one highlight per row on larger mobile widths (landscape/plus sizes) */
@media (max-width: 1024px) {
    .highlights-grid {
        grid-template-columns: 1fr !important;
    }
}
    .cta-buttons {
        flex-direction: column;
    }

    .btn {
        width: 100%;
        justify-content: center;
    }
}

    /* Floating audio control */
    .audio-toggle-btn {
        position: fixed;
        right: 20px;
        bottom: 20px;
        width: 52px;
        height: 52px;
        border: 1px solid var(--border-color);
        border-radius: 50%;
        background-color: var(--card-bg);
        color: var(--text-dark);
        font-size: 20px;
        line-height: 1;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        z-index: 1200;
        box-shadow: 0 8px 18px rgba(0, 0, 0, 0.18);
        transition: transform 0.2s ease, background-color 0.2s ease, color 0.2s ease;
    }

    .audio-toggle-btn:hover {
        transform: translateY(-2px);
        background-color: var(--primary);
        color: #ffffff;
    }

    @media (max-width: 768px) {
        .audio-toggle-btn {
            right: 14px;
            bottom: 14px;
            width: 48px;
            height: 48px;
        }
    }