/* Use the visible mobile viewport as the browser controls show and hide. */
@media(max-width:700px), (pointer:coarse) and (max-width:1000px){
  #atlas .sticky{height:100dvh}
  #siteOpening{min-height:100dvh}
  html[data-theme=light] body{background:#eeefe5}

  #collection #stage,
  #collection #stage:has(#pack:not([hidden])),
  #collection #stage.unsealing{height:min(65dvh,495px)}
  #collection #cards,
  #collection #stage.dealt #cards{
    --mobile-card-width:min(78cqw,250px,calc((100cqh - 34px) * .6667));
    display:flex;flex-wrap:nowrap;justify-content:flex-start;align-items:center;
    padding-inline:max(8px,calc((100cqw - var(--mobile-card-width)) / 2));
    gap:14px;scrollbar-width:none;
  }
  #collection #cards .card{
    width:var(--mobile-card-width);max-width:none;flex:0 0 var(--mobile-card-width);
    scroll-snap-align:center;
  }
  #collection #stage.dealt #cards{
    overflow-x:auto;overflow-y:hidden;overscroll-behavior-inline:contain;
    scroll-snap-type:x mandatory;touch-action:pan-x pinch-zoom;
  }
  #collection #stage.dealt #cards::-webkit-scrollbar{display:none}
}

/* A contained scroll keeps the document and its browser toolbar out of the gesture. */
@media(hover:none) and (pointer:coarse){
  html,body{height:100%;overflow:hidden;overscroll-behavior:none}
  #track{
    position:fixed;inset:0;box-sizing:border-box;
    height:100dvh;overflow-x:hidden;overflow-y:auto;
    overscroll-behavior:none;scrollbar-width:none;
    background:var(--latam-charcoal,#262626);
  }
  #track::-webkit-scrollbar{display:none}
  body.inside #track{overflow-y:hidden}
  html[data-theme=light] #track{background:#eeefe5}
  #atlas{height:760dvh}
  #atlas .sticky{height:100dvh}
  #mapScene{min-height:100dvh}
  #mapScene .mapLogo{bottom:var(--map-logo-bottom)}
  #atlasGuide{bottom:calc(var(--map-logo-bottom) + var(--map-logo-height) + var(--map-logo-gap))}
}

/* Touch layout: map on top, readable destination sheet below, actions in reach. */
html[data-mobile-layout] #projectOpen{
  top:max(11px,env(safe-area-inset-top));right:14px;
}
html[data-mobile-layout] #mapScene #board{inset:0;touch-action:pinch-zoom}
html[data-mobile-layout] #mapScene #home,
html[data-mobile-layout] #collection #back{display:none}
html[data-mobile-layout] #atlasGuide{
  top:auto;left:12px;right:12px;bottom:calc(65px + env(safe-area-inset-bottom));
  width:auto;max-height:34dvh;display:block;overflow:auto;
  padding:12px 15px;border:1px solid var(--latam-line);border-radius:16px;
  background:#262626e8;overscroll-behavior:contain;
}
html[data-mobile-layout] #atlasGuide[hidden]{display:none}
html[data-mobile-layout] #atlasGuide .atlasReading{overflow:visible;padding:0}
html[data-mobile-layout] #atlasGuide .atlasTerritory{font-size:clamp(21px,5.5vw,31px);max-width:none}
html[data-mobile-layout] #atlasGuide .atlasTitleWindow{margin-bottom:4px;padding:0}
html[data-mobile-layout] #mapScene .mapLogo{top:10px;bottom:auto;left:9px;height:43px}
html[data-mobile-layout][data-theme=light] #atlasGuide{background:#f9faf3f3}
html[data-mobile-layout] #mobileNav{
  position:fixed;z-index:100;bottom:max(13px,env(safe-area-inset-bottom));left:13px;right:68px;
  display:flex;align-items:center;justify-content:space-between;gap:9px;pointer-events:none;
}
html[data-mobile-layout] #mobileNav[hidden],
html[data-mobile-layout] #mobileMapSteps[hidden],
html[data-mobile-layout] body:has(dialog[open]) #mobileNav{display:none}
#mobileNav button{
  min-width:44px;min-height:44px;padding:0 12px;border-radius:99px;pointer-events:auto;
  border:1px solid var(--latam-line);background:var(--latam-surface);color:var(--latam-mist);
  font:600 13px Poppins,sans-serif;
}
#mobileMapSteps{display:flex;gap:5px}
#mobileMapSteps button{font-size:26px;line-height:1}
html[data-theme=light] #mobileNav button{
  background:var(--day-paper);color:var(--day-ink);border-color:var(--day-edge);
}
html[data-mobile-layout] #detail[open]{
  grid-template-columns:minmax(0,1fr);padding:17px 16px 30px;
  width:min(94vw,520px);max-height:89dvh;
}
html[data-mobile-layout] #detail #close{right:10px;top:9px}
html[data-mobile-layout] #detail #large .card:not(.cardFlight){width:min(66vw,255px)}
html[data-mobile-layout] #detail .mediaPane .youtubePlayer{width:100%}
html[data-mobile-layout] #project .projectCloseBar{
  justify-content:flex-start;padding:10px 14px;
}
@media(max-height:450px){
  html[data-mobile-layout] #atlasGuide{max-height:30dvh;width:min(45%,280px);right:auto}
}

/* The touch action belongs to the destination sheet; cartography stays clear. */
html[data-mobile-layout] #call,
html[data-mobile-layout] #route{visibility:hidden;pointer-events:none}
html[data-mobile-layout] #atlasGuide:has(#mobileOpenDestination:not([hidden])){
  border-color:var(--latam-sage);
}
html[data-mobile-layout][data-theme=light] #atlasGuide:has(#mobileOpenDestination:not([hidden])){
  border-color:var(--day-olive);
}
html[data-mobile-layout] .atlasTitleWindow:has(#mobileOpenDestination:not([hidden])){
  min-height:44px;padding-inline-end:44px;
}
#mobileOpenDestination{
  position:absolute;inset:0;display:flex;justify-content:flex-end;align-items:center;
  padding:0 3px;border:0;background:transparent;color:inherit;text-align:right;
}
#mobileOpenDestination[hidden]{display:none}
#mobileOpenDestination span{
  display:grid;place-items:center;width:33px;height:33px;border-radius:50%;
  background:var(--latam-sage);color:var(--latam-charcoal);font-size:19px;
}
html[data-theme=light] #mobileOpenDestination span{background:var(--day-green);color:var(--day-olive)}
#mobileOpenDestination:focus-visible{outline:2px solid var(--latam-sage);outline-offset:-2px}

/* Reserve full-card space, with the neighbors outside the resting frame. */
html[data-mobile-layout] #collection #cards,
html[data-mobile-layout] #collection #stage.dealt #cards{
  --mobile-gutter:max(8px,calc((100cqw - var(--mobile-card-width)) / 2));
  gap:calc(var(--mobile-gutter) + 6px);
  padding-inline:var(--mobile-gutter);
}
html[data-mobile-layout] #collection #stage.dealt #cards .card{
  scroll-snap-stop:always;scroll-margin:0;
}

/* Compact sheet and a single horizontal row of controls. */
html[data-mobile-layout] #atlasGuide{
  left:14px;right:14px;bottom:calc(64px + env(safe-area-inset-bottom));
  max-height:42dvh;padding:12px 15px 11px;
  border-radius:13px;border-color:#a0ac8957;
  background:#262b24f2;box-shadow:0 6px 22px #14181362;
}
html[data-mobile-layout] #atlasGuide:has(#mobileOpenDestination:not([hidden])){border-color:#a0ac897e}
html[data-mobile-layout] #atlasGuide .atlasRegion{
  font-size:11px;line-height:1.25;letter-spacing:.02em;margin:0 0 3px;
}
html[data-mobile-layout] #atlasGuide .atlasTitleWindow{min-height:37px;margin:0 0 2px;padding-block:0}
html[data-mobile-layout] #atlasGuide .atlasTerritory{font-size:clamp(23px,6.2vw,32px);line-height:1.08}
html[data-mobile-layout] #atlasGuide button#mobileOpenDestination{
  position:absolute;inset:0;display:flex;justify-content:flex-end;align-items:center;
  min-height:0;width:100%;padding:0;border:0;border-radius:5px;background:none;box-shadow:none;
}
html[data-mobile-layout] #atlasGuide button#mobileOpenDestination[hidden]{display:none}
#mobileOpenDestination span{width:30px;height:30px;font-size:16px}
html[data-mobile-layout] #atlasGuide #mobilePlaceInfo{
  display:inline-flex;align-items:center;justify-content:flex-start;gap:6px;
  min-height:34px;padding:0;border:0;border-radius:0;
  background:none;color:var(--latam-sage);box-shadow:none;font-size:11px;
}
#mobilePlaceInfo[aria-expanded=true] span{transform:rotate(180deg)}
#atlasPlaceDetails[hidden]{display:none}
html[data-mobile-layout] #atlasPlaceDetails{
  padding-top:8px;border-top:1px solid var(--latam-line);
}
html[data-mobile-layout] #atlasPlaceDetails .atlasPlaceStory{font-size:13px;line-height:1.48}
html[data-mobile-layout] #atlasPlaceDetails .atlasThumb{width:75px}
html[data-mobile-layout][data-theme=light] #atlasGuide #mobilePlaceInfo{color:var(--day-olive)}
html[data-mobile-layout] #mobileNav{
  right:68px;left:14px;bottom:max(10px,env(safe-area-inset-bottom));
}
html[data-mobile-layout] #mobileNav button{
  min-width:42px;min-height:42px;border-radius:11px;background:#262b24f5;
}
html[data-mobile-layout] #mobileMapSteps{gap:5px}
html[data-mobile-layout] #mobileMapSteps button{font-size:23px}
html[data-mobile-layout] body > .themeSwitchGlobal{
  right:14px;bottom:max(10px,env(safe-area-inset-bottom));width:42px;height:42px;border-radius:11px;
}
html[data-mobile-layout][data-theme=light] #mobileNav button{background:var(--day-paper)}

/* Two cards identify the collection action without an external-link arrow. */
html[data-mobile-layout] #mobileOpenDestination span{
  width:36px;height:36px;border-radius:10px;
  box-shadow:0 2px 9px #14181335;
}
#mobileOpenDestination svg{width:24px;height:24px;display:block;pointer-events:none}
html[data-mobile-layout] .atlasTitleWindow:has(#mobileOpenDestination:not([hidden])){padding-inline-end:49px}

html[data-mobile-layout] #desktopDestinations{display:none}
html[data-mobile-layout] #mobileNav{gap:5px}
html[data-mobile-layout] #mobileNav #mobileDestinations{padding-inline:8px;font-size:11px}
html[data-mobile-layout] #mobileNav #mobileBack{padding-inline:8px;font-size:12px}
html[data-mobile-layout] #mobileMapSteps{gap:3px}
html[data-mobile-layout] #mobileMapSteps button:not(#mobileDestinations){min-width:36px;padding-inline:4px}

/* The centered card stays complete while its neighbors invite a swipe. */
html[data-mobile-layout] #collection{padding-inline:clamp(12px,4vw,22px)}
html[data-mobile-layout] #collection #cards,
html[data-mobile-layout] #collection #stage.dealt #cards{
  --mobile-card-width:min(75cqw,245px,calc((100cqh - 34px) * .6667));
  gap:clamp(10px,3cqw,14px);
}

/* Keep native touch feedback from painting or selecting button content. */
html[data-mobile-layout] :is(button,summary,[role=button]){
  -webkit-tap-highlight-color:transparent;
  -webkit-user-select:none;
  user-select:none;
}
html[data-mobile-layout] :is(button,summary,[role=button]):focus-visible{
  outline:2px solid currentColor;outline-offset:3px;
}
