/* Picture rails.
   services.php — .svc-grid.rails-list: one service per row. Under 1280px each
     picture is a banner at the top of its own service card; at 1280px and up the
     pictures move into the page margins, 4 even pictures per rail, both rails
     starting level with the first service.
   index.html / index.php (home pages) — .wrap.rails-page holds two .page-rail
     columns that run down both sides of the whole main content (from the first
     cards to the last section) at 1280px and up, 4 pictures per side spaced
     evenly. Under 1280px those rails are hidden and the "What we handle" cards
     (.svc-grid.rails-grid2 on index.html, .rails-grid2s on index.php) show the
     pictures as banners at the top of their matching card instead.
   Home pages carry a compact companies row just above the footer (.doors-compact).
   The Local Links page (.doors-page) lists every door: stacked lists on phones,
   a multi-column grid from 768px up.
   Rules only touch elements carrying .svc-item / .rail / .rails-* / .page-rail /
   .doors-compact* / .doors-page* / .doors-band-col classes, so the pages' own
   styles are unchanged everywhere else. */

/* ---------- Small and medium screens: banners at the top of each card ---------- */
.svc-item {
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  overflow: hidden; display: flex; flex-wrap: wrap; align-content: flex-start;
}
.rails-grid2 .svc-item { background: #fbfcfd; }
.svc-item > .svc { order: 2; flex: 1 1 100%; border: 0; border-radius: 0; background: none; }
.svc-item > .rail {
  order: 1; flex: 1 1 30%; min-width: 0; display: block;
  width: 100%; height: 170px; object-fit: cover; object-position: center 40%;
  border-bottom: 3px solid var(--red);
}
.rails-grid2 .svc-item > .rail { height: 150px; }
.svc-item > .rail[src$="rail-lockout.jpg"] { object-position: center 25%; }
.svc-item > .rail[src$="rail-winch-recovery.jpg"] { object-position: center 75%; }
.svc-item > .rail + .rail { border-left: 2px solid var(--card); }

/* index.php: Lockouts & Roadside is the odd fifth block, so it spans the full row. */
@media (min-width: 640px) {
  .rails-grid2s .svc-item.svc-span { grid-column: 1 / -1; }
}

/* ---------- Home pages: compact companies row above the footer ---------- */
.doors-compact { padding-top: 16px; padding-bottom: 16px; }
.doors-compact-row {
  margin: 0; font-size: 15.5px; font-weight: 700; color: var(--navy);
  line-height: 1.55; text-align: center;
}
.doors-compact-label { font-weight: 800; margin-right: 4px; }
.doors-compact-dot { color: var(--muted); font-weight: 700; padding: 0 2px; }
.doors-compact-row a { color: var(--navy); text-decoration: none; font-weight: 700; }
.doors-compact-row a:hover, .doors-compact-row a:focus-visible { color: var(--red); }
.doors-compact-all { white-space: nowrap; }

/* ---------- Local Links page ---------- */
.doors-page-cols { display: grid; grid-template-columns: 1fr; gap: 22px; }
.doors-page-note {
  margin: 0 0 8px; font-size: 13.5px; color: var(--muted); line-height: 1.45;
}
.doors-band-col h3 {
  margin: 0 0 4px; font-size: 13px; font-weight: 800; color: var(--muted);
  text-transform: uppercase; letter-spacing: .6px;
}
.doors-band-col ul { list-style: none; margin: 0; padding: 0; }
.doors-band-col li { margin: 0; border-top: 1px solid var(--line); }
.doors-band-col a {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  padding: 11px 2px; font-size: 15.5px; font-weight: 700; color: var(--navy); text-decoration: none;
}
.doors-band-col a::after { content: "\2197"; color: var(--red); font-weight: 800; }
.doors-band-col a:hover, .doors-band-col a:focus-visible { color: var(--red); }
@media (min-width: 768px) {
  .doors-page-cols { grid-template-columns: 1fr 1fr; gap: 28px 36px; }
}
@media (min-width: 1100px) {
  .doors-page-cols { grid-template-columns: 1fr 1fr 1fr; }
}

/* Home-page side rails are for wide screens only. */
.page-rail { display: none; }

/* ---------- Wide screens ---------- */
@media (min-width: 1280px) {
  /* Home pages: the cards drop their banners (the pictures are in the side rails). */
  .rails-grid2 .svc-item > .rail, .rails-grid2s .svc-item > .rail { display: none; }

  /* Home pages: two rails down the whole main content, just outside the cards.
     Top: level with the first cards; bottom: the end of the last section.
     Pictures are spaced evenly (first at the top, last at the bottom) and shrink
     a little if the page is short, so they never run past the content. */
  .rails-page { position: relative; }
  .page-rail {
    display: flex; flex-direction: column; justify-content: space-between;
    position: absolute; top: var(--page-rail-top, 0px); bottom: 0;
    width: var(--page-rail-w); z-index: 1;
  }
  .page-rail-l { left: var(--page-rail-x); }
  .page-rail-r { right: var(--page-rail-x); }
  .page-rail img {
    display: block; flex: 0 0 auto; width: 100%;
    height: min(calc(var(--page-rail-w) * 1.5), calc((100% - 48px) / 4));
    object-fit: cover; object-position: center;
    border: 3px solid #fff; border-bottom: 4px solid var(--red); border-radius: 12px;
    box-shadow: 0 8px 22px rgba(16, 28, 51, .22);
    background: var(--navy2);
  }
  .page-rail img[src$="rail-lockout.jpg"] { object-position: center 30%; }
  /* index.html: .rails-page is the main .wrap (1060px content, 20px side padding).
     The door cards' -30px margin moves the wrap itself up, so top 0 = the cards' top,
     which is on screen on first load. */
  .rails-page.rails-page-1060 {
    --page-rail-w: clamp(90px, calc((100vw - 1060px) / 2 - 20px), 170px);
    --page-rail-x: calc(4px - var(--page-rail-w)); --page-rail-top: 0px;
  }
  /* index.php: .rails-page is a full-width wrapper around the hero and the main
     .wrap (site style.css: 960px content). Its hero is tall, so the rails start
     level with the top of the hero text (its 34px padding), just under the nav,
     to be on screen on first load. */
  .rails-page.rails-page-960 {
    --page-rail-w: clamp(120px, calc((100vw - 960px) / 2 - 24px), 170px);
    --page-rail-x: calc(50% - 482px - var(--page-rail-w)); --page-rail-top: 34px;
  }

  /* services.php: rail | one service per row | rail. */
  .rails-list, .rails-grid2, .rails-grid2s { align-items: stretch; grid-auto-rows: auto; }
  .rails-list .svc-item { display: contents; }
  .rails-list .svc-item > .svc {
    order: 0; border: 1px solid var(--line); border-radius: 12px;
    display: flex; flex-direction: column; justify-content: center;
    background: var(--card);
  }

  /* Each picture fills its grid area (rows set by --at). contain:size stops the
     480x720 source from stretching the rows. */
  .rails-list .svc-item > .rail {
    order: 0; grid-row: var(--at); align-self: stretch;
    width: var(--rail-w); height: auto; min-height: var(--rail-min, 150px);
    aspect-ratio: auto; contain: size; object-fit: cover; object-position: center;
    border: 3px solid #fff; border-bottom: 4px solid var(--red); border-radius: 12px;
    box-shadow: 0 8px 22px rgba(16, 28, 51, .22);
    background: var(--navy2);
  }
  .rails-list .svc-item > .rail + .rail { border-left: 3px solid #fff; }
  .rails-list .svc-item > .rail[src$="rail-lockout.jpg"] { object-position: center 30%; }
  .rails-list .svc-item > .rail[src$="rail-winch-recovery.jpg"] { object-position: center 60%; }
  .rails-list .rail-l { justify-self: start; }
  .rails-list .rail-r { justify-self: end; }

  /* Each service spans 4 quarter-rows (36 for the 9 services), so a picture can
     start or end a quarter of the way into a block: 4 near-equal pictures per
     rail, starting and ending level, without making any card taller.
     Picture positions are the --at lines set in services.php. */
  .rails-list {
    --rail-min: 0px;
    --rail-w: clamp(120px, calc((100vw - 960px) / 2 - 24px), 170px);
    grid-template-columns: var(--rail-w) minmax(0, 1fr) var(--rail-w);
    column-gap: 37px;
    margin-left: calc(-1 * (var(--rail-w) + 37px));
    margin-right: calc(-1 * (var(--rail-w) + 37px));
  }
  .rails-list > .svc, .rails-list .svc-item > .svc { grid-column: 2; grid-row: span 4; }
  .rails-list .rail-l { grid-column: 1; }
  .rails-list .rail-r { grid-column: 3; }
}

/* Local Links: keep a linked group (e.g. #rental-cars) clear of the sticky header. */
.doors-band-col[id] { scroll-margin-top: 90px; }
