/*
 * Whale Fall V101 — measured HUD lanes.
 * Loaded after the V98/V99 cinematic artwork. Layout only: all realm art,
 * orbital data, 5FRE preview permissions, native details, and inspector state
 * remain in their respective owners.
 */
:root{
  --wf-hud-heaven-top:72px;
  --wf-hud-heaven-open-top:72px;
  --wf-hud-heaven-max-height:560px;
  --wf-hud-inspector-right-top:196px;
  --wf-hud-inspector-left-top:205px;
  --wf-hud-hell-bottom:12px;
  --wf-hud-hell-max-height:520px;
}

/* A real navigation lane beats all realm artwork while its menu is open. */
body[data-wf-hud-menu="open"] header,
body[data-wf-hud-menu="open"]:has(#world.active) header{
  z-index:155!important;
}
body[data-wf-hud-menu="open"] .nav-more-menu{
  position:absolute;
  z-index:165;
  max-height:min(70dvh,540px);
  overflow-y:auto;
  overscroll-behavior:contain;
  scrollbar-width:thin;
  min-width:min(240px,calc(100vw - 24px));
  border-color:rgba(171,194,212,.3);
  box-shadow:0 20px 64px rgba(0,0,0,.74);
}
body[data-wf-hud-menu="open"] #wfPortableRealmPreview .wf-realm-card,
body[data-wf-hud-menu="open"] #wfPortableRealmPreview .wf-realm-launcher,
body[data-wf-hud-menu="open"] #wfPortableRealmPreview .wf-realm-scrim{
  visibility:hidden!important;
  opacity:0!important;
  transition:none!important;
  pointer-events:none!important;
}
/* Record drawer, native dialog and Cinema have exclusive attention.
   Their original z-index and keyboard semantics remain intact. */
body[data-wf-hud-overlay="open"] #wfPortableRealmPreview .wf-realm-card,
body[data-wf-hud-overlay="open"] #wfPortableRealmPreview .wf-realm-launcher,
body[data-wf-hud-overlay="open"] #wfPortableRealmPreview .wf-realm-scrim{
  visibility:hidden!important;
  opacity:0!important;
  transition:none!important;
  pointer-events:none!important;
}
body[data-wf-hud-overlay="open"] #wfWorldEngine .wf-engine-inspector{
  pointer-events:none;
  opacity:.28;
}
/* Menu navigation is always possible and does not alter the realm's state. */
body[data-wf-hud-menu="open"] #wfWorldEngine .wf-engine-inspector{
  pointer-events:none;
  opacity:.32;
}

/* A lightweight Heaven launcher owns the top-right lane below Menu.
   A 3D scene continues unfurling from that anchor, but its maximum physical
   height is capped above the live World controls. */
body[data-wf-hud-layout] #wfPortableRealmPreview .wf-realm-card[data-dock="TOP_RIGHT"],
body[data-wf-hud-layout] #wfPortableRealmPreview .wf-realm-launcher[data-dock="TOP_RIGHT"]{
  top:var(--wf-hud-heaven-top)!important;
  right:12px!important;
  bottom:auto!important;
  left:auto!important;
}
body[data-wf-hud-layout] #wfPortableRealmPreview .wf-realm-card[data-dock="BOTTOM_LEFT"],
body[data-wf-hud-layout] #wfPortableRealmPreview .wf-realm-launcher[data-dock="BOTTOM_LEFT"]{
  left:12px!important;
  bottom:var(--wf-hud-hell-bottom)!important;
  right:auto!important;
  top:auto!important;
}
body[data-wf-hud-layout] #wfPortableRealmPreview .wf-realm-card[data-scene="heaven"][data-state="EXPANDED"]{
  width:min(508px,calc(100vw - 38px))!important;
  height:var(--wf-hud-heaven-max-height)!important;
}
body[data-wf-hud-layout] #wfPortableRealmPreview .wf-realm-card[data-scene="hell"][data-state="EXPANDED"]{
  width:min(516px,calc(100vw - 38px))!important;
  height:var(--wf-hud-hell-max-height)!important;
}
body[data-wf-hud-layout] #wfPortableRealmPreview .wf-realm-card[data-scene="heaven"][data-state="DOCKED"]{
  width:min(340px,calc(100vw - 32px))!important;
  height:min(380px,var(--wf-hud-heaven-max-height))!important;
}
body[data-wf-hud-layout] #wfPortableRealmPreview .wf-realm-card[data-scene="hell"][data-state="DOCKED"]{
  width:min(340px,calc(100vw - 32px))!important;
  height:min(375px,var(--wf-hud-hell-max-height))!important;
}

/* Inspector and Heaven never own the same strip. When Heaven is compact,
   right-side reference data moves underneath it; when Heaven is enlarged,
   reference data takes the left-side lane under the World caption. */
body[data-wf-hud-layout] #wfWorldEngine .wf-engine-inspector:not([hidden]){
  top:var(--wf-hud-inspector-right-top)!important;
  right:14px!important;
  left:auto!important;
  bottom:auto!important;
  width:min(318px,calc(100% - 28px))!important;
  max-height:min(410px,calc(100% - var(--wf-hud-inspector-right-top) - 76px))!important;
  padding:15px 16px 16px;
  border:1px solid rgba(216,255,69,.20);
  border-radius:14px;
  background:linear-gradient(135deg,rgba(8,16,25,.88),rgba(3,9,16,.96));
  backdrop-filter:blur(13px);
  box-shadow:0 14px 40px rgba(0,0,0,.55);
  scrollbar-width:thin;
}
body[data-wf-hud-open-realm="heaven"] #wfWorldEngine .wf-engine-inspector:not([hidden]){
  top:var(--wf-hud-inspector-left-top)!important;
  left:18px!important;
  right:auto!important;
  width:min(305px,calc(100% - 36px))!important;
  max-height:min(390px,calc(100% - var(--wf-hud-inspector-left-top) - 145px))!important;
}
/* Hell occupies the bottom-left; its inspector remains on the right. */
body[data-wf-hud-open-realm="hell"] #wfWorldEngine .wf-engine-inspector:not([hidden]){
  top:var(--wf-hud-inspector-right-top)!important;
  left:auto!important;
  right:14px!important;
}
body[data-wf-hud-layout] #wfWorldEngine .wf-engine-inspector h2{
  font-size:1rem;
  line-height:1.2;
  margin:4px 28px 12px 0;
}
body[data-wf-hud-layout] #wfWorldEngine .wf-engine-inspector dl>div{
  grid-template-columns:minmax(82px,.82fr) minmax(0,1.18fr);
  gap:9px;
}

/* The World remains legible while a larger Hell scene floats below it. */
body[data-wf-hud-open-realm="hell"] #wfWorldEngine .wf-engine-hud{
  isolation:isolate;
}
body[data-wf-hud-layout] #wfWorldEngine .wf-engine-controls{
  z-index:26;
}

/* Mobile context return: a real button appears only if an open realm and a
   World inspector would otherwise compete for the same touch area. */
.wf-hud-inspector-resume{
  position:fixed;
  z-index:103;
  top:calc(var(--wf-hud-heaven-top) + 90px);
  right:12px;
  max-width:min(230px,calc(100vw - 24px));
  min-height:38px;
  padding:8px 12px;
  border:1px solid rgba(216,255,69,.52);
  border-radius:999px;
  background:rgba(5,16,26,.93);
  color:#e7f2d1;
  box-shadow:0 10px 28px rgba(0,0,0,.63);
  font:600 12px/1.25 system-ui,sans-serif;
  cursor:pointer;
  backdrop-filter:blur(10px);
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap
}
.wf-hud-inspector-resume[hidden]{display:none!important}
.wf-hud-inspector-resume:hover{border-color:#ddfa8c;background:#102334}
.wf-hud-inspector-resume:focus-visible{
  outline:3px solid #d8ff45;outline-offset:3px
}

/* Phone/tablet touch lanes: Heaven at upper right, World caption upper left,
   Hell lower left, World controls lower right. The inspector occupies an
   independent, scrollable sheet when neither realm is enlarged. */
@media(max-width:760px){
  body[data-wf-hud-layout] #wfPortableRealmPreview .wf-realm-card[data-state="PEEK"]{
    width:140px!important;height:76px!important;
  }
  body[data-wf-hud-layout] #wfPortableRealmPreview .wf-realm-card[data-state="PEEK"][data-scene="hell"]{
    width:134px!important;height:75px!important;
  }
  body[data-wf-hud-layout] #wfPortableRealmPreview .wf-realm-card[data-dock="TOP_RIGHT"],
  body[data-wf-hud-layout] #wfPortableRealmPreview .wf-realm-launcher[data-dock="TOP_RIGHT"]{
    right:max(8px,env(safe-area-inset-right))!important;
  }
  body[data-wf-hud-layout] #wfPortableRealmPreview .wf-realm-card[data-dock="BOTTOM_LEFT"],
  body[data-wf-hud-layout] #wfPortableRealmPreview .wf-realm-launcher[data-dock="BOTTOM_LEFT"]{
    left:max(8px,env(safe-area-inset-left))!important;
  }
  body[data-wf-hud-layout] #wfPortableRealmPreview .wf-realm-card[data-state="EXPANDED"]{
    width:calc(100vw - 16px)!important;
    max-width:460px!important;
  }
  body[data-wf-hud-layout="compact"] #wfPortableRealmPreview .wf-realm-card[data-scene="heaven"]{
    transition:
      top 610ms var(--wf-v98-timing),
      width 880ms var(--wf-v98-timing),
      height 880ms var(--wf-v98-timing),
      opacity 620ms ease,
      filter 650ms ease,
      transform 830ms var(--wf-v98-timing),
      visibility 0s linear 830ms!important;
  }
  body[data-wf-hud-layout="compact"] #wfPortableRealmPreview .wf-realm-card[data-scene="heaven"][data-state="EXPANDED"],
  body[data-wf-hud-layout="compact"] #wfPortableRealmPreview .wf-realm-card[data-scene="heaven"][data-state="DOCKED"]{
    top:var(--wf-hud-heaven-open-top)!important;
  }
  body[data-wf-hud-layout] #wfPortableRealmPreview .wf-realm-card[data-state="DOCKED"]{
    width:min(322px,calc(100vw - 18px))!important
  }
  body[data-wf-hud-layout] #wfPortableRealmPreview .wf-realm-card[data-state="EXPANDED"] .wf-realm-card-body{
    max-width:calc(100% - 20px);
    max-height:calc(100% - 90px);
  }
  body[data-wf-hud-layout] #wfPortableRealmPreview .wf-realm-vista-tag{
    letter-spacing:.10em;
  }
  body[data-wf-hud-layout] #wfWorldEngine .wf-engine-hud{
    max-width:calc(100vw - 160px)!important;
    padding:8px 9px;
    gap:4px;
  }
  body[data-wf-hud-layout] #wfWorldEngine .wf-engine-ephemeris{
    font-size:.55rem;
    line-height:1.35;
    overflow-wrap:anywhere
  }
  body[data-wf-hud-layout] #wfWorldEngine .wf-engine-loc strong{
    font-size:1rem
  }
  body[data-wf-hud-layout] #wfWorldEngine .wf-engine-controls{
    left:150px!important;
    right:8px!important;
    bottom:max(9px,env(safe-area-inset-bottom))!important;
    max-width:calc(100vw - 158px)!important;
    justify-content:flex-end!important;
    align-content:flex-end;
    gap:5px!important
  }
  body[data-wf-hud-layout] #wfWorldEngine .wf-engine-controls button{
    padding:7px 8px;
    min-height:33px;
    font-size:.61rem;
    white-space:nowrap
  }
  body[data-wf-hud-layout] #wfWorldEngine .wf-engine-inspector:not([hidden]){
    top:var(--wf-hud-inspector-right-top)!important;
    right:8px!important;
    bottom:auto!important;
    left:auto!important;
    width:min(320px,calc(100% - 16px))!important;
    max-height:min(28dvh,calc(100% - var(--wf-hud-inspector-right-top) - 110px))!important;
    padding:11px 12px 12px;
    font-size:.75rem;
    border:1px solid rgba(216,255,69,.25);
    border-radius:12px;
  }
  /* Save real touch space instead of placing an invisible window beneath
     the animated vista. The details return chip is reachable and labeled. */
  body[data-wf-hud-inspector="suspended"] #wfWorldEngine .wf-engine-inspector:not([hidden]){
    visibility:hidden!important;
    opacity:0!important;
    pointer-events:none!important;
  }
  /* The world-details restore pill is part of the expanded vista's own
     controls, never an unrelated floating window. */
  body[data-wf-hud-layout="compact"] #wfPortableRealmPreview .wf-realm-actions .wf-hud-inspector-resume{
    position:static!important;z-index:auto!important;
    display:inline-flex!important;align-items:center!important;
    min-height:32px!important;max-width:100%;
    padding:7px 9px!important;
    border-color:rgba(216,255,69,.6)!important;
    background:rgba(16,30,21,.88)!important;
    color:#ecf8d8!important;
    font:600 10px/1.15 system-ui,sans-serif!important;
    white-space:nowrap;box-shadow:0 5px 13px rgba(0,0,0,.4)
  }
  body[data-wf-hud-layout="compact"] #wfPortableRealmPreview .wf-realm-actions .wf-hud-inspector-resume[hidden]{display:none!important}
  body[data-wf-hud-menu="open"] .nav-more-menu{
    position:fixed;
    top:54px;
    left:10px;
    right:10px;
    max-height:min(68dvh,520px);
    width:auto;
    min-width:0;
    z-index:170;
  }
  body[data-wf-hud-layout] #wfPortableRealmPreview .wf-realm-launcher{
    min-width:45px;
    min-height:43px;
  }
}
@media(max-width:380px){
  body[data-wf-hud-layout] #wfWorldEngine .wf-engine-hud{
    max-width:calc(100vw - 152px)!important
  }
  body[data-wf-hud-layout] #wfWorldEngine .wf-engine-controls{
    left:140px!important;
    max-width:calc(100vw - 148px)!important;
  }
  body[data-wf-hud-layout] #wfPortableRealmPreview .wf-realm-card[data-state="PEEK"]{
    width:132px!important;
  }
}
/* Compact landscape: preserve access to controls even when vertical space
   cannot sustain two full-height scenic projections. */
@media(max-height:540px){
  body[data-wf-hud-layout] #wfPortableRealmPreview .wf-realm-card[data-state="EXPANDED"]{
    height:min(330px,var(--wf-hud-heaven-max-height))!important;
  }
  body[data-wf-hud-layout] #wfPortableRealmPreview .wf-realm-card[data-scene="hell"][data-state="EXPANDED"]{
    height:var(--wf-hud-hell-max-height)!important;
  }
  body[data-wf-hud-layout] #wfWorldEngine .wf-engine-inspector:not([hidden]){
    max-height:min(36dvh,calc(100% - var(--wf-hud-inspector-right-top) - 38px))!important;
  }
}
@media(prefers-reduced-motion:reduce){
  body[data-wf-hud-layout] #wfPortableRealmPreview .wf-realm-card{
    animation:none!important;
    transition:none!important;
  }
  /* The V98 bloom/siphon selectors outrank its original generic reduced-
     motion rule. Make the final painted frame visible without any motion. */
  body[data-wf-hud-layout] #wfPortableRealmPreview .wf-realm-card[data-phase="bloom"] .wf-realm-artwork,
  body[data-wf-hud-layout] #wfPortableRealmPreview .wf-realm-card[data-phase="siphon"] .wf-realm-artwork{
    animation:none!important;
    opacity:1!important;
    transform:none!important;
    filter:none!important;
  }
  body[data-wf-hud-layout="compact"] #wfPortableRealmPreview .wf-realm-card[data-scene="heaven"]{
    transition:none!important;
  }
  body[data-wf-hud-layout] #wfWorldEngine .wf-engine-inspector{
    transition:none!important;
  }
  .wf-hud-inspector-resume{transition:none!important}
}
