/* ==========================================================================
   Rahim Hossain — site theme
   Layered on top of Bootstrap 5.2. Bootstrap 5.2 has no built-in dark mode,
   so the utility classes already in the markup (bg-light, text-dark,
   link-danger, navbar-light) are re-pointed at theme tokens below. Several
   of those utilities ship with !important, so the overrides need it too.
   ========================================================================== */

/* --- Tokens: light ------------------------------------------------------- */
:root {
    color-scheme: light dark;

    --bg:            #fbfbfa;
    --surface:       #ffffff;
    --surface-alt:   #f4f5f4;
    --text:          #1f2328;
    --text-muted:    #5a6270;
    --border:        #e3e5e6;
    --border-strong: #d2d6d8;

    --accent:        #0f6b6b;
    --accent-hover:  #0b5252;
    --accent-soft:   rgba(15, 107, 107, 0.14);
    --accent-wash:   rgba(15, 107, 107, 0.05);

    --shadow-sm: 0 1px 2px rgba(16, 24, 32, 0.05);
    --shadow-md: 0 4px 16px rgba(16, 24, 32, 0.07);
    --shadow-lg: 0 12px 32px rgba(16, 24, 32, 0.10);

    --radius:    14px;
    --radius-sm: 9px;

    --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
                 "Helvetica Neue", Arial, "Noto Sans", sans-serif;
    --measure: 68ch;
}

/* --- Tokens: dark -------------------------------------------------------- */
@media (prefers-color-scheme: dark) {
    :root {
        --bg:            #15181d;
        --surface:       #1c2027;
        --surface-alt:   #21262e;
        --text:          #e7e7e4;
        --text-muted:    #9aa3af;
        --border:        #2b313a;
        --border-strong: #3a424d;

        --accent:        #4ec9c9;
        --accent-hover:  #7ddede;
        --accent-soft:   rgba(78, 201, 201, 0.18);
        --accent-wash:   rgba(78, 201, 201, 0.07);

        --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.40);
        --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.45);
        --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.55);
    }
}

/* --- Base ---------------------------------------------------------------- */
body {
    background-color: var(--bg);
    color: var(--text);
    font-family: var(--font-sans);
    font-size: 1.0125rem;
    line-height: 1.72;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

main p {
    max-width: var(--measure);
    color: var(--text);
}

h1, h2, h3, h4, h5, h6 {
    color: var(--text);
    font-weight: 650;
    letter-spacing: -0.015em;
    line-height: 1.25;
}

h1 { font-size: clamp(2rem, 1.4rem + 2.2vw, 2.75rem); font-weight: 700; letter-spacing: -0.03em; }
h2 { font-size: 1.6rem; margin-top: 2.75rem; margin-bottom: 1rem; }
h3 { font-size: 1.2rem; }

/* Section headings get a short accent rule underneath. */
main h2 {
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border);
    position: relative;
}
main h2::after {
    content: "";
    position: absolute;
    left: 0;
    bottom: -1px;
    width: 2.75rem;
    height: 2px;
    background: var(--accent);
    border-radius: 2px;
}

a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 0.18em; }
a:hover { color: var(--accent-hover); }

/* The markup uses .link-danger throughout for body links; re-point at accent. */
.link-danger { color: var(--accent) !important; }
.link-danger:hover, .link-danger:focus { color: var(--accent-hover) !important; }

b, strong { font-weight: 650; color: var(--text); }

hr {
    border: 0;
    border-top: 1px solid var(--border);
    opacity: 1;
    margin: 2.5rem 0;
}

::selection { background: var(--accent-soft); color: var(--text); }

:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
    border-radius: 3px;
}

/* --- Navbar -------------------------------------------------------------- */
.navbar.bg-light {
    background-color: color-mix(in srgb, var(--bg) 88%, transparent) !important;
    -webkit-backdrop-filter: saturate(1.6) blur(10px);
    backdrop-filter: saturate(1.6) blur(10px);
    border: 0 !important;
    border-bottom: 1px solid var(--border) !important;
    position: sticky;
    top: 0;
    z-index: 1030;
    padding-top: 0.55rem;
    padding-bottom: 0.55rem;
}

/* Fallback for browsers without color-mix(). */
@supports not (background-color: color-mix(in srgb, red 50%, blue)) {
    .navbar.bg-light { background-color: var(--bg) !important; }
}

.navbar .navbar-brand.link-dark {
    color: var(--text) !important;
    font-weight: 650;
    letter-spacing: -0.02em;
}

.navbar .nav-link {
    color: var(--text-muted) !important;
    font-size: 0.945rem;
    font-weight: 500;
    border-radius: var(--radius-sm);
    padding: 0.35rem 0.7rem !important;
    transition: color 0.15s ease, background-color 0.15s ease;
}
.navbar .nav-link:hover {
    color: var(--text) !important;
    background: var(--surface-alt);
}
.navbar .nav-link.active {
    color: var(--accent) !important;
    background: var(--accent-wash);
}
.navbar .nav-link i { margin-right: 0.15rem; opacity: 0.85; }

.navbar-toggler {
    border-color: var(--border-strong);
    color: var(--text);
}
@media (prefers-color-scheme: dark) {
    /* Bootstrap's navbar-light toggler icon is a dark SVG; invert for dark bg. */
    .navbar-light .navbar-toggler-icon { filter: invert(1) opacity(0.75); }
}

/* --- Hero ---------------------------------------------------------------- */
.hero-photo {
    border-radius: var(--radius) !important;
    box-shadow: var(--shadow-md) !important;
    border: 1px solid var(--border);
}

.hero-meta {
    color: var(--text-muted);
    font-size: 1.03rem;
    line-height: 1.65;
    margin-bottom: 0.9rem;
}
.hero-meta strong { color: var(--text); font-weight: 600; }

/* Social icon row (replaces the old <table> that sat illegally inside a <p>) */
.social-links {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.35rem;
    margin: 0.85rem 0 0;
    padding: 0;
    list-style: none;
}
.social-links a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.5rem;
    height: 2.5rem;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-size: 1.3rem;
    text-decoration: none;
    transition: color 0.15s ease, background-color 0.15s ease, transform 0.15s ease;
}
.social-links a:hover {
    color: var(--accent);
    background: var(--accent-wash);
    transform: translateY(-2px);
}
.social-links .ai { font-size: 1.45rem; }
.social-links img {
    width: 20px;
    height: 19px;
    opacity: 0.72;
    transition: opacity 0.15s ease;
}
.social-links a:hover img { opacity: 1; }
@media (prefers-color-scheme: dark) {
    /* The Twitter mark is a dark raster PNG — lift it out of the dark bg. */
    .social-links img { filter: invert(1); opacity: 0.62; }
}

/* --- News timeline ------------------------------------------------------- */
.news {
    position: relative;
    margin-top: 1.75rem;
    padding-left: 1.75rem;
    border-left: 2px solid var(--border);
}
.news h5 {
    position: relative;
    margin-top: 2rem;
    margin-bottom: 0.4rem;
    color: var(--accent);
    font-size: 0.8rem;
    font-weight: 650;
    letter-spacing: 0.09em;
    text-transform: uppercase;
}
.news h5:first-child { margin-top: 0; }
.news h5::before {
    content: "";
    position: absolute;
    left: -2.03rem;
    top: 0.42em;
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: var(--accent);
    box-shadow: 0 0 0 4px var(--bg);
}
.news p {
    margin-left: 0 !important;
    margin-right: 0 !important;
    margin-bottom: 0.65rem;
    max-width: var(--measure);
    color: var(--text-muted);
}
.news p b, .news p strong { color: var(--text); }

/* --- Project cards (Research) -------------------------------------------- */
.project {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem 1.65rem;
    margin-bottom: 1.15rem;
    box-shadow: var(--shadow-sm);
    transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}
.project:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    border-color: var(--border-strong);
}
.project h3 {
    margin-top: 0;
    margin-bottom: 0.85rem;
    font-size: 1.16rem;
    letter-spacing: -0.02em;
}
.project-body {
    color: var(--text-muted);
    max-width: var(--measure);
}
.project-figure img {
    width: 100%;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--surface-alt);
}
.project-tag {
    display: inline-block;
    margin-bottom: 0.7rem;
    padding: 0.16rem 0.6rem;
    border-radius: 999px;
    background: var(--accent-wash);
    color: var(--accent);
    font-size: 0.74rem;
    font-weight: 650;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

/* --- Publication list ---------------------------------------------------- */
.pub {
    display: flex;
    gap: 1.25rem;
    align-items: flex-start;
    padding: 1.15rem 0;
    border-bottom: 1px solid var(--border);
}
.pub:last-child { border-bottom: 0; }
.pub-thumb { flex: 0 0 108px; }
.pub-thumb img {
    width: 100%;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    background: var(--surface-alt);
}
.pub-body { flex: 1 1 auto; color: var(--text-muted); line-height: 1.6; }
.pub-title {
    display: block;
    margin: 0.2rem 0;
    color: var(--text);
    font-weight: 650;
}
.pub-venue { color: var(--text-muted); font-style: italic; }
.pub-links { margin-top: 0.35rem; font-size: 0.9rem; }
.pub-links a { margin-right: 0.75rem; }

@media (max-width: 575.98px) {
    .pub { flex-direction: column; gap: 0.75rem; }
    .pub-thumb { flex-basis: auto; max-width: 140px; }
}

/* --- CV frame ------------------------------------------------------------ */
.cv-frame {
    width: 100%;
    height: 900px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    background: var(--surface-alt);
}
.cv-actions { margin: 0.25rem 0 1.25rem; }

/* --- Footer -------------------------------------------------------------- */
.footer.bg-light {
    background-color: var(--surface-alt) !important;
    border: 0 !important;
    border-top: 1px solid var(--border) !important;
    color: var(--text-muted);
}
.footer .text-dark { color: var(--text-muted) !important; font-size: 0.9rem; }

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