/* M1 Mobile Density — compact mobile composition
FINAL layer in the cascade manifest (m1-tokens.css), which is why nothing
here needs !important: it already outranks every page module.
This file owns phone geometry. No page module may redefine global sizes,
control heights, gutters or card padding for phones. */
@layer m1-mobile-density {
  /* Collapse reserved validation geometry on phones — was 2.35–5.8em blank per field */
  @media (max-width: 760px) {
    body.m1-app .form-group > .m1-form-status,
    body.m1-app .field > .m1-form-status,
    body.m1-app .location-field > .m1-form-status,
    body.m1-app .service-choice-field > .m1-form-status,
    .field__status,
    .field > .field__error,
    .location-field > .field__error {
      min-block-size: 1em;
    }
    body.m1-app .form-group > .m1-form-status:empty,
    body.m1-app .field > .m1-form-status:empty {
      min-block-size: 0;
    }
  }
  /* Page rhythm (gutters, header spacing) is owned by m1-system.css. */
  @media (max-width: 360px) {
    .page-shell {
      width: min(100% - var(--m1-mobile-page-gutter-narrow)*2, var(--m1-content));
    }
  }
  /* Shared form stack — single primitive */
  .m1-field {
    display: grid;
    gap: var(--m1-mobile-label-gap);
    min-width: 0;
  }
  /* Shared form primitives — one compact rhythm for every form on a phone */
  @media (max-width: 760px) {
    .form-stack {
      gap: var(--m1-mobile-field-gap);
    }
    .form-row {
      gap: var(--m1-mobile-field-gap);
    }
    .form-group {
      gap: var(--m1-mobile-label-gap);
      margin-bottom: 0;
    }
  }

  /* Controls — 16px text on phones, 44px height, compact where appropriate */
  @media (max-width: 760px) {
    body.m1-app input,
    body.m1-app select,
    body.m1-app textarea,
    body.m1-app .form-input,
    body.m1-app .form-select,
    body.m1-app .form-textarea,
    body.m1-app .m1-datetime-trigger {
      min-height: var(--m1-mobile-control-height);
      font-size: 16px;
      padding: 10px 12px;
      border-radius: var(--m1-mobile-radius-control);
    }
    body.m1-app textarea,
    body.m1-app .form-textarea {
      min-height: 84px;
    }
    .button,
    body.m1-app .btn {
      min-height: var(--m1-mobile-button-height);
      padding: 10px 16px;
      border-radius: var(--m1-mobile-radius-control);
    }
    .button--small,
    .btn-sm {
      min-height: var(--m1-mobile-button-height-compact);
    }
    .icon-button {
      width: var(--m1-mobile-icon-target);
      height: var(--m1-mobile-icon-target);
    }
  }
  /* Cards — compact padding, no desktop minima on mobile */
  @media (max-width: 760px) {
    .card,
    .trip-card,
    .surface__header,
    .surface__body,
    .detail-shell .trip-hero > header,
    .detail-shell .detail-section,
    .next-trip {
      padding: var(--m1-mobile-card-padding);
    }
    .trip-card {
      padding: var(--m1-mobile-card-padding-compact);
    }
    /* Remove luxe minima that inflate mobile */
    .booking-shell--luxury,
    .booking-concierge {
      min-height: 0;
    }
    .booking-concierge__visual {
      margin-top: 18px;
    }
  }
  @media (max-width: 430px) {
    .card {
      padding: var(--m1-mobile-card-padding-compact);
    }
  }
  /* Reservation density — reusable primitives + overrides for legacy markup */
  @media (max-width: 760px) {
    .detail-shell {
      padding-block: var(--m1-mobile-section-gap) 28px;
    }
    .detail-header {
      gap: 10px;
      margin-bottom: 12px;
      flex-direction: row;
      align-items: center;
    }
    .detail-header .status-badge {
      margin-left: auto;
    }
    /* Legacy status-statement -> compact banner */
    .status-statement {
      padding: 12px 14px;
      margin-bottom: var(--m1-mobile-card-gap);
      gap: 10px;
    }
    .status-statement > div {
      gap: 10px;
    }
    /* Trip hero — compact schedule */
    .trip-hero {
      padding: var(--m1-mobile-card-padding);
    }
    .trip-hero > header {
      padding: 0;
      margin-bottom: 12px;
      flex-direction: row;
      align-items: flex-end;
      justify-content: space-between;
      gap: 10px;
    }
    .detail-route {
      /* Narrow the marker gutter on a phone; never remove it. The component
         derives the markers and the connector from this token, so the
         timeline stays inside its card at every width. */
      --m1-route-gutter: 2.1rem;
      gap: 10px;
      padding-block: 12px;
      padding-inline-end: 0;
    }
    .detail-route > div {
      gap: 6px;
    }
    .trip-notes {
      gap: 8px;
      padding: 10px 0 0;
    }
    /* Detail sections */
    .detail-section {
      padding: var(--m1-mobile-card-padding);
      margin-bottom: var(--m1-mobile-card-gap);
    }
    .detail-section header {
      margin-bottom: 10px;
    }
    /* Compact status banner instead of large card */
    /* Schedule compact */
    /* Ride-details grid — also override legacy .detail-data (dl) to become grid */
    .detail-data {
      display: grid;
      gap: 8px 14px;
      grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    }
    .detail-data > div {
      display: grid;
      gap: 2px;
      padding: 6px 0;
      border: 0;
    }
    .detail-data dd {
      font-weight: 600;
      margin: 0;
    }
    @media (max-width: 360px) {
      .detail-data {
        grid-template-columns: 1fr 1fr;
      }
    }
    @media (max-width: 320px) {
      .detail-data {
        grid-template-columns: 1fr;
      }
    }
  }
  /* Contact — tighten */
  @media (max-width: 760px) {
    .contact-layout {
      gap: var(--m1-mobile-card-gap);
    }
    .contact-layout .surface__header {
      padding: var(--m1-mobile-card-padding);
    }
    .contact-layout .surface__body {
      padding: var(--m1-mobile-card-padding);
      gap: var(--m1-mobile-field-gap);
    }
    .field-grid {
      gap: var(--m1-mobile-field-gap);
    }
    .field {
      gap: var(--m1-mobile-label-gap);
    }
  }
  /* Guest manage — help sections denser */
  @media (max-width: 760px) {
    .guest-help {
      padding: var(--m1-mobile-card-padding);
      gap: 12px;
      margin-bottom: var(--m1-mobile-card-gap);
    }
    .guest-help {
      display: grid;
      gap: 12px;
    }
    .guest-help > div:last-child {
      display: grid;
      grid-template-columns: repeat(2, minmax(0, 1fr));
      gap: 8px;
    }
    .guest-help .button {
      min-height: var(--m1-mobile-button-height-compact);
      padding-inline: .5rem;
    }
    .linked-trip {
      padding: var(--m1-mobile-card-padding-compact);
      gap: 10px;
    }
  }
  /* Ensure no horizontal overflow at 320 */
  html {
    min-width: 320px;
  }
  body {
    overflow-x: hidden;
  }
  /* Content images scale; a brand lockup is a fixed-height asset the shell
     sizes, so it opts out by class rather than by this layer reaching into
     the header and footer. */
  img:not(.m1-logo-asset),
  video {
    max-width: 100%;
    height: auto;
  }
  /* Desktop unmodified — density only below 700px */

  /* Typeable date/time field: the picker button sits inside the 44px text
     box, so the phone control sizing above must not pad or resize it. */
  @media (max-width: 760px) {
    body.m1-app .m1-datetime-field--typeable .m1-datetime-trigger {
      min-height: 0;
      padding: 0;
      border-radius: 0 var(--m1-mobile-radius-control) var(--m1-mobile-radius-control) 0;
    }
  }

  /* ------------------------------------------------------------------ *
   * 2026-11-09 mobile UAT (docs/mobile/MOBILE_UAT_REPORT.md)
   * ------------------------------------------------------------------ */
  /* Live-update wrappers must not change layout. */
  .m1-live-block { display: contents; }

  /* Busy state for any submitted POST form (m1-live.js). */
  .button.is-busy, button.is-busy { cursor: progress; opacity: .78; pointer-events: none; }
  .button.is-busy::after, button.is-busy::after {
    content: "";
    width: 1em;
    height: 1em;
    margin-inline-start: .5em;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    display: inline-block;
    vertical-align: -.15em;
    animation: m1-spin .7s linear infinite;
  }
  @keyframes m1-spin { to { transform: rotate(360deg); } }
  @media (prefers-reduced-motion: reduce) { .button.is-busy::after, button.is-busy::after { animation: none; } }

  @media (max-width: 760px) {
    /* Touch targets >= 44px for navigation links that were 20-26px tall. */
    .m1-previous-site__link,
    .saved-passenger a[href] {
      display: inline-flex;
      align-items: center;
      min-height: 44px;
    }
    /* Heading rows wrap instead of pushing the page sideways at 320px. */
    .m1-worklist-heading { flex-wrap: wrap; row-gap: 2px; }
    .m1-worklist-heading__aside { white-space: normal; display: inline-flex; align-items: center; min-height: 44px; }

    /* Readable text: nothing under 12px in lists and detail pages. */
    .new-marker,
    .reservation-item__reference,
    .reservation-item__identity,
    .reservation-item__people,
    .trip-hero__zone,
    .detail-data dt,
    .detail-route small,
    .sidebar-section dt,
    .m1-worklist__reference,
    .status-index span,
    .reservation-item__return span,
    .pagination span,
    .trip-notes span {
      font-size: 12px;
    }

    /* Booking wizard type scale on phones: labels, hints and step numbers
       were 8-11px (desktop luxury scale shrunk down). */
    /* Label/hint/step sizes are type roles in m1-system.css. */
    .booking-shell--luxury .booking-progress ol { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .booking-shell--luxury .booking-progress li { gap: .35rem; }

    .booking-shell--luxury .m1-select__chevron { font-size: 14px; }

    /* Booking wizard on a phone: first field above the fold, sticky CTA. */
    .booking-shell--luxury .booking-concierge { display: none; }
    .booking-shell--luxury .booking-context-copy { padding-block: .6rem; }
    /* The sticky step footer is the page's one action surface: m1-system.css. */
  }
  @media (max-width: 360px) {
    .booking-shell--luxury .booking-progress li > span { display: none; }
  }
}
