/* The table with pockets: a roastery's order book in warm ink on a white page, a pale stone track for the pockets,
   and three states in the colours of the trade: ember for the drum, kraft for the bag, a deep green for the road. */
:root {
  --page: #ffffff;          /* the page and the rows */
  --ink: #1f1813;
  --muted: #6b625b;
  --heads: #736a63;         /* the column heads */
  --rule: #efebe7;          /* the lines between rows */
  --rule-strong: #e2dcd6;   /* the line under the heads */
  --hover: #faf8f6;         /* a row under the pointer */
  --track: #f3f0ec;         /* the pockets */
  --badge: #ebe6e0;         /* the counts in the pockets */
  --badge-ink: #5f5750;
  --focus: #a63c0c;         /* the rings of the focus */
  --roasting: #a63c0c;
  --roasting-bg: #fdeee6;
  --packed: #7a4f27;
  --packed-bg: #f5ede4;
  --shipped: #1f6146;
  --shipped-bg: #e6f2eb;
  --curve: #2b1d14;         /* the roast curve */
  --grid: #efebe7;          /* the lines behind it */
}

* {
  box-sizing: border-box;
}

html {
  touch-action: manipulation;
}

html,
body {
  margin: 0;
}

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

/* held from the top: rows that leave or come back change the height, and a table kept in the middle would jump */
.stage {
  min-height: 100svh;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  justify-items: center;
  align-content: start;
  padding: clamp(32px, 11vh, 112px) 16px 48px;
}

.orders {
  position: relative;
  isolation: isolate;
  width: min(680px, 100%);
}

.orders__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 0 4px 16px;
}

.orders__title {
  margin: 0;
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.025em;
  line-height: 1.1;
}

.orders__note {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

/* ---------------------------------------------------------------- the pockets */
/* above the labels in flight: a label going into its pocket slips behind the track's edge */
.tabs {
  position: relative;
  z-index: 3;
  display: inline-flex;
  gap: 2px;
  padding: 4px;
  border-radius: 14px;
  background: var(--track);
}

.tabs__knob {
  position: absolute;
  left: 0;
  top: 4px;
  width: 0;
  height: 40px;
  border-radius: 10px;
  background: var(--page);
  box-shadow: 0 1px 2px rgba(31, 24, 19, 0.08), 0 3px 10px -3px rgba(31, 24, 19, 0.14);
}

/* the button gets pressed (CSS), its insides get the jolts (the script) */
.tab {
  position: relative;
  display: inline-flex;
  align-items: center;
  height: 40px;
  padding: 0 10px 0 12px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  font: 560 15px 'Bricolage Grotesque Variable', system-ui, sans-serif;
  cursor: pointer;
  transition: color 0.2s ease, background-color 0.2s ease;
  -webkit-tap-highlight-color: transparent;
}

.tab__in {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.tab__icon {
  display: grid;
  width: 18px;
  height: 18px;
}

.tab__icon svg {
  width: 18px;
  height: 18px;
  overflow: visible;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.tab--roasting .tab__icon {
  color: var(--roasting);
}

.tab--packed .tab__icon {
  color: var(--packed);
}

.tab--shipped .tab__icon {
  color: var(--shipped);
}

.tab__count {
  display: inline-grid;
  place-items: center;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border-radius: 7px;
  background: var(--badge);
  color: var(--badge-ink);
  font-size: 13px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  transition: background-color 0.25s ease, color 0.25s ease;
}

.tab[aria-pressed='true'] {
  color: var(--ink);
}

.tab--roasting[aria-pressed='true'] .tab__count {
  background: var(--roasting-bg);
  color: var(--roasting);
}

.tab--packed[aria-pressed='true'] .tab__count {
  background: var(--packed-bg);
  color: var(--packed);
}

.tab--shipped[aria-pressed='true'] .tab__count {
  background: var(--shipped-bg);
  color: var(--shipped);
}

@media (hover: hover) {
  .tab:hover {
    color: var(--ink);
  }

  .tab[aria-pressed='false']:hover {
    background: rgba(31, 24, 19, 0.045);
  }
}

.tab:active {
  transform: scale(0.96);
  transition: color 0.2s ease, background-color 0.2s ease, transform 0.1s ease-out;
}

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

.tab:disabled {
  opacity: 0.45;
  cursor: default;
}

.tab:disabled:active {
  transform: none;
}

/* ---------------------------------------------------------------- the table */
.sheet {
  position: relative;
  z-index: 1;
  margin-top: 16px;
}

.table {
  width: 100%;
  table-layout: fixed;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 15px;
  font-variant-numeric: tabular-nums;
}

.table thead th {
  height: 40px;
  padding: 0 12px;
  border-bottom: 1px solid var(--rule-strong);
  background: var(--page);
  color: var(--heads);
  font-size: 13px;
  font-weight: 560;
  letter-spacing: 0.01em;
  text-align: left;
  white-space: nowrap;
}

.table thead th.c-cafe {
  padding-left: 36px;
}

.table tbody th,
.table td {
  height: 52px;
  padding: 0 12px;
  border-bottom: 1px solid var(--rule);
  background: var(--page);
  font-weight: 400;
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: background-color 0.18s ease;
}

.table .c-coffee {
  width: 172px;
}

.table .c-kg {
  width: 78px;
}

.table .c-total {
  width: 104px;
}

.table .c-state {
  width: 136px;
}

.table .num {
  text-align: right;
}

.c-coffee {
  color: var(--muted);
}

.row {
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

@media (hover: hover) {
  .row:hover > * {
    background: var(--hover);
  }
}

/* an order whose label is in flight keeps its place, unseen (and so does its roast, if it left open) */
.row.is-pending,
.detail.is-pending {
  visibility: hidden;
}

/* an open order and its roast read as one */
.row.is-open > * {
  border-bottom-color: transparent;
}

/* the order's name is the button that opens it */
.order {
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 100%;
  margin-left: -4px;
  padding: 6px 4px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-weight: 620;
  text-align: left;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.order__chevron {
  flex: none;
  width: 16px;
  height: 16px;
  fill: none;
  stroke: var(--muted);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: stroke 0.2s ease;
}

.order__text {
  min-width: 0;
}

.order__name,
.order__meta {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
}

.order__meta {
  display: none;
}

@media (hover: hover) {
  .row:hover .order__chevron {
    stroke: var(--ink);
  }
}

.row.is-open .order__chevron {
  stroke: var(--ink);
}

.order:active .order__text {
  transform: translateY(1px);
}

.order:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 0;
}

/* ---------------------------------------------------------------- the states */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 26px;
  padding: 0 10px 0 8px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
  vertical-align: middle;
}

.chip svg {
  flex: none;
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.chip--roasting {
  background: var(--roasting-bg);
  color: var(--roasting);
}

.chip--packed {
  background: var(--packed-bg);
  color: var(--packed);
}

.chip--shipped {
  background: var(--shipped-bg);
  color: var(--shipped);
}

/* ---------------------------------------------------------------- the roast */
.detail > td {
  height: auto;
  padding: 0;
  border-bottom: 1px solid var(--rule);
  background: var(--page);
  white-space: normal;
  overflow: visible;
}

.detail__clip {
  overflow: hidden;
}

.detail__body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 212px;
  gap: 24px;
  padding: 2px 12px 20px 36px;
}

.roast {
  display: block;
  width: 100%;
  overflow: visible;
}

.roast__grid {
  stroke: var(--grid);
  stroke-width: 1;
}

.roast__axis {
  fill: var(--muted);
  font-size: 11.5px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

.roast__line {
  fill: none;
  stroke: var(--curve);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.roast__plan {
  fill: none;
  stroke: var(--curve);
  stroke-width: 1.5;
  stroke-dasharray: 2 4;
  stroke-linecap: round;
  stroke-opacity: 0.45;
}

.roast__crack {
  stroke: var(--curve);
  stroke-width: 1;
  stroke-dasharray: 3 3;
  stroke-opacity: 0.45;
}

.roast__cursor {
  stroke: var(--curve);
  stroke-width: 1;
  stroke-opacity: 0.3;
}

.roast__label {
  fill: var(--ink);
  font-size: 12px;
  font-weight: 620;
  font-variant-numeric: tabular-nums;
}

.roast__label tspan.is-soft {
  fill: var(--muted);
  font-weight: 500;
}

.facts {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-content: start;
  gap: 8px 14px;
  margin: 0;
  padding-top: 14px;
  font-size: 14px;
  line-height: 18px;
}

.facts dt {
  color: var(--muted);
}

.facts dd {
  margin: 0;
  font-weight: 560;
}

/* ---------------------------------------------------------------- labels in flight */
/* over the table, under the pockets */
.flight {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
}

.token {
  position: absolute;
  left: 0;
  top: 0;
  will-change: transform;
}

.token__mask {
  position: absolute;
  overflow: hidden;
}

.token__face {
  position: absolute;
  left: 0;
  top: 0;
}

.token__face .chip {
  visibility: hidden;
}

.token__chip {
  position: absolute;
  left: 0;
  top: 0;
}

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

/* ---------------------------------------------------------------- the phone */
@media (max-width: 600px) {
  .stage {
    padding: 28px 16px 40px;
  }

  .orders__head {
    flex-direction: column;
    gap: 4px;
    padding: 0 2px 14px;
  }

  .orders__title {
    font-size: 24px;
  }

  .orders__note {
    font-size: 13.5px;
  }

  /* the four pockets share the width: the words and the counts stay, the icons live in the labels of the rows
     */
  .tabs {
    display: flex;
    width: 100%;
    gap: 0;
  }

  .tabs__knob {
    height: 44px;
  }

  .tab {
    flex: 1 1 auto;
    justify-content: center;
    height: 44px;
    padding: 0 6px;
    font-size: 14.5px;
  }

  .tab__in {
    gap: 6px;
  }

  .tab__icon {
    display: none;
  }

  .tab__count {
    min-width: 20px;
    height: 20px;
    padding: 0 5px;
    font-size: 12.5px;
  }

  .sheet {
    margin-top: 12px;
  }

  .table .c-coffee,
  .table .c-kg {
    display: none;
  }

  .table thead th,
  .table tbody th,
  .table td {
    padding: 0 8px;
  }

  .table thead th.c-cafe {
    padding-left: 32px;
  }

  .table tbody th,
  .table td {
    height: 62px;
  }

  .table .c-total {
    width: 76px;
  }

  .table .c-state {
    width: 104px;
  }

  .order {
    align-items: flex-start;
    gap: 6px;
  }

  .order__chevron {
    margin-top: 2px;
  }

  .order__meta {
    display: block;
    margin-top: 2px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 450;
  }

  /* the labels narrow on the width axis of the face, so the names keep their room */
  .chip {
    gap: 4px;
    padding: 0 7px 0 6px;
    font-size: 13.5px;
    font-stretch: 86%;
  }

  .chip svg {
    width: 15px;
    height: 15px;
  }

  .detail__body {
    grid-template-columns: minmax(0, 1fr);
    gap: 4px;
    padding: 2px 8px 16px 8px;
  }

  .facts {
    padding-top: 6px;
    font-size: 13.5px;
  }
}
