/* Schedules: results (A's page in the shared system). The row, the search fields, the rate sheet and the lane chip
   are in schedules.css. */

/* ---------- the horizon band: the small ship sails toward its bow (left) as the page moves ----------
   base = the plate with the ship lifted out; the ship (with its bow wave and, at dusk, its lights' reflections) is
   its own layer and sits on open sea, so it can travel. motion.js scene "results-ship", scrubbed.
   Fix stage 2 (Emil): the scene starts at the page top (the section runs up under the fixed header), runs over a
   quarter of a screen, the ship travels 5.5% of the plate (8% of the phone crop) and the plate drifts down against
   the scroll, so the band leaves slower than the page and the ship's move is seen before the band is gone.
   The stage is laid like object-fit: cover, 12% wider than the band and anchored at 34% 58%, so the ship stands
   clear of the lane card while it sails. On a phone the plate is its own 1100 px crop around the ship. */
/* --rb-drift: 44 px keeps the hull inside the band at p = 1 (it sits about 50 px above the band's foot at rest; a
   deeper drift pushed it out through the bottom edge instead of letting it leave under the header) */
.results-bar { position: relative; --band-h: 248px; --rb-drift: 44px; margin-top: calc(-1 * var(--header-h)); padding-top: var(--header-h); min-height: calc(var(--header-h) + var(--band-h)); }
.rb-band { position: relative; height: var(--band-h); overflow: hidden; background: var(--c-bg-alt); }
.rb-stage { position: absolute; left: 34%; top: 58%; width: max(112%, calc(var(--band-h) * 2.3337)); aspect-ratio: 2560 / 1097; transform: translate(-34%, calc(-58% + var(--p, 0) * var(--rb-drift))); animation: rb-in .45s var(--p-ease-out) both; }
.js .results-bar:not(.ready) .rb-stage { animation-play-state: paused; }
@keyframes rb-in { from { opacity: 0; } to { opacity: 1; } }
/* gap pass M1: the plate and the ship together in one idle layer (data-idle="drift", 34 s a leg), so the ship never
   slides off its horizon; the scroll moves stay on .rb-stage and .rb-ship */
.rb-idle, .rb-plate, .rb-ship { position: absolute; inset: 0; }
/* final polish F3: the idle layer bobs (data-idle="bob", site.css: 6.5 px, 3.8 on a phone): the camera rides the swell
   with the ship on its horizon. The stage overhangs the band by 15 px or more above and below at every size and
   scroll position, so no edge shows. */
.rb-plate > picture, .rb-plate img { position: absolute; inset: 0; width: 100%; height: 100%; }
.rb-ship { transform: translate3d(calc(var(--p, 0) * -5.5%), 0, 0); }
.results-bar.is-moving .rb-stage, .results-bar.is-moving .rb-ship { will-change: transform; }
.rb-ship > picture { position: absolute; left: 64.375%; top: 54.6946%; width: 21.5625%; height: 20.0547%; }
.rb-ship img { width: 100%; height: 100%; }

/* final polish m13: the card is in the flow, its top 88 px into the band (where it stood when it was pinned to the
   band's foot: 87 to 94 px). Pinned to the foot, the inline search grew the card UPWARD, under the fixed header; now it
   grows down and the list moves down with it, so opening the search never moves the card. When a script brings it
   into view (the empty state's "Change search") it stops 24 px under the fixed header: the page's own
   scroll-padding-top (site.css: header + 16 px) plus this 8 px margin. */
.results-bar .summary { position: relative; z-index: 5; margin-top: calc(88px - var(--band-h)); padding-bottom: 28px; }
.summary-card { background: var(--c-surface); border: 1px solid var(--c-line); border-radius: var(--p-radius-3); padding: 18px 20px 18px 26px; display: grid; grid-template-columns: auto auto; align-items: center; gap: 6px 40px; box-shadow: var(--shadow-soft); width: fit-content; max-width: 100%; scroll-margin-top: 8px; }
.summary-card h1 { grid-column: 1; }
.summary-card .meta { grid-column: 1; }
.summary-card .change { grid-column: 2; grid-row: 2 / span 2; justify-self: end; }
/* gap pass S4: the page's breadcrumb, first line of the lane card (the H1 is the page itself), as its BreadcrumbList says */
.summary-card .crumbs { grid-column: 1 / -1; color: var(--c-text-muted); }
.summary-card .crumbs ol { margin: 0 0 2px; }
.summary-card h1 { font-size: clamp(26px, 2.2vw, 32px); line-height: 1.1; letter-spacing: -.022em; display: flex; align-items: center; gap: 8px 12px; flex-wrap: wrap; }
/* repair 2 (closure r1, new 2): the port code is in the name's own line flow (it was a flex item beside the name), so
   when a long name wraps ("Ho Chi Minh City" at 320) the code follows its last word instead of floating at the end
   of the first line; the space before it is the gap */
.summary-card h1 .lane-end { display: block; min-width: 0; }
.summary-card h1 .lane-end .code { white-space: nowrap; margin-inline-start: 3px; }   /* with the space: the 8 px gap it had */
.summary-card h1 .code { font-size: var(--fs-xs); font-weight: var(--fw-ui); color: var(--c-text-muted); letter-spacing: .04em; }
.summary-card h1 .code.nomatch { color: var(--c-text); padding: 2px 6px; border-radius: 4px; border: 1px dashed var(--c-text-muted); letter-spacing: 0; }
.summary-card .route-arrow { width: 22px; height: 22px; color: var(--c-accent-text); flex: none; }
/* final polish m12: the arrow travels with the destination, so a lane that needs two lines breaks before the arrow
   ("Shanghai CNSHA" / "→ Rotterdam NLRTM"), never after it */
.summary-card h1 .lane-to { display: inline-flex; align-items: flex-start; gap: 12px; min-width: 0; }
.summary-card h1 .lane-to .route-arrow { margin-top: calc((1.1em - 22px) / 2); }   /* centred on the name's first line */
.summary-card .meta { color: var(--c-text-muted); font-size: var(--fs-m); }
/* repair 1: each meta item is one piece with the "·" before it, so a wrapped line never ends on it ("40'HC · ready
   from 1 Dec 2026 ·" at 320), as the count line does (m6) */
.summary-card .meta .mi { white-space: nowrap; }

/* the inline search (fix stage 2): the card widens to the row and the compact fields open under the lane */
.summary-card.editing { width: 100%; }
.lane-edit { grid-column: 1 / -1; margin-top: 12px; padding-top: 16px; border-top: 1px solid var(--c-line); }
.mini-fields { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1.3fr) minmax(0, 1fr) minmax(0, .9fr) auto; gap: 12px; align-items: start; }
.lane-edit .field input, .lane-edit .field select { height: 44px; font-size: var(--fs-m); }
.lane-edit .date-show { font-size: var(--fs-m); }
.lane-edit .go { margin-top: 24px; height: 44px; }

/* ---------- filters and the list ---------- */
.results { display: grid; grid-template-columns: 272px minmax(0, 1fr); gap: 48px; align-items: start; padding: 40px 0 var(--p-space-14); }
.results.no-lane { grid-template-columns: minmax(0, 1fr); }
.results.no-lane .fwrap, .results.no-lane .sort { display: none; }
.fwrap > summary { display: none; }
@media (min-width: 1101px) { .fwrap { position: sticky; top: calc(var(--header-h) + 20px); } }
.filters { display: flex; flex-direction: column; gap: 28px; }
.filters fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
.filters legend { padding: 0; margin-bottom: 6px; font: var(--fw-strong) var(--fs-s)/1.3 var(--f-text); }
.checks { display: flex; flex-direction: column; }
.check { display: flex; align-items: center; gap: 12px; min-height: 44px; font-size: var(--fs-m); cursor: pointer; }
.check input { width: 20px; height: 20px; margin: 0; flex: none; accent-color: var(--c-accent-deep); }
.check .count { margin-inline-start: auto; color: var(--c-text-muted); font-size: var(--fs-s); font-variant-numeric: tabular-nums; }
.range { display: flex; flex-direction: column; gap: 6px; }
.range input { width: 100%; height: 44px; margin: 0; accent-color: var(--c-accent-deep); }
.range output { font-size: var(--fs-s); color: var(--c-text-muted); }
.reset { align-self: flex-start; min-height: 44px; padding: 0; border: 0; background: none; color: var(--c-accent-text); font: var(--fw-ui) var(--fs-s)/1 var(--f-text); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
.list-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 16px; }
.list-head .count { font-size: var(--fs-m); color: var(--c-text-muted); }
.list-head .count b { color: var(--c-text); font-weight: var(--fw-strong); }
.sort { display: inline-flex; padding: 3px; border-radius: var(--p-radius-pill); background: var(--c-surface); border: 1px solid var(--c-line-strong); }
.sort button { min-height: 42px; padding: 0 16px; border: 0; border-radius: var(--p-radius-pill); background: transparent; color: var(--c-text); font: var(--fw-ui) var(--fs-s)/1 var(--f-text); cursor: pointer; transition: background-color .2s var(--p-ease-ui); }
.sort button[aria-pressed="true"] { background: var(--c-text); color: var(--c-bg); }
.list .sample-note { margin-top: 20px; }

/* loading: the skeleton has the real rows' height, so nothing jumps; the filters and the sort wait (aria-disabled,
   set by the script) and look it */
.results.is-loading .filters fieldset, .results.is-loading .filters .reset, .results.is-loading .sort { opacity: .5; pointer-events: none; }
.sk-row { pointer-events: none; }
.sk { position: relative; display: block; height: 14px; border-radius: 6px; background: var(--c-line); overflow: hidden; }
.sk::after { content: ""; position: absolute; inset: 0; background: linear-gradient(90deg, transparent, var(--c-line-strong), transparent); transform: translateX(-100%); animation: shimmer 1.3s linear infinite; }
@keyframes shimmer { to { transform: translateX(100%); } }

/* empty states */
.empty { display: flex; flex-direction: column; align-items: center; gap: 14px; padding: 64px 24px; text-align: center; background: var(--c-surface); border: 1px solid var(--c-line); border-radius: var(--p-radius-3); }
.empty h2 { font-size: var(--fs-2xl); line-height: var(--lh-snug); max-width: 24ch; text-wrap: balance; }
.empty p { color: var(--c-text-muted); max-width: 52ch; }
.empty .ctas { justify-content: center; margin-top: 6px; }
.empty svg.box { width: 80px; height: 64px; color: var(--c-accent-text); }
.chips, .choices { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.chips li { padding: 6px 12px; border-radius: var(--p-radius-pill); background: var(--c-accent-wash); color: var(--c-accent-text); font-size: var(--fs-s); font-weight: var(--fw-ui); }

/* ---------- widths ---------- */
@media (max-width: 1240px) {
  .mini-fields { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .lane-edit .go { grid-column: 1 / -1; margin-top: 0; justify-content: space-between; }
}
@media (max-width: 1100px) {
  .results { grid-template-columns: minmax(0, 1fr); gap: 24px; }
  .fwrap { border: 1px solid var(--c-line); border-radius: var(--p-radius-2); background: var(--c-surface); }
  .fwrap > summary { display: flex; align-items: center; min-height: 52px; padding: 0 18px; font-weight: var(--fw-strong); cursor: pointer; list-style: none; }
  .fwrap > summary::-webkit-details-marker { display: none; }
  .fwrap > summary #fcount { color: var(--c-accent-text); margin-inline-start: 4px; }
  .fwrap > summary::after { content: ""; margin-inline-start: auto; width: 9px; height: 9px; border-inline-end: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(45deg); margin-top: -4px; }
  .fwrap[open] > summary::after { transform: rotate(225deg); margin-top: 4px; }
  .fwrap .filters { padding: 4px 18px 18px; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 32px; }
  .fwrap .filters .reset { grid-column: 1 / -1; }
  .results.is-loading .fwrap > summary { opacity: .5; }
}
@media (max-width: 767px) {
  /* the phone crop: 1100x620 of the plate around the ship; the ship layer placed in it in the crop's own percentages */
  .results-bar { --band-h: 176px; --rb-drift: 18px; }
  /* the ship stands high in the phone band and is under the header by p = .5, so the whole move plays by p = .45 */
  .results-bar { --pp: min(1, calc(var(--p, 0) * 2.2)); }
  .rb-stage { left: 50%; top: 0; width: max(100%, 401px); aspect-ratio: 1100 / 620; transform: translate(-50%, calc(-34px + var(--pp) * var(--rb-drift))); }
  /* gap pass (Emil, the phone move too small): the ship sails 11% of the crop (was 8%), about 44 px at 390; the base
     under it is open sea (the ship was lifted out), so nothing is uncovered */
  .rb-ship { transform: translate3d(calc(var(--pp) * -11%), 0, 0); }
  .rb-ship > picture { left: 37.0909%; top: 29.0323%; width: 50.1818%; height: 35.4839%; }
  .results-bar .summary { position: relative; inset: auto; margin-top: -54px; padding-bottom: 0; }
  .summary-card { width: 100%; padding: 16px 18px; grid-template-columns: minmax(0, 1fr); row-gap: 8px; }
  /* final polish m11: the touch size on a phone (it was the 40 px small button) */
  .summary-card .change { grid-column: 1; grid-row: auto; margin-top: 6px; width: 100%; height: 44px; justify-content: center; }
  .mini-fields { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .lane-edit .field.from, .lane-edit .field.to { grid-column: 1 / -1; }
  .lane-edit .field select { padding: 0 30px 0 12px; }
  .fwrap .filters { grid-template-columns: minmax(0, 1fr); }
  .list-head { flex-direction: column; align-items: stretch; }
  .sort { width: 100%; }
  .sort button { flex: 1; padding: 0 8px; min-height: 44px; }   /* final polish m11: the touch size (was 42) */
  .empty { padding: 44px 18px; }
  .empty .ctas { width: 100%; }
}
@media (max-width: 374px) {
  .mini-fields { grid-template-columns: minmax(0, 1fr); }
  /* final gap stage: at 320 "Transit time" broke onto two lines in an equal third; the three widths follow their words */
  .sort button { flex: 1 1 auto; padding: 0 6px; white-space: nowrap; }
}
:root.rm .rb-stage { animation: none; }
