/* Dice-dependent line simulation — shared by EN + HE "Why Line Balancing Backfires" pages.
   Scoped under .dice-sim so it never leaks into header/footer/nav (no bare element selectors). */

.dice-sim {
  --ds-ink: #1a1a1a;
  --ds-muted: #666;
  --ds-line: #e5e7eb;
  --ds-panel: #fff;
  --ds-blue: #2563eb;
  --ds-blue-dark: #1d4ed8;
  --ds-red: #C62828;
  --ds-red-dark: #B71C1C;
  --ds-green: #1e7d32;
  --ds-amber: #b45309;
  --ds-shadow: 0 10px 30px rgba(17, 24, 39, .08);
  margin: 2.5rem 0;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  color: var(--ds-ink);
}

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

.dice-sim .sim-panel,
.dice-sim .summary-panel {
  background: var(--ds-panel);
  border: 1px solid var(--ds-line);
  border-radius: 12px;
  box-shadow: var(--ds-shadow);
}

.dice-sim .sim-panel {
  padding: 1.75rem;
  margin-bottom: 1.25rem;
  overflow: hidden;
}

.dice-sim .dice-banner {
  display: grid;
  grid-template-columns: auto auto;
  justify-content: center;
  align-items: center;
  gap: 1rem;
  margin: 0 0 1.5rem;
}

.dice-sim .dice-label {
  color: var(--ds-muted);
  font-size: 1.1rem;
  font-weight: 700;
}

.dice-sim .dice-value {
  display: grid;
  place-items: center;
  min-width: 84px;
  height: 84px;
  border: 4px solid var(--ds-red);
  border-radius: 12px;
  background: #fff;
  color: var(--ds-red);
  font-size: 2.75rem;
  font-weight: 800;
}

.dice-sim .line {
  display: grid;
  grid-template-columns:
    minmax(52px, 1fr) 14px
    repeat(4, minmax(70px, 1.5fr) 14px minmax(48px, 0.85fr) 14px)
    minmax(70px, 1.5fr) 14px
    minmax(52px, 1fr);
  align-items: stretch;
  gap: 4px;
  direction: ltr;
  min-height: 220px;
  max-width: 100%;
}

.dice-sim .machine-wrap {
  display: flex;
  align-items: center;
  min-width: 0;
}

.dice-sim .source,
.dice-sim .finished {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100px;
  border: 1px solid var(--ds-line);
  border-radius: 10px;
  background: #eef4ff;
  color: var(--ds-ink);
  text-align: center;
  font-weight: 700;
  padding: 8px 4px;
  font-size: 11px;
  overflow-wrap: break-word;
}

.dice-sim .finished {
  background: #eef7ec;
}

.dice-sim .finished-value {
  display: block;
  color: var(--ds-green);
  font-size: 1.5rem;
  line-height: 1;
  font-weight: 800;
}

.dice-sim .finished-label {
  display: block;
  margin-top: 6px;
  color: var(--ds-ink);
  font-size: 11px;
  font-weight: 700;
}

.dice-sim .machine {
  position: relative;
  width: 100%;
  min-height: 148px;
  border: 2px solid #d1d5db;
  border-radius: 10px;
  background: #fff;
  padding: 12px 6px;
  overflow: hidden;
  transition: transform .18s ease, border-color .18s ease, box-shadow .18s ease, background .18s ease;
}

.dice-sim .machine.active {
  border-color: var(--ds-blue);
  background: #f3f7ff;
  box-shadow: 0 0 0 5px rgba(37, 99, 235, .14), 0 12px 28px rgba(37, 99, 235, .16);
  transform: translateY(-4px);
}

.dice-sim .machine.just-ran {
  border-color: var(--ds-amber);
}

.dice-sim .machine-title {
  font-size: .95rem;
  font-weight: 800;
  text-align: center;
}

.dice-sim .machine-stat {
  margin-top: 10px;
  color: var(--ds-muted);
  font-size: 11px;
  font-weight: 600;
  text-align: center;
}

.dice-sim .capacity-average {
  margin-top: 6px;
  color: var(--ds-blue);
  font-size: 10px;
  font-weight: 700;
  text-align: center;
}

.dice-sim .lost-total {
  margin-top: 6px;
  color: var(--ds-red);
  font-size: 10px;
  font-weight: 700;
  text-align: center;
}

.dice-sim .buffer {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  align-self: center;
  min-height: 56px;
  padding: 6px 4px;
  border: 2px dashed #cbd5e1;
  border-radius: 10px;
  background: #fff;
  color: var(--ds-ink);
  font-weight: 700;
  text-align: center;
  overflow-wrap: break-word;
}

.dice-sim .unit-value {
  unicode-bidi: isolate;
  white-space: nowrap;
  font-size: 12px;
}

.dice-sim .buffer-label {
  display: block;
  margin-top: 3px;
  color: var(--ds-muted);
  font-size: 9px;
  font-weight: 600;
  line-height: 1.25;
}

.dice-sim .flow {
  display: grid;
  place-items: center;
  color: var(--ds-muted);
  font-size: 1.1rem;
  font-weight: 700;
}

.dice-sim .summary-panel {
  display: grid;
  grid-template-columns: minmax(210px, auto) 1fr 2fr;
  gap: 1.1rem;
  padding: 1.5rem;
  align-items: stretch;
}

.dice-sim .controls {
  display: grid;
  gap: 10px;
  align-content: start;
}

.dice-sim .ds-btn {
  min-height: 48px;
  border: 0;
  border-radius: 8px;
  font: inherit;
  font-size: .95rem;
  font-weight: 700;
  line-height: 1.25;
  cursor: pointer;
  white-space: normal;
  padding: 10px 14px;
  transition: background .2s ease;
}

.dice-sim .ds-btn-run {
  background: var(--ds-red);
  color: #fff;
}

.dice-sim .ds-btn-run:hover {
  background: var(--ds-red-dark);
}

.dice-sim .ds-btn-reset {
  background: #f3f4f6;
  color: var(--ds-ink);
  border: 1px solid var(--ds-line);
}

.dice-sim .ds-btn-reset:hover {
  background: #e5e7eb;
}

.dice-sim .ds-btn:focus-visible {
  outline: 3px solid rgba(37, 99, 235, .45);
  outline-offset: 2px;
}

.dice-sim .last-run {
  min-height: 108px;
  border: 1px solid var(--ds-line);
  border-radius: 10px;
  background: #fafafa;
  padding: 14px;
  font-size: .95rem;
  line-height: 1.55;
}

.dice-sim .last-run strong {
  color: var(--ds-blue);
}

.dice-sim .metric-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 10px;
}

.dice-sim .metric {
  border: 1px solid var(--ds-line);
  border-radius: 10px;
  background: #fff;
  padding: 12px;
}

.dice-sim .metric-value {
  display: block;
  font-size: 1.6rem;
  font-weight: 800;
  line-height: 1;
}

.dice-sim .metric-label {
  display: block;
  margin-top: 6px;
  color: var(--ds-muted);
  font-size: 11px;
  font-weight: 700;
}

.dice-sim .metric.danger {
  border-color: rgba(198, 40, 40, .35);
  background: #fdf3f2;
}

.dice-sim .metric.danger .metric-value,
.dice-sim .metric.danger .metric-label {
  color: var(--ds-red);
}

.dice-sim .metric.opportunity {
  border-color: rgba(30, 125, 50, .35);
  background: #f1f8f0;
}

.dice-sim .metric.opportunity .metric-value,
.dice-sim .metric.opportunity .metric-label {
  color: var(--ds-green);
}

.dice-sim .log {
  grid-column: 2 / 4;
  max-height: 118px;
  overflow: auto;
  border: 1px solid var(--ds-line);
  border-radius: 10px;
  background: #fff;
  padding: 8px 10px;
  font-size: 12px;
  color: var(--ds-muted);
}

.dice-sim .log div {
  padding: 5px 0;
  border-bottom: 1px solid #f1f2f4;
}

.dice-sim .log div:last-child {
  border-bottom: 0;
}

@media (max-width: 980px) {
  .dice-sim .line {
    grid-template-columns: 1fr;
    direction: inherit;
    gap: 8px;
    min-height: 0;
  }

  html[dir="rtl"] .dice-sim .line {
    direction: rtl;
  }

  html[dir="ltr"] .dice-sim .line {
    direction: ltr;
  }

  .dice-sim .machine {
    min-height: 0;
  }

  .dice-sim .source,
  .dice-sim .finished {
    min-height: 0;
    padding: 10px;
  }

  .dice-sim .buffer {
    align-self: stretch;
    min-height: 0;
    max-height: none;
  }

  .dice-sim .flow {
    min-height: 24px;
    font-size: 0;
  }

  .dice-sim .flow::before {
    content: "\2193";
    font-size: 1.1rem;
    color: var(--ds-muted);
  }

  .dice-sim .dice-banner,
  .dice-sim .summary-panel,
  .dice-sim .metric-grid {
    grid-template-columns: 1fr;
  }

  .dice-sim .log {
    grid-column: auto;
  }
}
