/* ClimateOdds' own stylesheet - a genuinely independent file, NOT shared or
   symlinked with climate_diy's assets/style.css (see navbar.py's own
   docstring for why that separation matters: the two apps' assets/ folders
   used to be the same directory on disk via a whole-folder symlink, so a
   cleanup pass meant for one app's leftover files deleted the other app's
   live CSS/JS instead). Any rule added here only ever affects ClimateOdds. */

/* ── Kill the page-level scrollbar ────────────────────────────────────────
   Two contributing causes, both addressed here:

   1. app.layout's own root div is height:100vh + overflow:hidden
   (ClimateOdds.py) - a deliberate "fixed viewport, every scroll happens in
   a nested internal container" design (the content wrapper/_main/_sidebar
   each have their own overflowY:'auto'). That root div sits INSIDE <body>,
   and browsers give <body> an 8px margin by default - so without this
   reset, the document was 100vh (the div) + 16px (body's own margin)
   tall, taller than the viewport, triggering the browser's own page-level
   scrollbar.

   2. The bigger culprit: dash-bootstrap-components' dbc.Modal -
   specifically the 'Welcome to ClimateOdds!' one, which opens by default
   on page load - inherits react-bootstrap's Modal behavior of adding its
   own INLINE `padding-right` to <body> (and `margin-right` to any
   .sticky-top/.fixed-top/.fixed-bottom element - this app's navbar uses
   sticky='top', see navbar.py) the moment it opens, to visually
   compensate for whatever scrollbar it assumes it's hiding. That inline
   style wins over a plain external CSS rule - only an !important external
   rule can override an inline style that has none of its own, hence both
   rules below. */
html, body {
    margin: 0;
    padding: 0;
    height: 100%;
    overflow: hidden;
}

body,
.sticky-top,
.fixed-top,
.fixed-bottom {
    padding-right: 0 !important;
    margin-right: 0 !important;
}

/* ── Mobile sidebar drawer ───────────────────────────────────────────────
   Same mechanism climate_diy's own mobile sidebar uses (its assets/style.css,
   "#sidebar-col"/"#sidebar-overlay") - ported deliberately rather than
   shared, so the two apps' copies can't accidentally affect each other again.
   On small screens the sidebar becomes a slide-in drawer from the right.
   position:fixed removes it from the flex flow so the main content expands
   to fill the full width automatically. Toggled by ClimateOdds.py's own
   toggle_mobile_sidebar clientside callback (adds/removes the .sidebar-open
   class on #sidebar-col/#sidebar-overlay). */

#sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    z-index: 1049;
    cursor: pointer;
}

@media (max-width: 767px) {
    #sidebar-col {
        position: fixed !important;
        top: 0;
        right: 0;
        height: 100vh;
        width: 92vw !important;
        max-width: 400px;
        z-index: 1050;
        background: white;
        overflow-y: auto !important;
        box-shadow: -6px 0 24px rgba(0, 0, 0, 0.18);
        transform: translateX(105%);
        transition: transform 0.3s ease;
        padding: 12px !important;
    }

    #sidebar-col.sidebar-open {
        transform: translateX(0);
    }

    #sidebar-overlay.sidebar-open {
        display: block;
    }
}

@media (min-width: 768px) {
    #mobile-section-nav,
    #btn-close-sidebar {
        display: none !important;
    }
}

/* ── "X% of the year ... is likely to have suitable conditions in ..."
   (div-summary's sentence rows, calculate() in ClimateOdds.py) - sizes
   kept here (not inline) specifically so the mobile override below can
   win without needing !important. */
.odds-summary-pct {
    font-size: 1.6rem;
}

.odds-summary-text {
    font-size: 1.3rem;
}

@media (max-width: 767px) {
    .odds-summary-pct {
        font-size: 1.15rem;
    }

    .odds-summary-text {
        font-size: 0.95rem;
    }
}

/* ── div-title ("<region> — Suitable conditions for <activity>" + its own
   "Criteria: ..." line below it, calculate() in ClimateOdds.py) - same
   "sizes live here, not inline, so a later media query can win without
   !important" pattern as .odds-summary-pct/-text above. */
.odds-title-text {
    font-size: 1.3rem;
}

.odds-title-criteria {
    font-size: 0.95rem;
}

@media (max-width: 767px) {
    .odds-title-text {
        font-size: 1.05rem;
    }

    .odds-title-criteria {
        font-size: 0.8rem;
    }
}

/* ── Shorter figure on mobile ──────────────────────────────────────────────
   graph-odds' own height (58vh, set as an inline style via dcc.Graph's
   `style` prop in ClimateOdds.py) is otherwise the same on every screen
   size - 58% of viewport height eats into a mobile screen's limited space
   more than it should, with the sidebar/summary text etc. all competing
   for the same vertical room below a small viewport. !important is
   required to win over that inline style. */
@media (max-width: 767px) {
    #graph-odds {
        height: 42vh !important;
    }
}

/* ── Smaller "Figure guide"/"Figure summary" buttons on mobile - so they sit
   side by side instead of wrapping to two rows. dmc.Button's own `size`
   prop is a single Python-side value, so this is done via CSS instead;
   their button text itself is already shortened on mobile in
   ClimateOdds.py (the d-md-none/d-none d-md-inline span pair each one
   wraps). !important needed to win over Mantine's own size='sm' styling. */
@media (max-width: 767px) {
    #btn-explain-figure,
    #btn-ai-summary {
        height: 24px !important;
        min-height: 24px !important;
        padding-left: 8px !important;
        padding-right: 8px !important;
        font-size: 0.68rem !important;
    }
}

/* ── #mobile-section-nav's 4 buttons (Activity/Region/Period/Criteria), on
   mobile - wrapped in a dmc.ButtonGroup in ClimateOdds.py (one connected
   strip instead of 4 separately-bordered buttons in a row), tightened
   here the same way as btn-explain-figure/btn-ai-summary above: shrink
   padding + font-size, selecting via a plain descendant selector
   (`#mobile-section-nav button`) rather than any Mantine-internal class
   name, since those are version-dependent/hashed.

   Two non-obvious parts needed for these 4 to actually fill the row
   without clipping:

   1. Each button's own `style={'flex': '1'}` (ClimateOdds.py) forces all 4
   into an EQUAL quarter-share of the row regardless of label length -
   "Region"/"Period" fit with slack to spare, but "Activity"/"Criteria"
   need more than a quarter, and Mantine's Button root clips overflowing
   label text rather than letting it spill. Fixing this needs each
   longhand set separately (flex-grow/flex-shrink/flex-basis), not a bare
   `flex` shorthand - a shorthand here loses to the inline `style="flex:1
   1 0%"` attribute in some browsers' cascade resolution of shorthand-vs-
   longhand !important rules. flex-basis:auto makes each button's MINIMUM
   width its own content size; flex-shrink:0 means a button can never be
   squeezed thinner than that; flex-grow:1 then lets any left-over row
   width (once every button already has the space its label needs) get
   distributed across all 4.

   2. flex-grow alone isn't enough: it only redistributes LEFTOVER space
   inside its own flex container, but dmc.ButtonGroup's own wrapper div
   (#mobile-section-nav's one and only child, sitting between it and the 4
   buttons) sizes itself to fit its content (shrink-to-fit) rather than
   stretching to fill #mobile-section-nav's own width - so without the
   rule below, there's no leftover space for the buttons to grow into in
   the first place. `#mobile-section-nav > div` (rather than Mantine's own
   hashed/versioned class name - it's the only div #mobile-section-nav
   has, so this can't catch anything else) forces that wrapper itself to
   span the full row. */
@media (max-width: 767px) {
    #mobile-section-nav > div {
        width: 100% !important;
    }

    #mobile-section-nav button {
        flex-grow: 1 !important;
        flex-shrink: 0 !important;
        flex-basis: auto !important;
        padding-left: 6px !important;
        padding-right: 6px !important;
        font-size: 0.72rem !important;
    }
}
