/* Nanostore tracking page: one centred search box, in the spirit of a search engine home page. */

@font-face {
  font-family: "Karla";
  src: url("fonts/karla-latin.woff2") format("woff2");
  font-weight: 400 700;
  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: "Karla";
  src: url("fonts/karla-latin-ext.woff2") format("woff2");
  font-weight: 400 700;
  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 {
  --ink: #1f2430;
  --ink-2: #474f5d;
  --ink-3: #626b7a;
  --placeholder: #6a7280;
  --brand: #334f9e;
  --brand-strong: #263f86;
  --brand-soft: #e9eef8;
  --line: #e6e8ec;
  --box-line: #dadde3;
  --page: #fdfdfd;
  --footer: #f5f6f8;
  --on-brand: #fbfcfe;
  --ok: #1d6b45;
  --warn: #8a4b00;
  --warn-bg: #fcf3e6;
  --bad: #a1232b;

  --font: "Karla", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --shadow-hover: 0 1px 6px rgb(31 36 48 / 0.16);
  --shadow-focus: 0 1px 6px rgb(31 36 48 / 0.18), 0 0 0 2px var(--brand);
  color-scheme: light;
}

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

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

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  font: 400 1rem/1.5 var(--font);
  color: var(--ink);
  background: var(--page);
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--brand);
  text-underline-offset: 3px;
}

a:focus-visible,
button:focus-visible,
summary:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

a:focus-visible {
  border-radius: 4px;
}

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

.skip-link {
  position: absolute;
  left: 16px;
  top: -48px;
  padding: 8px 14px;
  border-radius: 8px;
  background: var(--ink);
  color: var(--on-brand);
  z-index: 10;
}

.skip-link:focus {
  top: 12px;
}

/* Top-right links */

.top-links {
  display: flex;
  justify-content: flex-end;
  gap: 20px;
  padding: 16px 24px;
  font-size: 14px;
}

.top-links a {
  color: var(--ink-2);
  text-decoration: none;
  padding: 4px 2px;
}

.top-links a:hover {
  color: var(--ink);
  text-decoration: underline;
}

/* Search */

.page {
  flex: 1;
}

.search {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: clamp(40px, 16vh, 160px) 16px 0;
}

.brand {
  display: block;
  line-height: 0;
}

.brand img {
  display: block;
  width: 320px;
  height: auto;
}

.search-form {
  width: min(100%, 640px);
  margin-top: 36px;
}

.search-box {
  display: flex;
  align-items: center;
  height: 54px;
  padding: 0 6px 0 18px;
  background: var(--page);
  border: 1px solid var(--box-line);
  border-radius: 27px;
  transition: box-shadow 0.2s var(--ease-out), border-color 0.2s var(--ease-out);
}

.search-box:hover {
  border-color: transparent;
  box-shadow: var(--shadow-hover);
}

.search-box:focus-within {
  border-color: transparent;
  box-shadow: var(--shadow-focus);
}

.search-box:has(input[aria-invalid="true"]) {
  border-color: var(--bad);
}

.search-icon,
.clear-button svg {
  flex: none;
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.search-icon {
  color: var(--placeholder);
}

.search-box input {
  flex: 1;
  min-width: 0;
  height: 100%;
  padding: 0 12px;
  border: 0;
  outline: 0;
  background: transparent;
  font: 400 17px/1 var(--font);
  letter-spacing: 0.01em;
  color: var(--ink);
}

.search-box input::placeholder {
  color: var(--placeholder);
}

.clear-button {
  flex: none;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--placeholder);
  cursor: pointer;
}

.clear-button:hover {
  background: #f1f3f5;
  color: var(--ink);
}

.clear-button[hidden] {
  display: none;
}

.track-button {
  flex: none;
  height: 42px;
  margin-left: 4px;
  padding: 0 22px;
  border: 0;
  border-radius: 21px;
  background: var(--brand);
  color: var(--on-brand);
  font: 600 15px/1 var(--font);
  cursor: pointer;
  transition: background-color 0.15s var(--ease-out), transform 0.12s var(--ease-out);
}

.track-button:hover {
  background: var(--brand-strong);
}

.track-button:focus-visible {
  outline-color: var(--ink);
}

.track-button:active {
  transform: scale(0.97);
}

.track-button[aria-disabled="true"] {
  cursor: progress;
  background: var(--brand-strong);
}

.track-button.is-loading .btn-label::before {
  content: "";
  display: inline-block;
  width: 0.95em;
  height: 0.95em;
  margin-right: 0.45em;
  vertical-align: -0.12em;
  border: 2px solid rgb(251 252 254 / 0.4);
  border-top-color: var(--on-brand);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

.hint {
  margin: 16px 0 0;
  text-align: center;
  font-size: 14px;
  color: var(--ink-3);
}

.field-error {
  margin: 12px 0 0;
  text-align: center;
  font-size: 14px;
  font-weight: 600;
  color: var(--bad);
}

/* After a search: the logo and box move up, results sit below in the same column */

.has-results .search {
  padding-top: 4px;
}

.has-results .brand img {
  width: 184px;
}

.has-results .search-form {
  margin-top: 20px;
}

.has-results .hint {
  display: none;
}

.results {
  width: min(100% - 32px, 640px);
  margin: 0 auto;
  padding: 12px 0 64px;
}

.results:empty {
  display: none;
}

.results-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px 8px;
  padding: 8px 0 12px;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
  color: var(--ink-3);
}

.link-button {
  padding: 6px 4px;
  border: 0;
  background: none;
  font: 600 14px/1 var(--font);
  color: var(--brand);
  cursor: pointer;
}

.link-button:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.results-bar .link-button {
  margin-left: auto;
}

.notice {
  margin: 16px 0 0;
  padding: 10px 14px;
  border-radius: 10px;
  background: var(--warn-bg);
  color: var(--warn);
  font-size: 14px;
}

/* One shipment */

.shipment {
  padding: 28px 0 32px;
  border-bottom: 1px solid var(--line);
  animation: rise 0.24s var(--ease-out) both;
  animation-delay: calc(var(--i, 0) * 50ms);
}

.shipment:last-child {
  border-bottom: 0;
}

.shipment-id {
  display: flex;
  align-items: center;
  gap: 6px;
}

.shipment-id h2 {
  margin: 0;
  font: 500 15px/1.4 var(--mono);
  letter-spacing: 0.02em;
  color: var(--ink-2);
  overflow-wrap: anywhere;
}

.copy {
  padding: 4px 6px;
  border: 0;
  border-radius: 6px;
  background: none;
  font: 600 13px/1 var(--font);
  color: var(--brand);
  cursor: pointer;
}

.copy:hover {
  background: var(--brand-soft);
}

.status {
  margin: 8px 0 0;
  font-size: 28px;
  line-height: 1.15;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--brand);
  text-wrap: balance;
}

.tone-ok {
  color: var(--ok);
}

.tone-warn {
  color: var(--warn);
}

.tone-bad {
  color: var(--bad);
}

.tone-neutral {
  color: var(--ink);
}

.latest {
  margin: 8px 0 0;
  font-size: 16px;
  color: var(--ink-3);
}

.latest strong {
  font-weight: 600;
  color: var(--ink);
}

.note {
  margin: 8px 0 0;
  max-width: 60ch;
  color: var(--ink-2);
}

/* Milestones */

.progress {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  margin: 26px 0 0;
  padding: 0;
}

.step {
  position: relative;
  display: grid;
  justify-items: center;
  gap: 8px;
  padding: 0 2px;
  text-align: center;
}

.step::before {
  content: "";
  position: absolute;
  top: 5px;
  right: 50%;
  width: 100%;
  height: 2px;
  background: var(--line);
}

.step:first-child::before {
  display: none;
}

.step.is-done::before,
.step.is-current::before {
  background: var(--brand);
}

.step-dot {
  position: relative;
  z-index: 1; /* above the next step's connector */
  width: 12px;
  height: 12px;
  border: 2px solid #c8cdd5;
  border-radius: 50%;
  background: var(--page);
}

.step.is-done .step-dot {
  border-color: var(--brand);
  background: var(--brand);
}

.step.is-current .step-dot {
  border: 3px solid var(--brand);
  box-shadow: 0 0 0 4px var(--brand-soft);
}

.step-label {
  font-size: 12px;
  line-height: 1.3;
  color: var(--ink-3);
}

.step.is-done .step-label {
  color: var(--ink);
}

.step.is-current .step-label {
  font-weight: 700;
  color: var(--ink);
}

.is-problem .step.is-current .step-dot {
  border-color: var(--warn);
  box-shadow: 0 0 0 4px var(--warn-bg);
}

/* Key facts */

.facts {
  display: flex;
  flex-wrap: wrap;
  gap: 14px 32px;
  margin: 26px 0 0;
  font-size: 14px;
}

.facts div {
  min-width: 0;
}

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

.facts dd {
  margin: 2px 0 0;
  font-weight: 500;
  color: var(--ink);
  overflow-wrap: anywhere;
}

.facts .mono {
  font-family: var(--mono);
  letter-spacing: 0.02em;
}

.facts a {
  display: inline-block;
  margin-top: 2px;
  font-size: 13px;
  font-weight: 600;
}

/* History */

.history {
  margin-top: 26px;
}

.history h3 {
  margin: 0 0 6px;
  font-size: 14px;
  font-weight: 700;
}

.events {
  list-style: none;
  margin: 0;
  padding: 0;
}

.event {
  display: grid;
  grid-template-columns: 9.5rem minmax(0, 1fr);
  gap: 2px 16px;
  padding: 6px 0;
  font-size: 15px;
}

.event[hidden] {
  display: none;
}

.event time {
  font-size: 14px;
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
  padding-top: 1px;
}

.event p {
  margin: 0;
  color: var(--ink-2);
}

.event.is-latest p {
  font-weight: 600;
  color: var(--ink);
}

.more {
  margin-top: 4px;
  margin-left: -4px;
}

/* Loading */

.skeleton {
  display: grid;
  gap: 12px;
  padding: 28px 0;
}

.sk {
  display: block;
  height: 14px;
  border-radius: 7px;
  background: #eceef2;
  animation: pulse 1.1s ease-in-out infinite alternate;
}

.sk-a {
  width: 30%;
}

.sk-b {
  width: 46%;
  height: 26px;
}

.sk-c {
  width: 68%;
}

.sk-d {
  height: 10px;
}

/* Footer */

.site-footer {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 6px 24px;
  padding: 14px 24px;
  background: var(--footer);
  border-top: 1px solid var(--line);
  font-size: 13px;
  color: var(--ink-3);
}

.site-footer p {
  margin: 0;
}

.site-footer a {
  color: var(--ink-2);
  text-decoration: none;
}

.site-footer a:hover {
  text-decoration: underline;
}

/* Motion */

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
}

@keyframes pulse {
  from {
    opacity: 0.55;
  }
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-delay: 0s !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* Phones */

@media (max-width: 560px) {
  .top-links {
    padding: 12px 16px;
  }

  .search {
    padding-top: clamp(32px, 12vh, 112px);
  }

  .brand img {
    width: 248px;
  }

  .has-results .brand img {
    width: 156px;
  }

  .search-box {
    height: 52px;
    padding-left: 14px;
  }

  .search-box input {
    padding: 0 8px;
  }

  .track-button {
    padding: 0 16px;
  }

  .status {
    font-size: 24px;
  }

  .step-label {
    font-size: 11px;
  }

  .event {
    grid-template-columns: 1fr;
  }

  .site-footer {
    justify-content: center;
    text-align: center;
  }
}
