/* =========================================================
   Buckets — the hash map visualiser

   Light ground, one accent, and colour carried entirely by
   the tiles, whose hue comes from the key's own hash.
   ========================================================= */

:root {
  --paper: #fcfcfd;
  --panel: #ffffff;
  --sunk: #f1f2f5;
  --ink: #14161c;
  --ink-2: #4a4e59;
  --muted: #858a97;
  --rule: #e3e5ea;

  --accent: #3d5afe;
  --accent-soft: #edefff;
  --warn: #c2410c;

  --ui: "Outfit", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --mono: "Roboto Mono", ui-monospace, monospace;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--ui);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

button,
input {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

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

.page {
  max-width: 1000px;
  margin-inline: auto;
  padding: clamp(1.5rem, 5vw, 3rem) clamp(1rem, 4vw, 2rem) 4rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

/* --- masthead --- */

.eyebrow {
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.05em;
  color: var(--muted);
  margin: 0;
}

.masthead h1 {
  font-size: clamp(2rem, 6vw, 3rem);
  font-weight: 700;
  letter-spacing: -0.035em;
  line-height: 1;
  margin: 0.35rem 0 0;
}

.lede {
  max-width: 62ch;
  color: var(--ink-2);
  margin: 0.6rem 0 0;
}

/* --- readout --- */

.readout {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(7rem, 1fr));
  align-items: end;
  gap: 1rem 1.5rem;
  padding: 1rem 1.15rem;
  background: var(--panel);
  border: 1px solid var(--rule);
  border-radius: 10px;
}

.stat {
  display: flex;
  flex-direction: column;
}

.stat-label {
  font-size: 0.68rem;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}

.stat-value {
  font-family: var(--mono);
  font-size: 1.5rem;
  font-weight: 500;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

.gauge {
  grid-column: 1 / -1;
}

.gauge-track {
  position: relative;
  height: 8px;
  border-radius: 4px;
  background: var(--sunk);
  overflow: visible;
}

.gauge-fill {
  height: 100%;
  border-radius: 4px;
  background: var(--accent);
  transition: width 220ms ease, background-color 220ms ease;
}

.gauge-fill.is-full {
  background: var(--warn);
}

.gauge-mark {
  position: absolute;
  top: -3px;
  bottom: -3px;
  width: 2px;
  background: var(--ink);
  opacity: 0.55;
}

.gauge-label {
  font-family: var(--mono);
  font-size: 0.68rem;
  color: var(--muted);
  margin: 0.35rem 0 0;
}

/* --- controls --- */

.controls {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.5rem;
}

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

.field > span {
  font-family: var(--mono);
  font-size: 0.68rem;
  color: var(--muted);
}

.field input {
  border: 1px solid var(--rule);
  border-radius: 7px;
  padding: 0.45rem 0.6rem;
  background: var(--panel);
  font-family: var(--mono);
  font-size: 0.88rem;
  width: 10rem;
}

.field input:focus {
  outline: none;
  border-color: var(--accent);
}

.primary,
.quiet {
  border-radius: 7px;
  padding: 0.48rem 0.9rem;
  font-size: 0.85rem;
  font-weight: 500;
  border: 1px solid transparent;
}

.primary {
  background: var(--accent);
  color: #fff;
}

.primary:hover {
  background: #3049e0;
}

.quiet {
  background: var(--panel);
  border-color: var(--rule);
  color: var(--ink-2);
}

.quiet:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.hint {
  font-size: 0.8rem;
  color: var(--warn);
  min-height: 1.1em;
  margin: 0;
}

/* --- the chart --- */

.chart-wrap {
  overflow-x: auto;
  padding-bottom: 0.25rem;
}

.chart {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(38px, 1fr);
  align-items: end;
  gap: 4px;
  min-height: calc(var(--tallest, 1) * 30px + 60px);
  padding: 1rem 0.9rem 0.5rem;
  background: var(--panel);
  border: 1px solid var(--rule);
  border-radius: 10px;
  min-width: 100%;
}

/* thirty-two buckets will not fit comfortably, so let it scroll */
.chart.is-wide {
  grid-auto-columns: minmax(30px, 1fr);
  min-width: 900px;
}

.column {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 4px;
  min-width: 0;
}

.stack {
  display: flex;
  flex-direction: column-reverse;
  gap: 3px;
  min-height: 4px;
  border-bottom: 2px solid var(--rule);
  padding-bottom: 4px;
}

.column.is-collision .stack {
  border-bottom-color: var(--warn);
}

.tile {
  height: 26px;
  border-radius: 5px;
  display: grid;
  place-items: center;
  overflow: hidden;
  font-size: 0.6rem;
  font-weight: 500;
  letter-spacing: -0.01em;
  white-space: nowrap;
  text-overflow: ellipsis;
  padding-inline: 3px;

  background: hsl(var(--hue) 62% 88%);
  color: hsl(var(--hue) 55% 26%);
  border: 1px solid hsl(var(--hue) 45% 74%);
}

@keyframes land {
  from {
    transform: translateY(-8px);
    opacity: 0;
  }
}

.tile.is-new {
  animation: land 260ms ease-out;
}

.index {
  font-family: var(--mono);
  font-size: 0.62rem;
  color: var(--muted);
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.column.is-collision .index {
  color: var(--warn);
  font-weight: 500;
}

/* --- log --- */

.log-wrap h2 {
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 0.5rem;
}

.log {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 11rem;
  overflow-y: auto;
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--ink-2);
}

.log li {
  padding: 0.28rem 0;
  border-bottom: 1px solid var(--rule);
}

.log li.is-grow {
  color: var(--warn);
  font-weight: 500;
}

.colophon {
  font-size: 0.78rem;
  color: var(--muted);
}

.colophon a {
  color: var(--ink-2);
  text-underline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  .tile.is-new,
  .gauge-fill {
    animation: none;
    transition: none;
  }
}
