/* Agely marketplace simulator. Builds on ../styles.css for tokens, type and the top bar. */

:root {
  /* Outcome colours: a fixed categorical order, validated for colour-blind separation in both
     modes. Text never wears them; they only fill marks. */
  --o-matched: #6250d6;
  --o-engine: #1baf7a;
  --o-skill: #eb6834;
  --o-price: #2a78d6;
  --o-busy: #eda100;
  --o-declined: #e87ba4;
  --good: #1a7f4b;
}

@media (prefers-color-scheme: dark) {
  :root {
    --o-matched: #9085e9;
    --o-engine: #199e70;
    --o-skill: #d95926;
    --o-price: #3987e5;
    --o-busy: #c98500;
    --o-declined: #d55181;
    --good: #5fcf96;
  }
}

.sim {
  padding-bottom: 64px;
}

.sim-intro {
  max-width: 72ch;
  padding: 24px 0 32px;
}

.sim-intro h1 {
  font-size: clamp(2.25rem, 5vw, 3.25rem);
}

.sim-intro p {
  color: var(--text-muted);
  font-size: 1.125rem;
}

.sim-intro .sim-caveat {
  font-size: 1rem;
  padding-left: 14px;
  border-left: 4px solid var(--border);
}

.sim-layout {
  display: grid;
  grid-template-columns: 340px minmax(0, 1fr);
  gap: 32px;
  align-items: start;
}

/* Controls */
.controls {
  position: sticky;
  top: 16px;
  max-height: calc(100vh - 32px);
  overflow-y: auto;
  padding: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--card-radius);
}

.controls h2,
.panel h2 {
  font-size: 1.375rem;
}

.field {
  display: block;
  font-weight: 600;
  margin-bottom: 6px;
}

.controls select {
  width: 100%;
  min-height: var(--control-h);
  padding: 0 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font: inherit;
}

.control-buttons {
  display: grid;
  gap: 8px;
  margin: 12px 0 4px;
}

.btn {
  min-height: 48px;
  padding: 0 16px;
  border-radius: 12px;
  border: 1px solid var(--color-accent-strong);
  background: transparent;
  color: var(--color-accent-strong);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.btn:hover {
  background: var(--color-accent-soft);
}

.adjust summary {
  display: flex;
  align-items: center;
  min-height: 48px;
  margin-top: 8px;
  font-weight: 600;
  color: var(--color-accent-strong);
  cursor: pointer;
}

.controls fieldset {
  margin: 20px 0 0;
  padding: 0;
  border: 0;
}

.controls legend {
  padding: 0;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.125rem;
}

.slider {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 2px 12px;
  margin-top: 14px;
}

.slider output {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.slider input {
  grid-column: 1 / -1;
  width: 100%;
  height: 32px;
  accent-color: var(--color-accent-strong);
}

.toggle {
  display: grid;
  grid-template-columns: 24px 1fr;
  gap: 4px 10px;
  margin-top: 16px;
}

.toggle input {
  width: 22px;
  height: 22px;
  margin: 3px 0 0;
  accent-color: var(--color-accent-strong);
}

.toggle label {
  font-weight: 600;
}

.toggle p {
  grid-column: 2;
  margin: 0;
  color: var(--text-muted);
  font-size: 0.89rem;
}

/* Results */
.results {
  display: grid;
  gap: 20px;
}

.panel {
  padding: 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--card-radius);
}

.chart-note {
  max-width: 68ch;
  color: var(--text-muted);
}

.playback {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 16px 24px;
}

.playback .button {
  border: 0;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  min-width: 11.5em;
  justify-content: center;
}

.scrub {
  flex: 1 1 240px;
  display: grid;
  gap: 2px;
  font-weight: 600;
}

.scrub input {
  width: 100%;
  height: 32px;
  accent-color: var(--color-accent-strong);
}

.goals {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 12px;
}

.goal {
  display: grid;
  grid-template-columns: 32px 1fr;
  gap: 6px 10px;
  align-items: center;
}

.goal-mark {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 2px dashed var(--text-muted);
  color: var(--text-muted);
  font-weight: 600;
}

.goal--met .goal-mark {
  border: 2px solid var(--good);
  background: var(--good);
  color: var(--surface);
}

.goal-text strong {
  white-space: nowrap;
}

.goal-bar {
  grid-column: 2;
  height: 6px;
  border-radius: 3px;
  background: var(--surface-muted);
  overflow: hidden;
}

.goal-bar span {
  display: block;
  height: 100%;
  border-radius: 3px;
  background: var(--text-muted);
  transition: width 0.3s;
}

.goal--met .goal-bar span {
  background: var(--good);
}

.diagnosis {
  margin: 20px 0 0;
  padding: 14px 16px;
  border-radius: 12px;
  background: var(--color-accent-soft);
}

.tiles {
  display: grid;
  /* Localized USD amounts can include grouping spaces and a three-letter currency code. */
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 16rem), 1fr));
  gap: 12px;
}

.tile {
  padding: 16px 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}

.tile p {
  margin: 0;
}

.tile-label,
.tile-note {
  color: var(--text-muted);
  font-size: 0.89rem;
}

.tile-note {
  min-height: 1.5em;
}

.tile-value {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.75rem;
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}

/* Weekly outcome bars */
.weekbars {
  display: flex;
  align-items: stretch;
  gap: 3px;
  height: 220px;
  margin-top: 8px;
  border-bottom: 1px solid var(--border);
}

.weekbar {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column-reverse;
  gap: 2px;
  padding: 0 0 2px;
  border: 0;
  border-top: 4px solid transparent;
  background: none;
  cursor: pointer;
}

.weekbar--current {
  border-top-color: var(--text);
}

.weekbar--future {
  opacity: 0.18;
}

.seg {
  display: block;
  flex-basis: 0;
  min-height: 2px;
  border-radius: 2px;
}

.seg--matched {
  background: var(--o-matched);
}

.seg--engine {
  background: var(--o-engine);
}

.seg--skill {
  background: var(--o-skill);
}

.seg--price {
  background: var(--o-price);
}

.seg--busy {
  background: var(--o-busy);
}

.seg--declined {
  background: var(--o-declined);
}

.legend-list {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 6px 22px;
  margin: 14px 0 0;
  padding: 0;
  color: var(--text-muted);
}

.legend-list li {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.legend-list strong,
.legend-head {
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.legend-head {
  font-weight: 600;
  min-width: 4.5em;
}

.key {
  flex: none;
  width: 14px;
  height: 14px;
  border-radius: 4px;
}

.key--expert {
  background: var(--o-matched);
}

.key--buyer {
  background: var(--color-dev);
}

.table-view {
  margin-top: 16px;
}

.table-view summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--color-accent-strong);
  min-height: 44px;
  display: flex;
  align-items: center;
}

.table-scroll {
  overflow-x: auto;
}

.table-view table {
  border-collapse: collapse;
  width: 100%;
  font-variant-numeric: tabular-nums;
}

.table-view th,
.table-view td {
  padding: 6px 12px;
  border-bottom: 1px solid var(--border);
  text-align: right;
}

.table-view th:first-child {
  text-align: left;
}

/* Price fit: experts above the line, budgets below, on one dollar axis */
.fit {
  display: flex;
  gap: 3px;
  margin-top: 8px;
}

.fit-col {
  flex: 1 1 0;
  min-width: 0;
}

.fit-up,
.fit-down {
  height: 90px;
  display: flex;
}

.fit-up {
  align-items: flex-end;
  border-bottom: 1px solid var(--text-muted);
}

.fit-bar {
  display: block;
  width: 100%;
}

.fit-bar--expert {
  background: var(--o-matched);
  border-radius: 4px 4px 0 0;
}

.fit-bar--buyer {
  background: var(--color-dev);
  border-radius: 0 0 4px 4px;
}

.fit-tick {
  display: block;
  height: 1.5em;
  color: var(--text-muted);
  font-size: 0.89rem;
  white-space: nowrap;
}

.readout {
  margin: 14px 0 0;
  min-height: 3.2em;
}

/* Expert grid */
.expert-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 8px;
}

.expert {
  width: 30px;
  height: 30px;
  padding: 0;
  border-radius: 6px;
  border: 2px solid transparent;
  background: color-mix(in oklab, var(--o-matched) var(--level, 0%), var(--color-accent-soft));
  cursor: pointer;
}

.expert--none {
  background: transparent;
  border: 2px dashed var(--text-muted);
}

.expert--selected {
  outline: 3px solid var(--text);
  outline-offset: 1px;
}

@media (max-width: 900px) {
  .sim-layout {
    grid-template-columns: minmax(0, 1fr);
  }

  .controls {
    position: static;
    max-height: none;
  }

  .panel {
    padding: 18px;
  }

  .weekbars {
    height: 180px;
    gap: 1px;
  }

  .fit {
    gap: 1px;
  }
}
