/* --- BASE STYLES --- */
body {
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: #ffffff;
    color: #000000;
    margin: 0;
    padding: 0 10px; /* Adjusted to 0 top/bottom to allow sticky header to touch top */
    line-height: 1.6;
    max-width: 900px;
    margin-left: auto;
    margin-right: auto;
}

/* --- INDIC FONT STACKS (SERIF) --- */
[lang="ta"] {
    font-family: 'Noto Serif Tamil', 'Tamil MN', serif;
    font-size: 0.93em;
}

[lang="hi"], [lang="mr"] {
    font-family: 'Noto Serif Devanagari', 'Devanagari Sangam MN', 'Mangal', serif;          
}

/* Specifically for Latin characters/numbers on Indian language pages */
.latin-text {
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    /* Optional: adjust size if the sans-serif looks too large next to the serif */
    font-size: 0.95em;
}

.latin-text-in-tamil {
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    font-size: 1.02em;
}

/* LINK COLOR: #0077CC (Recommended) */
a { color: #0077CC; text-decoration: none; }
a:hover { text-decoration: underline; }

/* HEADER & RAINBOW LINES */
header {
    margin-bottom: 30px;
}

/* The Rainbow Line */
.rainbow-line {
    height: 4px;
    border: none;
    background: linear-gradient(to right, red, orange, yellow, green, blue, indigo, violet);
    margin: 15px 0;
}

/* --- NEW STICKY HEADER CONTAINER --- */
.site-header {
    /* Keeps the header pinned to the top of the browser window during scroll */
    position: -webkit-sticky; 
    position: sticky;
    top: 0;
    /* Prevents page content from showing through the header background */
    background-color: #ffffff; 
    /* Ensures the header stays visually 'above' images and bio text */
    z-index: 1000;            
    width: 100%;
    margin-bottom: 5px;
}

/* --- HEADER TOP BAR (NAME & ICON) --- */
.header-top {
    /* Uses Flexbox to align name on the left and hamburger on the right */
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0 5px 0;
}

/* --- BRANDING (NAME ON LEFT) --- */
.header-name {
    font-size: 1.4em;
    font-weight: bold;
    color: #333;
    font-family: system-ui, -apple-system, sans-serif;
}

.header-name a {
    color: #333;
    text-decoration: none;
    font-size: 1em; /* Ensures it inherits the 1.4em from parent, without compounding */
}

/* --- HAMBURGER MENU TOGGLE --- */
/* This checkbox is hidden; it tracks if the menu is 'open' or 'closed' */
#menu-toggle {
    display: none;
}

/* Styles the 3-line symbol as a clickable button */
.menu-icon {
    font-size: 28px;
    cursor: pointer;
    user-select: none;
    padding: 5px;
}

/* --- NAVIGATION & ANCHORS --- */
[id] {
    scroll-margin-top: 80px;
}

/* --- THE PUSH-DOWN NAVIGATION LIST --- */
.main-nav {
    /* Positions the dropdown list directly underneath the top bar */
    position: absolute;
    top: 100%; 
    left: 0;
    right: 0;
    width: 100%;
    background: #ffffff;
    /* Hidden by default; only shows when toggled */
    display: none;
    border-bottom: 1px solid #eee;
    /* Adds depth to the dropdown when it overlaps page content */
    box-shadow: 0 4px 6px rgba(0,0,0,0.1); 
}

/* --- THE TOGGLE LOGIC --- */
/* When the hidden checkbox is checked, the menu list becomes visible */
#menu-toggle:checked ~ .main-nav {
    display: block;
}

/* --- DROPDOWN LINK STYLING --- */
.main-nav ul {
    list-style: none;
    padding: 20px 0;
    margin: 0;
    /* Stacks the links vertically in the dropdown */
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
}

.main-nav li a {
    text-decoration: none;
    font-weight: bold;
    text-transform: uppercase;
    font-size: 0.9em;
    color: #0077CC; /* Consistent academic blue */
}

/* --- VISUAL DIVIDERS --- */
.rainbow-line {
    height: 4px;
    border: none;
    background: linear-gradient(to right, red, orange, yellow, green, blue, indigo, violet);
    /* Sits tightly under the name bar */
    margin: 5px 0 15px 0;
}

/* --- PROFILE SECTION (CENTERS PHOTO WHEN STACKED) --- */
.profile-container {
    display: flex;
    flex-wrap: wrap; /* Allows photo to wrap under text on narrow screens */
    justify-content: center; /* Centers items when they wrap */
    gap: 40px;
    margin-bottom: 30px;
    max-width: 85%; 
    margin-left: auto;
    margin-right: auto; 
}

.contact-info { 
    flex: 1; 
    min-width: 320px; /* Prevents address from getting too narrow */
}

.profile-photo {
    flex: 0 0 auto;
}

.profile-photo img {
    max-width: 200px;
    height: auto;
    display: block; /* Removes bottom spacing gap */
}

/* --- KEEPING YOUR EXISTING COMPACT CONTENT RULES --- */
.compact-content p {
    margin-top: 5px;
    margin-bottom: 5px;
}

.compact-content ol, .compact-content ul {
    line-height: 1.4;
    padding-left: 25px; 
    margin-top: 5px;
    margin-bottom: 5px;
}

.compact-content ol li, .compact-content ul li {
    margin-bottom: 2px;
}

/* --- KEEPING YOUR EXISTING IMAGE WRAPPING RULES --- */
.inline-photo-right {
    float: right;
    margin-left: 25px;
    margin-bottom: 15px;
    max-width: 350px;
}

.inline-photo-right img { width: 100%; height: auto; display: block; }
.inline-photo-right figcaption { font-size: 0.8em; color: #555; text-align: center; }

/* --- MOBILE RESPONSIVENESS TWEAKS --- */
@media (max-width: 600px) {
    .inline-photo-right { float: none; margin: 20px auto; max-width: 90%; }
    .profile-container { max-width: 95%; }

    /* --- RESPONSIVE TABLE STACKING --- */
    .fullwidth tr, .lectures-table tr {
        display: block;
        margin-bottom: 15px; 
    }

    .fullwidth td, .lectures-table td {
        display: block;
        width: 100% !important; 
        padding: 0 5px; 
        box-sizing: border-box; 
    }

    /* Override nowrap for mobile stacking and align with title text */
    td.lt-refs {
        white-space: normal;
        padding-left: 30px;
    }

    /* Style the first cell (Date/Topic) to look like a label */
    .fullwidth td:first-child, .lt-date {
        color: #000;
        margin-bottom: 0;
    }
}

/* =========================
   Teaching page polish
   ========================= */

/* Section header row (title left, switch link right) */
.section-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 8px;
}

.section-head h2 {
  font-size: 1.2em;
  margin: 0;
}

.section-head h3 {
    font-size: 1.1em;
    margin: 0;
}

.section-switch {
  margin: 0;
  font-size: 0.9em;
}

/* Tables */
.teaching-table {
  width: 100%;
  border-collapse: collapse;
  /*line-height: 1.45;*/
}

/* (a) first cell bold + grey (desktop + mobile) */
.teaching-label {
  /*font-weight: 700;
  color: #666;*/
  width: 25%;
  vertical-align: top;
  padding: 2px 8px 2px 5px; /* (b) tighter between rows */
  white-space: nowrap;
}

.teaching-item {
  vertical-align: top;
  padding: 2px 5px;         /* (b) tighter between rows */
}

/* --- MOBILE RESPONSIVENESS TWEAKS --- */
@media (max-width: 600px) {
    
    /* Stacked layout for teaching tables */
    .teaching-table tr {
      display: block;
      margin-bottom: 8px;     /* (b) tighter between rows on mobile */
    }

    .teaching-table td {
      display: block;
      width: 100%;
      box-sizing: border-box;
    }

    /* (c) minimal spacing between stacked label + item */
    .teaching-label {
      width: 100%;
      white-space: normal;
      padding: 1px 5px 0 5px;
    }

    .teaching-item {
      padding: 0 5px 1px 5px;
    }
}

/* --- Course Page Specifics --- */
.course-main-title { font-size: 1.5em; margin-bottom: 0.2em; }
.course-sub-title { font-size: 1.2em; color: #555; margin-top: 0; }

.lectures-container { margin-top: 1em; }
/* .section-head and .section-switch are defined above */

.lectures-table { width: 100%; border-collapse: collapse; margin-top: 10px; }
.no-lecture-row { background-color: #fcfcfc; color: #777; font-size: 0.95em; }

.lt-date { padding: 4px 10px; vertical-align: top; width: 12%; }
.lt-content { padding: 4px 10px; vertical-align: top; }
.lt-refs { padding: 4px 10px; vertical-align: top; width: 1%; font-size: 0.9em; text-align: left; white-space: nowrap; }

.li-wrapper { display: flex; align-items: flex-start; }
.li-num { min-width: 25px; display: inline-block; }
.li-topics { padding-left: 25px; font-size: 0.9em; color: #444; }

/* NEWS ITEM HIGHLIGHT BLOCK */
.news-item {
    margin-bottom: 20px;
    padding: 10px;
    background-color: #f0f7ff;
    border-left: 4px solid #0077CC;
}

.refs-table { width: 100%; border-collapse: collapse; line-height: 1.4; }
.ref-id { padding: 2px 10px 2px 0; vertical-align: top; width: 10%; white-space: nowrap; }
.ref-content { padding: 2px 0; vertical-align: top; }

.bib-list { padding-left: 1.5em; }
.bib-list li { margin-bottom: 1.2em; }

.footer-flex { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 10px; }
.footer-right { display: flex; align-items: center; gap: 8px; font-size: 0.7em; color: #555; }
.footer-ts { white-space: nowrap; }
.footer-counter { display: flex; align-items: center; gap: 4px; white-space: nowrap; }
.footer-counter img { vertical-align: middle; height: 12px; }
