/* ================================================================
   NVIDIA SIL Main Layout Styles
   
   Shared styles for main pages (main.html, members/main.html, 
   publications/main.html) to eliminate CSS duplication and 
   ensure consistent styling across all main pages.
================================================================ */

/* ========================================
   CSS Custom Properties (Design System)
======================================== */
:root {
    /* NVIDIA Brand Colors */
    --primary-color: #76b900;
    --primary-hover: #5a8c00;
    
    /* Text Colors */
    --text-dark: #1a1a1a;
    --text-medium: #444;
    --text-light: #555;
    
    /* Background Colors */
    --bg-white: #ffffff;
    --bg-light: #f8f9fa;
    
    /* Shadow System (full shorthand to match research-template.css convention) */
    --shadow-light: 0 2px 8px rgba(0, 0, 0, 0.1);
    --shadow-medium: 0 4px 16px rgba(0, 0, 0, 0.15);
    
    /* Border Radius */
    --border-radius: 8px;
    
    /* Animation */
    --transition: all 0.2s ease;
}

/* ========================================
   Base Styles
======================================== */
* {
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background-color: var(--bg-white);
    color: #333;
    margin: 0;
    padding: 0 20px 5px 20px;
    line-height: 1.5;
}

/* ========================================
   Typography
======================================== */
h1 {
    text-align: center;
    margin-top: 0;
    margin-bottom: 8px;
    color: var(--text-dark);
    font-weight: 700;
    font-size: 2.5em;
}

h2 {
    margin-top: 15px;
    margin-bottom: 8px;
    font-weight: 600;
    font-size: 2.0em;
    color: var(--text-dark);
}

h3 {
    margin-top: 0;
    margin-bottom: 2px;
    font-weight: 600;
    color: var(--text-dark);
    font-size: 1.1em;
    line-height: 1.2;
    text-align: center;
}

/* Card title sizing (applies to all tiles: Research Areas, Libraries, Applications) */
.column-content h3,
.column-content h3 a,
.column-content a h3 {
    font-size: 0.8em;
    line-height: 0.5;
}

/* Helper: precise spacing for manual second line in titles */
.column-content h3 .title-break {
    display: block;
    margin-top: 2px; /* adjust to taste */
}

/* Normalize heading/link layout so <h3><a>..</a></h3> and <a><h3>..</h3></a> match */
.column-content h3 a,
.column-content a h3 {
    text-decoration: none;
}

.column-content h3 a:hover,
.column-content a h3:hover {
    text-decoration: underline;
}

p {
    color: var(--text-light);
    line-height: 1.2;
    margin-bottom: 0;
    margin-top: 0;
    font-size: 0.9em;
}

/* ========================================
   Links
======================================== */
a {
    color: var(--primary-color);
    text-decoration: none;
    transition: var(--transition);
}

a:hover {
    color: var(--primary-hover);
    text-decoration: underline;
    text-underline-offset: 1px;
    text-decoration-thickness: 1px;
}

a:focus-visible,
.paper-cell a:focus-visible,
.column a:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
    border-radius: 2px;
}

/* Tight-underline style for inline text links inside card descriptions.
   Uses a background-gradient pseudo-underline so we can position the line
   closer to the text than text-decoration allows. Underline is always
   visible in the link's green color and deepens on hover. */
.column-content p a {
    text-decoration: none;
    background-image: linear-gradient(var(--primary-color), var(--primary-color));
    background-position: 0 calc(100% - 2px);
    background-repeat: no-repeat;
    background-size: 100% 2px;
    transition: color 0.2s ease, background-image 0.2s ease;
}

.column-content p a:hover {
    background-image: linear-gradient(var(--primary-hover), var(--primary-hover));
}

/* ========================================
   Layout Components
======================================== */
.container {
    max-width: 1200px;
    margin: 0 auto;
}

header {
    margin-bottom: 30px;
}

.header2-content {
    line-height: 1.3;
    max-width: 900px;
    margin: 0 auto 10px auto;
    color: var(--text-medium);
    font-size: 1.0em;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.section {
    margin-bottom: 20px;
}

/* ========================================
   Grid Systems
======================================== */
.row {
    display: flex;
    flex-wrap: wrap;
    margin-top: 2px;
    gap: 12px;
    justify-content: center;
}

.core-tech-row {
    display: flex;
    flex-wrap: nowrap;
    margin-top: 2px;
    gap: 8px;
    justify-content: center;
    overflow-x: clip;
    padding-top: 4px;
    padding-bottom: 12px;
    padding-left: 20px;
    padding-right: 20px;
    -webkit-overflow-scrolling: touch;
    position: relative;
}

.libraries-row {
    display: flex;
    flex-wrap: nowrap;
    margin-top: 2px;
    gap: 8px;
    justify-content: center;
    overflow-x: clip;
    padding-top: 4px;
    padding-bottom: 12px;
    padding-left: 20px;
    padding-right: 20px;
    -webkit-overflow-scrolling: touch;
    position: relative;
}

/* ========================================
   Horizontal Scrollbar Styling (where supported)
   Note: iOS Safari hides scrollbars by design; see mobile hint below.
======================================== */
.core-tech-row::-webkit-scrollbar,
.libraries-row::-webkit-scrollbar {
    height: 8px;
}

.core-tech-row::-webkit-scrollbar-track,
.libraries-row::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.06);
    border-radius: 4px;
}

.core-tech-row::-webkit-scrollbar-thumb,
.libraries-row::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.35);
    border-radius: 4px;
}

.core-tech-row,
.libraries-row,
.recent-papers-row {
    scrollbar-width: thin; /* Firefox */
    scrollbar-color: rgba(0, 0, 0, 0.35) rgba(0, 0, 0, 0.06);
}

/* Wrapper and fixed overlays so gradients stay pinned at row edges */
.scroll-row-wrapper {
    position: relative;
    overflow-x: clip;
}

.scroll-row-overlay {
    position: absolute;
    top: 0;
    height: 100%;
    pointer-events: none;
    width: 88px; /* larger to fully cover edge and any scrollbar */
    z-index: 5;
    opacity: 0;
    display: none; /* hidden by default, only shown when needed */
    transition: opacity 120ms ease;
}

.scroll-row-overlay.right {
    right: -15px; /* extend slightly beyond edge to cover rounding/gutters */
    background: linear-gradient(to left,
        var(--bg-white) 0%,
        var(--bg-white) 35%,
        rgba(255, 255, 255, 0) 100%
    );
}

.scroll-row-overlay.left {
    left: -15px;
    background: linear-gradient(to right,
        var(--bg-white) 0%,
        var(--bg-white) 35%,
        rgba(255, 255, 255, 0) 100%
    );
}

.scroll-row-wrapper.show-right .scroll-row-overlay.right { display: block; opacity: 1; }
.scroll-row-wrapper.show-left .scroll-row-overlay.left { display: block; opacity: 1; }

/* ========================================
   Cards
======================================== */
.column {
    padding: 0;
    background-color: var(--bg-light);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-light);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    overflow: hidden;
}

.row .column {
    flex: 0 1 310px;
    max-width: 310px;
    min-width: 310px;
    width: 310px;
}

.core-tech-row .column {
    flex: 0 0 245px;
    width: 245px;
    max-width: 245px;
    min-width: 245px;
}

.libraries-row .column {
    flex: 0 0 310px;
    width: 310px;
    max-width: 310px;
    min-width: 310px;
}

/* ========================================
   Recent Papers Row
======================================== */
.recent-papers-row {
    display: flex;
    flex-wrap: nowrap;
    margin-top: 2px;
    gap: 10px;
    justify-content: flex-start;
    overflow-x: auto;
    padding-top: 4px;
    padding-bottom: 12px;
    padding-left: 20px;
    padding-right: 20px;
    -webkit-overflow-scrolling: touch;
    position: relative;
}

.recent-papers-row::-webkit-scrollbar {
    height: 6px;
}

.recent-papers-row::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.04);
    border-radius: 3px;
}

.recent-papers-row::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.25);
    border-radius: 3px;
}

.recent-papers-row {
    scrollbar-width: thin;
    scrollbar-color: rgba(0, 0, 0, 0.25) rgba(0, 0, 0, 0.04);
}

.paper-cell {
    flex: 0 0 auto;
    background: linear-gradient(135deg, var(--bg-light) 0%, #f0f1f2 100%);
    border-radius: 8px;
    padding: 1px 10px;
    border-left: 3px solid var(--primary-color);
    transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
    max-width: 260px;
    min-width: 180px;
}

.paper-cell:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    border-left-color: var(--primary-hover);
}

.paper-cell a {
    text-decoration: none;
    color: inherit;
    display: block;
}

.paper-cell .paper-title {
    font-size: 0.78em;
    font-weight: 600;
    color: var(--text-dark);
    line-height: 1.25;
    margin: 0;
    min-height: 3.5em; /* Reserve space for 2 lines so 1- and 2-line titles align; 3-line titles grow the cell (the row uses align-items:stretch so neighbours match height) */
    display: -webkit-box;
    -webkit-line-clamp: 3;
    line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.paper-cell:hover .paper-title {
    color: var(--primary-color);
}

.paper-cell .paper-venue {
    font-size: 0.65em;
    color: var(--text-light);
    margin: 0;
    font-weight: 500;
    letter-spacing: 0.02em;
}

/* ========================================
   Recent Papers Thumbnail Cards
   Cards with background images from data-thumb
======================================== */
.recent-papers-row .paper-cell {
    min-height: 140px;
    background-color: var(--bg-light);
    background-size: cover;
    background-position: center;
    padding: 0;
}

.recent-papers-row .paper-cell a {
    display: flex;
    flex-direction: column;
    justify-content: center;
    height: 100%;
    padding: 12px;
    background: rgba(255, 255, 255, 0.7);
    border-radius: inherit;
}

.recent-papers-row .paper-title {
    background: rgba(255, 255, 255, 0.85);
    padding: 6px 8px;
    border-radius: 4px;
    display: inline-block;
    color: var(--primary-color);
    transition: var(--transition);
}

.recent-papers-row .paper-cell:hover .paper-title {
    color: var(--primary-hover);
    text-decoration: underline;
}

.recent-papers-row .paper-venue {
    margin-top: 4px;
    color: var(--text-dark);
}

.column:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-medium);
}

.column-content {
    padding: 5px 15px 8px 15px;
}

/* ========================================
   Media
======================================== */
.teaser-video {
    width: 100%;
    height: auto;
    aspect-ratio: 16 / 9;
    object-fit: cover;
    margin: 0;
    display: block;
    border-radius: var(--border-radius) var(--border-radius) 0 0;
}

/* ========================================
   Buttons
======================================== */
/* Pill button rows on the homepage. Visually mirrors the
   .resource-buttons / .sdk-buttons rules in shared/research-template.css
   so the same outlined-pill style appears whether a button is on the
   homepage, a research area page, or an application page. */
.sdk-buttons,
.resource-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
    margin-top: 8px;
}

.sdk-button,
.resource-button {
    display: inline-flex;
    align-items: center;
    padding: 5px 14px;
    background-color: #fff;
    color: var(--primary-color);
    text-decoration: none;
    border: 1.5px solid var(--primary-color);
    border-radius: 999px;
    font-size: 0.8em;
    font-weight: 600;
    line-height: 1.3;
    white-space: nowrap;
    cursor: pointer;
    transition: background-color var(--transition),
                color var(--transition),
                border-color var(--transition),
                transform var(--transition),
                box-shadow var(--transition);
}

.sdk-button:hover,
.resource-button:hover {
    background-color: var(--primary-color);
    color: #fff;
    border-color: var(--primary-color);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(118, 185, 0, 0.25);
    text-decoration: none;
}

.sdk-button:focus-visible,
.resource-button:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* ========================================
   Utility Classes
======================================== */
/* .highlight class removed — was a no-op (color: inherit) */

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

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

/* ========================================
   Responsive Design
======================================== */
/* Recent Papers Section Header */
.recent-section-header {
    display: flex;
    align-items: baseline;
    justify-content: center;
    position: relative;
    margin-top: 10px;
    margin-bottom: 8px;
    padding: 0 20px;
}

.recent-section-header h2 {
    margin: 0;
    font-size: 2.0em;
    font-weight: 600;
    color: var(--text-dark);
    text-align: center;
}

.recent-section-header .view-all-link {
    position: absolute;
    right: 20px;
    bottom: -2px;
    font-size: 0.85em;
    font-weight: 500;
    color: var(--primary-color);
    text-decoration: none;
}

.recent-section-header .view-all-link:hover {
    color: var(--primary-hover);
    text-decoration: underline;
}

@media (max-width: 1350px) {
    .core-tech-row {
        overflow-x: auto;
        justify-content: flex-start;
    }
    
    .libraries-row {
        overflow-x: auto;
        justify-content: flex-start;
    }

    /* Overlays are added as fixed elements via JS within a wrapper */
}

@media (max-width: 768px) {
    body {
        padding: 0 10px 5px 10px;
    }
    
    h1 {
        font-size: 2em;
    }
    
    h2 {
        font-size: 1.5em;
    }

    /* Overlays are added as fixed elements via JS within a wrapper */

    /* Account for iOS safe-area inset on the right to suppress sliver */
    .scroll-row-overlay.right {
        right: calc(-8px - env(safe-area-inset-right));
        width: calc(96px + 16px + env(safe-area-inset-right));
    }

    /* Recent papers section mobile adjustments */
    .recent-section-header h2 {
        font-size: 1.5em;
    }

    .recent-section-header .view-all-link {
        font-size: 0.75em;
    }

    .recent-papers-row {
        padding-left: 10px;
        padding-right: 10px;
        gap: 8px;
    }

    .paper-cell {
        min-width: 160px;
        max-width: 220px;
        padding: 2px 4px;
    }

    .paper-cell .paper-title {
        font-size: 0.74em;
    }

    .paper-cell .paper-venue {
        font-size: 0.6em;
    }
}

/* Respect users who ask the OS to reduce motion. Pauses decorative
   transitions/animations and neutralizes hover transforms. Autoplay videos
   are decorative loops, so we also pause them via the
   prefers-reduced-motion query in markup (where supported). */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
    .column:hover,
    .paper-cell:hover {
        transform: none !important;
    }
} 