/* CSS Variables */
:root {
  /* Typography - Title Font Options */
  --title-font: "Noto Sans", sans-serif;
  
  /* Typography - Body Font Options */
  --body-font: "Noto Sans", sans-serif;
  
  /* UI Font */
  --ui-font: "Noto Sans", sans-serif;
  
  /* Author Font */
  --author-font: "Lato", sans-serif;
  
  /* Font sizes */
  --base-font-size: 16px;
  --h1-size: 2.5rem;
  --h2-size: 1.6rem;
  --h3-size: 1.3rem;
  --h4-size: 1.1rem;
  --body-size: 1rem;
  --small-text: 0.9rem;
  --author-size: 1rem;
  
  /* Colors */
  --text-color: #333;
  --background-color: #efefef;
  --content-bg: #efefef;
  --footer-bg: #f5f5f5;
  --author-text: #6c757d;
  --footer-text: #adb5bd;
  --sim-bg: #fff;
  --card-bg: white;
  --card-shadow: rgba(0, 0, 0, 0.1);
  
  /* UI Colors */
  --primary-btn: #3a86ff;
  --primary-btn-hover: #2a75ee;
  --danger-btn: #ef476f;
  --danger-btn-hover: #e02f5a;
  --control-bg: #f8f9fa;
  --border-color: #e5e5e5;
  
  /* Layout */
  --content-width: 800px;
  --content-padding: 2rem 1rem;
  --section-spacing: 2.5rem;
  --simulation-width: 95vw;
  --simulation-max-width: 1400px;
}

/* Base styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  background-color: var(--background-color);
  font-family: sans-serif;
  display: flex; /* Keep flex for column layout */
  flex-direction: column;
  padding: 20px; /* This padding might need adjustment later */
  font-size: var(--base-font-size);
  line-height: 1.5;
  overflow-x: hidden; /* Prevent horizontal scrolling */
  min-height: 120vh;
  margin: 0;
  padding: 0; /* Remove body padding */
  color: var(--text-color);
}

/* Typography */
h1, h2, h3, h4 {
  font-family: var(--title-font);
  line-height: 1.2;
  font-weight: 600;
}

h1 {
  font-size: var(--h1-size);
  margin-bottom: 1.2rem;
  margin-top: 2.5rem;
}

h2 {
  font-size: var(--h2-size);
  margin-top: var(--section-spacing);
  margin-bottom: 1.2rem;
}

h3 {
  font-size: var(--h3-size);
  margin-bottom: 1rem;
}

h4 {
  font-size: var(--h4-size);
  margin-bottom: 0.5rem;
  font-weight: 600;
}

p {
  font-family: var(--body-font);
  font-size: var(--body-size);
  line-height: 1.5;
  margin-bottom: 1rem;
  color: var(--text-color);
}

ul, ol {
  font-family: var(--body-font);
  font-size: var(--body-size);
  line-height: 1.5;
  color: var(--text-color);
  margin-bottom: 1.5rem;
  padding-left: 1.5rem;
}

li {
  margin-bottom: 0.5rem;
}

/* Author styling */
.author {
  margin: 0.8rem 0 1.5rem 0;
  font-family: var(--author-font);
  font-style: normal;
  font-weight: 400;
}

.author p {
  margin: 0;
  font-family: var(--author-font);
  color: var(--author-text);
  font-size: var(--author-size);
  margin-bottom: 4rem;
}

/* Content */
.content {
  max-width: var(--content-width);
  width: 100%; /* Ensure it takes up available width up to max-width */
  margin: 0 auto; /* Center the content block */
  padding: var(--content-padding);
  background-color: var(--content-bg);
  position: relative;
  overflow: visible;
}

.text-block {
  margin-bottom: 2rem;
}

/* Simulation section */
.simulation-container {
    background-color: var(--sim-bg);
    margin: 2rem 0;
    width: 100vw;
    position: relative;
    left: 50%;
    transform: translateX(-50%);
    padding: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Inner container to center the grid */
.simulation-inner {
    width: 90%;
    max-width: 1600px;
    min-width: 900px;
    margin: 0 auto;
    display: flex;
    justify-content: center;
    padding: 10px;
}

/* Three column layout */
.simulation-grid {
    display: grid;
    grid-template-columns: 250px 1fr 450px; /* Adjusted to match the width above */
    gap: 20px;
    height: 100%;
}



/* Controls column */
.controls-column {
    display: flex;
    flex-direction: column;
    gap: 15px;
    align-self: start;
}

/* Visualization columns */
.agent-pool-column, .histogram-column {
    height: 500px;
    overflow: hidden;
    align-self: center;
}

/* Agent pool column specific */
.agent-pool-column {
    width: 600px; /* Increased width */
    height: 600px; /* Increased height */
    position: relative; /* Make it a positioning context */
}

/* Histogram column specific */
.histogram-column {
    width: 450px; /* Changed from 400px to 450px */
    max-width: 100%;
    height: 500px;
    overflow: hidden;
}

/* SVG containers */
.agent-pool-visualization, 
.agent-pool-visualization svg,
.histogram-column svg {
    width: 100%;
    height: 100%;
}

/* Strategy selection */
.strategy-selection {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 15px;
}

.strategy-group {
  margin-bottom: 12px;
}

.strategy-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 3px;
}

.strategy-description {
  font-size: 0.85rem;
  color: #666;
  margin-top: 4px;
  margin-bottom: 0;
  min-height: 2em; /* Ensure consistent height even when empty */
}

/* Color indicator styling */
.color-indicator {
  display: none; /* Hide color indicators */
}

/* Proportion control styling */
.proportion-control-container {
  background-color: var(--control-bg);
  padding: 12px 15px;
  border-radius: 4px;
  margin-bottom: 15px;
}

.proportion-control-container h3 {
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: 10px;
}

.proportion-slider-container {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 8px;
}

.proportion-slider {
  flex: 1;
  height: 6px;
  border-radius: 3px;
  -webkit-appearance: none;
  appearance: none;
  outline: none;
  background: #ddd;
}

.proportion-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: white;
  border: 2px solid #577590;
  cursor: pointer;
}

.proportion-slider::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: white;
  border: 2px solid #577590;
  cursor: pointer;
}

.proportion-label {
  font-size: 12px;
  font-weight: bold;
  width: 40px;
  text-align: center;
}

/* Tournament parameters */
.tournament-params {
  background-color: var(--control-bg);
  padding: 12px 15px;
  border-radius: 4px;
  border: none;
}

.param-group {
  margin-bottom: 20px;
}

.param-group label {
  display: block;
  margin-bottom: 5px;
  font-weight: 600;
  font-size: 0.9rem;
}

.param-description {
  font-size: 0.8rem;
  color: #666;
  margin-bottom: 10px;
}

.slider-container {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.slider-container input[type="range"] {
  width: 100%;
  height: 6px;
  border-radius: 3px;
  -webkit-appearance: none;
  appearance: none;
  background: #ddd;
  outline: none;
  margin: 5px 0;
}

.slider-container input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: white;
  border: 2px solid #577590;
  cursor: pointer;
}

.slider-container input[type="range"]::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: white;
  border: 2px solid #577590;
  cursor: pointer;
}

.slider-minmax {
  display: flex;
  justify-content: space-between; /* Return to space-between for proportion slider */
  width: 100%;
}

/* Only hide min values for sliders other than proportion */
.param-group:not(:first-child) .slider-min {
  display: none; /* Hide min values for all except proportion slider */
  text-align: left;
  font-size: 12px;
}

/* For proportion slider specifically */
.param-group:first-child .slider-min {
  display: block; /* Show for proportion slider */
  text-align: left;
  font-size: 12px;
}

.slider-max {
  text-align: right;
  font-size: 12px;
}

/* Button styling */
.button-group {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  justify-content: space-between;
  gap: 10px;
  margin-top: 20px;
}

.button-group button {
  flex: 1;
  padding: 8px 10px;
  border: none;
  border-radius: 4px;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  transition: background-color 0.2s, transform 0.1s;
}

#start-tournament {
  background-color: var(--primary-btn);
  color: white;
}

#start-tournament:hover:not(:disabled) {
  background-color: var(--primary-btn-hover);
}

#stop-tournament {
  background-color: var(--danger-btn);
  color: white;
}

#stop-tournament:hover:not(:disabled) {
  background-color: var(--danger-btn-hover);
}

#reset-visualization {
  background-color: #f8f9fa;
  border: 1px solid #ddd;
  color: #333;
}

#reset-visualization:hover {
  background-color: #e9ecef;
}

/* Button disabled state */
button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  border-color: #ddd; /* Gray border for disabled state */
}

/* Form controls styling */
select {
  padding: 8px 12px;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  background-color: white;
  font-family: var(--ui-font);
  font-size: 0.9rem;
  color: var(--text-color);
  width: 100%;
  max-width: 100%;
  cursor: pointer;
  outline: none;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
  height: 62px; /* Increased height to fit two lines by default */
  /* Custom select styling for flat, minimalist appearance */
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='14' height='8' fill='none' stroke='%23666' stroke-width='1.5'><path d='M1,1 L7,7 L13,1' /></svg>");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 30px;
  white-space: normal; /* Allow text to wrap */
}

select:focus {
  border-color: var(--primary-btn);
}

select option {
  padding: 12px;
  font-size: 0.9rem;
  line-height: 1.5;
  min-height: 62px; /* Match the height of the select */
  white-space: normal;
  text-align: left;
}

select option::before {
  content: attr(value);
  display: inline;
  font-weight: 600;
}

/* Style for strategy name and description in dropdowns */
.strategy-name {
  display: block;
  font-weight: 600;
  margin-bottom: 6px;
}

.strategy-desc {
  display: block;
  font-size: 0.8rem;
  color: #999;
  font-style: italic;
}

/* Running indicator */
#running-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #adb6c4;
  font-weight: bold;
  font-size: 13px;
  font-family: var(--ui-font);
  position: absolute;
  bottom: 15px;
  right: 15px;
  background-color: rgba(255, 255, 255, 0.8);
  padding: 6px 12px;
  border-radius: 4px;
  z-index: 100;
}

#running-indicator.hidden {
  display: none;
}

.spinner {
  width: 14px;
  height: 14px;
  border: 2px solid rgba(173, 182, 196, 0.3);
  border-top-color: #adb6c4;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Strategy node styling */
.strategy circle {
  cursor: pointer;
  transition: r 0.3s ease-out, stroke-width 0.3s ease-out;
}

.strategy circle:hover {
  stroke-width: 3px;
  stroke: #fff;
}

.strategy text {
  pointer-events: none;
  font-family: var(--ui-font);
}

.matchup-line {
  pointer-events: none;
}

/* Agent pool styling */
.agent {
  transition: r 0.3s ease-out;
  cursor: pointer;
}

.agent:hover {
  opacity: 0.9;
}

/* Histogram styling */
.histogram-area {
  transition: d 0.3s ease-out;
}

.histogram-area:hover {
  opacity: 0.8;
}

.histogram-line {
  transition: d 0.3s ease-out;
  pointer-events: none;
}

/* Axis styling */
.x-axis path,
.x-axis line,
.y-axis path,
.y-axis line {
  stroke: #ccc;
  stroke-width: 1px;
}

.x-axis text,
.y-axis text {
  font-size: 11px;
  fill: #666;
  font-family: var(--ui-font);
}

.x-axis-label,
.y-axis-label {
  font-size: 12px;
  fill: #333;
  font-family: var(--ui-font);
}

/* Legend styling */
.legend-item text {
  fill: #333;
  font-family: var(--ui-font);
  font-size: 12px;
}

/* Grid lines */
.grid-line {
  stroke: #eee;
  stroke-width: 1;
}

/* Y-axis labels */
.left-y-label, .right-y-label {
  font-size: 10px;
  fill: #777;
  font-family: var(--ui-font);
}

/* Winner styles */
.winner-label {
  font-size: 13px;
  text-align: center;
  color: var(--primary-btn);
  text-transform: uppercase;
  letter-spacing: 1px;
  font-family: var(--ui-font);
  font-weight: bold;
}

/* Strategy name and total score text */
.strategy-name-label, .strategy-label {
  font-family: var(--ui-font);
  font-size: 15px !important;
}

.total-score, .avg-score {
  font-family: var(--ui-font);
  font-size: 12px !important;
}
.section-divider {
    border: 0;
    height: 1px;
    background-color: var(--footer-text);
    opacity: 0.3;
    margin: 4rem auto;
    width: 100%;
    max-width: var(--content-width);
}

/* More Stories section */
.more-stories {
    background: var(--background-color);
    padding: var(--section-spacing) 0;
    margin-top: 4rem;
    width: 100%;
}

.more-stories .content {
    max-width: 100%;
    padding: 0 2rem;
    background-color: transparent;
}

.stories-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 2rem;
    margin-top: 2rem;
    max-width: 1200px;
    margin-left: auto;
    margin-right: auto;
    align-items: start;
}

.story-card-link {
    text-decoration: none;
    color: inherit;
    display: block;
}

.story-card {
    background: var(--card-bg);
    overflow: hidden;
    border: 1px solid #eaeaea;
    display: flex;
    flex-direction: column;
    height: auto;
}

.story-card img {
    width: 100%;
    height: auto;
    display: block;
    object-fit: cover;
    background-color: #000;
}

.story-card-content {
    padding: 1rem;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

.story-card h4 {
    font-size: var(--h4-size);
    margin: 0 0 0.5rem 0;
    font-weight: 600;
}

.story-card p {
    margin: 0;
    font-size: var(--small-text);
    color: var(--footer-text);
}

/* Center the "More Stories" heading */
.more-stories h3 {
  text-align: center;
  margin-bottom: 1.5rem;
}

/* Footer */
.footer {
  /* Keep this to ensure it spans the viewport */
  width: 100%;
  /* Restore original styling from reference */
  min-height: 20vh;
  background-color: var(--footer-bg);
  margin-top: 4rem; /* Use margin from reference */
  padding: 2rem 0; /* Use padding from reference */
  /* Remove border and text-align */
  /* border-top: 1px solid var(--border-color); */
  /* text-align: center; */
}

.footer .container {
  /* Keep these for alignment with main content */
  max-width: var(--content-width);
  margin: 0 auto;
  padding: 0 1rem; /* Use padding from reference */
  /* Restore text color */
  color: var(--footer-text);
  /* Remove flex properties to revert to default block layout */
  /* display: flex; */
  /* justify-content: space-between; */
  /* align-items: center; */
}

/* Add specific styles for footer paragraphs from reference */
.footer p {
  margin-bottom: 1rem;
  color: var(--footer-text);
  font-family: var(--ui-font); /* Assuming --ui-font is desired */
  font-size: 1rem;
  /* Ensure text aligns left within the container */
  text-align: left;
}

/* Add specific styles for footer links from reference */
.footer a {
  color: var(--footer-text);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: border-bottom-color 0.2s ease-in-out;
}

.footer a:hover {
  border-bottom-color: var(--footer-text);
}

/* Media queries for responsive layout */
@media (max-width: 1024px) {
    /* Tablet layout - stack in 2 rows */
    .simulation-grid {
        grid-template-columns: minmax(auto, 400px) 1fr;
        grid-template-areas:
            "controls simulation"
            "histogram histogram";
        gap: 20px;
    }
    
    .controls-column {
        grid-area: controls;
    }
    
    .agent-pool-column {
        grid-area: simulation;
        width: 100%;
        max-width: 600px;
        height: 600px;
    }
    
    .histogram-column {
        grid-area: histogram;
        width: 100%;
        height: 400px;
    }
}

@media (max-width: 768px) {
    /* Mobile layout - stack vertically */
    .simulation-grid {
        grid-template-columns: 1fr;
        grid-template-areas:
            "controls"
            "simulation"
            "histogram";
    }
    
    .simulation-inner {
        min-width: auto;
        width: 95%;
    }
    
    .agent-pool-column {
        width: 100%;
        height: 500px;
    }
    
    .histogram-column {
        width: 100%;
        height: 400px;
    }
}

@media (max-width: 480px) {
    /* Small mobile adjustments */
    .simulation-container {
        padding: 1rem;
    }
    
    .simulation-inner {
        padding: 5px;
    }
    
    .simulation-grid {
        gap: 15px;
    }
}

/* Position the running indicator inside the agent-pool-column */
.agent-pool-column {
    position: relative; /* Make it a positioning context */
}

/* Add styles for disabled sliders and buttons */
input[type="range"]:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background-color: #ccc;
}

/* Style for the disabled slider labels */
.param-group:has(input:disabled) .param-description,
.param-group:has(input:disabled) label,
.param-group:has(input:disabled) .slider-minmax {
    opacity: 0.5;
}

/* Citation styling */
.citation {
    font-size: 0.9rem;
    color: #666;
    margin: 2rem 0;
    padding-top: 1rem;
    border-top: 1px solid #eee;
}

.citation a {
    color: #3a86ff;
    text-decoration: none;
    font-weight: 500;
}

.citation a:hover {
    text-decoration: underline;
}

/* Media container for images and videos */
.media-container {
    margin: 3rem 0;
    width: 100vw;
    position: relative;
    left: 50%;
    transform: translateX(-50%);
    text-align: center;
    max-width: 100vw;
}

.full-width-image {
    width: 90%;
    max-width: 1200px;
    height: auto;
    border-radius: 4px;
    box-shadow: none;
    margin: 0 auto;
    display: block;
}

.caption {
  font-size: 0.9rem;
  color: #999;
  margin-top: 1rem;
  text-align: left;
  /* font-style: italic; */
  max-width: var(--content-width);
  margin-left: auto;
  margin-right: auto;
  padding-left: 1rem;
  padding-right: 1rem;
  box-sizing: border-box;
}

/* More Stories Section */
.more-stories {
  background: var(--background-color);
  padding: var(--section-spacing) 0;
  margin-top: 4rem;
  width: 100%;
}

.section-divider {
  border: 0;
  height: 1px;
  background-color: var(--footer-text);
  opacity: 0.3;
  margin: 4rem auto;
  width: 100%;
  max-width: var(--content-width);
}

.more-stories .content {
  max-width: 100%;
  padding: 0 2rem;
  background-color: transparent;
}

.more-stories h3 {
  font-family: var(--title-font);
  font-size: 1.5rem;
  text-align: center;
  margin-bottom: 2rem;
  color: var(--text-color);
}

.stories-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 2rem;
  margin-top: 2rem;
  max-width: 1200px;
  margin-left: auto;
  margin-right: auto;
  align-items: start;
}

/* Story Cards */
.stories-track .story-card {
  flex: 0 0 auto;
  width: calc(33.333% - 20px);
  /* Show 3 cards by default, with margins */
  margin: 0 10px;
  background: var(--card-bg);
  border-radius: 8px !important;
  overflow: visible;
  /* Changed from hidden to visible */
  box-shadow: none;
  border: none !important;
  display: flex;
  flex-direction: column;
  height: 100%;
  cursor: pointer;
  text-decoration: none;
  color: inherit;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  transform-origin: center center;
  position: relative;
  z-index: 1;
}

.stories-track .story-card:hover,
.stories-track .story-card:focus,
.stories-track .story-card:active {
  border: none !important;
  border-bottom: none !important;
  text-decoration: none;
  outline: none;
  transform: translateY(-5px) scale(1.02);
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.1);
  z-index: 2;
  /* Bring hovered card to front */
  border-radius: 8px !important;
}

/* Override any default link styles for story cards */
a.story-card,
a.story-card:hover,
a.story-card:active,
a.story-card:visited,
a.story-card:focus {
  border: none !important;
  border-bottom: none !important;
  text-decoration: none !important;
}

/* Story card content styling */
.story-card-content {
  padding: 1rem;
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  background: var(--card-bg);
  border-bottom-left-radius: 8px !important;
  border-bottom-right-radius: 8px !important;
}

.story-card h4 {
  font-family: var(--title-font);
  font-size: var(--h4-size);
  margin: 0 0 0.5rem 0;
  font-weight: 600;
  color: var(--text-color);
}

.story-card p {
  margin: 0;
  font-size: var(--small-text);
  color: var(--footer-text);
}

.story-card:hover h4 {
  color: #0077b6;
}

/* Story card media container with aspect ratio */
.story-card-media {
  position: relative;
  width: 100%;
  padding-top: 107.5%;
  /* 1/0.93 ≈ 107.5% to create 0.93:1 ratio */
  overflow: hidden; /* Explicitly hide overflow */
  background-color: #fff;
  border-top-left-radius: 8px !important;
  border-top-right-radius: 8px !important;
  border: none !important;
  border-bottom: none !important;
  transition: none !important;
}

.story-card-media img,
.story-card-media video {
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: auto;
  height: 100%;
  object-fit: cover;
  border: 0 !important;
  border-bottom: 0 !important;
  outline: 0 !important;
  transition: none !important;
  box-shadow: none !important;
}

/* Additional specific rule to override any hover borders on media elements */
.stories-track .story-card:hover .story-card-media,
.stories-track .story-card:focus .story-card-media,
.stories-track .story-card:active .story-card-media {
  border: none !important;
  border-bottom: none !important;
  outline: none !important;
  transition: none !important;
}

.stories-track .story-card:hover .story-card-media img,
.stories-track .story-card:hover .story-card-media video,
.stories-track .story-card:focus .story-card-media img,
.stories-track .story-card:focus .story-card-media video,
.stories-track .story-card:active .story-card-media img,
.stories-track .story-card:active .story-card-media video {
  border: 0 !important;
  border-bottom: 0 !important;
  outline: 0 !important;
  transition: none !important;
  box-shadow: none !important;
}

/* Responsive adjustments */
@media (min-width: 1100px) {
  .story-card {
    width: calc(25% - 20px);
    /* Show 4 cards on large screens */
    border-radius: 8px !important;
  }
}

@media (max-width: 900px) {
  .story-card {
    width: calc(50% - 20px);
    /* Show 2 cards on medium screens */
    border-radius: 8px !important;
  }
}

@media (max-width: 600px) {
  .story-card {
    width: calc(100% - 20px);
    /* Show 1 card on smaller screens */
    border-radius: 8px !important;
  }

  .stories-carousel-container {
    padding: 0 30px;
  }
}

/* Stories Carousel */
.stories-carousel-container {
  position: relative;
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 40px;
  /* Space for navigation buttons */
}

.stories-carousel {
  width: 100%;
  overflow: visible;
  /* Allow cards to expand outside of container on hover */
  position: relative;
  padding: 10px 0 20px 0;
  /* Add padding to accommodate transformed cards */
}

.stories-track {
  display: flex;
  transition: transform 0.4s ease-in-out;
  padding: 10px 0;
  /* Add padding to accommodate shadows */
}

.story-card:hover h4 {
  color: #0070f3;
}

/* Navigation buttons */
.carousel-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background-color: white;
  border: 1px solid #eaeaea;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 10;
  transition: all 0.2s ease;
  color: #666;
}

.carousel-nav:hover {
  background-color: #f5f5f5;
  /* color: #333; */
}

.carousel-nav.prev {
  left: 0;
}


.carousel-nav.next {
  right: 0;
}

/* Fix story card styling to remove hover border and ensure consistent rounded corners */
a.story-card {
  border-bottom: none;
  border: none !important;
}

.stories-track a.story-card:hover {
  border-bottom: none !important;
  border-bottom-color: transparent;
  transform: translateY(-5px) scale(1.02);
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.1);
}

/* Completely remove any border from story card links */
.stories-track a.story-card,
.stories-track a.story-card:hover,
.stories-track a.story-card:focus,
.stories-track a.story-card:active {
  border: none;
  border-bottom: none;
  text-decoration: none;
  outline: none;
}

/* Ensure consistent rounded corners on all story cards, including when hovered */
.stories-track .story-card {
  border-radius: 8px !important;
  overflow: hidden;
}

.stories-track .story-card:hover {
  border-radius: 8px !important;
}

/* Prevent any hover border on story card media */
.story-card-media,
.story-card-media img,
.story-card-media video {
  border: none !important;
  outline: none !important;
}

/* Responsive adjustments */
@media (max-width: 768px) {
  :root {
    --base-font-size: 16px;
    --h1-size: 2rem;
  }
}

/* Override the default a:hover behavior specifically for story cards */
.more-stories a:hover,
.more-stories a:hover *,
.more-stories a:hover *:before,
.more-stories a:hover *:after {
  border: none !important;
  border-bottom: none !important;
  border-color: transparent !important;
  border-bottom-color: transparent !important;
  outline: none !important;
  box-shadow: none !important;
  text-decoration: none !important;
}

/* Ultimate override for story card borders - added at the end to have maximum specificity */
.story-card,
.story-card *,
.story-card:hover,
.story-card:hover *,
.stories-track .story-card,
.stories-track .story-card *,
.stories-track .story-card:hover,
.stories-track .story-card:hover *,
.story-card-media,
.story-card-media *,
.story-card-media img,
.story-card-media video,
.story-card:hover .story-card-media,
.story-card:hover .story-card-media img,
.story-card:hover .story-card-media video,
.story-card::before,
.story-card::after,
.story-card *::before,
.story-card *::after,
.story-card:hover::before,
.story-card:hover::after,
.story-card:hover *::before,
.story-card:hover *::after {
  border: 0 none !important;
  border-bottom: 0 none !important;
  border-top: 0 none !important;
  border-left: 0 none !important;
  border-right: 0 none !important;
  border-color: transparent !important;
  border-style: none !important;
  border-width: 0 !important;
  outline: 0 none !important;
}

/* Prevent hover events on media elements */
.story-card-media,
.story-card-media img,
.story-card-media video {
  pointer-events: none !important;
}

/* Apply border radius only where needed */
.story-card,
.story-card:hover {
  border-radius: 8px !important;
}

.story-card-media {
  border-top-left-radius: 8px !important;
  border-top-right-radius: 8px !important;
}

.story-card-content {
  border-bottom-left-radius: 8px !important;
  border-bottom-right-radius: 8px !important;
}

/* Ultimate video element reset - this overrides ALL browser styling for videos */
video {
  all: initial !important;
  /* Reset all properties */
  display: block !important;
  /* Maintain block display */
  position: absolute !important;
  top: 0 !important;
  left: 50% !important;
  transform: translateX(-50%) !important;
  width: auto !important;
  height: 100% !important;
  object-fit: cover !important;
  background-clip: padding-box !important;
  /* Prevent background extending into border area */
  -webkit-background-clip: padding-box !important;
  border: 0 !important;
  border-width: 0 !important;
  border-style: none !important;
  border-color: transparent !important;
  outline: 0 !important;
  box-shadow: none !important;
}

/* Video wrapper to isolate media elements */
.video-wrapper {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  overflow: hidden;
  border: 0 !important;
  border-width: 0 !important;
  border-style: none !important;
  border-color: transparent !important;
  outline: 0 !important;
}

.video-wrapper * {
  pointer-events: none;
  user-select: none;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  border: 0 !important;
  border-width: 0 !important;
  border-style: none !important;
  border-color: transparent !important;
  outline: 0 !important;
}

/* Override for main content videos */
.media-container video.full-width-image {
    all: revert !important;
    position: static !important;
    display: block !important;
    width: 90% !important;
    max-width: 1200px !important;
    height: auto !important;
    margin: 0 auto !important;
    border-radius: 4px !important;
    overflow: hidden !important; /* Fix the overflow warning */
    object-fit: contain !important;
    transform: none !important;
}

/* Fix for video controls */
.media-container video.full-width-image::-webkit-media-controls {
    display: flex !important;
    visibility: visible !important;
}

/* Firefly Visualization Specific Styles */
.firefly-visualization-container {
    position: relative; /* Needed for absolute positioning of SVG */
    /* Inherits width/max-width from .media-container */
}

#firefly-svg-overlay {
    position: absolute;
    top: 0;
    left: 0;
    pointer-events: auto; 
    /* ViewBox and preserveAspectRatio set by JS */
    /* Add background for debugging if needed */
    /* background-color: rgba(255, 0, 0, 0.1); */ 
}

.firefly-track {
    fill: none;
    stroke: rgba(255, 255, 255, 0.15); /* Subtle white tracks */
    stroke-width: 1;
    stroke-linecap: round;
    stroke-linejoin: round;
    pointer-events: stroke; /* Allow hover only on the line itself */
    transition: stroke 0.1s ease-in-out, stroke-width 0.1s ease-in-out; /* Smooth transition */
}

.firefly-track.highlighted {
    stroke: #ffff00; /* Bright yellow highlight */
    stroke-width: 2.5;
    stroke-opacity: 1.0;
    cursor: pointer; /* Add pointer cursor when hovering highlighted track */
}

/* Intensity Chart Pop-up Styles */
.intensity-chart-popup {
    position: absolute; /* Positioned by JS relative to the page */
    /* REMOVE fixed width/height - JS will set these */
    /* width: 160px; */
    /* height: 160px; */
    background-color: rgba(40, 40, 40, 0.85); /* Semi-transparent dark background */
    border-radius: 6px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    z-index: 100; /* Ensure it's above the SVG overlay */
    pointer-events: none; /* Initially ignore mouse events */
    opacity: 0; /* Initially hidden */
    transition: opacity 0.2s ease-in-out;
    padding: 5px; /* Small padding around the SVG */
    box-sizing: border-box;
    overflow: hidden; /* Hide anything slightly overflowing */
}

.intensity-chart-popup.visible {
    opacity: 1;
    pointer-events: auto; /* Allow interaction when visible (though maybe not needed) */
}

/* Styles for the D3 chart elements inside the popup */
.intensity-chart-popup svg {
    width: 100%;
    height: 100%;
    display: block;
    /* Improve rendering quality */
    shape-rendering: geometricPrecision; 
    text-rendering: optimizeLegibility;
}

.intensity-chart-popup .axis path,
.intensity-chart-popup .axis line {
    fill: none;
    stroke: #ccc; /* Light gray axis lines */
    shape-rendering: crispEdges; /* Keep axes sharp */
    stroke-width: 1px;
}

.intensity-chart-popup .axis text {
    font-family: var(--ui-font), sans-serif;
    font-size: 10px; /* Slightly larger tick labels */
    fill: #eee; /* Light text color */
    /* Add font smoothing */
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.intensity-chart-popup .intensity-line {
    fill: none;
    stroke: #ffffff; /* White line for intensity */
    stroke-width: 1.5px;
    shape-rendering: geometricPrecision; /* Smoother line */
}

.intensity-chart-popup .chart-title {
    font-family: var(--ui-font), sans-serif;
    font-size: 12px; /* Slightly larger title */
    fill: #eee;
    text-anchor: middle;
    /* Add font smoothing */
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Style for the new X-axis label */
.intensity-chart-popup .axis-label {
    fill: #ccc;
    font-size: 11px; /* Slightly larger axis label */
    font-family: var(--ui-font), sans-serif;
    text-anchor: middle;
    /* Add font smoothing */
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

#image-container {
    position: relative; /* Crucial for absolute positioning of children */
    width: 90%;
    max-width: 1200px;
    margin: 0 auto; /* Center container */
    line-height: 0; /* Prevent extra space below base image affecting height */
}

/* Base image dictates the container size */
#image-container #base-image {
    display: block; /* Remove bottom space */
    width: 100%; /* Use full container width */
    max-width: 100%;
    height: auto; /* Maintain aspect ratio */
}

/* Overlay MUST match the base image exactly */
#overlay-image {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%; /* Match container width */
    height: 100%; /* Match container height */
    pointer-events: none;
    display: block; /* Initially visible */
}

/* Class to hide the overlay */
#overlay-image.hidden {
    display: none;
}

/* Styling for the toggle text - positioned relative to #image-container */
.track-toggle-text {
    position: absolute;
    top: 15px;
    right: 15px;
    background-color: rgba(0, 0, 0, 0.6);
    color: #efefef;
    padding: 6px 12px;
    font-family: 'Open Sans', sans-serif;
    font-size: 1em;
    font-weight: 600;
    border-radius: 4px;
    cursor: pointer;
    z-index: 10;
    user-select: none;
    transition: background-color 0.2s ease;
}

/* Optional: Slightly change background on hover */
.track-toggle-text:hover {
    background-color: rgba(0, 0, 0, 0.8);
}

/* Optional: Add some spacing to the specific container */
.animation-viewer-container {
    margin-top: 2em;
    margin-bottom: 2em;
}

/* Visualization Specific Styles */
.visualization-container {
    width: 100vw;
    margin-left: calc(50% - 50vw);
    margin-right: calc(50% - 50vw);
    position: sticky;
    top: 0;
    z-index: 10;
    margin-top: var(--section-spacing);
    margin-bottom: var(--section-spacing);
    height: 100vh; /* Ensure it takes full viewport height */
    min-height: 100vh; /* Ensure it's at least viewport height */
    background-color: #EFEFEF; /* Changed background for better visibility of light elements */
    /* border: 1px solid #ccc;  */
    padding: 0; /* Remove padding to allow full use of space by wrapper */
    box-sizing: border-box; 
    display: flex; /* Added to help center content if wrapper is not 100% */
    align-items: center; /* Vertically center content */
    justify-content: center; /* Horizontally center content */
}

/* Arctic Ground Temperature Visualization Styles */
.arctic-visualization-wrapper {
    position: relative; 
    width: 100%; 
    height: 100%; 
    max-width: none; 
    margin: 0 auto; 
    line-height: 0; 
    display: flex; 
    align-items: center;
    justify-content: center;
    overflow: hidden; /* Important to contain absolutely positioned children like foreground image */
}

#arctic-monthly-background-image,
#foreground-land-cutout {
    position: absolute;
    top: 0;
    left: 0; /* Ensure they align to the flex center of the wrapper */
    right: 0; /* Ensure they align to the flex center of the wrapper */
    margin-left: auto; /* Works with left/right 0 for centering block */
    margin-right: auto; /* Works with left/right 0 for centering block */
    max-width: 100%;  
    max-height: 100%; 
    width: auto;      
    height: 100%;     
    object-fit: contain; 
}

#arctic-monthly-background-image {
    z-index: 1; /* Base layer */
}

#foreground-land-cutout {
    z-index: 3; /* Above monthly background and SVG overlay initially */
}

#arctic-svg-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    margin-left: auto;
    margin-right: auto;
    max-width: 100%;  
    max-height: 100%; 
    width: auto;      
    height: 100%;     
    object-fit: contain; /* Match image sizing behavior */
    pointer-events: none; 
    overflow: visible !important; 
    z-index: 2; /* Between monthly background and foreground cutout */
}

/* Floating Annotation Text Styles */
.floating-annotation-text {
    position: fixed; /* Fixed to viewport, or use absolute if relative to a specific non-100vw parent */
    left: 10vw; /* Adjusted from 2vw to be closer to the visual center */
    top: 30vh; /* Example: initial vertical position for first annotation */
    width: 350px; /* Increased width from 200px */
    padding: 15px;
    background-color: rgba(247, 247, 247, 0.5); /* Light background with opacity */
    color: var(--text-color); /* Changed from white for better contrast */
    border-radius: 5px;
    font-family: var(--body-font);
    font-size: 0.4rem !important; /* Test with a new value and !important */
    z-index: 100; /* Ensure they are on top of other content */
    /* Initial state for slide-up animation will be set by GSAP (e.g., y: "+100vh", opacity: 0) */
}

/* For wider screens, position annotations further to the left */
@media (min-width: 1280px) {
    .floating-annotation-text {
        left: 3vw;
    }
}

#annotation-text-2 {
    top: 30vh; /* Different initial Y for the second annotation, can be adjusted */
}

/* Link styling within text blocks */
.text-block a {
  color: #1982c4;
  text-decoration: none;
}

.text-block a:hover {
  color: #e76f51; /* A slightly darker shade for hover */
  /* text-decoration: underline; */ /* Optionally add underline on hover */
}

.full-width-chart-wrapper {
    width: 100vw; /* Make it viewport width */
    position: relative;
    left: 50%;
    transform: translateX(-50%);
    margin-top: 2em;
    margin-bottom: 2em;
    padding: 0; 
    box-sizing: border-box; 
    /* background-color: #2a75ee; */
}

/* Optional: If you want to ensure it breaks out of any parent's width constraints like .media-container often does.
   This might require adjusting based on your existing CSS for .content or other wrappers.
   Use with caution and test thoroughly.
*/
/*
.full-width-chart-wrapper {
    width: 100vw;
    position: relative;
    left: 50%;
    right: 50%;
    margin-left: -50vw;
    margin-right: -50vw;
    margin-top: 2em;
    margin-bottom: 2em;
    padding: 0;
    box-sizing: border-box;
}
*/