/* Enhanced Deckset Slide Styles */

/* Base typography and font scaling for presentation slides */
html {
    font-size: 18px; /* Larger base font size for presentations */
}

/* Typography hierarchy for presentation slides */
.slide-content h1 {
    font-size: 3.5rem; /* 63px at 18px base */
    font-weight: 700;
    line-height: 1.1;
    margin: 0 0 1.5rem 0;
    color: #1f2937;
}

.slide-content h2 {
    font-size: 2.75rem; /* 49.5px at 18px base */
    font-weight: 600;
    line-height: 1.2;
    margin: 0 0 1.25rem 0;
    color: #374151;
}

.slide-content h3 {
    font-size: 2.125rem; /* 38.25px at 18px base */
    font-weight: 600;
    line-height: 1.3;
    margin: 0 0 1rem 0;
    color: #4b5563;
}

.slide-content h4 {
    font-size: 1.625rem; /* 29.25px at 18px base */
    font-weight: 500;
    line-height: 1.4;
    margin: 0 0 0.75rem 0;
    color: #6b7280;
}

.slide-content h5 {
    font-size: 1.25rem; /* 22.5px at 18px base */
    font-weight: 500;
    line-height: 1.4;
    margin: 0 0 0.5rem 0;
    color: #6b7280;
}

.slide-content h6 {
    font-size: 1.125rem; /* 20.25px at 18px base */
    font-weight: 500;
    line-height: 1.4;
    margin: 0 0 0.5rem 0;
    color: #6b7280;
}

/* Enhanced paragraph and text styling */
.slide-content p {
    font-size: 1.25rem; /* 22.5px at 18px base - much larger than default */
    line-height: 1.6;
    margin: 0 0 1.25rem 0;
    color: #374151;
}

.slide-content li {
    font-size: 1.25rem; /* 22.5px at 18px base */
    line-height: 1.6;
    margin-bottom: 0.5rem;
    color: #374151;
}

.slide-content ul, .slide-content ol {
    margin: 0 0 1.25rem 0;
    padding-left: 2rem;
}

.slide-content blockquote {
    font-size: 1.375rem; /* 24.75px at 18px base */
    line-height: 1.5;
    font-style: italic;
    border-left: 4px solid #3b82f6;
    padding-left: 1.5rem;
    margin: 1.5rem 0;
    color: #4b5563;
}

.slide-content code {
    font-size: 1.125rem; /* 20.25px at 18px base */
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    background: #f3f4f6;
    padding: 0.125rem 0.375rem;
    border-radius: 0.25rem;
    color: #dc2626;
}

/* Base slide styles */
.presentation-container {
    max-width: 100%;
    margin: 0 auto;
    background: #f8fafc;
    min-height: 100vh;
}

.slides-container {
    max-width: 100%;
    margin: 0 auto;
    padding: 2rem;
}

.slide {
    background: white;
    border-radius: 0.5rem;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    margin-bottom: 2rem;
    overflow: hidden;
    position: relative;
    display: none; /* Hidden by default, JavaScript will show the active slide */
    /* Enforce strict 16:9 aspect ratio */
    aspect-ratio: 16 / 9;
}

.slide.active {
    display: block;
}

/* For presentations that don't use JavaScript navigation, show all slides */
.presentation-container:not(.js-enabled) .slide {
    display: block;
}

/* Slide content layout */
.slide-content {
    padding: 2rem;
    min-height: 0; /* Height is governed by the 16:9 container */
    height: 100%;
    position: relative;
    z-index: 2;
    box-sizing: border-box;
}

.slide-content.single-column {
    display: block;
}

.slide-content.columns {
    display: flex;
    gap: 2rem;
}

/* Column layouts */
.columns-container {
    display: flex;
    gap: 2rem;
    width: 100%;
}

.column {
    flex: 1;
    min-width: 0;
}

.column:first-child {
    border-right: 1px solid #e5e7eb;
    padding-right: 2rem;
}

/* Background images */
.background-image {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
}

.background-image.left {
    width: 50%;
}

.background-image.right {
    left: 50%;
    width: 50%;
}

.background-image.filtered {
    filter: blur(2px) brightness(0.7);
}

/* Automatic readability overlay for text over background images */
.slide.has-readability-filter::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 2; /* above background, below content */
    /* Baseline overlay; JS may adapt the opacity via CSS variable */
    background: linear-gradient(
        to bottom,
        rgba(0, 0, 0, var(--overlay-opacity, 0.35)) 0%,
        rgba(0, 0, 0, var(--overlay-opacity, 0.35)) 100%
    );
    pointer-events: none;
}

/* Optional blur applied to background via CSS variable; guarded by support */
.slide.has-readability-filter .background-image {
    filter: blur(var(--bg-blur, 0px)) brightness(0.9);
}

/* Minimal backplate for text when overlay cannot reach required contrast */
.slide .text-backplate {
    background: rgba(0, 0, 0, var(--backplate-opacity, 0.35));
    color: #fff !important;
    padding: 0.1em 0.3em;
    border-radius: 0.2em;
}

/* Inline images */
.inline-image {
    max-width: 100%;
    height: auto;
    border-radius: 0.25rem;
    margin: 1rem 0;
    /* Prevent tall images from overflowing the slide content area */
    max-height: calc(100% - 4rem);
    object-fit: contain;
}

/* Inline-in-text images: keep within line box and align baseline */
.inline-image.inline-text {
    display: inline;
    max-height: 1em;
    width: auto;
    vertical-align: text-bottom;
    margin: 0 0.25em;
}

/* Inline figures (image + caption) */
.inline-figure {
    display: block;
    text-align: center;
    margin: 1rem 0;
}

.inline-figcaption {
    font-size: 0.95rem;
    color: #6b7280;
    margin-top: 0.5rem;
}

/* Constrain figure images slightly more to accommodate caption space */
.inline-figure > img.inline-image {
    max-height: calc(100% - 5rem);
}

.inline-image.fill {
    width: 100%;
    object-fit: cover;
}

/* Generic fit behavior to respect both width and height within content area */
.slide-content img.inline-image {
    max-width: 100%;
    max-height: 100%;
}

/* Inline alignment floats for inline images when requested */
.slide-content img.inline-image[style*="float: left"] {
    /* ensure text wraps appropriately */
}
.slide-content img.inline-image[style*="float: right"] {
    /* ensure text wraps appropriately */
}

/* Image grids */
.image-grid {
    display: grid;
    gap: 1rem;
    margin: 1rem 0;
}

.image-grid.two-columns {
    grid-template-columns: repeat(2, 1fr);
}

.image-grid.three-columns {
    grid-template-columns: repeat(3, 1fr);
}

.image-grid.multi-columns {
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}

.grid-image-container {
    overflow: hidden;
    border-radius: 0.25rem;
}

.grid-image {
    width: 100%;
    height: auto;
    object-fit: cover;
}

/* Video and audio players */
.video-player, .audio-player {
    margin: 1rem 0;
    border-radius: 0.25rem;
    overflow: hidden;
}

.video-player.left, .audio-player.left {
    float: left;
    margin-right: 1rem;
    max-width: 50%;
}

.video-player.right, .audio-player.right {
    float: right;
    margin-left: 1rem;
    max-width: 50%;
}

.video-player iframe,
.video-player video,
.audio-player audio {
    width: 100%;
    border: none;
}

/* Code blocks */
.code-container {
    margin: 1rem 0;
    border-radius: 0.5rem;
    overflow: hidden;
    background: #1f2937;
}

.code-block-with-highlighting {
    position: relative;
}

.code-line {
    display: block;
    padding: 0.125rem 0;
    border-radius: 0.125rem;
}

.code-line-highlighted {
    background-color: rgba(59, 130, 246, 0.3);
    border-left: 3px solid #3b82f6;
    padding-left: 0.5rem;
}

.line-number {
    color: #6b7280;
    margin-right: 1rem;
    user-select: none;
}

/* Math formulas */
.math-display {
    text-align: center;
    margin: 1.5rem 0;
    overflow-x: auto;
    overflow-y: hidden;
    max-width: 100%;
}

.math-inline {
    display: inline;
    max-width: 100%;
}

/* MathJax responsive containers */
.MathJax[display="true"] {
    max-width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    margin: 0.5em 0;
}

.MathJax[display="false"] {
    max-width: 100%;
    overflow-x: auto;
    display: inline-block;
    vertical-align: middle;
}

/* Error styling for math formulas */
.MathJax .merror {
    background-color: #ffebee !important;
    color: #c62828 !important;
    border: 1px solid #f44336 !important;
    border-radius: 3px !important;
    padding: 1px 3px !important;
    font-size: 0.9em !important;
}

/* Footnotes */
.footnotes {
    border-top: 1px solid #e5e7eb;
    margin-top: 2rem;
    padding-top: 1rem;
    position: relative;
    z-index: 3;
}

.footnotes-separator {
    width: 100%;
    height: 1px;
    background: #e5e7eb;
    margin-bottom: 1rem;
}

.footnote-item {
    display: flex;
    margin-bottom: 0.5rem;
    font-size: 0.875rem;
}

.footnote-marker {
    font-weight: 600;
    margin-right: 0.5rem;
    color: #3b82f6;
}

.footnote-content {
    flex: 1;
}

/* Slide footer */
.slide-footer {
    background: #f9fafb;
    border-top: 1px solid #e5e7eb;
    padding: 1rem 2rem;
    font-size: 0.875rem;
    color: #6b7280;
    position: relative;
    z-index: 3;
}

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

/* Slide numbers */
.slide-number {
    position: absolute;
    bottom: 1rem;
    right: 2rem;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 0.25rem 0.5rem;
    border-radius: 0.25rem;
    font-size: 0.75rem;
    font-weight: 500;
    z-index: 3;
}

.slide-number-current {
    font-weight: 600;
}

.slide-number-separator {
    margin: 0 0.25rem;
    opacity: 0.7;
}

.slide-number-total {
    opacity: 0.8;
}

/* Speaker notes (hidden by default) */
.speaker-notes {
    background: #fef3c7;
    border: 1px solid #f59e0b;
    border-radius: 0.5rem;
    padding: 1rem;
    margin-top: 1rem;
    font-size: 0.875rem;
}

/* Navigation */
.navigation {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%);
    background: white;
    border-radius: 2rem;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1);
    padding: 0.5rem;
    display: flex;
    gap: 0.5rem;
    align-items: center;
    z-index: 50;
}

.nav-button {
    background: #3b82f6;
    color: white;
    border: none;
    border-radius: 1.5rem;
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.2s;
}

.nav-button:hover {
    background: #2563eb;
}

.nav-button:disabled {
    background: #9ca3af;
    cursor: not-allowed;
}

#slide-counter {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: #374151;
}

/* Autoscale content */
.autoscale-content {
    transform-origin: top left;
    transition: transform 0.3s ease;
}

/* Fit text styling */
.fit {
    font-weight: 700;
    line-height: 1.1;
    text-align: center;
    display: block;
    margin: 1rem 0;
    /* Larger initial responsive font size to match presentation scale */
    font-size: clamp(3rem, 15vw, 12rem);
    /* Allow text to scale up much larger than before */
    max-width: 100%;
    /* Prevent text from overflowing horizontally */
    overflow: hidden;
    /* Allow word breaking for very long words */
    word-break: break-word;
    /* Ensure text fits within container */
    box-sizing: border-box;
    /* Smooth transitions when JavaScript adjusts the size */
    transition: font-size 0.2s ease-out;
    /* Override normal header colors for fit text */
    color: #1f2937 !important;
}

/* Responsive design */
@media (max-width: 768px) {
    /* Adjust base font size for tablets */
    html {
        font-size: 16px;
    }
    
    /* Scale down typography for tablets */
    .slide-content h1 {
        font-size: 2.75rem; /* 44px at 16px base */
    }
    
    .slide-content h2 {
        font-size: 2.25rem; /* 36px at 16px base */
    }
    
    .slide-content h3 {
        font-size: 1.875rem; /* 30px at 16px base */
    }
    
    .slide-content h4 {
        font-size: 1.5rem; /* 24px at 16px base */
    }
    
    .slide-content h5 {
        font-size: 1.25rem; /* 20px at 16px base */
    }
    
    .slide-content h6 {
        font-size: 1.125rem; /* 18px at 16px base */
    }
    
    .slide-content p,
    .slide-content li {
        font-size: 1.125rem; /* 18px at 16px base */
    }
    
    .slide-content blockquote {
        font-size: 1.25rem; /* 20px at 16px base */
    }
    
    .slides-container {
        padding: 1rem;
    }
    
    .slide-content {
        padding: 1rem;
        min-height: 0;
        height: 100%;
        box-sizing: border-box;
    }
    
    .slide-content.columns {
        flex-direction: column;
        gap: 1rem;
    }
    
    .column:first-child {
        border-right: none;
        border-bottom: 1px solid #e5e7eb;
        padding-right: 0;
        padding-bottom: 1rem;
    }
    
    .image-grid.two-columns,
    .image-grid.three-columns {
        grid-template-columns: 1fr;
    }
    
    .video-player.left,
    .video-player.right,
    .audio-player.left,
    .audio-player.right {
        float: none;
        margin: 1rem 0;
        max-width: 100%;
    }
    
    .navigation {
        bottom: 1rem;
        left: 1rem;
        right: 1rem;
        transform: none;
        justify-content: space-between;
    }
    
    .MathJax[display="true"] {
        font-size: 0.9em;
        margin: 0.3em 0;
    }
    
    .MathJax[display="false"] {
        font-size: 0.85em;
    }
}

@media (max-width: 480px) {
    /* Adjust base font size for mobile */
    html {
        font-size: 14px;
    }
    
    /* Scale down typography for mobile */
    .slide-content h1 {
        font-size: 2.25rem; /* 31.5px at 14px base */
    }
    
    .slide-content h2 {
        font-size: 1.875rem; /* 26.25px at 14px base */
    }
    
    .slide-content h3 {
        font-size: 1.5rem; /* 21px at 14px base */
    }
    
    .slide-content h4 {
        font-size: 1.25rem; /* 17.5px at 14px base */
    }
    
    .slide-content h5,
    .slide-content h6 {
        font-size: 1.125rem; /* 15.75px at 14px base */
    }
    
    .slide-content p,
    .slide-content li {
        font-size: 1rem; /* 14px at 14px base */
        line-height: 1.5;
    }
    
    .slide-content blockquote {
        font-size: 1.125rem; /* 15.75px at 14px base */
    }
    
    .slide-content code {
        font-size: 0.875rem; /* 12.25px at 14px base */
    }
    
    .slide-content {
        padding: 0.75rem;
        min-height: 0;
        height: 100%;
        box-sizing: border-box;
    }
    
    .nav-button {
        padding: 0.375rem 0.75rem;
        font-size: 0.75rem;
    }
    
    #slide-counter {
        padding: 0.375rem 0.75rem;
        font-size: 0.75rem;
    }
    
    .MathJax[display="true"] {
        font-size: 0.8em;
    }
    
    .MathJax[display="false"] {
        font-size: 0.8em;
    }
}

/* Print styles */
@media print {
    /* Render pages at a 16:9 size with minimal margins */
    @page {
        size: 1280px 720px;
        margin: 0.5cm;
    }
    .navigation {
        display: none;
    }
    
    .slide {
        break-inside: avoid;
        page-break-inside: avoid;
        margin-bottom: 1rem;
        aspect-ratio: 16 / 9;
    }
    
    .speaker-notes {
        display: block !important;
    }
    
    .MathJax[display="true"] {
        break-inside: avoid;
        page-break-inside: avoid;
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    .presentation-container {
        background: #111827;
    }
    
    .slide {
        background: #1f2937;
        color: #f9fafb;
    }
    
    .slide-footer {
        background: #374151;
        border-top-color: #4b5563;
        color: #d1d5db;
    }
    
    .footnotes {
        border-top-color: #4b5563;
    }
    
    .footnotes-separator {
        background: #4b5563;
    }
    
    .column:first-child {
        border-right-color: #4b5563;
    }
}

/* Animation and transitions */
.slide {
    animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Focus and accessibility */
.nav-button:focus {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
}

.presentation-link:focus {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
    border-radius: 0.5rem;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .slide {
        border: 2px solid #000;
    }
    
    .nav-button {
        border: 2px solid #000;
    }
}