/* Google Fonts */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=Merriweather:wght@400;700&display=swap');

:root {
    --primary-color: #1a1a2e;
    --secondary-color: #16213e;
    /* Link blue and muted grey were #0f7dff / #718096, which score 3.9:1 and
       4.0:1 on white — under the 4.5 minimum for body text. Darkened just enough
       to clear it against both --white and --light-bg (5.5:1 and 5.4:1). */
    --accent-color: #0b63d9;
    --accent-hover: #0a54b8;
    --text-color: #2d3748;
    --text-muted: #5d6b7f;
    --light-bg: #f7f8fc;
    --white: #ffffff;
    --border-color: #e2e8f0;
    --card-shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
    --card-shadow-hover: 0 10px 25px rgba(0,0,0,0.08), 0 4px 10px rgba(0,0,0,0.04);

    /* Surfaces that used to be hardcoded literals in the rules below. The footer
       keeps its own variables rather than reusing --primary-color, which doubles
       as heading text. */
    --header-bg: rgba(255,255,255,0.92);
    --footer-bg: #1a1a2e;
    --footer-text: rgba(255,255,255,0.7);
    --footer-link: rgba(255,255,255,0.88);
    --accent-soft: #eef4ff;
    --badge-green-bg: #e6f6ec;
    --badge-green-text: #1a7f37;

    --font-heading: 'Merriweather', serif;
    --font-body: 'Inter', sans-serif;
    --spacing-xs: 0.25rem;
    --spacing-sm: 0.5rem;
    --spacing-md: 1rem;
    --spacing-lg: 1.5rem;
    --spacing-xl: 2rem;
    --spacing-2xl: 3rem;
    --container-width: 960px;
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --transition: 0.2s ease;

    color-scheme: light;
}

/* ---------- Legacy <font color> ----------
   21 archived pages still carry <font color="..."> from the 1990s/2000s. None of
   them sets a body background, so those colours assumed one that never existed:
   Sokoban's white "Greetz To:" has been invisible on white since the original
   site, and #CCCCCC scores 1.6:1. Neutralising the attribute lets them inherit
   the page colour instead.

   Scoped to pages that do NOT set their own bgcolor — the generated Javadoc under
   programs/fire/fire/javadoc/ does set one and is internally consistent, so it
   keeps its own 2006 styling. Near-black and near-white are the broken cases;
   deliberate accents like #FF0000 are left alone.

   The `:not(:where([bgcolor] *))` guard matters: some pages colour a table cell
   and then use a matching font colour inside it. Those are self-consistent, and
   neutralising them turns readable text into 4.2:1 mud. */
body:not([bgcolor]) font[color="#FFFFFF" i]:not(:where([bgcolor] *)),
body:not([bgcolor]) font[color="white" i]:not(:where([bgcolor] *)),
body:not([bgcolor]) font[color="#CCCCCC" i]:not(:where([bgcolor] *)),
body:not([bgcolor]) font[color="#C0C0C0" i]:not(:where([bgcolor] *)),
body:not([bgcolor]) font[color="silver" i]:not(:where([bgcolor] *)),
body:not([bgcolor]) font[color="#999999" i]:not(:where([bgcolor] *)),
body:not([bgcolor]) font[color="#000000" i]:not(:where([bgcolor] *)),
body:not([bgcolor]) font[color="black" i]:not(:where([bgcolor] *)) {
    color: inherit;
}

/* Reset & Base */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-body);
    font-size: 16px;
    line-height: 1.7;
    color: var(--text-color);
    background-color: var(--light-bg);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

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

/* Medium-imported posts wrap images in <figure> with a .imageCaption caption.
   Without these, the browser default (figure { margin: 1em 40px }) indents the
   image and the caption renders at full body size, reading as a paragraph. */
figure {
    margin: 1.5rem 0;
    text-align: center;
}

figcaption,
.imageCaption {
    margin-top: 0.5rem;
    font-size: 0.85em;
    line-height: 1.5;
    color: var(--text-muted);
    text-align: center;
    font-style: italic;
}

/* Post bodies (both the 2005-2008 archive and the Medium imports) rely on these;
   without them <pre> has no background, inline <code> is indistinguishable from
   body text, and the 68 <hr> separators are nearly invisible. */
pre {
    overflow-x: auto;
    margin: 1rem 0;
    padding: 0.9rem 1rem;
    background: var(--light-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 0.875em;
    line-height: 1.5;
}

code {
    font-size: 0.9em;
}

:not(pre) > code {
    padding: 0.1em 0.35em;
    background: var(--light-bg);
    border: 1px solid var(--border-color);
    border-radius: 4px;
}

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

table {
    display: block;
    overflow-x: auto;
    margin: 1rem 0;
    border-collapse: collapse;
}

th, td {
    border: 1px solid var(--border-color);
    padding: 0.4rem 0.65rem;
    text-align: left;
}

th {
    background: var(--light-bg);
    font-weight: 600;
}

a {
    color: var(--accent-color);
    text-decoration: none;
    transition: color var(--transition);
}

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

/* Typography */
h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-heading);
    color: var(--primary-color);
    line-height: 1.3;
}

h1 {
    font-size: 2.25rem;
    margin-bottom: var(--spacing-lg);
    letter-spacing: -0.02em;
}

h2 {
    font-size: 1.5rem;
    margin-top: var(--spacing-2xl);
    margin-bottom: var(--spacing-md);
    padding-bottom: var(--spacing-sm);
    border-bottom: 2px solid var(--border-color);
}

h3 {
    font-size: 1.15rem;
    margin-top: var(--spacing-lg);
    margin-bottom: var(--spacing-sm);
    color: var(--secondary-color);
}

p {
    margin-bottom: var(--spacing-md);
}

ul, ol {
    margin-bottom: var(--spacing-md);
    padding-left: var(--spacing-lg);
}

li {
    margin-bottom: var(--spacing-sm);
}

strong {
    font-weight: 600;
}

/* Layout */
.container {
    width: 100%;
    max-width: var(--container-width);
    margin: 0 auto;
    padding: 0 var(--spacing-lg);
}

/* Header */
header {
    background-color: var(--white);
    border-bottom: 1px solid var(--border-color);
    padding: var(--spacing-md) 0;
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(10px);
    background-color: var(--header-bg);
}

header .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: var(--spacing-md);
}

.site-title {
    font-family: var(--font-heading);
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--primary-color);
    letter-spacing: -0.01em;
}

.site-title:hover {
    color: var(--accent-color);
    text-decoration: none;
}

/* Navigation */
nav ul {
    display: flex;
    list-style: none;
    padding: 0;
    margin: 0;
    gap: var(--spacing-xs);
}

nav a {
    color: var(--text-muted);
    font-weight: 500;
    font-size: 0.95rem;
    padding: var(--spacing-sm) var(--spacing-md);
    border-radius: var(--radius-sm);
    transition: all var(--transition);
}

nav a:hover {
    color: var(--primary-color);
    background-color: var(--light-bg);
    text-decoration: none;
}

nav a.active {
    color: var(--accent-color);
    background-color: var(--accent-soft);
}

/* Main Content */
main {
    flex: 1;
    padding: var(--spacing-xl) 0 var(--spacing-2xl);
}

section {
    background: var(--white);
    padding: var(--spacing-xl) var(--spacing-2xl);
    border-radius: var(--radius-lg);
    box-shadow: var(--card-shadow);
    margin-bottom: var(--spacing-xl);
    border: 1px solid var(--border-color);
}

/* Footer */
footer {
    background-color: var(--footer-bg);
    color: var(--footer-text);
    padding: var(--spacing-xl) 0;
    margin-top: auto;
    text-align: center;
    font-size: 0.875rem;
}

footer a {
    color: var(--footer-link);
}

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

/* ===== Component: Hero ===== */
.hero {
    text-align: center;
    padding: var(--spacing-2xl) 0 var(--spacing-xl);
}

.hero h1 {
    font-size: 2.75rem;
    margin-bottom: var(--spacing-md);
    background: linear-gradient(135deg, var(--primary-color), var(--accent-color));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.hero .subtitle {
    font-size: 1.15rem;
    color: var(--text-muted);
    max-width: 600px;
    margin: 0 auto var(--spacing-xl);
    line-height: 1.7;
}

/* ===== Component: Card Grid ===== */
.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: var(--spacing-lg);
    list-style: none;
    padding: 0;
    margin: 0;
}

.card {
    background: var(--white);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: var(--spacing-lg);
    transition: all var(--transition);
    display: flex;
    flex-direction: column;
}

.card:hover {
    box-shadow: var(--card-shadow-hover);
    transform: translateY(-2px);
    border-color: var(--accent-color);
}

.card h3 {
    margin-top: 0;
    font-size: 1.1rem;
    margin-bottom: var(--spacing-sm);
}

.card p {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: var(--spacing-md);
    flex: 1;
}

.card a {
    font-weight: 500;
}

.card-icon {
    font-size: 1.75rem;
    margin-bottom: var(--spacing-sm);
    display: block;
}

/* ===== Component: Info Grid ===== */
.info-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--spacing-md);
}

.info-item {
    padding: var(--spacing-md) var(--spacing-lg);
    background: var(--light-bg);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
}

.info-item .label {
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-bottom: var(--spacing-xs);
}

.info-item .value {
    font-size: 0.95rem;
    color: var(--text-color);
}

/* ===== Component: Social Links ===== */
.social-links {
    display: flex;
    gap: var(--spacing-sm);
    flex-wrap: wrap;
    margin-top: var(--spacing-lg);
}

.social-link {
    display: inline-flex;
    align-items: center;
    gap: var(--spacing-sm);
    padding: var(--spacing-sm) var(--spacing-lg);
    border-radius: var(--radius-sm);
    font-weight: 500;
    font-size: 0.9rem;
    transition: all var(--transition);
    border: 1px solid var(--border-color);
    color: var(--text-color);
    background: var(--white);
}

.social-link:hover {
    text-decoration: none;
    border-color: var(--accent-color);
    color: var(--accent-color);
    box-shadow: var(--card-shadow);
}

/* ===== Component: Tech Tags ===== */
.tag {
    display: inline-block;
    font-size: 0.75rem;
    font-weight: 500;
    padding: 2px 10px;
    border-radius: 20px;
    background: var(--accent-soft);
    color: var(--accent-color);
    margin-right: var(--spacing-xs);
    margin-bottom: var(--spacing-xs);
}

.tag-muted {
    background: var(--light-bg);
    color: var(--text-muted);
}

/* ===== Component: Project List ===== */
.project-list {
    list-style: none;
    padding: 0;
}

.project-list li {
    padding: var(--spacing-md) 0;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: var(--spacing-sm);
}

.project-list li:last-child {
    border-bottom: none;
}

.project-list a {
    font-weight: 500;
}

/* ===== Component: Publication Entry ===== */
.pub-entry {
    padding: var(--spacing-md) var(--spacing-lg);
    border-left: 3px solid var(--border-color);
    margin-bottom: var(--spacing-md);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    background: var(--light-bg);
    transition: border-color var(--transition);
}

.pub-entry:hover {
    border-left-color: var(--accent-color);
}

.pub-entry .pub-title {
    font-weight: 600;
    color: var(--primary-color);
    margin-bottom: var(--spacing-xs);
}

.pub-entry .pub-authors {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-bottom: var(--spacing-xs);
}

.pub-entry .pub-venue {
    font-size: 0.9rem;
    font-style: italic;
    margin-bottom: var(--spacing-sm);
}

.pub-entry .pub-links {
    display: flex;
    gap: var(--spacing-sm);
}

.pub-entry .pub-links a {
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    padding: 2px 10px;
    border: 1px solid var(--accent-color);
    border-radius: var(--radius-sm);
    transition: all var(--transition);
}

.pub-entry .pub-links a:hover {
    background: var(--accent-color);
    color: var(--white);
    text-decoration: none;
}

/* ===== Component: Blockquote ===== */
blockquote {
    position: relative;
    padding: var(--spacing-lg) var(--spacing-xl);
    margin-bottom: var(--spacing-xl);
    background: var(--light-bg);
    border-radius: var(--radius-md);
    border-left: 4px solid var(--accent-color);
    font-style: italic;
    color: var(--text-muted);
}

blockquote cite, blockquote .attribution {
    display: block;
    margin-top: var(--spacing-sm);
    font-style: normal;
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-color);
}

/* ===== Component: Timeline Items ===== */
.timeline-item {
    padding: var(--spacing-md) var(--spacing-lg);
    border-left: 2px solid var(--border-color);
    margin-left: var(--spacing-sm);
    margin-bottom: var(--spacing-md);
    position: relative;
    transition: border-color var(--transition);
}

.timeline-item:hover {
    border-left-color: var(--accent-color);
}

.timeline-item::before {
    content: '';
    position: absolute;
    left: -6px;
    top: var(--spacing-lg);
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--border-color);
    border: 2px solid var(--white);
    transition: background var(--transition);
}

.timeline-item:hover::before {
    background: var(--accent-color);
}

.timeline-item h3 {
    margin-top: 0;
    font-size: 1rem;
}

.timeline-item .meta {
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* ===== Component: CV Section ===== */
.cv-section {
    margin-bottom: var(--spacing-lg);
}

.cv-header {
    margin-bottom: var(--spacing-lg);
}

/* ===== Component: Badge ===== */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 500;
    background: var(--badge-green-bg);
    color: var(--badge-green-text);
}

.badge-blue {
    background: var(--accent-soft);
    color: var(--accent-color);
}

/* ===== Specific Page: Intro ===== */
.intro-text {
    font-size: 1.1rem;
    max-width: 800px;
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
    header .container {
        flex-direction: column;
        text-align: center;
    }

    nav ul {
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: center;
        gap: var(--spacing-xs);
    }

    h1 {
        font-size: 1.75rem;
    }

    .hero h1 {
        font-size: 2rem;
    }

    section {
        padding: var(--spacing-lg);
    }

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

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

    .pub-entry {
        padding: var(--spacing-md);
    }
}

@media (max-width: 480px) {
    section {
        padding: var(--spacing-md);
        border-radius: var(--radius-md);
    }

    nav a {
        padding: var(--spacing-xs) var(--spacing-sm);
        font-size: 0.875rem;
    }
}
