/* ==========================================================================
   Johar Cassa — academic website
   Single shared design system used by every page.
   Sections: 1) Tokens  2) Reset/base  3) Layout  4) Typography
             5) Header/nav  6) Buttons & links  7) Components  8) Footer
             9) Utilities  10) Responsive
   ========================================================================== */

/* 1) DESIGN TOKENS ------------------------------------------------------- */
:root {
    /* Color — restrained academic palette (navy / charcoal / white / gray) */
    --bg: #ffffff;
    --bg-subtle: #f6f7f9;
    --bg-tint: #eef1f6;
    --ink: #1b1d24;          /* primary text */
    --ink-soft: #454b57;     /* secondary text */
    --muted: #6b7280;        /* metadata, captions */
    --navy: #16305c;         /* brand / headings accent */
    --navy-deep: #0f2242;
    --link: #1c4587;         /* interactive text */
    --link-hover: #0f2b52;
    --line: #e6e8ec;         /* hairlines */
    --line-strong: #d4d8df;

    /* Typography */
    --font-serif: "Source Serif 4", Georgia, "Times New Roman", serif;
    --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;

    /* Spacing scale */
    --space-1: 0.25rem;
    --space-2: 0.5rem;
    --space-3: 0.75rem;
    --space-4: 1rem;
    --space-5: 1.5rem;
    --space-6: 2rem;
    --space-7: 3rem;
    --space-8: 4rem;
    --space-9: 6rem;

    /* Shape */
    --radius: 8px;
    --radius-sm: 5px;
    --radius-pill: 999px;
    --shadow-sm: 0 1px 2px rgba(16, 34, 66, 0.05);
    --shadow: 0 6px 24px rgba(16, 34, 66, 0.08);

    /* Widths */
    --container: 72rem;
    --measure: 68ch;
}

/* 2) RESET / BASE -------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }

html {
    -webkit-text-size-adjust: 100%;
    scroll-behavior: smooth;
}

body {
    margin: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background: var(--bg);
    color: var(--ink);
    font-family: var(--font-serif);
    font-size: 1.075rem;
    line-height: 1.7;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

img { max-width: 100%; height: auto; display: block; }

/* Reduced motion: honor user preference */
@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
    *, *::before, *::after {
        animation-duration: 0.001ms !important;
        transition-duration: 0.001ms !important;
    }
}

/* 3) LAYOUT -------------------------------------------------------------- */
.container {
    width: 100%;
    max-width: var(--container);
    margin-inline: auto;
    padding-inline: var(--space-5);
}

main { flex: 1 0 auto; }

.section { padding-block: var(--space-8); }
.section + .section { padding-top: 0; }

.divider {
    border: 0;
    border-top: 1px solid var(--line);
    margin-block: var(--space-7);
}

/* 4) TYPOGRAPHY ---------------------------------------------------------- */
h1, h2, h3, h4 {
    font-family: var(--font-serif);
    color: var(--navy);
    font-weight: 600;
    line-height: 1.2;
    letter-spacing: -0.01em;
    margin: 0 0 var(--space-4);
}

h1 { font-size: clamp(2.1rem, 4.5vw, 3.1rem); letter-spacing: -0.02em; }
h2 { font-size: clamp(1.5rem, 3vw, 1.9rem); }
h3 { font-size: 1.25rem; }
h4 { font-size: 1.05rem; }

p { margin: 0 0 var(--space-4); }
.prose { max-width: var(--measure); }
.prose p { color: var(--ink-soft); }

/* Small-caps section eyebrow, echoing the LaTeX CV section rules */
.eyebrow {
    font-family: var(--font-sans);
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--muted);
    margin: 0 0 var(--space-4);
}

.section-title {
    display: flex;
    align-items: baseline;
    gap: var(--space-4);
    margin-bottom: var(--space-6);
}
.section-title::after {
    content: "";
    flex: 1;
    height: 1px;
    background: var(--line);
}

.lead {
    font-size: 1.2rem;
    line-height: 1.6;
    color: var(--ink-soft);
}

/* 5) HEADER / NAV -------------------------------------------------------- */
.skip-link {
    position: absolute;
    left: -999px;
    top: 0;
    background: var(--navy);
    color: #fff;
    padding: var(--space-2) var(--space-4);
    border-radius: 0 0 var(--radius-sm) 0;
    z-index: 100;
    font-family: var(--font-sans);
}
.skip-link:focus { left: 0; }

.site-header {
    position: sticky;
    top: 0;
    z-index: 50;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: saturate(180%) blur(8px);
    border-bottom: 1px solid var(--line);
}

.nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 64px;
    gap: var(--space-4);
}

.nav__brand {
    font-family: var(--font-serif);
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--navy);
    text-decoration: none;
    letter-spacing: -0.01em;
    white-space: nowrap;
}
.nav__brand:hover { color: var(--navy-deep); }

.nav__toggle {
    display: none;
    background: none;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-sm);
    padding: var(--space-2);
    cursor: pointer;
    color: var(--navy);
}
.nav__toggle svg { display: block; width: 22px; height: 22px; }

.nav__menu {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    list-style: none;
    margin: 0;
    padding: 0;
}

.nav__link {
    font-family: var(--font-sans);
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--ink-soft);
    text-decoration: none;
    padding: var(--space-2) var(--space-3);
    border-radius: var(--radius-sm);
    transition: color 0.15s ease, background-color 0.15s ease;
}
.nav__link:hover { color: var(--navy); background: var(--bg-subtle); }

/* Active page is always obvious */
.nav__link[aria-current="page"] {
    color: var(--navy);
    font-weight: 600;
}
.nav__link[aria-current="page"]::after {
    content: "";
    display: block;
    height: 2px;
    background: var(--navy);
    border-radius: 2px;
    margin-top: 3px;
}

.nav__link--external::after {
    content: "\2197";
    font-size: 0.8em;
    margin-left: 2px;
    color: var(--muted);
}

/* 6) BUTTONS & LINKS ----------------------------------------------------- */
a { color: var(--link); text-decoration-color: rgba(28, 69, 135, 0.35); text-underline-offset: 2px; }
a:hover { color: var(--link-hover); text-decoration-color: currentColor; }

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

.btn {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    font-family: var(--font-sans);
    font-size: 0.9rem;
    font-weight: 500;
    line-height: 1;
    text-decoration: none;
    padding: 0.6rem 1rem;
    border-radius: var(--radius-pill);
    border: 1px solid var(--line-strong);
    color: var(--navy);
    background: var(--bg);
    transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease, transform 0.15s ease;
    cursor: pointer;
}
.btn:hover { background: var(--bg-subtle); border-color: var(--navy); color: var(--navy-deep); }
.btn:active { transform: translateY(1px); }

.btn--primary {
    background: var(--navy);
    border-color: var(--navy);
    color: #fff;
}
.btn--primary:hover { background: var(--navy-deep); border-color: var(--navy-deep); color: #fff; }

/* Small resource chip used on papers (PDF / Slides / Code …) */
.chip {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-family: var(--font-sans);
    font-size: 0.82rem;
    font-weight: 500;
    text-decoration: none;
    padding: 0.3rem 0.7rem;
    border-radius: var(--radius-pill);
    border: 1px solid var(--line-strong);
    color: var(--ink-soft);
    background: var(--bg);
    transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.chip:hover { border-color: var(--navy); color: var(--navy); background: var(--bg-subtle); }

.link-row {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
}

/* 7) COMPONENTS ---------------------------------------------------------- */

/* --- Hero (homepage) --- */
.hero {
    display: grid;
    grid-template-columns: 1.6fr 1fr;
    gap: var(--space-8);
    align-items: start;
    padding-block: var(--space-8) var(--space-7);
}
.hero__name { margin-bottom: var(--space-3); }
.hero__role {
    font-family: var(--font-sans);
    font-size: 1.05rem;
    font-weight: 500;
    color: var(--ink-soft);
    margin-bottom: var(--space-5);
}
.hero__role .accent { color: var(--navy); font-weight: 600; }

.hero__photo-wrap { justify-self: end; max-width: 320px; }
.hero__photo {
    width: 100%;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    aspect-ratio: 4 / 5;
    object-fit: cover;
}
.hero__caption {
    font-family: var(--font-sans);
    font-size: 0.82rem;
    color: var(--muted);
    text-align: center;
    margin-top: var(--space-3);
}

/* Field tags */
.tags { display: flex; flex-wrap: wrap; gap: var(--space-2); margin-bottom: var(--space-5); }
.tag {
    font-family: var(--font-sans);
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--navy);
    background: var(--bg-tint);
    border-radius: var(--radius-pill);
    padding: 0.35rem 0.85rem;
}

/* --- Cards / list items --- */
.card {
    background: var(--bg);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: var(--space-5);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.card:hover { border-color: var(--line-strong); box-shadow: var(--shadow-sm); }

.stack { display: grid; gap: var(--space-4); }
.stack--lg { gap: var(--space-5); }

/* --- Paper entry (research) --- */
.paper { padding-block: var(--space-5); border-bottom: 1px solid var(--line); }
.paper:last-child { border-bottom: 0; }
.paper__title {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--navy);
    margin: 0 0 var(--space-2);
    line-height: 1.35;
}
.paper__meta {
    font-family: var(--font-sans);
    font-size: 0.92rem;
    color: var(--muted);
    margin: 0 0 var(--space-3);
}
.paper__note { color: var(--ink-soft); font-size: 0.98rem; margin: 0 0 var(--space-3); }
.paper__note .label {
    font-family: var(--font-sans);
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--muted);
    margin-right: 0.4rem;
}

/* --- CV / structured entries --- */
.entry { padding-block: var(--space-4); border-bottom: 1px solid var(--line); }
.entry:last-child { border-bottom: 0; }
.entry__head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: var(--space-4);
    flex-wrap: wrap;
}
.entry__title { font-size: 1.08rem; font-weight: 600; color: var(--ink); margin: 0; }
.entry__place { font-style: italic; color: var(--ink-soft); margin: 0.1rem 0 0; }
.entry__date {
    font-family: var(--font-sans);
    font-size: 0.88rem;
    color: var(--muted);
    white-space: nowrap;
}
.entry__body { margin-top: var(--space-2); color: var(--ink-soft); font-size: 0.98rem; }
.entry__courses { list-style: none; padding: 0; margin: var(--space-2) 0 0; }
.entry__courses li { padding: 0.15rem 0; color: var(--ink-soft); font-size: 0.98rem; }
.entry__courses .code {
    font-family: var(--font-sans);
    font-weight: 600;
    color: var(--navy);
    font-size: 0.9rem;
    margin-right: 0.4rem;
}

/* Definition-style facts (skills, languages) */
.facts { display: grid; gap: var(--space-3); margin: 0; }
.facts dt {
    font-family: var(--font-sans);
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--muted);
    margin-bottom: 0.15rem;
}
.facts dd { margin: 0 0 var(--space-2); color: var(--ink-soft); }

/* Two-column layout for CV / content pages */
.grid-2 {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: var(--space-6);
}

/* News list */
.news { list-style: none; padding: 0; margin: 0; }
.news li {
    position: relative;
    padding-left: var(--space-5);
    margin-bottom: var(--space-4);
    color: var(--ink-soft);
}
.news li::before {
    content: "";
    position: absolute;
    left: 0;
    top: 0.65em;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--navy);
}
.news .date {
    font-family: var(--font-sans);
    font-size: 0.8rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--muted);
    display: block;
    margin-bottom: 0.1rem;
}

/* PDF embed (CV) */
.pdf-frame {
    width: 100%;
    height: min(85vh, 1000px);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--bg-subtle);
}

/* Callout / personal note */
.note {
    font-style: italic;
    color: var(--ink-soft);
    border-left: 3px solid var(--line-strong);
    padding-left: var(--space-4);
    margin-block: var(--space-5);
}

/* 8) FOOTER -------------------------------------------------------------- */
.site-footer {
    flex-shrink: 0;
    border-top: 1px solid var(--line);
    background: var(--bg-subtle);
    padding-block: var(--space-6);
    margin-top: var(--space-9);
}
.site-footer .container {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-4);
}
.site-footer p {
    margin: 0;
    font-family: var(--font-sans);
    font-size: 0.85rem;
    color: var(--muted);
}
.site-footer a { color: var(--ink-soft); text-decoration: none; }
.site-footer a:hover { color: var(--navy); }
.footer-links { display: flex; gap: var(--space-4); flex-wrap: wrap; }

/* 9) UTILITIES ----------------------------------------------------------- */
.text-center { text-align: center; }
.muted { color: var(--muted); }
.sans { font-family: var(--font-sans); }
.mt-0 { margin-top: 0; }
.mb-0 { margin-bottom: 0; }
.sr-only {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

/* Subtle entrance animation, disabled under reduced-motion (above) */
@keyframes fadeUp {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}
.fade-in { animation: fadeUp 0.6s ease-out both; }

/* 10) RESPONSIVE --------------------------------------------------------- */
@media (max-width: 820px) {
    .hero {
        grid-template-columns: 1fr;
        gap: var(--space-6);
        padding-top: var(--space-6);
    }
    .hero__photo-wrap { order: -1; justify-self: start; max-width: 220px; }
    .hero__photo { aspect-ratio: 1 / 1; }
}

@media (max-width: 680px) {
    body { font-size: 1.02rem; }
    .section { padding-block: var(--space-7); }

    .nav__toggle { display: inline-flex; }
    .nav__menu {
        position: absolute;
        left: 0;
        right: 0;
        top: 100%;
        flex-direction: column;
        align-items: stretch;
        gap: 0;
        background: var(--bg);
        border-bottom: 1px solid var(--line);
        box-shadow: var(--shadow);
        padding: var(--space-2);
        max-height: 0;
        overflow: hidden;
        visibility: hidden;
        transition: max-height 0.25s ease;
    }
    .nav__menu.is-open { max-height: 420px; visibility: visible; }
    .nav__link { padding: var(--space-3); border-radius: var(--radius-sm); }
    .nav__link[aria-current="page"]::after { display: none; }
    .nav__link[aria-current="page"] { background: var(--bg-subtle); }

    .entry__head { flex-direction: column; }
    .site-footer .container { flex-direction: column; text-align: center; }
}
