/* ============================================================
   site.css — landing, semester and subject pages.

   Grounded in the MAKAUT question paper: a masthead like the paper's
   header, and a marks rail set in a machine face, the way marks are
   printed in the right margin.

   Palette is the project's existing one — desk, paper, ink and the five
   subject accents. Every tint below is derived from those, nothing new.
   ============================================================ */

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

:root {
    --bg-desk: #eae6db;
    --bg-paper: #fefdfb;
    --ink: #1e293b;
    --ink-strong: #0f172a;
    --ink-muted: #57687e;

    --rule: rgba(15, 23, 42, 0.11);
    --rule-soft: rgba(15, 23, 42, 0.06);
    --wash: rgba(15, 23, 42, 0.035);

    --os: #2563eb;
    --ai: #8b5cf6;
    --cn: #047857;
    --cd: #c2410c;
    --se: #0369a1;
    --accent: var(--ink-strong);

    --display: 'Plus Jakarta Sans', system-ui, sans-serif;
    --body: 'Inter', system-ui, sans-serif;
    --util: 'JetBrains Mono', ui-monospace, monospace;

    --ease: cubic-bezier(.16, 1, .3, 1);

    /* Depth: a tight contact shadow plus a wide ambient one */
    --lift-1: 0 1px 2px rgba(15,23,42,.04), 0 8px 22px -16px rgba(15,23,42,.30);
    --lift-2: 0 1px 2px rgba(15,23,42,.05), 0 18px 40px -22px rgba(15,23,42,.40);
    --lift-3: 0 2px 4px rgba(15,23,42,.05), 0 40px 80px -32px rgba(15,23,42,.35);
}

html { scroll-behavior: smooth; }

body {
    font-family: var(--body);
    color: var(--ink);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
    font-feature-settings: "kern" 1, "liga" 1, "calt" 1;

    /* The desk the sheet rests on — fine grain, as before */
    background-color: var(--bg-desk);
    background-image:
        radial-gradient(rgba(30, 41, 59, .035) 1px, transparent 1px),
        radial-gradient(rgba(30, 41, 59, .035) 1px, var(--bg-desk) 1px);
    background-size: 22px 22px;
    background-position: 0 0, 11px 11px;
    padding: clamp(0rem, 3vw, 3rem) clamp(0rem, 3vw, 2.5rem);
}

/* ---------- The sheet ---------- */

.sheet {
    position: relative;
    max-width: 1200px;
    margin: 0 auto;
    background: var(--bg-paper);
    border: 1px solid rgba(15, 23, 42, .09);
    border-radius: clamp(0px, 1.5vw, 20px);
    box-shadow: var(--lift-3);
    padding: clamp(2.25rem, 5.5vw, 5rem) clamp(1.15rem, 4.5vw, 4.25rem) 4.5rem;
    overflow: hidden;
}

/* A hairline of accent along the very top edge of the sheet */
.sheet::before {
    content: "";
    position: absolute;
    inset: 0 0 auto 0;
    height: 3px;
    background: linear-gradient(90deg,
        var(--os) 0%, var(--ai) 26%, var(--se) 50%, var(--cn) 74%, var(--cd) 100%);
    opacity: .85;
}

/* ---------- Back link ---------- */

.back {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    margin-bottom: 2.25rem;
    padding: 0.45rem 0.95rem 0.45rem 0.75rem;
    border: 1px solid var(--rule-soft);
    border-radius: 999px;
    background: linear-gradient(180deg, #fff, #fbfaf7);
    box-shadow: var(--lift-1);
    font-family: var(--util);
    font-size: 0.75rem;
    letter-spacing: 0.03em;
    color: var(--ink-muted);
    text-decoration: none;
    transition: color 180ms var(--ease), transform 180ms var(--ease), box-shadow 180ms var(--ease);
}
.back:hover { color: var(--ink-strong); transform: translateX(-3px); box-shadow: var(--lift-2); }

/* ---------- Masthead ---------- */

.masthead {
    padding-bottom: 0;
    border-bottom: 1px solid var(--rule);
}

.masthead-text { min-width: 0; max-width: 62ch; }

.eyebrow {
    display: inline-block;
    font-family: var(--util);
    font-size: 0.7rem;
    font-weight: 500;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--ink-muted);
}
.eyebrow .accent { color: var(--accent); font-weight: 700; }

h1 {
    font-family: var(--display);
    font-size: clamp(2.4rem, 6.4vw, 4.6rem);
    font-weight: 800;
    line-height: 1.01;
    letter-spacing: -0.038em;
    color: var(--ink-strong);
    margin: 1.15rem 0 1rem;
    text-wrap: balance;
}

.standfirst {
    font-size: clamp(1rem, 1.45vw, 1.16rem);
    color: var(--ink-muted);
    max-width: 52ch;
    text-wrap: pretty;
}

.paper-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem 2.25rem;
    margin-top: 2.25rem;
    font-family: var(--util);
    font-size: 0.8rem;
    color: var(--ink-muted);
}
.paper-meta b { color: var(--ink-strong); font-weight: 700; }

/* ---------- Figures: numbers on the baseline, not in a widget ---------- */

.figures {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    margin-top: clamp(2.5rem, 5vw, 4rem);
    border-top: 1px solid var(--rule-soft);
}

.figure {
    padding: 1.4rem 1.5rem 1.5rem 0;
    border-left: 1px solid var(--rule-soft);
    padding-left: 1.5rem;
}
/* The first column aligns to the text edge — no rule, no indent */
.figure:first-child { border-left: none; padding-left: 0; }

.figure dt {
    font-family: var(--util);
    font-size: 0.66rem;
    font-weight: 500;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--ink-muted);
    margin-bottom: 0.6rem;
}

.figure dd {
    font-family: var(--display);
    font-size: clamp(1.6rem, 3.2vw, 2.3rem);
    font-weight: 800;
    line-height: 1;
    letter-spacing: -0.035em;
    font-variant-numeric: tabular-nums;
    color: var(--ink-strong);
}

/* ---------- Section bands ---------- */

.band {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 1.5rem;
    margin: 4rem 0 1.6rem;
    padding-bottom: 0.8rem;
    border-bottom: 1px solid var(--rule);
}

.band h2 {
    font-family: var(--display);
    font-size: clamp(1.3rem, 2.3vw, 1.85rem);
    font-weight: 700;
    letter-spacing: -0.022em;
    color: var(--ink-strong);
}

.band-note {
    font-family: var(--util);
    font-size: 0.73rem;
    letter-spacing: 0.09em;
    text-transform: uppercase;
    color: var(--ink-muted);
    white-space: nowrap;
}

/* ---------- Cards ---------- */

.subjects {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(290px, 1fr));
    gap: 1.15rem;
}

.subject {
    position: relative;
    display: flex;
    flex-direction: column;
    padding: 1.7rem 1.55rem 1.35rem;
    /* Cards read as a separate material from the sheet they sit on */
    background: linear-gradient(180deg, #ffffff 0%, #fcfbf8 100%);
    border: 1px solid rgba(15, 23, 42, .085);
    border-radius: 16px;
    box-shadow: var(--lift-1), inset 0 1px 0 rgba(255, 255, 255, .9);
    text-decoration: none;
    color: inherit;
    overflow: hidden;
    isolation: isolate;
    transition:
        transform 380ms var(--ease),
        box-shadow 380ms var(--ease),
        border-color 380ms var(--ease);
}

/* Accent rail — always present, not a hover-only reveal */
.subject::before {
    content: "";
    position: absolute;
    inset: 0 0 auto 0;
    height: 3px;
    background: var(--accent);
    opacity: .9;
    transition: height 300ms var(--ease);
}

/* A faint accent bloom that warms the card on hover */
.subject::after {
    content: "";
    position: absolute;
    inset: 0;
    z-index: -1;
    background: radial-gradient(120% 80% at 50% 0%,
        color-mix(in srgb, var(--accent) 9%, transparent) 0%, transparent 70%);
    opacity: 0;
    transition: opacity 380ms var(--ease);
}

.subject:hover, .subject:focus-visible {
    transform: translateY(-4px);
    border-color: color-mix(in srgb, var(--accent) 32%, var(--rule));
    box-shadow: var(--lift-2), inset 0 1px 0 rgba(255, 255, 255, .9);
}
.subject:hover::before, .subject:focus-visible::before { height: 5px; }
.subject:hover::after, .subject:focus-visible::after { opacity: 1; }
.subject:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

/* The course code as a tinted chip, not a bare label */
.code {
    align-self: flex-start;
    padding: 0.3rem 0.6rem;
    border-radius: 6px;
    background: color-mix(in srgb, var(--accent) 11%, transparent);
    font-family: var(--util);
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    color: var(--accent);
}

.subject h3 {
    font-family: var(--display);
    font-size: 1.34rem;
    font-weight: 700;
    line-height: 1.2;
    letter-spacing: -0.02em;
    color: var(--ink-strong);
    margin: 0.75rem 0 0.5rem;
}

.topics {
    font-size: 0.875rem;
    line-height: 1.55;
    color: var(--ink-muted);
    margin-bottom: 1.35rem;
    text-wrap: pretty;
}

/* ---------- The marks rail ---------- */

.rail {
    margin-top: auto;
    padding-top: 0.85rem;
    border-top: 1px solid var(--rule-soft);
    font-family: var(--util);
    font-size: 0.73rem;
    font-variant-numeric: tabular-nums;
    color: var(--ink-muted);
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.rail-row { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; }
.rail-row span:first-child { letter-spacing: 0.03em; min-width: 0; }
.rail-row b { color: var(--ink); font-weight: 500; white-space: nowrap; }

/* The total is the number that matters — give it real size */
.rail-total {
    margin-top: 0.45rem;
    padding-top: 0.6rem;
    border-top: 1px solid var(--rule-soft);
    align-items: center;
}
.rail-total span:first-child {
    font-size: 0.68rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}
.rail-total b {
    font-family: var(--display);
    font-size: 1.12rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    color: var(--ink-strong);
}

/* ---------- Colophon ---------- */

footer {
    margin-top: 4.5rem;
    padding-top: 1.6rem;
    border-top: 1px solid var(--rule);
    font-size: 0.85rem;
    color: var(--ink-muted);
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 1.5rem;
    justify-content: space-between;
}
footer a { color: var(--ink); text-decoration: none; border-bottom: 1px solid var(--rule); }
footer a:hover { border-bottom-color: var(--ink); }
.colophon-note { font-family: var(--util); font-size: 0.74rem; }

/* ---------- Entrance: one quiet settle, not scattered effects ---------- */

@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

.subject { animation: rise 620ms var(--ease) backwards; }
.subjects .subject:nth-child(1) { animation-delay: 40ms; }
.subjects .subject:nth-child(2) { animation-delay: 90ms; }
.subjects .subject:nth-child(3) { animation-delay: 140ms; }
.subjects .subject:nth-child(4) { animation-delay: 190ms; }
.subjects .subject:nth-child(5) { animation-delay: 240ms; }
.subjects .subject:nth-child(n+6) { animation-delay: 280ms; }

/* ---------- Responsive ---------- */

@media (max-width: 780px) {
    .figures { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    /* Third and fourth wrap to a second row — give that row its own rule */
    .figure:nth-child(3) { border-left: none; padding-left: 0; }
    .figure:nth-child(n+3) { border-top: 1px solid var(--rule-soft); }
}

@media (max-width: 700px) {
    .subjects { grid-template-columns: 1fr; }
    .sheet { border-radius: 0; border-inline: none; }

    /* Stack the band so the heading never breaks mid-word to make room
       for the note beside it */
    .band {
        margin-top: 2.75rem;
        flex-direction: column;
        align-items: flex-start;
        gap: 0.4rem;
    }
    .band-note { white-space: normal; }
}

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