/* The tip selector at the end of a delivery order, on black. The light indicator behind the pills is moved by a
   spring in script.js (x and width), the pills only change colour; Custom grows inside the row and the keypad rises
   from the bottom of the card. */
:root {
  --page: #000000;          /* the page */
  --card: #0f0f11;          /* the body of the card */
  --track: #18181b;         /* the groove under the pills */
  --edge: rgba(255, 255, 255, 0.07); /* the thin edges */
  --ink: #ededf0;           /* the words */
  --muted: #85858f;         /* the small words */
  --ind: #f3f3f4;           /* the indicator that slides */
  --ind-ink: #0d0d0f;       /* the words on the indicator */
  --accent: #ff9b55;        /* the warm accent: generous tips, the Done key, the caret */
  --key: #1a1a1e;           /* the keys */
}

* {
  box-sizing: border-box;
}

html {
  touch-action: manipulation;
}

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

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

button {
  font: inherit;
  color: inherit;
  -webkit-tap-highlight-color: transparent;
}

.stage {
  position: relative;
  min-height: 100svh;
  display: grid;
  place-items: center;
  padding: 12px;
  overflow: hidden;
}

.scale {
  display: grid;
  align-items: center;
}

.card {
  position: relative;
  width: min(88vw, 336px);
  padding: clamp(14px, 4vh, 20px) clamp(14px, 4.6vw, 18px) clamp(10px, 3vh, 14px);
  border-radius: 24px;
  background: linear-gradient(180deg, #141417 0%, var(--card) 46%);
  box-shadow:
    inset 0 0 0 1px var(--edge),
    inset 0 1px 0 rgba(255, 255, 255, 0.06),
    0 1px 2px rgba(0, 0, 0, 0.6),
    0 24px 60px -24px rgba(0, 0, 0, 0.9);
  overflow: hidden;
  opacity: 0;
}

/* a soft warm light on the top edge, stronger with bigger tips (--glow from script.js) */
.card__light {
  --glow: 0.35;
  position: absolute;
  left: 12%;
  right: 12%;
  top: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  opacity: var(--glow);
  pointer-events: none;
}

.card__light::after {
  content: '';
  position: absolute;
  left: 10%;
  right: 10%;
  top: 0;
  height: 46px;
  background: radial-gradient(60% 100% at 50% 0%, color-mix(in srgb, var(--accent) 22%, transparent), transparent 70%);
  opacity: 0.8;
}

.head {
  display: flex;
  align-items: center;
  gap: 11px;
}

.avatar {
  flex: none;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  padding: 1.5px;
  background: linear-gradient(150deg, rgba(255, 255, 255, 0.28), rgba(255, 255, 255, 0.04));
}

.avatar__in {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: radial-gradient(120% 120% at 30% 20%, #3a2a20, #17120f 70%);
  font-size: 12px;
  font-weight: 600;
  font-variation-settings: 'wdth' 110;
  letter-spacing: 0.04em;
  color: #f1d2bb;
}

.head__text {
  min-width: 0;
  flex: 1;
}

.head__title,
.head__meta {
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.head__title {
  font-size: 15px;
  font-weight: 620;
  font-variation-settings: 'wdth' 106;
  letter-spacing: 0.005em;
}

.head__meta {
  margin-top: 2px;
  font-size: 11.5px;
  color: var(--muted);
}

.head__order {
  flex: none;
  font-size: 12px;
  color: var(--muted);
  padding: 4px 9px;
  border-radius: 999px;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.09);
}

/* the row of pills */
.seg {
  position: relative;
  display: flex;
  gap: 2px;
  margin-top: clamp(12px, 3.6vh, 18px);
  padding: 4px;
  border-radius: 18px;
  background: var(--track);
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.7), inset 0 0 0 1px rgba(255, 255, 255, 0.04), 0 1px 0 rgba(255, 255, 255, 0.04);
}

.seg__ind {
  position: absolute;
  left: 0;
  top: 4px;
  bottom: 4px;
  width: 10px;
  border-radius: 14px;
  background: linear-gradient(180deg, #ffffff, var(--ind) 60%, #e4e4e7);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 1),
    inset 0 -1px 0 rgba(0, 0, 0, 0.08),
    0 1px 1px rgba(0, 0, 0, 0.5),
    0 6px 16px -6px rgba(0, 0, 0, 0.8);
  will-change: transform, width;
  pointer-events: none;
}

.pill {
  position: relative;
  z-index: 1;
  flex: 1 1 0;
  min-width: 0;
  height: clamp(44px, 12.4vh, 54px);
  padding: 0 2px;
  border: 0;
  border-radius: 14px;
  background: none;
  cursor: pointer;
  color: var(--muted);
  transition: color 0.28s ease;
  outline: none;
}

.pill[aria-checked='true'] {
  color: var(--ind-ink);
}

.pill:focus-visible {
  box-shadow: 0 0 0 2px var(--page), 0 0 0 3.5px var(--accent);
}

.pill__face {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  transition: transform 0.18s cubic-bezier(0.3, 0.7, 0.4, 1.4);
}

.pill:active .pill__face {
  transform: scale(0.94);
}

.pill__main {
  font-size: 15px;
  font-weight: 600;
  font-variation-settings: 'wdth' 104;
  letter-spacing: -0.01em;
  line-height: 1.15;
}

.pill__sub {
  font-size: 10.5px;
  font-weight: 480;
  opacity: 0.72;
  white-space: nowrap;
}

.pill--custom .pill__main {
  font-size: 13.5px;
  font-variation-settings: 'wdth' 96;
}

.pill--custom .pill__main--field {
  display: inline-flex;
  align-items: center;
  font-size: 15px;
  font-variation-settings: 'wdth' 104;
}

.pill__face--field {
  opacity: 0;
}

.caret {
  width: 1.5px;
  height: 15px;
  margin-left: 2px;
  border-radius: 1px;
  background: var(--accent);
  opacity: 0;
}

.caret.on {
  animation: blink 1.05s steps(1) infinite;
}

@keyframes blink {
  0%, 55% { opacity: 1; }
  56%, 100% { opacity: 0; }
}

/* the totals */
.rows {
  margin-top: clamp(12px, 3.4vh, 18px);
  display: grid;
  gap: 4px;
}

.row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
}

.row__label {
  font-size: 13px;
  color: var(--muted);
}

.row__value {
  font-size: 13px;
}

.row--total .row__label {
  color: var(--ink);
  font-weight: 560;
}

.total {
  font-size: clamp(22px, 6.4vh, 26px);
  font-weight: 640;
  font-variation-settings: 'wdth' 96;
  letter-spacing: -0.02em;
}

/* the thank-you line: its tone (colour, weight and width) comes from script.js */
.thanks {
  margin: clamp(8px, 2.4vh, 12px) 0 0;
  min-height: 1.35em;
  font-size: 13px;
  line-height: 1.35;
  color: var(--muted);
  --wg: 470;
  --wd: 100;
  font-weight: var(--wg);
  font-variation-settings: 'wdth' var(--wd);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.thanks .w {
  display: inline-block;
  white-space: pre;
}

/* the keypad that rises from the bottom */
.pad {
  height: 0;
  overflow: hidden;
}

.pad__in {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 5px;
  padding: clamp(10px, 2.8vh, 14px) 0 6px;
  border-top: 0;
}

.key {
  height: clamp(25px, 6.6vh, 36px);
  border: 0;
  border-radius: 10px;
  background: var(--key);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06), inset 0 0 0 1px rgba(255, 255, 255, 0.04), 0 1px 1px rgba(0, 0, 0, 0.6);
  font-size: 16px;
  font-weight: 540;
  cursor: pointer;
  outline: none;
  display: grid;
  place-items: center;
}

.key:focus-visible {
  box-shadow: inset 0 0 0 1.5px var(--accent);
}

.key svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.key--back {
  background: transparent;
  box-shadow: none;
  color: var(--muted);
}

.key--done {
  background: var(--accent);
  color: #1a0d04;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35), 0 4px 14px -6px var(--accent);
}

.key--done svg {
  stroke-width: 2;
}

/* rolling characters: every character is a small window with its glyph inside */
.roll {
  display: inline-flex;
}

.ch {
  position: relative;
  display: inline-block;
  overflow: hidden;
  height: 1.2em;
  line-height: 1.2em;
  vertical-align: bottom;
}

.ch__g {
  display: block;
}

.ch__g + .ch__g {
  position: absolute;
  left: 0;
  top: 0;
}

.ghost {
  position: absolute;
  left: 0;
  top: 0;
  width: 22px;
  height: 22px;
  pointer-events: none;
  z-index: 5;
  opacity: 0;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.6));
}

.ghost path {
  fill: #ffffff;
  stroke: #0b0b0c;
  stroke-width: 1.3;
  stroke-linejoin: round;
}

@media (hover: hover) {
  .pill:not([aria-checked='true']):hover {
    color: var(--ink);
  }
  .key:hover {
    background: #222227;
  }
  .key--back:hover {
    background: transparent;
    color: var(--ink);
  }
  .key--done:hover {
    background: var(--accent);
    filter: brightness(1.06);
  }
}

/* on large screens the card grows a little, as on a tablet */
@media (min-width: 1000px) and (min-height: 760px) {
  .scale {
    transform: scale(1.3);
  }
}

@media (prefers-reduced-motion: reduce) {
  .caret.on {
    animation: none;
    opacity: 1;
  }
  .pill__face,
  .pill {
    transition: none;
  }
}
