@font-face {
  font-family: 'Jura';
  src: url('fonts/jura-latin-wght-normal.woff2') format('woff2');
  font-weight: 300 700;
  font-display: swap;
}
@font-face {
  font-family: 'Rubik';
  src: url('fonts/rubik-latin-wght-normal.woff2') format('woff2');
  font-weight: 300 900;
  font-display: swap;
}

:root {
  --indigo: #29234b;
  --indigo-deep: #1f1a3b;
  --orange: #ec6607;
  --orange-hover: #f47d26;
  --orange-ink: #b04a05;
  --ink: #1c1733;
  --paper: #f4f3f8;
  --white: #ffffff;
  --rule: #dad7e5;
  --muted: #55506e;
  --lilac: #cfcbe3;
  --error: #b3261e;

  --display: 'Jura', 'Trebuchet MS', sans-serif;
  --body: 'Rubik', system-ui, -apple-system, 'Segoe UI', sans-serif;

  --gutter: 20px;
  --measure: 34rem;
  --radius: 6px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100dvh;
  font-family: var(--body);
  font-size: 1.0625rem;
  line-height: 1.55;
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

[hidden] { display: none !important; }

h1, h2 {
  font-family: var(--display);
  font-weight: 700;
  line-height: 1.1;
  margin: 0;
  text-wrap: balance;
}

p { margin: 0; }

a { color: inherit; }

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

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

/* ---------- Screens ---------- */

.screen {
  min-height: 100dvh;
}
.screen--dark {
  background: var(--indigo);
  color: var(--white);
}

.logo { display: block; height: auto; }
.sprite { position: absolute; }

/* ---------- Buttons ---------- */

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 52px;
  padding: 12px 22px;
  border: 2px solid transparent;
  border-radius: var(--radius);
  font: 600 1.0625rem/1.2 var(--body);
  text-decoration: none;
  cursor: pointer;
  touch-action: manipulation;
  transition: background-color 0.15s ease, transform 0.1s ease;
}
.button:active { transform: scale(0.98); }
.button:disabled { opacity: 0.6; cursor: progress; transform: none; }

.button--primary {
  background: var(--orange);
  color: var(--ink);
}
.button--primary:hover { background: var(--orange-hover); }

.button--big {
  width: 100%;
  min-height: 60px;
  font-size: 1.1875rem;
}

.button--ghost {
  background: transparent;
  border-color: rgba(255, 255, 255, 0.5);
  color: var(--white);
}
.button--ghost:hover { border-color: var(--white); }

.button--quiet {
  background: transparent;
  color: var(--lilac);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.button--small {
  min-height: 44px;
  padding: 8px 16px;
  font-size: 1rem;
  background: var(--indigo);
  color: var(--white);
}

.link {
  background: none;
  border: 0;
  padding: 12px 4px;
  min-height: 44px;
  font: 500 1rem/1.2 var(--body);
  color: var(--indigo);
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}
.link--light { color: var(--lilac); }

.spinner {
  width: 18px;
  height: 18px;
  border: 2.5px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Loading ---------- */

.loading {
  min-height: 100dvh;
  display: grid;
  place-items: center;
}
.loading__mark {
  width: 64px;
  height: 64px;
  color: var(--orange);
  animation: breathe 1.4s ease-in-out infinite;
}
@keyframes breathe { 50% { opacity: 0.35; } }

/* ---------- No key ---------- */

.message {
  max-width: var(--measure);
  margin: 0 auto;
  padding: calc(48px + var(--safe-top)) var(--gutter) calc(32px + var(--safe-bottom));
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.message .logo { margin-bottom: 28px; }
.message h1 { font-size: 2rem; }
.message p { color: var(--lilac); margin-bottom: 10px; }

/* ---------- Home ---------- */

.top {
  background: var(--indigo);
  color: var(--white);
  padding: calc(20px + var(--safe-top)) var(--gutter) 28px;
}
.top > * { max-width: var(--measure); margin-left: auto; margin-right: auto; }
.top .logo { margin-bottom: 36px; margin-left: 0; }
.top__hello { font-size: 2.25rem; }
.top__company { color: var(--lilac); margin-top: 4px; margin-bottom: 28px; }
.top__hint { color: var(--lilac); font-size: 0.9375rem; margin-top: 12px; }
.top__find { display: flex; width: 100%; margin-top: 20px; }

.codes {
  max-width: calc(var(--measure) + 2 * var(--gutter));
  margin: 0 auto;
  padding: 28px var(--gutter) calc(40px + var(--safe-bottom));
}
.codes h2 { font-size: 1.375rem; margin-bottom: 8px; }

.empty { color: var(--muted); padding: 16px 0; }

.code-list {
  list-style: none;
  margin: 0 0 28px;
  padding: 0;
}
.code-list li { border-bottom: 1px solid var(--rule); }
.code-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 2px 16px;
  width: 100%;
  padding: 16px 0;
  background: none;
  border: 0;
  text-align: left;
  font: inherit;
  color: inherit;
  cursor: pointer;
  touch-action: manipulation;
}
.code-row__code {
  font: 700 1.375rem/1.2 var(--display);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
}
.code-row__date { color: var(--muted); font-size: 0.9375rem; align-self: center; }
.code-row__customer { grid-column: 1 / -1; font-weight: 500; overflow-wrap: anywhere; }
.code-row__meta { grid-column: 1 / -1; color: var(--muted); font-size: 0.9375rem; overflow-wrap: anywhere; }
.code-row__goods {
  grid-column: 1 / -1;
  color: var(--muted);
  font-size: 0.9375rem;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.code-row--new .code-row__code { color: var(--orange-ink); }

.help { color: var(--muted); font-size: 0.9375rem; }

.install {
  background: var(--white);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 28px;
}
.install p { font-size: 0.9375rem; }
.install__actions { display: flex; align-items: center; gap: 12px; margin-top: 10px; }
.install .share-icon { display: inline-block; width: 1.05em; height: 1.05em; vertical-align: -0.15em; }

/* ---------- Form ---------- */

.screen--sheet { background: var(--paper); }

.form {
  max-width: calc(var(--measure) + 2 * var(--gutter));
  margin: 0 auto;
  padding: calc(20px + var(--safe-top)) var(--gutter) calc(32px + var(--safe-bottom));
  display: flex;
  flex-direction: column;
  gap: 22px;
}
.form__head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding-bottom: 6px;
}
.form__head h1 { font-size: 1.875rem; }

.field { display: flex; flex-direction: column; gap: 8px; }
.field label { font-weight: 500; }
.optional { color: var(--muted); font-weight: 400; }
.field select,
.field input,
.field textarea {
  width: 100%;
  min-height: 52px;
  padding: 12px 14px;
  border: 2px solid #b9b4cc;
  border-radius: var(--radius);
  background: var(--white);
  font: 400 1.0625rem/1.3 var(--body);
  color: var(--ink);
}
.field select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='9' viewBox='0 0 14 9'%3E%3Cpath d='M1 1l6 6 6-6' fill='none' stroke='%2329234b' stroke-width='2'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 16px center;
  padding-right: 44px;
}
.field select:focus,
.field input:focus,
.field textarea:focus { border-color: var(--indigo); outline: none; box-shadow: 0 0 0 3px rgba(236, 102, 7, 0.45); }
.field [aria-invalid='true'],
.field [aria-invalid='true']:focus { border-color: var(--error); }
.field textarea { resize: vertical; min-height: 76px; }
.field__hint { color: var(--muted); font-size: 0.9375rem; }

/* Opens Google Maps searching for the store near the customer */
.map-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  align-self: flex-start;
  min-height: 44px;
  padding: 8px 0;
  color: var(--indigo);
  font-weight: 500;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.map-link svg { width: 18px; height: 18px; flex: none; }
.map-link--light { color: var(--lilac); align-self: center; margin-top: 14px; }
.find-link { align-self: flex-start; padding-left: 0; text-align: left; }

/* ---------- Find a store ---------- */

.find__question { font-size: 1.375rem; margin-bottom: 14px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  min-height: 44px;
  padding: 8px 16px;
  border: 2px solid #b9b4cc;
  border-radius: 999px;
  background: var(--white);
  font: 500 1rem/1.2 var(--body);
  color: var(--ink);
  cursor: pointer;
  touch-action: manipulation;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}
.chip:hover { border-color: var(--indigo); }
.chip[aria-pressed='true'] { background: var(--indigo); border-color: var(--indigo); color: var(--white); }

.find__results { scroll-margin-top: 16px; }
.find__title { font-size: 1.375rem; margin-bottom: 4px; }
.store-list { list-style: none; margin: 12px 0 0; padding: 0; border-top: 1px solid var(--rule); }
.store-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 4px 16px;
  padding: 12px 0;
  border-bottom: 1px solid var(--rule);
}
.store-row__name { font-weight: 600; font-size: 1.125rem; flex: 1 1 100%; }
.store-row__actions { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex: 1 1 100%; }
.store-row .map-link { padding: 0; }
@media (min-width: 480px) {
  .store-row__name { flex: 1 1 auto; }
  .store-row__actions { flex: 0 0 auto; }
}

.field__error, .form__error { color: var(--error); font-size: 0.9375rem; font-weight: 500; }
.form__error {
  background: #fbeceb;
  border-left: 4px solid var(--error);
  padding: 12px 14px;
}

/* ---------- The code ---------- */

.screen--code {
  background:
    radial-gradient(120% 70% at 50% 38%, #332c5c 0%, var(--indigo) 55%, var(--indigo-deep) 100%);
}
.ticket {
  min-height: 100dvh;
  max-width: var(--measure);
  margin: 0 auto;
  padding: calc(8px + var(--safe-top)) var(--gutter) calc(28px + var(--safe-bottom));
  display: flex;
  flex-direction: column;
}
.ticket__close { align-self: flex-start; }

.ticket__body {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 24px 0;
}
.ticket__mark {
  width: 72px;
  height: 74px;
  color: var(--orange);
  margin-bottom: 28px;
}
.ticket__lead { color: var(--lilac); font-size: 1.0625rem; }
.ticket__code {
  /* Sized so Q0000041CL fits on one line on a small phone */
  font: 700 clamp(2.25rem, 12.5vw, 5rem)/1 var(--display);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.03em;
  margin: 10px 0 22px;
  user-select: all;
  -webkit-user-select: all;
  white-space: nowrap;
}
.ticket__for { font-size: 1.125rem; line-height: 1.5; max-width: 22rem; text-wrap: balance; }
.ticket__for strong { font-weight: 600; }
.ticket__account {
  display: inline-block;
  font: 700 1.375rem/1.2 var(--display);
  letter-spacing: 0.04em;
  white-space: nowrap;
  padding: 2px 10px;
  margin-top: 4px;
  border-radius: 8px;
  background: rgb(255 255 255 / 0.12);
  box-shadow: inset 0 0 0 1px rgb(255 255 255 / 0.18);
}
.ticket__job { color: var(--lilac); margin-top: 4px; overflow-wrap: anywhere; white-space: pre-line; }
.ticket__goods { color: var(--lilac); margin-top: 4px; max-width: 28rem; overflow-wrap: anywhere; }

.ticket__actions { display: grid; grid-template-columns: 1fr; gap: 12px; }
.ticket__actions:has(#share:not([hidden])) { grid-template-columns: 1fr 1fr; }

/* One moment of motion: the chevron draws itself, then the code arrives */
.screen--code.is-new .ticket__mark polygon {
  stroke-dasharray: 1100;
  stroke-dashoffset: 1100;
  animation: draw 0.7s cubic-bezier(0.6, 0, 0.2, 1) forwards;
}
.screen--code.is-new .ticket__code {
  opacity: 0;
  transform: translateY(6px);
  animation: arrive 0.35s ease-out 0.5s forwards;
}
@keyframes draw { to { stroke-dashoffset: 0; } }
@keyframes arrive { to { opacity: 1; transform: none; } }

/* ---------- Banners ---------- */

.offline {
  position: sticky;
  top: 0;
  z-index: 10;
  background: #fff4d6;
  color: var(--ink);
  padding: calc(10px + var(--safe-top)) var(--gutter) 10px;
  font-size: 0.9375rem;
  text-align: center;
  border-bottom: 1px solid #ecd9a0;
}

.demo {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 10;
  margin: 0;
  padding: 8px var(--gutter) calc(8px + var(--safe-bottom));
  background: var(--orange);
  color: var(--ink);
  font-size: 0.8125rem;
  font-weight: 500;
  text-align: center;
}
body.is-demo .codes,
body.is-demo .form,
body.is-demo .find,
body.is-demo .ticket { padding-bottom: calc(72px + var(--safe-bottom)); }

@media (min-width: 700px) {
  .top { padding-top: calc(32px + var(--safe-top)); padding-bottom: 40px; }
  .top__hello { font-size: 2.75rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .screen--code.is-new .ticket__code { opacity: 1; transform: none; }
  .screen--code.is-new .ticket__mark polygon { stroke-dashoffset: 0; }
}
