:root {
    --bg: #0A0A0C;
    --surface: #0F0D12;
    --surface-2: #121014;
    --border: #241E2C;

    --purple-dark: #2E0B4E;
    --purple: #4B1878;
    --purple-light: #8A4FD1;

    --text: #EDEBF2;
    --muted: #8F879B;
    --dim: #6E6480;

    --grid: rgba(138, 79, 209, 0.055);
}

[data-theme="light"] {
    --bg: #F6F4F8;
    --surface: #FFFFFF;
    --surface-2: #EFECF3;
    --border: #D9D1E1;

    --text: #17131C;
    --muted: #62586D;
    --dim: #81758D;

    --grid: rgba(75, 24, 120, 0.06);
}

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: "Space Grotesk", sans-serif;
    transition: background .3s ease, color .3s ease;
    overflow-x: hidden;
}

/* ================= LANGUAGE / RTL ================= */

[lang="en"] .lang-ar {
    display: none;
}

[lang="ar"] .lang-en {
    display: none;
}

[dir="rtl"] body {
    font-family: "IBM Plex Sans Arabic", "Space Grotesk", sans-serif;
}

[dir="rtl"] pre,
[dir="rtl"] code,
[dir="rtl"] .terminal-line {
    direction: ltr;
    text-align: left;
}

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

button {
    font: inherit;
}

.research-page {
    min-height: 100vh;
    overflow: hidden;
}

/* ================= PAGE LOADER ================= */

.page-loader {
    position: fixed;
    inset: 0;
    z-index: 10000;

    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;

    background: var(--bg);
    color: var(--purple-light);

    animation: loaderOut .7s ease 1.2s forwards;
    pointer-events: none;
}

.loader-mark {
    font-size: 42px;
    color: var(--purple-light);
    animation: loaderPulse 800ms infinite alternate;
}

.loader-text {
    margin-top: 15px;
    font-size: 12px;
    letter-spacing: 7px;
    color: var(--muted);
}

.loader-text span {
    color: var(--purple-light);
}

@keyframes loaderPulse {
    from { opacity: .35; transform: scale(.9); }
    to { opacity: 1; transform: scale(1.1); }
}

@keyframes loaderOut {
    to {
        opacity: 0;
        visibility: hidden;
    }
}


/* =========================
   NAV
========================= */

.research-nav {
    height: 76px;
    padding: 0 6vw;

    display: flex;
    align-items: center;
    justify-content: space-between;

    border-bottom: 1px solid var(--border);

    background: rgba(10, 10, 12, 0.82);

    backdrop-filter: blur(18px);

    position: sticky;
    top: 0;
    z-index: 100;
}

[data-theme="light"] .research-nav {
    background: rgba(246, 244, 248, 0.88);
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;

    font-weight: 700;
    letter-spacing: 4px;
}

.brand > span:last-child span {
    color: var(--purple-light);
}

.brand-mark {
    width: 30px;
    height: 30px;
}

.brand-mark svg {
    width: 100%;
    height: 100%;
}

.research-nav nav {
    display: flex;
    gap: 28px;
}

.research-nav nav a {
    color: var(--muted);
    font-size: 13px;
    transition: .25s ease;
}

.research-nav nav a:hover,
.research-nav nav a.active {
    color: var(--purple-light);
}

.nav-actions {
    display: flex;
    gap: 8px;
}

.nav-actions button {
    width: 36px;
    height: 36px;

    border: 1px solid var(--border);
    background: var(--surface);

    color: var(--text);

    cursor: pointer;

    transition: .25s ease;
}

.nav-actions button:hover {
    border-color: var(--purple-light);
    color: var(--purple-light);
}

#menuToggle {
    display: none;
}


/* =========================
   HERO
========================= */

.research-hero {
    position: relative;
    min-height: 720px;

    padding: 130px 10vw 80px;

    display: flex;
    flex-direction: column;
    justify-content: center;

    overflow: hidden;
}

.hero-grid {
    position: absolute;
    inset: 0;

    background-image:
        linear-gradient(var(--grid) 1px, transparent 1px),
        linear-gradient(90deg, var(--grid) 1px, transparent 1px);

    background-size: 50px 50px;

    mask-image: linear-gradient(to bottom, black, transparent);
}

.hero-grid::after {
    content: "";

    position: absolute;

    width: 500px;
    height: 500px;

    top: 20%;
    right: 5%;

    background: radial-gradient(
        circle,
        rgba(138, 79, 209, .18),
        transparent 65%
    );

    filter: blur(30px);
}

.terminal-line {
    position: relative;

    color: var(--dim);

    font-family: "IBM Plex Mono", monospace;
    font-size: 13px;

    margin-bottom: 22px;
}

.terminal-line span {
    color: var(--purple-light);
}

.status {
    position: relative;

    display: inline-flex;
    align-items: center;
    gap: 9px;

    width: fit-content;

    padding: 7px 12px;

    border: 1px solid var(--border);

    background: rgba(75, 24, 120, .08);

    color: var(--purple-light);

    font-family: "IBM Plex Mono", monospace;
    font-size: 10px;
    letter-spacing: 2px;
}

.status i {
    width: 6px;
    height: 6px;

    background: var(--purple-light);
    border-radius: 50%;

    box-shadow: 0 0 12px var(--purple-light);

    animation: pulse 1.8s infinite;
}

@keyframes pulse {
    50% {
        opacity: .35;
    }
}

.research-hero h1 {
    position: relative;

    max-width: 950px;

    margin: 28px 0 24px;

    font-size: clamp(54px, 8vw, 110px);

    line-height: .92;

    letter-spacing: -5px;
}

.research-hero h1 span {
    color: var(--purple-light);
}

.hero-description {
    position: relative;

    max-width: 650px;

    color: var(--muted);

    font-size: 17px;
    line-height: 1.8;
}

.hero-buttons {
    position: relative;

    display: flex;
    gap: 12px;

    margin-top: 32px;
}

.btn-primary,
.btn-secondary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 20px;

    padding: 14px 20px;

    font-size: 12px;
    font-weight: 600;

    letter-spacing: 1px;

    transition: .25s ease;
}

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

    border: 1px solid var(--purple);
}

.btn-primary:hover {
    background: var(--purple-light);
    transform: translateY(-3px);

    box-shadow: 0 12px 35px rgba(138, 79, 209, .25);
}

.btn-secondary {
    border: 1px solid var(--border);
    color: var(--muted);
}

.btn-secondary:hover {
    border-color: var(--purple-light);
    color: var(--purple-light);
}

.hero-metrics {
    position: relative;

    display: flex;
    gap: 60px;

    margin-top: 90px;

    border-top: 1px solid var(--border);

    padding-top: 28px;
}

.hero-metrics div {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.hero-metrics strong {
    font-family: "IBM Plex Mono", monospace;

    font-size: 30px;

    color: var(--text);
}

.hero-metrics span {
    color: var(--dim);

    font-size: 10px;

    text-transform: uppercase;

    letter-spacing: 2px;
}


/* =========================
   SECTIONS
========================= */

.section {
    padding: 120px 8vw;
    border-top: 1px solid var(--border);
}

.section-heading {
    max-width: 700px;
    margin-bottom: 60px;
}

.section-heading.compact {
    margin-bottom: 40px;
}

.eyebrow {
    color: var(--purple-light);

    font-family: "IBM Plex Mono", monospace;

    font-size: 11px;

    letter-spacing: 3px;

    margin-bottom: 18px;
}

.section-heading h2 {
    margin: 0 0 20px;

    font-size: clamp(40px, 5vw, 70px);

    line-height: .95;

    letter-spacing: -3px;
}

.section-heading h2 span {
    color: var(--muted);
}

.section-heading p {
    color: var(--muted);

    line-height: 1.8;
}


/* =========================
   RESEARCH AREAS
========================= */

.area-grid {
    display: grid;

    grid-template-columns: repeat(3, 1fr);

    border-top: 1px solid var(--border);
    border-left: 1px solid var(--border);
}

.area-card {
    position: relative;

    min-height: 300px;

    padding: 34px;

    border-right: 1px solid var(--border);
    border-bottom: 1px solid var(--border);

    overflow: hidden;

    transition: .35s ease;
}

.area-card::before {
    content: "";

    position: absolute;

    width: 250px;
    height: 250px;

    left: var(--mouse-x, 50%);
    top: var(--mouse-y, 50%);

    transform: translate(-50%, -50%);

    background: radial-gradient(
        circle,
        rgba(138,79,209,.14),
        transparent 70%
    );

    opacity: 0;

    transition: opacity .25s;

    pointer-events: none;
}

.area-card:hover::before {
    opacity: 1;
}

.area-card:hover {
    background: var(--surface);
}

.area-number {
    position: absolute;

    top: 25px;
    right: 30px;

    font-family: "IBM Plex Mono", monospace;

    color: var(--dim);

    font-size: 11px;
}

.area-icon {
    width: 48px;
    height: 48px;

    display: flex;
    align-items: center;
    justify-content: center;

    margin-bottom: 45px;

    border: 1px solid var(--border);

    color: var(--purple-light);

    font-family: "IBM Plex Mono", monospace;

    transition: .3s ease;
}

.area-card:hover .area-icon {
    border-color: var(--purple-light);

    transform: rotate(8deg);

    box-shadow: 0 0 25px rgba(138,79,209,.18);
}

.area-card h3 {
    margin: 0 0 12px;

    font-size: 21px;
}

.area-card p {
    margin: 0;

    color: var(--muted);

    font-size: 13px;

    line-height: 1.7;
}

.area-link {
    position: absolute;

    bottom: 30px;

    color: var(--dim);

    font-family: "IBM Plex Mono", monospace;

    font-size: 10px;

    letter-spacing: 2px;

    transition: .25s;
}

.area-card:hover .area-link {
    color: var(--purple-light);
    transform: translateX(5px);
}


/* =========================
   FEATURE
========================= */

.featured {
    background: var(--surface);
}

.research-feature {
    display: grid;

    grid-template-columns: 1.2fr 1fr;

    gap: 70px;

    align-items: center;
}

.feature-terminal {
    border: 1px solid var(--border);

    background: #080709;

    box-shadow: 0 30px 80px rgba(0,0,0,.3);
}

.terminal-header {
    height: 42px;

    display: flex;
    align-items: center;

    gap: 7px;

    padding: 0 15px;

    border-bottom: 1px solid #211c27;
}

.terminal-dot {
    width: 7px;
    height: 7px;

    border-radius: 50%;

    background: #4B1878;
}

.terminal-title {
    margin-left: 10px;

    color: #6E6480;

    font-family: "IBM Plex Mono", monospace;

    font-size: 10px;
}

.terminal-body {
    min-height: 360px;

    padding: 30px;

    color: #81758D;

    font-family: "IBM Plex Mono", monospace;

    font-size: 12px;

    line-height: 2;
}

.terminal-body p {
    margin: 0 0 16px;
}

.terminal-body p span {
    color: #8A4FD1;
}

.terminal-output {
    color: #C9A9E8;
}

.progress {
    height: 5px;

    background: #211c27;

    margin: 20px 0;
}

.progress span {
    display: block;

    width: 78%;
    height: 100%;

    background: #8A4FD1;

    animation: load 2s ease-in-out infinite alternate;
}

@keyframes load {
    from {
        width: 65%;
    }

    to {
        width: 82%;
    }
}

.cursor {
    display: inline-block;

    width: 7px;
    height: 13px;

    background: #8A4FD1;

    vertical-align: middle;

    animation: blink 1s infinite;
}

@keyframes blink {
    50% {
        opacity: 0;
    }
}

.feature-content .tag {
    display: inline-block;

    padding: 6px 9px;

    border: 1px solid var(--border);

    color: var(--purple-light);

    font-family: "IBM Plex Mono", monospace;

    font-size: 9px;

    letter-spacing: 2px;
}

.feature-content h3 {
    margin: 22px 0;

    font-size: clamp(35px, 4vw, 60px);

    line-height: .95;

    letter-spacing: -2px;
}

.feature-content h3 span {
    color: var(--purple-light);
}

.feature-content p {
    color: var(--muted);

    line-height: 1.8;

    max-width: 500px;
}

.feature-meta {
    display: flex;

    gap: 25px;

    margin: 30px 0;

    padding: 20px 0;

    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);

    font-family: "IBM Plex Mono", monospace;

    font-size: 9px;

    color: var(--dim);
}

.feature-meta b {
    color: var(--text);
}


/* =========================
   PUBLICATIONS
========================= */

.publication-list {
    border-top: 1px solid var(--border);
}

.publication {
    display: grid;

    grid-template-columns: 100px 1fr 40px;

    gap: 30px;

    align-items: center;

    padding: 28px 10px;

    border-bottom: 1px solid var(--border);

    transition: .3s ease;
}

.publication:hover {
    padding-left: 20px;
    padding-right: 20px;

    background: var(--surface);
}

.pub-id {
    color: var(--dim);

    font-family: "IBM Plex Mono", monospace;

    font-size: 10px;
}

.pub-type {
    color: var(--purple-light);

    font-family: "IBM Plex Mono", monospace;

    font-size: 9px;

    letter-spacing: 2px;
}

.publication h3 {
    margin: 7px 0;

    font-size: 20px;
}

.publication p {
    margin: 0;

    color: var(--muted);

    font-size: 13px;
}

.pub-arrow {
    color: var(--purple-light);

    font-size: 22px;

    transition: .25s;
}

.publication:hover .pub-arrow {
    transform: translateX(7px);
}


/* =========================
   CTA
========================= */

.research-cta {
    position: relative;

    padding: 140px 8vw;

    text-align: center;

    overflow: hidden;

    border-top: 1px solid var(--border);
}

.cta-grid {
    position: absolute;
    inset: 0;

    background-image:
        linear-gradient(var(--grid) 1px, transparent 1px),
        linear-gradient(90deg, var(--grid) 1px, transparent 1px);

    background-size: 45px 45px;

    opacity: .7;
}

.research-cta > *:not(.cta-grid) {
    position: relative;
}

.research-cta h2 {
    margin: 0 auto 20px;

    font-size: clamp(50px, 7vw, 90px);

    line-height: .9;

    letter-spacing: -4px;
}

.research-cta h2 span {
    color: var(--purple-light);
}

.research-cta p {
    color: var(--muted);

    margin-bottom: 30px;
}


/* =========================
   FOOTER
========================= */

footer {
    display: flex;

    justify-content: space-between;

    padding: 25px 6vw;

    border-top: 1px solid var(--border);

    color: var(--dim);

    font-family: "IBM Plex Mono", monospace;

    font-size: 9px;

    letter-spacing: 1px;
}


/* =========================
   RESPONSIVE
========================= */

/* Tablet and below: switch to the mobile nav so the navbar
   doesn't have to fit all links + theme/lang toggles in one row. */
@media (max-width: 1024px) {

    .research-nav {
        padding: 0 25px;
    }

    .research-nav nav {
        position: absolute;

        top: 76px;
        left: 0;
        right: 0;

        display: none;

        flex-direction: column;

        padding: 25px;

        background: var(--surface);

        border-bottom: 1px solid var(--border);
    }

    .research-nav nav.open {
        display: flex;
    }

    #menuToggle {
        display: block;
    }
}

@media (max-width: 900px) {

    .research-hero {
        padding: 100px 7vw 60px;
    }

    .research-hero h1 {
        letter-spacing: -3px;
    }

    .hero-metrics {
        gap: 25px;
        flex-wrap: wrap;
    }

    .area-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .research-feature {
        grid-template-columns: 1fr;
    }

    .section {
        padding: 90px 7vw;
    }
}


@media (max-width: 600px) {

    .brand {
        letter-spacing: 2px;
    }

    .research-hero {
        min-height: 650px;
    }

    .research-hero h1 {
        font-size: 53px;
    }

    .hero-buttons {
        flex-direction: column;
        align-items: stretch;
    }

    .hero-metrics {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
    }

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

    .area-card {
        min-height: 280px;
    }

    .publication {
        grid-template-columns: 1fr 30px;
    }

    .pub-id {
        display: none;
    }

    .publication p {
        line-height: 1.6;
    }

    .feature-terminal {
        overflow: hidden;
    }

    .terminal-body {
        min-height: 300px;
        padding: 20px;
        font-size: 10px;
    }

    footer {
        flex-direction: column;
        gap: 10px;
    }
}
