/* Job page v3: phone layout only. Every visual rule sits inside the max-width: 899.98px block,
   so the desktop layout (900px and wider, job-v2.css) is untouched. The new elements are
   hidden by default and only shown inside that block. */
.jd3-pay, .jd3-links, .jd3-more, .jd3-bar-text { display: none; }
.jd2 .jd2-similar li a.jd3-sim-apply { display: none; }

@media (max-width: 899.98px) {
  /* first screen: pay and place, Apply, two links, then the remaining facts */
  .jd2-side { display: flex; flex-direction: column; }
  .jd3-pay { display: block; order: 1; margin: 0 0 0.9rem; }
  .jd3-pay-amount { margin: 0 0 0.2rem; font-size: 1.375rem; line-height: 1.25; font-weight: 800; color: var(--heading, #111827); }
  .jd3-pay-place { margin: 0; font-size: 1rem; line-height: 1.4; color: #374151; }
  .jd2-side #jd2-apply-top { order: 2; }
  .jd3-links { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.6rem; order: 3; margin: 0.6rem 0 1.1rem; }
  .jd3-links .jd3-share,
  .jd2 .jd3-links a.jd3-jump {
    display: flex; align-items: center; justify-content: center; min-height: 46px; box-sizing: border-box;
    padding: 0.4rem 0.6rem; border: 1px solid #9aa2ad; border-radius: 0.4rem; background: #fff;
    color: var(--heading, #111827); font: inherit; font-size: 0.95rem; font-weight: 600; text-decoration: none; cursor: pointer;
  }
  .jd3-links .jd3-share[hidden] { display: none; }
  .jd3-links .jd3-share[hidden] + .jd3-jump { grid-column: 1 / -1; }
  .jd3-links .jd3-share:only-child { grid-column: 1 / -1; }
  /* neither link to show (no share sheet and no similar jobs): no empty gap */
  .jd3-links:not(:has(a, button:not([hidden]))) { display: none; }
  .jd2-side .jd2-facts { order: 4; margin-bottom: 0; }
  .jd2-facts .jd3-dup { display: none; }

  /* long description folded; the script adds .is-folded, so without script the full text shows */
  .jd3-desc-body.is-folded { position: relative; max-height: 21rem; overflow: hidden; }
  .jd3-desc-body.is-folded::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 4rem; background: linear-gradient(rgba(255, 255, 255, 0), #fff); }
  .jd3-more { display: block; width: 100%; min-height: 46px; margin: 0.8rem 0 0; border: 1px solid #9aa2ad; border-radius: 0.4rem; background: #fff; color: var(--heading, #111827); font: inherit; font-size: 0.95rem; font-weight: 600; cursor: pointer; }
  .jd3-more[hidden] { display: none; }

  /* similar jobs: an Apply button on each row */
  .jd2-similar li { display: flex; align-items: center; gap: 0.75rem; }
  .jd3-sim-text { flex: 1 1 auto; min-width: 0; }
  /* html body: list-v2.css sets .apply-now-btn to width 100% on phones; this must win */
  html body .jd2 .jd2-similar li a.jd3-sim-apply {
    display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto; min-height: 44px; box-sizing: border-box;
    width: auto; min-width: 0; max-width: none; margin: 0; padding: 0 1.1rem; border-radius: 0.4rem; color: #fff; font-size: 0.95rem; font-weight: 700; text-decoration: none;
  }

  /* fixed bar: pay and title beside Apply */
  .jd2-bar { display: flex; align-items: center; gap: 0.75rem; }
  .jd2-bar[hidden] { display: none; }
  .jd3-bar-text { display: flex; flex-direction: column; flex: 1 1 auto; min-width: 0; line-height: 1.25; }
  .jd3-bar-text strong { font-size: 1rem; color: var(--heading, #111827); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .jd3-bar-text span { font-size: 0.85rem; color: #4b5563; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .jd2-bar .jd2-apply { flex: 0 0 auto; width: auto; padding: 0.8rem 1.4rem; }
}

/* Phones (under 480px wide): the logo and the two menu links stay on one line where they fit.
   Where they do not (Leicestershire needs 374px, Milton Keynes 380px), the menu links stack on
   the right instead of pushing the page sideways. Fixes a fault already on the live v2 pages
   (sideways scroll on narrow phones). The smaller gap is only a minimum; with room to spare the
   header looks as it does now. */
@media (max-width: 479.98px) {
  .jd2-page .site-header-inner { gap: 0.5rem; }
  .jd2-page .logo { flex: 0 0 auto; }
  .jd2-page .top-nav { flex: 0 1 auto; min-width: 0; }
  .jd2-page .top-nav ul { flex-wrap: wrap; justify-content: flex-end; row-gap: 0; }
}
