/* HTerminal Atlas: uncluttered central globe/map, collapsible rails, slim geo strip, mobile full-view */
:root{
  --ht-safe-l:310px;
  --ht-safe-t:72px;
  --ht-safe-r:310px;
  --ht-safe-b:92px;
  --ht-ink:#e6f6ec;
  --ht-sub:#8ebaa0;
  --ht-accent:#2ce67b;
}

/* Smooth panel & stage visibility */
#globe,#atlasFlat{
  position:fixed;
  inset:0;
  z-index:1;
  touch-action:none;
  user-select:none;
  -webkit-user-select:none;
}
#atlasFlat{background:radial-gradient(circle at 50% 45%,#05190e 0,#020805 78%)}
#flatC{width:100%;height:100%;display:block;cursor:grab;touch-action:none}
#flatC.dragging{cursor:grabbing}

/* Hide legacy floating rail completely */
#atlasRail{display:none!important}

/* Compact corner mode/layers control anchored to visible map safe-area */
#atlasCtrl{
  position:fixed;
  left:calc(var(--ht-safe-l) + 10px);
  top:calc(var(--ht-safe-t) + 8px);
  z-index:18;
  display:flex;
  align-items:center;
  gap:6px;
  pointer-events:auto;
  transition:left .28s cubic-bezier(.22,1,.36,1),top .28s cubic-bezier(.22,1,.36,1),opacity .2s;
}
body:not([data-d=news]):not([data-d=supply]):not([data-d=markets]) #atlasCtrl,
body:not([data-d=news]):not([data-d=supply]):not([data-d=markets]) #atlasZoomCtrl{
  opacity:0;
  pointer-events:none;
}
body[data-d=markets] #atlasCtrl,
body[data-d=markets] #atlasZoomCtrl{
  opacity:.72;
}
body[data-d=markets] #atlasCtrl:hover,
body[data-d=markets] #atlasZoomCtrl:hover{opacity:1}

.ht-seg{
  display:inline-flex;
  padding:2px;
  border-radius:999px;
  background:rgba(2,14,8,.88);
  border:1px solid rgba(57,255,106,.28);
  backdrop-filter:blur(10px);
  -webkit-backdrop-filter:blur(10px);
  box-shadow:0 4px 16px rgba(0,0,0,.45);
}
.ht-seg button{
  padding:4px 10px;
  border-radius:999px;
  font:700 10.5px var(--mono);
  letter-spacing:.08em;
  color:var(--ht-sub);
  transition:background .18s,color .18s;
}
.ht-seg button.on{
  background:rgba(57,255,106,.2);
  color:#eafff2;
  box-shadow:inset 0 0 0 1px rgba(57,255,106,.5);
}
.ht-ctrl-btn{
  display:inline-flex;
  align-items:center;
  gap:5px;
  padding:5px 10px;
  border-radius:999px;
  background:rgba(2,14,8,.88);
  border:1px solid rgba(57,255,106,.28);
  color:var(--ht-ink);
  font:700 10.5px var(--mono);
  letter-spacing:.06em;
  backdrop-filter:blur(10px);
  -webkit-backdrop-filter:blur(10px);
  box-shadow:0 4px 16px rgba(0,0,0,.45);
  transition:border-color .18s,background .18s;
}
.ht-ctrl-btn:hover,.ht-ctrl-btn.on{
  border-color:rgba(57,255,106,.65);
  background:rgba(8,32,18,.94);
}
.ht-ctrl-btn em{font-style:normal;color:var(--ht-sub);font-weight:500}

/* Clean desktop layers popover */
#atlasLayerPop{
  position:fixed;
  left:calc(var(--ht-safe-l) + 10px);
  top:calc(var(--ht-safe-t) + 44px);
  z-index:35;
  width:238px;
  max-width:calc(100vw - 24px);
  padding:10px;
  border-radius:10px;
  background:rgba(3,16,9,.94);
  border:1px solid rgba(57,255,106,.34);
  box-shadow:0 12px 34px rgba(0,0,0,.65);
  backdrop-filter:blur(14px);
  -webkit-backdrop-filter:blur(14px);
  pointer-events:auto;
}
#atlasLayerPop[hidden]{display:none}
.ht-pop-h{
  display:flex;
  align-items:center;
  justify-content:space-between;
  margin-bottom:8px;
  font:700 10.5px var(--mono);
  letter-spacing:.14em;
  color:var(--ht-ink);
}
.ht-pop-list{display:flex;flex-direction:column;gap:5px}
.ht-pop-list .rl-btn{
  padding:6px 8px;
  border-radius:6px;
  font-size:11px;
  color:var(--ht-sub);
}
.ht-pop-list .rl-btn.on{color:var(--ht-ink)}
.ht-pop-note{margin-top:8px;font:10px/1.35 var(--mono);color:var(--ht-sub);opacity:.85}

/* Zoom / reset / spin pill in bottom-right corner of visible map */
#atlasZoomCtrl{
  position:fixed;
  right:calc(var(--ht-safe-r) + 10px);
  bottom:calc(var(--ht-safe-b) + 10px);
  z-index:18;
  display:flex;
  align-items:center;
  gap:2px;
  padding:3px;
  border-radius:999px;
  background:rgba(2,14,8,.88);
  border:1px solid rgba(57,255,106,.28);
  backdrop-filter:blur(10px);
  -webkit-backdrop-filter:blur(10px);
  box-shadow:0 4px 16px rgba(0,0,0,.45);
  pointer-events:auto;
  transition:right .28s cubic-bezier(.22,1,.36,1),bottom .28s cubic-bezier(.22,1,.36,1),opacity .2s;
}
#atlasZoomCtrl button{
  min-width:28px;
  height:28px;
  padding:0 7px;
  border-radius:999px;
  font:700 13px var(--mono);
  color:var(--ht-ink);
  display:inline-flex;
  align-items:center;
  justify-content:center;
}
#atlasZoomCtrl button:hover{background:rgba(57,255,106,.16)}
#atlasZoomCtrl button[hidden]{display:none}

/* Clean interactive pin popup */
#atlasPinPop{
  position:fixed;
  z-index:36;
  width:min(310px,calc(100vw - 24px));
  padding:11px 12px;
  border-radius:10px;
  background:rgba(3,16,9,.95);
  border:1px solid rgba(57,255,106,.45);
  box-shadow:0 14px 36px rgba(0,0,0,.72);
  backdrop-filter:blur(14px);
  -webkit-backdrop-filter:blur(14px);
  pointer-events:auto;
  color:var(--ht-ink);
}
#atlasPinPop[hidden]{display:none}
.ht-pin-top{display:flex;align-items:center;gap:6px;margin-bottom:5px}
.ht-pin-kind{
  font:700 9.5px var(--mono);
  letter-spacing:.12em;
  text-transform:uppercase;
  padding:2px 6px;
  border-radius:4px;
  background:rgba(57,255,106,.14);
  color:#d8ffe4;
  border:1px solid rgba(57,255,106,.3);
}
.ht-pin-x{margin-left:auto;width:24px;height:24px;border-radius:50%;color:var(--ht-sub);font-size:13px}
.ht-pin-x:hover{background:rgba(255,255,255,.08);color:#fff}
.ht-pin-title{font:600 13px/1.35 var(--sans);color:#fff;margin-bottom:4px}
.ht-pin-sub{font:11px/1.35 var(--mono);color:var(--ht-sub);margin-bottom:8px}
.ht-pin-list{display:flex;flex-direction:column;gap:5px;max-height:190px;overflow:auto;margin:6px 0 8px}
.ht-pin-row{
  display:flex;align-items:flex-start;gap:7px;text-align:left;
  padding:6px 7px;border-radius:6px;background:rgba(255,255,255,.03);
  border:1px solid rgba(57,255,106,.16);color:var(--ht-ink);font:12px/1.3 var(--sans);
}
.ht-pin-row:hover{border-color:rgba(57,255,106,.5);background:rgba(57,255,106,.09)}
.ht-pin-row i{width:7px;height:7px;border-radius:50%;margin-top:4px;flex:none}
.ht-pin-actions{display:flex;gap:6px;flex-wrap:wrap}
.ht-pin-actions .btn{font-size:10.5px;padding:5px 10px;color:var(--ht-ink);border-color:rgba(57,255,106,.45)}

/* Refined readable text in panels (avoid loud green walls of text) */
.st .t,.brief p,.xi a{color:#e6f6ec}
.panel h3{color:#dff7e8}
.panel h3 small{color:#8ebaa0}

/* Panel collapse controls */
.ht-pcol-btn{
  margin-left:6px;
  width:22px;
  height:22px;
  border-radius:4px;
  border:1px solid rgba(57,255,106,.24);
  color:var(--ht-sub);
  font:700 12px/1 var(--mono);
  display:inline-flex;
  align-items:center;
  justify-content:center;
  flex:none;
}
.ht-pcol-btn:hover{border-color:rgba(57,255,106,.6);color:#fff;background:rgba(57,255,106,.12)}
.panel.ht-collapsed{min-height:0!important;height:auto!important;flex:none}
.panel.ht-collapsed .body,
.panel.ht-collapsed .chart-tools,
.panel.ht-collapsed #indChips,
.panel.ht-collapsed #chWrap,
.panel.ht-collapsed #chartSub{display:none!important}
.panel.ht-collapsed h3{border-bottom:0}

/* Desktop News & Supply layout: narrower rails + slim bottom Geo strip + clear center map */
@media (min-width:761px){
  .display{padding:8px 40px 10px;gap:10px}
  .edge{width:28px}.edge.prev{left:4px}.edge.next{right:26px}

  .display[data-d=news]{
    grid-template-columns:minmax(230px,21%) 1fr minmax(230px,21%);
    grid-template-rows:minmax(0,1.12fr) minmax(0,1fr) auto;
    transition:grid-template-columns .25s ease;
  }
  .display[data-d=news] .p-wire{grid-column:1;grid-row:1/4}
  .display[data-d=news] .p-brief{grid-column:3;grid-row:1}
  .display[data-d=news] .p-x{grid-column:3;grid-row:2/4}
  .display[data-d=news] .p-geo{
    grid-column:2;
    grid-row:3;
    align-self:end;
    max-height:none;
    clip-path:none;
    border-radius:6px;
  }

  /* Slim single-row Geo Headlines strip by default */
  .display[data-d=news] .p-geo:not(.ht-geo-expanded):not(.ht-collapsed){
    flex-direction:row;
    align-items:center;
    height:40px;
    padding:0 6px;
    gap:8px;
  }
  .display[data-d=news] .p-geo:not(.ht-geo-expanded):not(.ht-collapsed) h3{
    border-bottom:0;
    padding:0 6px 0 4px;
    font-size:10px;
    letter-spacing:.14em;
    flex:none;
  }
  .display[data-d=news] .p-geo:not(.ht-geo-expanded):not(.ht-collapsed) h3 small,
  .display[data-d=news] .p-geo:not(.ht-geo-expanded):not(.ht-collapsed) h3 .fresh{display:none}
  .display[data-d=news] .p-geo:not(.ht-geo-expanded):not(.ht-collapsed) .body{
    display:flex;
    align-items:center;
    gap:6px;
    overflow-x:auto;
    overflow-y:hidden;
    white-space:nowrap;
    padding:4px 2px;
    scrollbar-width:none;
  }
  .display[data-d=news] .p-geo:not(.ht-geo-expanded):not(.ht-collapsed) .body::-webkit-scrollbar{display:none}
  .display[data-d=news] .p-geo:not(.ht-geo-expanded):not(.ht-collapsed) .geo-i{
    display:inline-flex;
    align-items:center;
    gap:5px;
    padding:3px 9px;
    border:1px solid rgba(57,255,106,.22);
    border-radius:999px;
    background:rgba(0,0,0,.38);
    font-size:11px;
    color:var(--ht-ink);
    cursor:pointer;
    flex:none;
    max-width:250px;
    overflow:hidden;
    text-overflow:ellipsis;
  }
  .display[data-d=news] .p-geo:not(.ht-geo-expanded):not(.ht-collapsed) .geo-i:hover{
    border-color:rgba(57,255,106,.6);
    background:rgba(57,255,106,.12);
  }
  .display[data-d=news] .p-geo:not(.ht-geo-expanded):not(.ht-collapsed) .geo-i b{color:#b8ffcc;font-weight:600}
  .display[data-d=news] .p-geo.ht-geo-expanded{max-height:190px}
  .display[data-d=news] .p-geo.ht-geo-expanded .geo-i{display:block;padding:4px 0;border-bottom:1px solid rgba(57,255,106,.08);cursor:pointer}

  /* Collapsed rail states */
  .display[data-d=news].ht-left-collapsed{grid-template-columns:36px 1fr minmax(230px,21%)}
  .display[data-d=news].ht-right-collapsed{grid-template-columns:minmax(230px,21%) 1fr 36px}
  .display[data-d=news].ht-left-collapsed.ht-right-collapsed{grid-template-columns:36px 1fr 36px}

  .display[data-d=news].ht-left-collapsed .p-wire .body,
  .display[data-d=news].ht-left-collapsed .p-wire h3 small,
  .display[data-d=news].ht-left-collapsed .p-wire h3 .fresh{display:none!important}
  .display[data-d=news].ht-left-collapsed .p-wire{cursor:pointer;align-items:center;justify-content:flex-start}
  .display[data-d=news].ht-left-collapsed .p-wire h3{
    writing-mode:vertical-rl;
    transform:rotate(180deg);
    border-bottom:0;
    padding:12px 6px;
    gap:8px;
    align-items:center;
  }

  .display[data-d=news].ht-right-collapsed .p-brief .body,
  .display[data-d=news].ht-right-collapsed .p-brief h3 small,
  .display[data-d=news].ht-right-collapsed .p-brief h3 .fresh,
  .display[data-d=news].ht-right-collapsed .p-x{display:none!important}
  .display[data-d=news].ht-right-collapsed .p-brief{grid-row:1/4;cursor:pointer;align-items:center}
  .display[data-d=news].ht-right-collapsed .p-brief h3{
    writing-mode:vertical-rl;
    border-bottom:0;
    padding:12px 6px;
    gap:8px;
    align-items:center;
  }

  /* Supply keeps 3-column clear center even at 1024px */
  .display[data-d=supply]{grid-template-columns:minmax(220px,22%) 1fr minmax(220px,22%);grid-template-rows:1fr 1fr}
  .display[data-d=supply] .p-freight{grid-column:1;grid-row:1}
  .display[data-d=supply] .p-shock{grid-column:1;grid-row:2}
  .display[data-d=supply] .p-choke{grid-column:3;grid-row:1;min-height:0}
  .display[data-d=supply] .p-shipbreak{grid-column:3;grid-row:2;min-height:0}
  .display[data-d=supply].ht-left-collapsed{grid-template-columns:36px 1fr minmax(220px,22%)}
  .display[data-d=supply].ht-right-collapsed{grid-template-columns:minmax(220px,22%) 1fr 36px}
  .display[data-d=supply].ht-left-collapsed.ht-right-collapsed{grid-template-columns:36px 1fr 36px}
  .display[data-d=supply].ht-left-collapsed .p-freight .body,
  .display[data-d=supply].ht-left-collapsed .p-freight h3 small,
  .display[data-d=supply].ht-left-collapsed .p-freight h3 .fresh,
  .display[data-d=supply].ht-left-collapsed .p-shock{display:none!important}
  .display[data-d=supply].ht-left-collapsed .p-freight{grid-row:1/3;cursor:pointer;align-items:center}
  .display[data-d=supply].ht-left-collapsed .p-freight h3{writing-mode:vertical-rl;transform:rotate(180deg);border-bottom:0;padding:12px 6px}
  .display[data-d=supply].ht-right-collapsed .p-choke .body,
  .display[data-d=supply].ht-right-collapsed .p-choke h3 small,
  .display[data-d=supply].ht-right-collapsed .p-choke h3 .fresh,
  .display[data-d=supply].ht-right-collapsed .p-shipbreak,
  .display[data-d=supply].ht-right-collapsed .p-sc{display:none!important}
  .display[data-d=supply].ht-right-collapsed .p-choke{grid-row:1/3;cursor:pointer;align-items:center}
  .display[data-d=supply].ht-right-collapsed .p-choke h3{writing-mode:vertical-rl;border-bottom:0;padding:12px 6px}

  /* Compact medium laptops (761px..1180px, e.g. 1024x768 & 1024x513) */
  @media (max-width:1180px){
    .display[data-d=news]{grid-template-columns:minmax(205px,22.5%) 1fr minmax(205px,22.5%)}
    .display[data-d=supply]{grid-template-columns:minmax(200px,22%) 1fr minmax(200px,22%)}
    .display[data-d=news] .p-wire .st{padding:6px 0}
    .display[data-d=news] .p-wire .st .t{font-size:12px}
    .panel h3{padding:6px 9px 5px;font-size:10px}
    .panel .body{padding:6px 9px 8px}
  }
  @media (max-height:620px){
    :root{--top:50px;--tape:30px}
    .brand img{width:26px;height:26px}
    .disp-title strong{font-size:17px}
    .display{padding:4px 36px 6px;gap:8px}
    .display[data-d=news] .p-geo:not(.ht-geo-expanded):not(.ht-collapsed){height:34px}
  }
}

/* Mobile (iPhone 14 Pro Max 430x932 etc.): full-view map + swipe-up sheets */
@media (max-width:760px){
  .ht-desk-only{display:none!important}

  body[data-d=news] #globe,
  body[data-d=news] #atlasFlat,
  body[data-d=supply] #globe,
  body[data-d=supply] #atlasFlat{
    top:calc(var(--top) + var(--safe-t))!important;
    bottom:calc(var(--tape) + var(--dock) + var(--safe-b) + 8px)!important;
    height:auto!important;
    left:0!important;
    right:0!important;
  }

  /* Make news & supply displays float only the bottom sheet pills; keep rest transparent so touches hit map */
  .display[data-d=news],
  .display[data-d=supply]{
    padding:0!important;
    overflow:hidden!important;
    pointer-events:none!important;
  }
  .display[data-d=news] .panel:not(.in-sheet),
  .display[data-d=supply] .panel:not(.in-sheet){
    display:none!important;
  }
  .display[data-d=news] .mob-sheet-bar,
  .display[data-d=supply] .mob-sheet-bar{
    position:fixed;
    left:50%;
    transform:translateX(-50%);
    width:max-content;
    max-width:calc(100vw - 12px);
    bottom:6px;
    z-index:22;
    padding:2px 2px;
    gap:6px;
    justify-content:flex-start;
    pointer-events:auto;
  }
  .display[data-d=news] .mob-sheet-pill,
  .display[data-d=supply] .mob-sheet-pill{
    min-height:36px;
    padding:6px 10px;
    font-size:10px;
    gap:4px;
    background:rgba(2,14,8,.92);
    backdrop-filter:blur(10px);
    -webkit-backdrop-filter:blur(10px);
  }
  .in-sheet .ht-pcol-btn{display:none!important}
  .in-sheet .geo-i{display:block;padding:9px 0;border-bottom:1px solid rgba(57,255,106,.12);font-size:13.5px;line-height:1.4;cursor:pointer}
  .in-sheet .geo-i b{color:#b8ffcc;display:inline-block;margin-right:6px}


  #atlasCtrl{
    left:max(10px,var(--safe-l));
    top:calc(var(--top) + var(--safe-t) + 6px);
  }
  #atlasZoomCtrl{
    right:max(10px,var(--safe-r));
    bottom:calc(var(--tape) + var(--dock) + var(--safe-b) + 56px);
  }
  #atlasZoomCtrl button{min-width:34px;height:34px;font-size:15px}
  #atlasPinPop{
    left:50%!important;
    right:auto!important;
    top:auto!important;
    bottom:calc(var(--tape) + var(--dock) + var(--safe-b) + 58px)!important;
    transform:translateX(-50%);
    width:min(380px,calc(100vw - 20px));
  }
}
