/* Review candidate: gallery cards keep a readable ratio in short landscape windows. */
@media (orientation: landscape) and (max-width: 1100px) {
  #lsr .ls-app[data-design=atelier] #reference .reference-projects {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: start;
  }
  #lsr .ls-app[data-design=atelier] #reference .reference-photo {
    height: auto;
    max-height: none;
    aspect-ratio: 4 / 3;
  }
  #lsr .ls-app[data-design=atelier] #reference .reference-photo img {
    width: 100%;
    height: 100%;
    max-height: none;
    aspect-ratio: 4 / 3;
    object-fit: cover;
  }
}

/* Approved viewer enhancement; load after the existing viewer styles. */
#lsr :is(#lukas-photo-viewer,#ls-stories-photoview)[data-touch-viewer][open]{display:grid;position:fixed;inset:0;width:100%;height:100vh;height:100dvh;max-width:none;max-height:none;margin:0;padding:max(8px,env(safe-area-inset-top)) max(8px,env(safe-area-inset-right)) max(8px,env(safe-area-inset-bottom)) max(8px,env(safe-area-inset-left));gap:8px;border-radius:0;grid-template-rows:auto minmax(0,1fr);overflow:hidden;overscroll-behavior:none}
#lsr :is(#lukas-photo-viewer,#ls-stories-photoview)[data-touch-viewer] .lukas-photo-toolbar{display:flex;align-items:center;justify-content:space-between;flex-wrap:wrap;gap:6px 12px;min-width:0;min-height:44px;margin:0;padding:0;background:#000;color:#fff}
#lsr :is(#lukas-photo-viewer,#ls-stories-photoview)[data-touch-viewer] .lukas-photo-toolbar [data-photo-counter]{font:400 13px/1.3 Arial,Helvetica,sans-serif;margin:0;white-space:nowrap}
#lsr :is(#lukas-photo-viewer,#ls-stories-photoview)[data-touch-viewer] .lukas-photo-toolbar button{box-sizing:border-box;min-height:44px;padding:8px 12px;border:1px solid #ffffff70;border-radius:6px;background:#161b19;color:#fff;font:600 14px/1.2 Arial,Helvetica,sans-serif;white-space:nowrap;cursor:pointer}
#lsr :is(#lukas-photo-viewer,#ls-stories-photoview)[data-touch-viewer] .lukas-photo-toolbar button:disabled{opacity:.4;cursor:default}
#lsr :is(#lukas-photo-viewer,#ls-stories-photoview)[data-touch-viewer] .lukas-photo-toolbar button:focus-visible{outline:3px solid #fff;outline-offset:2px}
#lsr :is(#lukas-photo-viewer,#ls-stories-photoview)[data-touch-viewer] .lv-zoom-controls{display:flex;align-items:center;justify-content:center;gap:5px;flex:0 0 auto}
#lsr :is(#lukas-photo-viewer,#ls-stories-photoview)[data-touch-viewer] .lv-zoom-controls button:first-child,#lsr :is(#lukas-photo-viewer,#ls-stories-photoview)[data-touch-viewer] .lv-zoom-controls button:nth-of-type(2){width:44px;padding:4px;font-size:24px}
#lsr :is(#lukas-photo-viewer,#ls-stories-photoview)[data-touch-viewer] .lv-zoom-controls output{min-width:48px;text-align:center;color:#fff;font:400 13px/1.2 Arial,Helvetica,sans-serif;white-space:nowrap}
#lsr :is(#lukas-photo-viewer,#ls-stories-photoview)[data-touch-viewer] .lukas-photo-stage{display:block;width:100%;height:100%;min-width:0;min-height:0;overflow:hidden;touch-action:auto;overscroll-behavior:none}
#lsr :is(#lukas-photo-viewer,#ls-stories-photoview)[data-touch-viewer] figure{display:grid;grid-template-rows:minmax(0,1fr) auto;width:100%;height:100%;min-width:0;min-height:0;margin:0;overflow:hidden}
#lsr :is(#lukas-photo-viewer,#ls-stories-photoview)[data-touch-viewer] .lv-image-plane{position:relative;width:100%;height:100%;min-width:0;min-height:0;overflow:hidden;touch-action:manipulation;overscroll-behavior:none;user-select:none;-webkit-user-select:none}
#lsr :is(#lukas-photo-viewer,#ls-stories-photoview)[data-touch-pointer="true"] .lv-image-plane{touch-action:none}
#lsr :is(#lukas-photo-viewer,#ls-stories-photoview)[data-touch-viewer] .lv-image-plane img{display:block;position:absolute;left:0;top:0;min-width:0;min-height:0;max-width:none;max-height:none;margin:0;border-radius:0;aspect-ratio:auto;object-fit:contain;transform-origin:0 0;visibility:hidden;-webkit-user-drag:none;user-select:none;-webkit-user-select:none;will-change:transform}
#lsr :is(#lukas-photo-viewer,#ls-stories-photoview)[data-touch-viewer] .lv-image-plane.is-zoomed{cursor:grab}
#lsr :is(#lukas-photo-viewer,#ls-stories-photoview)[data-touch-viewer] .lv-image-plane.is-dragging{cursor:grabbing}
#lsr :is(#lukas-photo-viewer,#ls-stories-photoview)[data-touch-viewer] :is(figcaption,.lv-image-caption){max-height:54px;min-width:0;overflow-y:auto;padding:7px 54px 0;margin:0;color:#fff;text-align:center;font:400 13px/1.35 Arial,Helvetica,sans-serif;overflow-wrap:anywhere}
#lsr :is(#lukas-photo-viewer,#ls-stories-photoview)[data-touch-viewer] .lukas-photo-arrow{position:absolute;left:4px;right:auto;top:calc(50% - 24px);display:flex;align-items:center;justify-content:center;width:48px;height:48px;min-height:48px;padding:0;transform:none;z-index:2}
#lsr :is(#lukas-photo-viewer,#ls-stories-photoview)[data-touch-viewer] [data-photo-next]{left:auto;right:4px}
#lsr :is(#lukas-photo-viewer,#ls-stories-photoview)[data-touch-viewer] .lukas-photo-arrow[hidden]{display:none}
@media(max-width:560px){
 #lsr :is(#lukas-photo-viewer,#ls-stories-photoview)[data-touch-viewer] .lv-zoom-controls{order:3;flex-basis:100%}
 #lsr :is(#lukas-photo-viewer,#ls-stories-photoview)[data-touch-viewer] [data-photo-close]{margin-left:auto}
 #lsr :is(#lukas-photo-viewer,#ls-stories-photoview)[data-touch-viewer] :is(figcaption,.lv-image-caption){font-size:12px;max-height:48px}
}
@media(orientation:landscape) and (max-height:600px){
 #lsr :is(#lukas-photo-viewer,#ls-stories-photoview)[data-touch-viewer][open]{gap:4px;padding:4px max(8px,env(safe-area-inset-right)) 4px max(8px,env(safe-area-inset-left))}
 #lsr :is(#lukas-photo-viewer,#ls-stories-photoview)[data-touch-viewer] .lukas-photo-toolbar{gap:4px 8px}
 #lsr :is(#lukas-photo-viewer,#ls-stories-photoview)[data-touch-viewer] .lukas-photo-toolbar button{padding:6px 9px}
 #lsr :is(#lukas-photo-viewer,#ls-stories-photoview)[data-touch-viewer] :is(figcaption,.lv-image-caption){max-height:36px;padding-top:4px;font-size:12px}
}

/* Keep phone/tablet navigation compact in both orientations. Loaded last. */
@media (max-width: 1100px), (hover: none) and (pointer: coarse) and (max-height: 700px) {
  #lsr { --ls-header-offset: 0px; }
  body.admin-bar #lsr { --ls-header-offset: 32px; }
  #lsr .ls-app[data-design=atelier] .utility { display: none; }
  #lsr .ls-app[data-design=atelier] .header,
  #lsr .ls-app[data-design=atelier] .header.is-scrolled,
  body.admin-bar #lsr .ls-app[data-design=atelier] .header,
  body.admin-bar #lsr .ls-app[data-design=atelier] .header.is-scrolled {
    position: sticky;
    top: var(--ls-header-offset, 0px);
    margin: 0;
    transform: none;
    transition: none;
  }
  #lsr .ls-app[data-design=atelier] .header .header-inner {
    position: relative;
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    justify-content: space-between;
    grid-template: none;
    gap: 8px;
    height: 56px;
    min-height: 56px;
    padding-block: 4px;
    box-sizing: border-box;
  }
  #lsr .ls-app[data-design=atelier] .header .header-inner .brand {
    flex: 1 1 auto;
    width: auto;
    min-width: 0;
    max-width: calc(100% - 84px);
    margin: 0;
    gap: 8px;
  }
  #lsr .ls-app[data-design=atelier] .header .header-inner .brand > img {
    flex: 0 0 auto;
    width: 26px;
    height: 36px;
    object-fit: contain;
  }
  #lsr .ls-app[data-design=atelier] .header .header-inner .brand > span {
    min-width: 0;
    font-size: clamp(11px, 3.4vw, 16px);
  }
  #lsr .ls-app[data-design=atelier] .header .header-inner .brand-wordmark {
    width: 13.782em;
    max-width: 100%;
    height: auto;
  }
  #lsr .ls-app[data-design=atelier] .header .header-inner :is(.header-inquiry, .header-call, .header-phone) {
    display: none;
  }
  #lsr .ls-app[data-design=atelier].has-js .header .header-inner .menu-toggle {
    display: inline-flex;
    position: static;
    flex: 0 0 auto;
    align-items: center;
    justify-content: center;
    gap: 6px;
    width: auto;
    min-width: 44px;
    min-height: 44px;
    height: 44px;
    margin: 0;
    padding: 8px;
    box-sizing: border-box;
    border: 1px solid #bcd4cc;
    border-radius: 8px;
    background: #fff;
    color: #005f4e;
    font-size: 13px;
  }
  #lsr .ls-app[data-design=atelier].has-js .header .header-inner nav,
  #lsr .ls-app[data-design=atelier].has-js .header .header-inner nav.open {
    display: none;
    position: absolute;
    inset: 100% 0 auto;
    width: 100%;
    min-width: 0;
    max-height: calc(100vh - 56px - var(--ls-header-offset, 0px));
    max-height: calc(100dvh - 56px - var(--ls-header-offset, 0px));
    margin: 0;
    padding: 8px;
    box-sizing: border-box;
    grid-template-columns: minmax(0, 1fr);
    gap: 4px;
    overflow-y: auto;
    overscroll-behavior: contain;
    border: 1px solid #dce8e3;
    border-radius: 0 0 10px 10px;
    background: #fff;
    box-shadow: 0 8px 20px #0f2b2420;
    z-index: 61;
  }
  #lsr .ls-app[data-design=atelier].has-js .header .header-inner nav.open {
    display: grid;
  }
  #lsr .ls-app[data-design=atelier].has-js .header .header-inner nav a {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    min-width: 0;
    min-height: 44px;
    margin: 0;
    padding: 9px 12px;
    box-sizing: border-box;
    font-size: 16px;
    line-height: 1.4;
    text-align: left;
    white-space: normal;
  }
  #lsr .ls-app[data-design=atelier]:not(.has-js) .header .header-inner {
    height: auto;
    flex-wrap: wrap;
  }
  #lsr .ls-app[data-design=atelier]:not(.has-js) .header .header-inner .menu-toggle {
    display: none;
  }
  #lsr .ls-app[data-design=atelier]:not(.has-js) .header .header-inner nav {
    display: grid;
    position: static;
    flex: 1 0 100%;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
    max-height: none;
    margin: 0;
    padding: 8px 0;
    gap: 4px 12px;
  }

}
@media (max-width: 782px) {
  body.admin-bar #lsr { --ls-header-offset: 46px; }
}
@media (max-width: 600px) {
  body.admin-bar #lsr { --ls-header-offset: 0px; }
}
@media (orientation: landscape) and (max-width: 1100px),
       (orientation: landscape) and (hover: none) and (pointer: coarse) and (max-height: 700px) {
  #lsr .ls-app[data-design=atelier].has-js .header .header-inner nav.open {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* Short landscape screens must not reduce content photos to viewport-height strips. */
@media (orientation: landscape) and (max-width: 1100px),
       (orientation: landscape) and (hover: none) and (pointer: coarse) {
  #lsr .ls-app[data-design=atelier] .detail-section.ls-compact-service-photos .service-detail :is(.montazni-main-photo, .equipment-reference-photo) {
    width: 330px;
    max-width: 100%;
    height: auto;
    max-height: none;
    aspect-ratio: auto;
  }
  #lsr .ls-app[data-design=atelier] .detail-section.ls-compact-service-photos .service-detail :is(.montazni-main-photo, .equipment-reference-photo) > img {
    display: block;
    width: 100%;
    max-width: 100%;
    height: auto;
    max-height: none;
    aspect-ratio: auto;
    object-fit: contain;
  }
  #lsr .ls-stories-dialog .ls-stories-photos {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: start;
    gap: 20px;
  }
  #lsr .ls-stories-dialog .ls-stories-photo img {
    display: block;
    width: 100%;
    height: auto;
    max-height: none;
    aspect-ratio: 4 / 3;
    object-fit: contain;
    object-position: center;
  }
}
