/* ─── GLOBAL & CARD LAYOUT ───────────────────────────────────────── */

body {
  margin: 0;
  font-family: sans-serif;
  background: #fff;
  display: flex;
  justify-content: center;
  padding: 2rem;
}

.card {
  position: relative;
  background: #fff;
  border: 1px solid #000;
  border-radius: 6px;
  box-shadow: 0 0 3px rgba(0,0,0,0.3);
  width: 95%;
  max-width: 800px;
  height: 520px; /* Decreased from 550px to 520px */
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
}

.menu-btn {
  position: absolute;
  top: 0.5rem;
  left: 0.5rem;
  background: lightblue;
  border: 1px solid #000;
  border-radius: 6px;
  padding: 6px;
  height: 40px;
}
.menu-btn img {
  height: 100%;
}


/* ─── CONTROLS LAYOUT ─────────────────────────────────────────────── */

.controls {
  display: flex;
  flex-direction: column;
  gap: 0.7rem; /* Slightly increased from 0.6rem */
  margin-left: 3rem;    /* clear the hamburger */
}

/* prevent the ratio slider group from filling the whole row */
.controls .slider-row:last-of-type .slider-group {
  flex: 0 0 auto;
  min-width: 240px; /* Make volume ratio slider even smaller */
  margin-left: 0.1rem; 
}
/* tighten that ratio label */
.controls .slider-row:last-of-type .slider-group .long-label {
  min-width: 120px; /* Reduced from 140px */
}


/* each row of sliders + actions */
.slider-row {
  display: flex;
  flex-wrap: wrap;
  gap: 1.2rem; /* Reduced from 1.5rem */
  align-items: center;
  justify-content: flex-start;
}

/* Force second row to not wrap */
.slider-row:last-of-type {
  flex-wrap: nowrap;
  gap: 0.7rem; /* Reduced from 1rem to move buttons left */
}

/* slider + label + value */
.slider-group {
  display: flex;
  align-items: center;
  gap: 0.5rem; /* Reduced from 0.75rem */
  min-width: 260px; /* Reduced from 280px */   
}

.long-label {
  min-width: 140px; /* Reduced from 150px */
  font-size: 0.9rem; /* Slightly smaller */
}
input[type="range"] {
  width: 120px; /* Reduced from 130px */
  accent-color: green;
}

.slider-wrapper {
  display: flex;
  align-items: center;
  justify-content: space-between; /* ensures value is always to the right */
  min-width: 160px; /* Reduced from 180px */
  gap: 0.4rem; /* Reduced gap */
}

.slider-val {
  min-width: 40px;
  text-align: left;
  font-size: 0.95rem;
}

/* the action buttons on the 2nd row */
.action-group {
  display: flex;
  align-items: center;
  gap: 0.8rem; /* Reduced from 1rem */
  margin-left: 0; /* Remove negative margin to flow naturally after slider */
  flex-wrap: nowrap; /* Prevent wrapping */
}
.action-group label {
  font-size: 0.85rem; /* Slightly smaller text */
  cursor: pointer;
  white-space: nowrap; /* Prevent label text from wrapping */
}
.mix-btn,
.reset-btn {
  padding: 0.5rem 0.5rem; /* Further reduced padding to make buttons smaller */
  border-radius: 4px;
  border: 1px solid #000;
  cursor: pointer;
  font-size: 0.85rem; /* Reduced from 0.9rem */
}
.mix-btn {
  background: #007bff;
  color: #fff;
}
.reset-btn {
  background: #ddd;
  color: #000;
}


/* ─── ENTROPY & LABELS ───────────────────────────────────────────── */

.entropy-total,
.entropy-label {
  display: none;        /* shown by script.js when mixing */
}
.entropy-total {
  position: absolute;
  top: 1rem;
  left: 50%;
  transform: translateX(-50%);
  text-align: center;
  font-size: 1.5rem;
  font-weight: normal !important;
  z-index: 10;
}

.entropy-total, .entropy-total *, .entropy-total sub, .entropy-total span {
  font-weight: normal !important;
}

/* Specific rule for the entropy total div and all nested elements */
#entropyTotal, #entropyTotal *, #entropyTotal sub, #entropyTotal span {
  font-weight: normal !important;
}


/* ─── SIMULATION PANEL (outer box) ───────────────────────────────── */

.simulation-panel {
  position: relative;
  margin-top: 1rem; /* Increased from 1rem to move the entire simulation panel down slightly */
  padding: 1.8rem 2rem 1.8rem 2rem; /* Increased vertical padding slightly */
  background-color: #fff;
  border: 1px solid #ccc;
  border-radius: 3px;
  display: flex;
  flex-direction: column;
  gap: 1rem; /* Restored to 1rem */
}


/* ─── SIMULATION CARD (inner black box) ─────────────────────────── */

.simulation-card {
  border: 2px solid #000; /* Increased thickness */
  border-radius: 0px;     
  flex:1; 
  display: block;
  height: 350px; /* Increased from 300px to 350px */
  overflow: hidden;
  margin-top: 1.8rem; /* Increased from 1.8rem to move the box down slightly */
}

#svgCard svg {
  display: block;     /* kill the default svg bottom‐white‐gap */
  width: 100%;
  height: 100%;
}

.chamber {
  flex: 1;
  margin: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  transition: background-color 0.3s;
}
.chamber.right {
  border-left: 3px solid #000 !important;
}

/* Add this to your CSS */
.labelsLayer .card-group {
  pointer-events: none; /* Prevent interaction with the cards */
}

.labelsLayer .card-bg {
  fill: white;
  stroke: #ccc;
  stroke-width: 1px;
  rx: 6px;
  ry: 6px;
  opacity: 0.9;
}

.labelsLayer .card-text {
  font-size: 25px;
  font-family: sans-serif;
  fill: #000;
}

/* Add to your CSS */
#svgCard {
  position: relative;
  z-index: 1;
}

.labelsLayer {
  position: relative;
  z-index: 10;
}

/* labels inside each chamber */
.pressure-label,
.entropy-label {
  background: #fff;
  padding: 0.3rem 0.6rem;
  border-radius: 4px;
  font-size:1.5 rem;
  font-weight: 540;
  margin: 0.3rem 0;
}

.pressure-label,
.entropy-label {
  font-size: 1.5rem;    
  font-weight: 540;
} 

/* Add to your CSS */
.overlap {
  mix-blend-mode: multiply; /* Creates nice color blending effect */
  pointer-events: none; /* Prevent interaction with the overlap */
}

/* ─── your existing styles up through .simulation-card & .chamber ... */

/* ─── DROPDOWN MENU ──────────────────────────────────────────────── */
.hidden {
  display: none !important;
}
.dropdown-menu {
  position: absolute;
  top: 3.5rem;        /* just below the hamburger button */
  left: 0.5rem;
  background: #fff;
  border: 1px solid #ccc;
  border-radius: 6px;
  list-style: none;
  padding: 0.25rem 0;
  box-shadow: 0 2px 6px rgba(0,0,0,0.2);
  z-index: 100;
}
.dropdown-menu li {
  padding: 0.5rem 1rem;
  cursor: pointer;
  white-space: nowrap;
}
.dropdown-menu li:hover {
  background: #f0f0f0;
}

/* ─── MODAL STYLES ──────────────────────────────────────────────── */
.modal {
  position: fixed;
  top: 0; left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: flex-start;    /* <-- was center */
  justify-content: center;
  padding-top: 1.5rem;        /* add some breathing room from the top */
  z-index: 200;
}
.modal-content {
  position: relative;
  background: #fff;
  border-radius: 6px;
  width: 800px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
  max-height: 80vh;           /* allow vertical scroll if very long */
  overflow-y: auto;
  padding: 2rem;              /* more breathing room */
  font-size: 1rem;            /* slightly larger base font */
  line-height: 1.6;           /* generous line spacing */
}

.modal-body p {
  margin: 0.25em 0; /* slight spacing between lines */
}

.mjx-chtml {
  text-align: left !important;
}


/* Tighten up the title spacing */
.modal-content h2 {
  margin-top: 0;
  margin-bottom: 1rem;
  font-size: 1.5rem;
}

/* Paragraphs and lists */
.modal-content p,
.modal-content ul {
  margin-bottom: 1rem;
}

.modal-content p {
  line-height: 1.6;
}

.modal-content ul {
  padding-left: 1.5rem;      /* indent bullets */
}

/* Bullet spacing */
.modal-content li {
  margin-bottom: 0.5rem;
}

/* Centered formula block */
.formula {
  font-family: monospace;
  font-size: 1.2rem;
  text-align: center;
  margin: 1.5rem 0;
}

.modal-close {
  position: absolute;
  top: 0.5rem;
  right: 0.75rem;
  font-size: 1.5rem;
  cursor: pointer;
}

.dropdown-menu {
  /* make the overall box wider so text never collides */
     /* tweak this value as needed */
  padding: 1rem;
}

/* center the "or" separator */
.modal-content .modal-or {
  text-align: center;
  margin: 1rem 0;
  font-style: italic;      /* optional: make it stand out */
  font-weight: 500;
}


/* make each dropdown item look like a blue button */
.dropdown-menu li {
  background: #007bff;
  color: #fff;
  border-radius: 4px;
  margin: 0.5rem 0;
  padding: 0.75rem 1.25rem;
  cursor: pointer;
  transition: background 0.2s;
  /* ensure it fills the dropdown's width */
  display: block;
  white-space: nowrap;
}

/* darker on hover */
.dropdown-menu li:hover {
  background: #0056b3;
}

@media (max-width: 768px) {
  .slider-row {
    flex-direction: column;
    align-items: flex-start;
  }

  .slider-group {
    width: 100%;
  }

  .slider-group .long-label {
    min-width: auto;
  }

  .slider-val {
    text-align: right;
    flex-shrink: 0;
  }
}

/* Force left alignment on MathJax block equations */
mjx-container[jax="CHTML"][display="true"] {
  display: block;
  text-align: left !important;
  margin-left: 0 !important;
  margin-right: auto !important;
  margin-top: 0.3em;
  margin-bottom: 0.3em;
}

.simulation-card.no-barrier .chamber.right {
  border-left: none !important;
}

/* 1. Reset native appearance */
input[type="range"] {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  width: 140px;
  height: 4px;
  background: transparent;
  margin: 0;
}
input[type="range"]:focus { outline: none; }

/* 2. Custom track */
input[type="range"]::-webkit-slider-runnable-track {
  width: 100%; height: 4px; background: #ddd; border-radius: 2px;
}
input[type="range"]::-moz-range-track {
  width: 100%; height: 4px; background: #ddd; border-radius: 2px;
}
input[type="range"]::-ms-track {
  width: 100%; height: 4px; background: transparent; border-color: transparent; color: transparent;
}
input[type="range"]::-ms-fill-lower,
input[type="range"]::-ms-fill-upper {
  background: #ddd; border-radius: 2px;
}

/* 3. Custom thumb */
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px; height: 16px; border-radius: 50%; background: #007bff;
  cursor: pointer; margin-top: -6px;
}
input[type="range"]::-moz-range-thumb {
  width: 16px; height: 16px; border: none; border-radius: 50%; background: #007bff;
  cursor: pointer;
}
input[type="range"]::-ms-thumb {
  width: 16px; height: 16px; border: none; border-radius: 50%; background: #007bff;
  cursor: pointer; margin-top: 0;
}

/* Responsive design for smaller screens */
@media (max-width: 1100px) {
  .slider-row:last-of-type {
    flex-wrap: wrap; /* Allow wrapping on smaller screens */
    gap: 0.4rem;
  }
  
  .controls .slider-row:last-of-type .slider-group {
    min-width: 180px; /* Make volume ratio slider smaller */
    margin-right: 0.2rem;
  }
  
  .controls .slider-row:last-of-type .slider-group .long-label {
    min-width: 100px; /* Further reduce label width */
  }
  
  input[type="range"] {
    width: 100px; /* Make sliders narrower */
  }
  
  .action-group {
    gap: 0.4rem; /* Reduce gap between action elements */
  }
  
  .action-group label {
    font-size: 0.75rem; /* Smaller text */
  }
  
  .mix-btn,
  .reset-btn {
    padding: 0.3rem 0.3rem; /* Smaller buttons */
    font-size: 0.75rem;
  }
}

@media (max-width: 950px) {
  .slider-row:last-of-type {
    flex-wrap: wrap; /* Allow wrapping on smaller screens */
    gap: 0.5rem;
  }
  
  .controls .slider-row:last-of-type .slider-group {
    min-width: 200px; /* Make volume ratio slider smaller on small screens */
    margin-right: 0.3rem;
  }
  
  .action-group {
    gap: 0.5rem; /* Reduce gap between action elements */
  }
  
  .action-group label {
    font-size: 0.8rem; /* Smaller text on small screens */
  }
  
  .mix-btn,
  .reset-btn {
    padding: 0.4rem 0.4rem; /* Smaller buttons on small screens */
    font-size: 0.8rem;
  }
}

@media (max-width: 768px) {
  .slider-row:last-of-type {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.8rem;
  }
  
  .action-group {
    flex-wrap: wrap;
    gap: 0.4rem;
  }
}