/* CSS Reset for author links */
.authors-section a,
.authors-container a,
.author-name {
    font-weight: normal !important;
    font-weight: 400 !important; /* Explicit normal weight */
}

/* General Body Styles */
body {
    margin: 0;
    font-family: 'Montserrat', sans-serif;
    color: #333;
    line-height: 1.6;
    background-color: #f8f8f8;
}

/* Header Section Styles (Super Light Blue) */
.header-section {
    background: linear-gradient(135deg, #F0F8FF 0%, #E6F3FF 100%);
    color: black;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 20vh;
    padding-bottom: 14px; /* extra spacing below buttons */
}

.header-section > .header-content > .algotune-images {
    padding: 17px 20px 7px 20px;
}

.authors-section {
    /* Inherit the header gradient so the shade of blue matches exactly */
    background: inherit;
    padding: 3px 20px 7px 20px;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
}

/* Desktop: logos are positioned absolutely within authors-section */
.university-logos {
    display: contents; /* On desktop, act as if the container doesn't exist */
}

.header-content {
    max-width: 1200px;
    margin: 0 auto;
}

.algotune-banner {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    margin-bottom: 0;
    margin-top: -30px; /* Pull banner up even more aggressively */
    flex-wrap: wrap;
}

.algotune-mascot {
    max-width: 201.6px;
    height: auto;
    flex-shrink: 0;
    align-self: flex-start;
    margin-top: -10px;
}

.algotune-mascot-inline {
    height: 2.8em;
    width: auto;
    vertical-align: -0.8em;
    margin-right: 0.3em;
    display: inline-block;
    transition: all 0.3s ease;
    margin-top: -35px; /* Very strong negative margin to pull mascot almost to top edge */
}

.algotune-mascot-inline:hover {
    transform: scale(1.2);
}

.algotune-text {
    text-align: center;
    flex: 1;
    min-width: 300px;
}

.algotune-text .algotune-title {
    font-size: 2.975em;
    margin: 0 0 5px 0;
    font-weight: 700;
    color: black;
    text-shadow: none;
}

.algotune-text .algotune-subtitle {
    font-size: 1.3em;
    margin: 0;
    font-weight: 700;
    opacity: 0.9;
    color: black;
    line-height: 1.4;
}

.main-title {
    font-size: 3.5em;
    margin-bottom: 10px;
    font-weight: 700;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
}

.subtitle {
    font-size: 1.3em;
    margin-bottom: 30px;
    font-weight: 500;
    opacity: 0.9;
}

.authors-container {
    display: inline-block; /* Show as single inline block to allow continuous text flow */
    font-size: 0.85em; /* Smaller font size for authors */
    font-weight: normal !important;
    opacity: 1;
    text-align: center;
    line-height: 1.3; /* Slightly looser for readability */
    flex: 1;
    max-width: 1000px; /* Plenty of room on desktop */
}

/* Reset any browser default bold on links */
.authors-container * {
    font-weight: inherit !important;
}

.author-name {
    margin-right: 6px; /* spacing after each name */
    white-space: nowrap; /* Prevent names from being split across lines */
}

/* Make author links more visible */
.authors-container a {
    color: black;
    text-decoration: underline;
    text-decoration-color: rgba(0, 0, 0, 0.6);
    font-weight: normal !important;
}

/* More specific rule to ensure no bold */
.authors-container a.author-name {
    font-weight: normal !important;
}

.authors-container a:hover {
    text-decoration-color: black;
    text-shadow: 0 0 3px rgba(0, 0, 0, 0.3);
}

/* All authors now have normal font-weight, so this rule is no longer needed */

.university-logo {
    /* Standardize logo height */
    height: 50px;
    width: auto;
    flex-shrink: 0;
}

.left-logo {
    margin-right: 20px;
    height: 43px; /* 10% smaller than previous 48px */
}

.right-logo {
    margin-left: 20px;
    height: 45px; /* 5% bigger than previous 43px */
    width: auto;
}

.buttons-container {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 15px;
    margin-top: 7px;
    margin-bottom: 10px;
    text-align: center;
}

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    /* Smaller buttons */
    padding: 8px 18px;
    border: 2px solid black;
    border-radius: 5px;
    background-color: transparent;
    color: black;
    text-decoration: none;
    font-size: 0.9em;
    font-weight: 500;
    transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease;
}

.button:hover {
    background-color: rgba(0, 0, 0, 0.1);
    border-color: rgba(0, 0, 0, 0.8);
    color: black;
}

.button i {
    margin-right: 8px;
}

/* TL;DR Section Styles */
.tldr-section {
    background-color: #f8f9fa;
    padding: 40px 20px;
    border-top: 1px solid #eee;
}

.tldr-content {
    max-width: 900px;
    margin: 0 auto;
    padding: 0 15px;
    text-align: center;
}

.tldr-heading {
    font-size: 2.2rem;
    font-weight: 600;
    color: #2c3e50;
    margin-bottom: 20px;
}

.tldr-text {
    font-size: 1.3rem;
    color: #34495e;
    line-height: 1.6;
    font-weight: 500;
}

/* Overview Section Styles */
.overview-section {
    background-color: #fff;
    padding: 1px 1px;
    border-top: 1px solid #eee;
}

.overview-content {
    max-width: 900px;
    margin: 0 auto;
    padding: 0 15px;
    text-align: left;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}

.overview-heading {
    font-size: 2.5em;
    color: #333;
    margin-bottom: 30px;
    padding-bottom: 15px;
    border-bottom: 1px solid #ddd;
    font-weight: 700;
}

.overview-text {
    font-size: 1.1em;
    color: #555;
    line-height: 1.8;
    margin-bottom: 20px;
}

.algotune-banner {
    max-width: 100%;
    height: auto;
    margin: 30px 0;
}

/* Target only the overview section image */
.overview-section .algotune-banner {
    display: block;
    max-width: 48%;
    margin: 15px auto;
}

/* Tables Section */
.tables-section {
    background-color: #f8f9fa;
    padding: 5px 20px;
}

.tables-content {
    max-width: 900px;
    margin: 0 auto;
    padding: 0 15px;
}

.tables-heading {
    font-size: 2.2em;
    color: #333;
    margin-bottom: 30px;
    margin-top: 10px;
    text-align: center;
    font-weight: 700;
    position: relative;
    display: block;
    width: 100%;
}

/* Clickable heading styles */
.tables-heading a {
    color: inherit;
    text-decoration: none;
    position: relative;
    display: inline-block;
}

.tables-heading a::after {
    content: "🔗";
    opacity: 0;
    margin-left: 0.5em;
    font-size: 0.7em;
    transition: opacity 0.3s ease;
    vertical-align: middle;
}

.tables-heading a:hover::after {
    opacity: 1;
}

.tables-heading a:hover {
    color: #2196F3;
    transition: color 0.3s ease;
}

.table-container {
    width: 100%;
    margin: 0 auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 2rem;
    background: white;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    border-radius: 6px;
    overflow: hidden;
    table-layout: fixed;
}

th, td {
    padding: 0.8rem;
    text-align: left;
    border-bottom: 1px solid #eee;
}

/* Set equal column widths for the task summary table */
#task-summary-table th:first-child,
#task-summary-table td:first-child {
    width: 20%;
    word-wrap: break-word;
    word-break: break-all;
    hyphens: auto;
    -webkit-hyphens: auto;
    -ms-hyphens: auto;
    line-height: 1.3;
    white-space: normal;
    overflow-wrap: break-word;
    max-width: 0;
}

#task-summary-table th:nth-child(2),
#task-summary-table td:nth-child(2),
#task-summary-table th:nth-child(3),
#task-summary-table td:nth-child(3),
#task-summary-table th:nth-child(4),
#task-summary-table td:nth-child(4),
#task-summary-table th:nth-child(5),
#task-summary-table td:nth-child(5) {
    width: 18.75%;
}

th {
    background-color: #e9ecef;
    font-weight: 600;
}

/* Make first column text bold like header row */
td:first-child {
    font-weight: 600;
}



tr:hover {
    background-color: #f8f9fa;
}

.score-badge {
    color: white !important;
    display: inline-block;
    margin-right: 0.5rem;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    font-size: 0.85rem;
    font-weight: normal;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1px solid transparent;
    white-space: normal !important;
    word-break: break-word;
    position: relative;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

/* Make clickable cells more obvious */
td:nth-child(2) a,
td:nth-child(3) a,
td:nth-child(4) a,
td:nth-child(5) a {
    text-decoration: underline;
    color: black;
    display: block;
    width: 100%;
    height: 100%;
    border-radius: 4px;
    transition: all 0.2s ease;
}

td:nth-child(2) a .score-badge,
td:nth-child(3) a .score-badge,
td:nth-child(4) a .score-badge,
td:nth-child(5) a .score-badge {
    color: white !important;
}

/* Hover effects for clickable score badges */
td:nth-child(2) a:hover .score-badge,
td:nth-child(3) a:hover .score-badge,
td:nth-child(4) a:hover .score-badge,
td:nth-child(5) a:hover .score-badge {
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    border: 1px solid rgba(0,0,0,0.1);
}

/* Hover effect for the entire cell */
td:nth-child(2):hover,
td:nth-child(3):hover,
td:nth-child(4):hover,
td:nth-child(5):hover {
    background-color: #f0f8ff !important;
    cursor: pointer;
}

/* Add a subtle pointer cursor to indicate clickability */
td:nth-child(2),
td:nth-child(3),
td:nth-child(4),
td:nth-child(5) {
    cursor: pointer;
    position: relative;
}

/* Add scroll emoji overlaid in top right corner of score badges */
.score-badge:hover {
    transform: translateY(-1px);
    box-shadow: 0 3px 8px rgba(0,0,0,0.2);
    border: 1px solid rgba(0,0,0,0.1);
}



/* Sorting Controls */
.sorting-controls {
    margin: 0 auto 1rem auto;
    width: 80%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sort-buttons-container {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.sort-btn {
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    padding: 0.5rem 1rem;
    margin-right: 0.5rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.2s ease;
}

.sort-btn:hover {
    background: #e9ecef;
}

.sort-btn.active {
    background: #2196F3;
    color: white;
    border-color: #2196F3;
}

/* Task Name Cell Styling */
.task-name-cell {
    cursor: help;
    position: relative;
}

.task-name-cell:hover {
    background-color: #f8f9fa;
}

/* Enhanced tooltip styling with smart positioning */
.tooltip {
    position: fixed;
    background-color: #333;
    color: white;
    padding: 12px 16px;
    border-radius: 6px;
    font-size: 0.9rem;
    white-space: pre-wrap;
    max-width: min(400px, 90vw);
    width: max-content;
    z-index: 10000;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    line-height: 1.5;
    text-align: left;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s ease-out;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.tooltip.show {
    opacity: 1;
}

.tooltip::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 6px solid transparent;
    border-top-color: #333;
}

.tooltip.bottom {
    /* No transform needed for bottom positioning */
}

.tooltip.bottom::after {
    top: -12px;
    border-top-color: transparent;
    border-bottom-color: #333;
}

/* Responsive Adjustments */
@media (max-width: 768px) {
    .algotune-banner {
        flex-direction: column;
        gap: 15px;
    }
    
    .algotune-mascot {
        max-width: 100px;
    }
    
    .algotune-text .algotune-title {
        font-size: 2.125em;
    }
    
    .algotune-text .algotune-subtitle {
        font-size: 1.1em;
    }
    
    .main-title {
        font-size: 2.5em;
    }
    
    .subtitle {
        font-size: 1.1em;
    }
    
    .authors-section {
        flex-direction: column;
        gap: 15px;
        padding: 15px 20px 20px 20px;
    }
    
    .authors-container {
        font-size: 0.8em; /* Keep smaller font size on tablets */
        max-width: 100%; /* Allow full width on tablets */
        order: 1;
    }
    
    /* Show logos below authors on tablets */
    .university-logos {
        display: flex !important;
        justify-content: center;
        align-items: center;
        gap: 25px;
        order: 2;
        width: 100%;
    }
    
    .university-logo {
        height: auto;
        max-height: 70px;
        width: auto;
        object-fit: contain;
    }
    
    .left-logo {
        height: 46.75px;
    }
    
    .right-logo {
        height: 70px;
    }
    
    .button {
        padding: 10px 20px;
        font-size: 0.9em;
    }
    
    .overview-heading {
        font-size: 2em;
    }
    
    .overview-text {
        font-size: 1em;
    }
    
    .table-container {
        width: 90%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    table {
        min-width: auto;
        table-layout: auto;
    }
    
    .sorting-controls {
        width: 90%;
    }
    
    /* Make the banner inside the overview section span full width on tablets/mobile */
    .overview-section .algotune-banner {
        max-width: 100% !important;
        width: 100% !important;   /* ensure width fills container */
    }
}

@media (max-width: 480px) {
    .header-section > .header-content > .algotune-images {
        padding: 60px 15px 20px 15px;
    }
    
    .main-title {
        font-size: 2em;
    }
    
    .subtitle {
        font-size: 1em;
    }
    
    .authors-section {
        flex-direction: column;
        gap: 20px;
        padding: 15px 15px 15px 15px;
    }
    
    .authors-container {
        width: 100%;
        text-align: center;
        font-size: 0.75em; /* Even smaller on mobile */
        max-width: 100%; /* Allow full width on mobile */
        order: 1; /* Ensure authors come first */
    }
    
    /* Removed commas between author names */
    
    /* Create a flex container for logos on mobile */
    .university-logos {
        display: flex !important; /* Override the desktop display: contents */
        justify-content: center;
        align-items: center;
        gap: 30px;
        order: 2; /* Logos come after authors */
        width: 100%;
    }
    
    .university-logo {
        width: auto !important;
        height: auto !important;
        object-fit: contain !important;
        max-height: 40px !important; /* Increased from 55px to make logos more visible on mobile */
        min-height: 35px !important; /* Ensure minimum size for readability */
    }
    
    .left-logo {
        margin-right: 0 !important;
    }
    
    .right-logo {
        margin-left: 0 !important;
    }
    
    .buttons-container {
        flex-direction: column;
        gap: 10px;
    }
    
    .tldr-section {
        padding: 30px 15px;
    }
    
    .tldr-heading {
        font-size: 1.6em;
    }
    
    .tldr-text {
        font-size: 1.1rem;
    }
    
    .overview-section {
        padding: 40px 15px;
    }
    
    .overview-heading {
        font-size: 1.8em;
    }
    
    .table-container {
        width: 100%;
    }
    
    .sorting-controls {
        width: 100%;
    }
    
    /* Mobile table responsiveness */
    .table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        margin: 0 -15px;
        padding: 0 15px;
    }
    
    .tables-section table {
        min-width: 600px;
        font-size: 0.8rem;
    }
    
    .tables-section th,
    .tables-section td {
        padding: 8px 4px;
        white-space: nowrap;
    }
    
    .task-name-cell {
        min-width: 120px;
        max-width: 150px;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    
    /* Mobile sorting controls */
    .sorting-controls {
        display: flex;
        flex-direction: column;
        gap: 0.5rem;
        align-items: flex-start;
    }
    
    .sorting-controls label {
        margin-right: 0 !important;
        margin-bottom: 0;
        font-size: 0.9rem;
    }
    
    .sort-buttons-container {
        display: flex;
        flex-wrap: wrap;
        gap: 0.3rem;
    }
    
    .sort-btn {
        padding: 0.4rem 0.6rem;
        margin-right: 0;
        margin-bottom: 0;
        font-size: 0.8rem;
        flex: 1;
        min-width: fit-content;
        white-space: nowrap;
    }
}

@media (max-width: 380px) {
    .header-section {
        padding: 40px 10px;
    }
    
    .main-title {
        font-size: 1.8em;
    }
    
    .table-container {
        margin: 0 -10px;
        padding: 0 10px;
    }
    
    .tables-section table {
        min-width: 500px;
        font-size: 0.75rem;
    }
    
    .tables-section th,
    .tables-section td {
        padding: 6px 2px;
    }
    
    .task-name-cell {
        min-width: 100px;
        max-width: 120px;
    }
    
    /* Extra small mobile sorting */
    .sort-btn {
        padding: 0.3rem 0.4rem;
        font-size: 0.7rem;
        flex: 1;
        min-width: 0;
        text-align: center;
    }
    
    .sort-buttons-container {
        width: 100%;
        gap: 0.2rem;
    }
    
    .sorting-controls label {
        font-size: 0.85rem;
    }
}

/* Performance Optimizations */
* {
    box-sizing: border-box;
}

/* Smooth scrolling for better UX */
html {
    scroll-behavior: smooth;
}

/* Optimize font loading */
.font-display-swap {
    font-display: swap;
}

/* Improve image loading */
img {
    max-width: 100%;
    height: auto;
}

/* Focus styles for accessibility */
.button:focus,
.sort-btn:focus {
    outline: 2px solid #2196F3;
    outline-offset: 2px;
}

/* Reduce motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    html {
        scroll-behavior: auto;
    }
}

/* -------------------- New: Mobile-Friendly Code Blocks & Tables -------------------- */

/* Gorgeous glass-morphism code blocks (shared with trajectory pages) */
.code-block {
    position: relative;
    margin: 1rem 0;
    border-radius: 12px;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.12);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08), 0 2px 6px rgba(0, 0, 0, 0.04);
}

.code-block-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    background: rgba(0, 0, 0, 0.04);
    border-bottom: 1px solid rgba(255, 255, 255, 0.15);
}

.code-language-tag {
    font-size: 0.75rem;
    font-weight: 600;
    opacity: 0.7;
    text-transform: uppercase;
}

.code-copy-btn {
    padding: 0.4rem 0.7rem;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: 6px;
    font-size: 0.75rem;
    cursor: pointer;
    transition: background 0.2s ease;
}

.code-copy-btn:hover { background: rgba(255, 255, 255, 0.15); }

.code-content { overflow: hidden; }

.code-block pre {
    margin: 0;
    padding: 1rem;
    font-family: 'SF Mono', Monaco, 'Fira Code', monospace;
    font-size: 1rem;
    line-height: 1.55;
    color: #24292e;
    background: transparent;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* NEW: Code blocks inside the main overview section */
.overview-section pre {
    font-size: 1rem;
    line-height: 1.5;
    margin-top: 20px;
    margin-bottom: 24px;
    width: 100%;
    overflow-x: auto;
}

/* --- Mobile overrides --- */
@media (max-width: 600px) {
    /* Wrap long code lines so users don't have to scroll sideways */
    .code-block pre { white-space: pre-wrap; word-break: break-word; overflow-wrap: anywhere; }

    /* Focus on the two most relevant columns to avoid horizontal scroll */
    #task-summary-table th:nth-child(3),
    #task-summary-table td:nth-child(3),
    #task-summary-table th:nth-child(4),
    #task-summary-table td:nth-child(4),
    #task-summary-table th:nth-child(5),
    #task-summary-table td:nth-child(5) {
        display: none;
    }
}

/* ------------------------------------------------------------------ */
/* Fix: Prevent speed-up badges from overflowing and give columns room */
/* ------------------------------------------------------------------ */

/* Widen the numeric columns (Best/2nd/3rd/4th speed-up) just a bit so
   the wrapped badges have some breathing space on desktop screens.   */
#task-summary-table td:nth-child(n+2),
#task-summary-table th:nth-child(n+2) {
    min-width: 160px !important; /* was 135px inline – override safely */
}

/* Optionally add a subtle vertical separator to visually distinguish
   the columns (purely cosmetic). Comment these lines out if you prefer
   the original no-border look. */
#task-summary-table td:not(:last-child),
#task-summary-table th:not(:last-child) {
    border-right: 1px solid #eee;
}