/* Root variables */
:root {
    /* Document measurements */
    --paper-width: 8.5in;
    --paper-margin: 1in;

    /* Typography */
    --base-font-size: 12pt;
    --paper-font: "Helvetica Neue", Helvetica, "Nimbus Sans", Arial, sans-serif;
    /* Colors */
    --text-color: #333333;
    --background-color: #ffffff;

    /* Effects */
    --hover-shadow: 0 2px 10px rgba(0,0,0,0.1);
    --hover-bg: rgba(255, 255, 255, 0.1);
}

/* Enable the "swish" smooth scroll globally */
html {
    scroll-behavior: smooth;
}

/* Base styles */
body {
    font-family: var(--paper-font);
    font-size: var(--base-font-size);
    color: var(--text-color);
    background-color: var(--background-color);
    line-height: 1.5;
    margin: 0;
    padding: 0;
}

/* --- UNIFY CURSOR STYLES --- */
/* Forces the "Hand" cursor on all interactive elements */
a,
button,
.video-trigger,              /* The images that open videos */
.close-popup,                /* The 'X' buttons */
.methods-section-link,       /* The transparent overlay links */
.fluorescent-reporter-section-link {
    cursor: pointer !important;
}

/* Scientific paper layout */
.scientific-paper {
    max-width: var(--paper-width);
    margin: 0 auto;
    padding: var(--paper-margin);
    overflow: visible;
}

/* Justify all main manuscript text */
.scientific-paper p {
    text-align: left;
    hyphens: auto;
}

/* Title section styles */
/* Container forces a square aspect ratio */
.title-container {
    position: relative;
    width: 100%;
    aspect-ratio: 1 / 1; 
    margin-bottom: 3rem;
    overflow: hidden;
    border-radius: 24px;
    /* Set background to transparent or white to avoid a black 'ghost' border */
    background-color: transparent; 
}

.title-image {
    width: 100%;
    height: 100%;
    /* display: block is the key to removing the tiny line at the bottom */
    display: block;
    /* Use 'cover' to ensure it fills the square perfectly without borders */
    object-fit: cover;
    border-radius: 24px;
    border: none; /* Explicitly remove any browser-default borders */
    outline: none;
}

.title-video {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 24px;
    z-index: 0;
    opacity: 0;
    transition: opacity 2.5s ease-in-out;
}

.title-video.playing {
    opacity: 1;
}

.title-poster {
    position: relative;
    z-index: 0;
}

/* Video sits behind the overlay text but replaces the image */
.title-container .overlay {
    z-index: 1;
}

/* The Keynote Title Styling with Fluid Typography */
.title-heading {
    color: #ffffff;
    font-family: "Helvetica", "Nimbus Sans", sans-serif;
    
    /* clamp(minimum, preferred, maximum) */
    /* This ensures text is never smaller than 1.5rem and never larger than 3rem */
    font-size: clamp(1.5rem, 5vw, 3rem); 
    
    font-weight: 800;
    line-height: 1.1;
    letter-spacing: -0.03em;
    margin: 0;
    text-shadow: 0 2px 10px rgba(0,0,0,0.2);
}

/* Small Subtitle/Abstract Hook with Fluid Scaling */
.title-heading::after {
    content: "Interactive Research Manuscript";
    display: block;
    white-space: pre-wrap;
    
    font-size: clamp(0.8rem, 2vw, 1.2rem);
    font-weight: 400;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    margin-top: 1.5rem;
    color: #a6d96a;
    -webkit-text-fill-color: initial;
}

.title-heading::before {
    content: none;
}

.overlay::after {
    content: "scroll to continue or click for contents";
    display: block;
    font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
    font-size: clamp(0.55rem, 1.2vw, 0.75rem);
    font-weight: 300;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.55);
    text-align: center;
    position: absolute;
    bottom: clamp(0.5rem, 1.5vw, 1rem);
    left: 50%;
    transform: translateX(-50%);
    white-space: nowrap;
}

/* Ensure the overlay handles the space correctly */
.overlay {
    position: absolute;
    top: 45%; 
    left: 50%;
    transform: translate(-50%, -50%);
    width: 85%; /* Increased slightly for better mobile padding */
    max-height: 80%; /* Increased to prevent clipping of the frosted box itself */
    max-width: 800px;
    
    background: rgba(255, 255, 255, 0.12); 
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    
    padding: clamp(1rem, 3vw, 2.5rem); /* Fluid padding inside the glass box */
    border-radius: 24px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.2);
    text-align: center;
    overflow: hidden; /* Keeps the fluid content contained */
}

/* Ensure the link doesn't add unwanted underlines or colors to your title */
.title-link {
    text-decoration: none;
    display: block;
    cursor: pointer !important; /* Forces the "Hand" cursor */
}

/* Optional: Subtle Apple-style hover effect */
.title-link:hover .title-image {
    transform: scale(1.02); /* Slight zoom on hover */
    transition: transform 0.5s cubic-bezier(0.25, 1, 0.5, 1); /* Sleek, easing transition */
}

.title-link:hover .overlay {
    background: rgba(255, 255, 255, 0.18); /* Slight brighten on hover */
    transition: background 0.3s ease;
}

/* Author links */

.authors {
    display: flex;
    font-weight: bold;
    font-size: 1.25rem;     /* Slightly smaller for hierarchy */
    flex-wrap: wrap;       /* Allows names to wrap to next line if needed */
    justify-content: center; /* Centers the whole block of names */
    gap: 2px;             /* Even spacing between names */
    width: 100%;
    margin: 0px auto;
    line-height: 1.1;
    text-align: center;
}

/* Corresponding author container */
.corresponding-author {
    display: flex;          /* Enables flexbox for centering */
    justify-content: center; /* Centers the content horizontally */
    width: 100%;            /* Ensures it spans the full paper width */
    margin-top: 10px;       /* Adds space below the author names */
    text-align: center;     /* Fallback for older browsers */
}

/* Corresponding author links (Hover state) */
.corresponding-author a:hover {
    color: #276419 !important;
    text-decoration: underline;
    font-style: italic;
    font-weight: bold;
}

/* Ensure the container is normal (non-italicised) */
.corresponding-author address {
    font-size: 1rem;     /* Slightly smaller for hierarchy */
    font-style: normal;
    font-family: var(--paper-font); /* Inherits your unified Helvetica stack */
    display: flex;
    justify-content: center;
    width: 100%;
    margin-top: 1px;
}

/* Make only the email link italicised */
.corresponding-author address a {
    font-style: italic;
    color: var(--text-color); /* Matches your document's base color */
    text-decoration: none;
    padding-left: 4px;
}

/* Hover effect for the email */
.corresponding-author address a:hover {
    color: #276419 !important;
    text-decoration: underline;
    font-weight: bold;
}

/* Affiliations container */
.affiliations {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    margin-top: 0.5rem;
    gap: 0.1rem;
}

/* Address text properties */
.affiliations address {
    font-size: 0.8rem;
    max-width: 80%;
    line-height: 1.1;
    font-style: normal;
}

/* Unified hover and JavaScript-active states */
.affiliations a:hover,
.affiliations a.active-affiliation {
    color: #d01c8b !important;
    text-decoration: underline;
    font-style: italic;
    font-weight: bold;
}

/* Author names (Base state) */
.author-dropdown {
    position: relative;
    display: inline-block;
    cursor: pointer;
    color: #000000; 
    text-decoration: none;
    outline: none;
}

/* Author names (Hover state) */
.author-dropdown:hover {
    color: #276419;
    text-decoration: underline;
    font-style: italic;
    font-weight: bold;
}

/* Dropdown container */
.dropdown-content {
    display: none;
    position: absolute;
    background-color: #ffffff;
    min-width: 140px;
    box-shadow: 0px 4px 8px rgba(0,0,0,0.1);
    z-index: 10;
    border: 1px solid #d1d1ca;
    border-radius: 4px;
    text-align: left;
    top: 100%;
    left: 0;
}

/* Reveal dropdown on click/focus */
.author-dropdown:focus .dropdown-content,
.author-dropdown:focus-within .dropdown-content {
    display: block;
}

/* Dropdown links (Base state) - Resets inheritance from parent hover */
.dropdown-content a {
    color: #333333;
    padding: 8px 12px;
    text-decoration: none;
    display: block;
    font-family: 'Nimbus Sans', sans-serif;
    font-size: 14px;
    font-style: normal;
    font-weight: normal;
}

/* Dropdown links (Hover state) */
.dropdown-content a:hover {
    background-color: #f1b6da;
    color: #000000;
}

/* -- SPLIT HOVER COLOURS FOR AUTHORS AND SUPERSCRIPTS -- */

/* 1. Base state for the superscript links */
.author-dropdown a[href^="#aff"] {
    color: inherit;            /* Starts black, blending with the name */
    text-decoration: none;     /* Prevents standard link underlines */
}

/* 2. When the main author block is hovered: 
      The name turns green (via your existing rule), 
      BUT we force the superscript links to turn magenta */
.author-dropdown:hover a[href^="#aff"] {
    color: #d01c8b !important; /* Overrides the green inherited from the name */
    font-style: normal;        /* Keeps the number upright while the name goes italic */
    display: inline-block;     /* Prevents the name's underline from striking through the number */
}

/* 3. When hovering explicitly over the superscript number itself */
.author-dropdown a[href^="#aff"]:hover {
    font-weight: 900;
    transform: scale(1.15);    /* Adds a subtle 'pop' so you know it's a separate button */
    transition: transform 0.2s ease;
}

/* General link styles */
a {
    text-decoration: none;
    color: inherit;
}

/* Reference links (italic, not bold) */
.introduction a[href^="#ref"],
.results a[href^="#ref"],
.discussion-section a[href^="#ref"],
.methods-section a[href^="#ref"] {
    font-style: italic;
    font-weight: normal; /* Not bold */
}

/* Hover effect for reference links */
.introduction a[href^="#ref"]:hover,
.results a[href^="#ref"]:hover,
.discussion-section a[href^="#ref"]:hover,
.methods-section a[href^="#ref"]:hover {
    color: #d01c8b !important;
    text-decoration: underline;
    font-style: italic;
    font-weight: bold; /* Keep normal weight */
}


/* --- GLASSMORPHISM SECTION HEADINGS --- */

.glass-heading {
    position: relative;
    padding: 1rem 1rem;
    margin-top: 1rem;
    margin-bottom: 1rem;
    color: #ffffff;
    font-size: 2rem;
    font-weight: bold;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.7);
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
    overflow: hidden;
    z-index: 1;
    text-align: left; 
    width: 100%;             /* Fits exactly within your text column */
    margin: 3rem auto 2rem auto; /* Centers the box itself, with top/bottom spacing */
    box-sizing: border-box;  /* Ensures padding doesn't push it off-center */
}

/* The blurred image background */
.glass-heading::before {
    content: "";
    position: absolute;
    top: -40px; 
    left: -40px; 
    right: -40px; 
    bottom: -40px;
    background-image: url('../images/landing_img.png');
    background-position: center; /* Ensures the central region is captured */
    background-size: cover;
    filter: blur(12px) brightness(1); /* Frosted and darkened */
    z-index: -1;
}

/* Adding the glass sheen over the top */
.glass-heading::after {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, rgba(255,255,255,0.2) 0%, rgba(255,255,255,0) 100%);
    z-index: -1;
    pointer-events: none;
}

/* Subheading Style (H3) */
section h3 {
    position: relative;
    font-size: 1.4rem;
    color: var(--text-color);
    margin-top: 2.5rem;
    margin-bottom: 1rem;
    padding: 0.5rem 1rem;
    font-weight: bold;
    text-align: left;
    
    /* Left anchor line using the palette green */
    border-left: 4px solid #a6d96a; 
    
    /* Subtle fade-out background using the same green, heavily transparent */
    background: linear-gradient(90deg, rgba(166, 217, 106, 0.15) 0%, rgba(255, 255, 255, 0) 100%);
    border-radius: 0 8px 8px 0; 
}



/* Research figures */
.results-section {
    /* width: 100%; */
    max-width: var(--paper-width);
    margin: 2em auto;
    padding: 0;
    overflow: visible;
    position: relative;
}

.results-text p {
    margin-bottom: 1.2em;
}

/* Links within results text */
.results-text a {
    text-decoration: none;
    font-weight: bold;
}

.results-text a:hover {
  color: #d01c8b !important;

    text-decoration: underline;
    font-style: italic;

}

/* 1. Base anchor wrapper */
.methods-section-link {
    position: relative;
    display: inline-block; 
    width: 100%;
    text-decoration: none;
}

/* Ensure images fill the new anchor wrapper naturally */
.methods-section-link img {
    display: block;
    width: 100%;
    height: auto;
    margin: 0;
}

/* 2. Apply the 'swish' overlay using a pseudo-element */
.methods-section-link::after {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: transparent;
    border-radius: 2px;
    border: 2px solid transparent;
    box-sizing: border-box;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    pointer-events: none; 
}

/* 3. Hover states on the pseudo-element (Magenta tone) */
.methods-section-link:hover::after {
    background: linear-gradient(135deg, rgba(208, 44, 145, 0.02) 0%, rgba(208, 44, 145, 0.12) 100%);
    border-color: rgba(208, 44, 145, 0.4);
    box-shadow: inset 0 0 20px rgba(208, 44, 145, 0.15);
}

/* 4. Restore specific F1A/F1D layout constraints to the new anchor wrapper */
.F1A-container .methods-section-link,
.F1D-container .methods-section-link {
    width: 98%;
    margin: 2% auto;
    display: block;
}


/********* FIGURE 1 STYLES ************/

/* Main grid: 3 columns, 4 rows (A spans top, 3x3 image grid, H spans bottom) */
.F1-container {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: auto auto auto auto;
    gap: 5px;
    width: 100%;
    max-width: var(--paper-width);
    margin: 0 auto;
}

/* All images scale to fit their cell */
.F1-container img {
    max-width: 100%;
    height: auto;
    display: block;
}

/* Row 1: Panel A spans full width */
#F1A {
    grid-column: 1 / -1;
    grid-row: 1;
}

/* Row 2: Panels B, C, D — one per column */
#F1B { grid-column: 1; grid-row: 2; }
#F1C { grid-column: 2; grid-row: 2; }
#F1D { grid-column: 3; grid-row: 2; }

/* Row 3: Panels E, F, G — one per column */
#F1E { grid-column: 1; grid-row: 3; }
#F1F { grid-column: 2; grid-row: 3; }
#F1G { grid-column: 3; grid-row: 3; }

/* Row 4: Panel H (interactive plot) spans full width */
#F1H {
    grid-column: 1 / -1;
    grid-row: 4;
    display: flex;
    flex-direction: column;
}

/* Panels with click-to-zoom or overlay links need relative positioning */
.F1A-container,
.F1B-container,
.F1C-container,
.F1D-container,
.F1F-container {
    position: relative;
}

/* Panels with images that need slight inset for visual breathing room */
.F1A-container img,
.F1D-container img {
    width: 98%;
    margin: 2% auto;
}

/* Click-to-zoom cursors */
.F1B-container img,
.F1C-container img,
.F1F-container img {
    cursor: pointer !important;
}



/* Force the plot container to have height */
#plot-1H {
    min-height: 300px;
    width: 100%;
    display: block;
}

/********* FIGURE 2 STYLES ************/

/* --- Outer Container (Matches text width) --- */
.F2-container {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 0px;
    margin-bottom: 0em;
}

/* --- The Row Wrapper --- */
.F2-pair-container {
    display: grid;
    width: 100%;
    align-items: center;
    grid-template-columns: 1fr; 
    gap: 15px;
}

/* --- DESKTOP LAYOUT --- */
@media (min-width: 768px) {
    .F2-pair-container {
        grid-template-columns: 1.8fr 1.3fr; 
        column-gap: 10px;
    }
}

/* --- Plot Containers (Right Side) --- */
.F2-growth-plot {
    width: 100%;
    height: 300px; 
    min-height: 300px;
    position: relative;
    margin-top: 0;
}


/* --- Image Containers (Left Side) --- */
.F2A-container,
.F2B-container,
.F2C-container {
    width: 100%;
    position: relative;
    display: flex;
    justify-content: center;
}

/* Force images to fill their 2/3rds column */
.F2A-container img,
.F2B-container img,
.F2C-container img {
    width: 100%;
    height: auto;
    max-height: 400px; /* Prevent them from getting excessively tall */
    object-fit: contain;
    display: block;
}


/* --- Figure 2D (Bottom Boxplot) --- */
.F2D-container {
    display: flex;
    position: relative;
    width: 100%;
    margin-top: 10px;
}

.F2D-container .vertical-caption-container {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    display: flex;
    flex-direction: row;
}

.F2D-container .caption {
    font-weight: bold;
    font-size: 26px;
    margin-right: 10px;
}

.F2D-container .vertical-line {
    width: 3px;
    background-color: black;
    height: 100%;
}

.F2D-boxplot {
    width: calc(100% + 40px) !important;
    margin-left: -20px !important;
    min-height: 350px;
    overflow: visible;
}

/********* FIGURE 3 STYLES ************/

/* Figure 3 Main Grid Container */
.F3-container {
  display: grid;
  grid-template-columns: 1.5fr 1fr; /* Allocates more space to C, less to D */
  gap: 20px;
  width: 100%;
  align-items: stretch; /* Forces C and D to match height */
}

/* Full-width rows for A and B */
.F3A-container, 
.F3B-container {
  grid-column: 1 / -1; /* Spans across all columns */
  width: 100%;
  height: auto;
}

/* Shared row containers for C and D */
.F3C-container, 
.F3D-container {
  display: flex;
  flex-direction: column;
  position: relative;
  width: 100%;
  height: auto;
  min-width: 0; /* Prevents flexbox overflow */
}

/* Universal Image Styling for F3 */
.F3-container img {
  width: 100%;
  height: 100%;
  max-width: 100%;
  object-fit: contain; /* Prevents distortion whilst stretching */
  border-radius: 2px;
}

#F4.F4-container {
  display: grid !important;
  grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
  gap: 4px;
  width: 100% !important;
}

#F4A.F4A-container {
  grid-column: 1 / -1 !important;
}

#F4 .image-popup {
  display: none; /* Ensure popups are not artificially widening the grid */
}

.F4-container img {
  width: 100% !important;
  max-width: 100% !important;
  height: auto !important;
  object-fit: contain;
}

/* F4 B/C/D: click-to-zoom positioning and cursor */
.F4B-container,
.F4C-container,
.F4D-container {
    position: relative;
}

.F4B-container img,
.F4C-container img,
.F4D-container img {
    cursor: pointer !important;
}
/********* SUPPLEMENTARY FIGURE S1 STYLES ************/

.S1-container {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 20px;
    width: 100% !important;
    align-items: start;
}

/* Force A, B, C, and D to span both columns */
.S1A-container,
.S1B-container,
.S1C-container,
.S1D-container {
    grid-column: 1 / -1 !important;
    width: 100%;
    height: auto;
}

/* Explicitly place E, F, G, H in their respective 2-column rows */
.S1E-container { grid-column: 1 !important; }
.S1F-container { grid-column: 2 !important; }
.S1G-container { grid-column: 1 !important; }
.S1H-container { grid-column: 2 !important; }

/* Keep containers constrained */
.S1-container > div {
    display: flex;
    flex-direction: column;
    position: relative;
    width: 100%;
    height: auto;
    min-width: 0 !important;
}

/* Image constraints */
.S1-container img {
    width: 100% !important;
    max-width: 100% !important;
    height: auto !important;
    object-fit: contain;
    border-radius: 2px;
}

/********* SUPPLEMENTARY FIGURE S2 STYLES ************/

.S2-container {
    display: grid !important;
    grid-template-columns: 1fr !important; /* Single column layout */
    gap: 40px; /* Slightly larger gap for clear separation between large vertical panels */
    width: 100% !important;
    align-items: start;
}

/* Container constraints */
.S2A-container,
.S2B-container {
    display: flex;
    flex-direction: column;
    position: relative;
    width: 100%;
    height: auto;
    min-width: 0 !important;
}

/* Image constraints */
.S2-container img {
    width: 100% !important;
    max-width: 100% !important;
    height: auto !important;
    object-fit: contain;
    border-radius: 2px;
}

/********* SUPPLEMENTARY FIGURE S3 STYLES ************/
.S3-container {
    display: block !important; /* No grid needed for a single element */
    width: 100% !important;
    position: relative;
    margin-bottom: 40px; /* Space before S4 */
}

/* Image constraints */
.S3-container img {
    width: 100% !important;
    max-width: 100% !important;
    height: auto !important;
    object-fit: contain;
    border-radius: 2px;
}

/********* SUPPLEMENTARY FIGURE S4 STYLES ************/

.S4-container {
    display: grid !important;
    grid-template-columns: 1fr !important; /* Single column vertical stack */
    gap: 40px; 
    width: 100% !important;
    align-items: start;
    margin-bottom: 40px;
}

/* Container constraints */
.S4A-container,
.S4B-container {
    display: flex;
    flex-direction: column;
    position: relative;
    width: 100%;
    height: auto;
    min-width: 0 !important;
}

/* Image constraints */
.S4-container img {
    width: 100% !important;
    max-width: 100% !important;
    height: auto !important;
    object-fit: contain;
    border-radius: 2px;
}

/********* SUPPLEMENTARY FIGURE S3 STYLES ************/
.S5-container {
    display: block !important; /* No grid needed for a single element */
    width: 100% !important;
    position: relative;
    margin-bottom: 40px; /* Space before S4 */
}

/* Image constraints */
.S5-container img {
    width: 100% !important;
    max-width: 100% !important;
    height: auto !important;
    object-fit: contain;
    border-radius: 2px;
}

/********* SUPPLEMENTARY FIGURE S6 STYLES ************/

.S6-container {
    display: grid !important;
    grid-template-columns: 2.5fr 1fr !important; /* Forces the 75% / 25% split for B and C */
    gap: 20px;
    width: 100% !important;
    align-items: start; /* Prevents vertical stretching distortion between asymmetric columns */
    margin-bottom: 40px;
}

/* Force A to span across the top of both columns */
.S6A-container {
    grid-column: 1 / -1 !important;
    width: 100%;
    height: auto;
}

/* Explicit placement for B and C in the second row */
.S6B-container {
    grid-column: 1 !important;
    display: flex;
    flex-direction: column;
    position: relative;
    width: 100%;
    min-width: 0 !important;
}

.S6C-container {
    grid-column: 2 !important;
    display: flex;
    flex-direction: column;
    position: relative;
    width: 100%;
    min-width: 0 !important;
}

/* Constrain images to respect the grid boundaries */
.S6-container img {
    width: 100% !important;
    max-width: 100% !important;
    height: auto !important;
    object-fit: contain;
    border-radius: 2px;
}

/********* SUPPLEMENTARY FIGURE S7 STYLES ************/

.S7-container {
    display: grid !important;
    grid-template-columns: 1fr !important; /* Single column vertical stack */
    gap: 40px; 
    width: 100% !important;
    align-items: start;
    margin-bottom: 40px;
}

/* Container constraints for all 5 panels */
.S7A-container,
.S7B-container,
.S7C-container,
.S7D-container,
.S7E-container {
    display: flex;
    flex-direction: column;
    position: relative;
    width: 100%;
    height: auto;
    min-width: 0 !important;
}

/* Image constraints */
.S7-container img {
    width: 100% !important;
    max-width: 100% !important;
    height: auto !important;
    object-fit: contain;
    border-radius: 2px;
}

/********* SUPPLEMENTARY FIGURE S8 STYLES ************/
/* 1. The Main Container */
.S8-container {
    display: grid !important;
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important; 
    /* row-gap: 2px, column-gap: 4px */
    gap: 4px 2px !important; 
    width: 100% !important;
    align-items: start;
    margin-bottom: 40px;
}

/* 2. Full-width Headers A and B */
.S8A-container,
.S8B-container {
    grid-column: 1 / -1 !important;
    width: 100%;
    height: auto;
    position: relative;
}

/* 3. Grid Items C through H */
.S8C-container,
.S8D-container,
.S8E-container,
.S8F-container,
.S8G-container,
.S8H-container {
    display: flex;
    flex-direction: column;
    position: relative;
    width: 100%;
    height: auto;
    min-width: 0 !important;
    /* Pulls this second row closer to the B panel above it */
    margin-top: 1px; 
}

/* 4. Image Constraints */
.S8-container img {
    width: 100% !important;
    display: block;
    height: auto !important;
    object-fit: contain;
    border-radius: 2px;
}


/********* CAPTION STYLES ************/
.horizontal-caption-container {
    display: flex;
    flex-direction: column; /* Stack caption and line vertically */
    align-items: flex-start; /* Align items to the left */
    margin-bottom: 5px; /* Space between the line and the plot */
}

.horizontal-caption-container .caption {
    font-weight: bold;
    font-size: 20px;
    margin-bottom: 3px; /* Space between the caption and the line */
}

.horizontal-line {
    width: 100%; /* Make the line extend the full width of the container */
    height: 2px; /* Thickness of the line */
    background-color: black; /* Color of the line */
}

/* Specific override for Figure 1A tight cropping */
#F1A .horizontal-caption-container {
    margin-bottom: 30px; /* Adjust this value until the line clears the image content */
}

/* =========================================
   GENERIC POP UP STYLES (Flexbox Centering)
   ========================================= */

/* 1. Base Popup Container */
.image-popup, 
.video-popup {
    /* Hidden by default; JS will set this to 'flex' */
    display: none; 
    position: fixed;
    z-index: 10000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    
    /* This centers the content perfectly without 'transform' side effects */
    justify-content: center;
    align-items: center;
    
    background-color: rgba(0, 0, 0, 0.95);
}

/* 2. The Close Button — Keynote-style subtle pill */
.close-popup {
    position: fixed;
    top: 24px;
    right: 24px;
    
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.12);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.15);
    
    color: rgba(255, 255, 255, 0.7);
    font-size: 20px;
    font-weight: 300;
    line-height: 34px;
    text-align: center;
    
    cursor: pointer !important;
    z-index: 10005;
    pointer-events: auto;
    
    opacity: 0;
    transition: opacity 0.3s ease, background 0.2s ease, color 0.2s ease;
}

.image-popup:hover .close-popup,
.video-popup:hover .close-popup {
    opacity: 1;
}

.close-popup:hover {
    background: rgba(255, 255, 255, 0.25);
    color: #ffffff;
}



/* 3. Content Wrapper */
.popup-content,
.video-container {
    /* No absolute positioning needed - Flexbox parent handles centering */
    position: relative; 
    width: auto;
    height: auto;
    max-width: 90vw;
    max-height: 90vh;
    
    display: flex;
    justify-content: center;
    align-items: center;
    
    background: transparent;
    pointer-events: none; /* Let clicks pass through to background */
}

/* 4. Media Elements */
.zoomable-image,
.popup-video {
    width: auto;
    height: auto;
    max-width: 90vw;
    max-height: 90vh;
    object-fit: contain;
    
    pointer-events: auto; /* Re-enable clicks */
    transform-origin: center center; 
}

.hover-preview-wrapper {
    position: fixed;
    z-index: 9999;
    pointer-events: none;
    background: rgba(0,0,0,0.8);
    color: white;
    padding: 6px 10px;
    border-radius: 4px;
    font-size: 13px;
    font-family: sans-serif;
    white-space: nowrap;
}

/* --- Special Styling for Figure 2D/4B Hover Tooltip --- */
/* This targets ONLY the interactive plot hover video, nothing else */
#video-tooltip {
    /* Keep width the same (250px) but double the height */
    width: 750px !important;
    height: auto !important;     /* Let height adjust automatically */
    aspect-ratio: 1696 / 750;    /* Precision ratio derived from your file */
    object-fit: cover;

    /* Ensure placement logic remains solid */
    position: fixed;
    z-index: 10000; /* Stays on top of everything */
    
    /* Styling to match your theme */
    background: black;
    border: 2px solid white;
    border-radius: 4px;
    box-shadow: 0 10px 20px rgba(0,0,0,0.5);
    
    /* Functional properties */
    overflow: hidden;
    pointer-events: none; /* Ignore mouse clicks so it doesn't block the plot */
}

/* Ensure the video fills this new tall container */
#video-tooltip video {
    width: 100%;
    height: 100%;
    /* 'cover' fills the tall box (cropping sides). 
       Change to 'contain' if you want to see the whole video with black bars. */
    object-fit: cover; 
}


/********* SUPPLEMENTARY TABLES & TOOLTIP STYLES ************/

/* Shared Typography */
.supplementary-tables-container, 
#table-tooltip {
    font-family: 'Helvetica', 'Helvetica Neue', Arial, sans-serif;
    color: #333;
}

/* Static Container (Keynote Aesthetic) */
.table-placeholder {
    overflow-x: auto;
    margin-bottom: 15px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
    border-radius: 8px;
    border: 1px solid #d1d1ca;
    background-color: #fff;
}

/* Tooltip Container */
#table-tooltip {
    position: fixed;
    display: none;
    z-index: 10001;
    background: white;
    border: 1px solid #d1d1ca;
    padding: 16px;
    border-radius: 8px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.2);
    pointer-events: none;
    max-width: 600px; /* Slightly widened to prevent data wrapping */
}

/* Tooltip Specific Title */
#table-tooltip .table-title {
    font-weight: 600;
    margin-bottom: 12px;
    color: #d02c91; 
    display: block;
    font-size: 14px;
}

/* Shared Table Core Styles */
.supplementary-table, 
#table-tooltip table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    white-space: nowrap; /* Keeps data concise and aligned */
}

/* Shared Headers */
.supplementary-table th, 
#table-tooltip th {
    background-color: #fbfbfb;
    color: #222;
    font-weight: 600;
    padding: 12px 16px;
    border-bottom: 2px solid #978897; 
}

/* Shared Data Cells */
.supplementary-table td, 
#table-tooltip td {
    padding: 10px 16px;
    border-bottom: 1px solid #d1d1ca;
    color: #444;
    font-size: 0.9rem;
}

/* Clean Bottom Edges */
.supplementary-table tbody tr:last-of-type td,
#table-tooltip tr:last-child td {
    border-bottom: none; 
}

/* Static Hover State (Tooltip relies on pointer-events: none, so hover will not trigger there) */
.supplementary-table tbody tr:hover {
    background-color: #fcfcfc; 
}

/* Section Headers & Captions (Static specific) */
.supplementary-tables-container h3 {
    font-weight: 600;
    font-size: 18px;
    margin-top: 40px;
    margin-bottom: 15px;
    color: #111;
}

.supplementary-tables-container figcaption {
    font-size: 14px;
    line-height: 1.6;
    color: #555;
    margin-bottom: 50px; 
    padding: 0 5px;
}



/********* CAPTION STYLES ************/
figcaption {
    display: block;
    font-family: 'Helvetica', 'Helvetica Neue', Arial, sans-serif;
    /* Matching .toc-h3: clamp(0.65rem, 1.5vw, 0.85rem) */
    font-size: clamp(0.65rem, 1.5vw, 0.85rem);
    line-height: 1.6;
    color: #333333;
    background-color: #fcfcfcbe;
    border-left: 5px solid #d01c8b;
    padding: 1rem;
    margin: 2rem 0;
}

figcaption p {
    margin-top: 0;
    margin-bottom: 0.0rem;
    font-size: 1rem; 
    color: #000000;
}

/* Ensure the bold title scales identically */
figcaption p:first-of-type b {
    font-size: 1.rem;
    color: #000000;
}

.references {
    font-size: 0.8rem;
    line-height: 1.4;
    color: #555;
}
/********* BACK-MATTER STYLES ************/
.back-matter-content {
    font-size: 0.9rem;
    line-height: 1.4;
    color: #555;
}

.back-matter-content .acknowledgements,
.back-matter-content .author-contributions,
.back-matter-content .competing-interests {
    margin-bottom: 1.5rem;
}

.back-matter-content .data-availability {
    margin-bottom: 3rem;
}

.back-matter-content .data-link {
    color: #d01c8b;
    text-decoration: underline;
}

/* ========= 3D FLIP CARD ========= back of title contents */

.title-card-flip-container {
    perspective: 2000px;
    width: 100%;
    aspect-ratio: 1 / 1;
    margin-bottom: 3rem;
    cursor: pointer;
}

.title-card-flipper {
    position: relative;
    width: 100%;
    height: 100%;
    transition: transform 0.8s cubic-bezier(0.4, 0.0, 0.2, 1);
    transform-style: preserve-3d;
}

.title-card-flip-container.flipped .title-card-flipper {
    transform: rotateY(180deg);
}

.title-card-front,
.title-card-back {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    border-radius: 24px;
    overflow: hidden;
}

.title-card-back {
    transform: rotateY(180deg);
}

/* Back face TOC styling */
.toc-overlay {
    top: 5% !important;
    transform: translate(-50%, 0) !important;
    max-height: 90% !important;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.3) transparent;
}

/* Hide the "scroll to continue" prompt on the back (TOC) face */
.toc-overlay::after {
    content: none;
}

.toc-heading {
    color: #ffffff;
    font-family: "Helvetica", "Nimbus Sans", sans-serif;
    font-size: clamp(1.2rem, 3.5vw, 2rem);
    font-weight: 800;
    letter-spacing: -0.02em;
    margin: 0 0 1rem 0;
    padding-bottom: 0.75rem;
    border-bottom: 2px solid rgba(166, 217, 106, 0.6);
    text-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

.toc-nav {
    display: flex;
    flex-direction: column;
    gap: 0;
    text-align: left;
}

.toc-nav a {
    color: #ffffff;
    text-decoration: none;
    font-family: "Helvetica Neue", Helvetica, sans-serif;
    line-height: 1.3;
    padding: 0.4rem 0.6rem;
    border-radius: 8px;
    transition: background 0.2s ease, color 0.2s ease;
    display: block;
    text-shadow: 0 1px 4px rgba(0,0,0,0.4);
}

/* H2 entries */
.toc-nav a.toc-h2 {
    font-size: clamp(0.75rem, 1.8vw, 1rem);
    font-weight: 700;
    padding-left: 0.6rem;
    margin-top: 0.3rem;
}

/* H3 entries */
.toc-nav a.toc-h3 {
    font-size: clamp(0.65rem, 1.5vw, 0.85rem);
    font-weight: 400;
    padding-left: 1.4rem;
    color: rgba(255, 255, 255, 0.8);
    margin-left: 0.6rem;
    position: relative;
    border-left: none;
}

.toc-nav a.toc-h3::before {
    content: "";
    position: absolute;
    left: 0.2rem;
    top: 50%;
    width: 0.5rem;
    height: 1.5px;
    background-color: rgba(166, 217, 106, 0.5);
    transition: background-color 0.2s ease, width 0.2s ease;
}

.toc-nav a.toc-h3:hover::before {
    background-color: #a6d96a;
    width: 0.7rem;
}

/* --- INLINE TABLE EXPANSION --- */
.inline-table-wrapper {
    display: block; /* Forces the line break */
    width: 100%;
    margin: 1.5rem 0;
    padding: 1.5rem;
    background: #ffffff;
    border: 1px solid #d1d1ca;
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.08);
    overflow-x: auto;
    clear: both;
    animation: slideDown 0.3s ease-out;
}

.inline-table-close {
    float: right;
    font-size: 0.9rem;
    color: #d01c8b; /* Magenta accent */
    cursor: pointer !important;
    font-weight: bold;
    margin-bottom: 1rem;
}

.inline-table-close:hover {
    text-decoration: underline;
}

.inline-table-wrapper .table-placeholder {
    box-shadow: none;
    border: none;
    margin-bottom: 0;
}

@keyframes slideDown {
    from { opacity: 0; transform: translateY(-5px); }
    to { opacity: 1; transform: translateY(0); }
}

/* =========================================
   LIVE SIDEBAR TOC
   ========================================= */

.sidebar-toc {
    position: fixed;
    top: 60px;
    /* Dynamically places it to the left of the centered paper */
    left: max(20px, calc(50% - 4.25in - 260px)); 
    width: 220px;
    max-height: calc(100vh - 120px);
    background: transparent;
    display: none; /* Hidden by default on narrow screens */
    flex-direction: column;
    z-index: 100;
}

/* Animate the sidebar on wide screens */
@media (min-width: 1350px) {
    .sidebar-toc {
        display: flex; /* Ensure it's in the document flow to animate */
        opacity: 0;
        visibility: hidden; /* Prevents clicking when hidden */
        transform: translateX(-40px); /* Push it slightly to the left */
        
        /* The "Swish" transition parameters */
        transition: opacity 0.5s ease, 
                    transform 0.5s cubic-bezier(0.2, 0.8, 0.2, 1), 
                    visibility 0.5s;
    }

    .sidebar-toc.show-sidebar {
        opacity: 1;
        visibility: visible;
        transform: translateX(0); /* Settle into its final position */
    }
}

.sidebar-toc h4 {
    margin-top: 0;
    font-size: 1.1rem;
    color: var(--text-color);
    border-bottom: 2px solid #a6d96a; /* Green accent */
    padding-bottom: 0.5rem;
    margin-bottom: 1rem;
    font-family: 'Helvetica', sans-serif;
    font-weight: bold;
}

.sidebar-toc nav {
    overflow-y: auto;
    scrollbar-width: thin;
    display: flex;
    flex-direction: column;
}

.sidebar-toc a {
    font-size: 0.85rem;
    color: #777777;
    text-decoration: none;
    padding: 6px 0 6px 12px;
    margin-bottom: 2px;
    border-left: 2px solid transparent;
    transition: all 0.2s ease;
    line-height: 1.3;
    display: block;
    font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
}

.sidebar-toc a.toc-h3 {
    padding-left: 24px; /* Indent subheadings */
    font-size: 0.75rem;
    color: #999999;
}

.sidebar-toc a:hover {
    color: #d01c8b; /* Magenta */
    border-left-color: #f1b6da;
    background-color: rgba(241, 182, 218, 0.1);
}

/* Active State tracked by JS */
.sidebar-toc a.active {
    color: #d01c8b;
    border-left-color: #d01c8b;
    font-weight: bold;
    background-color: rgba(241, 182, 218, 0.1);
}

/* --- S8 SPECIFIC CONDENSED OVERLAYS --- */

/* Force the images together to align the visual zoom lines */
.S8-container {
    gap: 2px !important; 
}

/* The new absolute overlay */
.sf8-caption-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    z-index: 10;
    pointer-events: none; /* Ensures the image behind can still be clicked */
    padding: 2px; /* Adjust this to align with the baked-in white margins of your PNGs */
    box-sizing: border-box;
}

.sf8-caption-overlay .caption {
    font-weight: bold;
    font-size: 28px; /* Slightly larger to match standard panel labels */
    color: #ffffff; /* Changed to white */
    margin-bottom: 4px;
    line-height: 1;
    /* Adds a subtle dark glow so it pops against bright green/magenta tissue */
    text-shadow: 0px 2px 4px rgba(0, 0, 0, 0.8);
}

/* Force A and B to span across all 3 columns */
.S8A-container,
.S8B-container {
    grid-column: 1 / -1 !important;
    width: 100%;
    height: auto;
    position: relative; /* <-- Add this line */
}

/* --- SUPPLEMENTARY VIDEOS --- */
.supplementary-video {
    border-radius: 8px; 
    overflow: hidden; /* Ensures the video itself respects the curved border */
    display: block; /* Removes the tiny default gap underneath inline videos */
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1); /* Adds a subtle shadow to match the Keynote aesthetic */
}

/* --- EASTER EGG --- */
#easter-egg-njd {
    cursor: pointer;
    transition: color 0.3s ease;
    user-select: none; /* Prevents text highlighting when rapidly clicking */
}

#easter-egg-njd:hover {
    text-decoration: underline;
    text-decoration-style: dotted;
}

.zoomable-image-container {
    pointer-events: auto;
}

.zoomable-image {
    cursor: grab !important;
}

.zoomable-image-container.dragging .zoomable-image {
    cursor: grabbing !important;
}

/* =========================================
   MOBILE WARNING BANNER
   ========================================= */

.mobile-warning {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 99999;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    justify-content: center;
    align-items: center;
    padding: 2rem;
}

.mobile-warning-card {
    background: #ffffff;
    border-radius: 20px;
    padding: 2.5rem 2rem;
    max-width: 380px;
    width: 100%;
    text-align: center;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

/* .mobile-warning-icon { previous icon before ken
    font-size: 3rem;
    margin-bottom: 1rem;
} */
 .mobile-warning-icon {
    width: 80px;
    height: 80px;
    object-fit: cover;
    border-radius: 12px;
    margin: 0 auto 1rem auto;
    display: block;
}

.mobile-warning-card h2 {
    font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
    font-size: 1.4rem;
    font-weight: 700;
    color: #111;
    margin: 0 0 0.75rem 0;
}

.mobile-warning-card p {
    font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
    font-size: 0.95rem;
    color: #555;
    line-height: 1.5;
    margin: 0 0 0.5rem 0;
    text-align: center;
}

.mobile-warning-sub {
    font-size: 0.8rem !important;
    color: #999 !important;
    margin-top: 0.5rem !important;
}

.mobile-warning-btn {
    display: inline-block;
    margin-top: 1.25rem;
    padding: 0.7rem 2rem;
    font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
    font-size: 0.95rem;
    font-weight: 600;
    color: #ffffff;
    background: linear-gradient(135deg, #a6d96a, #1a9641);
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.mobile-warning-btn:hover {
    transform: scale(1.03);
    box-shadow: 0 4px 16px rgba(26, 150, 65, 0.3);
}

@media (max-width: 768px) {
    .mobile-warning {
        display: flex;
    }
}

.mobile-warning.dismissed {
    display: none !important;
}

.mobile-warning-btn-email {
    background: transparent;
    color: #555;
    border: 1.5px solid #d1d1ca;
    margin-top: 0.6rem;
}

.mobile-warning-btn-email:hover {
    border-color: #999;
    box-shadow: none;
    transform: none;
}