/* ===== CSS Variables ===== */
:root {
    --wiki-blue: #0645ad;
    --wiki-blue-hover: #0b0080;
    --wiki-visited: #0b0080;
    --wiki-external: #36b;
    --wiki-border: #a2a9b1;
    --wiki-bg-light: #f8f9fa;
    --wiki-bg-infobox: #f8f9fa;
    --wiki-header-border: #a2a9b1;
    --text-primary: #202122;
    --text-secondary: #54595d;
    --font-serif: 'Linux Libertine', 'Georgia', 'Times', serif;
    --font-sans: 'Source Sans Pro', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

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

html {
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-sans);
    font-size: 14px;
    line-height: 1.6;
    color: var(--text-primary);
    background: #fff;
}

a {
    color: var(--wiki-blue);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
    color: var(--wiki-blue-hover);
}

a:visited {
    color: var(--wiki-visited);
}

.external-link::after {
    content: '';
    display: inline-block;
    width: 12px;
    height: 12px;
    margin-left: 3px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23036' d='M6 1h5v5L8.5 3.5 5.4 6.6 4.4 5.6l3.1-3.1L6 1zm3 7v2H2V3h2l1-1H1v9h9V7l-1 1z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: center;
}

/* ===== Layout ===== */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px 30px;
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
}

/* ===== Infobox (Sidebar) ===== */
.infobox {
    float: right;
    width: 280px;
    margin: 0 0 20px 20px;
    border: 1px solid var(--wiki-border);
    background: var(--wiki-bg-infobox);
    font-size: 13px;
    order: 1;
}

.infobox-image {
    padding: 10px;
    text-align: center;
    background: #fff;
}

.infobox-image img {
    max-width: 100%;
    height: auto;
    border: 1px solid #c8ccd1;
}

.infobox-table {
    width: 100%;
    border-collapse: collapse;
}

.infobox-table th,
.infobox-table td {
    padding: 6px 10px;
    border-top: 1px solid var(--wiki-border);
    vertical-align: top;
    text-align: left;
}

.infobox-table th {
    width: 35%;
    background: var(--wiki-bg-light);
    font-weight: 600;
    color: var(--text-secondary);
}

.infobox-header {
    text-align: center !important;
    font-size: 16px;
    font-weight: bold;
    background: #cce0f5 !important;
    padding: 10px !important;
}

.infobox-subheader th {
    text-align: center !important;
    background: #dde8f5 !important;
    font-weight: 600;
}

.location {
    color: var(--text-secondary);
    font-size: 12px;
}

/* ===== Main Content ===== */
.content {
    flex: 1;
    min-width: 0;
    order: 0;
}

#page-title {
    font-family: var(--font-serif);
    font-size: 28px;
    font-weight: normal;
    border-bottom: 1px solid var(--wiki-header-border);
    padding-bottom: 5px;
    margin-bottom: 15px;
}

.lead {
    font-size: 15px;
    margin-bottom: 20px;
}

/* ===== Table of Contents ===== */
.toc {
    display: inline-block;
    background: var(--wiki-bg-light);
    border: 1px solid var(--wiki-border);
    padding: 10px 15px;
    margin: 10px 0 20px;
    min-width: 200px;
}

.toc-header {
    font-weight: bold;
    margin-bottom: 8px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.toc-toggle {
    font-weight: normal;
    color: var(--wiki-blue);
    font-size: 12px;
}

.toc-toggle:hover {
    text-decoration: underline;
}

.toc-list {
    list-style: none;
    padding-left: 0;
}

.toc-list li {
    margin: 4px 0;
}

.toc-list li a {
    color: var(--wiki-blue);
}

.toc-list ul {
    list-style: none;
    padding-left: 20px;
    margin-top: 4px;
}

.toc.collapsed .toc-list {
    display: none;
}

/* ===== Section Headings ===== */
h2 {
    font-family: var(--font-serif);
    font-size: 22px;
    font-weight: normal;
    border-bottom: 1px solid var(--wiki-header-border);
    margin: 25px 0 12px;
    padding-bottom: 3px;
    display: flex;
    align-items: baseline;
    justify-content: space-between;
}

h3 {
    font-family: var(--font-serif);
    font-size: 18px;
    font-weight: normal;
    margin: 20px 0 10px;
}

.mw-headline {
    flex: 1;
}

.edit-link {
    font-size: 13px;
    font-weight: normal;
    font-family: var(--font-sans);
    margin-left: 10px;
}

.edit-link a {
    color: var(--wiki-blue);
}

/* ===== Paragraphs & Lists ===== */
p {
    margin-bottom: 12px;
}

ul,
ol {
    margin: 10px 0 15px 25px;
}

li {
    margin-bottom: 5px;
}

/* ===== Publications List ===== */
.publications-list {
    margin-left: 25px;
}

.publications-list li {
    margin-bottom: 12px;
}

.pub-title {
    font-weight: 600;
}

.citation-link {
    font-size: 12px;
    margin-left: 5px;
}

.see-also {
    font-style: italic;
    margin-top: 15px;
    padding-top: 10px;
    border-top: 1px dotted var(--wiki-border);
}

/* ===== Wiki Table ===== */
.wikitable {
    border-collapse: collapse;
    margin: 15px 0;
    background: #f8f9fa;
}

.wikitable th,
.wikitable td {
    border: 1px solid var(--wiki-border);
    padding: 8px 12px;
    text-align: left;
}

.wikitable th {
    background: #eaecf0;
    font-weight: 600;
}

.wikitable tr:nth-child(even) {
    background: #f8f9fa;
}

.wikitable tr:nth-child(odd) {
    background: #fff;
}

/* ===== Contact Info ===== */
.contact-info {
    background: var(--wiki-bg-light);
    border: 1px solid var(--wiki-border);
    padding: 15px 20px;
    margin: 10px 0;
}

.contact-info p {
    margin-bottom: 8px;
}

/* ===== References ===== */
.references {
    font-size: 13px;
    margin-left: 25px;
}

.references li {
    margin-bottom: 8px;
}

.ref-content {
    color: var(--text-secondary);
}

/* ===== Categories ===== */
.categories {
    margin-top: 30px;
    padding: 10px 15px;
    background: var(--wiki-bg-light);
    border: 1px solid var(--wiki-border);
    font-size: 13px;
}

.category-label {
    font-weight: 600;
    margin-right: 10px;
}

.categories a {
    margin: 0 5px;
}

/* ===== Footer ===== */
.footer {
    margin-top: 30px;
    padding: 20px 30px;
    background: var(--wiki-bg-light);
    border-top: 1px solid var(--wiki-border);
    text-align: center;
    font-size: 12px;
    color: var(--text-secondary);
}

.footer p {
    margin: 5px 0;
}

/* ===== Responsive Design ===== */
@media (max-width: 900px) {
    .container {
        flex-direction: column;
        padding: 15px;
    }

    .infobox {
        float: none;
        width: 100%;
        margin: 0 0 20px 0;
        order: 0;
    }

    .content {
        order: 1;
    }

    .infobox-table th {
        width: 30%;
    }
}

@media (max-width: 600px) {
    body {
        font-size: 15px;
    }

    #page-title {
        font-size: 24px;
    }

    h2 {
        font-size: 20px;
    }

    h3 {
        font-size: 17px;
    }

    .toc {
        width: 100%;
    }

    .wikitable {
        display: block;
        overflow-x: auto;
    }

    .infobox-image img {
        max-width: 180px;
    }
}

/* ===== Print Styles ===== */
@media print {

    .edit-link,
    .toc-toggle {
        display: none;
    }

    .infobox {
        page-break-inside: avoid;
    }

    a[href]:after {
        content: none;
    }
}

/* ===== Smooth Scrolling for Anchor Links ===== */
section {
    scroll-margin-top: 20px;
}

/* ===== Selection Styling ===== */
::selection {
    background: #b3d4fc;
    color: #000;
}

/* ===== Focus States for Accessibility ===== */
a:focus {
    outline: 2px solid var(--wiki-blue);
    outline-offset: 2px;
}

/* ===== Smooth Transitions ===== */
.toc-list {
    transition: all 0.3s ease;
}

.infobox {
    transition: box-shadow 0.2s ease;
}

.infobox:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* Wikipedia-style quote blocks if needed */
blockquote {
    margin: 15px 40px;
    padding-left: 15px;
    border-left: 3px solid var(--wiki-border);
    color: var(--text-secondary);
    font-style: italic;
}

/* ===== Project Meta Info ===== */
.project-meta {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 10px;
    padding: 5px 0;
    border-bottom: 1px dotted var(--wiki-border);
}

.project-date {
    font-weight: 600;
    color: var(--text-primary);
}

.project-type {
    font-style: italic;
}

.project-link {
    font-weight: 600;
}

/* ===== Grade Highlights ===== */
.grade-highlight {
    background: linear-gradient(135deg, #f8f9fa 0%, #eef5ff 100%);
    padding: 10px 15px;
    border-left: 4px solid #0645ad;
    margin: 12px 0;
    border-radius: 0 4px 4px 0;
}

.grade-s {
    background: linear-gradient(135deg, #10b981, #059669);
    color: white;
    padding: 2px 10px;
    border-radius: 12px;
    font-weight: 600;
    font-size: 12px;
    display: inline-block;
}

.grade-a {
    background: linear-gradient(135deg, #3b82f6, #2563eb);
    color: white;
    padding: 2px 10px;
    border-radius: 12px;
    font-weight: 600;
    font-size: 12px;
    display: inline-block;
}

/* ===== Skill Tags ===== */
.skills-table td {
    padding: 12px 15px;
}

.skill-tag {
    display: inline-block;
    background: linear-gradient(135deg, #e0e7ff 0%, #c7d2fe 100%);
    color: #3730a3;
    padding: 4px 12px;
    border-radius: 15px;
    font-size: 13px;
    font-weight: 500;
    margin: 3px 4px 3px 0;
    transition: all 0.2s ease;
}

.skill-tag:hover {
    background: linear-gradient(135deg, #c7d2fe 0%, #a5b4fc 100%);
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.skill-tag.soft {
    background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
    color: #92400e;
}

.skill-tag.soft:hover {
    background: linear-gradient(135deg, #fde68a 0%, #fcd34d 100%);
}

/* ===== Enhanced Infobox for Portfolio ===== */
.infobox-table td a {
    word-break: break-word;
}

/* ===== Project Section Improvements ===== */
.section-subheader {
    background: linear-gradient(135deg, #e8f4fd 0%, #d4e8f9 100%);
    padding: 8px 15px;
    margin: 25px 0 15px 0;
    border-left: 4px solid #0645ad;
    border-radius: 0 4px 4px 0;
}

.section-subheader .mw-headline {
    font-weight: 600;
    color: #1a4971;
}

#projects h4 {
    font-family: var(--font-serif);
    font-size: 16px;
    font-weight: normal;
    margin-top: 20px;
    padding-top: 12px;
    border-top: 1px dashed var(--wiki-border);
}

#projects h3+h4 {
    border-top: none;
    padding-top: 5px;
}