/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --text-dark: #1a1a1a;
    --text-medium: #4a4a4a;
    --text-light: #8a8a8a;
    --bg-color: #ffffff;
    --border-color: #e0e0e0;
}

html, body {
    min-height: 100%;
    overflow: auto;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    line-height: 1.5;
    color: var(--text-dark);
    background-color: var(--bg-color);
    font-size: 14px;
}

.page-container {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    max-width: 1400px;
    margin: 0 auto;
    padding: 1.5rem 2.5rem;
}

/* Header */
.header {
    margin-bottom: 1.5rem;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 1rem;
}

.header h1 {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-dark);
    margin-bottom: 0.25rem;
}

.header h1 .degrees {
    color: var(--text-medium);
    font-weight: 400;
}

.header h1 sup {
    font-size: 0.7em;
    vertical-align: super;
    font-weight: 400;
}

.subtitle {
    font-size: 0.9rem;
    color: var(--text-medium);
    font-weight: 400;
}

.header .education {
    font-size: 0.8rem;
    color: var(--text-light);
    font-weight: 400;
    margin-top: 0.5rem;
    font-style: italic;
}

/* Bio Section */
.bio-section {
    margin-bottom: 1.5rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}

.bio-content p {
    margin-bottom: 0.75rem;
    color: var(--text-medium);
    font-size: 0.9rem;
}

.bio-content a {
    color: var(--text-dark);
    text-decoration: underline;
    text-decoration-color: var(--text-light);
}

.bio-content a:hover {
    text-decoration-color: var(--text-dark);
}

/* Main Grid */
.main-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 1.5rem;
    flex: 1;
}

.left-column {
    display: flex;
    flex-direction: column;
}

/* Sections Grid (Research and Teaching) */
.sections-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.5rem;
    flex: 1;
}

.right-column {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.bio-image {
    flex-shrink: 0;
    position: relative;
    display: inline-block;
    width: 100%;
    text-align: center;
}

.image-caption {
    font-style: italic;
    font-size: 0.9rem;
    color: var(--text-medium);
    margin-top: 0.5rem;
    margin-bottom: 0;
    text-align: center;
    line-height: 1.4;
}

/* Desktop: single line */
@media (min-width: 1025px) {
    .image-caption {
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
}

.profile-img {
    width: 100%;
    height: auto;
    object-fit: contain;
    transition: opacity 0.3s ease;
    display: block;
}

.profile-img-default {
    position: relative;
    width: 100%;
}

.profile-img-hover {
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    opacity: 0;
    width: 100%;
    height: auto;
    object-fit: contain;
    display: block;
    max-width: 100%;
}

/* Hover effect - commented out, using click instead */
/* .bio-image:hover .profile-img-default {
    opacity: 0;
}

.bio-image:hover .profile-img-hover {
    opacity: 1;
} */

.section {
    display: flex;
    flex-direction: column;
}

/* Mobile: Override section display for tabs */
@media (max-width: 1024px) {
    .section.tab-content {
        display: none !important;
    }
    
    .section.tab-content.active {
        display: block !important;
    }
}

.section > p:first-of-type {
    margin-bottom: 0.75rem;
    color: var(--text-medium);
    font-size: 0.85rem;
}

.section h2 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-dark);
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.5rem;
    flex-shrink: 0;
}

.section-content {
    flex: 1;
}

.section-content p {
    margin-bottom: 0.6rem;
    color: var(--text-medium);
    font-size: 0.8rem;
    line-height: 1.5;
}

/* Truncate publication items to 3 lines - only paragraphs that don't start with strong (labels) */
#research .section-content > p:not(:has(> strong:first-child)) {
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    word-break: normal;
    overflow-wrap: break-word;
}

/* Allow URLs to break more aggressively */
#research .section-content > p:not(:has(> strong:first-child)) a {
    word-break: break-all;
    overflow-wrap: anywhere;
}

.section-content a {
    color: var(--text-dark);
    text-decoration: underline;
    text-decoration-color: var(--text-light);
}

.section-content a:hover {
    text-decoration-color: var(--text-dark);
}

/* Highlight specific links with yellow background */
a.highlight-link {
    background-color: #ffffcc;
    padding: 0.1em 0.2em 0.1em 0;
    text-decoration: underline;
}

a.highlight-link:hover {
    background-color: #ffffcc;
    text-decoration: underline;
    text-decoration-color: var(--text-dark);
}

.section-content strong {
    color: var(--text-dark);
    font-weight: 600;
}

.section-content em {
    color: var(--text-medium);
    font-style: normal;
}

.section-content .award {
    font-style: italic;
}

/* Mobile Tabs - Hidden on desktop */
.mobile-tabs {
    display: none;
}

.tab-buttons {
    display: none;
}

.tab-button {
    display: none;
}

/* Desktop: Show all tab content by default */
@media (min-width: 1025px) {
    .tab-content {
        display: block !important;
    }
}

/* Desktop: Show mobile bio image, hide desktop bio image */
.desktop-bio-image {
    display: none;
}

.mobile-bio-image {
    display: block;
}

/* Tablet and Mobile Responsive Design */
@media (max-width: 1024px) {
    html, body {
        height: auto;
        overflow: auto;
    }
    
    .page-container {
        overflow-y: auto;
    }
    
    .main-grid {
        grid-template-columns: 1fr;
    }
    
    .sections-grid {
        grid-template-columns: 1fr;
    }
    
    .right-column {
        order: -1;
    }
}

/* Mobile-First Responsive Design */
@media (max-width: 1024px) {
    /* Reset desktop constraints */
    html, body {
        height: auto;
        overflow: auto;
    }
    
    .page-container {
        padding: 0;
        min-height: 100vh;
        height: auto;
        display: block;
    }
    
    /* Show mobile tabs */
    .mobile-tabs {
        display: block;
        position: sticky;
        top: 0;
        z-index: 100;
        background-color: var(--bg-color);
        border-bottom: 1px solid var(--border-color);
        margin-bottom: 1rem;
    }
    
    .tab-buttons {
        display: flex;
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .tab-button {
        flex: 1;
        display: block;
        padding: 0.75rem 0.5rem;
        background: none;
        border: none;
        border-bottom: 2px solid transparent;
        color: var(--text-medium);
        font-size: 0.85rem;
        font-weight: 500;
        cursor: pointer;
        text-align: center;
        white-space: nowrap;
        transition: all 0.2s ease;
    }
    
    .tab-button.active {
        color: var(--text-dark);
        border-bottom-color: var(--text-dark);
        font-weight: 600;
    }
    
    .tab-button:active {
        background-color: var(--bg-light);
    }
    
    /* Hide all tab content by default, show only active */
    .tab-content {
        display: none !important;
        padding: 1rem;
    }
    
    .tab-content.active {
        display: block !important;
    }
    
    /* Override section display for tabs */
    .section.tab-content {
        display: none !important;
    }
    
    .section.tab-content.active {
        display: block !important;
    }
    
    .bio-section.tab-content {
        display: none !important;
    }
    
    .bio-section.tab-content.active {
        display: block !important;
    }
    
    /* Show desktop bio image in Bio tab on mobile - inline on the right */
    .desktop-bio-image {
        display: inline-block;
        float: right;
        margin: 0 0 1rem 1rem;
        width: auto;
        max-width: 120px;
        flex-shrink: 0;
    }
    
    .bio-section .bio-image {
        width: auto;
        max-width: 120px;
    }
    
    /* Hide mobile bio image on mobile (it's in right column, we don't need it) */
    .mobile-bio-image {
        display: none;
    }
    
    /* Header - compact and readable */
    .header {
        margin-bottom: 0;
        padding: 1rem 1rem 1rem;
        border-bottom: 1px solid var(--border-color);
    }
    
    .header h1 {
        font-size: clamp(0.9rem, 4vw, 1.3rem);
        line-height: 1.4;
        margin-bottom: 0.5rem;
        white-space: nowrap;
    }
    
    .header h1 sup {
        font-size: 0.7em;
    }
    
    .subtitle {
        font-size: clamp(0.7rem, 3.2vw, 0.85rem);
        line-height: 1.5;
        margin-bottom: 0.5rem;
        white-space: nowrap;
    }
    
    .header .education {
        font-size: clamp(0.65rem, 2.8vw, 0.75rem);
        margin-top: 0.5rem;
        white-space: nowrap;
    }
    
    /* Main grid becomes single column - use display: contents to flatten structure */
    .main-grid {
        display: contents;
    }
    
    .left-column,
    .right-column {
        width: 100%;
        display: contents;
    }
    
    /* Remove ordering since we're using tabs now */
    .main-grid {
        display: block;
    }
    
    .left-column,
    .right-column {
        display: block;
    }
    
    .sections-grid {
        display: block;
    }
    
    .profile-img {
        width: 100%;
        max-width: 120px;
        height: auto;
        display: block;
    }
    
    .profile-img-default {
        position: relative;
        width: 100%;
        max-width: 120px;
    }
    
    .profile-img-hover {
        position: absolute;
        top: 0;
        left: 0;
        transform: none;
        width: 100%;
        max-width: 120px;
        height: auto;
    }
    
    /* Bio section */
    .bio-section {
        margin-bottom: 2rem;
        padding-bottom: 1.5rem;
        border-bottom: 1px solid var(--border-color);
        overflow: hidden; /* Clear float */
    }
    
    .bio-content {
        display: block;
    }
    
    .bio-content p {
        font-size: 0.95rem;
        line-height: 1.7;
        margin-bottom: 1rem;
    }
    
    .bio-content p:first-of-type {
        margin-top: 0;
    }
    
    /* Sections grid - hide when children are not active */
    .sections-grid {
        display: block;
        gap: 0;
    }
    
    /* Hide all tab content by default on mobile */
    .tab-content {
        display: none !important;
    }
    
    .tab-content.active {
        display: block !important;
    }
    
    /* Individual sections in tabs */
    .section.tab-content {
        overflow: visible;
        margin-bottom: 0;
    }
    
    .bio-section.tab-content {
        margin-bottom: 0;
        padding-bottom: 0;
        border-bottom: none;
    }
    
    .section h2 {
        font-size: 1rem;
        margin-bottom: 1rem;
        padding-bottom: 0.5rem;
    }
    
    .section > p:first-of-type {
        font-size: 0.9rem;
        margin-bottom: 1rem;
        line-height: 1.6;
    }
    
    .section-content {
        overflow: visible;
    }
    
    .section-content p {
        font-size: 0.9rem;
        line-height: 1.7;
        margin-bottom: 1rem;
    }
    
    .section-content a {
        word-break: break-word;
        font-size: 0.9rem;
    }
    
    /* Remove line clamp on mobile */
    #research .section-content > p:not(:has(> strong:first-child)) {
        display: block;
        -webkit-line-clamp: unset;
        -webkit-box-orient: unset;
        overflow: visible;
        word-break: normal;
    }
    
    #research .section-content > p:not(:has(> strong:first-child)) a {
        word-break: break-all;
    }
}

@media (max-width: 480px) {
    .page-container {
        padding: 0.75rem;
    }
    
    .header h1 {
        font-size: 1.15rem;
    }
    
    .subtitle {
        font-size: 0.8rem;
    }
    
    .header .education {
        font-size: 0.7rem;
    }
    
    .bio-content p {
        font-size: 0.9rem;
    }
    
    .section h2 {
        font-size: 0.95rem;
    }
    
    .section-content p {
        font-size: 0.85rem;
    }
    
    .section-content a {
        font-size: 0.85rem;
    }
    
    .bio-image,
    .profile-img,
    .profile-img-default,
    .profile-img-hover {
        max-width: 200px;
    }
    
    .image-caption {
        font-style: italic;
        font-size: 0.8rem;
        margin-top: 0.4rem;
        white-space: normal;
        overflow: visible;
        text-overflow: clip;
        line-height: 1.4;
    }
    
    .sections-grid {
        gap: 2rem;
    }
}
