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

html, body {
  width: 100%;
  height: 100%;
  overflow-x: hidden;
}

.viewport-wrapper {
  width: 100%;
  min-height: 100vh;
}

.app-container {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-items: flex-start;
  align-content: start;
  gap: 24px;
  width: 100%;
  min-height: 100vh;
  min-height: 100dvh;
  padding: 0 20px 0 0;

  /* Width at which the SVG's height equals the viewport height.
     --svg-ratio (width / height of the SVG incl. the table) is set by main.js. */
  --content-width: min(100%, calc(100dvh * var(--svg-ratio, 0.9754)));
}

.svg-wrapper {
  position: relative;
  width: var(--content-width);
  aspect-ratio: 698.98096 / 716.57917; /* main.js replaces this with the real ratio */
}

.svg-wrapper object {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
}

html, body {
  margin: 0;
  padding: 0;
  overflow: auto;
  
  background-color: #fff9c9;
  background-image:
    radial-gradient(rgba(135, 70, 55, 0.09) 0.65px, transparent 0.95px),
    radial-gradient(rgba(255, 255, 255, 0.65) 0.6px, transparent 0.95px);
  background-size: 4px 4px, 6px 6px;
  background-position: 0 0, 2px 3px;
  color: #000000;

}

/* Pin button container strictly to top-right */
.controls {
  position: fixed;
  top: 20px;
  right: 20px;
  left: auto; /* Override any inherited or default left alignment */
  z-index: 100;
}

button {
  padding: 10px 16px;
  font-size: 14px;
  cursor: pointer;
}

@media (orientation: portrait) {
  html, body {
    height: 100%;
    overflow: hidden;
  }

  .viewport-wrapper {
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    min-height: 0;
    overflow: auto;
    overscroll-behavior: contain;
  }

  .app-container {
    display: block;
    width: max-content;
    min-height: 0;
    padding: 20px 0;
  }

  .svg-wrapper {
    width: calc((100dvh - 40px) * 698.98096 / 716.57917);
    height: auto;
  }
}

/* References panel: wide, landscape box under the SVG */
.references-panel {
  width: var(--content-width);
  margin-bottom: 20px;
  padding: 12px 16px 16px;
  border: 1px solid #000000;
  border-radius: 4px;
  background-color: #fff2a8;
  background-image: repeating-linear-gradient(
    to bottom,
    transparent 0,
    transparent 26px,
    rgba(143, 124, 36, 0.11) 26px,
    rgba(143, 124, 36, 0.11) 27px
  );
  color: #241f0c;
  font-family: Arial, sans-serif;
}

.references-panel h3 {
  margin-bottom: 8px;
  font-size: 18px;
}

.references-columns {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 8px 24px;
  align-items: start;
}

.reference-group h4 {
  margin-bottom: 4px;
  font-size: 15px;
}

.reference-group ul {
  padding-left: 18px;
}

.reference-citation {
  margin-bottom: 6px;
  font-size: 12px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.references-image {
  display: block;
  width: auto;
  max-width: 100%;
  max-height: 260px;
  margin: 0 auto;
}

@media (orientation: portrait) {
  /* Stay pinned to the visible left edge while the SVG scrolls sideways */
  .references-panel {
    position: sticky;
    left: 0;
    width: 100vw;
    margin-bottom: 20px;
  }
}

/*Position table on top-left, shifted down 
.molecule-dashboard {
  position: fixed;
  top: 80px; 
  left: 20px;
  z-index: 100;
  background: rgba(255, 255, 255, 0.9);
  padding: 12px;
  border-radius: 6px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}
  */

/*
.molecule-dashboard {
  width: 100%;
  height: 100%;

  background-color: #ffffff !important; 
  border: 1px solid #b5b5b5;
  border-radius: 6px;
  box-sizing: border-box;
  padding: 8px;
  font-family: Arial, sans-serif;
  font-size: 11px;
  color: #000000 !important;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.molecule-dashboard table {
  width: 100%;
  border-collapse: collapse;
  background-color: #ffffff !important;
}

.molecule-dashboard th,
.molecule-dashboard td {
  padding: 4px 6px;
  text-align: left;
  color: #333333 !important;
  border-bottom: 1px solid #eee;
}

.molecule-dashboard th {
  font-weight: bold;
  border-bottom: 2px solid #ccc;
}

#glucose-btn {
  cursor: pointer;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

#glucose-btn:hover {
  opacity: 0.7;

  filter: drop-shadow(0px 0px 4px rgba(0, 150, 255, 0.8)); 
}

#PCr-btn {
  cursor: pointer;
  pointer-events: all; 
  transition: opacity 0.2s ease, filter 0.2s ease;
}
#PCr-btn:hover {
  opacity: 0.7;
  filter: drop-shadow(0px 0px 4px rgba(0, 150, 255, 0.8)); 
}*/

.greyed-out {
  opacity: 0.25 !important;
  filter: grayscale(100%) !important;
  fill: #888888 !important; /* Forces color switch if filter fails in SVG */
  transition: opacity 0.4s ease, filter 0.4s ease;
}

.active-state {
  opacity: 1 !important;
  filter: grayscale(0%) !important;
  transition: opacity 0.4s ease, filter 0.4s ease;
}

.pop-text {
  font-family: Arial, sans-serif;
  font-size: 14px;
  font-weight: bold;
  pointer-events: none;
  paint-order: stroke fill;
  stroke: #ffffff;
  stroke-width: 2px;
  stroke-linejoin: round;
  animation: pop-text-rise 0.8s ease-out forwards;
}

.pop-negative {
  fill: #ff4d4d;
}

.pop-positive {
  fill: #00e676;
}

@keyframes pop-text-rise {
  from {
    opacity: 1;
    transform: translateY(0);
  }
  to {
    opacity: 0;
    transform: translateY(-10px);
  }
}