/* Reset basic margins and set a clean font */
body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    font-size: 18px;

    line-height: 1.55;
}

.container {
    max-width: 1200px;      /* Adjust this to fit your desired site width */
    margin: 0 auto;         /* The magic trick: automatically centers the box */
    padding: 0 20px;        /* Prevents text from touching the screen edge on mobile */
    width: 100%;            /* Ensures it spans the screen up to the max-width */
    box-sizing: border-box; /* Ensures padding doesn't accidentally increase the total width */
}

/* The main header container */
header {
    background-color: #ffffff;
    border-bottom: 1px solid #eaeaea; /* Subtle line under the navbar */
    padding: 1rem 2rem;
    position: sticky;
    top: 0;
    z-index: 100;
    max-width: 1000px; /* Constrains the header width */
    margin: 0 auto;
}

/* Flexbox magic: separates the Title and the Links */
nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 1000px;
    margin: 0 auto; /* Centers the navbar on large screens */
}

/* Style the site title/logo */
.site-title a {
    font-size: 1.25rem;
    font-weight: 600;
    text-decoration: none;
    color: #111;
}

/* Remove bullet points and set links in a row */
.nav-links {
    list-style: none;
    display: flex;
    gap: 1.5rem; /* Space between links */
    margin: 0;
    padding: 0;
}

/* Style the individual links */
.nav-links a {
    text-decoration: none;
    color: #555;
    font-size: 1rem;
    transition: color 0.2s ease;
}

/* Hover effect */
.nav-links a:hover {
    color: #0056b3; /* A nice academic blue */
}

article {
    counter-reset: theorem lemma proposition definition;
}

/* 2. Base styling for all math environments */
.math-env {
    margin: 1.5rem 0;
    padding: 1rem;
    background-color: #f8f9fa; /* Very subtle grey background */
    border-left: 3px solid #0056b3; /* Academic blue accent */
    border-radius: 2px;

    scroll-margin-top: 5rem;
}

/* Definitions usually get a different accent color to stand out */
.math-env.definition {
    border-left-color: #28a745; 
}

/* 3. Auto-numbering and formatting the Titles */
.math-env-title {
    font-weight: bold;
    display: block;
    margin-bottom: 0.5rem;
}

.math-env.theorem .math-env-title::before {
    counter-increment: theorem;
    content: "Theorem " counter(theorem) " ";
}
.math-env.lemma .math-env-title::before {
    counter-increment: lemma;
    content: "Lemma " counter(lemma) " ";
}
.math-env.proposition .math-env-title::before {
    counter-increment: proposition;
    content: "Proposition " counter(proposition) " ";
}
.math-env.definition .math-env-title::before {
    counter-increment: definition;
    content: "Definition " counter(definition) " ";
}

/* 4. Body Text: Theorems are italic, Definitions are upright */
.math-env.theorem .math-env-content,
.math-env.lemma .math-env-content,
.math-env.proposition .math-env-content {
    font-style: italic;
}
.math-env.definition .math-env-content {
    font-style: normal;
}

/* 5. The Proof Environment */
details.math-proof {
    margin: 1.5rem 0;
    padding-left: 1rem;
    border-left: 2px solid #ccc;
}

/* The Clickable Title */
details.math-proof summary.math-proof-title {
    font-style: italic;
    font-weight: bold;
    margin-bottom: 0.5rem;
    cursor: pointer;
    user-select: none;
    color: #555;
    transition: color 0.2s;
    
    /* 1. Hide the default browser triangle */
    list-style: none;
}

/* 2. Hide the default triangle in Safari/Webkit browsers */
details.math-proof summary.math-proof-title::-webkit-details-marker {
    display: none;
}

/* 3. Add the [+] when the box is closed */
details.math-proof summary.math-proof-title::before {
    content: "[+] ";
    font-weight: bold;
    font-style: normal; /* Keeps the brackets upright next to the italic text */
    color: #0056b3;     /* Makes the toggle button stand out slightly */
    display: inline-block;
    width: 1.5rem;      /* Keeps spacing consistent so text doesn't jump */
}

/* 4. Change it to [-] when the box is clicked and opens */
details.math-proof[open] summary.math-proof-title::before {
    content: "[-] ";
}

/* Hover effect */
details.math-proof summary.math-proof-title:hover {
    color: #0056b3; 
}

/* Add a slight margin to the actual text inside */
.math-proof-content {
    margin-top: 0.5rem;
    margin-bottom: 1.5rem;
}

.qed {
    text-align: right;
    display: block;
    margin-top: -1rem;
}

p {
    /* 1. Force the edges to be flush */
    text-align: justify;
    
    /* 2. Tell the browser to prioritize adjusting word spacing, not letter spacing */
    text-justify: inter-word; 
    
    /* 3. CRITICAL: Allow the browser to break long words with hyphens */
    hyphens: auto;
    -webkit-hyphens: auto; /* Safari support */
    -ms-hyphens: auto;     /* Older Edge support */
}

.profile-img {
    float: right; 
    width: 220px; 
    height: auto; 
    border-radius: 8px; 
    margin: 0 0 1.5rem 2rem; 
    box-shadow: 0 4px 6px rgba(0,0,0,0.5); 
    border: 2px solid #333333;
}


@media (max-width: 768px) {
    /* 1. Hide the name/site title */
    .site-title {
        display: none;
    }

    /* 2. Center the remaining navigation menu */
    nav {
        justify-content: center;
    }

    /* 3. Adjust the links to fit better on small screens */
    .nav-links {
        gap: 1rem; /* Reduces the space between links from 1.5rem to 1rem */
        flex-wrap: wrap; /* Allows links to flow to a second line if the screen is very narrow */
        justify-content: center;
    }
    
    /* Optional: Reduce header padding to save screen space on mobile */
    header {
        padding: 0.75rem 1rem;
    }

    .profile-img {
        float: none;           /* Stops the image from pushing to the right */
        display: block;        /* Allows the image to behave like a standard block element */
        margin: 0 auto 1.5rem; /* The magic trick: 'auto' on left/right centers it perfectly! */
    }
}