.changes-learning-page .learning-breadcrumb,
.changes-learning-page .learning-hero,
.changes-learning-page .learning-tool,
.changes-learning-page .learning-summary {
  width: min(1180px, calc(100% - 2rem));
}

.changes-simulator {
  --particle-fill: #6f8ee8;
  --particle-edge: #324fa6;
  --particle-shadow: rgb(28 53 126 / 22%);
  overflow: visible;
  background:
    linear-gradient(rgb(11 30 45 / 1.8%) 1px, transparent 1px),
    linear-gradient(90deg, rgb(11 30 45 / 1.8%) 1px, transparent 1px),
    #fbfdfd;
  background-size: 32px 32px;
}

.changes-simulator[data-substance="water"] {
  --particle-fill: #6f8ee8;
  --particle-edge: #324fa6;
  --particle-shadow: rgb(28 53 126 / 22%);
}

.changes-simulator[data-substance="ethanol"] {
  --particle-fill: #55bfa4;
  --particle-edge: #207c70;
  --particle-shadow: rgb(22 93 82 / 22%);
}

.changes-simulator[data-substance="nitrogen"] {
  --particle-fill: #a27bdd;
  --particle-edge: #6546a1;
  --particle-shadow: rgb(77 48 133 / 23%);
}

.changes-simulator[data-substance="bromine"] {
  --particle-fill: #c46c52;
  --particle-edge: #7f382c;
  --particle-shadow: rgb(102 38 28 / 24%);
}

.changes-tool-heading {
  padding: clamp(1.4rem, 3.5vw, 2.35rem);
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 1.5rem;
  border-bottom: 1px solid var(--line);
  background: rgb(255 255 255 / 75%);
}

.changes-tool-heading h2 {
  margin: 0 0 0.45rem;
  font-size: clamp(1.75rem, 3.5vw, 2.65rem);
  letter-spacing: -0.045em;
}

.changes-tool-heading p:last-child {
  max-width: 68ch;
  margin: 0;
  color: var(--navy-650);
  font-size: 0.9rem;
}

.substance-picker {
  width: min(410px, 100%);
  flex: 0 0 auto;
}

.substance-picker-label {
  display: block;
  margin-bottom: 0.5rem;
  color: var(--navy-650);
  font-size: 0.68rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.substance-options button,
.energy-controls button {
  font: inherit;
  cursor: pointer;
}

.substance-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.4rem;
}

.option-swatch {
  width: 1rem;
  height: 1rem;
  display: inline-block;
  flex: 0 0 auto;
  border: 2px solid var(--particle-edge);
  border-radius: 50%;
  background: var(--particle-fill);
}

.substance-options button {
  width: 100%;
  min-height: 2.45rem;
  padding: 0.5rem 0.65rem;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  border: 1px solid var(--line);
  border-radius: 0.55rem;
  color: var(--navy-650);
  background: var(--surface);
  font-size: 0.78rem;
  font-weight: 800;
  text-align: left;
}

.substance-options button:hover,
.substance-options button[aria-pressed="true"] {
  border-color: var(--particle-edge);
  color: var(--navy-950);
  background: #f4f7f8;
}

.substance-options button[aria-pressed="true"] {
  box-shadow: inset 0 0 0 1px var(--particle-edge);
}

.water-swatch { border-color: #324fa6; background: #6f8ee8; }
.ethanol-swatch { border-color: #207c70; background: #55bfa4; }
.nitrogen-swatch { border-color: #6546a1; background: #a27bdd; }
.bromine-swatch { border-color: #7f382c; background: #c46c52; }

.changes-simulation {
  padding: clamp(1rem, 3vw, 2rem);
  display: grid;
  grid-template-columns: minmax(0, 1fr) 190px 150px;
  gap: 1rem;
  align-items: stretch;
}

.state-chamber,
.thermometer-panel,
.energy-controls {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius-medium);
  background: var(--surface);
  box-shadow: 0 10px 28px rgb(11 30 45 / 6%);
}

.state-chamber {
  min-height: 440px;
  position: relative;
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 110%, rgb(131 185 207 / 12%), transparent 54%),
    #edf5f8;
}

.state-chamber::before {
  content: "Particle box";
  position: absolute;
  top: 0.8rem;
  left: 0.9rem;
  z-index: 2;
  color: var(--navy-650);
  font-size: 0.68rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.state-particle {
  width: 34px;
  height: 34px;
  position: absolute;
  border: 3px solid var(--particle-edge);
  border-radius: 50%;
  background: var(--particle-fill);
  box-shadow: inset -5px -5px 0 var(--particle-shadow);
  transition:
    left 520ms ease,
    top 520ms ease,
    border-color 240ms ease,
    background-color 240ms ease;
}

.state-particle[data-state="solid"] {
  animation: state-solid-motion var(--motion-duration, 500ms) ease-in-out infinite alternate;
  animation-delay: var(--motion-delay, 0ms);
}

.state-particle[data-state="liquid"] {
  animation: state-liquid-motion var(--motion-duration, 900ms) ease-in-out infinite;
  animation-delay: var(--motion-delay, 0ms);
}

.state-particle[data-state="gas"] {
  animation: state-gas-motion var(--motion-duration, 1450ms) linear infinite;
  animation-delay: var(--motion-delay, 0ms);
}

.thermometer-panel {
  padding: 0.85rem;
  display: flex;
  flex-direction: column;
}

.thermometer-heading {
  padding-bottom: 0.75rem;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
  border-bottom: 1px solid var(--line);
}

.thermometer-heading span {
  color: var(--navy-650);
  font-size: 0.68rem;
  font-weight: 900;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.thermometer-heading strong {
  color: var(--coral-deep);
  font-size: 1.05rem;
}

.thermometer-display {
  min-height: 330px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 28px;
  gap: 0.45rem;
  flex: 1;
}

.state-scale {
  min-height: 330px;
  position: relative;
  overflow: hidden;
  border: 1px solid #d4e0e4;
  border-radius: 0.7rem;
  background: #f5f8f9;
}

.state-band {
  position: absolute;
  z-index: 0;
  right: 0;
  left: 0;
  transition: top 300ms ease, height 300ms ease;
}

.state-band-gas { top: 0; background: #f1e4f2; }
.state-band-liquid { background: #fff0cf; }
.state-band-solid { bottom: 0; background: #dff2f8; }

.state-boundary {
  height: 1px;
  position: absolute;
  right: 0;
  left: 0;
  z-index: 3;
  background: rgb(11 30 45 / 28%);
  transition: top 300ms ease;
}

.state-boundary span,
.scale-limit {
  position: absolute;
  right: 4px;
  padding: 1px 3px;
  color: #536b79;
  background: rgb(255 255 255 / 78%);
  font-size: 0.57rem;
  white-space: nowrap;
}

.state-boundary span {
  top: -8px;
}

.scale-limit {
  z-index: 5;
}

.scale-maximum { top: 4px; }
.scale-minimum { bottom: 4px; }

.state-band-name {
  position: absolute;
  left: 7px;
  z-index: 2;
  color: #4f6673;
  font-size: 0.57rem;
  font-weight: 850;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  transition: top 300ms ease, opacity 180ms ease;
}

.thermometer-tube {
  width: 18px;
  position: relative;
  align-self: stretch;
  justify-self: center;
  margin: 4px 0 12px;
  border: 3px solid #8298a3;
  border-radius: 999px 999px 7px 7px;
  background: #f5f8f9;
}

.thermometer-mercury {
  position: absolute;
  right: 3px;
  bottom: 4px;
  left: 3px;
  height: 57.14%;
  border-radius: 999px;
  background: #c8565a;
  transition: height 160ms linear;
}

.thermometer-bulb {
  width: 32px;
  height: 32px;
  position: absolute;
  right: 50%;
  bottom: -16px;
  border: 3px solid #8298a3;
  border-radius: 50%;
  background: #c8565a;
  transform: translateX(50%);
}

.energy-controls {
  padding: 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.energy-controls > p {
  margin: 0 0 0.2rem;
  color: var(--navy-650);
  font-size: 0.68rem;
  font-weight: 900;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.energy-controls button {
  min-height: 3rem;
  padding: 0.6rem 0.55rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  border: 1px solid var(--line);
  border-radius: 0.75rem;
  color: var(--navy-650);
  background: var(--surface);
  font-size: 0.73rem;
  font-weight: 850;
}

.energy-controls button span {
  width: 1.35rem;
  height: 1.35rem;
  display: inline-grid;
  place-items: center;
  border-radius: 50%;
  background: #eef3f5;
  font-size: 0.95rem;
}

.energy-controls button:hover {
  border-color: var(--coral-deep);
  color: var(--navy-950);
}

.energy-controls button[aria-pressed="true"] {
  border-color: var(--coral-deep);
  color: var(--coral-deep);
  background: #fff1f0;
  box-shadow: inset 0 0 0 1px rgb(200 86 90 / 12%);
}

.energy-controls .reset-simulation {
  min-height: 2.2rem;
  margin-top: auto;
  border-color: transparent;
  color: var(--navy-650);
  background: transparent;
}

.state-explanation {
  margin: 0 clamp(1rem, 3vw, 2rem);
  padding: 1rem 1.15rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  border: 1px solid #d8dff7;
  border-radius: 1rem;
  background: #edf1ff;
}

.state-summary {
  display: grid;
  grid-template-columns: auto auto 1fr;
  align-items: center;
  gap: 0.45rem 0.65rem;
}

.state-summary strong {
  color: #304caa;
  font-size: 0.82rem;
}

.state-summary p {
  margin: 0;
  color: var(--navy-650);
  font-size: 0.8rem;
}

.state-chip {
  padding: 0.34rem 0.55rem;
  border-radius: 999px;
  color: white;
  background: var(--particle-edge);
  font-size: 0.65rem;
  font-weight: 850;
}

.simulation-status {
  min-width: max-content;
  margin: 0;
  color: var(--navy-650);
  font-size: 0.72rem;
  font-weight: 750;
  text-align: right;
}

.conservation-note {
  margin: 0.8rem clamp(1rem, 3vw, 2rem) clamp(1.25rem, 3vw, 2rem);
  padding: 0.8rem 1rem;
  display: flex;
  align-items: baseline;
  gap: 0.45rem;
  border-left: 4px solid #74d5df;
  color: var(--navy-650);
  background: rgb(232 248 250 / 75%);
  font-size: 0.75rem;
}

.conservation-note strong {
  color: var(--navy-950);
}

.changes-simulator button:focus-visible,
.changes-learning-page a:focus-visible {
  outline: 3px solid var(--aqua-deep);
  outline-offset: 3px;
}

@keyframes state-solid-motion {
  from { transform: translate(var(--x1, -1px), var(--y1, 1px)); }
  to { transform: translate(var(--x2, 1px), var(--y2, -1px)); }
}

@keyframes state-liquid-motion {
  0%, 100% { transform: translate(0, 0); }
  30% { transform: translate(var(--x1, 3px), var(--y1, -2px)); }
  65% { transform: translate(var(--x2, -3px), var(--y2, 2px)); }
}

@keyframes state-gas-motion {
  0%, 100% { transform: translate(0, 0); }
  22% { transform: translate(var(--x1, 28px), var(--y1, -25px)); }
  46% { transform: translate(var(--x2, -34px), var(--y2, 21px)); }
  69% { transform: translate(var(--x3, 20px), var(--y3, 32px)); }
  86% { transform: translate(var(--x4, -27px), var(--y4, -29px)); }
}

@media (max-width: 920px) {
  .changes-simulation {
    grid-template-columns: minmax(0, 1fr) 180px;
  }

  .energy-controls {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
  }

  .energy-controls > p,
  .energy-controls .reset-simulation {
    grid-column: 1 / -1;
  }
}

@media (max-width: 700px) {
  .changes-tool-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .substance-picker {
    width: 100%;
  }

  .changes-simulation {
    grid-template-columns: minmax(0, 1fr) 155px;
  }

  .state-chamber {
    min-height: 380px;
  }

  .thermometer-display,
  .state-scale {
    min-height: 290px;
  }

  .state-explanation {
    align-items: flex-start;
    flex-direction: column;
  }

  .state-summary {
    grid-template-columns: auto 1fr;
  }

  .state-summary p {
    grid-column: 1 / -1;
  }

  .simulation-status {
    min-width: 0;
    text-align: left;
  }
}

@media (max-width: 560px) {
  .changes-simulation {
    grid-template-columns: 1fr;
  }

  .state-chamber {
    min-height: 330px;
  }

  .thermometer-panel {
    min-height: 390px;
  }

  .energy-controls {
    grid-template-columns: 1fr;
  }

  .energy-controls > p,
  .energy-controls .reset-simulation {
    grid-column: auto;
  }

  .conservation-note {
    align-items: flex-start;
    flex-direction: column;
  }
}

@media (prefers-reduced-motion: reduce) {
  .state-particle,
  .state-band,
  .state-boundary,
  .thermometer-mercury {
    animation: none !important;
    transition: none !important;
  }
}
