/* Styles for the hydrostatic restoring simulators of Chapter 6. The base
   .sdof-* classes are kept identical to ch_02/sdof-simulator.css and
   ch_04/kinematics-simulator.css so the three chapters' tools look alike;
   the .hst-* classes below are new to this chapter. */

.sdof-app {
  margin: 1.5rem 0;
  border: 1px solid var(--bs-border-color, #ccc);
  border-radius: 0.5rem;
  padding: 1rem;
  background: var(--bs-body-bg, #fff);
}

.sdof-controls {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 0.75rem 1.25rem;
  align-items: end;
  margin-bottom: 0.75rem;
}

.sdof-control-group {
  display: flex;
  flex-direction: column;
  font-size: 0.9rem;
}

.sdof-control-group label {
  margin-bottom: 0.25rem;
}

.sdof-control-group input[type="range"] {
  width: 100%;
}

.sdof-control-group select {
  width: 100%;
  padding: 0.25rem 0.3rem;
  border-radius: 0.3rem;
  border: 1px solid var(--bs-border-color, #ccc);
  background: var(--bs-body-bg, #fff);
  color: var(--bs-body-color, #222);
  font-size: 0.9rem;
}

.sdof-buttons {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-wrap: wrap;
}

.sdof-buttons button {
  padding: 0.4rem 0.9rem;
  border-radius: 0.35rem;
  border: 1px solid var(--bs-border-color, #ccc);
  background: var(--bs-tertiary-bg, #f0f0f0);
  color: var(--bs-body-color, #222);
  cursor: pointer;
  font-size: 0.9rem;
}

.sdof-buttons button:hover {
  filter: brightness(0.95);
}

.sdof-buttons button.hst-active {
  background: #2c5282;
  border-color: #2c5282;
  color: #fff;
}

.sdof-readout {
  display: flex;
  gap: 1.25rem;
  flex-wrap: wrap;
  font-size: 0.9rem;
  align-items: center;
}

/* ---- layout: section view beside the waterplane plan view ---- */

.hst-stage {
  display: grid;
  grid-template-columns: 1.35fr 1fr;
  gap: 1rem;
  margin-bottom: 0.9rem;
}

@media (max-width: 900px) {
  .hst-stage {
    grid-template-columns: 1fr;
  }
}

.hst-panel {
  display: flex;
  flex-direction: column;
}

.hst-panel canvas {
  width: 100%;
  height: 420px;
  background: #eef3f7;
  border: 1px solid var(--bs-border-color, #ccc);
  border-radius: 0.4rem;
  display: block;
  touch-action: none;
}

.hst-panel-title {
  margin-top: 0.35rem;
  font-size: 0.85rem;
  color: var(--bs-body-color, #333);
  text-align: center;
}

/* ---- the running commentary under the section view ---- */

.hst-status {
  font-size: 0.9rem;
  line-height: 1.5;
  min-height: 3.2em;
  margin-bottom: 0.75rem;
  padding: 0.55rem 0.75rem;
  border-left: 4px solid #2c5282;
  border-radius: 0.25rem;
  background: var(--bs-tertiary-bg, #f1f3f5);
  color: var(--bs-body-color, #333);
}

/* ---- the two-term moment ledger ---- */

.hst-ledger {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(255px, 1fr));
  gap: 0.75rem;
  margin-bottom: 0.9rem;
}

.hst-term {
  padding: 0.6rem 0.8rem;
  border: 1px solid var(--bs-border-color, #ccc);
  border-top: 4px solid transparent;
  border-radius: 0.4rem;
  font-size: 0.88rem;
  background: var(--bs-body-bg, #fff);
}

.hst-term-wedge  { border-top-color: #3182ce; }
.hst-term-gb     { border-top-color: #c53030; }
.hst-term-total  { border-top-color: #2f855a; }

.hst-term-name {
  font-weight: 600;
  margin-bottom: 0.2rem;
}

.hst-term-note {
  color: var(--bs-secondary-color, #666);
  font-size: 0.83rem;
  margin-top: 0.25rem;
}

.hst-term-value {
  font-family: var(--bs-font-monospace, monospace);
  font-variant-numeric: tabular-nums;
  font-size: 0.95rem;
  margin-top: 0.3rem;
}

.hst-sign-neg { color: #2f855a; font-weight: 600; }
.hst-sign-pos { color: #c53030; font-weight: 600; }

/* ---- waterplane integrals and the stiffness matrix ---- */

.hst-lower {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1rem;
  margin-top: 0.9rem;
}

.hst-block figcaption {
  font-size: 0.85rem;
  text-align: center;
  margin-bottom: 0.4rem;
}

.hst-integrals {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.3rem 0.8rem;
  font-size: 0.88rem;
  align-items: baseline;
}

.hst-integrals .hst-int-val {
  font-family: var(--bs-font-monospace, monospace);
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.hst-matrix {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 0.12rem 0.35rem;
  justify-items: end;
  padding: 0.5rem 0.6rem;
  border-left: 2px solid var(--bs-body-color, #222);
  border-right: 2px solid var(--bs-body-color, #222);
  border-radius: 0.25rem;
  font-family: var(--bs-font-monospace, monospace);
  font-size: 0.78rem;
  font-variant-numeric: tabular-nums;
  overflow-x: auto;
}

.hst-matrix span {
  padding: 0.05rem 0.15rem;
  border-radius: 0.2rem;
  transition: background-color 0.25s ease;
}

.hst-matrix .hst-zero {
  color: var(--bs-secondary-color, #999);
}

.hst-matrix .hst-live {
  background: #fef3c7;
  color: #92400e;
  font-weight: 600;
}

.hst-matrix .hst-coupled {
  background: #fde2e2;
  color: #9b2c2c;
  font-weight: 600;
}

.hst-legend {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 0.6rem;
}

.hst-chip {
  font-size: 0.83rem;
  padding: 0.2rem 0.6rem;
  border-radius: 0.35rem;
  border-left: 6px solid transparent;
  background: var(--bs-tertiary-bg, #f1f3f5);
}

.hst-chip-wedge { border-left-color: #3182ce; }
.hst-chip-w     { border-left-color: #2f855a; }
.hst-chip-b     { border-left-color: #c53030; }
.hst-chip-o     { border-left-color: #1a202c; }
.hst-chip-f     { border-left-color: #805ad5; }
