/* Waybill design system. Spec §8; ported from the approved mockup (option B). */

@font-face {
  font-family: 'IBM Plex Sans Condensed';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url(/fonts/ibm-plex-sans-condensed-latin-400-normal.woff2) format('woff2');
}
@font-face {
  font-family: 'IBM Plex Sans Condensed';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url(/fonts/ibm-plex-sans-condensed-latin-600-normal.woff2) format('woff2');
}
@font-face {
  font-family: 'Courier Prime';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url(/fonts/courier-prime-latin-400-normal.woff2) format('woff2');
}
@font-face {
  font-family: 'Courier Prime';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url(/fonts/courier-prime-latin-700-normal.woff2) format('woff2');
}

:root {
  --paper: #ffffff;
  --page: #eef1f4;
  --ink: #1f2a44;
  --carbon: #2340a0;
  --stamp: #c8102e;
  --muted: #56607a;

  --font-ui: 'IBM Plex Sans Condensed', 'Arial Narrow', Arial, sans-serif;
  --font-typed: 'Courier Prime', 'Courier New', monospace;

  --rule: 1px solid var(--ink);
  --rule-heavy: 1.5px solid var(--ink);
  --tap: 44px;
  --wrap: 68rem;
  --gutter: 16px;
}

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

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

body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 16px;
  line-height: 1.55;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
}

/* Type scale */
h1,
h2,
h3 {
  font-weight: 600;
  line-height: 1.2;
  margin: 0 0 0.6em;
  text-wrap: balance;
}
h1 {
  font-size: 2rem;
}
h2 {
  font-size: 1.4rem;
}
h3 {
  font-size: 1.1rem;
}
p {
  margin: 0 0 1em;
}
small,
.muted {
  color: var(--muted);
}

a {
  color: var(--ink);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
}
a:hover {
  text-decoration-thickness: 2px;
}

:focus-visible {
  outline: 3px solid #2340a0;
  outline-offset: 2px;
}

.wrap {
  width: 100%;
  max-width: var(--wrap);
  margin: 0 auto;
  padding: 0 var(--gutter);
}

main.wrap {
  flex: 1;
  padding-top: 2rem;
  padding-bottom: 3rem;
}

.skip {
  position: absolute;
  left: var(--gutter);
  top: -100px;
  background: var(--ink);
  color: var(--paper);
  padding: 0.6rem 1rem;
  z-index: 10;
}
.skip:focus {
  top: 0.5rem;
}

/* Buttons */
.btn,
button,
input[type='submit'] {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--tap);
  padding: 0.5rem 1rem;
  border: var(--rule-heavy);
  border-radius: 0;
  background: var(--ink);
  color: var(--paper);
  font: inherit;
  font-weight: 600;
  line-height: 1.2;
  text-decoration: none;
  cursor: pointer;
}
.btn:hover,
button:hover {
  background: var(--carbon);
  border-color: var(--carbon);
}
.btn-alt,
button.btn-alt {
  background: var(--paper);
  color: var(--ink);
}
.btn-alt:hover,
button.btn-alt:hover {
  background: var(--page);
  border-color: var(--ink);
}

/* Header */
.site-hd {
  background: var(--paper);
  border-bottom: var(--rule-heavy);
}
.site-hd-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: 64px;
}
.wordmark {
  font-weight: 600;
  font-size: 1.35rem;
  line-height: 1;
  letter-spacing: -0.01em;
  text-decoration: none;
  white-space: nowrap;
  padding: 0.6rem 0;
}

.nav ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  align-items: center;
  gap: 0.25rem;
}
.nav a:not(.btn) {
  display: inline-flex;
  align-items: center;
  min-height: var(--tap);
  padding: 0 0.6rem;
  text-decoration: none;
  font-weight: 600;
}
.nav a:not(.btn):hover {
  text-decoration: underline;
}
.nav .btn {
  margin-left: 0.5rem;
}

/* Small screens: the nav lives in a <details> menu, so it works without JS. */
.nav-menu {
  display: none;
}
.nav-menu summary {
  display: inline-flex;
  align-items: center;
  min-height: var(--tap);
  padding: 0 0.9rem;
  border: var(--rule-heavy);
  font-weight: 600;
  cursor: pointer;
  list-style: none;
}
.nav-menu summary::-webkit-details-marker {
  display: none;
}
.nav-menu summary::after {
  content: '+';
  margin-left: 0.5rem;
}
.nav-menu[open] summary::after {
  content: '\2212';
}

@media (max-width: 640px) {
  .nav-wide {
    display: none;
  }
  .nav-menu {
    display: block;
  }
  .site-hd {
    position: relative;
  }
  .nav-menu .nav {
    position: absolute;
    left: 0;
    right: 0;
    top: 100%;
    z-index: 5;
    background: var(--paper);
    border-bottom: var(--rule-heavy);
    padding: 0 var(--gutter) 0.75rem;
  }
  .nav-menu .nav ul {
    flex-direction: column;
    align-items: stretch;
    gap: 0;
  }
  .nav-menu .nav li {
    border-bottom: var(--rule);
  }
  .nav-menu .nav li:has(.btn) {
    border-bottom: 0;
    padding: 0.75rem 0;
  }
  .nav-menu .nav a:not(.btn) {
    display: flex;
    padding: 0;
  }
  .nav-menu .nav .btn {
    margin: 0;
    width: 100%;
  }
}

/* Footer */
.site-ft {
  border-top: var(--rule-heavy);
  background: var(--paper);
  padding: 1.25rem 0;
}
.site-ft ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0 1.25rem;
}
.site-ft a {
  display: inline-flex;
  align-items: center;
  min-height: var(--tap);
  color: var(--muted);
}

/* Waybill card */
.waybill {
  position: relative;
  background: var(--paper);
  border: var(--rule-heavy);
  margin: 0 0 1.5rem;
}
.waybill-hd {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  border-bottom: var(--rule-heavy);
  padding: 0.5rem 0.75rem;
  font-weight: 600;
}
.waybill-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  margin: 0;
}
.waybill-cell {
  border-right: var(--rule);
  border-bottom: var(--rule);
  padding: 0.4rem 0.75rem 0.5rem;
  min-width: 0;
}
.waybill-grid .waybill-cell:nth-child(2n) {
  border-right: 0;
}
.waybill-cell dt {
  font-size: 0.75rem;
  line-height: 1.3;
  color: var(--muted);
}
.waybill-cell dd {
  margin: 0;
  font-family: var(--font-typed);
  font-weight: 700;
  font-size: 1rem;
  color: var(--carbon);
  overflow-wrap: anywhere;
}
.waybill-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding: 0.75rem;
}

/* Stamps: the one bold element. Static, so nothing to reduce for motion. */
.stamps {
  position: absolute;
  right: 14px;
  bottom: 64px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.5rem;
  pointer-events: none;
}
.stamp {
  display: inline-block;
  border: 3px solid var(--stamp);
  border-radius: 4px;
  color: var(--stamp);
  background: transparent;
  font-family: var(--font-ui);
  font-weight: 600;
  font-size: 1.125rem;
  line-height: 1.2;
  padding: 2px 8px;
  opacity: 0.85;
  transform: rotate(-12deg);
  white-space: nowrap;
}
.stamp:nth-child(2n) {
  transform: rotate(-8deg);
}
.stamp:nth-child(3n) {
  transform: rotate(-10deg);
}

/* Compact list row */
.waybill-row {
  position: relative;
  background: var(--paper);
  border: var(--rule-heavy);
  margin: 0 0 -1.5px;
  display: grid;
  grid-template-columns: minmax(12rem, 1.2fr) 3fr;
  align-items: stretch;
}
.waybill-row-title {
  margin: 0;
  padding: 0.6rem 0.75rem;
  font-size: 1rem;
  border-right: var(--rule);
  display: flex;
  align-items: center;
}
.waybill-row-title a {
  text-decoration: none;
}
.waybill-row-title a:hover {
  text-decoration: underline;
}
.waybill-row-title a::after {
  content: '';
  position: absolute;
  inset: 0;
}
.waybill-row-cells {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(8rem, 1fr));
  margin: 0;
}
.waybill-row-cells .waybill-cell {
  border-bottom: 0;
}
.waybill-row-cells .waybill-cell:last-child {
  border-right: 0;
}
.waybill-row .stamps {
  position: absolute;
  right: 10px;
  top: 50%;
  bottom: auto;
  translate: 0 -50%;
}
.waybill-row .stamp {
  font-size: 0.8rem;
  border-width: 2px;
}

@media (max-width: 720px) {
  .waybill-row {
    grid-template-columns: 1fr;
  }
  .waybill-row-title {
    border-right: 0;
    border-bottom: var(--rule);
    padding-right: 7rem;
  }
  .waybill-row .stamps {
    top: 0.6rem;
    translate: none;
  }
}

/* Under ~420px the ruled grid becomes one column. */
@media (max-width: 420px) {
  .waybill-grid {
    grid-template-columns: 1fr;
  }
  .waybill-grid .waybill-cell {
    border-right: 0;
  }
  .waybill-hd {
    flex-direction: column;
    gap: 0;
  }
}

/* Below 720px stacked stamps sit in the flow under the grid so they never cover a cell. */
@media (max-width: 720px) {
  .waybill .stamps {
    position: static;
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: flex-start;
    gap: 0.5rem 1rem;
    padding: 0.9rem 0.75rem 0.75rem;
  }
}

/* Ads: labelled, neutral, reserved height so nothing shifts. */
.ad {
  background: var(--page);
  border: 1px dashed var(--muted);
  margin: 1.5rem 0;
  padding: 0.5rem;
  min-height: 280px;
}
.ad-label {
  font-size: 0.75rem;
  color: var(--muted);
  margin: 0 0 0.25rem;
}
.ad-list_inline {
  min-height: 120px;
}

/* Breadcrumbs and pagination */
.breadcrumbs ol {
  list-style: none;
  margin: 0 0 1rem;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  font-size: 0.9rem;
  color: var(--muted);
}
.breadcrumbs li + li::before {
  content: '/';
  padding: 0 0.5rem;
}
.breadcrumbs a {
  color: var(--muted);
}

.pagination ul {
  list-style: none;
  margin: 2rem 0 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
}
.pagination a,
.pagination span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: var(--tap);
  min-height: var(--tap);
  padding: 0 0.75rem;
  border: var(--rule-heavy);
  background: var(--paper);
  text-decoration: none;
  font-weight: 600;
}
.pagination [aria-current='page'] {
  background: var(--ink);
  color: var(--paper);
}
.pagination .gap {
  align-self: center;
  padding: 0 0.25rem;
}

/* Forms: a form reads like a blank waybill. */
.form-page {
  max-width: 30rem;
}
.sheet {
  background: var(--paper);
  border: var(--rule-heavy);
  padding: 1.25rem 1rem 1rem;
}
.field {
  margin: 0 0 1rem;
}
label {
  display: block;
  font-size: 0.875rem;
  color: var(--muted);
  margin-bottom: 0.25rem;
}
input[type='text'],
input[type='email'],
input[type='password'],
input[type='tel'],
input[type='number'],
input[type='search'],
select,
textarea {
  display: block;
  width: 100%;
  min-height: var(--tap);
  padding: 0.5rem 0.6rem;
  border: 0;
  border-bottom: var(--rule-heavy);
  border-radius: 0;
  background: var(--page);
  color: var(--carbon);
  font-family: var(--font-typed);
  font-size: 1rem;
  font-weight: 700;
}
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline-offset: 0;
}
.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 1.25rem;
}
.alert {
  border: 2px solid var(--stamp);
  color: var(--stamp);
  background: var(--paper);
  padding: 0.6rem 0.75rem;
  font-weight: 600;
}
.after {
  margin-top: 1rem;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
}

/* Listing detail */
.contact {
  background: var(--paper);
  border: var(--rule-heavy);
  padding: 0.75rem 1rem 1rem;
  margin: 0 0 1.5rem;
}
.contact h2 {
  margin: 0 0 0.5rem;
  font-size: 1.125rem;
}
.contact p {
  margin: 0 0 0.5rem;
}
.contact-list {
  margin: 0;
}
.contact-list div {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1rem;
  padding: 0.25rem 0;
}
.contact-list dt {
  min-width: 4rem;
  color: var(--muted);
}
.contact-list dd {
  margin: 0;
  font-family: var(--font-typed);
  font-weight: 700;
  overflow-wrap: anywhere;
}
.description {
  max-width: 42rem;
  margin: 0 0 1.5rem;
}
.posted {
  color: var(--muted);
  font-size: 0.9rem;
}
.report {
  margin: 1.5rem 0;
}
.report summary {
  display: inline-flex;
  align-items: center;
  min-height: var(--tap);
  cursor: pointer;
}
.report .sheet {
  max-width: 30rem;
}
.logo {
  display: block;
  max-width: 160px;
  height: auto;
  margin: 0 0 1rem;
  border: var(--rule);
  background: var(--paper);
}
.similar .waybill-row {
  margin-bottom: 0.75rem;
}

/* Home and archives */
.intro {
  max-width: 42rem;
}
.home-hero h1 {
  margin-bottom: 1rem;
}
.search-form,
.filters {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(18rem, 1fr));
  gap: 0 1.5rem;
  align-items: end;
}
.filters {
  margin: 1rem 0 1.5rem;
  padding: 1rem;
  background: var(--paper);
  border: var(--rule-heavy);
}
.search-form .actions,
.filters .actions {
  margin-top: 0;
  margin-bottom: 1rem;
}
.home-section {
  margin: 2rem 0;
}
.link-grid,
.plain {
  list-style: none;
  margin: 0;
  padding: 0;
}
.link-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(12rem, 1fr));
  gap: 0.5rem;
}
.link-grid a {
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-height: var(--tap);
  padding: 0 0.75rem;
  background: var(--paper);
  border: var(--rule);
  text-decoration: none;
}
.link-grid a:hover {
  border-color: var(--carbon);
}
.link-grid .count {
  font-family: var(--font-typed);
  color: var(--carbon);
}
.plain li a {
  display: inline-block;
  padding: 0.5rem 0;
}
.steps {
  list-style: none;
  counter-reset: step;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.75rem;
}
.steps li {
  counter-increment: step;
  display: grid;
  grid-template-columns: 2.5rem 1fr;
  background: var(--paper);
  border: var(--rule-heavy);
}
.steps li::before {
  content: counter(step);
  grid-row: span 2;
  display: grid;
  place-items: center;
  border-right: var(--rule);
  font-family: var(--font-typed);
  font-weight: 700;
  color: var(--carbon);
}
.steps li > * {
  padding: 0.4rem 0.75rem;
}
.empty {
  background: var(--paper);
  border: var(--rule-heavy);
  padding: 1rem;
}

/* Posting forms and account */
.hint {
  margin: 0.25rem 0 0;
  font-size: 0.875rem;
  color: var(--muted);
}
.field-error {
  margin: 0.25rem 0 0;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--stamp);
}
input[aria-invalid='true'],
select[aria-invalid='true'],
textarea[aria-invalid='true'] {
  border-bottom-color: var(--stamp);
  background: #fdf1f3;
}
textarea {
  resize: vertical;
}
input[type='file'] {
  width: 100%;
  font: inherit;
}
fieldset {
  min-width: 0;
  margin: 0 0 1rem;
  padding: 0;
  border: 0;
}
legend {
  padding: 0;
  margin-bottom: 0.25rem;
  font-size: 0.875rem;
  color: var(--muted);
}
.group {
  margin-top: 1.5rem;
}
.group legend {
  width: 100%;
  padding-top: 0.75rem;
  border-top: var(--rule);
  font-weight: 600;
  color: var(--ink);
}
.group .hint {
  margin: 0 0 0.75rem;
}
label.check {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-height: var(--tap);
  margin: 0;
  color: var(--ink);
  font-size: 1rem;
}
input[type='checkbox'],
input[type='radio'] {
  width: 1.25rem;
  height: 1.25rem;
  flex: none;
  accent-color: var(--ink);
}
.logo-preview {
  display: block;
  max-width: 120px;
  height: auto;
  margin: 0 0 0.5rem;
  border: var(--rule);
}
.ok {
  border: 2px solid var(--carbon);
  background: var(--paper);
  padding: 0.6rem 0.75rem;
  font-weight: 600;
}
.kind-list {
  list-style: none;
  margin: 1rem 0;
  padding: 0;
  display: grid;
  gap: 0.75rem;
  max-width: 36rem;
}
.kind-link {
  display: block;
  padding: 0.75rem 1rem;
  background: var(--paper);
  border: var(--rule-heavy);
  color: var(--ink);
  text-decoration: none;
}
.kind-link strong,
.kind-link span {
  display: block;
}
.kind-link span {
  color: var(--muted);
}
.kind-link:hover {
  border-color: var(--carbon);
}
.account-list {
  list-style: none;
  margin: 0 0 1.5rem;
  padding: 0;
  display: grid;
  gap: 1rem;
}
.row-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  background: var(--paper);
  border: var(--rule);
  border-top: 0;
}
.row-actions form {
  margin: 0;
}
.row-status {
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}
.btn-danger,
button.btn-danger {
  background: var(--stamp);
  border-color: var(--stamp);
}
.delete summary {
  display: inline-flex;
  align-items: center;
  min-height: var(--tap);
  padding: 0 0.5rem;
  cursor: pointer;
  color: var(--stamp);
  font-weight: 600;
}
.delete[open] {
  flex-basis: 100%;
}
.notice {
  background: var(--paper);
  border: 2px solid var(--carbon);
  padding: 0.75rem 1rem 1rem;
  margin: 1rem 0 1.5rem;
}
.notice h2 {
  margin-top: 0;
}
.notice-list {
  list-style: none;
  margin: 1rem 0;
  padding: 0;
  display: grid;
  gap: 0.75rem;
}
.notice-list li {
  border-top: var(--rule);
  padding-top: 0.5rem;
}
.notice-list .muted {
  display: block;
}
.notice-list .row-actions {
  border: 0;
  padding: 0.5rem 0 0;
}
.account-forms {
  margin-top: 2rem;
}
.account-forms section {
  margin-bottom: 2rem;
}

/* Location picker: province select + searchable town box (public/js/location-picker.js) */
.loc-pair {
  display: grid;
  gap: 0.75rem;
}
@media (min-width: 36rem) {
  .loc-pair {
    grid-template-columns: 1fr 1fr;
  }
}
.loc-sub {
  font-size: 0.8125rem;
}
.loc-pair input::-webkit-calendar-picker-indicator {
  opacity: 0.6;
}
select[data-loc][hidden] {
  display: none;
}

/* Contact form spam trap: off-screen, not display:none, so simple bots still fill it in. */
.trap {
  position: absolute;
  left: -10000px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}
