/* Frameless desktop ISS viewer — floats directly above the looping homepage video.
   Keep the original mobile homepage untouched. */
@media (min-width: 901px) {
  body.home-page .home-main section.hero {
    /* Wider right-hand canvas while keeping the text in its own column. */
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.12fr);
    align-items: center;
    gap: clamp(18px, 2.5vw, 42px);
    position: relative;
  }

  body.home-page .home-main section.hero > .hero-content {
    grid-column: 1;
    grid-row: 1;
    min-width: 0;
    align-self: center;
  }

  body.home-page .home-main section.hero > .home-iss-showcase {
    grid-column: 2;
    grid-row: 1;
    align-self: center;
    justify-self: stretch;
    min-width: 0;
  }

  body.home-page .home-iss-showcase {
    width: 100%;
    max-width: none;
    overflow: visible;
    position: relative;
    z-index: 2;
    background: transparent !important;
    border: 0 !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
  }

  body.home-page .home-iss-stage {
    position: relative;
    width: 100%;
    /* Increase the actual WebGL viewport, not just CSS overflow: the
       model-viewer canvas clips rendered geometry to its own dimensions. */
    height: clamp(460px, 45vw, 640px);
    margin: 0;
    padding: 0;
    overflow: visible;
    background: transparent !important;
    border: 0 !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
  }

  body.home-page .home-iss-stage model-viewer {
    display: block;
    position: relative;
    width: 100% !important;
    height: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    background: transparent !important;
    border: 0 !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    outline: none;
    overflow: visible !important;
    --poster-color: transparent;
    touch-action: pan-y;
  }

  /* Suppress the standard viewer loading bar; the GLB itself stays interactive. */
  body.home-page .home-iss-stage model-viewer::part(default-progress-bar),
  body.home-page .home-iss-stage model-viewer::part(progress-bar) {
    display: none !important;
  }

  /* Defensive fallback for older cached shared scripts injecting model extras. */
  body.home-page #toggleBtn,
  body.home-page .toggle-btn,
  body.home-page #albaModelPlayer,
  body.home-page .home-iss-showcase .model-loading-overlay {
    display: none !important;
  }

  body.home-page #textContent {
    display: block !important;
    -webkit-line-clamp: unset !important;
    overflow: visible !important;
  }

  body.home-page .home-iss-stage .viewer-wrapper {
    width: 100% !important;
    height: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    background: transparent !important;
    border: 0 !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    overflow: visible !important;
  }

  /* Arabic remains RTL for text, but the model occupies the right grid column. */
  html[dir="rtl"] body.home-page .home-main section.hero {
    direction: ltr;
  }
  html[dir="rtl"] body.home-page .home-main section.hero > .hero-content {
    direction: rtl;
    text-align: right;
  }
}

@media (max-width: 900px) {
  body.home-page .home-iss-showcase {
    display: none !important;
  }
}


/* Standard-style AR action anchored in the bottom-left of the ISS viewer.
   On AR-capable devices the native model-viewer slot is used; otherwise
   the visible desktop button hands the ISS off to a phone via QR code. */
body.home-page .home-iss-stage .home-iss-ar-button {
  display: inline-flex;
  gap: 9px;
  align-items: center;
  justify-content: center;
  position: absolute;
  bottom: 22px;
  left: 20px;
  z-index: 8;
  min-height: 43px;
  padding: 9px 17px;
  border: 1px solid rgba(162, 231, 253, .9);
  border-radius: 999px;
  background: rgba(249, 253, 255, .96);
  color: #122b42;
  font: 700 13px/1.2 system-ui, -apple-system, "Segoe UI", sans-serif;
  white-space: nowrap;
  cursor: pointer;
  box-shadow: 0 5px 20px rgba(0, 0, 0, .24), 0 1px 2px rgba(255, 255, 255, .2) inset;
  transition: transform .2s ease, box-shadow .2s ease;
}
body.home-page .home-iss-stage .home-iss-ar-button:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(0, 0, 0, .36);
}
body.home-page .home-iss-stage .home-iss-ar-button:focus-visible {
  outline: 3px solid #64daff;
  outline-offset: 3px;
}
body.home-page .home-iss-stage .home-iss-ar-button[hidden] {
  display: none !important;
}
body.home-page .home-iss-stage .home-iss-ar-symbol {
  display: inline-grid;
  place-items: center;
  width: 22px;
  height: 22px;
  flex: 0 0 22px;
  border: 1.5px solid currentColor;
  border-radius: 5px;
  font-size: 17px;
  line-height: 1;
}

/* Phone handoff dialog is an accessible native <dialog>, outside the viewer. */
dialog.home-iss-ar-dialog {
  position: fixed;
  inset: 0;
  margin: auto;
  width: min(92vw, 450px);
  max-height: min(90vh, 740px);
  padding: 0;
  border: 1px solid rgba(130, 217, 254, .6);
  border-radius: 22px;
  background: linear-gradient(155deg, #0a2338, #061326 70%);
  color: #f4fbff;
  box-shadow: 0 30px 100px rgba(0,0,0,.75);
  overflow: auto;
  z-index: 20000;
}
dialog.home-iss-ar-dialog::backdrop {
  background: rgba(0, 5, 17, .78);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}
.home-iss-ar-dialog-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  padding: 27px 25px 25px;
  text-align: center;
}
.home-iss-ar-dialog-content h2 {
  margin: 0;
  font: 750 clamp(20px, 3vw, 25px)/1.3 system-ui, sans-serif;
  color: #f7fdff;
}
.home-iss-ar-dialog-content p {
  margin: 0;
  font: 14px/1.6 system-ui, sans-serif;
  color: #c0dceb;
}
.home-iss-ar-qr {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 224px;
  height: 224px;
  padding: 12px;
  border-radius: 14px;
  background: #fff;
  color: #10253a;
  font: 12px/1.4 system-ui, sans-serif;
}
.home-iss-ar-qr img,
.home-iss-ar-qr canvas {
  display: block;
  max-width: 200px;
  max-height: 200px;
}
.home-iss-ar-page-link {
  display: inline-flex;
  min-height: 40px;
  align-items: center;
  justify-content: center;
  color: #89e5ff;
  font: 700 14px/1.3 system-ui, sans-serif;
  text-decoration: underline;
  text-underline-offset: 4px;
}
.home-iss-ar-close {
  padding: 10px 22px;
  min-height: 39px;
  border: 1px solid rgba(130, 210, 243, .4);
  border-radius: 999px;
  background: rgba(75, 139, 178, .17);
  color: #fff;
  cursor: pointer;
  font: 650 13px/1.3 system-ui, sans-serif;
}
.home-iss-ar-close:hover { background: rgba(75, 139, 178, .3); }
@media (prefers-reduced-motion: reduce) {
  body.home-page .home-iss-stage .home-iss-ar-button { transition: none; }
}

/* Atlas poster + blue progress bar: desktop hero only. */
@media (min-width: 901px) {
 body.home-page .home-iss-stage .home-model-loading {
   position:absolute;inset:0;z-index:5;display:flex;flex-direction:column;
   align-items:center;justify-content:center;gap:10px;overflow:hidden;
   background:rgba(1,9,26,.84);opacity:1;pointer-events:none;
   transition:opacity .35s ease;
 }
 body.home-page .home-iss-stage .home-model-loading.is-complete {opacity:0;visibility:hidden}
 body.home-page .home-iss-stage .home-model-progress {
   position:absolute;top:0;left:0;right:0;height:5px;
   background:rgba(35,160,225,.23);box-shadow:0 0 16px #0982b3;
 }
 body.home-page .home-iss-stage .home-model-progress-fill {
   width:0;height:100%;background:linear-gradient(90deg,#009bde,#00eaff);
   box-shadow:0 0 16px #00dafa;transition:width .16s ease;
 }
 body.home-page .home-iss-stage .home-model-preview {
   display:block;width:min(95%,680px);height:min(76%,490px);
   object-fit:contain;flex:0 1 auto;
 }
 body.home-page .home-iss-stage .home-model-loading-label {
   margin:0;text-align:center;color:#c7f4ff;
   font:700 16px/1.35 system-ui,sans-serif;text-shadow:0 2px 8px #001321;
 }
 body.home-page .home-iss-stage .home-model-loading-name {color:#92bcd5;font:600 13px/1.3 system-ui,sans-serif}
 body.home-page .home-iss-stage .home-model-error-link {
   padding:8px 13px;border:1px solid #00c3ff;border-radius:20px;
   color:#fff;background:#07446a;text-decoration:none;
   font:650 13px system-ui,sans-serif;
 }
 body.home-page .home-iss-stage .home-model-error-link[hidden] {display:none!important}
 body.home-page .home-iss-stage .home-model-loading.is-error {pointer-events:auto}
 body.home-page .home-iss-stage .home-model-loading.is-error .home-model-progress-fill {background:#ff6877}
}
@media (prefers-reduced-motion: reduce) {
 body.home-page .home-iss-stage .home-model-loading,
 body.home-page .home-iss-stage .home-model-progress-fill {transition:none}
}
