/*
 * This is a manifest file that'll be compiled into application.css.
 *
 * With Propshaft, assets are served efficiently without preprocessing steps. You can still include
 * application-wide styles in this file, but keep in mind that CSS precedence will follow the standard
 * cascading order, meaning styles declared later in the document or manifest will override earlier ones,
 * depending on specificity.
 *
 * Consider organizing styles into separate files for maintainability.
 *
 * This file is linked *after* Bulma in the layout; see the comment there before reordering.
 */

/*
 * Primary colour: light gray (was Bulma's default turquoise).
 *
 * Bulma 1.0 derives every `is-primary` surface from these three variables — the
 * `hero is-primary` band in shared/_header, every `button is-primary`, and all ~20
 * `--bulma-primary-NN` shades — so this is the entire recolour.
 *
 * The selector list is not padding. Bulma sets these in `:root` and *again* in
 * `.theme-light, [data-theme=light]`, which has the same (0,1,0) specificity as `:root`
 * but comes later in its file. Overriding `:root` alone would win on source order only,
 * and would silently stop working if the layout's hardcoded `data-theme="light"` changed.
 * Matching every selector Bulma uses keeps this correct under either theme.
 *
 * `--bulma-primary-invert-l` — the text colour Bulma puts on a primary background — is
 * deliberately left alone. It resolves to 6% lightness, so text on the new gray lands at
 * roughly 13:1 contrast; it needs no adjustment and hardcoding one here would break if
 * the lightness below is retuned.
 */
:root,
.theme-light,
[data-theme=light],
.theme-dark,
[data-theme=dark] {
  --bulma-primary-h: 0deg;
  --bulma-primary-s: 0%;
  --bulma-primary-l: 85%;
}

/*
 * Sticky footer: hold the footer at the bottom of the viewport on short pages.
 *
 * `margin-top: auto` rather than a `flex: 1` content wrapper because the layout yields
 * several top-level sections straight into <body> (the home page emits four) -- there is no
 * single content element to grow, and adding a wrapper would mean touching every view.
 * As the last flex item, the footer's auto top margin absorbs whatever space is left over,
 * which works for any number of siblings and is inert once the content overflows.
 *
 * The two <script> tags at the end of <body> are display: none, so they generate no boxes
 * and never become flex items.
 *
 * 100dvh follows 100vh so browsers that understand it win: on mobile, 100vh is sized
 * against the *expanded* viewport behind a retractable URL bar, which parks the footer
 * just under the fold.
 */
body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
}

body > footer {
  margin-top: auto;
}

/*
 * Mobile header: put the burger on the title's row.
 *
 * shared/_header stacks `p.title` above the whole `nav.navbar`, which is a Bulma layout
 * this markup isn't shaped for. Below the navbar breakpoint the menu is hidden, so the
 * navbar collapses to just `.navbar-brand` — a 3.25rem-tall block sitting under the title
 * (which adds its own 1.5rem margin-bottom), with `.navbar-burger`'s
 * `margin-inline-start: auto` pinning the burger to that block's right edge. The result is
 * a burger stranded on a row of its own, ~60px below the title.
 *
 * Bounded to max-width 1023px — Bulma's navbar breakpoint, the same one that hides
 * `.navbar-burger` and lays the menu out as a row. Desktop is untouched by design.
 */
@media screen and (max-width: 1023px) {
  .header-bar {
    display: flex;
    align-items: center;
    gap: 1rem;
  }

  /* Would otherwise push the navbar down as if it were still a stacked block. */
  .header-bar > .title:not(:last-child) {
    margin-bottom: 0;
  }

  /* Right-aligns the burger against the hero padding. .navbar is a plain block in Bulma,
     so as a flex item it shrink-wraps the brand and this margin does the pushing --
     .navbar-burger's own margin-inline-start only centres it within .navbar-brand. */
  .header-bar > .navbar {
    margin-inline-start: auto;
    /* Bulma sets .navbar to position: relative, which would make it the containing block
       for the absolutely-positioned open menu below -- pinning the menu to the burger's
       ~46px width instead of the hero's. Static hands that role to .hero-body. */
    position: static;
  }

  /*
   * The open menu cannot simply wrap onto the next line: it is a child of .navbar, not a
   * sibling of the title, so it is not a flex item of .header-bar. (`display: contents` on
   * the nav would make it one, but it also drops the navigation landmark from the
   * accessibility tree, and this nav carries role="navigation" and an aria-label.)
   * Floating it under the bar keeps the DOM and the landmark intact. Bulma already gives
   * .navbar-menu a background and box-shadow at this breakpoint, so it reads as a dropdown
   * panel; z-index matches Bulma's own --bulma-navbar-z.
   */
  .hero-body:has(> .header-bar) {
    position: relative;
  }

  .header-bar .navbar-menu.is-active {
    position: absolute;
    inset-inline: 0;
    top: 100%;
    z-index: 30;
  }
}
