:root {
  --bg: #0c0c0c;
  --fg: #e6e6e6;
  --dim: #7a7a7a;
  --faint: #4a4a4a;
  --blue: #3a82ef;
  --fs: 10px;
  --pad: 16px;
  --mono: "SF Mono", ui-monospace, SFMono-Regular, Menlo, "JetBrains Mono", Consolas, "Liberation Mono", monospace;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--fg);
}

body {
  display: flex;
  min-height: 100%;
  overflow: hidden;
  font-family: var(--mono);
  font-size: var(--fs);
  line-height: 1.4;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

.stage {
  position: relative;
  width: 540px;
  height: 540px;
  flex: none;
  margin: auto; /* centred, but scrolls from the top when taller than the screen */
}

canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  touch-action: none;
  outline: none;
}

.head, .controls, .foot {
  position: absolute;
  margin: 0;
}

.head {
  left: var(--pad);
  top: var(--pad);
  pointer-events: none;
}

h1 {
  margin: 0;
  font-size: calc(var(--fs) + 1px);
  font-weight: 400;
  letter-spacing: 0.04em;
  color: var(--fg);
}

.head p {
  margin: 0.3em 0 0;
  color: var(--dim);
}

/* Settings: quiet steppers in the empty top-right corner. */
.controls {
  right: var(--pad);
  top: var(--pad);
  display: grid;
  grid-template-columns: auto auto auto auto;
  align-items: center;
  justify-items: end;
  column-gap: 0.2em;
  color: var(--faint);
}

.ctl { display: contents; }

.ctl .k { padding-right: 0.6em; }

.ctl output {
  min-width: 5.5ch;
  text-align: center;
  color: var(--dim);
  font-variant-numeric: tabular-nums;
}

.ctl.disabled output, .ctl.disabled button { opacity: 0.35; }

button {
  font: inherit;
  letter-spacing: inherit;
  text-transform: inherit;
  color: var(--faint);
  background: none;
  border: 0;
  padding: 0.15em 0.35em;
  cursor: pointer;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}

button:hover, button:focus-visible { color: var(--fg); }
button:focus-visible { outline: 1px dotted var(--faint); outline-offset: 2px; }
button:disabled { cursor: default; color: var(--faint); }

/* The selected coffee's own stepper, under its dot on the axis. */
.cupctl {
  position: absolute;
  left: 0;
  top: 0;
  display: flex;
  align-items: center;
  white-space: nowrap;
  color: var(--blue);
  font-variant-numeric: tabular-nums;
  pointer-events: none; /* only the buttons take input; the rest stays the chart's */
}
.cupctl > * { background: var(--bg); }
.cupctl button { pointer-events: auto; }
.cupctl[hidden] { display: none; }
.cupctl .sep { padding: 0 0.5em; }
.cupctl button { color: var(--blue); opacity: 0.6; padding: 0 0.45em; line-height: 1; }
.cupctl button:hover, .cupctl button:focus-visible { color: var(--blue); opacity: 1; }
.cupctl button:disabled { opacity: 0.2; }

.foot {
  left: var(--pad);
  right: var(--pad);
  bottom: var(--pad);
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1em;
  pointer-events: none;
}

.foot p { margin: 0; color: var(--fg); }

.foot .reset { pointer-events: auto; margin-right: -0.35em; }

/* Touch screens: give the steppers finger-sized targets. */
@media (pointer: coarse) {
  .controls { row-gap: 0; }
  .ctl button, .cupctl button { min-width: 30px; min-height: 28px; }
  .foot .reset { min-height: 28px; }
}

/* Narrow screens: settings move under the chart, two per row. app.js sets
   their top from the chart height. */
.stage.narrow .controls {
  left: var(--pad);
  right: var(--pad);
  grid-template-columns: 1fr 1fr;
  justify-items: start;
}
.stage.narrow .ctl { display: flex; align-items: center; }
.stage.narrow .ctl .k { min-width: 11ch; }
.stage.narrow .ctl:first-child .k, .stage.narrow .ctl:nth-child(3) .k { margin-left: -0.35em; }

@media (max-width: 499px) {
  body { overflow-y: auto; }
}
