/* ───────────────────────────────────────────
   TOKENS
─────────────────────────────────────────── */
:root {
    --bg: #0a0a0a;
    --surface: rgba(255, 255, 255, 0.03);
    --surface-hover: rgba(255, 255, 255, 0.055);
    --text: rgba(255, 255, 255, 0.92);
    --muted: rgba(255, 255, 255, 0.55);
    --subtle: rgba(255, 255, 255, 0.35);
    --border: rgba(255, 255, 255, 0.10);
    --border-hover: rgba(255, 255, 255, 0.22);

    --btn-bg: rgba(255, 255, 255, 0.07);
    --btn-bg-hover: rgba(255, 255, 255, 0.12);
    --btn-border: rgba(255, 255, 255, 0.18);
    --btn-border-hover: rgba(255, 255, 255, 0.32);
    --focus: rgba(255, 255, 255, 0.22);

    --tag-bg: rgba(255, 255, 255, 0.06);
    --tag-border: rgba(255, 255, 255, 0.12);

    --accent: rgba(180, 220, 255, 0.85);
    --card-bg: rgba(255, 255, 255, 0.03);
    --card-border: rgba(255, 255, 255, 0.09);
    --card-border-hover: rgba(255, 255, 255, 0.18);

    --selection-bg: #2156CA;
    --selection-text: #ffffff;

    --max-w: 780px;
    --section-gap: clamp(64px, 10vw, 96px);
    --card-radius: 10px;
}

/* ───────────────────────────────────────────
   RESET
─────────────────────────────────────────── */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
    -webkit-text-size-adjust: 100%;
    line-height: 1.5;
    tab-size: 4;
    -webkit-tap-highlight-color: transparent;
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    background-color: var(--bg);
    background-image:
        linear-gradient(rgba(255, 255, 255, 0.026) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.026) 1px, transparent 1px),
        radial-gradient(ellipse 900px 500px at 20% 10%, rgba(255, 255, 255, 0.04) 0%, transparent 60%),
        radial-gradient(ellipse 600px 400px at 80% 60%, rgba(180, 220, 255, 0.022) 0%, transparent 60%);
    background-size: 48px 48px, 48px 48px, auto, auto;
    color: var(--text);
    font-family: 'Figtree', ui-sans-serif, system-ui, -apple-system, sans-serif;
    font-size: clamp(0.975rem, 1.05vw, 1.05rem);
    line-height: 1.7;
    min-height: 100dvh;
    font-synthesis: none;
    scrollbar-gutter: stable;
}

h1,
h2,
h3 {
    font-family: 'Figtree', ui-sans-serif, system-ui, sans-serif;
    line-height: 1.15;
}

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

ul,
ol {
    list-style: none;
}

img,
svg {
    display: block;
}

/* ───────────────────────────────────────────
   SELECTION
─────────────────────────────────────────── */
::selection {
    background: var(--selection-bg);
    color: var(--selection-text);
}

::-moz-selection {
    background: var(--selection-bg);
    color: var(--selection-text);
}

/* ───────────────────────────────────────────
   LAYOUT WRAPPER
─────────────────────────────────────────── */
main,
section,
footer {
    width: 100%;
    max-width: var(--max-w);
    margin-left: auto;
    margin-right: auto;
    padding-left: clamp(20px, 5vw, 32px);
    padding-right: clamp(20px, 5vw, 32px);
}

header {
    display: flex;
    justify-content: center;
}

/* ───────────────────────────────────────────
   HEADER & NAV
─────────────────────────────────────────── */
header {
    position: sticky;
    top: 0;
    z-index: 100;
    width: 100%;
    padding: 16px clamp(20px, 5vw, 32px);
    background: rgba(10, 10, 10, 0.3);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--border);
}

.nav {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    max-width: var(--max-w);
    margin: 0 auto;
}

.nav-toggle {
    display: none;
}

.nav-ul {
    list-style: none;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: clamp(12px, 2.5vw, 24px);
    flex-wrap: wrap;
}

.nav-li {
    /* flex item */
}

.nav-a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.58rem 1.2rem;
    border-radius: 7px;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--muted);
    transition: color 140ms ease;
    white-space: nowrap;
}

.nav-a:hover {
    color: var(--text);
}

/* hamburger button */
.hamburger {
    display: none;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
    width: 36px;
    height: 36px;
    cursor: pointer;
    z-index: 2;
    flex-shrink: 0;
    padding: 4px;
    border-radius: 6px;
    transition: background 140ms ease;
    position: absolute;
    left: clamp(20px, 5vw, 32px);
}

.hamburger:hover {
    background: rgba(255, 255, 255, 0.07);
}

.hamburger span {
    display: block;
    height: 1.5px;
    background: var(--text);
    border-radius: 2px;
    transform-origin: center;
    transition:
        transform 240ms cubic-bezier(0.22, 1, 0.36, 1),
        opacity 180ms ease,
        width 240ms ease;
}

.hamburger span:nth-child(1) {
    width: 22px;
}

.hamburger span:nth-child(2) {
    width: 16px;
}

.hamburger span:nth-child(3) {
    width: 22px;
}

.nav-toggle:checked~.hamburger span:nth-child(1) {
    transform: translateY(6.5px) rotate(45deg);
    width: 22px;
}

.nav-toggle:checked~.hamburger span:nth-child(2) {
    opacity: 0;
    transform: scaleX(0);
}

.nav-toggle:checked~.hamburger span:nth-child(3) {
    transform: translateY(-6.5px) rotate(-45deg);
    width: 22px;
}

/* ───────────────────────────────────────────
   HERO
─────────────────────────────────────────── */
.hero-section {
    padding-top: clamp(72px, 13vw, 120px);
    padding-bottom: clamp(72px, 13vw, 120px);
    border-bottom: 1px solid var(--border);
}

.hero-text {
    text-align: center;
    font-size: clamp(1.8rem, 8vw, 3rem);
    font-weight: 800;
    letter-spacing: -0.03em;
    color: var(--text);
}

/* ───────────────────────────────────────────
   SECTIONS
─────────────────────────────────────────── */
section {
    padding-top: var(--section-gap);
    padding-bottom: var(--section-gap);
    border-bottom: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    align-items: center;
}

section:last-of-type {
    border-bottom: none;
}

.assignments-heading,
.blogs-heading {
    font-size: clamp(0.68rem, 1.05vw, 0.76rem);
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--subtle);
    margin-bottom: clamp(28px, 4vw, 40px);
    align-self: center;
}

.assignments-para,
.blogs-para {
    font-size: 0.95rem;
    color: var(--muted);
    margin-bottom: 16px;
    text-align: center;
}

.blogs-all-link {
    display: inline-block;
    transition: color 140ms ease;
}

.blogs-all-link:hover .blogs-para {
    color: var(--text);
}

/* ───────────────────────────────────────────
   TABLE
─────────────────────────────────────────── */
.assignments-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 1rem;
    font-size: 0.95rem;
    display: table;
    overflow-x: auto;
    overflow-y: auto;
    max-width: 100%;
}

.assignments-table thead {
    background: var(--card-bg);
}

.assignments-table th {
    text-align: left;
    padding: 0.75rem 1rem;
    font-weight: 600;
    color: var(--text);
    border-bottom: 1px solid var(--border);
}

.assignments-table td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border);
    color: var(--muted);
}

.assignments-table tbody tr:nth-child(even) {
    background: var(--surface);
}

.assignments-table tbody tr:hover {
    background: var(--surface-hover);
}

.assignments-table a {
    color: var(--text);
    font-weight: 500;
    transition: color 140ms ease;
}

.assignments-table a:hover {
    color: var(--accent);
}

/* ───────────────────────────────────────────
   BLOG GRID
─────────────────────────────────────────── */
.blogs-ol {
    list-style: none;
    display: grid;
    gap: 1rem;
    grid-template-columns: 1fr;
    width: 100%;
}

/* TABLET */
@media (min-width: 600px) {
    .blogs-ol {
        grid-template-columns: repeat(2, 1fr);
    }

    .blog-li:last-child:nth-child(4n+1) {
        grid-column: span 2;
    }
}

/* DESKTOP */
@media (min-width: 900px) {
    .blogs-ol {
        grid-template-columns: repeat(4, 1fr);
    }

    .blog-li:last-child:nth-child(4n+1) {
        grid-column: span 4;
    }

    /* 2 items in last row */
    .blog-li:nth-last-child(2):nth-child(4n+1),
    .blog-li:last-child:nth-child(4n+2) {
        grid-column: span 2;
    }

    /* 3 items in last row */
    .blog-li:nth-last-child(3):nth-child(4n + 1) {
        grid-column: span 2;
    }
}

.blog-li {
    max-height: 12rem;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--card-radius);
    transition: 0.2s ease;
    display: flex;
    align-items: center;
    text-align: center;
    justify-content: center;
    width: 100%;
}

.blog-li:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 14px rgba(0, 0, 0, 0.08);
    border-color: var(--card-border-hover);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
}

.blog-link {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    padding: 1.5rem;
    text-decoration: none;
    color: var(--text);
    font-weight: 600;
    text-align: center;
    /* max-width: 15rem; */
    /* margin-inline: auto; */
}

/* ───────────────────────────────────────────
   FOOTER
─────────────────────────────────────────── */
footer {
    padding-top: clamp(40px, 6vw, 56px);
    padding-bottom: clamp(40px, 6vw, 56px);
    text-align: center;
    border-top: 1px solid var(--border);
}

footer p {
    font-size: 0.78rem;
    color: var(--subtle);
    margin-bottom: 8px;
}

footer a {
    color: var(--subtle);
    transition: color 140ms ease;
}

footer a:hover {
    color: var(--text);
}

/* ───────────────────────────────────────────
   FOCUS
─────────────────────────────────────────── */
:focus-visible {
    outline: 2px solid var(--focus);
    outline-offset: 3px;
    border-radius: 3px;
}

/* ───────────────────────────────────────────
   RESPONSIVE
─────────────────────────────────────────── */

.three-orphans-row {
    display: contents;
}

/* MOBILE: 1 column (no orphans possible) */
@media (max-width: 599px) {
    .hamburger {
        display: flex;
    }

    .nav-ul {
        position: fixed;
        inset: 0 0 auto 0;
        top: 53px;
        flex-direction: column;
        align-items: flex-start;
        gap: 0;
        padding: 8px 0 16px;
        background: rgba(10, 10, 10, 0.97);
        backdrop-filter: blur(20px);
        -webkit-backdrop-filter: blur(20px);
        border-bottom: 1px solid var(--border);
        opacity: 0;
        transform: translateY(-8px);
        pointer-events: none;
        transition:
            opacity 220ms cubic-bezier(0.22, 1, 0.36, 1),
            transform 220ms cubic-bezier(0.22, 1, 0.36, 1);
    }

    .nav-toggle:checked~.nav-ul {
        opacity: 1;
        transform: translateY(0);
        pointer-events: auto;
    }

    .nav-li {
        width: 100%;
    }

    .nav-a {
        display: flex;
        width: 100%;
        padding: 13px clamp(20px, 5vw, 32px);
        border-radius: 0;
        border-bottom: 1px solid var(--border);
        color: var(--muted);
        font-size: 1rem;
        transition: color 140ms ease, background 140ms ease;
    }

    .nav-li:last-child .nav-a {
        border-bottom: none;
    }

    .nav-a:hover {
        color: var(--text);
        background: rgba(255, 255, 255, 0.04);
    }
}

/* TABLET: 2 columns (single orphan stretches full) */
@media (min-width: 600px) and (max-width: 899px) {
    .blogs-ol {
        grid-template-columns: repeat(2, 1fr);
    }

    /* If last card is alone in last row, stretch it across both columns */
    .blog-li:last-child:nth-child(odd) {
        grid-column: 1 / -1;
    }

    .three-orphans-row {
        grid-column: 1 / -1;
        display: flex;
        justify-content: center;
        gap: 1rem;
    }

    .three-orphans-row .blog-li {
        flex: 0 0 calc((100% - 2rem) / 3);
    }
}

/* DESKTOP: 4 columns (with orphan logic) */
@media (min-width: 900px) {
    .blogs-ol {
        grid-template-columns: repeat(4, 1fr);
    }

    /* 1 leftover: stretch full width */
    .blog-li:last-child:nth-child(4n + 1) {
        grid-column: 1 / -1;
    }

    /* 2 leftovers: each spans 2 columns (centered pair) */
    .blog-li:not(.orphan-item):nth-last-child(2):nth-child(4n + 1),
    .blog-li:not(.orphan-item):last-child:nth-child(4n + 2) {
        grid-column: span 2;
    }

    /* 3 leftovers: use wrapper */
    .three-orphans-row {
        grid-column: 1 / -1;
        display: flex;
        justify-content: center;
        gap: 1rem;
    }

    .three-orphans-row .blog-li {
        flex: 0 0 calc((100% - 2rem) / 3);
        max-height: 12rem;
        grid-column: unset;
    }
}

/* ───────────────────────────────────────────
   DIVIDERS
─────────────────────────────────────────── */
.section-divider {
    width: 100%;
    border-top: 1px solid var(--border);
    margin-top: clamp(28px, 4vw, 40px);
    margin-bottom: clamp(28px, 4vw, 40px);
}