@font-face {
  font-family: "Atkinson Hyperlegible Next";
  src: url("/fonts/atkinson-next-latin.woff2") format("woff2");
  font-weight: 200 800;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: "Atkinson Hyperlegible Next";
  src: url("/fonts/atkinson-next-latin-ext.woff2") format("woff2");
  font-weight: 200 800;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

:root {
  --bg: #121212;
  --surface: #1b1b1b;
  --surface-2: #262626;
  --line: #3a3a3a;
  --text: #e8e8e8;
  --text-2: #adadad;
  --text-3: #7d7d7d;
  --amber: #e7b040;
  --amber-pressed: #d29c2f;
  --on-amber: #141414;
  --gutter: 1rem;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  font-size: 125%;
  background: var(--bg);
}

body {
  margin: 0;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font-family: "Atkinson Hyperlegible Next", system-ui, sans-serif;
  line-height: 1.35;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

::selection {
  background: color-mix(in srgb, var(--amber) 22%, var(--bg));
}

:focus-visible {
  outline: 3px solid var(--text);
  outline-offset: 3px;
}

.sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

.icon {
  flex: none;
  width: 1em;
  height: 1em;
  fill: currentColor;
}

.bar,
main {
  width: 100%;
  max-width: 30rem;
  margin: 0 auto;
}

.bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: calc(4rem + env(safe-area-inset-top));
  padding: env(safe-area-inset-top) var(--gutter) 0;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.45em;
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: -0.01em;
}

.brand .icon {
  width: 1.35em;
  height: 1.35em;
  color: var(--amber);
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.45em;
  min-height: 2.6rem;
  padding: 0 1rem;
  border: 2px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font-size: 1rem;
  font-weight: 700;
}

.chip .icon {
  width: 1.15em;
  height: 1.15em;
}

main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow-x: clip;
}

.screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 0 var(--gutter);
  animation: screen-in 280ms var(--ease) both;
}

.screen.replay {
  animation-name: screen-in-again;
}

@keyframes screen-in {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
}

@keyframes screen-in-again {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
}

button,
.btn {
  font: inherit;
  cursor: pointer;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}

.scan {
  flex: 1;
  display: flex;
  flex-direction: column;
  margin: 0.25rem 0 calc(1rem + env(safe-area-inset-bottom));
  padding: 0;
  overflow: hidden;
  border: 2px solid var(--line);
  border-radius: 32px;
  background: var(--surface);
  color: var(--text);
  transition: transform 160ms var(--ease);
}

.scan:active {
  transform: scale(0.985);
}

.frame {
  position: relative;
  flex: 1;
  display: grid;
  place-items: center;
  min-height: 11rem;
}

.corners {
  position: absolute;
  inset: 0;
}

.frame::before,
.frame::after,
.corners::before,
.corners::after {
  content: "";
  position: absolute;
  width: 3.2rem;
  height: 3.2rem;
  border: 7px solid var(--amber);
}

.frame::before {
  top: 14%;
  left: 13%;
  border-right: 0;
  border-bottom: 0;
  border-top-left-radius: 22px;
}

.frame::after {
  top: 14%;
  right: 13%;
  border-left: 0;
  border-bottom: 0;
  border-top-right-radius: 22px;
}

.corners::before {
  bottom: 14%;
  left: 13%;
  border-right: 0;
  border-top: 0;
  border-bottom-left-radius: 22px;
}

.corners::after {
  bottom: 14%;
  right: 13%;
  border-left: 0;
  border-top: 0;
  border-bottom-right-radius: 22px;
}

.frame-icon {
  width: 6rem;
  height: 6rem;
  fill: var(--text-3);
}

.scan-label {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5em;
  min-height: 5.5rem;
  background: var(--amber);
  color: var(--on-amber);
  font-size: 1.6rem;
  font-weight: 800;
  letter-spacing: -0.01em;
  transition: background-color 160ms var(--ease);
}

.scan-label .icon {
  width: 1.15em;
  height: 1.15em;
}

.scan:active .scan-label {
  background: var(--amber-pressed);
}

.reading {
  padding-top: 0.25rem;
}

.photo {
  position: relative;
  flex: 1;
  min-height: 12rem;
  overflow: hidden;
  border-radius: 28px;
  background: var(--surface) center / cover no-repeat;
}

.photo::before {
  content: "";
  position: absolute;
  inset: 0;
  background: rgb(18 18 18 / 0.5);
}

.sweep {
  position: absolute;
  inset: 6%;
  animation: sweep 1.6s cubic-bezier(0.45, 0, 0.55, 1) infinite alternate;
}

.sweep::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 6px;
  border-radius: 6px;
  background: var(--amber);
}

@keyframes sweep {
  to {
    transform: translateY(100%);
  }
}

.status {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  margin: 1rem 0 0;
  font-size: 1.25rem;
  font-weight: 700;
}

.status-time {
  color: var(--text-2);
  font-variant-numeric: tabular-nums;
}

.destination {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  padding: 0.75rem 0 1rem;
}

.recipient {
  margin: 0 0 0.5rem;
  color: var(--text-2);
  font-size: 1.3rem;
  font-weight: 650;
  line-height: 1.25;
  text-wrap: balance;
  overflow-wrap: anywhere;
}

.street {
  margin: 0;
  font-size: 2.2rem;
  font-weight: 800;
  line-height: 1.08;
  letter-spacing: -0.02em;
  text-wrap: balance;
  overflow-wrap: anywhere;
  hyphens: auto;
}

.locality {
  margin: 0;
  color: var(--text-2);
  font-size: 1.5rem;
  font-weight: 650;
  text-wrap: balance;
}

.city {
  margin: 0;
  font-size: 1.6rem;
  font-weight: 800;
  line-height: 1.15;
  text-wrap: balance;
}

.flag {
  display: flex;
  align-items: flex-start;
  gap: 0.5em;
  margin: 1rem 0 0;
  font-size: 1.25rem;
  line-height: 1.3;
}

.flag .icon {
  width: 1.3em;
  height: 1.3em;
}

.flag-doubt {
  color: var(--text);
  font-weight: 700;
}

.flag-doubt .icon {
  color: var(--amber);
}

.flag-note {
  color: var(--text-2);
  font-weight: 600;
}

.text-btn {
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  gap: 0.45em;
  min-height: 3rem;
  margin: 0.75rem 0 0 -0.75rem;
  padding: 0 0.75rem;
  border: 0;
  border-radius: 14px;
  background: none;
  color: var(--amber);
  font-size: 1.15rem;
  font-weight: 750;
}

.text-btn .icon {
  width: 1.2em;
  height: 1.2em;
}

.editor {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  padding-top: 0.75rem;
}

.result:not(.is-editing) .editor,
.result.is-editing .destination,
.result.is-editing #result-actions {
  display: none;
}

.editor-label {
  color: var(--text-2);
  font-size: 1.15rem;
  font-weight: 650;
}

.editor-text {
  width: 100%;
  padding: 0.7em 0.8em;
  border: 2px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1.25;
  field-sizing: content;
  min-height: 6.5rem;
  resize: none;
  transition: border-color 160ms var(--ease);
}

.editor-text:focus {
  border-color: var(--amber);
  outline: none;
}

.actions {
  position: sticky;
  bottom: 0;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-top: auto;
  padding: 1rem 0 calc(1rem + env(safe-area-inset-bottom));
  background: linear-gradient(to bottom, rgb(18 18 18 / 0), var(--bg) 1rem);
}

.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5em;
  min-height: 4.2rem;
  padding: 0 1.2rem;
  border: 2px solid var(--line);
  border-radius: 22px;
  background: var(--surface-2);
  color: var(--text);
  font-size: 1.3rem;
  font-weight: 750;
  letter-spacing: -0.01em;
  text-decoration: none;
  transition: transform 160ms var(--ease), background-color 160ms var(--ease), border-color 160ms var(--ease);
}

.btn .icon {
  width: 1.2em;
  height: 1.2em;
}

.btn:active {
  transform: scale(0.98);
  background: var(--line);
}

.btn-primary {
  min-height: 5rem;
  border-color: var(--amber);
  background: var(--amber);
  color: var(--on-amber);
  font-size: 1.45rem;
  font-weight: 800;
}

.btn-primary:active {
  border-color: var(--amber-pressed);
  background: var(--amber-pressed);
}

.message-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  padding: 1rem 0;
  text-align: center;
}

.message-icon {
  display: grid;
  place-items: center;
  width: 6rem;
  height: 6rem;
  margin-bottom: 0.25rem;
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--text-2);
}

.message-icon .icon {
  width: 3rem;
  height: 3rem;
}

.message-title {
  max-width: 16ch;
  margin: 0;
  font-size: 1.85rem;
  font-weight: 800;
  line-height: 1.15;
  letter-spacing: -0.015em;
  text-wrap: balance;
}

.message-detail {
  max-width: 20ch;
  margin: 0;
  color: var(--text-2);
  font-size: 1.25rem;
  font-weight: 600;
  text-wrap: balance;
}

.toast {
  position: fixed;
  top: calc(env(safe-area-inset-top) + 4.5rem);
  left: 50%;
  z-index: 10;
  margin: 0;
  border: 2px solid var(--line);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text);
  font-size: 1.15rem;
  font-weight: 750;
  white-space: nowrap;
  transform: translateX(-50%);
}

.toast:not(:empty) {
  padding: 0.7rem 1.15rem;
  animation: toast-in 280ms var(--ease) both;
}

.toast:empty {
  border: 0;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translate(-50%, -8px);
  }
}

@media (prefers-reduced-motion: reduce) {
  .screen,
  .toast:not(:empty) {
    animation-name: fade-in;
  }

  .screen.replay {
    animation-name: fade-in-again;
  }

  @keyframes fade-in {
    from {
      opacity: 0;
    }
  }

  @keyframes fade-in-again {
    from {
      opacity: 0;
    }
  }

  .sweep {
    animation: none;
  }

  .sweep::before {
    top: 50%;
  }

  .scan,
  .btn {
    transition: none;
  }

  .scan:active,
  .btn:active {
    transform: none;
  }
}
