/* Candidate for the consolidated COS TRANS audit package. No data or form logic. */
@media (max-width: 767px) {
  /* Keep route title words intact at ordinary widths. Emergency wrapping is
     retained for extreme zoom, unusually narrow containers or future content. */
  body .ctr-route-wrap .ctr-hero-title,
  body .ct-eu-route .ct-hero-content h1,
  body .ct-landing .ct-hero-content h1,
  body .ct-segment-preview .ct-hero-content h1 {
    min-width: 0;
    max-width: 100%;
    font-size: clamp(18.4px, 6.4vw, 28px) !important;
    line-height: 1.13 !important;
    letter-spacing: 0 !important;
    overflow-wrap: break-word !important;
    word-break: normal !important;
    -webkit-hyphens: none !important;
    hyphens: none !important;
  }

  /* A white surface makes the icon legible both in and below the blue bar. */
  body .ct-lp-head .ct-legacy-menu > summary {
    color: #062d63 !important;
    background: #fff !important;
    border: 1px solid #b9cde0;
    box-sizing: border-box;
  }
  body .ct-lp-head .ct-legacy-menu > summary:focus-visible {
    outline: 3px solid #e20c3a;
    outline-offset: 2px;
  }
  /* First-generation header: a compact call button, with the original phone
     text still inside the link for screen readers and the original tel: URL. */
  body.ct-lp-europe .ct-lp-head a.ct-tel {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    min-height: 44px;
    font-size: 0 !important;
    color: #fff !important;
    background: #062d63;
    border-radius: 4px;
  }
  body.ct-lp-europe .ct-lp-head a.ct-tel::before {
    content: "☎";
    font-size: 22px;
    line-height: 1;
  }

  /* Long labels require real room; preserve the link and arrow on each card. */
  body .ctr-route-wrap .ctr-services-grid {
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 160px), 1fr));
  }
  body .ctr-route-wrap .ctr-services-grid > a {
    min-width: 0;
    overflow-wrap: break-word;
    word-break: normal;
    hyphens: auto;
  }
  body .ct-segment-preview .ct-service { min-width: 0; gap: 8px; }
  body .ct-segment-preview .ct-service h3 {
    min-width: 0;
    flex: 1 1 auto;
    overflow-wrap: break-word;
    word-break: normal;
    hyphens: auto;
  }
  body .ct-segment-preview .ct-service > span { flex: 0 0 auto; }
  body .ct-landing .ct-services-heading { flex-wrap: wrap; gap: 12px; }
  body .ct-landing .ct-services-heading > * { min-width: 0; max-width: 100%; }

  /* Match the other controls without touching the submitted value or script. */
  body .ctr-route-wrap select,
  body .ct-embedded-quote select,
  body .ct-form select {
    box-sizing: border-box;
    min-height: 44px;
    max-width: 100%;
  }

  /* Old theme news headings and sidebar items must grow with wrapped text. */
  body.single-post #subheader h1,
  body.single-service.postid-195 #subheader h1,
  body.archive #subheader h1 {
    max-width: 100%;
    overflow-wrap: break-word;
    word-break: normal;
    hyphens: auto;
    font-size: clamp(22px, 6vw, 30px);
    line-height: 1.2;
  }
  body #sidebar .widget_recent_entries .bloglist-small > li {
    display: flow-root;
    height: auto;
    min-height: 0;
    padding-bottom: 12px;
    margin-bottom: 12px;
  }
  body #sidebar .widget_recent_entries .bloglist-small .txt,
  body #sidebar .widget_recent_entries .bloglist-small h5 {
    height: auto;
    min-height: 0;
    overflow-wrap: break-word;
    word-break: normal;
    hyphens: auto;
  }
  body #sidebar .widget_recent_entries .bloglist-small h5 { line-height: 1.35; }

  /* The original archive uses fixed one-third floated/table-cell cards. */
  body.post-type-archive-service #newslist { height: auto !important; }
  body.post-type-archive-service #newslist > .box-service.one-third {
    display: block;
    float: none;
    width: 100% !important;
    max-width: 100%;
    position: relative !important;
    inset: auto !important;
    transform: none !important;
    overflow: visible;
  }
  body.post-type-archive-service #newslist > .box-service h3,
  body.post-type-archive-service #newslist > .box-service p {
    overflow-wrap: break-word;
    word-break: normal;
    hyphens: auto;
  }
}

/* Local candidate: the original 300x600 raster cuts off its own last line.
   Restrict the caption to that exact legacy widget and image on archive pages. */
body.archive #media_image-2:has(> img.wp-image-631[src*="/2019/04/Banner1.jpg"]) {
  position: relative;
  width: min(300px, 100%);
  display: grid;
  grid-template-areas: "banner";
  grid-template-columns: minmax(0, 1fr);
}
body.archive #media_image-2:has(> img.wp-image-631[src*="/2019/04/Banner1.jpg"]) > img.wp-image-631 {
  display: block;
  width: 100%;
  height: auto;
  grid-area: banner;
}
body.archive #media_image-2:has(> img.wp-image-631[src*="/2019/04/Banner1.jpg"])::before {
  content: "";
  position: static;
  grid-area: banner;
  align-self: end;
  justify-self: start;
  z-index: 1;
  width: 66%;
  height: 13.5%;
  background: #b2001a;
  clip-path: polygon(0 39%, 100% 0, 100% 100%, 0 100%);
  pointer-events: none;
}
body.archive #media_image-2:has(> img.wp-image-631[src*="/2019/04/Banner1.jpg"])::after {
  content: "УЗНАЙ\A БОЛЬШЕ";
  white-space: pre;
  position: static;
  grid-area: banner;
  align-self: end;
  justify-self: start;
  z-index: 2;
  width: 66%;
  height: 10%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font: 700 clamp(12px, 5vw, 20px)/1.05 Arial, sans-serif;
  text-align: center;
  pointer-events: none;
}

/* Local candidate: preserve the original route heading text and capitalization.
   Scoped to the Route Matrix hero; forms and other page templates are untouched. */
body .ctr-route-wrap h1.ctr-hero-title {
  text-transform: none;
}

/* Candidate only. Scoped to captions inserted by this component. */
.ctr-managed-route .ctr-hero-art > .ct-hero-caption-added {
  position: absolute;
  z-index: 2;
  top: 32px;
  right: 32px;
  max-width: calc(100% - 64px);
  box-sizing: border-box;
  padding: 7px 10px;
  border-radius: 3px;
  background: #062d63;
  text-align: right;
  color: #fff;
  font: 700 20px/1.25 Arial, Helvetica, sans-serif;
  overflow-wrap: break-word;
}
@media (max-width: 520px) {
  .ctr-managed-route .ctr-hero-art > .ct-hero-caption-added {
    top: 16px;
    right: 16px;
    max-width: calc(100% - 32px);
    font-size: 16px;
  }
}

/* Only the two standalone Russia → Moldova translations with a fixed header.
   Preserve the existing mobile rule (112px plus the WP admin-bar height). */
@media (min-width: 768px) {
  body:is(.page-id-1205,.page-id-1206).ct-lp section.ct-calculator#cost-calculator {
    scroll-margin-top: calc(88px + var(--wp-admin--admin-bar--height, 0px));
  }
}

/* Separate the existing map CTA from the theme's fixed 32px back-to-top
   control. The selector is intentionally limited to the managed route CTA. */
@media (min-width: 641px) {
  body.ctr-managed-route main.ctr-route-wrap > section.ctr-why > a.ctr-map-link {
    margin-inline-end: 64px;
  }
}
@media (max-width: 640px) {
  body.ctr-managed-route main.ctr-route-wrap > section.ctr-why > a.ctr-map-link {
    max-width: calc(100% - 64px);
    white-space: normal;
    text-align: center;
  }
}

/* Suppress automatic hyphenation in route headings on phones. Very long words
   may still wrap as an overflow safeguard; natural hyphens remain usable. */
@media (max-width: 991px) {
  body .ctr-route-wrap .ctr-transport-grid {
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 360px), 1fr)) !important;
  }
  body .ctr-route-wrap .ctr-transport-card {
    flex-wrap: wrap;
  }
  body .ctr-route-wrap .ctr-transport-card > div:not(.ctr-transport-icon) {
    min-width: 0;
    flex: 1 1 240px;
  }
  body .ctr-route-wrap :is(h2, h3) {
    word-break: normal !important;
    overflow-wrap: anywhere !important;
    -webkit-hyphens: none !important;
    hyphens: none !important;
  }
}
@media (max-width: 800px) {
  body .ct-eu-route :is(h2, h3) {
    word-break: normal !important;
    overflow-wrap: anywhere !important;
    -webkit-hyphens: none !important;
    hyphens: none !important;
  }
}

/* First-generation routes: give service labels room on small phones and
   avoid discretionary hyphens in service and FAQ headings. */
@media (max-width: 640px) {
  body .ct-eu-route .ct-services-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}
@media (max-width: 767px) {
  body .ct-eu-route .ct-service h3,
  body .ct-eu-route .ct-faq .ct-heading h2 {
    min-width: 0;
    max-width: 100%;
    word-break: normal !important;
    overflow-wrap: break-word !important;
    -webkit-hyphens: none !important;
    hyphens: none !important;
  }
}
/* Keep long ordinary words intact in the 273px first-generation heading. */
@media (max-width: 360px) {
  body .ct-eu-route .ct-heading h2 {
    font-size: 23px !important;
  }
}

/* Preserve the full Hungarian country name within the quote panel. */
@media (max-width: 360px) {
  body:is(.page-id-1479, .page-id-1910, .page-id-1914) .ctr-route-wrap .ctr-quote-copy h2 {
    font-size: 26px !important;
  }
}

/* Keep German route-intro words within the measured phone-width column. */
@media (max-width: 360px) {
  html:lang(de) body.ctr-managed-route .ctr-route-wrap .ctr-intro .ctr-standard-inner > h2 {
    font-size: 26px !important;
  }
}

/* Scoped repairs for continuously written words wider than phone columns. */
@media (max-width: 520px) {
  html:lang(nl) body.ctr-managed-route .ctr-route-wrap :is(.ctr-intro .ctr-standard-inner > h2, .ctr-standard-transport > h2) {
    font-size: 22px !important;
  }
  body:is(.page-id-1425, .page-id-1428) .ctr-route-wrap .ctr-quote-copy > h2 {
    font-size: 22px !important;
    margin-inline-end: -8px;
  }
  body:is(.page-id-1425, .page-id-1428) .ctr-route-wrap .ctr-route-final > h2 {
    font-size: 22px !important;
  }
  body:is(.page-id-1479, .page-id-1910, .page-id-1914) .ctr-route-wrap .ctr-quote-copy h2 {
    font-size: 26px !important;
  }
  html:lang(de) body.ctr-managed-route .ctr-route-wrap .ctr-intro .ctr-standard-inner > h2 {
    font-size: 26px !important;
  }
  body.page-id-1351 .ct-eu-route .ct-heading > div > h2 {
    font-size: 20px !important;
    letter-spacing: -.02em;
  }
}

/* Avoid covering content on phones; keep the existing link in the footer flow. */
@media (max-width: 800px) {
  body:is(.ct-lp, .ctr-managed-route) > #back-to-top {
    position: static !important;
    display: block !important;
    width: 44px !important;
    height: 44px !important;
    line-height: 42px !important;
    margin: 12px 16px 12px auto;
    background: #b20e30 !important;
    opacity: 1 !important;
    visibility: visible !important;
    pointer-events: auto !important;
    transition: none !important;
  }
  body:is(.ct-lp, .ctr-managed-route) > #back-to-top:focus-visible {
    outline: 3px solid #062d63;
    outline-offset: 3px;
  }
  body:is(.ct-lp, .ctr-managed-route) > #back-to-top::before {
    color: #fff !important;
  }
}

/* Local candidate: place the existing menu inside the seven-page header grid. */
@media (max-width: 767px) {
  body:is(.page-id-1157,.page-id-1205,.page-id-1206,.page-id-1315,.page-id-1317,.page-id-1319) .ct-lp-head .ct-in {
    grid-template-columns: minmax(0,1fr) 44px auto;
  }
  body:is(.page-id-1157,.page-id-1205,.page-id-1206,.page-id-1315,.page-id-1317,.page-id-1319) .ct-lp-head .ct-legacy-menu {
    grid-column: 2;
    grid-row: 1;
    min-width: 0;
    width: 44px;
  }
  body:is(.page-id-1157,.page-id-1205,.page-id-1206,.page-id-1315,.page-id-1317,.page-id-1319) .ct-lp-head .ct-legacy-menu > summary {
    width: 44px;
  }
  body:is(.page-id-1157,.page-id-1205,.page-id-1206,.page-id-1315,.page-id-1317,.page-id-1319) .ct-lp-head a.ct-btn {
    grid-column: 3;
  }
  body:is(.page-id-1157,.page-id-1205,.page-id-1206,.page-id-1315,.page-id-1317,.page-id-1319) .ct-lp-head .ct-lang {
    grid-column: 1 / -1;
  }
  body:is(.page-id-1157,.page-id-1205,.page-id-1206,.page-id-1315,.page-id-1317,.page-id-1319) .ct-lp-head .ct-legacy-menu nav {
    top: calc(var(--wp-admin--admin-bar--height, 0px) + 88px);
    max-height: calc(100vh - var(--wp-admin--admin-bar--height, 0px) - 104px);
  }
}

/* Restore only the route-specific footer where the legacy rule hides it. */
body.ct-lp:is(.page-id-1157, .page-id-1205, .page-id-1206) #wrapper > footer.ct-lp-foot {
  display: block !important;
}


/* Local candidate: managed route header under the WordPress mobile admin bar. */
@media (max-width: 600px) {
  body.admin-bar.ctr-managed-route .ctr-route-shell:has(> .ctr-standard-header) {
    padding-top: 46px;
  }
}

@media (max-width: 520px) {
  /* Give the long fleet headings the card's full content width. */
  body:is(.page-id-1338, .page-id-1351, .page-id-1359) .ct-eu-route .ct-fleet-card {
    grid-template-columns: minmax(0, 1fr);
    align-items: start;
  }

  /* Keep full-size statistics readable instead of splitting words. */
  body:is(.page-id-1351, .page-id-1359, .page-id-1336, .page-id-1344) .ct-eu-route .ct-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  /* Keep both the services title and its link within the available width. */
  body:is(.page-id-1157, .page-id-1205, .page-id-1206, .page-id-1315, .page-id-1317, .page-id-1319) .ct-services-heading {
    flex-wrap: wrap;
    gap: 12px;
  }
  body:is(.page-id-1157, .page-id-1205, .page-id-1206, .page-id-1315, .page-id-1317, .page-id-1319) .ct-services-heading h2 {
    flex: 0 1 100%;
    min-width: 0;
  }
}

/* These cargo cards become two columns above 520 px and need the same
   full-width text treatment until the columns are wide enough at 768 px. */
@media (max-width: 767px) {
  body.ctr-managed-route:is(.page-id-1467, .page-id-1488, .page-id-1466) .ctr-cargo-list li {
    flex-direction: column;
  }
}

/* The 521–600 px two-column cards still cannot fit the longest word. */
@media (max-width: 600px) {
  body.ctr-managed-route:is(.page-id-1467, .page-id-1488, .page-id-1466) .ctr-cargo-list {
    grid-template-columns: minmax(0, 1fr);
  }
}



/* Local research only: keep all administrator toolbar items in normal rows. */
@media (min-width: 783px) {
  body.admin-bar.ctr-managed-route.ct-adminbar-layout-active #wpadminbar {
    height: auto;
  }
  body.admin-bar.ctr-managed-route.ct-adminbar-layout-active #wp-toolbar {
    display: flex;
    flex-wrap: wrap;
  }
  body.admin-bar.ctr-managed-route.ct-adminbar-layout-active #wp-toolbar > ul {
    display: flex;
    flex-wrap: wrap;
    max-width: 100%;
  }
  body.admin-bar.ctr-managed-route.ct-adminbar-layout-active #wp-admin-bar-root-default {
    flex: 1 1 auto;
    min-width: 0;
  }
  body.admin-bar.ctr-managed-route.ct-adminbar-layout-active #wp-admin-bar-top-secondary {
    flex: 0 1 auto;
    margin-left: auto;
  }
  /* WordPress's equal z-index rows otherwise cover an open submenu. */
  body.admin-bar.ctr-managed-route.ct-adminbar-layout-active #wp-toolbar > ul:has(> li.hover) {
    z-index: 100001;
  }
  body.admin-bar.ctr-managed-route.ct-adminbar-layout-active #wp-toolbar > ul > li.hover {
    z-index: 100001;
  }
  body.admin-bar.ctr-managed-route.ct-adminbar-layout-active .ctr-route-shell:has(> .ctr-standard-header) {
    padding-top: var(--ct-admin-toolbar-padding, 0px);
  }
  body.admin-bar.ctr-managed-route.ct-adminbar-layout-active .ctr-route-shell > .ctr-standard-header {
    top: var(--ct-admin-toolbar-height, var(--wp-admin--admin-bar--height, 32px));
  }
}



/* Local candidate: theme clips WordPress's open submenu on managed routes. */
@media (min-width:783px) {
  body.admin-bar.ctr-managed-route.ct-adminbar-layout-active #wpadminbar #wp-toolbar > ul > li.menupop.hover {
    overflow: visible !important;
  }
}



@media (max-width: 600px) {
  body.page-id-1205 .ct-services-heading,
  body.page-id-1206 .ct-services-heading,
  body.page-id-1317 .ct-services-heading,
  body.page-id-1319 .ct-services-heading { flex-wrap: wrap; gap: 12px; }
  body.page-id-1205 .ct-services-heading h2,
  body.page-id-1206 .ct-services-heading h2,
  body.page-id-1317 .ct-services-heading h2,
  body.page-id-1319 .ct-services-heading h2 { min-width: 0; }
}

