/* cpcrop.css — page-shell styling shared by the three web-native U.S. crop
 * analytics pages (cropcondition, cropprogress, drought): the enterprise
 * site's dark-mode + theme-transition rules for the Tailwind shell, the
 * graphic card (spinner + unavailable message) and the
 * MapLibre mount. ONE copy served via the app stamp (extracted from the
 * templates' inline <style> block 2026-09-02). Loaded AFTER ag.css and
 * cpmenustyle.css so its dark-mode overrides win. The widget's own styling
 * is cp_embed.css; the sidebar-cell hover colors are set inline by
 * cpcrop.js (lcellon/lcelloff). */

@keyframes spin { to { transform: rotate(360deg); } }
/* no internal scrollbar on the sidebar (its 2026-09-04 max-height/overflow
   cap was removed 2026-09-08 — user): a sidebar taller than the window
   (the progress page's 45-state table) scrolls with the page */
.sidebar-sticky { position: sticky; top: 1.5rem; }

/* Smooth theme transitions */
body.theme-ready { transition: background-color 0.4s ease, color 0.4s ease; }
body.theme-ready nav, body.theme-ready footer, body.theme-ready .bg-white, body.theme-ready .bg-slate-50, body.theme-ready .bg-gray-100,
body.theme-ready .bg-green-800, body.theme-ready .bg-green-100, body.theme-ready #contextbar {
  transition: background-color 0.4s ease, color 0.4s ease, border-color 0.4s ease;
}
body.theme-ready .border-gray-200, body.theme-ready .border-gray-100 { transition: border-color 0.4s ease; }
body.theme-ready .text-gray-800, body.theme-ready .text-gray-700, body.theme-ready .text-gray-600, body.theme-ready .text-gray-500,
body.theme-ready .text-gray-400, body.theme-ready .text-gray-300, body.theme-ready .text-green-800, body.theme-ready .text-green-700 {
  transition: color 0.4s ease;
}

/* ---- Dark Mode ---- */
body.dark-mode { background-color: #111827 !important; color: #e5e7eb; }
body.dark-mode nav { background: linear-gradient(to right, #111827, #111827); border-bottom: 1px solid #374151; }
body.dark-mode .bg-white,
body.dark-mode .bg-slate-50,
body.dark-mode .bg-gray-100:not(.btn-toggle):not(button) { background: #1f2937 !important; color: #e5e7eb; }
body.dark-mode .border-gray-200,
body.dark-mode .border-gray-100 { border-color: #374151 !important; }
body.dark-mode .text-gray-800 { color: #f3f4f6 !important; }
body.dark-mode .text-gray-700 { color: #d1d5db !important; }
body.dark-mode .text-gray-500 { color: #9ca3af !important; }
body.dark-mode .text-gray-400 { color: #9ca3af !important; }
body.dark-mode .text-gray-300 { color: #6b7280 !important; }
body.dark-mode .text-green-800 { color: #6ee7b7 !important; }
body.dark-mode .text-green-700 { color: #6ee7b7 !important; }
body.dark-mode .bg-green-800 { background: #065f46 !important; }
body.dark-mode .sidebar-header { background-color: rgb(54,124,43) !important; }
body.dark-mode .bg-green-100 { background: #064e3b !important; }
body.dark-mode a.text-green-700 { color: #6ee7b7 !important; }
body.dark-mode a.text-green-700:hover { color: #a7f3d0 !important; }
body.dark-mode footer { background-color: #111827 !important; }
body.dark-mode .leftmenu2 { background-color: #374151; color: #d1d5db; border-color: #4b5563 !important; }
body.dark-mode .text-gray-600 { color: #9ca3af !important; }
body.dark-mode .text-gray-900 { color: #f9fafb !important; }
body.dark-mode a:hover { color: #f87171; }

/* Keep the navbar (and its dropdowns) above any overlays */
#nav-container ul, #nav-container ul ul, #nav-container ul ul ul,
#nav-container ul ul ul ul, #nav-container ul ul ul ul ul { z-index: 2001 !important; }

/* Navbar theme button */
#navThemeBtn:active { transform: scale(0.9); }

/* Embedded graphic (scaled-to-fit; native sizes are baked into the plotly files) */
#unavailable-msg { position: absolute; inset: 0; display: none; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 24px; color: #6b7280; }
body.dark-mode #unavailable-msg { color: #9ca3af; }
body.dark-mode #graphic-spinner { background: rgba(31,41,55,0.8) !important; }
body.dark-mode #graphic-spinner circle { stroke: #6ee7b7; }
body.theme-ready #graphic-card { transition: border-color 0.4s ease; }

/* MapLibre widget mount (MAP tab). Sized to the card; the widget fills it. */
#agmap { width: 100%; height: 700px; position: relative; transition: opacity 0.08s ease; }
/* Park the inactive view offstage instead of display:none, so MapLibre's
   ResizeObserver never sees 0x0 and the drawing buffer never collapses — the
   canvas is already correctly sized on the first visible frame (no flash). */
/* !important: the base rule is an ID selector (#agmap{position:relative}) which
   out-specifies a plain class, so without it the element never parks (it stays
   in flow and the chart lands below it). */
.view-offstage { position: absolute !important; inset: 0 !important;
                 visibility: hidden !important; pointer-events: none !important; }

/* Chart widget mount (the CHART tab; cpcropchart.js) — #agchart is the flow
   BOX beside #agmap in the graphic card; the widget draws the figure at its
   native size on the inner #agchart-fig (created by cpcrop.js) and the kit's
   fitScaled scales that mount to the window, sizing the box to match (the
   template's aspect-ratio / min-height are cleared at runtime — the one fit
   rule of every chart page since 2026-09-10). The inactive tab is parked with
   .view-offstage, exactly like #agmap. */
#agchart { width: 100%; position: relative; transition: opacity 0.08s ease;
           margin: 5px; }   /* the 5 px inset every chart card has (weather host padding, severe box margin); the kit's fitScaled counts it */
#agchart .js-plotly-plot, #agchart .plotly-graph-div { width: 100%; height: 100%; }
/* the figure is transparent and picks up its paper/plot colour from the
   widget's theme, so the mount only has to carry the card's own background */
body.dark-mode #agchart { background: transparent; color: #e5e7eb; }
/* Plotly scales its SVG with a viewBox on export; the default non-scaling
   stroke then renders hairlines at the wrong width (the legacy chart HTML
   carried the same rule). */
#agchart .plotly-graph-div path { vector-effect: none !important; }
