/* V4.1: geometry and interaction refinement — no changes to V3 scene controllers. */
.site-header,.site-header.solid,.site-header.light,.site-header.solid.light{
 height:84px!important;min-height:84px!important;max-height:84px!important;
 padding:7px clamp(12px,1.4vw,24px)!important;box-sizing:border-box!important;
 border-radius:var(--brand-radius)!important;
}
.v4-header{height:100%;min-height:0;gap:clamp(8px,1.6vw,18px)}
.v4-header-brand{height:100%;gap:clamp(10px,1.5vw,16px)}
.v4-brand{height:100%;width:clamp(50px,5.4vw,75px);min-width:50px}
.v4-brand-divider{height:60%;background:var(--brand-border);opacity:.75}
.v4-icon{display:block!important;width:20px;height:20px;aspect-ratio:1/1;flex-shrink:0;overflow:visible;object-fit:contain}
.v4-node-icon,.v4-card-icon{display:grid;place-items:center;flex:0 0 auto;aspect-ratio:1;min-width:20px;min-height:20px}
.v4-node-icon .v4-icon,.v4-card-icon .v4-icon{width:20px;height:20px;aspect-ratio:1}
/* One consistent rail axis, with the Ricerca branch extending sideways, never downward. */
.v4-desktop-rail{height:68px!important;min-height:0;gap:0!important;align-items:stretch}
.v4-desktop-rail::before{top:51px;left:calc(100% / 15);right:calc(100% / 15);height:1px;background:var(--brand-border);z-index:0}
.v4-nav-node{flex:1 1 0;padding:2px 2px 19px!important;gap:1px;min-width:0;transform:none!important}
.v4-node-icon{height:21px}
.v4-node-label{font-size:clamp(10px,.78vw,12px);line-height:1.13;text-wrap:balance;min-height:14px;display:flex;justify-content:center;align-items:center}
.v4-node-dot{top:45px!important;width:11px;height:11px;left:50%;transform:translateX(-50%);z-index:2}
.v4-nav-node.is-current .v4-node-dot,.v4-nav-node.is-parent-active .v4-node-dot{top:43px!important;width:15px;height:15px;box-shadow:0 0 0 5px color-mix(in srgb,var(--brand-primary) 18%,transparent)}
.v4-research-group{
 display:grid!important;grid-template-columns:minmax(0,1fr) minmax(0,0fr) minmax(0,0fr);
 flex:1 1 0;min-width:0;height:100%;background:none!important;outline:none!important;border:0!important;
 transition:grid-template-columns .82s cubic-bezier(.2,.8,.18,1), flex-grow .82s cubic-bezier(.2,.8,.18,1)!important;
}
.v4-research-group>.v4-nav-node{width:100%;min-width:0;overflow:hidden}
.v4-research-group>.v4-child{
 display:flex!important;opacity:0!important;visibility:hidden;pointer-events:none;
 transition:opacity .25s ease 0s,visibility 0s linear .3s!important;
}
.v4-desktop.v4-research-open .v4-research-group{
 flex-grow:3.05;grid-template-columns:repeat(3,minmax(0,1fr));
}
.v4-desktop.v4-research-open .v4-research-group>.v4-child{
 opacity:1!important;visibility:visible;pointer-events:auto;
 transition:opacity .4s ease .25s,visibility 0s linear 0s!important;
}
/* A subtle branched stroke, rather than a bright orange capsule. */
.v4-research-group::before{
 content:''!important;inset:auto!important;position:absolute;
 left:17%;width:66%;top:49px;height:13px;
 border-top:1px dashed var(--brand-primary);
 border-bottom:1px solid color-mix(in srgb,var(--brand-primary) 44%,transparent);
 border-left:1px solid var(--brand-primary);border-right:1px solid color-mix(in srgb,var(--brand-primary) 35%,transparent);
 border-radius:0 0 18px 18px;background:var(--brand-plum)!important;opacity:0;
 transform:scaleX(.2) translateY(-2px);transform-origin:left center;
 transition:transform .75s cubic-bezier(.2,.8,.18,1),opacity .35s ease!important;pointer-events:none;z-index:0;
}
.v4-desktop.v4-research-open .v4-research-group::before{opacity:.85;transform:scaleX(1) translateY(0)}
.v4-research-group::after{display:none!important}
.v4-desktop.v4-research-open .v4-research-group .v4-nav-node:not(.v4-child)::after{display:none!important}
.v4-desktop.v4-research-open .v4-research-group>.v4-child .v4-node-icon{opacity:.54;pointer-events:none}
.v4-desktop.v4-research-open .v4-research-group>.v4-child .v4-node-label{font-size:clamp(9px,.74vw,11px)}
.v4-nav-node:focus-visible,.v4-perspective-card:focus-visible{outline:2px solid var(--brand-primary);outline-offset:2px}
@media(max-width:900px){
 .site-header,.site-header.solid,.site-header.light,.site-header.solid.light{
  height:84px!important;min-height:84px!important;max-height:84px!important;
  padding:8px clamp(8px,2vw,12px)!important;top:max(10px,env(safe-area-inset-top))!important;
  border-radius:calc(var(--brand-radius) * .72)!important;
 }
 .v4-mobile{height:100%!important;gap:clamp(5px,1.4vw,10px)}
 .v4-header-brand{gap:clamp(5px,1.3vw,9px)}
 .v4-brand{min-width:0;width:clamp(34px,10vw,54px)!important;height:100%!important}
 .v4-brand-divider{height:60%!important}
 .v4-mobile-carousel{height:100%;align-items:center;gap:clamp(3px,.9vw,6px);perspective:600px}
 .v4-perspective-card{height:56px;min-height:0!important;max-height:56px;max-width:100%;aspect-ratio:auto;overflow:hidden;padding:3px 2px!important;gap:2px;border-radius:calc(var(--brand-radius) * .4);backface-visibility:hidden}
 .v4-card-icon,.v4-node-icon{min-height:0;min-width:0}
 .v4-card-icon .v4-icon{width:clamp(15px,4vw,21px);height:clamp(15px,4vw,21px)}
 .v4-current .v4-card-icon .v4-icon{width:clamp(18px,4.5vw,23px);height:clamp(18px,4.5vw,23px)}
 .v4-current{transform:translate3d(calc(var(--v4-shift,0) * -5%),0,14px) scale(1.015)!important}
 .v4-previous{transform:translateX(calc(var(--v4-shift,0) * -5%)) rotateY(-17deg) scale(.94)!important}
 .v4-next{transform:translateX(calc(var(--v4-shift,0) * -5%)) rotateY(17deg) scale(.94)!important}
 /* Solid-bottom dock creates a safe, dedicated strip instead of translucent floating chips. */
 #v4-mobile-dock{
  left:var(--page-margin);right:var(--page-margin);
  bottom:calc(max(9px,env(safe-area-inset-bottom)) + var(--hud-inset,0px));
  box-sizing:border-box;padding:9px clamp(7px,2.2vw,14px);
  min-height:64px;border:var(--brand-border-width) solid var(--brand-border);
  border-radius:calc(var(--brand-radius) * .65);
  background:var(--brand-plum)!important;
  box-shadow:0 -7px 25px color-mix(in srgb,var(--brand-ink) 38%,transparent);
  backdrop-filter:none!important;-webkit-backdrop-filter:none!important;
  grid-template-columns:minmax(44px,.75fr) minmax(65px,1.5fr) minmax(96px,1fr);
  gap:clamp(4px,1.5vw,10px);
 }
 #v4-mobile-dock :is(.v4-dock-menu,.v4-dock-chat,.v4-dock-scroll),
 #v4-mobile-dock #skip-animation{background:var(--brand-plum)!important;backdrop-filter:none!important;-webkit-backdrop-filter:none!important}
 #v4-mobile-dock .v4-dock-actions{gap:clamp(4px,1.3vw,10px)}
 #v4-mobile-dock :is(.v4-dock-menu,.v4-dock-chat,.v4-dock-scroll){width:42px!important;min-width:42px!important;height:42px!important}
 #v4-mobile-dock #earth-autoplay-control,#v4-mobile-dock #hold-animation{max-height:44px!important;min-height:42px!important;height:44px!important}
 #v4-mobile-dock .v4-dock-chat .v4-icon{width:22px!important;height:22px!important;aspect-ratio:1;min-width:22px}
 :root{--v41-dock-reserved:calc(82px + env(safe-area-inset-bottom))}
 /* Keep main panels visually above the dock without altering scroll distances. */
 #citta,#arredi,#palazzo-butera{--panel-bottom:max(82px,var(--v41-dock-reserved))!important}
 #mondo .journey-note.project-note{top:calc(max(10px,env(safe-area-inset-top)) + 84px + 18px)!important;max-height:calc(100dvh - 84px - 18px - var(--v41-dock-reserved))!important}
}
@media(max-width:375px){
 .v4-card-label{font-size:9px!important}.v4-current .v4-card-label{font-size:10px!important}
 #v4-mobile-dock{grid-template-columns:45px minmax(56px,1fr) 94px;padding-inline:6px;gap:4px}
 #v4-mobile-dock :is(.v4-dock-menu,.v4-dock-chat,.v4-dock-scroll){width:40px!important;min-width:40px!important;height:40px!important}
}
@media(prefers-reduced-motion:reduce){.v4-research-group,.v4-research-group::before,.v4-research-group>.v4-child{transition:none!important}}
/* The same lightbox is reused for plans and each source carousel. */
.portfolio-lightbox .lightbox-canvas{position:relative;overflow:hidden!important;touch-action:none!important;overscroll-behavior:contain;cursor:zoom-in;user-select:none;-webkit-user-select:none}
.portfolio-lightbox .lightbox-canvas.is-pannable{cursor:grab}
.portfolio-lightbox .lightbox-canvas.is-pannable:active{cursor:grabbing}
.portfolio-lightbox .lightbox-canvas img,.portfolio-lightbox.is-zoomed .lightbox-canvas img{
 display:block!important;position:absolute!important;inset:0!important;
 width:100%!important;height:100%!important;max-width:none!important;max-height:none!important;min-width:0!important;min-height:0!important;
 object-fit:contain!important;object-position:center!important;pointer-events:none;
 transform:translate3d(var(--lightbox-x,0px),var(--lightbox-y,0px),0) scale(var(--lightbox-scale,1))!important;
 transform-origin:50% 50%!important;will-change:transform;
}
.portfolio-lightbox footer{height:38px;min-height:38px;justify-content:center;padding:0 55px;position:relative}
.portfolio-lightbox footer span{max-width:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:clamp(11px,1.8vw,14px)}
.portfolio-lightbox footer [data-step]{position:absolute;top:calc(-1*(100dvh - 24px - 50px)/2);z-index:4;min-width:44px;min-height:44px;border-radius:50%;background:var(--brand-plum);color:var(--brand-white);border-color:var(--brand-border);font-size:23px;touch-action:manipulation}
.portfolio-lightbox footer [data-step='-1']{left:0}
.portfolio-lightbox footer [data-step='1']{right:0}
.portfolio-lightbox footer [data-step]:disabled{opacity:.25;cursor:default}
@media(max-width:900px){.portfolio-lightbox footer [data-step]{top:calc(-1*(100dvh - 24px - 50px)/2);font-size:25px}}
