/* ── Random Number Generator — tool-specific styles ──────────────────────────
   Global styles are inherited from /css/style.css.
   Colours reference CSS custom properties only — no hardcoded values.
   ─────────────────────────────────────────────────────────────────────────── */

.rng-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-card, 8px);
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
}

.rng-card__heading {
  font-size: 1.05rem;
  margin: 0;
}

.rng-card__top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
}

/* ── Presets ──────────────────────────────────────────────────────────── */

.rng-preset-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.rng-preset-btn {
  padding: 0.4rem 0.8rem;
  border: 1px solid var(--border-color);
  border-radius: 999px;
  background: var(--bg-card);
  color: var(--text-primary);
  cursor: pointer;
  font-size: 0.82rem;
}

.rng-preset-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* ── Fields ───────────────────────────────────────────────────────────── */

.rng-field-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.85rem;
}

.rng-field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

/* .rng-field sets display:flex, which overrides the UA [hidden]{display:none}
   rule, so this restores the hide behavior (same pattern as .tool[hidden] in
   /css/style.css) — needed for #rng-decimal-places-row, toggled via JS. */
.rng-field[hidden] {
  display: none;
}

.rng-label {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-secondary);
}

.rng-input {
  width: 100%;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-control, 8px);
  background: var(--bg-input, var(--bg-card));
  color: var(--text-primary);
  font-size: 0.95rem;
  font-family: var(--font-mono, monospace);
}

.rng-input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.rng-select {
  font-family: inherit;
  cursor: pointer;
}

/* ── Mode toggle ──────────────────────────────────────────────────────── */

.rng-mode-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.rng-mode-pill {
  flex: 1 1 160px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  cursor: pointer;
  font-size: 0.875rem;
  color: var(--text-primary);
  transition: border-color var(--transition), background var(--transition);
}

.rng-mode-pill:hover {
  border-color: var(--accent);
}

.rng-mode-pill input[type="radio"] {
  accent-color: var(--accent);
  margin: 0;
}

.rng-mode-pill input[type="radio"]:checked ~ span {
  font-weight: 600;
}

.rng-mode-pill:has(input:checked) {
  border-color: var(--accent);
  background: var(--accent-light);
}

/* ── Options row (unique toggle + sort select) ───────────────────────── */

.rng-options-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 1.25rem;
}

.rng-checkbox {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.9rem;
  color: var(--text-primary);
  cursor: pointer;
}

.rng-sort-field {
  min-width: 200px;
}

/* ── Error ────────────────────────────────────────────────────────────── */

.rng-error {
  margin: 0;
  color: var(--color-danger, #ef4444);
  font-size: 0.875rem;
}

/* rng-error uses the default block display, so no [hidden] override is
   needed here — but rng-results, rng-stats and rng-actions below set
   display:flex/grid, which overrides the UA [hidden]{display:none} rule
   (same pitfall documented in /css/style.css for .tool[hidden]). */

.rng-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
}

.rng-actions[hidden] { display: none; }

/* ── Results ──────────────────────────────────────────────────────────── */

.rng-results {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  max-height: 20rem;
  overflow-y: auto;
  padding: 0.25rem 0.1rem;
}

.rng-results[hidden] { display: none; }

.rng-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2.5rem;
  padding: 0.4rem 0.7rem;
  border: 1px solid var(--border-color);
  border-radius: 999px;
  background: var(--bg-input, var(--bg-card));
  color: var(--text-primary);
  font-family: var(--font-mono, monospace);
  font-size: 0.9rem;
  font-weight: 600;
}

#rng-stats[hidden] { display: none; }

.rng-empty {
  margin: 0;
  color: var(--text-secondary);
  font-size: 0.9rem;
  text-align: center;
  padding: 1rem 0;
}

.rng-empty[hidden] { display: none; }

/* ── History ──────────────────────────────────────────────────────────── */

.rng-history-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.rng-history-list li {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  padding: 0.6rem 0.85rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-control, 8px);
  background: var(--bg-input, var(--bg-card));
  font-size: 0.85rem;
  cursor: pointer;
  text-align: left;
  color: inherit;
  width: 100%;
}

.rng-history-list li:hover {
  border-color: var(--accent);
}

.rng-history-summary {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.rng-history-config {
  font-weight: 600;
}

.rng-history-time {
  font-size: 0.75rem;
  color: var(--text-secondary);
  font-family: var(--font-mono, monospace);
  white-space: nowrap;
}

.rng-history-numbers {
  color: var(--text-secondary);
  font-family: var(--font-mono, monospace);
  word-break: break-word;
}

/* ── Uses grid ────────────────────────────────────────────────────────── */

.rng-uses-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
}

.rng-uses-grid article h3 {
  margin: 0 0 0.35rem;
  font-size: 1rem;
}

.rng-uses-grid article p {
  margin: 0;
  color: var(--text-secondary);
  font-size: 0.9rem;
}

@media (max-width: 640px) {
  .rng-mode-pill {
    flex: 1 1 100%;
  }
  .rng-options-row {
    flex-direction: column;
    align-items: stretch;
  }
}
