/* HUMAN-FRIENDLY DOOMER THEME */

body {
    /* Change from Pitch Black to Deep Charcoal (reduces eye strain) */
    background-color: #121212; 
    
    /* Change from White to Silver/Light Grey */
    color: #c0c0c0; 
    
    /* Better font stack: Menlo/Consolas are thicker and easier to read than Courier */
    font-family: 'Menlo', 'Consolas', 'Monaco', 'Courier New', monospace; 
    
    /* Increase spacing to let the text breathe */
    line-height: 1.8; 
    font-size: 1.125rem; /* 18px - Slightly larger text */
    
    margin: 0;
    padding: 0;
    -webkit-font-smoothing: antialiased; /* Makes text crisper */
}

/* SIDEBAR NAVIGATION */
.sidebar {
    position: fixed;
    left: 0;
    top: 0;
    height: 100vh;
    width: 200px;
    background-color: #0f0f0f; /* Slightly darker than body */
    display: flex;
    flex-direction: column;
    justify-content: flex-start; /* Start from top */
    align-items: stretch;
    z-index: 1000;
    transition: transform 0.3s ease;
    padding-top: 20px;
}

/* Sidebar profile image */
.sidebar-logo {
    display: flex;
    justify-content: center;
    padding: 20px;
    margin-bottom: 20px;
}

.sidebar-profile-image {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    object-fit: cover;
    object-position: center;
    border: 2px solid #333;
    cursor: pointer;
    transition: transform 0.2s ease, border-color 0.2s ease;
}

.sidebar-profile-image:hover {
    transform: scale(1.05);
    border-color: #ff5555;
}

/* Profile Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.85);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal-content {
    background-color: #1a1a1a;
    border: 1px solid #333;
    border-radius: 12px;
    padding: 0;
    max-width: 450px;
    width: 90%;
    text-align: center;
    position: relative;
    transform: scale(0.9);
    transition: transform 0.3s ease;
    overflow: hidden;
}

.modal-overlay.active .modal-content {
    transform: scale(1);
}

.modal-close {
    position: absolute;
    top: 10px;
    right: 15px;
    background: none;
    border: none;
    color: #666;
    font-size: 1.75rem;
    cursor: pointer;
    transition: color 0.2s ease;
    line-height: 1;
}

.modal-close:hover {
    color: #ff5555;
}

.modal-profile-section {
    margin: 0;
}

.modal-profile-image {
    width: 100%;
    height: 220px;
    object-fit: cover;
    object-position: center top;
    display: block;
}

.modal-caption {
    color: #c0c0c0;
    font-size: 0.875rem;
    margin: 15px 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid #333;
    text-align: center;
}

.modal-secondary-section {
    padding: 15px 20px 25px 20px;
}

.modal-secondary-image {
    max-width: 100%;
    height: 280px;
    object-fit: contain;
}

.sidebar-toggle {
    display: none; /* Hidden on desktop */
    position: fixed;
    top: 15px;
    left: 15px;
    width: 40px;
    height: 40px;
    background-color: #0f0f0f;
    border: 1px solid #333;
    color: #c0c0c0;
    cursor: pointer;
    z-index: 1001;
    font-size: 1.25rem;
    padding: 0;
    line-height: 1;
    transition: all 0.2s ease;
}

.sidebar-toggle:hover {
    background-color: #1a1a1a;
    border-color: #ff5555;
}

.sidebar-toggle::before {
    content: '☰';
    display: block;
}

.nav-button {
    background-color: transparent;
    border: none;
    border-left: 2px solid transparent;
    color: #c0c0c0;
    font-family: 'Menlo', 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 1rem;
    padding: 15px 20px;
    text-align: left;
    cursor: pointer;
    transition: all 0.2s ease;
    width: 100%;
    margin: 0;
}

.nav-button:hover {
    background-color: #1a1a1a;
    color: #ffffff;
}

.nav-button.active {
    border-left-color: #ff5555;
    background-color: rgba(255, 85, 85, 0.1);
    color: #ffffff;
}

.container {
    /* Take full width minus sidebar, then center content inside */
    margin-left: 200px;
    padding: 40px;
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
}

/* Copy Markdown Button */
.copy-markdown-btn {
    position: absolute;
    top: 0;
    right: 0;
    display: flex;
    align-items: center;
    gap: 6px;
    background: none;
    border: none;
    color: #555;
    font-family: inherit;
    font-size: 0.6875rem;
    padding: 4px 8px;
    cursor: pointer;
    transition: color 0.2s ease;
    width: auto;
    max-width: none;
}

.copy-markdown-btn:hover {
    color: #c0c0c0;
}

.copy-markdown-btn.copied {
    color: #4a9;
}

.copy-markdown-btn svg {
    flex-shrink: 0;
}

/* Content wrapper for positioning */
.content-wrapper {
    position: relative;
    max-width: 700px;
    width: 100%;
    text-align: left;
}

/* All direct children get max-width for centered column look (except copy button) */
.container > *:not(.copy-markdown-btn):not(.content-wrapper):not(.genz-layout) {
    max-width: 700px;
    width: 100%;
    text-align: left; /* Text left-aligned within centered container */
}

/* HEADERS */
h1, h2, h3, h4 {
    color: #ffffff; /* Headers stay bright white for contrast */
    border-bottom: 1px solid #333;
    padding-bottom: 15px;
    margin-top: 40px;
    margin-bottom: 20px;
    letter-spacing: -0.5px;
    text-align: left;
}

h1 {
    font-size: 1.5rem;
    text-align: left;
}

/* EMPHASIS (Bold text) */
strong {
    color: #ffffff; /* Make bold text pop in white */
    font-weight: 700;
}

/* LISTS (The Axioms) */
ul {
    padding-left: 1.5em;
    list-style-type: disc;
    list-style-position: outside;
    text-align: left;
}

li {
    margin-bottom: 15px;
    text-align: left;
}

/* THE MATH (LaTeX) - Inline math stays inline */
mjx-container {
    font-size: 115% !important;
    opacity: 0.9;
}

/* Display math ($$...$$) gets block treatment */
mjx-container[display="true"] {
    display: block;
    padding: 15px 0;
    text-align: center;
}

/* ANALOGY BLOCKS (Italic parts) */
em {
    color: #999; /* Dim the analogies slightly to separate them from logic */
    display: block; /* Give them their own line if possible, or just style inline */
    margin-top: 5px;
}

/* LINKS */
a {
    color: #ff5555; /* Softer Red */
    text-decoration: none;
    border-bottom: 1px dotted #ff5555;
    transition: all 0.2s ease;
}

a:hover {
    background-color: #ff5555;
    color: #121212;
}

/* Paragraphs and text content */
p {
    text-align: left;
}

/* Images in content */
.container img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    margin: 20px 0;
    display: block;
}

/* Page-specific font sizes */
.page-theorem {
    font-size: 1rem;
}

.page-theorem mjx-container {
    font-size: 125% !important; /* Keep equations same visual size */
}

.page-thoughts,
.page-analogies {
    font-size: 1.0625rem;
}

.page-genz {
    font-size: 0.9375rem;
}

.page-thoughts h1,
.page-analogies h1 {
    font-size: 1.5rem;
}

.page-thoughts h2,
.page-analogies h2 {
    font-size: 1.6rem;
}

/* Sources page - tighter spacing */
.page-sources {
    font-size: 0.8125rem;
    line-height: 1.5;
}

.page-sources h1 {
    font-size: 1.5rem;
    margin-bottom: 15px;
}

.page-sources h2 {
    font-size: 1.3rem;
    margin-top: 25px;
    margin-bottom: 10px;
}

.page-sources h3 {
    font-size: 1rem;
    margin-top: 18px;
    margin-bottom: 8px;
    padding-bottom: 8px;
}

.page-sources p {
    margin-bottom: 8px;
}

/* LOADING SCREEN */
.loading {
    text-align: center;
    padding-top: 30vh;
    font-size: 1.2rem;
    color: #666;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { opacity: 0.5; }
    50% { opacity: 1; }
    100% { opacity: 0.5; }
}

/* RESPONSIVE MOBILE */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        padding-top: 20px;
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .sidebar-toggle {
        display: block;
    }

    .container {
        margin-left: 0;
        padding: 80px 20px 20px 20px;
    }

    .copy-markdown-btn span {
        display: none;
    }

    .sidebar-logo {
        padding: 15px;
        margin-bottom: 15px;
    }

    .sidebar-profile-image {
        width: 70px;
        height: 70px;
    }

    .modal-content {
        max-width: 340px;
    }

    .modal-profile-image {
        height: 180px;
    }

    .modal-secondary-image {
        height: 220px;
    }

    body {
        font-size: 1rem;
    }
}

@media (max-width: 600px) {
    .container {
        padding: 80px 15px 20px 15px;
    }
}

/* RESPONSIVE LARGE SCREENS */
@media (min-width: 1400px) {
    .container {
        padding: 60px;
    }

    .container > * {
        max-width: 800px;
    }
}

/* AI MODEL SELECTOR & SEGMENTED CONTROL */

/* Hide copy button on AI page */
.page-ai .copy-markdown-btn {
    display: none;
}

/* Reduce AI page text size */
.page-ai {
    font-size: 0.875rem;
}

/* Reduce AI page header size and adjust spacing */
.page-ai h1 {
    font-size: 1.5rem;
    margin-top: 10px;
    margin-bottom: 20px;
}

/* AI Model Selector Container */
.ai-model-selector {
    margin: 40px 0;
    padding: 30px;
    background-color: #0f0f0f;
    border: 1px solid #333;
    border-radius: 8px;
}

/* Segmented Control */
.segmented-control {
    display: flex;
    gap: 0;
    background-color: #1a1a1a;
    border: 1px solid #333;
    border-radius: 6px;
    padding: 4px;
    margin-bottom: 30px;
    overflow: hidden;
}

/* Hide radio inputs */
.segmented-control input[type="radio"] {
    display: none;
}

/* Segment labels */
.segmented-control label {
    flex: 1;
    text-align: center;
    padding: 12px 20px;
    font-family: 'Menlo', 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 0.875rem;
    color: #c0c0c0;
    background-color: transparent;
    cursor: pointer;
    transition: all 0.2s ease;
    border-radius: 4px;
    user-select: none;
}

/* Hover state */
.segmented-control label:hover {
    color: #ffffff;
    background-color: rgba(255, 85, 85, 0.1);
}

/* Active (selected) state */
.segmented-control input[type="radio"]:checked + label {
    background-color: #ff5555;
    color: #121212;
    font-weight: 600;
}

/* Image container */
.ai-model-images {
    position: relative;
    width: 100%;
    height: 650px;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Individual images */
.ai-model-image {
    position: absolute;
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    border-radius: 8px;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

/* Active image */
.ai-model-image.active {
    opacity: 1;
    visibility: visible;
}

/* Mobile responsive for segmented control */
@media (max-width: 768px) {
    .segmented-control label {
        padding: 10px 12px;
        font-size: 0.75rem;
    }

    .ai-model-images {
        height: 450px;
    }
}

@media (max-width: 480px) {
    .segmented-control {
        flex-direction: column;
    }

    .segmented-control label {
        border-radius: 4px;
    }
}

/* Center the portrait player in the viewport while the article scrolls. */
.page-genz {
    --genz-inset: 2.5rem;
    --genz-video-height: min(33.333rem, 80dvh);
    --genz-video-top: calc((100dvh - var(--genz-video-height)) / 2);
    padding-block: var(--genz-inset);
}

.page-genz > .genz-layout {
    display: grid;
    grid-template-columns: minmax(0, 43.75rem) minmax(0, 18.75rem);
    gap: 4rem;
    max-width: 66.5rem;
    width: 100%;
    align-items: start;
}

.genz-layout .content-wrapper {
    min-width: 0;
}

.genz-gameplay {
    position: sticky;
    top: var(--genz-video-top);
    margin-top: max(0rem, calc(var(--genz-video-top) - var(--genz-inset)));
}

.genz-video {
    display: block;
    width: 100%;
    height: var(--genz-video-height);
    object-fit: contain;
    background: #0f0f0f;
    border: 0.0625rem solid #333;
    border-radius: 0.5rem;
    box-sizing: border-box;
}

@media (min-width: 87.5rem) {
    .page-genz {
        --genz-inset: 3.75rem;
    }
}

@media (max-width: 68.75rem) {
    .page-genz > .genz-layout {
        grid-template-columns: minmax(0, 1fr);
        gap: 2rem;
        max-width: 43.75rem;
    }

    .genz-gameplay {
        position: static;
        margin: 0 auto;
        width: min(100%, 18.75rem);
    }
}

/* Shorts-style split: independently scrolling text above fixed gameplay. */
@media (max-width: 48rem) {
    .page-genz {
        --genz-mobile-video-height: 54dvh;
        height: calc(100dvh - var(--genz-mobile-video-height));
        overflow-y: auto;
        scrollbar-width: none;
        box-sizing: border-box;
        padding-top: 5rem;
        padding-bottom: 2rem;
    }

    .page-genz::-webkit-scrollbar {
        display: none;
    }

    .page-genz .genz-gameplay {
        position: fixed;
        inset: auto 0 0;
        z-index: 900;
        width: 100%;
        margin: 0;
        height: var(--genz-mobile-video-height);
        box-sizing: border-box;
        display: flex;
        justify-content: center;
        align-items: center;
        padding: 0.75rem;
        padding-bottom: max(0.75rem, env(safe-area-inset-bottom));
        background: #0f0f0f;
    }

    .page-genz .genz-video {
        width: 100%;
        height: 100%;
        min-width: 0;
        min-height: 0;
        object-fit: contain;
        border: 0;
        border-radius: 0;
    }
}
