/* ==========================================================================
   Academic/LaTeX Stylesheet for ekgvr.com
   A strict, text-focused design inspired by Wikipedia and LaTeX documents.
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Manjari&display=swap');

/* ==========================================================================
   0. VARIABLES & THEME
   ========================================================================== */

:root {
    /* Light Mode (Default) */
    --bg-main: #fff;
    --text-main: #202122;
    --text-heading: #000;
    --text-secondary-dark: #333;
    --text-tertiary: #555;
    --text-meta: #54595d;
    --text-date: #72777d;

    --link-color: #0645ad;
    --link-visited: #0b0080;
    --link-active: #faa700;

    --border-main: #a2a9b1;
    --border-secondary: #c8ccd1;
    --border-light: #eaecf0;

    --bg-secondary: #f8f9fa;
    --table-stripe: #f8f9fa;
    --table-header: #eaecf0;

    --color-danger: #d00;
    --color-focus: #0645ad;
}

[data-theme="dark"] {
    /* Dark Mode */
    --bg-main: #121212;
    --text-main: #e8eaed;
    --text-heading: #ffffff;
    --text-secondary-dark: #bdc1c6;
    --text-tertiary: #9aa0a6;
    --text-meta: #9aa0a6;
    --text-date: #9aa0a6;

    --link-color: #8ab4f8;
    --link-visited: #c58af9;
    --link-active: #faa700;

    --border-main: #5f6368;
    --border-secondary: #5f6368;
    --border-light: #3c4043;

    --bg-secondary: #202124;
    --table-stripe: #202124;
    --table-header: #3c4043;

    --color-danger: #ff5252;
    --color-focus: #8ab4f8;
}

/* ==========================================================================
   1. RESET & BASE
   ========================================================================== */

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

html {
    font-size: 100%;
    scroll-behavior: smooth;
}

body {
    font-family: Georgia, Cambria, "Times New Roman", Times, "Manjari", serif;
    font-size: 1rem;
    line-height: 1.7;
    color: var(--text-main);
    background-color: var(--bg-main);
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

/* ==========================================================================
   2. TYPOGRAPHY
   ========================================================================== */

/* Headings - Serif, normal weight (LaTeX style) */
h1, h2, h3, h4, h5, h6 {
    font-family: Georgia, Cambria, "Times New Roman", Times, serif;
    font-weight: normal;
    color: var(--text-heading);
    line-height: 1.3;
    margin-top: 1.5em;
    margin-bottom: 0.5em;
}

h1 {
    font-size: 2em;
    border-bottom: 1px solid var(--border-main);
    padding-bottom: 0.25em;
}

h2 {
    font-size: 1.5em;
    border-bottom: 1px solid var(--border-main);
    padding-bottom: 0.2em;
}

h3 {
    font-size: 1.25em;
}

h4 {
    font-size: 1.1em;
    font-style: italic;
}

h5, h6 {
    font-size: 1em;
}

/* Paragraphs */
p {
    margin-bottom: 1em;
    text-align: justify;
    hyphens: auto;
}

/* Links - Wikipedia blue */
a {
    color: var(--link-color);
    text-decoration: none;
}

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

a:hover,
a:focus {
    text-decoration: underline;
}

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

/* Lists */
ul, ol {
    margin: 1em 0;
    padding-left: 2em;
}

li {
    margin-bottom: 0.5em;
}

/* Blockquotes */
blockquote {
    margin: 1.5em 2em;
    padding-left: 1em;
    border-left: 3px solid var(--border-secondary);
    font-style: italic;
    color: var(--text-secondary-dark);
}

blockquote cite {
    display: block;
    margin-top: 0.5em;
    font-style: normal;
    font-size: 0.9em;
    color: var(--text-tertiary);
}

/* Horizontal rules */
hr {
    border: none;
    border-top: 1px solid var(--border-main);
    margin: 2em 0;
}

/* Code and preformatted text */
code, pre {
    font-family: "Courier New", Courier, monospace;
    font-size: 0.9em;
    background-color: var(--bg-secondary);
}

code {
    padding: 0.1em 0.3em;
    color: var(--text-main);
}

pre {
    padding: 1em;
    overflow-x: auto;
    border: 1px solid var(--border-secondary);
    margin: 1.5em 0;
    color: var(--text-main);
}

/* Small text and metadata - Sans-serif */
small,
.meta,
.post-date,
.technical,
figcaption {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
    font-size: 0.875rem;
    color: var(--text-meta);
}

/* ==========================================================================
   3. LAYOUT
   ========================================================================== */

/* Main content container */
main {
    max-width: 800px;
    margin: 0 auto;
    padding: 2em 1.5em;
}

/* ==========================================================================
   4. HEADER & NAVIGATION
   ========================================================================== */

header {
    max-width: 800px;
    margin: 0 auto;
    padding: 1.5em 1.5em 1em;
    border-bottom: 1px solid var(--border-main);
}

header h1 {
    font-size: 1.5em;
    margin: 0;
    padding: 0;
    border: none;
}

header h1 a {
    color: var(--text-heading);
    text-decoration: none;
}

header h1 a:hover {
    text-decoration: none;
}

/* Navigation */
nav {
    margin-top: 0.75em;
}

nav ul {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 0.25em 1.5em;
}

nav ul li {
    margin: 0;
}

nav ul li a {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
    font-size: 0.9rem;
    color: var(--link-color);
}

nav ul li a:visited {
    color: var(--link-color);
}

nav ul li a.active {
    font-weight: bold;
}

/* ==========================================================================
   5. HERO SECTION (Homepage)
   ========================================================================== */

#hero {
    padding: 0;
}

.hero-container {
    display: flex;
    align-items: flex-start;
    gap: 2em;
    margin-top: 1em;
}

.hero-text {
    flex: 1;
}

.hero-text h1 {
    font-size: 1.4em;
    font-style: italic;
    font-weight: normal;
    border: none;
    margin: 0;
    padding: 0;
    line-height: 1.5;
}

.hero-image {
    flex: 0 0 280px;
}

.hero-image img {
    width: 100%;
    height: auto;
    border: 1px solid var(--border-main);
}

/* ==========================================================================
   6. BLOG/RESEARCH LISTING
   ========================================================================== */

#blog-contents {
    max-width: 100%;
    padding: 0;
}

#blog-contents > h1 {
    margin-top: 0;
}

/* Publication list (replaces blog grid) */
.blog-grid {
    display: block;
    margin: 0;
    padding: 0;
}

.blog-post {
    display: block;
    padding: 1.25em 0;
    border-bottom: 1px solid var(--border-light);
    background: none;
}

.blog-post:first-child {
    padding-top: 0;
}

/* Hide cover images for academic look */
.blog-post .post-image {
    display: none;
}

.blog-post h2 {
    font-size: 1.1em;
    font-weight: normal;
    margin: 0 0 0.25em 0;
    border: none;
    padding: 0;
    text-align: left;
}

.blog-post h2 a {
    color: var(--link-color);
}

.blog-post h2 a:visited {
    color: var(--link-visited);
}

.blog-post .post-date {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
    font-size: 0.8rem;
    color: var(--text-date);
    margin-bottom: 0.5em;
    text-align: left;
}

.blog-post .post-summary {
    font-size: 0.95em;
    color: var(--text-secondary-dark);
    line-height: 1.6;
    margin: 0;
    text-align: left;
}

/* ==========================================================================
   7. INDIVIDUAL BLOG POST / ARTICLE
   ========================================================================== */

article.blog-post-content {
    max-width: 100%;
    padding: 0;
}

article.blog-post-content h1 {
    text-align: left;
    margin-top: 0;
}

article.blog-post-content .post-date {
    text-align: left;
    margin-bottom: 2em;
    padding-bottom: 1em;
    border-bottom: 1px solid var(--border-light);
}

article.blog-post-content h2,
article.blog-post-content h3,
article.blog-post-content h4,
article.blog-post-content h5,
article.blog-post-content h6 {
    text-align: left;
}

article.blog-post-content p {
    margin-bottom: 1.25em;
}

article.blog-post-content ul,
article.blog-post-content ol {
    margin-bottom: 1.25em;
}

article.blog-post-content li {
    margin-bottom: 0.5em;
}

article.blog-post-content img {
    max-width: 100%;
    height: auto;
    margin: 1.5em 0;
    border: 1px solid var(--border-main);
}

/* ==========================================================================
   8. TABLES (Wikipedia style)
   ========================================================================== */

table {
    width: 100%;
    border-collapse: collapse;
    margin: 1.5em 0;
    font-size: 0.95em;
    line-height: 1.5;
}

th, td {
    border: 1px solid var(--border-main);
    padding: 0.5em 0.75em;
    text-align: left;
    vertical-align: top;
}

th {
    background-color: var(--table-header);
    font-weight: bold;
    color: var(--text-main);
}

tr:nth-child(even) {
    background-color: var(--table-stripe);
}

td {
    color: var(--text-main);
}

caption {
    caption-side: top;
    text-align: left;
    font-style: italic;
    padding: 0.5em 0;
    color: var(--text-meta);
}

/* ==========================================================================
   9. MUSIC / DISCOGRAPHY
   ========================================================================== */

.music-library {
    max-width: 100%;
    margin: 0;
    padding: 0;
}

.music-library h1 {
    margin-top: 0;
}

.track {
    padding: 1.25em 0;
    border-bottom: 1px solid var(--border-light);
    display: block;
    cursor: default;
}

.track:hover {
    background: none;
}

.track-info {
    margin: 0;
}

.track-title {
    font-size: 1.1em;
    font-weight: normal;
    margin-bottom: 0.25em;
}

.track-meta {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
    font-size: 0.85em;
    color: var(--text-meta);
    margin-bottom: 0.5em;
}

.track-description {
    font-size: 0.95em;
    color: var(--text-secondary-dark);
    margin-top: 0.5em;
    font-style: italic;
}

.add-to-queue {
    display: none;
}

/* Queue container */
.queue-container {
    max-width: 100%;
    margin: 2em 0;
    padding: 0;
}

.queue {
    border: 1px solid var(--border-main);
    padding: 1em;
    background-color: var(--bg-secondary);
}

.queue h2 {
    margin-top: 0;
    font-size: 1em;
    border: none;
}

.queue-item {
    display: flex;
    align-items: center;
    padding: 0.5em 0;
    border-bottom: 1px solid var(--border-light);
}

.queue-item:last-child {
    border-bottom: none;
}

.queue-item .move-handle {
    cursor: move;
    margin-right: 0.75em;
    color: var(--text-date);
}

.queue-item .queue-title {
    flex-grow: 1;
    font-size: 0.95em;
}

.queue-item .remove-from-queue {
    background: none;
    border: none;
    color: var(--border-main);
    cursor: pointer;
    font-size: 0.85em;
}

.queue-item .remove-from-queue:hover {
    color: var(--color-danger);
}

/* Player controls */
.player-controls {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background-color: var(--bg-secondary);
    border-top: 1px solid var(--border-main);
    padding: 0.75em 1.5em;
    display: flex;
    align-items: center;
    gap: 0.75em;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
    font-size: 0.9em;
}

.player-controls button {
    font-family: inherit;
    font-size: 0.85em;
    padding: 0.4em 0.8em;
    background: var(--bg-main);
    border: 1px solid var(--border-main);
    cursor: pointer;
    color: var(--text-main);
}

.player-controls button:hover {
    background: var(--bg-secondary);
}

.player-controls .current-track {
    flex-grow: 1;
    color: var(--text-main);
}

/* Native audio element */
audio {
    width: 100%;
    max-width: 500px;
    margin: 1em 0;
}

/* ==========================================================================
   10. FIGURES & IMAGES
   ========================================================================== */

.photo-entry {
    margin-bottom: 4em;
    padding-bottom: 2em;
    border-bottom: 1px solid var(--border-light);
}

.photo-entry:last-child {
    border-bottom: none;
}

figure {
    margin: 1.5em 0;
}

figure img {
    max-width: 100%;
    height: auto;
    border: 1px solid var(--border-main);
}

figcaption {
    margin-top: 0.5em;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
    font-size: 0.875em;
    color: var(--text-meta);
    line-height: 1.5;
}

/* ==========================================================================
   11. FOOTNOTES & REFERENCES
   ========================================================================== */

.footnote-ref {
    font-size: 0.75em;
    vertical-align: super;
    line-height: 0;
}

.footnotes,
.references {
    margin-top: 3em;
    padding-top: 1em;
    border-top: 1px solid var(--border-main);
}

.footnotes ol,
.references ol {
    padding-left: 1.5em;
    font-size: 0.9em;
}

/* Bibliography entries */
.bibliography {
    list-style: none;
    padding-left: 0;
}

.bibliography li {
    padding-left: 2em;
    text-indent: -2em;
    margin-bottom: 0.75em;
}

/* ==========================================================================
   12. TABLE OF CONTENTS (Wikipedia style)
   ========================================================================== */

.toc {
    display: inline-block;
    border: 1px solid var(--border-main);
    background-color: var(--bg-secondary);
    padding: 1em 1.5em;
    margin: 1em 0;
}

.toc-title {
    font-weight: bold;
    text-align: center;
    margin-bottom: 0.5em;
}

.toc ol {
    margin: 0;
    padding-left: 1.5em;
}

.toc li {
    margin-bottom: 0.25em;
}

/* ==========================================================================
   13. FORMS & INPUTS
   ========================================================================== */

input, textarea, select, button {
    font-family: inherit;
    font-size: 1em;
}

input[type="text"],
input[type="email"],
textarea {
    width: 100%;
    max-width: 400px;
    padding: 0.5em;
    border: 1px solid var(--border-main);
    background: var(--bg-main);
    color: var(--text-main);
}

input[type="text"]:focus,
input[type="email"]:focus,
textarea:focus {
    outline: none;
    border-color: var(--color-focus);
}

button,
input[type="submit"] {
    padding: 0.5em 1em;
    background: var(--bg-secondary);
    border: 1px solid var(--border-main);
    cursor: pointer;
    color: var(--text-main);
}

button:hover,
input[type="submit"]:hover {
    background: var(--border-light);
}

/* ==========================================================================
   14. UTILITY CLASSES
   ========================================================================== */

.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;
}

.text-center {
    text-align: center;
}

.text-right {
    text-align: right;
}

.small-caps {
    font-variant: small-caps;
    letter-spacing: 0.05em;
}

/* ==========================================================================
   15. RESPONSIVE DESIGN
   ========================================================================== */

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

    header, main {
        padding-left: 1em;
        padding-right: 1em;
    }

    .hero-container {
        flex-direction: column;
    }

    .hero-text {
        order: 2;
    }

    .hero-image {
        order: 1;
        flex: none;
        width: 100%;
        max-width: 250px;
        margin: 0 auto;
    }

    .hero-text h1 {
        text-align: center;
        font-size: 1.2em;
    }

    nav ul {
        justify-content: center;
    }

    p {
        text-align: left;
        hyphens: none;
    }

    blockquote {
        margin-left: 1em;
        margin-right: 1em;
    }

    .player-controls {
        padding: 0.5em 1em;
        flex-wrap: wrap;
    }
}

/* ==========================================================================
   16. PRINT STYLES
   ========================================================================== */

@media print {
    body {
        font-size: 12pt;
        color: #000;
        background: #fff;
    }

    header nav,
    .player-controls,
    .queue-container,
    .add-to-queue,
    audio {
        display: none;
    }

    a {
        color: #000;
        text-decoration: underline;
    }

    a[href^="http"]::after {
        content: " (" attr(href) ")";
        font-size: 0.8em;
        color: #555;
    }

    h1, h2, h3 {
        page-break-after: avoid;
    }

    img, figure, table {
        page-break-inside: avoid;
    }
}

/* ==========================================================================
   17. THEME SWITCHER
   ========================================================================== */

.theme-switcher-item {
    margin-left: auto; /* Push to right if flex */
    display: flex;
    align-items: center;
}

.theme-switcher {
    display: inline-flex;
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-main);
    border-radius: 6px;
    padding: 2px;
    font-size: 0.8rem;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
}

.theme-switcher button {
    background: transparent;
    border: none;
    padding: 2px 8px;
    border-radius: 4px;
    cursor: pointer;
    color: var(--text-meta);
    font-size: inherit;
    line-height: 1.5;
}

.theme-switcher button:hover {
    color: var(--text-main);
    background: transparent;
}

.theme-switcher button.active {
    background-color: var(--bg-main);
    color: var(--text-heading);
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    font-weight: 500;
}

/* Adjustments for dark mode switcher visibility */
[data-theme="dark"] .theme-switcher button.active {
    background-color: #4a4a4a;
    color: #fff;
}
