/* Customer-facing parcel tracker. Standalone on purpose, like web/public-locker/:
   none of the dashboard's bundle, fonts or tokens are served on this hostname.
   The palette is the locker page's, so the two read as one shop. No inline styles
   anywhere -- the listener's CSP is style-src 'self'. */
:root {
  /* EpicHome logo pink, one step darker for 4.5:1 on white. Same as the locker page
     and ACCENT in api/services/customer_mail.py. */
  --accent: #D1007D;
  --accent-ink: #ffffff;
  --accent-soft: #fdeaf4;
  --accent-line: #f2b3d4;
  --ink: #111827;
  --ink-2: #374151;
  --muted: #6b7280;
  --line: #e5e7eb;
  --bg: #f3f4f6;
  --card: #ffffff;
  --ok: #047857;
  --ok-soft: #ecfdf5;
  --ok-line: #a7e3c9;
  --warn: #b45309;
  --warn-soft: #fffbeb;
  --danger: #b91c1c;
  --danger-soft: #fef2f2;
  --radius: 12px;
}

/* Pseudo-elements too: `*` does not match ::before/::after, and the timeline's dots
   are drawn with them -- without this an 18px dot with a 2px border is 22px. */
*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-text-size-adjust: 100%;
}

.top {
  background: var(--card);
  border-bottom: 1px solid var(--line);
  padding: 14px 20px;
}
.brand { display: inline-block; }
.brand img { display: block; height: 30px; width: auto; }

.wrap {
  max-width: 640px;
  margin: 0 auto;
  padding: 20px 16px 32px;
}

h1 { font-size: 22px; line-height: 1.25; margin: 4px 0 6px; }
h2 { font-size: 16px; margin: 0 0 12px; }
p { margin: 0 0 12px; }
.muted { color: var(--muted); }
.small { font-size: 14px; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 16px;
  margin: 0 0 14px;
}

/* ── Header of the result card ── */
.awb-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.awb {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 0.2px;
  font-variant-numeric: tabular-nums;
  word-break: break-all;
}
.icon-btn {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink-2);
  border-radius: 8px;
  font: inherit;
  font-size: 13px;
  padding: 3px 10px;
  cursor: pointer;
  min-height: 32px;
}
.meta { color: var(--muted); font-size: 14px; margin-top: 2px; }
.meta strong { color: var(--ink-2); font-weight: 600; }

.badge {
  display: inline-block;
  font-size: 13px;
  font-weight: 600;
  padding: 2px 10px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
}
.tone-delivered .badge { background: var(--ok-soft); color: var(--ok); }
.tone-problem .badge, .tone-returned .badge { background: var(--warn-soft); color: var(--warn); }
.tone-cancelled .badge { background: var(--danger-soft); color: var(--danger); }

.headline { font-size: 22px; font-weight: 700; line-height: 1.25; margin: 14px 0 4px; }
.when { color: var(--muted); font-size: 14px; margin: 0; }

/* ── Progress: five steps, filled up to the current one ── */
.steps {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 4px;
  margin: 18px 0 4px;
  padding: 0;
}
.steps li { position: relative; text-align: center; font-size: 12px; color: var(--muted); line-height: 1.25; }
.steps li::before {
  content: "";
  display: block;
  height: 6px;
  border-radius: 999px;
  background: var(--line);
  margin-bottom: 8px;
}
.steps li.done::before { background: var(--accent); }
.steps li.current { color: var(--ink); font-weight: 600; }
.tone-delivered .steps li.done::before { background: var(--ok); }
.tone-problem .steps li.current::before,
.tone-returned .steps li.current::before { background: var(--warn); }

/* ── Locker / notices ── */
.notice {
  border-radius: var(--radius);
  padding: 12px 14px;
  margin: 14px 0 0;
  background: var(--accent-soft);
  font-size: 15px;
}
.notice.warn { background: var(--warn-soft); color: #7c2d12; }
.notice .label { display: block; font-size: 13px; color: var(--muted); }
.notice strong { display: block; }

/* ── Timeline ──
   Newest first. Every event below the newest already happened: a filled dot with a
   tick, joined by a coloured line -- the road travelled. The newest is a ring with a
   dot (still going), or a tick too once the parcel is delivered. The tick is an
   inline SVG as a data: URI, which the CSP's img-src allows. */
.timeline {
  list-style: none;
  margin: 0;
  padding: 0;
  --dot: var(--accent);
  --line: var(--accent-line);
  --tick: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M4.2 8.4l2.4 2.4 5.2-5.4' fill='none' stroke='white' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}
.tone-delivered .timeline { --dot: var(--ok); --line: var(--ok-line); }
.timeline li {
  position: relative;
  padding: 0 0 18px 32px;
}
.timeline li:last-child { padding-bottom: 0; }
.timeline li::before {
  content: "";
  position: absolute;
  left: 2px;
  top: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid var(--dot);
  background: var(--dot) var(--tick) center / 14px 14px no-repeat;
}
.timeline li::after {
  content: "";
  position: absolute;
  /* Centred under the 18px dot (2 + 9 - 1), with a 4px gap below this dot and
     above the next one (which sits 3px into its own item). */
  left: 10px;
  top: 25px;
  bottom: 1px;
  width: 2px;
  background: var(--line);
}
.timeline li:last-child::after { display: none; }
/* The newest event, still in progress: a ring with a dot. */
.timeline li.latest::before {
  background: var(--dot);
  box-shadow: inset 0 0 0 3px var(--card);
}
.tone-problem .timeline li.latest::before,
.tone-returned .timeline li.latest::before { border-color: var(--warn); background: var(--warn); }
.tone-cancelled .timeline li.latest::before { border-color: var(--danger); background: var(--danger); }
/* Delivered: nothing is pending any more, so the newest gets its tick too. */
.tone-delivered .timeline li.latest::before {
  background: var(--dot) var(--tick) center / 14px 14px no-repeat;
  box-shadow: none;
}
.timeline .t-status { font-weight: 600; }
.timeline li.latest .t-status { color: var(--accent); }
.tone-delivered .timeline li.latest .t-status { color: var(--ok); }
.tone-problem .timeline li.latest .t-status,
.tone-returned .timeline li.latest .t-status { color: var(--warn); }
.timeline .t-desc { color: var(--ink-2); font-size: 15px; }
.timeline .t-when { color: var(--muted); font-size: 13px; }

/* ── Actions ── */
.actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 4px; }
.btn {
  appearance: none;
  border: 0;
  border-radius: 9px;
  background: var(--accent);
  color: var(--accent-ink);
  font: inherit;
  font-weight: 600;
  font-size: 15px;
  padding: 10px 16px;
  cursor: pointer;
  min-height: 44px;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
}
.btn.ghost { background: var(--card); color: var(--ink-2); border: 1px solid var(--line); }
.btn:disabled { opacity: 0.6; cursor: progress; }

/* ── Search ── */
.search { display: flex; gap: 8px; }
.search input {
  flex: 1;
  min-width: 0;
  font: inherit;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--card);
  min-height: 44px;
  text-transform: uppercase;
}
.search input::placeholder { text-transform: none; }
.search input:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: transparent; }
.error { color: var(--danger); font-size: 14px; margin: 8px 0 0; }

.foot {
  max-width: 640px;
  margin: 0 auto;
  padding: 0 16px 32px;
  color: var(--muted);
  font-size: 13px;
}
.foot a { color: var(--accent); }

@media (max-width: 420px) {
  .steps li { font-size: 11px; }
  .headline { font-size: 20px; }
}
