/* ============================================================
   EP550 Course — Design System
   ============================================================ */



/* ----- Design Tokens ----- */
:root {
    /* palette */
    --primary:          #1e3a5f;
    --primary-light:    #2d5a8e;
    --primary-dark:     #0f2440;
    --accent:           #b91c1c;
    --accent-light:     #e02424;
    --success:          #15803d;
    --success-light:    #16a34a;
    --warning:          #d97706;
    --text:             #1f2937;
    --text-muted:       #6b7280;
    --bg:               #ffffff;
    --bg-subtle:        #f9fafb;
    --bg-card:          #ffffff;
    --border:           #e5e7eb;
    --border-light:     #f0f0f0;

    /* spacing */
    --space-xs:   0.25rem;
    --space-sm:   0.5rem;
    --space-md:   1rem;
    --space-lg:   1.5rem;
    --space-xl:   2rem;
    --space-2xl:  3rem;

    /* typography */
    --font-family: 'Noto Naskh Arabic', system-ui, -apple-system, sans-serif;
    --font-weight-light:   300;
    --font-weight-regular: 400;
    --font-weight-medium:  500;
    --font-weight-semibold:600;
    --font-weight-bold:    700;
    --line-height:         1.7;
    --line-heading:        1.3;

    /* layout */
    --sidebar-width: 280px;
    --header-height: auto;
    --content-max-width: 960px;
    --radius: 8px;
    --radius-sm: 4px;

    /* transitions */
    --transition-fast: 0.15s ease;
    --transition-base: 0.25s ease;
}

/* ----- Reset & Base ----- */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
    font-size: 16px;
}

body {
    font-family: var(--font-family);
    font-weight: var(--font-weight-regular);
    line-height: var(--line-height);
    color: var(--text);
    background: var(--bg);
    direction: rtl;
    text-align: right;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

img {
    max-width: 100%;
    height: auto;
    display: block;
}

a {
    color: var(--primary-light);
    text-decoration: none;
    transition: color var(--transition-fast);
}

a:hover {
    color: var(--primary);
    text-decoration: underline;
}

:focus-visible {
    outline: 2px solid var(--primary-light);
    outline-offset: 2px;
    border-radius: var(--radius-sm);
}

:focus:not(:focus-visible) {
    outline: none;
}

a:focus-visible {
    text-decoration: none;
}

ul, ol {
    padding-right: 1.25rem;
}

/* ----- Skip Link ----- */
.skip-link {
    position: absolute;
    top: -100px;
    right: 0;
    background: var(--primary);
    color: #fff;
    padding: var(--space-sm) var(--space-md);
    z-index: 1000;
    transition: top var(--transition-fast);
    border-radius: 0 0 var(--radius-sm) var(--radius-sm);
}

.skip-link:focus {
    top: 0;
    text-decoration: none;
    color: #fff;
}

/* ============================================================
   HEADER
   ============================================================ */
.site-header {
    background: var(--primary);
    color: #fff;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 1px 3px rgba(0,0,0,0.12);
}

.header-inner {
    max-width: 1320px;
    margin: 0 auto;
    padding: var(--space-md) var(--space-xl);
    display: flex;
    align-items: center;
    gap: var(--space-lg);
}

.header-home {
    color: #fff;
    font-size: 1.5rem;
    line-height: 1;
    flex-shrink: 0;
    transition: opacity var(--transition-fast);
}

.header-home:hover {
    color: #fff;
    opacity: 0.8;
    text-decoration: none;
}

.header-text {
    flex: 1;
    min-width: 0;
}

.header-title {
    font-weight: var(--font-weight-semibold);
    font-size: 1rem;
    line-height: var(--line-heading);
}

.header-subtitle {
    font-weight: var(--font-weight-light);
    font-size: 0.85rem;
    opacity: 0.85;
    margin-top: 2px;
}

.header-stats {
    display: flex;
    gap: var(--space-lg);
    font-size: 0.8rem;
    opacity: 0.9;
    flex-shrink: 0;
}

.header-stats span {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
}

.header-stats .bi {
    font-size: 0.9rem;
}

/* ============================================================
   LAYOUT — Sidebar + Main
   ============================================================ */
.layout-wrapper {
    display: flex;
    max-width: 1320px;
    margin: 0 auto;
    width: 100%;
    flex: 1;
}

/* ----- Sidebar ----- */
.sidebar {
    width: var(--sidebar-width);
    flex-shrink: 0;
    position: sticky;
    top: var(--header-height);
    align-self: flex-start;
    max-height: calc(100vh - 60px);
    overflow-y: auto;
    padding: var(--space-lg) var(--space-md);
    border-left: 1px solid var(--border);
    background: var(--bg);
}

.sidebar::-webkit-scrollbar {
    width: 4px;
}

.sidebar::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 99px;
}

.sidebar-title {
    font-size: 0.85rem;
    font-weight: var(--font-weight-semibold);
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: var(--space-md);
}

.sidebar-nav {
    list-style: none;
    padding: 0;
}

.sidebar-nav li {
    margin-bottom: 2px;
}

.sidebar-nav a {
    display: block;
    padding: var(--space-xs) var(--space-sm);
    font-size: 0.9rem;
    color: var(--text);
    border-radius: var(--radius-sm);
    transition: background var(--transition-fast), color var(--transition-fast);
}

.sidebar-nav a:hover,
.sidebar-nav a.active {
    background: var(--bg-subtle);
    color: var(--primary);
    text-decoration: none;
}

.sidebar-nav a.active {
    font-weight: var(--font-weight-medium);
    border-right: 3px solid var(--primary);
}

/* ----- Main Content ----- */
.main-content {
    flex: 1;
    min-width: 0;
    max-width: var(--content-max-width);
    padding: var(--space-2xl) var(--space-xl);
}

/* ============================================================
   TYPOGRAPHY
   ============================================================ */
h1, h2, h3, h4, h5, h6 {
    font-weight: var(--font-weight-semibold);
    line-height: var(--line-heading);
    color: var(--primary);
    margin-top: var(--space-xl);
    margin-bottom: var(--space-md);
}

h1 { font-size: 2rem; margin-top: 0; }
h2 { font-size: 1.5rem; border-bottom: 2px solid var(--border); padding-bottom: var(--space-sm); }
h3 { font-size: 1.2rem; }
h4 { font-size: 1.05rem; }

p {
    margin-bottom: var(--space-md);
}

/* ----- Lists ----- */
.content-list {
    margin-bottom: var(--space-md);
}

.content-list li {
    margin-bottom: var(--space-xs);
}

/* ----- Blockquote ----- */
blockquote {
    border-right: 4px solid var(--primary-light);
    background: var(--bg-subtle);
    padding: var(--space-md) var(--space-lg);
    margin: var(--space-md) 0;
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    color: var(--text-muted);
}

/* ============================================================
   COMPONENTS
   ============================================================ */

/* ----- Content Box ----- */
.content-box {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: var(--space-lg);
    margin-bottom: var(--space-lg);
}

.content-box h3:first-child,
.content-box h4:first-child {
    margin-top: 0;
}

/* ----- Formula Box ----- */
.formula-box {
    background: #f0f4f8;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: var(--space-md) var(--space-lg);
    margin: var(--space-md) 0;
    text-align: center;
    font-size: 1.05rem;
    font-family: var(--font-family);
}

/* ----- Info Box / Callout ----- */
.info-box {
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    border-radius: var(--radius);
    padding: var(--space-md) var(--space-lg);
    margin: var(--space-md) 0;
    color: #1e40af;
}

.info-box strong {
    color: var(--primary);
}

/* ----- Warning Box ----- */
.warning-box {
    background: #fefce8;
    border: 1px solid #fde68a;
    border-radius: var(--radius);
    padding: var(--space-md) var(--space-lg);
    margin: var(--space-md) 0;
    color: #92400e;
}

/* ----- Module Card (index page) ----- */
.module-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: var(--space-lg);
    margin-bottom: var(--space-md);
    transition: border-color var(--transition-base), transform var(--transition-base);
}

.module-card:hover {
    border-color: var(--primary-light);
    transform: translateY(-2px);
}

.module-card-title {
    font-size: 1.05rem;
    font-weight: var(--font-weight-semibold);
    color: var(--primary);
    margin-bottom: var(--space-sm);
}

.module-card-lessons {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: var(--space-sm);
}

.module-card-desc {
    font-size: 0.9rem;
    color: var(--text);
}

.module-card a {
    color: inherit;
    text-decoration: none;
}

.module-card a:hover {
    text-decoration: none;
}

/* ----- Tables ----- */
.table-wrap {
    overflow-x: auto;
    margin-bottom: var(--space-lg);
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
    margin-bottom: var(--space-md);
}

thead th {
    background: var(--primary);
    color: #fff;
    padding: var(--space-sm) var(--space-md);
    text-align: right;
    font-weight: var(--font-weight-medium);
    white-space: nowrap;
}

tbody td {
    padding: var(--space-sm) var(--space-md);
    border-bottom: 1px solid var(--border);
}

tbody tr:hover {
    background: var(--bg-subtle);
}

/* ----- Buttons ----- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-lg);
    font-family: var(--font-family);
    font-size: 0.9rem;
    font-weight: var(--font-weight-medium);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background var(--transition-fast), border-color var(--transition-fast), color var(--transition-fast);
    background: var(--bg);
    color: var(--text);
    text-decoration: none;
    line-height: 1.4;
}

.btn:hover {
    background: var(--bg-subtle);
    border-color: var(--text-muted);
    text-decoration: none;
}

.btn-primary {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

.btn-primary:hover {
    background: var(--primary-light);
    border-color: var(--primary-light);
    color: #fff;
}

/* ----- Tags / Badges ----- */
.tag {
    display: inline-block;
    font-size: 0.75rem;
    font-weight: var(--font-weight-medium);
    padding: 2px var(--space-sm);
    border-radius: 99px;
    background: var(--bg-subtle);
    color: var(--text-muted);
    border: 1px solid var(--border);
}

.tag-primary {
    background: #eff6ff;
    color: var(--primary);
    border-color: #bfdbfe;
}

.tag-success {
    background: #f0fdf4;
    color: var(--success);
    border-color: #bbf7d0;
}

/* ----- Figures & Captions ----- */
figure {
    margin: var(--space-lg) 0;
    text-align: center;
}

figcaption {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: var(--space-sm);
}

/* ----- Code / Inline Code ----- */
code {
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
    font-size: 0.85em;
    background: var(--bg-subtle);
    padding: 2px 6px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-light);
}

pre {
    background: #1f2937;
    color: #1d4ed8;
    padding: var(--space-md) var(--space-lg);
    border-radius: var(--radius);
    overflow-x: auto;
    margin-bottom: var(--space-md);
    font-size: 0.85rem;
    direction: ltr;
    text-align: left;
}

pre code {
    background: none;
    border: none;
    padding: 0;
    color: inherit;
}

/* ============================================================
   FORM ELEMENTS (minimal reset)
   ============================================================ */
input[type="text"],
input[type="search"],
input[type="url"],
input[type="email"],
input[type="password"],
textarea,
select {
    font-family: var(--font-family);
    font-size: 0.9rem;
    padding: var(--space-sm) var(--space-md);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg);
    color: var(--text);
    transition: border-color var(--transition-fast);
}

input:focus,
textarea:focus,
select:focus {
    outline: none;
    border-color: var(--primary-light);
    box-shadow: 0 0 0 3px rgba(45, 90, 142, 0.15);
}

/* ============================================================
   INDEX PAGE (Course Home)
   ============================================================ */
.index-container {
    max-width: 1100px;
    margin: 0 auto;
    padding: var(--space-2xl) var(--space-xl);
}

.course-home-intro {
    text-align: center;
    margin-bottom: var(--space-2xl);
}

.course-home-intro h1 {
    font-size: 2rem;
    margin: var(--space-md) 0;
}

.course-home-intro p {
    font-size: 1.05rem;
    color: var(--text-muted);
    max-width: 700px;
    margin: 0 auto;
}

.stat-badge {
    display: inline-block;
    background: #eff6ff;
    color: var(--primary);
    padding: var(--space-xs) var(--space-md);
    border-radius: 99px;
    font-size: 0.85rem;
    font-weight: var(--font-weight-medium);
    border: 1px solid #bfdbfe;
}

.resource-strip {
    display: flex;
    justify-content: center;
    gap: var(--space-md);
    margin-top: var(--space-lg);
    flex-wrap: wrap;
}

.resource-strip a {
    display: inline-flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-lg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.9rem;
    color: var(--text);
    transition: border-color var(--transition-fast), background var(--transition-fast);
}

.resource-strip a:hover {
    border-color: var(--primary-light);
    background: var(--bg-subtle);
    text-decoration: none;
}

.pillar-section {
    margin-bottom: var(--space-2xl);
}

.pillar-heading {
    margin-bottom: var(--space-lg);
    border-bottom: 2px solid var(--border);
    padding-bottom: var(--space-sm);
}

.pillar-heading span {
    display: inline-block;
    font-size: 0.78rem;
    font-weight: var(--font-weight-semibold);
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: var(--space-xs);
}

.pillar-heading h2 {
    margin: 0;
    border: none;
    padding: 0;
}

.module-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: var(--space-md);
}

.module-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: var(--space-lg);
    transition: border-color var(--transition-base), transform var(--transition-base);
}

.module-card:hover {
    border-color: var(--primary-light);
    transform: translateY(-2px);
}

.module-header {
    display: flex;
    gap: var(--space-md);
    align-items: flex-start;
    margin-bottom: var(--space-md);
}

.module-icon {
    font-size: 1.5rem;
    color: var(--primary-light);
    flex-shrink: 0;
}

.module-header h3 {
    margin: 0;
    font-size: 1.05rem;
}

.module-header h3 a {
    color: var(--primary);
}

.module-header h3 a:hover {
    color: var(--primary-light);
}

.module-desc {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: var(--space-xs);
}

.module-body {
    border-top: 1px solid var(--border-light);
    padding-top: var(--space-md);
}

.topic-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.topic-list li {
    margin-bottom: var(--space-xs);
    font-size: 0.88rem;
}

.topic-link {
    display: inline-flex;
    align-items: center;
    gap: var(--space-xs);
    color: var(--text);
}

.topic-link .bi {
    color: var(--success);
    font-size: 0.85rem;
}

.topic-link.cta {
    color: var(--primary-light);
    font-weight: var(--font-weight-medium);
    margin-top: var(--space-sm);
}

.topic-link.cta:hover {
    text-decoration: underline;
}

.unit-resource-chip {
    display: inline-flex;
    align-items: center;
    gap: var(--space-sm);
    margin-top: var(--space-md);
    padding: var(--space-xs) var(--space-md);
    background: #eff6ff;
    color: var(--primary);
    border-radius: 99px;
    font-size: 0.82rem;
    font-weight: var(--font-weight-medium);
    border: 1px solid #bfdbfe;
    transition: background var(--transition-fast);
}

.unit-resource-chip:hover {
    background: #dbeafe;
    text-decoration: none;
}

@media (max-width: 768px) {
    .index-container {
        padding: var(--space-lg) var(--space-md);
    }

    .course-home-intro h1 {
        font-size: 1.5rem;
    }

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

/* ============================================================
   FOOTER
   ============================================================ */
.site-footer {
    background: var(--primary);
    color: #fff;
    margin-top: auto;
}

.footer-inner {
    max-width: 1320px;
    margin: 0 auto;
    padding: var(--space-lg) var(--space-xl);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-md);
}

.footer-links {
    display: flex;
    gap: var(--space-lg);
}

.footer-links a {
    color: rgba(255,255,255,0.85);
    font-size: 0.9rem;
}

.footer-links a:hover {
    color: #fff;
}

.footer-copy {
    font-size: 0.8rem;
    opacity: 0.75;
    margin: 0;
}

/* ============================================================
   PROGRESS / GLOSSARY SPECIFIC
   ============================================================ */
.progress-bar {
    height: 8px;
    background: var(--border);
    border-radius: 99px;
    overflow: hidden;
    margin-bottom: var(--space-md);
}

.progress-fill {
    height: 100%;
    background: var(--success);
    border-radius: 99px;
    transition: width var(--transition-base);
}

.glossary-term {
    font-weight: var(--font-weight-semibold);
    color: var(--primary);
}

.glossary-def {
    margin-bottom: var(--space-md);
    padding-right: var(--space-md);
    border-right: 2px solid var(--border);
}

/* ============================================================
   UTILITY
   ============================================================ */
.text-center { text-align: center; }
.text-muted { color: var(--text-muted); }
.mt-0 { margin-top: 0; }
.mb-0 { margin-bottom: 0; }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 1024px) {
    .layout-wrapper {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        position: static;
        max-height: none;
        overflow-y: visible;
        border-left: none;
        border-bottom: 1px solid var(--border);
        padding: var(--space-md);
    }

    .sidebar-nav {
        display: flex;
        flex-wrap: wrap;
        gap: var(--space-xs);
    }

    .sidebar-nav li {
        margin-bottom: 0;
    }

    .sidebar-nav a {
        padding: var(--space-xs) var(--space-sm);
        font-size: 0.85rem;
        white-space: nowrap;
    }

    .sidebar-nav a.active {
        border-right: none;
        border-bottom: 2px solid var(--primary);
    }

    .main-content {
        max-width: 100%;
        padding: var(--space-lg) var(--space-md);
    }
}

@media (max-width: 768px) {
    .header-inner {
        flex-wrap: wrap;
        gap: var(--space-sm);
        padding: var(--space-sm) var(--space-md);
    }

    .header-stats {
        display: none;
    }

    .header-title {
        font-size: 0.9rem;
    }

    .header-subtitle {
        font-size: 0.8rem;
    }

    h1 { font-size: 1.5rem; }
    h2 { font-size: 1.25rem; }

    .footer-inner {
        flex-direction: column;
        text-align: center;
    }
}

@media (max-width: 480px) {
    .main-content {
        padding: var(--space-md) var(--space-sm);
    }

    h1 { font-size: 1.3rem; }
    h2 { font-size: 1.1rem; }
    h3 { font-size: 1rem; }

    .content-box {
        padding: var(--space-md);
    }

    table {
        font-size: 0.8rem;
    }

    thead th,
    tbody td {
        padding: var(--space-xs) var(--space-sm);
    }
}

/* ============================================================
   PRINT STYLES
   ============================================================ */
@media print {
    @page {
        margin: 15mm 12mm;
    }

    *, *::before, *::after {
        box-shadow: none !important;
        text-shadow: none !important;
    }

    html, body {
        background: #fff !important;
        color: #000 !important;
        font-size: 10pt;
        line-height: 1.5;
    }

    .site-header,
    .site-footer,
    .sidebar,
    .sidebar-overlay,
    .hamburger-btn,
    .breadcrumb,
    .bottom-nav,
    .btn-nav,
    .quiz-item,
    .questions-section,
    .skip-link,
    .header-stats {
        display: none !important;
    }

    .content-wrapper {
        display: block !important;
    }

    .main-content {
        max-width: 100% !important;
        padding: 0 !important;
        margin: 0 !important;
    }

    .chapter-intro,
    .content-box,
    .info-box,
    .formula-box,
    .chart-container,
    .card-white,
    .module-card {
        border: 1px solid #ccc !important;
        background: #fff !important;
        page-break-inside: avoid;
    }

    .chapter-intro {
        border-right-width: 3px;
    }

    h1, h2, h3, h4, h5, h6 {
        color: #000 !important;
        page-break-after: avoid;
    }

    a {
        color: #000 !important;
        text-decoration: underline;
    }

    a[href^="http"]::after {
        content: " (" attr(href) ")";
        font-size: 0.8em;
        color: #666;
    }

    img {
        max-width: 100% !important;
        page-break-inside: avoid;
    }

    table {
        border: 1px solid #000;
        page-break-inside: avoid;
    }

    thead th {
        background: #333 !important;
        color: #fff !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    .term-badge,
    .term-en {
        font-family: var(--font-family);
    }

    .dt-node,
    .dt-answer.yes,
    .dt-answer.no,
    .card-success,
    .card-warning,
    .card-secondary,
    .card-primary {
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    .step-num {
        background: #333 !important;
    }

    pre, code {
        border: 1px solid #ccc;
        background: #f9f9f9 !important;
        color: #000 !important;
    }

    .var-cards {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        gap: 8px;
    }
}
