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

body {
    padding: 15px;
    font-family: system-ui, -apple-system, sans-serif;
}

/* MOBILE VIEW (Default)
   Everything stacks in 1 column automatically
*/
.grid-container {
    display: grid;
    grid-template-columns: 1fr; 
}

.item {
    color: white;
    text-align: center;
    min-height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.empty {
    display: none; /* Hide the empty middle cell on mobile to save space */
}

/* Sticky Navigation Logic */
.sticky-nav {
    position: -webkit-sticky; /* For Safari */
    position: sticky;
    top: 0;
    z-index: 1000;
    background-color: #005a9c;
    padding: 0; /* Remove padding for a flush nav bar */
}

.nav-wrapper {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    width: 100%;
}

.nav-link {
    padding: 15px 5px;
    color: white;
    text-decoration: none;
    text-align: center;
    font-weight: bold;
    font-size: 0.9rem;
    transition: background 0.3s;
    cursor: pointer;
}

.nav-link:hover {
    background-color: #003d6b;
}

/* Row 4 Content Toggling */
.content-section {
    display: none; /* Hidden by default */
    padding: 20px;
    animation: fadeIn 0.4s;
}

.content-section.active {
    display: block; /* Shown when active class is added */
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* logo in the first row */
#iiitdlogo {
    max-height : 50px;
}

#cqtlogo {
    max-height : 40px;
}

/* name and picture in the second row */
.r2 { color: black }

.r2.bio-text {
    display: flex;
    flex-direction: column;
    align-items: flex-start; /* Aligns text to the left */
    text-align: left;
}

#name { margin-bottom:30px;}
#name span{font-size:300%; font-weight:bold;
    font-family: Times New Roman, Serif; font-variant:small-caps;font-style:oblique;
    letter-spacing:2px;
    border-width:2px 0; border-color: black; border-style:solid;
}
#position, #place, #degree {font-weight:bold}
#degree {width:300px; float:right}
#degree span { display: block}
#degree span:first-child {border-top:2px dotted gray; padding-top:5px;}
.r2 img {
/* h-offset | v-offset | blur | spread | color */
    box-shadow: 10px 10px 20px rgba(0, 0, 0, 0.2);
    margin-bottom: 20px;
    max-height: 200px;
    margin-top: 5px;
}

/* Positioning Row 3 in the Grid */
.r3 {
    grid-column: 1 / -1; /* Spans all 7 columns */
    padding: 0;          /* Remove padding so links touch the edges */
    display: flex;       /* Use flexbox inside the nav for equal spacing */
    background-color: #005a9c;
    position: sticky;
    top: 0;
    z-index: 1000;
    overflow: hidden;    /* Keeps background color within rounded corners */
}

.r3 a {
    flex: 1 0 33%;             /* Mobile view, 3 + 3 + 1 link */
    color: white;
    text-decoration: none;
    text-align: center;
    padding: 15px 0;
    font-weight: bold;
    font-size: 0.9rem;
    transition: background 0.3s;
}

.r3 a:hover {
    background-color: #003d6b;
}

/* Ensure Row 4 also spans the full width */
/* Ensure Row 4 takes up enough height so the sticky effect is visible */
.r4 {
    grid-column: 1 / -1;
    min-height: 400px;
    align-items: flex-start;
    text-align: center;
    background-color: #140C33;
}

/* Target all content sections inside Row 4 */
.r4 .content-section {
    text-align: left;       /* Overrides the inherited center alignment */
    align-items: flex-start; /* If using flex, aligns children to the left */
}

/* Specifically for lists to ensure bullets are inside the view */
.r4 ul {
    text-align: left;
    list-style-position: inside; /* Keeps bullets aligned with the text */
    padding-left: 20px;          /* Adds standard indentation */
}

.r4 li {
    margin-bottom: 10px;         /* Adds breathing room between news items */
    text-align: left;
}

.r4 a { color: lightgreen; text-decoration: underline }
.r4 a:hover { color: #00CC00; }
.r4 li { margin-top: 1em; }
.r4 ul ul { margin-left: 1em; }
.r4 ul ul li { margin-top: 0.5em; }

/* about section */
#about a { color: lightblue;}
#email > span:hover, #phone > span:hover, #resume a:hover {text-decoration:underline;}
.address {width:300px; margin-top:20px; margin-bottom: 20px; border:1px dotted #EAEAEA;}
#home-address:hover, #office-address:hover, #res-address:hover {border: 1px dotted gray;}
.address > span {display:block; color: lightblue;}
.address > span:first-child { color: gray;}

/* r4 : talks section */
.talks-grid {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.talk-entry {
    display: grid;
    grid-template-columns: 120px 1fr; /* Fixed width for date, elastic for content */
    border-left: 4px solid #005a9c;
    padding-left: 15px;
    margin-bottom: 5px;
}

.talk-date {
    font-weight: bold;
    color: #96c593;
    font-size: 0.9rem;
}

.talk-type {
    font-size: 0.75rem;
    text-transform: uppercase;
    color: #005a9c;
    font-weight: bold;
    margin-right: 10px;
    background: #eef2f7;
    padding: 2px 6px;
    border-radius: 4px;
}

.talk-title {
    font-weight: 600;
    font-size: 1.05rem;
    color: lightgreen;
}

.talk-link {
    color: #005a9c;
    text-decoration: underline;
}

.talk-venue {
    margin-top: 5px;
    font-style: italic;
    color: #d3d3d3;
    font-size: 0.95rem;
    display: inline;
}

ul.publist { font-size: large; background-color: #333; border-radius: 25px; padding: 0 1em 1em 1em; margin-bottom: 1em;}
.publist u { text-decoration: none; border-bottom: 1px dotted !important;}
.publist .first {
    background-color: #1e5773;
    margin-top: 0px;
    margin-left: 15px;
    border-bottom-left-radius: 10px;
    border-bottom-right-radius: 10px;
    list-style: none;
    padding: 5px;
    width: 50px;
    text-align: center;
}

.r5 span { color: darkblue;}

/* DESKTOP VIEW 
   This triggers when the screen is wider than 768px
*/
@media (min-width: 768px) {
    .grid-container {
        grid-template-columns: repeat(7, 1fr); /* The 7-column base */
    }

    .empty {
        display: flex; /* Bring back the empty cell */
        background: transparent;
    }

    /* Row 1: 3 columns (Elastic middle) */
    .r1:nth-child(1) { grid-column: span 2; justify-content: flex-start;}
    .r1.elastic      { grid-column: span 3; } 
    .r1:nth-child(3) { grid-column: span 2; justify-content: flex-end;}

    /* Row 2: 4 columns (1st and last empty) */
    .r2:nth-child(5) { grid-column: span 2; }
    .r2.empty, .r2.elastic { grid-column: span 1; }
    .r2:nth-child(7) { grid-column: span 2; }

    /* Row 3: 7 columns */
    .r3 {
        grid-column: 1 / -1; /* Spans all 7 columns of the main grid */
        display: flex;
        flex-direction: row;
        flex-wrap: nowrap;   /* Forces them into a single line */
        position: sticky;    /* Re-enable sticky for desktop */
        top: 0;
    }

    .r3 a {
        flex: 1;             /* Tells each link to take up exactly 1/7th of the space */
        border: none;        /* Optional: remove the mobile borders */
        border-right: 1px solid rgba(255,255,255,0.1); /* Subtle divider instead */
        text-align: center;
        padding: 15px 5px;
    }
    
    .r3 a:last-child {
        border-right: none;  /* Clean end to the bar */
    }
    /* Row 4: 1 column */
    .r4 { grid-column: 1 / -1; }

    /* Row 5: 4 columns */
    /* Spreading 4 columns across 7 units roughly */
    .r5:nth-child(15) { grid-column: span 1; }
    .r5:nth-child(16) { grid-column: span 1; }
    .r5:nth-child(17) { grid-column: span 1; }
    .r5:nth-child(18) { grid-column: span 4; }
}

@media print {
    .sticky-nav, .r3 { display: none; } /* Hide navbar on paper */
    .grid-container { display: block; }  /* Simplify grid for printers */
    body { background: white; color: black; }
}

/* On mobile, for talks, stack the date on top of the title */
@media (max-width: 600px) {
    .talk-entry {
        grid-template-columns: 1fr;
        gap: 5px;
    }
}
