/* ==========================================================================
   Listing page header card - PHONE ONLY: the contact info sits BELOW the logo row
   ==========================================================================
   Owner handoff "IP - Handoff: Listing Page, Phone Only - Contact Info Below the Logo" (2026-11-22; build board "P - Phone (390)"; docs/IP-Reference.md
   section DC, registry row L43). Loaded by the listing page alone (web/listing-detail.blade.php), after web.css, so no other page can be touched.

   WHAT IT DOES. The header card (.company-preamble) is one flex row in web.css: the logo on the left and, on the right, ONE column holding the name with its
   status circles, the category, the address, the service areas and the phone / e-mail / website pills. Under 700px (the header's own phone breakpoint, the
   --breakpoint-tablet token) that is rebuilt as two rows, with the same markup:
     row 1 - the logo on the left; on the right the name (with its status circles, same wrapping) and the category - sizes and gaps as they were;
     row 2 - the contact block, the full width of the page content, starting 16px under the taller of the logo and the name + category, with the address
             row, the service areas row (and its "Show all (N)" button) and the pills row in the order they always had.
   Above 700px nothing in this file applies: the card is exactly what web.css and ip-listing-card.css make it.

   HOW. The right-hand wrapper (.company-preamble-content) stops being a box (display: contents), so its children - the name row, the category, the three
   contact rows - become the grid's own items and can be placed without a second copy of the markup, a second set of links or a different reading and tab
   order (the same device the contact card uses, contact-widget.css). The logo spans the first three rows; the third row has no content, it only takes up
   what the logo is taller than the name + category, so the category never moves down when the logo is tall. The contact rows go in full-width rows below.

   WHAT IT KEEPS. Every row style of the contact block - the icon column, the text size, the outlined pills, the service areas' two-line clamp - is
   unchanged, and so are the spaces between the rows. Grid items' margins do not collapse the way the block flow's did, so the one place where two margins used to
   merge (the address row's 4px and the pills' 8px above them, which made 8px) is written out below as the 4px that gives the same 8px. A listing with
   nothing in row 2 (no address, no service areas, no pills) keeps the card exactly as it was: nothing is rendered for the block, no 16px is left behind, and
   the logo's and the category's own bottom spaces stay.
   Tokens only. */

@media (max-width: 699px) {

  /* ---- The two rows ---------------------------------------------------- */
  #company .company-page-info .company-preamble {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);   /* the logo and its 10px, then everything else */
    grid-template-rows: auto auto 1fr;            /* the name row, the category row, and what the logo is taller than both */
    align-items: start;
  }
  #company .company-page-info .company-preamble .company-preamble-content {
    display: contents;
  }

  /* Row 1: the logo spans the three rows; its 24px under it (web.css) is the space the card had below the logo - now the 16px under row 1 is the
     contact block's own margin, so the two do not add up. */
  #company .company-page-info .company-preamble .company-thumbnail {
    grid-column: 1;
    grid-row: 1 / span 3;
    margin-bottom: 0;
  }
  #company .company-page-info .company-preamble .listing-title-row {
    grid-column: 2;
    grid-row: 1;
  }
  #company .company-page-info .company-preamble .listing-main-category {
    grid-column: 2;
    grid-row: 2;
  }
  /* The category's 12px under it (web.css) was the space down to the first contact row; with a contact block the 16px below replaces it. */
  #company .company-page-info .company-preamble .listing-main-category:not(:last-child) {
    margin-bottom: 0;
  }

  /* ---- Row 2: the contact block, the full width, 16px under row 1 ---------- */
  #company .company-page-info .company-preamble .company_address,
  #company .company-page-info .company-preamble .company_service_area,
  #company .company-page-info .company-preamble .contact-pills {
    grid-column: 1 / -1;
  }
  /* Whichever of the three comes first is the one 16px under row 1 (the category is always printed, so it is always the element before it). */
  #company .company-page-info .company-preamble .listing-main-category + .company_address,
  #company .company-page-info .company-preamble .listing-main-category + .company_service_area,
  #company .company-page-info .company-preamble .listing-main-category + .contact-pills {
    margin-top: var(--space-4, 16px);
  }
  /* The address row's 4px under it and this 4px are the 8px the pills had above them while the two margins collapsed (ip-listing-card.css). */
  #company .company-page-info .company-preamble .company_address + .contact-pills {
    margin-top: var(--space-1, 4px);
  }

  /* ---- Nothing to show in row 2 ------------------------------------------- */
  /* No address, no service areas, no pills: the card keeps the 24px under its logo exactly as before. (:has() is a progressive enhancement, as in
     plan-tiles.css: in a browser without it only this one rare case is 24px tighter.) The category keeps its own 12px through :not(:last-child) above. */
  #company .company-page-info .company-preamble:not(:has(.company_address, .company_service_area, .contact-pills)) .company-thumbnail {
    margin-bottom: var(--space-5, 24px);
  }
}
