/* =====================================================
   Imperial University College - Learning Platform
   Base Styles - Reset, Typography, Utilities
   ===================================================== */

/* =====================================================
   Reset
   ===================================================== */

*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
    -webkit-text-size-adjust: 100%;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

body {
    font-family: var(--font-ar);
    font-size: var(--fs-base);
    font-weight: var(--fw-normal);
    line-height: var(--lh-normal);
    color: var(--c-text);
    background-color: var(--c-bg);
    min-height: 100vh;
    direction: rtl;
}

/* English text */
[lang="en"],
.en {
    font-family: var(--font-en);
    direction: ltr;
    unicode-bidi: embed;
}

[lang="ar"],
.ar {
    font-family: var(--font-ar);
    direction: rtl;
}

/* =====================================================
   Typography
   ===================================================== */

h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-ar);
    font-weight: var(--fw-semibold);
    line-height: var(--lh-tight);
    color: var(--c-text);
    letter-spacing: var(--ls-tight);
}

h1 {
    font-size: var(--fs-3xl);
    font-weight: var(--fw-bold);
}

h2 {
    font-size: var(--fs-2xl);
}

h3 {
    font-size: var(--fs-xl);
}

h4 {
    font-size: var(--fs-lg);
}

h5 {
    font-size: var(--fs-md);
    font-weight: var(--fw-semibold);
}

h6 {
    font-size: var(--fs-base);
    font-weight: var(--fw-semibold);
}

p {
    color: var(--c-text-secondary);
    line-height: var(--lh-relaxed);
}

p + p {
    margin-top: var(--sp-3);
}

strong, b {
    font-weight: var(--fw-semibold);
    color: var(--c-text);
}

em, i {
    font-style: italic;
}

small {
    font-size: var(--fs-xs);
    color: var(--c-text-tertiary);
}

hr {
    border: none;
    height: 1px;
    background-color: var(--c-border);
    margin: var(--sp-6) 0;
}

code, kbd, pre, samp {
    font-family: var(--font-mono);
    font-size: 0.9em;
}

code {
    padding: 2px 6px;
    background-color: var(--c-slate-100);
    border-radius: var(--r-sm);
    color: var(--c-text);
    font-size: var(--fs-xs);
}

pre {
    padding: var(--sp-4);
    background-color: var(--c-slate-900);
    color: var(--c-slate-100);
    border-radius: var(--r-md);
    overflow-x: auto;
    font-size: var(--fs-sm);
    line-height: var(--lh-normal);
}

pre code {
    background: none;
    padding: 0;
    color: inherit;
}

/* =====================================================
   Links
   ===================================================== */

a {
    color: var(--c-primary);
    text-decoration: none;
    transition: color var(--t-fast);
}

a:hover {
    color: var(--c-primary-hover);
}

a:focus-visible {
    outline: 2px solid var(--c-primary);
    outline-offset: 2px;
    border-radius: var(--r-xs);
}

/* =====================================================
   Lists
   ===================================================== */

ul, ol {
    padding-inline-start: var(--sp-6);
    color: var(--c-text-secondary);
}

ul li, ol li {
    margin-bottom: var(--sp-2);
    line-height: var(--lh-relaxed);
}

ul li::marker {
    color: var(--c-primary);
}

.list-unstyled {
    list-style: none;
    padding: 0;
}

/* =====================================================
   Media
   ===================================================== */

img, svg, video, canvas, audio, iframe, embed, object {
    display: block;
    max-width: 100%;
}

img, video {
    height: auto;
}

svg {
    flex-shrink: 0;
}

/* =====================================================
   Forms - Base
   ===================================================== */

input, button, textarea, select {
    font: inherit;
    color: inherit;
}

button {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    color: inherit;
}

button:disabled {
    cursor: not-allowed;
}

textarea {
    resize: vertical;
}

input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

input[type="number"] {
    -moz-appearance: textfield;
}

/* =====================================================
   Focus
   ===================================================== */

:focus {
    outline: none;
}

:focus-visible {
    outline: 2px solid var(--c-primary);
    outline-offset: 2px;
}

/* =====================================================
   Selection
   ===================================================== */

::selection {
    background-color: var(--c-primary-light);
    color: var(--c-dark);
}

/* =====================================================
   Scrollbar (Subtle, Modern)
   ===================================================== */

::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--c-slate-300);
    border-radius: var(--r-full);
    border: 2px solid var(--c-bg);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--c-slate-400);
}

/* Firefox */
* {
    scrollbar-width: thin;
    scrollbar-color: var(--c-slate-300) transparent;
}

/* =====================================================
   Container
   ===================================================== */

.container {
    width: 100%;
    max-width: var(--content-max);
    margin-inline: auto;
    padding-inline: var(--sp-6);
}

.container--sm  { max-width: 640px; }
.container--md  { max-width: 960px; }
.container--lg  { max-width: 1200px; }
.container--xl  { max-width: 1440px; }
.container--fluid { max-width: 100%; }

/* =====================================================
   Visibility
   ===================================================== */

.hidden       { display: none !important; }
.invisible    { visibility: hidden !important; }
.visible      { visibility: visible !important; }

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* =====================================================
   Flex Utilities
   ===================================================== */

.flex             { display: flex; }
.inline-flex      { display: inline-flex; }
.flex-col         { flex-direction: column; }
.flex-row         { flex-direction: row; }
.flex-wrap        { flex-wrap: wrap; }
.flex-nowrap      { flex-wrap: nowrap; }
.flex-1           { flex: 1 1 0%; }
.flex-auto        { flex: 1 1 auto; }
.flex-none        { flex: none; }

.items-start      { align-items: flex-start; }
.items-center     { align-items: center; }
.items-end        { align-items: flex-end; }
.items-stretch    { align-items: stretch; }

.justify-start    { justify-content: flex-start; }
.justify-center   { justify-content: center; }
.justify-end      { justify-content: flex-end; }
.justify-between  { justify-content: space-between; }
.justify-around   { justify-content: space-around; }

.self-start       { align-self: flex-start; }
.self-center      { align-self: center; }
.self-end         { align-self: flex-end; }

/* =====================================================
   Grid Utilities
   ===================================================== */

.grid             { display: grid; }
.grid-cols-1      { grid-template-columns: repeat(1, minmax(0, 1fr)); }
.grid-cols-2      { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-cols-3      { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-cols-4      { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-cols-5      { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.grid-cols-6      { grid-template-columns: repeat(6, minmax(0, 1fr)); }

/* =====================================================
   Gap
   ===================================================== */

.gap-0   { gap: 0; }
.gap-1   { gap: var(--sp-1); }
.gap-2   { gap: var(--sp-2); }
.gap-3   { gap: var(--sp-3); }
.gap-4   { gap: var(--sp-4); }
.gap-5   { gap: var(--sp-5); }
.gap-6   { gap: var(--sp-6); }
.gap-7   { gap: var(--sp-7); }
.gap-8   { gap: var(--sp-8); }
.gap-10  { gap: var(--sp-10); }
.gap-12  { gap: var(--sp-12); }

/* =====================================================
   Margin Utilities
   ===================================================== */

.m-0     { margin: 0; }
.m-auto  { margin: auto; }
.mx-auto { margin-inline: auto; }

.mt-0  { margin-top: 0; }
.mt-1  { margin-top: var(--sp-1); }
.mt-2  { margin-top: var(--sp-2); }
.mt-3  { margin-top: var(--sp-3); }
.mt-4  { margin-top: var(--sp-4); }
.mt-5  { margin-top: var(--sp-5); }
.mt-6  { margin-top: var(--sp-6); }
.mt-8  { margin-top: var(--sp-8); }
.mt-10 { margin-top: var(--sp-10); }

.mb-0  { margin-bottom: 0; }
.mb-1  { margin-bottom: var(--sp-1); }
.mb-2  { margin-bottom: var(--sp-2); }
.mb-3  { margin-bottom: var(--sp-3); }
.mb-4  { margin-bottom: var(--sp-4); }
.mb-5  { margin-bottom: var(--sp-5); }
.mb-6  { margin-bottom: var(--sp-6); }
.mb-8  { margin-bottom: var(--sp-8); }
.mb-10 { margin-bottom: var(--sp-10); }

.ms-auto { margin-inline-start: auto; }
.me-auto { margin-inline-end: auto; }

/* =====================================================
   Padding Utilities
   ===================================================== */

.p-0  { padding: 0; }
.p-1  { padding: var(--sp-1); }
.p-2  { padding: var(--sp-2); }
.p-3  { padding: var(--sp-3); }
.p-4  { padding: var(--sp-4); }
.p-5  { padding: var(--sp-5); }
.p-6  { padding: var(--sp-6); }
.p-8  { padding: var(--sp-8); }
.p-10 { padding: var(--sp-10); }

.px-4 { padding-inline: var(--sp-4); }
.px-6 { padding-inline: var(--sp-6); }
.py-4 { padding-block: var(--sp-4); }
.py-6 { padding-block: var(--sp-6); }

/* =====================================================
   Text Alignment
   ===================================================== */

.text-start   { text-align: start; }
.text-center  { text-align: center; }
.text-end     { text-align: end; }
.text-justify { text-align: justify; }

/* =====================================================
   Text Sizes
   ===================================================== */

.text-xs   { font-size: var(--fs-xs); }
.text-sm   { font-size: var(--fs-sm); }
.text-base { font-size: var(--fs-base); }
.text-md   { font-size: var(--fs-md); }
.text-lg   { font-size: var(--fs-lg); }
.text-xl   { font-size: var(--fs-xl); }
.text-2xl  { font-size: var(--fs-2xl); }
.text-3xl  { font-size: var(--fs-3xl); }

/* =====================================================
   Text Colors
   ===================================================== */

.text-primary   { color: var(--c-text); }
.text-secondary { color: var(--c-text-secondary); }
.text-tertiary  { color: var(--c-text-tertiary); }
.text-muted     { color: var(--c-text-muted); }
.text-brand     { color: var(--c-primary); }
.text-dark      { color: var(--c-dark); }
.text-success   { color: var(--c-success); }
.text-warning   { color: var(--c-warning); }
.text-error     { color: var(--c-error); }

/* =====================================================
   Font Weights
   ===================================================== */

.font-light    { font-weight: var(--fw-light); }
.font-normal   { font-weight: var(--fw-normal); }
.font-medium   { font-weight: var(--fw-medium); }
.font-semibold { font-weight: var(--fw-semibold); }
.font-bold     { font-weight: var(--fw-bold); }

/* =====================================================
   Font Families
   ===================================================== */

.font-ar   { font-family: var(--font-ar); }
.font-en   { font-family: var(--font-en); }
.font-mono { font-family: var(--font-mono); }

/* =====================================================
   Text Overflow
   ===================================================== */

.truncate {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.line-clamp-1,
.line-clamp-2,
.line-clamp-3,
.line-clamp-4 {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.line-clamp-1 { -webkit-line-clamp: 1; }
.line-clamp-2 { -webkit-line-clamp: 2; }
.line-clamp-3 { -webkit-line-clamp: 3; }
.line-clamp-4 { -webkit-line-clamp: 4; }

.break-words    { overflow-wrap: break-word; word-break: break-word; }
.break-all      { word-break: break-all; }
.whitespace-nowrap { white-space: nowrap; }

/* =====================================================
   Width / Height
   ===================================================== */

.w-full   { width: 100%; }
.w-auto   { width: auto; }
.h-full   { height: 100%; }
.min-h-screen { min-height: 100vh; }

/* =====================================================
   Position
   ===================================================== */

.relative { position: relative; }
.absolute { position: absolute; }
.fixed    { position: fixed; }
.sticky   { position: sticky; }

.inset-0 { top: 0; right: 0; bottom: 0; left: 0; }

/* =====================================================
   Overflow
   ===================================================== */

.overflow-hidden   { overflow: hidden; }
.overflow-auto     { overflow: auto; }
.overflow-x-auto   { overflow-x: auto; }
.overflow-y-auto   { overflow-y: auto; }

/* =====================================================
   Divider
   ===================================================== */

.divider {
    height: 1px;
    background-color: var(--c-border);
    border: none;
    margin: var(--sp-5) 0;
}

.divider-vertical {
    width: 1px;
    height: auto;
    align-self: stretch;
    background-color: var(--c-border);
    margin-inline: var(--sp-3);
}

/* =====================================================
   Border Utilities
   ===================================================== */

.border       { border: 1px solid var(--c-border); }
.border-t     { border-top: 1px solid var(--c-border); }
.border-b     { border-bottom: 1px solid var(--c-border); }
.border-l     { border-left: 1px solid var(--c-border); }
.border-r     { border-right: 1px solid var(--c-border); }
.border-none  { border: none; }

/* =====================================================
   Rounded
   ===================================================== */

.rounded-xs   { border-radius: var(--r-xs); }
.rounded-sm   { border-radius: var(--r-sm); }
.rounded-md   { border-radius: var(--r-md); }
.rounded-lg   { border-radius: var(--r-lg); }
.rounded-xl   { border-radius: var(--r-xl); }
.rounded-2xl  { border-radius: var(--r-2xl); }
.rounded-full { border-radius: var(--r-full); }

/* =====================================================
   Cursor
   ===================================================== */

.cursor-pointer   { cursor: pointer; }
.cursor-default   { cursor: default; }
.cursor-not-allowed { cursor: not-allowed; }

/* =====================================================
   Pointer Events
   ===================================================== */

.pointer-events-none { pointer-events: none; }
.pointer-events-auto { pointer-events: auto; }

/* =====================================================
   Opacity
   ===================================================== */

.opacity-0   { opacity: 0; }
.opacity-50  { opacity: 0.5; }
.opacity-75  { opacity: 0.75; }
.opacity-100 { opacity: 1; }

/* =====================================================
   Transitions
   ===================================================== */

.transition       { transition: all var(--t-base); }
.transition-fast  { transition: all var(--t-fast); }
.transition-slow  { transition: all var(--t-slow); }

/* =====================================================
   Animations
   ===================================================== */

@keyframes fade-in {
    from { opacity: 0; }
    to   { opacity: 1; }
}

@keyframes fade-in-up {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

@keyframes fade-in-down {
    from { opacity: 0; transform: translateY(-8px); }
    to   { opacity: 1; transform: translateY(0); }
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to   { transform: rotate(360deg); }
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50%      { opacity: 0.5; }
}

@keyframes skeleton {
    0%   { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.animate-fade-in      { animation: fade-in var(--t-slow) ease-out; }
.animate-fade-in-up   { animation: fade-in-up var(--t-slower) ease-out; }
.animate-fade-in-down { animation: fade-in-down var(--t-slower) ease-out; }
.animate-spin         { animation: spin 0.8s linear infinite; }
.animate-pulse        { animation: pulse 2s ease-in-out infinite; }

/* =====================================================
   Print
   ===================================================== */

@media print {
    .no-print,
    .sidebar-overlay,
    nav,
    aside {
        display: none !important;
    }

    body {
        background: white;
        color: black;
    }

    a {
        color: black;
        text-decoration: underline;
    }
}