/* TAAM mobile stabilization | 2026-10-24
   Overrides desktop layout ONLY at tablet/phone widths.
   Maintains original Cloudflare image paths, galleries and desktop site. */
@media screen and (max-width: 1024px) {
  html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
  body { max-width: 100%; overflow-x: clip; }
  body, main, .section, .shell, .site-footer { min-width: 0; }
  img, svg, video, picture { max-width: 100%; }
  img { height: auto; }
  .shell, .split, .section-heading, .project, .project-copy,
  .specialist-grid, .location-photo-grid, .ratawi-pair,
  .qhse-grid, .certificate-grid, .contact-links { min-width: 0; }
  .contact-links, .contact-links a, .contact-links strong,
  .project-copy, .location-heading, .facility-subchapter,
  .site-footer, .footer-top { overflow-wrap: anywhere; }
  .photo-dialog, .facility-photo-dialog {
    box-sizing: border-box;
    max-width: calc(100vw - 20px);
    max-height: calc(100dvh - 20px);
  }
  .photo-dialog img, .facility-photo-dialog img {
    display: block; width: 100%; height: auto;
    max-height: 62dvh; object-fit: contain;
  }
}

@media screen and (max-width: 760px), screen and (hover: none) and (pointer: coarse) and (max-width: 1024px) {
  :root { --shell: calc(100% - 32px); }
  *, *::before, *::after { box-sizing: border-box; }
  html { scroll-padding-top: 74px; }
  body { width: 100%; }
  .site-header { width: 100%; }
  .site-header .header-inner { min-height: 65px; }
  .site-header .brand { max-width: 42vw; }
  .site-header .brand img { display: block; width: 100%; height: auto; }
  #main-navigation { max-width: 100vw; }
  h1, h2, h3, h4 { overflow-wrap: break-word; }
  h1 { font-size: clamp(2.3rem, 10.4vw, 3.5rem); line-height: 1.04; }
  h2 { font-size: clamp(1.95rem, 7.1vw, 2.75rem); line-height: 1.11; }
  .section { padding-block: 54px; }
  .section-heading { margin-bottom: 30px; }
  .section-heading > p { font-size: 1rem; line-height: 1.65; }
  .hero { min-height: max(560px, 90svh); }
  .hero-inner { padding-top: 56px; padding-bottom: 34px; }
  .hero-media, .hero-media picture { overflow: hidden; }
  .hero-media img { width: 100%; height: 100%; max-width: none; object-fit: cover; }
  .hero .actions { flex-wrap: wrap; }
  .hero .actions .button { max-width: 100%; }
  .project .media img, .about-grid .media img, .safety-feature img,
  .execution-gallery .photo-open img, .photo-story .photo-open img,
  .specialist-image img, .location-photo img {
    display: block;
    width: 100%;
    height: auto;
    max-height: none;
    aspect-ratio: auto;
    object-fit: contain;
    background: transparent;
  }
  .photo-open { background: transparent; }
  .specialist-image { overflow: hidden; }
  .specialist-image img { max-height: 75svh; }
  .location-photo-grid { grid-template-columns: minmax(0, 1fr); gap: 14px; }
  .location-photo { width: 100%; }
  .location-photo figcaption { padding: 10px 0 16px; }
  .location-nav { gap: 8px; margin: 18px 0 30px; }
  .location-nav a { flex: 1 1 calc(50% - 8px); padding: 11px 10px; min-width: 0; font-size: .86rem; }
  .facility-subchapter { min-width: 0; padding: 18px; }
  .facility-subchapter h4 { font-size: clamp(1.6rem, 6vw, 2rem); }
  .ratawi-pair, .qhse-grid, .certificate-grid, .specialist-grid {
    grid-template-columns: minmax(0, 1fr);
  }
  .certificate-card img { height: auto; max-height: 420px; aspect-ratio: auto; object-fit: contain; }
  #hse .training-stage { aspect-ratio: 3 / 2; width: 100%; }
  #hse .training-stage img { max-width: 100%; object-fit: cover; background: transparent; }
  #hse .training-toolbar { padding: 12px 0; }
  #hse .training-controls button { min-width: 42px; min-height: 42px; flex: 0 0 42px; }
  #hse .training-controls [data-training-toggle] { flex: 0 1 auto; min-width: 68px; }
  #hse .training-thumbnails { -webkit-overflow-scrolling: touch; touch-action: pan-x; }
  .footer-top, .footer-bottom { min-width: 0; }
  .contact-links strong { font-size: clamp(1rem, 4.8vw, 1.3rem); }

  /* Facilities: simple scroll-friendly mobile presentation, no 420vh sticky trap. */
  #facilities .taam-journey {
    height: auto !important;
    min-height: 0 !important;
    margin: 0;
    overflow: visible;
  }
  #facilities .taam-journey-sticky {
    position: relative !important;
    inset: auto !important;
    height: auto !important;
    min-height: min(730px, 100svh) !important;
    padding: 18px 16px 20px;
    display: flex;
    flex-direction: column;
    gap: 0;
    overflow: visible;
    isolation: isolate;
  }
  #facilities .journey-backdrop,
  #facilities .journey-shade {
    inset: 0;
    overflow: hidden;
    pointer-events: none;
  }
  #facilities .journey-bg { width: 100%; height: 100%; object-fit: cover; object-position: center; }
  #facilities .journey-topline {
    position: relative;
    inset: auto !important;
    width: 100%;
    padding: 0 2px;
    font-size: 9px;
    letter-spacing: .08em;
    line-height: 1.5;
  }
  #facilities .journey-panel {
    position: relative !important;
    inset: auto !important;
    flex: 0 0 auto;
    width: 100% !important;
    max-width: 100%;
    min-width: 0;
    margin: 25px 0 32px;
    padding: 16px 18px;
    max-height: none !important;
    overflow: visible !important;
    transform: none !important;
    border-radius: 18px;
    background: #111b25ab;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
  }
  #facilities .journey-panel h2 {
    margin: 0 !important;
    font-size: clamp(23px, 6vw, 31px) !important;
    line-height: 1.13;
    overflow-wrap: break-word;
  }
  #facilities .journey-bottom {
    position: relative !important;
    inset: auto !important;
    width: 100%;
    margin-top: auto;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }
  #facilities .journey-gallery-controls {
    order: 0;
    grid-area: auto;
    justify-self: auto;
    align-self: center;
    max-width: 100%;
    margin: 0;
    gap: 7px;
    padding: 6px 9px;
  }
  #facilities .journey-gallery-controls button {
    width: 44px;
    height: 44px;
    min-height: 44px;
    flex: 0 0 44px;
  }
  #facilities .journey-gallery-controls [data-photo-count] { min-width: 40px; text-align: center; }
  #facilities .journey-step-controls {
    order: 1;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 7px;
    width: 100%;
    min-width: 0;
    align-self: stretch;
  }
  #facilities .journey-step-controls button {
    width: 100%;
    min-width: 0;
    min-height: 46px;
    padding: 9px 7px;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 5px;
    overflow-wrap: normal;
    white-space: normal;
    text-align: center;
    line-height: 1.2;
    font-size: 12px;
    border-radius: 12px;
  }
  #facilities .journey-step-controls button span {
    display: inline;
    margin: 0;
    font-size: 10px;
  }
  #facilities .journey-scroll-hint { display: none; }
  #facilities .journey-mobile-map-toggle {
    order: 2;
    display: inline-flex;
    gap: 9px;
    justify-content: center;
    align-items: center;
    align-self: center;
    min-height: 44px;
    max-width: 100%;
    padding: 10px 18px;
    background: #17242ddd;
    color: white;
    border: 1px solid #ffffffa0;
    border-radius: 999px;
    font: 700 13px/1.3 'Manrope', sans-serif;
    cursor: pointer;
  }
  /* On phones, the map appears only on demand, never over the photos. */
  #facilities .journey-map-card:not(.is-expanded) {
    display: none !important;
  }
  #facilities .journey-map-card.is-expanded {
    display: flex !important;
    position: fixed !important;
    inset: calc(env(safe-area-inset-top, 0px) + 8px)
           calc(env(safe-area-inset-right, 0px) + 8px)
           calc(env(safe-area-inset-bottom, 0px) + 8px)
           calc(env(safe-area-inset-left, 0px) + 8px) !important;
    width: auto !important;
    height: auto !important;
    max-width: none !important;
    max-height: none !important;
    min-height: 0 !important;
    margin: 0 !important;
    padding: 14px !important;
    z-index: 10000 !important;
    gap: 8px;
    background: #162630f7 !important;
    border-radius: 17px;
    transform: none !important;
    overflow: hidden;
  }
  #facilities .journey-map-card.is-expanded .journey-map-heading {
    min-height: 40px; justify-content: space-between;
  }
  #facilities .journey-map-card.is-expanded .journey-map-heading > div { display: block; }
  #facilities .journey-map-card.is-expanded .facility-map-expand {
    width: 44px; height: 44px; min-height: 44px; font-size: 25px;
  }
  #facilities .journey-map-card.is-expanded .facility-map-tools { display: grid; }
  #facilities .journey-map-card.is-expanded .facility-map-search input {
    min-height: 44px; font-size: 16px; width: 100%;
  }
  #facilities .journey-map-card.is-expanded .journey-map {
    display: block; flex: 1 1 auto; min-height: 160px; width: 100%;
    touch-action: none;
  }
  #facilities .journey-map-card.is-expanded .journey-map-bottom {
    flex: 0 0 auto; min-height: 36px; gap: 8px;
  }
  #facilities .journey-map-card.is-expanded .facility-map-numbers button {
    width: 36px; height: 36px; font-size: 13px;
  }
  #facilities .journey-map-card.is-expanded .facility-map-cluster {
    padding: 5px; gap: 3px;
  }
  body.taam-map-open, html.taam-map-open { overflow: hidden !important; }
  body.taam-map-open #facilities { position: relative; z-index: 100000; }
  body.taam-map-open #facilities .taam-journey { isolation: auto; }
  #facilities .journey-following { position: relative; z-index: 0; }
}

@media screen and (min-width: 761px) and (hover: hover) and (pointer: fine) {
  #facilities .journey-mobile-map-toggle { display: none !important; }
}

@media screen and (max-width: 380px) {
  :root { --shell: calc(100% - 24px); }
  #facilities .taam-journey-sticky { padding-inline: 12px; }
  #facilities .journey-panel { padding-inline: 13px; }
  #facilities .journey-step-controls button { font-size: 11px; }
  #facilities .journey-gallery-controls { gap: 5px; }
  #facilities .journey-gallery-controls button { width: 42px; min-height: 42px; height: 42px; flex-basis: 42px; }
}

@media screen and (max-width: 760px) and (orientation: landscape), screen and (hover: none) and (pointer: coarse) and (max-width: 1024px) and (orientation: landscape) {
  #facilities .taam-journey-sticky { min-height: 490px !important; }
  #facilities .journey-panel { margin-block: 12px 16px; }
  #facilities .journey-step-controls { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  #facilities .journey-map-card.is-expanded { padding: 8px !important; }
}


/* Mobile hero/header cleanup | 2026-10-24 h3
   - Footer navigation leak fixed in styles.css (menu selector is header-only).
   - Keep the first screen balanced on compact portrait phones.
   - No changes to desktop, map, galleries, or Cloudflare image references. */
@media screen and (max-width: 600px) {
  #home.hero {
    min-height: 0;
    height: auto;
  }
  #home .hero-inner {
    width: var(--shell);
    max-width: 100%;
    padding-top: clamp(34px, 5.5svh, 52px);
    padding-bottom: 26px;
  }
  #home .hero-inner > .eyebrow {
    display: block;
    margin: 0 0 16px;
    font-size: 12px;
    line-height: 1.5;
    letter-spacing: .085em;
  }
  #home #hero-title {
    max-width: 100%;
    margin: 0;
    font-size: clamp(38px, 10.5vw, 52px);
    line-height: .99;
    letter-spacing: -.015em;
    overflow-wrap: normal;
    word-break: normal;
  }
  #home .hero-inner > .actions {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    width: 100%;
    gap: 11px;
    margin-top: 28px;
  }
  #home .actions .button {
    box-sizing: border-box;
    width: 100%;
    max-width: 100%;
    min-height: 52px;
    padding: 12px 17px;
    gap: 10px;
    justify-content: space-between;
    text-align: left;
    line-height: 1.35;
  }
  #home .hero-scene-control:not([hidden]) {
    display: flex;
    flex-direction: row;
    justify-content: flex-start;
    align-items: center;
    width: 100%;
    margin-top: 18px;
    gap: 0;
  }
  #home .hero-scene-control > div:only-child {
    width: auto;
    max-width: 100%;
    justify-content: flex-start;
    align-items: center;
    gap: 8px;
  }
  #home .hero-scene-control span {
    font-size: 13px;
    line-height: 1.4;
  }
  #home .hero-bottom {
    margin-top: 20px;
    padding-top: 14px;
    width: 100%;
    gap: 8px;
    line-height: 1.5;
  }
}


/* Remove the remaining dead space below Discover TAAM on mobile/rotated iPhones.
   Section height now follows actual content instead of desktop min-height. */
@media screen and (max-width: 760px),
       screen and (hover: none) and (pointer: coarse) and (max-width: 1024px) {
  #home.hero {
    height: auto;
    min-height: 0;
  }
  #home .hero-inner {
    padding-bottom: 26px;
  }
}

/* Longer Facility names: Safari/iPhone layout in two readable columns. */
@media (max-width: 600px) {
  #facilities .journey-step-controls {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
  }
  #facilities .journey-step-controls button {
    min-height: 44px;
    padding: 9px 6px;
    font-size: 11px;
    white-space: normal;
    overflow-wrap: anywhere;
  }
}
