/* The grind picker: the grind of a bag of coffee chosen at a roaster's cart, alone on a white page. A small burr
   grinder fills a glass jar beside the five options; the grinder and the glass are SVG, the coffee is a canvas drawn
   by the script with the colours below. */
:root {
  --page: #ffffff;          /* the page */
  --ink: #1f1915;           /* the names, the ring round the grind chosen */
  --muted: #8a8079;         /* the lines under the names */
  --chosen: #f6efe7;        /* behind the grind chosen */
  --hover: #faf7f3;         /* behind a grind under the pointer */
  --accent: #8c5a35;        /* the line and the size of the grind chosen */
  --roast-dark: #2c190e;    /* the darkest coffee */
  --roast: #5d3920;         /* the coffee */
  --roast-light: #9c6c46;   /* the palest grains, where the bean was cut */
  --bean: #4a2a17;          /* the outside of a whole bean */
  --chaff: #d8b48c;         /* the silverskin left in a bean's crease */
  --body: #2a2623;          /* the grinder's matte body */
  --body-light: #4f4843;    /* the body where the light turns round it */
  --body-dark: #151311;     /* the body in its own shade */
  --steel: #b9bec3;         /* the brushed steel of the chute, the ring and the stand */
  --steel-light: #f1f3f4;
  --steel-dark: #7f868d;
  --steel-deep: #4b5157;
  --copper: #b87945;        /* the knob, the lever, the pointer */
  --copper-light: #e6b07c;
  --copper-dark: #7c4a26;
  --glass: #e6eef0;         /* the glass, a faint grey-green */
  --glass-edge: #8fa3a8;    /* the glass seen edge-on */
  --glint: #ffffff;         /* the light on the glass */
  --shadow: #2a221c;        /* the shadow on the page */
}

* {
  box-sizing: border-box;
}

/* a tap is a click at once: no wait for a double tap */
html {
  touch-action: manipulation;
}

html,
body {
  margin: 0;
  overflow-x: clip;
}

body {
  min-height: 100svh;
  background: var(--page);
  color: var(--ink);
  font-family: 'Instrument Sans Variable', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.stage {
  min-height: 100svh;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  place-items: center;
  padding: 32px 16px;
}

/* the grinder on the left, the options on the right; one above the other on a phone */
.grind {
  display: grid;
  grid-template-columns: auto minmax(0, 312px);
  align-items: center;
  gap: 44px;
}

/* ---------------------------------------------------------------- the grinder and the jar */
.grind__machine {
  position: relative;
  width: 256px;
  aspect-ratio: 256 / 340;
}

.grind__art,
.grind__grounds {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.s-body { stop-color: var(--body); }
.s-body-light { stop-color: var(--body-light); }
.s-body-dark { stop-color: var(--body-dark); }
.s-steel { stop-color: var(--steel); }
.s-steel-light { stop-color: var(--steel-light); }
.s-steel-dark { stop-color: var(--steel-dark); }
.s-steel-deep { stop-color: var(--steel-deep); }
.s-copper { stop-color: var(--copper); }
.s-copper-light { stop-color: var(--copper-light); }
.s-copper-dark { stop-color: var(--copper-dark); }
.s-glass { stop-color: var(--glass); }
.s-glass-edge { stop-color: var(--glass-edge); }
.s-glint { stop-color: var(--glint); }

.m-shadow {
  fill: var(--shadow);
  opacity: 0.28;
}

.m-edge-light {
  fill: var(--glint);
  opacity: 0.16;
}

.m-seam {
  fill: none;
  stroke: var(--body-dark);
  stroke-width: 1;
}

.m-pointer {
  fill: var(--copper-light);
}

.m-ring-shade {
  opacity: 0.55;
}

.m-tick {
  stroke: var(--steel-deep);
  stroke-linecap: round;
}

.m-tick.is-long {
  stroke: var(--body);
}

.m-window {
  fill: #0d0b0a;
}

.m-window-rim {
  fill: none;
  stroke: var(--body-dark);
  stroke-width: 1.6;
}

.m-window-glint {
  fill: var(--glint);
  opacity: 0.12;
}

.m-teeth line {
  stroke: var(--steel-deep);
  stroke-width: 1.3;
  stroke-linecap: round;
}

.m-burr-ring {
  fill: var(--steel-dark);
}

.m-burr-teeth {
  fill: none;
  stroke: var(--steel-deep);
  stroke-width: 1;
}

.m-switch {
  fill: var(--body-dark);
}

.m-switch-top {
  fill: var(--body-light);
  opacity: 0.7;
}

.m-glass-back {
  fill: var(--glass);
  opacity: 0.55;
}

.m-glass-front {
  fill: var(--glass);
  fill-opacity: 0.12;
  stroke: var(--glass-edge);
  stroke-width: 1.3;
  stroke-linejoin: round;
}

.m-glint-line {
  fill: none;
  stroke: var(--glint);
  stroke-width: 3;
  stroke-linecap: round;
  opacity: 0.7;
}

.m-glint-line.is-thin {
  stroke-width: 1.4;
  opacity: 0.55;
}

.m-chute-lip {
  fill: none;
  stroke: var(--glint);
  stroke-width: 1;
  opacity: 0.6;
}

.m-chute-mouth {
  fill: none;
  stroke: #0d0b0a;
  stroke-width: 2.2;
  stroke-linecap: round;
}

.m-glass-line {
  fill: none;
  stroke: var(--glass-edge);
  stroke-width: 1.1;
}

.m-rim-back {
  fill: none;
  stroke: var(--glass-edge);
  stroke-width: 1.2;
  opacity: 0.8;
}

.m-rim-front {
  fill: none;
  stroke: var(--glass-edge);
  stroke-width: 2;
}

.m-rim-glint {
  fill: none;
  stroke: var(--glint);
  stroke-width: 1.2;
  stroke-linecap: round;
  opacity: 0.85;
}

.m-stand-lip {
  fill: none;
  stroke: var(--steel-deep);
  stroke-width: 1.6;
  opacity: 0.7;
}

.m-lever {
  fill: none;
  stroke: var(--steel-dark);
  stroke-width: 2.6;
  stroke-linecap: round;
}

.m-pivot {
  fill: var(--steel-light);
  stroke: var(--steel-deep);
  stroke-width: 1;
}

/* ---------------------------------------------------------------- the options */
.grind__pick {
  min-width: 0;
}

.grind__head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 16px;
  margin: 0 16px 10px;
}

.grind__title {
  font-family: 'Bricolage Grotesque Variable', system-ui, sans-serif;
  font-size: 19px;
  line-height: 24px;
  font-weight: 650;
  letter-spacing: -0.015em;
}

.grind__hint {
  font-size: 13px;
  line-height: 24px;
  color: var(--muted);
  white-space: nowrap;
}

.grind__list {
  position: relative;
  display: grid;
  gap: 2px;
}

/* behind the grind chosen: one cream card that slides from option to option */
.grind__mark {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 58px;
  border-radius: 15px;
  background: var(--chosen);
  box-shadow: 0 6px 14px -10px rgba(42, 34, 28, 0.6);
  pointer-events: none;
}

/* its ring: it fades while the card travels, so no line ever runs across the words it slides behind */
.grind__mark::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  box-shadow: inset 0 0 0 1.5px var(--ink);
  opacity: var(--ring, 1);
}

.opt {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  column-gap: 14px;
  align-items: center;
  min-height: 58px;
  padding: 9px 16px;
  border-radius: 15px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
  transition: background-color 0.2s ease, transform 0.16s cubic-bezier(0.23, 1, 0.32, 1);
}

/* the radio itself is hidden but stays in the page: it takes the focus, the arrows and the clicks */
.opt__radio {
  position: absolute;
  top: 50%;
  left: 16px;
  width: 1px;
  height: 1px;
  margin: 0;
  opacity: 0;
  pointer-events: none;
}

.opt__name {
  grid-column: 1;
  font-family: 'Bricolage Grotesque Variable', system-ui, sans-serif;
  font-size: 16.5px;
  line-height: 21px;
  font-weight: 560;
  letter-spacing: -0.01em;
  color: #4a413b;
  transition: color 0.25s ease, font-weight 0.3s ease;
}

.opt__line {
  grid-column: 1;
  font-size: 13.5px;
  line-height: 18px;
  color: var(--muted);
  transition: color 0.25s ease;
}

.opt__size {
  grid-column: 2;
  grid-row: 1 / span 2;
  font-size: 13px;
  line-height: 18px;
  font-weight: 520;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  transition: color 0.25s ease;
}

.opt.is-chosen .opt__name {
  color: var(--ink);
  font-weight: 680;
}

.opt.is-chosen .opt__line,
.opt.is-chosen .opt__size {
  color: var(--accent);
}

.opt:has(.opt__radio:focus-visible) {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.opt:active {
  transform: scale(0.985);
}

@media (hover: hover) {
  .opt:not(.is-chosen):hover {
    background-color: var(--hover);
  }

  .opt:not(.is-chosen):hover .opt__name {
    color: var(--ink);
  }
}

/* ---------------------------------------------------------------- a phone */
@media (max-width: 640px) {
  .grind {
    grid-template-columns: minmax(0, 1fr);
    justify-items: center;
    gap: 14px;
    width: min(380px, 100%);
  }

  .grind__machine {
    width: min(212px, 58vw);
  }

  .grind__pick {
    width: 100%;
  }

  .opt {
    min-height: 54px;
    padding: 8px 14px;
  }

  .grind__mark {
    height: 54px;
  }

  .grind__head {
    margin: 0 14px 8px;
  }
}
