/* The address that becomes a label: the delivery step of a checkout on a white page. A quiet card of fields; once
   the address is right the card itself becomes the shipping label, ink on paper, and the only colour is the
   vermilion of a field that is not right yet and of the print head. */
:root {
  --page: #ffffff;          /* the page */
  --card: #ffffff;          /* the card, and the label's paper */
  --ink: #161616;           /* the words, the label's rules and the barcode */
  --muted: #8b8881;         /* the names of the fields */
  --edge: #dedbd5;          /* the edges of the fields and of the card */
  --accent: #e5401c;        /* a field that is not right yet, and the print head */
  --send: #161616;          /* the button */
  --send-ink: #ffffff;      /* the button's words */
}

* {
  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: 'Geist Variable', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.stage {
  min-height: 100svh;
  display: grid;
  place-items: center;
  padding: 40px 16px;
}

.ship {
  position: relative;
  width: min(440px, 100%);
}

/* ---------------------------------------------------------------- the card (and then the label) */
.sheet {
  position: relative;
  border: 1px solid var(--edge);
  border-radius: 20px;
  background: var(--card);
  box-shadow: 0 1px 0 rgba(22, 22, 22, 0.02);
  overflow: hidden;
}

.addr {
  position: relative;
  margin: 0;
  padding: 26px 26px 26px;
}

.addr__title {
  margin: 0 0 20px;
  font-size: 19px;
  font-weight: 620;
  letter-spacing: -0.01em;
  line-height: 1.2;
}

.addr__row {
  display: grid;
  grid-template-columns: 1fr 132px;
  gap: 12px;
}

/* ---------------------------------------------------------------- a field */
.field {
  position: relative;
  min-width: 0;
  margin-bottom: 4px;
}

.field__label {
  display: block;
  margin: 0 0 6px;
  font-size: 13px;
  font-weight: 540;
  line-height: 16px;
  color: var(--muted);
}

.field__box {
  position: relative;
  height: 46px;
  border: 1px solid var(--edge);
  border-radius: 11px;
  background: var(--card);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.field.is-focus .field__box {
  border-color: var(--ink);
  box-shadow: 0 0 0 1px var(--ink);
}

.field.is-wrong .field__box {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}

.field__input {
  display: block;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0 14px;
  border: 0;
  border-radius: inherit;
  outline: none;
  background: transparent;
  color: var(--ink);
  caret-color: var(--accent);
  font: 460 16px/44px 'Geist Variable', system-ui, sans-serif;
  letter-spacing: 0;
  -webkit-tap-highlight-color: transparent;
}

.field__input:-webkit-autofill {
  -webkit-text-fill-color: var(--ink);
  -webkit-box-shadow: 0 0 0 60px var(--card) inset;
}

.field__select {
  padding-right: 36px;
  -webkit-appearance: none;
  appearance: none;
  cursor: pointer;
}

.field__chev {
  position: absolute;
  right: 14px;
  top: 50%;
  width: 12px;
  height: 12px;
  margin-top: -6px;
  fill: none;
  stroke: var(--ink);
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  pointer-events: none;
}

.field__select:focus-visible {
  outline: none;
}

.field--country:focus-within .field__box {
  border-color: var(--ink);
  box-shadow: 0 0 0 1px var(--ink);
}

/* the caret of the library's preview, which types without taking the focus */
.field__caret {
  position: absolute;
  left: 14px;
  top: 13px;
  width: 1.5px;
  height: 19px;
  background: var(--accent);
  opacity: 0;
  pointer-events: none;
}

.field__caret.is-on {
  animation: blink 1.06s steps(1) infinite;
}

@keyframes blink {
  0%,
  50% {
    opacity: 1;
  }

  50.01%,
  100% {
    opacity: 0;
  }
}

/* the line under a field that is not right yet: it has its own height, which opens and closes on a tween */
.field__err {
  height: 0;
  margin: 0;
  overflow: hidden;
  font-size: 13px;
  font-weight: 500;
  line-height: 18px;
  color: var(--accent);
}

.field__err span {
  display: block;
  padding-top: 6px;
}

.field + .field,
.addr__row + .field,
.field + .addr__row {
  margin-top: 14px;
}

/* ---------------------------------------------------------------- the button */
.addr__foot {
  display: flex;
  align-items: center;
  margin-top: 22px;
}

.send {
  position: relative;
  flex: none;
  display: grid;
  place-items: center;
  width: 100%;
  height: 50px;
  margin: 0;
  padding: 0 24px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--send-ink);
  font: 600 16px/1 'Geist Variable', system-ui, sans-serif;
  cursor: pointer;
  isolation: isolate;
  -webkit-tap-highlight-color: transparent;
}

.send__bg {
  position: absolute;
  inset: 0;
  z-index: -1;
  border-radius: inherit;
  background: var(--send);
  transition: inset 0.6s cubic-bezier(0.3, 1.7, 0.45, 1), transform 0.16s ease-out;
}

.send__label {
  display: block;
  letter-spacing: 0;
  white-space: nowrap;
  transition: letter-spacing 0.6s cubic-bezier(0.3, 1.7, 0.45, 1);
}

@media (hover: hover) and (pointer: fine) {
  .send:not([aria-disabled='true']):hover .send__bg {
    inset: -2px -4px;
  }

  .send:not([aria-disabled='true']):hover .send__label {
    letter-spacing: 0.04em;
  }
}

.send:not([aria-disabled='true']):active .send__bg,
.send.is-pressed .send__bg {
  transform: scale(0.97);
}

.send[aria-disabled='true'] {
  cursor: default;
}

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

/* ---------------------------------------------------------------- the label */
.label {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  padding: 22px 24px 20px;
  visibility: hidden;
  font-family: 'Geist Variable', system-ui, sans-serif;
  color: var(--ink);
}

.label__cap {
  display: block;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.14em;
  line-height: 12px;
  text-transform: uppercase;
}

.label__from {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding-bottom: 12px;
  border-bottom: 2px solid var(--ink);
  font-size: 11.5px;
  font-weight: 500;
  line-height: 14px;
  white-space: nowrap;
  overflow: hidden;
}

.label__from .label__cap {
  flex: none;
}

.label__main {
  display: flex;
  gap: 16px;
  padding: 16px 0 16px;
  border-bottom: 2px solid var(--ink);
}

.label__to {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.label__to .label__cap {
  margin-bottom: 8px;
}

.label__line {
  display: block;
  min-height: 22px;
  font-size: 16px;
  font-weight: 560;
  line-height: 22px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.label__line--name {
  font-size: 18px;
  font-weight: 700;
  line-height: 24px;
}

.label__line--city,
.label__line--country {
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.label__line--city span {
  display: inline-block;
}

.label__sort {
  flex: none;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  width: 104px;
  padding: 9px 10px 10px;
  border-radius: 4px;
  background: var(--ink);
  color: var(--card);
}

.label__route {
  display: block;
  font-family: 'Geist Mono Variable', ui-monospace, monospace;
  font-size: 30px;
  font-weight: 700;
  line-height: 30px;
  letter-spacing: -0.02em;
  white-space: pre;
}

.label__route.is-long {
  font-size: 24px;
  line-height: 26px;
}

.label__code {
  position: relative;
  padding-top: 16px;
}

.label__bars {
  display: block;
  width: 100%;
  height: 64px;
  fill: var(--ink);
  shape-rendering: crispEdges;
}

/* the print head: a hairline that runs across the barcode while it is printed */
.label__head {
  position: absolute;
  left: 0;
  top: 12px;
  width: 2px;
  height: 72px;
  background: var(--accent);
  opacity: 0;
}

.label__track {
  display: block;
  margin-top: 8px;
  font-family: 'Geist Mono Variable', ui-monospace, monospace;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.12em;
  line-height: 16px;
  text-align: center;
  white-space: pre;
}

/* the words in flight from a field to their line on the label */
.flyer {
  position: absolute;
  left: 0;
  top: 0;
  z-index: 3;
  white-space: pre;
  pointer-events: none;
  transform-origin: 0 0;
  will-change: transform;
}

/* ---------------------------------------------------------------- under the label */
.ship__after {
  height: 0;
  overflow: hidden;
}

.after__line {
  margin: 0;
  padding: 16px 4px 0;
  font-size: 14px;
  font-weight: 450;
  line-height: 20px;
  color: var(--ink);
  text-align: center;
}

.after__change {
  margin: 0;
  padding: 2px 0;
  border: 0;
  background: none;
  color: var(--ink);
  font: inherit;
  font-weight: 650;
  letter-spacing: 0;
  cursor: pointer;
  transition: letter-spacing 0.5s cubic-bezier(0.3, 1.7, 0.45, 1), color 0.2s ease;
  -webkit-tap-highlight-color: transparent;
}

@media (hover: hover) and (pointer: fine) {
  .after__change:hover {
    letter-spacing: 0.06em;
    color: var(--accent);
  }
}

.after__change:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 3px;
}

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

@media (max-width: 420px) {
  .addr {
    padding: 22px 18px 20px;
  }

  .addr__row {
    grid-template-columns: 1fr 116px;
  }

  .label {
    padding: 18px 16px 16px;
  }

  .label__sort {
    width: 92px;
  }

  .label__route {
    font-size: 26px;
    line-height: 26px;
  }

  .label__route.is-long {
    font-size: 21px;
    line-height: 23px;
  }
}

.addr__row .field + .field {
  margin-top: 0;
}

.field__input::placeholder {
  color: #b3b0a9;
  opacity: 1;
}
