/* ==== Base Page Styling ==== */
body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background-color: #0e0e0e;
  color: white;
  margin: 0;
  padding: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
}

.wrapper {
  background: #1b1b1b;
  padding: 30px;
  border-radius: 12px;
  margin-top: 5vh;
  margin-bottom: 5vh;
  margin-left: 5vw;
  margin-right: 5vw;
  box-shadow: 0 0 20px rgba(0, 255, 255, 0.15);
  max-width: 1400px;
  width: 95%;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;  /* allow children to flow downward */
  min-height: 100vh;            /*  ensure enough height for canvas */
  box-sizing: border-box;
}

h1, h4 {
  color: white;
  margin: 5px 0;
}

/* ==== Layout: Controls + Equation ==== */
#mainControl {
  display: flex;
  flex-direction: row;
  justify-content: center;
  align-items: stretch;
  gap: 60px;
  margin-top: 20px;
  width: 85%;
  max-width: 900px;
}

/* ==== Panels ==== */
#controls, #params {
  background-color: black;
  color: white;
  padding: 20px;
  border-radius: 8px;
  box-shadow: 0 0 10px rgba(0, 255, 255, 0.1);
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
}

/* ==== Controls ==== */
#controls label {
  margin-top: 5px;
}

#controls input[type="range"] {
  width: 180px;
  cursor: pointer;
  margin-bottom: 8px;
}

#reset-btn {
  background-color: rgb(56, 134, 104);
  color: white;
  padding: 10px 20px;
  border-radius: 8px;
  border: none;
  margin-top: 10px;
  cursor: pointer;
  font-weight: bold;
  transition: background-color 0.3s ease;
}

#reset-btn:hover {
  background-color: rgb(72, 174, 134);
}

/* ==== Equation Panel ==== */
#param-title {
  font-size: 22px;
  font-weight: bold;
  margin-bottom: 10px;
  color: white;
}

#params {
  text-align: center;
  justify-content: center;
  align-items: center;
}

#params p {
  font-size: 18px;
  margin: 0;
  line-height: 1.8em;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 160px;
}

#params .MathJax {
  margin: auto !important;
}

/* ==== Canvas ==== */
#canvas-container {
  margin-top: 25px;
  background: black;
  border-radius: 12px;
  display: flex;
  justify-content: center;
  align-items: center;
  width: 60%;
  max-width: 800px;
  aspect-ratio: 1.3;          /* keep it square */
  flex-shrink: 0;               /*  prevents collapsing */
}

#canvas2d {
  width: 100%;
  height: 100%;
  display: block;
  border: 1px solid #333;
  border-radius: 8px;
  background-color: black;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  touch-action: none;      /* let our JS handle touch; avoid browser gestures */
  -ms-touch-action: none;  /* older Edge */
  user-select: none;
}



/* ==== Tip ==== */
#tip {
  background-color: black;
  color: white;
  font-weight: bold;
  font-family: Arial, Helvetica, sans-serif;
  border-radius: 5px;
  padding: 10px 15px;
  margin-top: 20px;
}

/* ==== Back Button ==== */
.back-button {
  position: absolute;
  top: 20px;
  left: 20px;
  background-color: black;
  color: white;
  padding: 8px 14px;
  border-radius: 6px;
  text-decoration: none;
  font-weight: bold;
  transition: background-color 0.3s ease;
}

.back-button:hover {
  background-color: #333;
}

/* ==== Responsive ==== */
@media (max-width: 700px) {
  #mainControl {
    flex-direction: column;
    align-items: center;
  }

  #controls, #params {
    width: 100%;
  }

  #canvas2d {
    width: 90vw;
    height: 90vw;
  }

  #params p {
    min-height: auto;
    transform: scale(1.05);
  }
}
#equation-panel {
    width: 100%;
    text-align: center;
    margin-bottom: 20px;
}

#main-layout {
    display: flex;
    flex-direction: row;
    justify-content: center;
    align-items: flex-start;
    gap: 40px;
    width: 100%;
}

#canvas-container {
    width: 650px;
    height: 450px;
    background: black;
    border-radius: 10px;
}

#controls-panel {
    background: #000;
    padding: 20px;
    border-radius: 10px;
    width: 280px;
    box-shadow: 0 0 12px rgba(0,255,255,0.2);
}

#controls-panel label {
    margin-top: 12px;
    font-weight: bold;
    display: block;
}

#equilibria-info {
    margin-top: 15px;
    font-size: 14px;
}

#bif-popup {
    display: none;
    margin-top: 10px;
    background: #333;
    padding: 6px 10px;
    border-radius: 6px;
}
