/* ============================================================
   Liquidation Risk Simulator: live prototype on the Brighty case.
   Desktop only (960px+). Below that the static carousel stays.
   Values come from the Figma file (XYZ Terminal lib, restored).
   ============================================================ */

.sim-figure {
  display: none;
}

@media (min-width: 960px) {
  .sim-figure.is-ready {
    display: block;
  }

  /* Text and screen get the usual 80px, even right after the hidden carousel */
  .case-section > .case-figure + .sim-figure {
    margin-top: 80px;
  }

  .case-carousel:has(+ .sim-figure.is-ready) {
    display: none;
  }
}

.sim-stage {
  position: relative;
  overflow: hidden;
  display: flex;
  justify-content: center;
  /* Modal hangs from the top; risk-sim.js keeps the stage at its tallest
     height, so a shorter state never rescales the backdrop or moves the page */
  align-items: flex-start;
  padding: 56px 24px;
  background: #000;
}

/* The terminal behind the modal, blurred and dimmed like the Figma scrim */
.sim-backdrop {
  position: absolute;
  inset: -24px;
  background: url("work/images/brighty/terminal-1536.webp") center / cover no-repeat;
  filter: blur(8px);
  opacity: 0.45;
}

/* ---------- Tokens ---------- */
.sim {
  --w100: #fff;
  --w50: rgba(255, 255, 255, 0.5);
  --w25: rgba(255, 255, 255, 0.25);
  --w20: rgba(255, 255, 255, 0.2);
  --w10: rgba(255, 255, 255, 0.1);
  --w8: rgba(255, 255, 255, 0.08);
  --green: #beff14;
  --red: #f65a4c;
  --soft-red: #f87784;
  --orange: #ff9500;
  --yellow: #ffcc00;
  --blue: #007aff;
  --blue-text: #2e8fff; /* blue for small text on dark: 5.2:1, --blue is 4.18:1 */

  position: relative;
  width: 872px;
  flex: none;
  border: 1px solid var(--w8);
  border-radius: 12px;
  overflow: hidden;
  background: #141414;
  color: var(--w100);
  font-family: "Inter", sans-serif;
  font-feature-settings: "tnum" 1;
  font-size: 13px;
  line-height: 16px;
  letter-spacing: -0.26px;
  text-align: left;
  -webkit-font-smoothing: antialiased;
  user-select: none;
  -webkit-user-select: none;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.5);
}

.sim * {
  box-sizing: border-box;
}

/* Undo the case page's running-text styles inside the modal */
.sim p {
  margin: 0;
  font-size: inherit;
  line-height: inherit;
  letter-spacing: inherit;
}

.sim p + p {
  margin-top: 0;
}

.sim button {
  font: inherit;
  letter-spacing: inherit;
  color: inherit;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
}

.sim .t11 {
  font-size: 11px;
  line-height: 12px;
  letter-spacing: -0.22px;
  font-weight: 500;
}

.sim .is-red { color: var(--red); }
.sim .is-green { color: var(--green); }
.sim .is-orange { color: var(--orange); }
.sim .is-muted { color: var(--w50); }
.sim .is-white { color: var(--w100); }

/* ---------- Header ---------- */
.sim-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 8px 12px 12px;
  border-bottom: 1px solid var(--w8);
}

.sim .sim-title {
  flex: 1;
  font-size: 15px;
  line-height: 20px;
  letter-spacing: -0.3px;
  font-weight: 700;
}

.sim-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
}

.sim-close img {
  display: block;
  width: 20px;
  height: 20px;
}

/* ---------- Body ---------- */
.sim-body {
  display: flex;
  gap: 32px;
  padding: 16px 12px;
}

/* ---------- Account column ---------- */
.sim-account {
  display: flex;
  flex-direction: column;
  gap: 20px;
  width: 240px;
  flex: none;
}

.sim-cmr {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sim-cmr-head {
  display: flex;
  gap: 8px;
  font-weight: 700;
}

.sim-cmr-head p:first-child {
  flex: 1;
}

.sim-cmr-bar {
  height: 6px;
  border-radius: 3px;
  background: var(--w10);
  overflow: hidden;
}

.sim-cmr-fill {
  height: 100%;
  border-radius: 3px;
  background: currentColor;
  transition: width 0.15s ease;
}

.sim .sim-liq-note {
  padding: 8px 10px;
  border-radius: 4px;
  background: rgba(246, 90, 76, 0.1);
  color: var(--red);
}

.sim-metrics {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sim-metric {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 24px;
  font-weight: 500;
}

.sim-metric p:first-child {
  flex: 1;
  color: var(--w50);
}

.sim-metric p:last-child {
  text-align: right;
  white-space: nowrap;
}

.sim-divider {
  height: 1px;
  background: var(--w8);
}

.sim-scenarios {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.sim .sim-label-caps {
  font-size: 9px;
  line-height: 12px;
  letter-spacing: 0.54px;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--w50);
}

/* .sim prefix: outweighs the `.sim button` reset above */
.sim .sim-scenario {
  display: flex;
  align-items: center;
  gap: 4px;
  width: 100%;
  height: 32px;
  padding: 0 10px;
  border-radius: 4px;
  background: var(--w8);
  box-shadow: inset 0 0 0 1px transparent;
  text-align: left;
  transition: background-color 0.15s ease;
}

.sim button.sim-scenario:hover {
  background: var(--w10);
}

.sim-scenario b {
  font-weight: 700;
  white-space: nowrap;
}

.sim-scenario span {
  flex: 1;
  text-align: right;
  color: var(--w50);
}

.sim button.sim-scenario.is-active {
  background: var(--w10);
  box-shadow: inset 0 0 0 1px rgba(190, 255, 20, 0.5);
}

.sim-scenario.is-active span {
  color: var(--green);
}

/* A falling market is bad news: red instead of green */
.sim button.sim-scenario.is-active.is-down {
  box-shadow: inset 0 0 0 1px rgba(246, 90, 76, 0.5);
}

.sim-scenario.is-active.is-down span {
  color: var(--red);
}

/* ---------- Footer ---------- */
.sim-foot {
  padding: 12px;
  text-align: center;
}

.sim-footnote {
  color: var(--w50); /* --w25 was 2.24:1, below WCAG AA */
}

/* ---------- Positions column ---------- */
.sim-positions {
  width: 576px;
  flex: none;
}

.sim-pos-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--w8);
}

.sim-pos-head b {
  font-weight: 700;
}

.sim-pos-head .sim-count {
  color: var(--w50);
}

.sim-tag {
  display: inline-flex;
  align-items: center;
  height: 24px;
  padding: 0 7px;
  border-radius: 4px;
  background: var(--w10);
  color: var(--w50);
  font-weight: 500;
  white-space: nowrap;
}

/* "Simulated" is a warning, not a disabled state */
.sim-tag--warn {
  background: rgba(255, 204, 0, 0.12);
  color: var(--yellow);
}

.sim-spacer {
  flex: 1;
}

.sim .sim-reset {
  height: 24px;
  padding: 0 8px;
  border-radius: 8px;
  font-weight: 700;
  line-height: 13px;
  letter-spacing: -0.13px;
  transition: background-color 0.15s ease;
}

.sim button.sim-reset:hover:not(:disabled) {
  background: var(--w8);
}

.sim button.sim-reset:disabled {
  opacity: 0.4;
  cursor: default;
}

/* ---------- Position row ---------- */
.sim-row {
  display: flex;
  flex-direction: column;
  gap: 24px;
  padding: 16px 0 12px;
  border-bottom: 1px solid var(--w8);
}

.sim-row:last-child {
  border-bottom: 0;
}

.sim-row-head {
  display: flex;
  align-items: center;
  gap: 16px;
}

.sim-asset {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  font-weight: 700;
  white-space: nowrap;
}

.sim-coin {
  position: relative;
  width: 20px;
  height: 20px;
  border-radius: 10px;
  overflow: hidden;
  flex: none;
}

.sim-coin img {
  position: absolute;
  inset: 0;
  display: block;
  width: 20px;
  height: 20px;
}

.sim-coin--eth { background: #627eea; }
.sim-coin--hype { background: #002417; }

.sim-coin--hype img {
  inset: 3.5px;
  width: 13px;
  height: 13px;
}

.sim-side {
  display: inline-flex;
  align-items: center;
  height: 20px;
  padding: 0 6px;
  border: 1px solid currentColor;
  border-radius: 4px;
}

.sim-stat {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
  width: 96px;
  flex: none;
  font-weight: 500;
  white-space: nowrap;
  text-align: right;
}

.sim-stat .t11 {
  color: var(--w50);
}

/* Holds the height of the track it replaces: 16 + 6 + labels (16 or 28) */
.sim-closed {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  min-height: 38px;
}

.sim-closed--full {
  min-height: 50px;
}

.sim-closed .t11 {
  align-self: flex-start;
  padding-top: 6px;
}

/* Room for three fixes, whether or not they are offered */
.sim-fixes {
  min-height: 120px;
}

.sim .sim-fixes-empty {
  color: var(--w25);
  padding-top: 4px;
}

/* ---------- Price track ---------- */
.sim-track-block {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.sim-track {
  position: relative;
  height: 16px;
  cursor: pointer;
  touch-action: none;
}

/* Taller hit area than the 16px track */
.sim-track::before {
  content: "";
  position: absolute;
  inset: -8px 0;
}

.sim-track > * {
  position: absolute;
  pointer-events: none;
}

.sim-base,
.sim-zone,
.sim-range {
  top: 6px;
  height: 4px;
}

.sim-base {
  left: 0;
  width: 100%;
  border-radius: 2px;
  background: #2c2c2c; /* --w10 on the panel */
}

/* Track layers are solid colors, not translucent ones: translucent layers
   add up where they overlap (range over base, the market tick over the
   track) and leave brighter patches. Each value is what the old rgba
   looked like on the #141414 panel, so the look doesn't change. */

/* Liquidated account: every track turns red */
.sim-base.is-liquidated {
  background: #853730;
}

.sim-zone {
  border-radius: 2px;
  background: #91433c;
}

.sim-range {
  background: #565656;
}

.sim-base.is-liquidated ~ .sim-zone { background: #be493e; }
.sim-base.is-liquidated ~ .sim-range { background: #9d5f59; }

.sim-tick {
  top: 3px;
  width: 2px;
  height: 10px;
  border-radius: 1px;
}

.sim-tick--sl { background: var(--soft-red); }
.sim-tick--tp { background: var(--blue); }

.sim-tick--market {
  top: 0;
  height: 16px;
  /* A step lighter than the range so the center stays visible where it crosses the track */
  background: #8c8c8c;
}

.sim-liq-marker {
  top: 0;
  width: 4px;
  height: 16px;
  border-radius: 1px;
  background: var(--red);
}

/* Where the liquidation price was before the simulation */
.sim-liq-marker.is-ghost {
  background: #683935; /* --red at 30% on the track */
}

/* Market value before the simulated one, struck through */
.sim .sim-was {
  color: var(--w50);
  font-size: 11px;
  letter-spacing: -0.22px;
  font-weight: 500;
  text-decoration: line-through;
  text-decoration-color: rgba(255, 255, 255, 0.35);
  /* Smaller type must not make the line taller */
  line-height: 1;
}

.sim-thumb {
  top: 0;
  width: 10px;
  height: 16px;
  border-radius: 3px;
  background: var(--w100);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
  pointer-events: auto !important;
  cursor: grab;
  outline: none;
  transition: box-shadow 0.15s ease;
}

.sim-track:hover .sim-thumb,
.sim-thumb:focus-visible,
.sim-thumb.is-hint {
  box-shadow: 0 0 0 3px #4f4f4f, 0 1px 4px rgba(0, 0, 0, 0.5);
}

.sim-thumb.is-dragging,
.sim-thumb.is-dragging:focus-visible {
  cursor: grabbing;
  box-shadow: 0 0 0 4px #50660d, 0 1px 4px rgba(0, 0, 0, 0.5);
}

.sim-tip {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 8px);
  translate: -50% 0;
  padding: 3px 6px;
  border: 1px solid var(--w10);
  border-radius: 4px;
  background: #000;
  color: var(--w50);
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease;
}

.sim-track:hover .sim-tip,
.sim-thumb:focus-visible .sim-tip,
.sim-thumb.is-hint .sim-tip,
.sim-thumb.is-dragging .sim-tip {
  opacity: 1;
}

.sim-thumb.is-dragging .sim-tip,
.sim-thumb:focus-visible .sim-tip {
  color: var(--w100);
}

/* ---------- Chips under the track ---------- */
.sim-labels {
  position: relative;
  height: 16px;
}

.sim-labels--full {
  height: 28px;
}

.sim-chip {
  position: absolute;
  top: 50%;
  translate: 0 -50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 2px 6px;
  border-radius: 4px;
  white-space: nowrap;
  text-align: center;
}

.sim-chip--liq {
  background: #0a0a0a;
  color: var(--red);
}

.sim-chip--sl {
  background: #2b1b1a;
  color: var(--soft-red);
}

.sim-chip--tp {
  background: #121e2c;
  color: var(--blue-text);
}

.sim-chip--warn {
  background: #2c2112;
  color: var(--orange);
}

.sim-chip--muted {
  color: var(--w50);
}
