/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #4A148C;
    --secondary-color: #00897B;
    --accent-color: #FFB300;
    --text-color: #333;
    --bg-color: #FAFAFA;
    --card-bg: #ffffff;
    --border-color: #e6dcec;
    --shadow: 0 2px 8px rgba(74, 20, 140, 0.12);
    --shadow-hover: 0 4px 16px rgba(74, 20, 140, 0.18);
}

body {
    font-family: 'Cairo', 'Noto Sans Arabic', Tahoma, Arial, sans-serif;
    line-height: 1.6;
    color: var(--text-color);
    background-color: var(--bg-color);
    direction: rtl;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Header */
.header {
    background: linear-gradient(135deg, var(--primary-color) 0%, #6A1B9A 100%);
    color: #fff;
    padding: 2rem 0;
    text-align: center;
    box-shadow: var(--shadow);
}

.logo,
.header .logo,
.header h1.logo {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
    font-weight: 700;
    color: var(--accent-color);
    border-bottom: none;
    padding-bottom: 0;
}

.tagline,
.header .tagline {
    font-size: 1.1rem;
    opacity: 0.95;
    font-weight: 400;
    color: #fff;
}

/* Navigation */
.nav {
    background-color: var(--card-bg);
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav .container {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
}

.nav-toggle {
    display: none;
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 0.55rem 0.7rem;
    cursor: pointer;
    flex-direction: column;
    justify-content: center;
    gap: 4px;
}

.nav-toggle-bar {
    display: block;
    width: 22px;
    height: 2px;
    background: var(--primary-color);
}

.nav-list {
    list-style: none;
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 0.5rem;
    padding: 1rem 0;
}

.nav-link {
    display: block;
    padding: 0.75rem 1.5rem;
    text-decoration: none;
    color: var(--text-color);
    border-radius: 8px;
    transition: all 0.3s ease;
    font-weight: 500;
}

.nav-link:hover {
    background-color: var(--secondary-color);
    color: white;
    transform: translateY(-2px);
}

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

/* Main Content */
.main {
    padding: 2rem 0;
    min-height: calc(100vh - 300px);
}

.content {
    background-color: var(--card-bg);
    padding: 2rem;
    border-radius: 12px;
    box-shadow: var(--shadow);
    animation: fadeIn 0.5s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
    margin-bottom: 1rem;
    color: var(--primary-color);
    font-weight: 600;
}

h1 {
    font-size: 2.5rem;
    border-bottom: 3px solid var(--accent-color);
    padding-bottom: 0.5rem;
    margin-bottom: 1.5rem;
}

h2 {
    font-size: 2rem;
    color: var(--secondary-color);
    margin-top: 2rem;
}

h3 {
    font-size: 1.5rem;
    margin-top: 1.5rem;
}

p {
    margin-bottom: 1rem;
}

ul, ol {
    margin-bottom: 1rem;
    padding-right: 2rem;
}

li {
    margin-bottom: 0.5rem;
}

/* Cards */
.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
    margin-top: 2rem;
}

.card {
    background-color: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: var(--shadow);
    transition: all 0.3s ease;
    cursor: default;
}

.card[onclick],
.card[role="button"],
a.card {
    cursor: pointer;
}

.card:hover {
    box-shadow: var(--shadow-hover);
    transform: translateY(-4px);
    border-color: var(--accent-color);
}

.card h3 {
    color: var(--primary-color);
    margin-top: 0;
    margin-bottom: 1rem;
}

.card-icon {
    font-size: 2.5rem;
    margin-bottom: 1rem;
    display: block;
}

/* Buttons */
.btn {
    display: inline-block;
    padding: 0.75rem 1.5rem;
    background-color: var(--secondary-color);
    color: white;
    text-decoration: none;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 1rem;
    font-weight: 500;
    font-family: inherit;
}

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

.btn-back {
    background-color: var(--border-color);
    color: var(--text-color);
    margin-bottom: 1rem;
}

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

/* Session/Exercise Content */
.content-section {
    margin-bottom: 2rem;
    padding: 1.5rem;
    background-color: var(--bg-color);
    border-radius: 8px;
    border-right: 4px solid var(--accent-color);
}

/* Footer */
.footer {
    background-color: var(--primary-color);
    color: white;
    text-align: center;
    padding: 2rem 0;
    margin-top: 3rem;
}

.footer a {
    color: var(--accent-color);
}

/* Focus */
:focus-visible {
    outline: 3px solid var(--accent-color);
    outline-offset: 3px;
}

/* Dictionary extras */
.dictionary-toc {
    background: #E0F2F1;
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 16px;
}

.dictionary-toc a {
    margin-inline: 8px;
    color: var(--primary-color);
}

.badge {
    display: inline-block;
    background: #FFF8E1;
    color: var(--primary-color);
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 12px;
    margin-inline-start: 8px;
}

.section {
    margin-block: 28px;
}

/* Responsive Design */
@media (max-width: 768px) {
    .logo,
    .header .logo {
        font-size: 2rem;
    }

    .tagline {
        font-size: 0.9rem;
    }

    .nav .container {
        justify-content: flex-start;
        padding-top: 0.6rem;
        padding-bottom: 0.6rem;
    }

    .nav-toggle {
        display: inline-flex;
    }

    .nav-list {
        display: none;
        width: 100%;
        flex-direction: column;
        align-items: stretch;
        padding-top: 0.25rem;
        padding-bottom: 0.5rem;
    }

    .nav.is-open .nav-list {
        display: flex;
    }

    .nav-link {
        width: 100%;
        text-align: center;
    }

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

    h1 {
        font-size: 2rem;
    }

    h2 {
        font-size: 1.5rem;
    }

    .content {
        padding: 1.5rem;
    }
}

/* Highlight boxes */
.highlight-box {
    background-color: #FFF8E1;
    border-right: 4px solid var(--accent-color);
    padding: 1rem;
    margin: 1rem 0;
    border-radius: 4px;
}

.info-box {
    background-color: #E0F2F1;
    border-right: 4px solid var(--secondary-color);
    padding: 1rem;
    margin: 1rem 0;
    border-radius: 4px;
}

.success-box {
    background-color: #E8F5E9;
    border-right: 4px solid var(--secondary-color);
    padding: 1rem;
    margin: 1rem 0;
    border-radius: 4px;
}

/* Loading animation */
.loading {
    text-align: center;
    padding: 3rem;
    font-size: 1.2rem;
    color: var(--accent-color);
}

.loading::after {
    content: '...';
    animation: dots 1.5s steps(4, end) infinite;
}

@keyframes dots {
    0%, 20% { content: '.'; }
    40% { content: '..'; }
    60%, 100% { content: '...'; }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* Study citations: preserve the original colour palette and RTL layout. */
.study-note {font-size:.92rem; line-height:1.95; color:#455a64; border-inline-start:3px solid #00897B; padding-inline-start:1rem; margin-block:1.2rem;}
.study-note a,.source-card a {color:#4A148C; text-decoration:underline; text-underline-offset:3px;}
.source-card {border:1px solid #e2d8eb; border-radius:12px; padding:1.3rem; margin-block:1.25rem; background:#fff;}
.source-card h3 {margin-block:.75rem; color:#4A148C;}
.source-original {font-size:.9rem; overflow-wrap:anywhere; color:#455a64; text-align:left; line-height:1.7;}
.review-date {font-size:.88rem; color:#546e7a; margin-block:1.5rem;}
@media(min-width:769px){.nav-list{flex-wrap:wrap;}}
