/* 
   Scientific Stylesheet - Dark Mode (High Contrast)
   Project: The Finite Loom
   Version: 4.1 (Dark Mode & Wide LaTeX Support)
*/

/* 1. GLOBAL RESET AND LAYOUT */
* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    width: 100%;
    overflow-x: hidden; 
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

body {
    font-family: 'Times New Roman', Times, serif;
    line-height: 1.7;
    background-color: #000000; /* Pure Black Background */
    color: #eeeeee;           /* Off-White Text for better readability */
    max-width: 1024px;
    margin: 0 auto;
    padding-bottom: 50px;
}

/* 2. TEXT INDENTATION & MARGINS */
h1 { 
    font-family: 'Helvetica', Arial, sans-serif; 
    color: #ffffff; 
    text-align: center; 
    font-size: 2.2em; 
    border-bottom: 2px solid #4466aa; 
    padding: 0.5em 0; 
    margin: 1em 20px; 
}

h2, h3, ul, ol, hr { 
    margin-left: 20px; 
    margin-right: 20px; 
    font-family: 'Helvetica', Arial, sans-serif; 
}

h2 { 
    color: #7799ff; /* Light Blue Headings */
    border-bottom: 1px solid #334466; 
    padding-top: 1em; 
}

h3 { 
    font-style: italic; 
    color: #cccccc;
    border: none; 
}

p, blockquote {
    margin-left: 35px;
    margin-right: 20px;
    margin-top: 1.2em;
    margin-bottom: 1.2em;
}

/* 3. TABLE STYLING (CENTERED) */
table {
    margin-left: auto;
    margin-right: auto;
    margin-top: 2em;
    margin-bottom: 2em;
    border-collapse: collapse;
    width: auto;
    max-width: 95%;
    background: #0a0a0a; 
    border: 1px solid #334466;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5);
}

th, td {
    padding: 12px 20px;
    border: 1px solid #223355;
    text-align: left;
}

th {
    background: #1a1a1a;
    color: #00d4ff; /* Cyan accent for headers */
    font-family: 'Helvetica', Arial, sans-serif;
    text-transform: uppercase;
    font-size: 0.9em;
    letter-spacing: 1px;
}

/* 4. EDGE-TO-EDGE IMAGES */
img { 
    width: 100% !important; 
    max-width: 100% !important; 
    display: block !important; 
    margin: 2em 0 !important; 
    filter: brightness(0.9); /* Slightly dims images for dark mode comfort */
}

/* 5. MATHJAX CORE LOGIC: THE PC-CHROME & MOBILE RESOLUTION */

mjx-container {
    display: inline-block !important; 
    width: auto !important;           
    margin: 0 !important;
    padding: 0 !important;
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    vertical-align: middle;
}

/* INLINE LaTeX ($) */
mjx-container:not([display="true"]) {
    white-space: nowrap;
}

mjx-container:not([display="true"]) mjx-math {
    color: #00d4ff !important; /* Cyan for inline math visibility */
    font-weight: bold;
}

/* BLOCK LaTeX ($$) */
mjx-container[display="true"] {
    display: flex !important;         
    flex-direction: column;
    align-items: flex-start;          /* Ensures formula starts at left for scrolling */
    
    margin: 2.5em 0 !important; 
    padding: 25px !important;
    background: #0f0f0f !important;   /* Slightly lighter than body for depth */
    
    /* Border Styling */
    border-left: 5px solid #7799ff !important; 
    border-top: 1px solid #223355 !important;
    border-right: 1px solid #223355 !important;
    border-bottom: 1px solid #223355 !important;

    /* WIDTH FIXES - Crucial for phone display */
    max-width: 100% !important; 
    width: 100% !important;           
    box-sizing: border-box !important;
    
    border-radius: 4px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.8);

    /* SCROLL FIXES */
    overflow-x: auto !important; 
    overflow-y: hidden;
}

/* Force math text to be white in block mode */
mjx-container[display="true"] mjx-math {
    color: #ffffff !important;
}

/* Ensure the internal MathJax element doesn't get squashed */
mjx-container[display="true"] > mjx-math {
    width: auto !important;
    min-width: min-content;
}

/* 6. LINKS & DESKTOP */
a { 
    color: #88ccff; 
    text-decoration: none; 
}

a:visited { 
    color: #aa88ff; /* Muted purple for visited links */
}

a:hover {
    text-decoration: underline;
    color: #00d4ff;
}

/* Desktop container shadow adjustment */
@media screen and (min-width: 1025px) {
    body { 
        width: 1024px; 
        box-shadow: 0 0 100px rgba(0,212,255,0.05); /* Very faint cyan glow */
    }
}