/* EarthWatch "widget mode" layout -- see js/ew-widget-mode.js for the
   ?widget=1 trigger that adds .ew-widget-mode to <html>. Built for a
   short, very wide ambient display (Corsair iCUE XENEON EDGE, 2560x720,
   shown through iCUE's "Web URL" widget -- NOT its "iFrame" widget,
   which renders this page blank for reasons outside EarthWatch: same
   URL works fine in a normal browser tab and in Web URL, confirmed
   live), but sized with plain px rather than viewport units so it
   degrades reasonably on any short+wide window, not just that exact
   panel.

   Loads last (after every other css/*.css file, including the
   ew-shell-*.css stage files) specifically to win the cascade outright,
   same strategy those files already use -- hence the liberal
   !important, matching their own convention rather than introducing a
   new one.

   Three columns: left rail (LIVE pill + incident stat tiles + the
   hazard-layer toggle buttons, reusing the main page's own #hazardButtons
   proxy-button panel rather than reimplementing the look), the map
   (with its zoom controls kept), and the right rail (the normal ACTIVE
   FEED list, stretched to full height, with the in-feed MAP KEY legend
   block hidden so the alert list gets the vertical space instead --
   reported live as needed since there isn't room for both). Click-to-
   detail on a map marker (#alertPane) is untouched -- that's the
   "popup on click" mode relies on instead of the dropped saved-
   locations/alert-centre side trackers.

   IMPORTANT gotcha this file already got bitten by once: #incidentSummary/
   #dataHealthButton/#updated are children of <header>. display:none on
   header hides its whole subtree regardless of position:fixed on a
   child -- fixed positioning escapes normal LAYOUT, not an ancestor's
   display:none. header is instead collapsed to a 0x0 box (still
   "displayed", just with no footprint) so those three can keep
   rendering via their own fixed coordinates; header's other children
   (brand/coverage button/mode text) are hidden individually instead. */

html.ew-widget-mode footer,
html.ew-widget-mode nav,
html.ew-widget-mode #missionSidebar,
html.ew-widget-mode #layersPanel,
html.ew-widget-mode #mapHint,
html.ew-widget-mode #declutterNote,
html.ew-widget-mode .legend,
html.ew-widget-mode .mapcredit,
html.ew-widget-mode #statusBar,
html.ew-widget-mode #mapKeyPanel{
  display:none!important;
}

/* header and #ewNavRail both need this "zero-footprint but not
   display:none" treatment, not a plain hide: each has at least one
   child (header: #dataHealthButton/#incidentSummary; #ewNavRail:
   #railLayers below) that needs to keep rendering via its own fixed
   position. display:none on a parent hides the whole subtree no matter
   what position/display the child itself asks for -- bitten by this
   once already on header, see below. */
html.ew-widget-mode header,
html.ew-widget-mode #ewNavRail{
  display:block!important;
  position:fixed!important;
  top:0!important;left:0!important;width:0!important;height:0!important;
  overflow:visible!important;
  padding:0!important;margin:0!important;border:0!important;
  pointer-events:none!important;
}
html.ew-widget-mode header>.brand,
html.ew-widget-mode header>#coverageButton,
html.ew-widget-mode header>#modeText,
html.ew-widget-mode header>.updated,
html.ew-widget-mode #ewNavRail>.ewRailBtn:not(#railLayers),
html.ew-widget-mode #ewNavRail>.ewRailDivider{
  display:none!important;
}
html.ew-widget-mode header>#dataHealthButton,
html.ew-widget-mode header>#incidentSummary,
html.ew-widget-mode #ewNavRail>#railLayers{
  pointer-events:auto!important;
}

:root{--ew-widget-stats-w:340px;--ew-widget-feed-w:360px;}
@media (max-width:1700px){:root{--ew-widget-stats-w:280px;--ew-widget-feed-w:300px;}}
@media (max-width:1300px){:root{--ew-widget-stats-w:230px;--ew-widget-feed-w:240px;}}

html.ew-widget-mode #app{
  display:block!important;
  height:100vh!important;
  width:100vw!important;
}

html.ew-widget-mode .main{
  display:grid!important;
  grid-template-columns:minmax(0,1fr) var(--ew-widget-feed-w)!important;
  grid-template-rows:none!important;
  grid-column:auto!important;
  grid-row:auto!important;
  height:100vh!important;
  padding:0 0 0 var(--ew-widget-stats-w)!important;
  gap:0!important;
}

html.ew-widget-mode #map{
  border:0!important;
  box-shadow:none!important;
}

html.ew-widget-mode .side{
  width:auto!important;
  min-width:0!important;
  height:100vh!important;
  border-top:0!important;border-right:0!important;border-bottom:0!important;
  border-radius:0!important;
  padding:10px!important;
}

html.ew-widget-mode .mapbar{
  top:8px!important;left:8px!important;
  font-size:11px!important;padding:5px 8px!important;
}

/* --- Left rail --- */

html.ew-widget-mode #dataHealthButton{
  position:fixed!important;left:10px!important;top:10px!important;z-index:51!important;
}

/* 2-column stat grid rather than a single vertical stack -- vertical
   space is the scarce resource here (a ~720px-tall panel), not width,
   so trading width for height on these tiles is the right exchange.
   7 chips -> 4 rows instead of 7, freeing real room below for the
   hazard-layer toggles. */
html.ew-widget-mode #incidentSummary{
  position:fixed!important;
  left:0!important;top:84px!important;
  width:var(--ew-widget-stats-w)!important;
  max-width:var(--ew-widget-stats-w)!important;
  height:calc(100vh - 100px)!important;
  display:grid!important;
  grid-template-columns:1fr 1fr!important;
  grid-auto-rows:min-content!important;
  gap:6px!important;
  overflow-y:auto!important;overflow-x:hidden!important;
  padding:0 10px!important;
  margin:0!important;
  background:transparent!important;
  border:0!important;
  z-index:50!important;
}

html.ew-widget-mode #incidentSummary .incChip{
  display:flex!important;flex-direction:column!important;align-items:flex-start!important;
  gap:2px!important;
  width:100%!important;
  border:1px solid #174f70!important;
  background:#0a1a26!important;
  padding:6px 8px!important;
  font-size:9px!important;font-weight:800!important;letter-spacing:.05em!important;
  color:#9bb3c2!important;
  white-space:normal!important;
}
html.ew-widget-mode #incidentSummary .incChip strong{
  font-size:17px!important;font-weight:900!important;
  color:#f2fbff!important;margin-left:0!important;line-height:1.1!important;
}
html.ew-widget-mode #incidentSummary .incChip.hot{border-color:#8a3d28!important;}
html.ew-widget-mode #incidentSummary .incChip.hot strong{color:#ff9f6a!important;}
html.ew-widget-mode #incidentSummary .incChip.urgent{border-color:#9d3042!important;background:#1c0b10!important;}
html.ew-widget-mode #incidentSummary .incChip.urgent strong{color:#ff6b85!important;}
/* Normal layout only shows the first 4 chips (v220-polish.css) -- all 7
   fit here across the grid. */
html.ew-widget-mode #incidentSummary .incChip:nth-child(n+5){display:flex!important;}

/* Hazard-layer toggles: a pop-out panel opened from a single button,
   same interaction as the main page -- not shown permanently (reported
   live as preferred, since it was eating rail height the stat tiles
   could use). #railLayers (inside #ewNavRail, see above) already
   toggles #hazardLayersPanel's .open class (ew-shell-nav-rail.js) and
   #hazardLayersPanelClose already closes it -- both reused as-is, just
   restyled/repositioned. #hazardButtons inside it is the same modern
   icon+label proxy-button panel described in the stat-tiles comment
   above: each button's onclick calls the real toggle's .click()
   directly, so it's fully working, not just visual. */
html.ew-widget-mode #railLayers{
  position:fixed!important;
  left:10px!important;top:44px!important;
  width:calc(var(--ew-widget-stats-w) - 20px)!important;height:30px!important;
  z-index:51!important;
  flex-direction:row!important;
  justify-content:flex-start!important;
  gap:8px!important;
  padding:0 10px!important;
  border-radius:6px!important;
  background:var(--ew2-raised,#161D26)!important;
  border:1px solid var(--ew2-border,#1C2530)!important;
}
html.ew-widget-mode #railLayers svg{width:15px!important;height:15px!important;}
html.ew-widget-mode #railLayers span{font-size:10px!important;letter-spacing:.06em!important;}
html.ew-widget-mode #railLayers.active{
  background:var(--ew2-accent-soft,rgba(47,191,224,.12))!important;
  border-color:var(--ew2-accent,#2FBFE0)!important;
}

/* (Stat tiles above get the extra room freed up since the hazard panel
   is no longer permanently occupying the rail below them.) */
html.ew-widget-mode #hazardLayersPanel{
  position:fixed!important;
  left:10px!important;top:80px!important;
  width:300px!important;max-width:calc(100vw - 20px)!important;
  max-height:calc(100vh - 90px)!important;
  z-index:1600!important;
}

/* #alertPane (click-to-detail) caps comfortably within a ~720px-tall
   viewport instead of assuming normal desktop height. */
html.ew-widget-mode #alertPane{
  max-height:calc(100vh - 20px)!important;
  overflow-y:auto!important;
}
