/* The sloshing inks: a shelf of ink bottles on a white page, each bottle on a pale tile of its own ink's colour,
   the name and the price under it. */
:root {
  --page: #ffffff;          /* the page */
  --ink: #1d1b22;           /* the words and the arrows */
  --muted: #6b6772;         /* the smaller words */
  --line: #dddbe0;          /* the arrows' ring */
  --off: #c3c0c8;           /* an arrow with nowhere to go */
  --off-line: #eeedf0;      /* its ring */
  --card: 280px;            /* the width of a tile */
  --gap: 16px;              /* between two tiles */
}

* {
  box-sizing: border-box;
}

html {
  touch-action: manipulation;
}

html,
body {
  margin: 0;
}

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;
  /* one column as wide as the page: the shelf's long row must not widen it */
  grid-template-columns: minmax(0, 1fr);
  place-items: center;
  padding: 32px 16px;
  overflow: hidden;
}

.shelf {
  --bleed: 0px;             /* how far the shelf runs past the column, to the edges of a phone's screen */
  width: min(720px, 100%);
  min-width: 0;
}

.shelf__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.shelf__title {
  margin: 0;
  font-family: 'Alegreya Variable', Georgia, serif;
  font-size: 28px;
  font-weight: 600;
  line-height: 1.15;
  letter-spacing: -0.01em;
}

.shelf__arrows {
  display: flex;
  flex: none;
  gap: 8px;
}

/* ---------------------------------------------------------------- the arrows */
.arrow {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--ink);
  box-shadow: inset 0 0 0 1.5px var(--line);
  cursor: pointer;
  transition: background-color 0.2s, color 0.2s, box-shadow 0.2s, opacity 0.2s, transform 0.16s cubic-bezier(0.23, 1, 0.32, 1);
  -webkit-tap-highlight-color: transparent;
}

.arrow svg {
  width: 20px;
  height: 20px;
  overflow: visible;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform 0.3s cubic-bezier(0.34, 1.8, 0.5, 1);
}

/* at the last inks the next arrow turns into the way back to the first */
.arrow__step,
.arrow__back {
  transition: opacity 0.2s, transform 0.35s cubic-bezier(0.34, 1.6, 0.5, 1);
  transform-box: fill-box;
  transform-origin: 50% 50%;
}

.arrow__back {
  opacity: 0;
  transform: scale(0.5) translateX(6px);
}

.arrow.is-back .arrow__step {
  opacity: 0;
  transform: scale(0.5) translateX(6px);
}

.arrow.is-back .arrow__back {
  opacity: 1;
  transform: none;
}

@media (hover: hover) {
  .arrow:not([aria-disabled='true']):hover {
    background: var(--ink);
    color: var(--page);
    box-shadow: inset 0 0 0 1.5px var(--ink);
  }

  [data-next]:not(.is-back):hover svg {
    transform: translateX(2px);
  }

  [data-next].is-back:hover svg,
  [data-prev]:not([aria-disabled='true']):hover svg {
    transform: translateX(-2px);
  }
}

.arrow:not([aria-disabled='true']):active {
  transform: scale(0.92);
}

/* the first inks: there is nothing before them */
.arrow[aria-disabled='true'] {
  color: var(--off);
  box-shadow: inset 0 0 0 1.5px var(--off-line);
  cursor: default;
}

.arrow:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 3px;
}

html[data-using='pointer'] .arrow:focus-visible {
  outline: none;
}

/* ---------------------------------------------------------------- the shelf */
.shelf__view {
  position: relative;
  margin: 20px calc(var(--bleed) * -1) 0;
  overflow: hidden;
  border-radius: 20px;
  outline: none;
  padding-bottom: 12px;
  cursor: grab;
  touch-action: pan-y;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

.shelf__view.is-held {
  cursor: grabbing;
}

.shelf__view:focus-visible {
  box-shadow: 0 0 0 2px var(--page), 0 0 0 4px var(--ink);
}

html[data-using='pointer'] .shelf__view:focus-visible {
  box-shadow: none;
}

.shelf__track {
  display: flex;
  gap: var(--gap);
  padding: 0 var(--bleed);
  will-change: transform;
}

/* ---------------------------------------------------------------- an ink */
.ink {
  flex: none;
  width: var(--card);
  margin: 0;
}

.ink__tile {
  position: relative;
  display: grid;
  place-items: end center;
  height: calc(var(--card) * 1.07);
  border-radius: 20px;
  background: var(--tint);
  transition: background-color 0.25s;
}

@media (hover: hover) {
  .shelf__view:not(.is-held) .ink:hover .ink__tile {
    background: var(--tint-deep);
  }
}

.ink__bottle {
  display: block;
  width: 72%;
  height: auto;
  margin-bottom: 6%;
  overflow: visible;
}

.ink__info {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: baseline;
  column-gap: 12px;
  padding: 14px 4px 0;
}

.ink__name {
  margin: 0;
  font-family: 'Alegreya Variable', Georgia, serif;
  font-size: 22px;
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: -0.005em;
}

.ink__price {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.ink__meta {
  grid-column: 1 / -1;
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 14px;
  font-weight: 500;
}

.sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

@media (max-width: 560px) {
  :root {
    --card: 264px;
    --gap: 12px;
  }

  .stage {
    padding: 24px 16px;
  }

  /* the shelf runs to the edges of the screen, the first tile in line with the title */
  .shelf {
    --bleed: 16px;
  }

  .shelf__view {
    border-radius: 0;
  }

  /* there the ring of the focus is drawn inside, at the edges of the screen */
  .shelf__view::after {
    content: '';
    position: absolute;
    inset: 0;
    box-shadow: inset 0 0 0 2px var(--ink);
    opacity: 0;
    pointer-events: none;
  }

  .shelf__view:focus-visible {
    box-shadow: none;
  }

  .shelf__view:focus-visible::after {
    opacity: 1;
  }

  html[data-using='pointer'] .shelf__view:focus-visible::after {
    opacity: 0;
  }

  .shelf__title {
    font-size: 24px;
  }

  .ink__name {
    font-size: 21px;
  }
}
