:root {
    --primary: #0f4c5c;
    --dark: #073b4c;
    --accent: #00a7a5;
    --gold: #d89a2b;
    --ink: #102331;
    --muted: #607081;
    --line: #dbe5ea;
    --bg: #eef4f6;
    --surface: #fff;
    --soft: #f5f9fa;
    --radius: 8px;
    --shadow: 0 16px 38px rgba(15, 35, 49, .09);
    --shadow-hover: 0 24px 52px rgba(15, 35, 49, .14);
}

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

html {
    overflow-x: hidden;
    scroll-behavior: smooth;
}

body {
    min-height: 100vh;
    overflow-x: hidden;
    background: var(--bg);
    color: var(--ink);
    font-family: Tajawal, system-ui, sans-serif;
    line-height: 1.65;
}

html[dir="ltr"] body {
    font-family: Inter, system-ui, sans-serif;
}

a {
    color: inherit;
    text-decoration: none;
}

button {
    font: inherit;
}

.en {
    direction: ltr;
    unicode-bidi: isolate;
    font-family: Inter, system-ui, sans-serif;
    letter-spacing: 0;
}

.nav {
    position: sticky;
    top: 0;
    z-index: 30;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    min-height: 70px;
    padding: 10px 5%;
    border-bottom: 1px solid rgba(219, 229, 234, .9);
    background: rgba(255, 255, 255, .94);
    box-shadow: 0 8px 24px rgba(15, 35, 49, .05);
    backdrop-filter: blur(14px);
    animation: nav-enter .55s ease both;
}

.brand,
.nav-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.brand img {
    width: 44px;
    height: 44px;
    flex: 0 0 44px;
    object-fit: contain;
    transition: transform .45s cubic-bezier(.2, .75, .25, 1);
}

.brand:hover img {
    transform: rotate(4deg) scale(1.04);
}

.brand strong {
    display: block;
    color: var(--dark);
    font-size: .96rem;
    font-weight: 800;
    line-height: 1.2;
}

.brand span {
    color: var(--muted);
    font-size: .8rem;
    font-weight: 700;
}

.btn {
    min-height: 42px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 8px 14px;
    border: 1px solid transparent;
    border-radius: var(--radius);
    background: var(--primary);
    color: #fff;
    font-weight: 700;
    line-height: 1.2;
    transition:
        transform .3s cubic-bezier(.2, .75, .25, 1),
        border-color .25s ease,
        background-color .25s ease,
        color .25s ease,
        box-shadow .3s ease;
}

.btn svg {
    width: 18px;
    height: 18px;
    flex: 0 0 auto;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.9;
    stroke-linecap: round;
    stroke-linejoin: round;
    transition: transform .3s ease;
}

.btn:hover {
    transform: translateY(-2px);
    background: var(--dark);
    box-shadow: 0 12px 26px rgba(15, 76, 92, .16);
}

.btn:hover svg {
    transform: translateY(-1px);
}

html[dir="rtl"] .back-to-courses svg {
    transform: rotate(180deg);
}

html[dir="rtl"] .back-to-courses:hover svg {
    transform: rotate(180deg) translateY(1px);
}

.btn.secondary {
    border-color: var(--line);
    background: #fff;
    color: var(--primary);
    box-shadow: none;
}

.btn.secondary:hover {
    border-color: rgba(0, 167, 165, .48);
    background: #f0fbfa;
    color: var(--dark);
}

.btn:focus-visible,
.type-tab:focus-visible,
.brand:focus-visible,
.breadcrumb a:focus-visible {
    outline: 3px solid rgba(0, 167, 165, .28);
    outline-offset: 3px;
}

.page-transition {
    transition: opacity .2s ease, transform .2s ease;
}

body.is-leaving .page-transition {
    opacity: .22;
    transform: translateY(6px);
}

.hero {
    position: relative;
    isolation: isolate;
    min-height: 360px;
    display: grid;
    align-items: end;
    overflow: hidden;
    color: #fff;
    background: var(--dark);
}

.hero-media,
.hero-shade {
    position: absolute;
    inset: 0;
    pointer-events: none;
}

.hero-media {
    z-index: -2;
    overflow: hidden;
}

.hero-media img {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: cover;
    object-position: center;
    transform: scale(1.035);
    animation: hero-image-drift 18s ease-in-out infinite alternate;
}

.hero-shade {
    z-index: -1;
    background: linear-gradient(90deg, rgba(7, 59, 76, .94) 0%, rgba(7, 59, 76, .82) 46%, rgba(15, 76, 92, .45) 100%);
}

html[dir="rtl"] .hero-shade {
    background: linear-gradient(270deg, rgba(7, 59, 76, .94) 0%, rgba(7, 59, 76, .82) 46%, rgba(15, 76, 92, .45) 100%);
}

.hero-inner {
    width: min(1120px, 90%);
    margin: 0 auto;
    padding: 44px 0 46px;
}

.breadcrumb {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 7px;
    margin-bottom: 22px;
    color: rgba(255, 255, 255, .76);
    font-size: .82rem;
    font-weight: 700;
    animation: hero-item-enter .58s .08s ease both;
}

.breadcrumb a {
    transition: color .2s ease;
}

.breadcrumb a:hover {
    color: #fff;
}

.breadcrumb svg {
    width: 15px;
    height: 15px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

html[dir="rtl"] .breadcrumb svg {
    transform: rotate(180deg);
}

.hero-label {
    display: flex;
    align-items: center;
    gap: 10px;
    animation: hero-item-enter .62s .14s ease both;
}

.hero-type-icon {
    width: 44px;
    height: 44px;
    display: grid;
    place-items: center;
    flex: 0 0 44px;
    border: 1px solid rgba(255, 255, 255, .3);
    border-radius: 50%;
    background: rgba(255, 255, 255, .12);
    color: #d8fffa;
    backdrop-filter: blur(8px);
}

.hero-type-icon svg {
    width: 21px;
    height: 21px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.kicker {
    color: #d8fffa;
    font-size: .92rem;
    font-weight: 800;
}

h1 {
    max-width: 920px;
    margin-top: 14px;
    overflow-wrap: anywhere;
    font-size: 3.55rem;
    font-weight: 800;
    line-height: 1.12;
    letter-spacing: 0;
    animation: hero-item-enter .68s .2s cubic-bezier(.2, .75, .25, 1) both;
}

.meta {
    width: 100%;
    display: flex;
    flex-wrap: wrap;
    gap: 9px;
    margin-top: 20px;
    animation: hero-item-enter .68s .28s cubic-bezier(.2, .75, .25, 1) both;
}

.meta span {
    min-height: 34px;
    display: inline-flex;
    align-items: center;
    padding: 5px 11px;
    border: 1px solid rgba(255, 255, 255, .2);
    border-radius: 999px;
    background: rgba(255, 255, 255, .11);
    color: rgba(255, 255, 255, .92);
    font-size: .82rem;
    font-weight: 700;
    backdrop-filter: blur(7px);
}

.page-content {
    width: min(1120px, 90%);
    margin: 0 auto;
    padding: 34px 0 72px;
}

.type-tabs {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 10px;
    margin-bottom: 36px;
}

.type-tab {
    position: relative;
    min-width: 0;
    min-height: 72px;
    display: grid;
    grid-template-columns: 38px minmax(0, 1fr) auto;
    align-items: center;
    gap: 10px;
    overflow: hidden;
    padding: 10px 11px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: rgba(255, 255, 255, .92);
    box-shadow: 0 9px 22px rgba(15, 35, 49, .05);
    animation: tab-enter .55s cubic-bezier(.2, .75, .25, 1) backwards;
    transition:
        transform .38s cubic-bezier(.2, .75, .25, 1),
        border-color .3s ease,
        background-color .3s ease,
        box-shadow .38s ease;
}

.type-tab::after {
    content: "";
    position: absolute;
    inset-inline: 10px;
    bottom: 0;
    height: 3px;
    border-radius: 3px 3px 0 0;
    background: var(--accent);
    opacity: 0;
    transform: scaleX(.3);
    transition: opacity .3s ease, transform .38s cubic-bezier(.2, .75, .25, 1);
}

.type-tab:hover {
    transform: translateY(-4px);
    border-color: rgba(0, 167, 165, .42);
    box-shadow: 0 16px 34px rgba(15, 35, 49, .1);
}

.type-tab.active {
    border-color: rgba(0, 167, 165, .48);
    background: #f0fbfa;
    box-shadow: 0 15px 34px rgba(15, 76, 92, .11);
}

.type-tab.active::after {
    opacity: 1;
    transform: scaleX(1);
}

.type-tab-icon {
    width: 38px;
    height: 38px;
    display: grid;
    place-items: center;
    border-radius: 6px;
    background: #eaf4f5;
    color: var(--primary);
    transition: transform .4s cubic-bezier(.2, .75, .25, 1), background-color .3s ease, color .3s ease;
}

.type-tab-icon svg,
.section-icon svg,
.material-icon svg {
    width: 20px;
    height: 20px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.type-tab:hover .type-tab-icon,
.type-tab.active .type-tab-icon {
    transform: rotate(3deg) scale(1.06);
    background: var(--primary);
    color: #fff;
}

html[dir="rtl"] .type-tab:hover .type-tab-icon,
html[dir="rtl"] .type-tab.active .type-tab-icon {
    transform: rotate(-3deg) scale(1.06);
}

.type-tab strong {
    min-width: 0;
    overflow-wrap: normal;
    word-break: keep-all;
    white-space: nowrap;
    color: var(--dark);
    font-size: .86rem;
    font-weight: 800;
    line-height: 1.35;
}

.type-tab-count {
    min-width: 28px;
    height: 28px;
    display: grid;
    place-items: center;
    padding: 0 6px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: #fff;
    color: var(--muted);
    font-family: Inter, system-ui, sans-serif;
    font-size: .72rem;
    font-weight: 800;
}

.type-tab.active .type-tab-count {
    border-color: transparent;
    background: var(--accent);
    color: #042f39;
}

.materials-section {
    min-width: 0;
}

.list-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 16px;
    padding-bottom: 15px;
    border-bottom: 1px solid #cfdee4;
}

.section-title {
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 12px;
}

.section-icon {
    width: 46px;
    height: 46px;
    display: grid;
    place-items: center;
    flex: 0 0 46px;
    border-radius: var(--radius);
    background: var(--dark);
    color: #fff;
    box-shadow: 0 10px 22px rgba(7, 59, 76, .15);
}

.section-kicker {
    display: block;
    margin-bottom: 1px;
    color: var(--accent);
    font-size: .75rem;
    font-weight: 800;
}

.list-head h2 {
    overflow-wrap: anywhere;
    color: var(--dark);
    font-size: 1.5rem;
    font-weight: 800;
    line-height: 1.3;
}

.file-total {
    flex: 0 0 auto;
    color: var(--muted);
    font-size: .82rem;
    font-weight: 700;
}

.list {
    display: grid;
    gap: 12px;
}

.material {
    position: relative;
    min-width: 0;
    display: grid;
    grid-template-columns: 38px 48px minmax(0, 1fr) auto;
    align-items: center;
    gap: 13px;
    overflow: hidden;
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow);
    transition:
        transform .48s cubic-bezier(.2, .75, .25, 1),
        border-color .35s ease,
        box-shadow .48s ease;
}

.material::before {
    content: "";
    position: absolute;
    inset-block: 12px;
    inset-inline-start: 0;
    width: 3px;
    border-radius: 0 3px 3px 0;
    background: var(--accent);
    transform: scaleY(.28);
    transition: transform .45s cubic-bezier(.2, .75, .25, 1);
}

html[dir="rtl"] .material::before {
    border-radius: 3px 0 0 3px;
}

.material:hover {
    transform: translateY(-4px);
    border-color: rgba(0, 167, 165, .4);
    box-shadow: var(--shadow-hover);
}

.material:hover::before {
    transform: scaleY(1);
}

.material-index {
    width: 34px;
    height: 34px;
    display: grid;
    place-items: center;
    border: 1px solid #cbdce2;
    border-radius: 50%;
    color: var(--muted);
    font-size: .7rem;
    font-weight: 800;
}

.material-icon {
    width: 48px;
    height: 48px;
    display: grid;
    place-items: center;
    border-radius: var(--radius);
    background: #eaf4f5;
    color: var(--primary);
    transition: transform .5s cubic-bezier(.2, .75, .25, 1), background-color .3s ease, color .3s ease;
}

.material:hover .material-icon {
    transform: rotate(4deg) scale(1.06);
    background: var(--primary);
    color: #fff;
}

html[dir="rtl"] .material:hover .material-icon {
    transform: rotate(-4deg) scale(1.06);
}

.material-copy {
    min-width: 0;
}

.material h3 {
    overflow-wrap: anywhere;
    color: var(--dark);
    font-size: 1.05rem;
    font-weight: 800;
    line-height: 1.45;
}

.material-description {
    margin-top: 3px;
    overflow-wrap: anywhere;
    color: var(--muted);
    font-size: .84rem;
}

.material-meta {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 7px 13px;
    margin-top: 7px;
    color: var(--muted);
    font-size: .76rem;
    font-weight: 700;
}

.material-meta span {
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.material-meta svg {
    width: 14px;
    height: 14px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

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

.actions .btn {
    min-width: 104px;
}

.empty {
    min-height: 210px;
    display: grid;
    place-items: center;
    align-content: center;
    gap: 12px;
    padding: 30px;
    border: 1px dashed #aec5ce;
    border-radius: var(--radius);
    background: rgba(255, 255, 255, .72);
    color: var(--muted);
    text-align: center;
    font-weight: 700;
}

.empty-icon {
    width: 58px;
    height: 58px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: #e8f3f4;
    color: var(--primary);
}

.empty-icon svg {
    width: 28px;
    height: 28px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.6;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.js [data-material-reveal] {
    opacity: 0;
    filter: blur(7px);
    transform: translate3d(0, 22px, 0) scale(.988);
}

.js [data-material-reveal].is-visible {
    opacity: 1;
    filter: none;
    transform: none;
    transition:
        opacity .7s ease var(--reveal-delay, 0ms),
        filter .7s ease var(--reveal-delay, 0ms),
        transform .72s cubic-bezier(.2, .75, .25, 1) var(--reveal-delay, 0ms);
}

.js [data-material-card].is-visible:hover {
    transform: translateY(-4px);
}

@keyframes nav-enter {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: none;
    }
}

@keyframes hero-image-drift {
    from { transform: scale(1.035) translate3d(0, 0, 0); }
    to { transform: scale(1.085) translate3d(-.7%, -.5%, 0); }
}

html[dir="rtl"] .hero-media img {
    animation-name: hero-image-drift-rtl;
}

@keyframes hero-image-drift-rtl {
    from { transform: scale(1.035) translate3d(0, 0, 0); }
    to { transform: scale(1.085) translate3d(.7%, -.5%, 0); }
}

@keyframes hero-item-enter {
    from {
        opacity: 0;
        transform: translateY(18px);
    }
    to {
        opacity: 1;
        transform: none;
    }
}

@keyframes tab-enter {
    from {
        opacity: 0;
        transform: translateY(14px) scale(.98);
    }
    to {
        opacity: 1;
        transform: none;
    }
}

@media (max-width: 920px) {
    h1 {
        font-size: 2.85rem;
    }

    .type-tabs {
        grid-template-columns: none;
        grid-auto-flow: column;
        grid-auto-columns: minmax(200px, 1fr);
        overflow-x: auto;
        padding: 3px 2px 12px;
        scroll-snap-type: inline mandatory;
        scrollbar-width: none;
    }

    .type-tabs::-webkit-scrollbar {
        display: none;
    }

    .type-tab {
        scroll-snap-align: start;
    }

    .material {
        grid-template-columns: 38px 48px minmax(0, 1fr);
    }

    .material .actions {
        grid-column: 2 / -1;
        justify-content: flex-start;
    }
}

@media (max-width: 640px) {
    .nav {
        min-height: 66px;
        padding-inline: 14px;
    }

    .brand-copy {
        display: none;
    }

    .nav-actions {
        justify-content: flex-end;
    }

    .btn {
        padding-inline: 11px;
    }

    .back-to-courses {
        width: 40px;
        min-width: 40px;
        min-height: 40px;
        padding: 0;
    }

    .back-to-courses span {
        display: none;
    }

    .hero {
        min-height: 320px;
    }

    .hero-inner,
    .page-content {
        width: calc(100% - 28px);
    }

    .hero-inner {
        padding: 34px 0 38px;
    }

    .breadcrumb {
        margin-bottom: 18px;
    }

    h1 {
        font-size: 2.15rem;
        line-height: 1.2;
    }

    .meta {
        gap: 7px;
    }

    .meta span {
        min-height: 31px;
        font-size: .74rem;
    }

    .page-content {
        padding-top: 26px;
    }

    .type-tabs {
        grid-auto-columns: minmax(200px, 1fr);
        margin-bottom: 30px;
    }

    .list-head {
        align-items: flex-start;
        flex-direction: column;
        gap: 8px;
    }

    .list-head h2 {
        font-size: 1.3rem;
    }

    .material {
        grid-template-columns: 36px 44px minmax(0, 1fr);
        gap: 10px;
        padding: 14px 12px;
    }

    .material-icon {
        width: 44px;
        height: 44px;
    }

    .material .actions {
        grid-column: 1 / -1;
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .actions .btn {
        min-width: 0;
        width: 100%;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        animation: none !important;
        transition-duration: .01ms !important;
        transition-delay: 0ms !important;
    }

    .js [data-material-reveal] {
        opacity: 1;
        filter: none;
        transform: none;
    }
}
