/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --color-text: #2c3e50;
    --color-text-light: #5a6c7d;
    --color-bg: #ffffff;
    --color-bg-alt: #f8f9fa;
    --color-accent: #3498db;
    --color-border: #e1e8ed;
    --font-serif: 'Georgia', 'Times New Roman', serif;
    --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Helvetica', 'Arial', sans-serif;
    --max-width: 720px;
}

html {
    font-size: 18px;
    line-height: 1.6;
}

body {
    font-family: var(--font-serif);
    color: var(--color-text);
    background-color: var(--color-bg);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Container */
.container {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0 2rem;
    overflow-x: visible;
}

/* Header */
.site-header {
    padding: 3rem 0 2rem;
    border-bottom: 1px solid var(--color-border);
    margin-bottom: 3rem;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

.site-title {
    font-size: 1.5rem;
    font-weight: 600;
    letter-spacing: -0.02em;
    margin: 0;
}

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

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

.site-nav {
    display: flex;
    gap: 1.5rem;
    font-family: var(--font-sans);
    font-size: 0.9rem;
}

.nav-link {
    color: var(--color-text-light);
    text-decoration: none;
    transition: color 0.2s ease;
}

.nav-link:hover {
    color: var(--color-accent);
}

/* Main content */
main {
    min-height: calc(100vh - 300px);
    padding-bottom: 4rem;
}

/* Typography */
h1,
h2,
h3,
h4,
h5,
h6 {
    font-family: var(--font-sans);
    font-weight: 600;
    line-height: 1.3;
    letter-spacing: -0.02em;
    margin-top: 2rem;
    margin-bottom: 1rem;
}

h1 {
    font-size: 2.5rem;
}

h2 {
    font-size: 2rem;
}

h3 {
    font-size: 1.5rem;
}

p {
    margin-bottom: 1.5rem;
}

a {
    color: var(--color-accent);
    text-decoration: none;
    transition: opacity 0.2s ease;
}

a:hover {
    opacity: 0.8;
}

/* Home page */
.home-quote {
    margin: 0 0 2.75rem;
    padding: 0.25rem 0 0.25rem 1.75rem;
    border-left: 4px solid var(--color-text);
    color: var(--color-text);
}

.home-quote-text {
    margin-bottom: 0.75rem;
    font-size: clamp(1.3rem, 2.6vw, 1.7rem);
    font-weight: 600;
    letter-spacing: -0.02em;
    line-height: 1.45;
    white-space: pre-line;
}

.home-quote-text-hanging {
    white-space: normal;
}

.home-quote-line {
    display: block;
}

.home-quote-line-hanging {
    padding-left: 1rem;
    text-indent: -1rem;
}

.home-quote-attribution {
    font-family: var(--font-sans);
    font-size: 0.98rem;
    color: var(--color-text-light);
    letter-spacing: 0.01em;
}

.home-quote-work {
    font-style: italic;
}

.home-quote-work-quoted {
    font-style: normal;
}

.page-title + .home-quote {
    margin-top: 2.0rem;
}

.home-content h1 {
    margin-top: 0;
}

.home-content h2 {
    margin-top: 3rem;
}

/* Post list */
.post-list {
    margin-top: 2rem;
}

.post-preview {
    padding: 2rem 0;
    border-bottom: 1px solid var(--color-border);
}

.post-preview:last-child {
    border-bottom: none;
}

.post-title {
    margin-top: 0;
    margin-bottom: 0.5rem;
}

.post-title a {
    color: var(--color-text);
    text-decoration: none;
}

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

.post-subtitle {
    font-family: var(--font-sans);
    color: rgba(44, 62, 80, 0.8);
    line-height: 1.4;
}

.post-header .post-subtitle {
    font-size: 1.3rem;
    margin-top: 0.5rem;
    margin-bottom: 1rem;
}

.post-preview .post-subtitle {
    font-size: 1.0rem;
    margin-top: 0.25rem;
    margin-bottom: 0.5rem;
}

.post-date {
    display: block;
    font-family: var(--font-sans);
    font-size: 0.85rem;
    color: var(--color-text-light);
    margin-bottom: 0.75rem;
}

.post-summary {
    color: var(--color-text-light);
    margin-bottom: 1rem;
}

.post-summary img {
    max-width: 100%;
    height: auto;
    margin: 1rem auto;
    display: block;
}

.continue-link {
    display: inline-block;
    font-family: var(--font-sans);
    font-size: 0.9rem;
    color: var(--color-accent);
    text-decoration: none;
    transition: opacity 0.2s ease;
}

.continue-link:hover {
    opacity: 0.7;
}

/* Single post */
.post {
    max-width: 100%;
}

.post-header {
    margin-bottom: 2rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--color-border);
}

.post-header .post-title {
    margin-top: 0;
}

.post-header .post-date {
    margin-bottom: 0;
}

.post-content {
    font-size: 1.05rem;
    line-height: 1.8;
}

.post-content h1,
.post-content h2,
.post-content h3 {
    margin-top: 2.5rem;
}

.post-content ul,
.post-content ol,
.post-summary ul,
.post-summary ol,
.page-content ul,
.page-content ol {
    margin-bottom: 1.5rem;
    padding-left: 2rem;
}

.post-content li,
.post-summary li,
.page-content li {
    margin-bottom: 0.25rem;
}

.post-content ul ul,
.post-content ol ol,
.post-content ul ol,
.post-content ol ul {
    margin-bottom: 0;
}

.post-content blockquote {
    margin: 2rem 0;
    padding-left: 1.5rem;
    border-left: 3px solid var(--color-border);
    color: var(--color-text-light);
    font-style: italic;
}

.post-content blockquote em,
.post-content blockquote i {
    font-style: normal;
}

.post-content code {
    font-family: 'SF Mono', 'Monaco', 'Consolas', monospace;
    font-size: 0.9em;
    background-color: var(--color-bg-alt);
    padding: 0.2em 0.4em;
    border-radius: 3px;
}

.post-content pre {
    background-color: var(--color-bg-alt);
    padding: 1.5rem;
    border-radius: 5px;
    overflow-x: auto;
    margin: 2rem 0;
}

.post-content pre code {
    background-color: transparent;
    padding: 0;
}

.post-content img {
    max-width: 100%;
    height: auto;
    margin: 2rem auto;
    display: block;
}

.post-content hr {
    border: none;
    margin: 1.5rem 0;
    text-align: center;
}

.post-content hr::after {
    content: "***";
    display: inline-block;
    font-size: 0.75rem;
    letter-spacing: 1em;
    padding-left: 1em;
    color: var(--color-text-light);
}

.post-footer {
    margin-top: 3rem;
    padding-top: 2rem;
    border-top: 1px solid var(--color-border);
}

.back-link {
    font-family: var(--font-sans);
    font-size: 0.9rem;
    color: var(--color-text-light);
}

.back-link:hover {
    color: var(--color-accent);
}

/* Footnotes */
.footnotes {
    margin-top: 3rem;
    padding-top: 2rem;
    border-top: none;
    font-size: 0.9rem;
}

.footnotes hr {
    display: none;
}

.footnotes ol {
    padding-left: 1.5rem;
}

.footnotes li {
    margin-bottom: 0.5rem;
}

/* Footer */
.site-footer {
    margin-top: 4rem;
    padding: 2rem 0;
    border-top: 1px solid var(--color-border);
    font-family: var(--font-sans);
    font-size: 0.85rem;
    color: var(--color-text-light);
    text-align: center;
}

.social-links {
    display: flex;
    justify-content: center;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

.social-links a {
    color: var(--color-text-light);
    transition: color 0.2s ease;
    display: flex;
    align-items: center;
}

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



/* Responsive */
@media (max-width: 768px) {
    html {
        font-size: 16px;
    }

    .container {
        padding: 0 1.5rem;
    }

    .site-header {
        padding: 2rem 0 1.5rem;
    }

    .header-content {
        flex-direction: column;
        align-items: flex-start;
    }

    h1 {
        font-size: 2rem;
    }

    h2 {
        font-size: 1.5rem;
    }

    .post-content {
        font-size: 1rem;
    }
}

/* Image Captions */
.post-content figure,
.post-summary figure {
    margin: 2rem auto;
    display: block;
    text-align: center;
}

.post-content figure img,
.post-summary figure img {
    margin: 0 auto 0.5rem auto;
}

.post-content figcaption,
.post-summary figcaption {
    font-size: 0.9rem;
    color: var(--color-text-light);
    font-family: var(--font-sans);
    line-height: 1.4;
}

/* Drop Cap */
.drop-cap {
    float: left;
    font-size: 3.5rem;
    line-height: 0.8;
    margin-right: 0.5rem;
    margin-top: 0.5rem;
    font-family: var(--font-serif);
    font-weight: bold;
    color: var(--color-text);
}

/* Wide Layout for Data Visualizations */
.wide-content {
    margin-top: 2rem;
    margin-bottom: 2rem;
}

/* Only apply wide layout on single post pages, not in previews */


@media (max-width: 799px) {
    .post .wide-content {
        margin-left: -2rem;
        margin-right: -2rem;
        padding-left: 2rem;
        padding-right: 2rem;
    }
}

@media (max-width: 768px) {
    .post .wide-content {
        margin-left: -1.5rem;
        margin-right: -1.5rem;
        padding-left: 1.5rem;
        padding-right: 1.5rem;
    }
}

/* Expand to full width on larger screens (single post only) */
@media (min-width: 800px) {
    .post .wide-content {
        width: 100vw;
        position: relative;
        left: 50%;
        right: 50%;
        margin-left: -50vw;
        margin-right: -50vw;
        padding-left: 2rem;
        padding-right: 2rem;
    }
}

/* Center and limit on very large screens */
@media (min-width: 1440px) {
    .post .wide-content {
        width: 1400px;
        left: 50%;
        margin-left: -700px;
        padding-left: 0;
        padding-right: 0;
    }
}

/* Two-column grid for chart + leaderboard */
.viz-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 2rem;
    margin: 2rem auto;
}

@media (min-width: 900px) {
    .viz-grid {
        grid-template-columns: 2fr 1fr;
        align-items: center;
    }
}

.viz-main {
    min-width: 0;
}

.viz-sidebar {
    min-width: 0;
}

.viz-single {
    margin: 2rem 0;
    display: flex;
    justify-content: center;
    align-items: flex-start;
}

/* Footnote Tooltips */
.footnote-tooltip {
    position: absolute;
    background: #2c3e50;
    color: #fff;
    padding: 0.75rem 1rem;
    border-radius: 4px;
    font-size: 0.85rem;
    max-width: 320px;
    z-index: 1000;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    opacity: 0;
    transition: opacity 0.2s ease;
    pointer-events: none;
    line-height: 1.5;
    font-family: var(--font-serif);
}

.footnote-tooltip.visible {
    opacity: 1;
}

.footnote-tooltip p {
    margin-bottom: 0;
}

.footnote-tooltip a {
    color: #3498db;
    text-decoration: underline;
}

/* Gallery Grid */
.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 1.5rem;
    margin: 2rem 0;
}

.gallery-item {
    border-radius: 4px;
    overflow: hidden;
    transition: transform 0.2s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
}

.gallery-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.gallery-item img {
    width: 100%;
    height: auto;
    display: block;
    margin: 0;
    /* Override default post image margin */
}

.gallery-item a {
    display: block;
    border-bottom: none;
    /* Remove default link underline if any */
}

.gallery-caption {
    font-family: var(--font-sans);
    font-size: 0.75rem;
    color: var(--color-text-light);
    padding: 0.5rem;
    background-color: #f8f9fa;
    border-top: 1px solid #e1e8ed;
    flex-grow: 1;
}

/* Lightbox */
.lightbox {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: #000000;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    touch-action: pan-y;
}

.lightbox.visible {
    opacity: 1;
    pointer-events: auto;
}

.lightbox-content {
    position: relative;
    max-width: 90%;
    max-height: 90vh;
    text-align: center;
}

.lightbox-viewport {
    width: min(90vw, 1100px);
    height: min(85vh, 900px);
    overflow-x: auto;
    overflow-y: hidden;
    scroll-snap-type: x mandatory;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.lightbox-viewport::-webkit-scrollbar {
    display: none;
}

.lightbox-track {
    display: flex;
    height: 100%;
}

.lightbox-slide {
    flex: 0 0 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 0.5rem;
    scroll-snap-align: center;
}

.lightbox-slide img {
    max-width: 100%;
    max-height: 85vh;
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: 4px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
}

#lightbox-caption {
    color: #fff;
    margin-top: 1rem;
    font-family: var(--font-sans);
    font-size: 0.9rem;
}

.lightbox-close {
    position: absolute;
    top: 20px;
    right: 30px;
    color: #fff;
    font-size: 40px;
    font-weight: bold;
    cursor: pointer;
    line-height: 1;
    transition: color 0.2s ease;
}

.lightbox-close:hover {
    color: var(--color-accent);
}

.lightbox-prev,
.lightbox-next {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.7);
    font-size: 3rem;
    cursor: pointer;
    padding: 0 1rem;
    z-index: 10001;
    transition: color 0.2s ease;
    user-select: none;
}

.lightbox-prev:hover,
.lightbox-next:hover {
    color: #fff;
}

.lightbox-prev {
    left: 10px;
}

.lightbox-next {
    right: 10px;
}

@media (max-width: 768px) {

    .lightbox-prev,
    .lightbox-next {
        font-size: 2rem;
        padding: 0 0.5rem;
        display: none;
    }
}
