/* ---------------------------------------------------------------------------
   BluKo — minimal structural stylesheet.
   Deliberately plain: dark gray on white, no brand colours, no decoration.
   The point of this pass is to make the structure legible, not pretty.
   --------------------------------------------------------------------------- */

:root {
  --ink:        #333333;
  --ink-strong: #111111;
  --ink-muted:  #6b6b6b;
  --rule:       #dcdcdc;
  --surface:    #ffffff;
  --surface-alt:#f6f6f6;

  --measure:  42rem;  /* comfortable reading width */
  --page:     68rem;  /* outer container width     */
  --gap:      1.5rem;
  --header-h: 4.75rem;/* the sticky header's height — anchors clear this */
}

*, *::before, *::after { box-sizing: border-box; }

/* Jumping to an anchor — a heading link, or "Skip to content" — would otherwise
   land the target underneath the sticky header. */
html {
  -webkit-text-size-adjust: 100%;
  scroll-padding-top: calc(var(--header-h) + 1rem);
}

body {
  margin: 0;
  background: var(--surface);
  color: var(--ink);
  font: 16px/1.65 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
        "Helvetica Neue", Arial, sans-serif;
}

img { max-width: 100%; height: auto; }

a { color: var(--ink-strong); text-decoration: underline; text-underline-offset: 2px; }
a:hover { color: var(--ink-muted); }

.container {
  width: 100%;
  max-width: var(--page);
  margin-inline: auto;
  padding-inline: var(--gap);
}

.skip-link {
  position: absolute;
  left: -9999px;
}
.skip-link:focus {
  left: var(--gap);
  top: var(--gap);
  z-index: 100;
  background: var(--surface);
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--ink);
}

/* --- Header ---------------------------------------------------------------- */

/* Sticky: the knowledge pages are long, and the menu is the only way between
   sections. It stays in flow, so nothing below needs its height compensated.
   The z-index sits above page content but below `.skip-link`, which has to be
   reachable over everything. */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  border-bottom: 1px solid var(--rule);
  background: var(--surface);
}

.site-header__inner {
  display: flex;
  align-items: center;
  gap: var(--gap);
  flex-wrap: wrap;
  padding-block: 1rem;
}

.site-header__brand { display: inline-flex; text-decoration: none; }
.site-header__brand img { display: block; height: 32px; width: auto; }

.site-header__cta { margin-left: auto; }

/* --- Navigation ------------------------------------------------------------ */

.nav__list { list-style: none; margin: 0; padding: 0; }

.nav__list--top {
  display: flex;
  gap: 1.5rem;
  align-items: center;
}

.nav__link {
  display: block;
  padding-block: 0.25rem;
  text-decoration: none;
  color: var(--ink);
  white-space: nowrap;
}
.nav__link:hover { color: var(--ink-strong); text-decoration: underline; }
.nav__link.is-current,
.nav__link.is-ancestor { color: var(--ink-strong); font-weight: 600; }

/* Nested levels: shown as a dropdown on pointer devices. The rule is written
   generically, so a third or fourth level needs no extra CSS. */
.nav__list--top .nav__item--parent { position: relative; }

.nav__list--top .nav__list--sub {
  position: absolute;
  top: 100%;
  left: 0;
  min-width: 16rem;
  padding: 0.5rem 0;
  background: var(--surface);
  border: 1px solid var(--rule);
  display: none;
  z-index: 20;
}

.nav__list--top .nav__item--parent:hover > .nav__list--sub,
.nav__list--top .nav__item--parent:focus-within > .nav__list--sub { display: block; }

.nav__list--top .nav__list--sub .nav__link { padding: 0.35rem 1rem; white-space: normal; }

/* Deeper levels fly out to the side rather than stacking on top. */
.nav__list--top .nav__list--sub .nav__list--sub { top: 0; left: 100%; }

/* --- Mobile menu (CSS only) ------------------------------------------------ */

.nav-toggle { position: absolute; opacity: 0; pointer-events: none; }

.nav-toggle__label {
  display: none;
  margin-left: auto;
  padding: 0.35rem 0.75rem;
  border: 1px solid var(--rule);
  cursor: pointer;
  font-size: 0.9rem;
}

@media (max-width: 800px) {
  .nav-toggle__label { display: inline-block; }

  .nav { display: none; width: 100%; }
  .nav-toggle:checked ~ .nav { display: block; }

  /* Fifteen entries, every submenu expanded: open, the menu is taller than a
     phone in landscape. A sticky header cannot scroll out of the way, so it
     has to scroll internally or its last items are unreachable. Safe only at
     this breakpoint — here the submenus are static, so nothing overflows the
     header's box for `overflow-y` to clip. */
  .site-header {
    max-height: 100vh;
    max-height: 100dvh;
    overflow-y: auto;
  }

  .site-header__cta { margin-left: 0; }

  .nav__list--top { display: block; }

  /* Everything is expanded on small screens — no hover to rely on. */
  .nav__list--top .nav__list--sub {
    position: static;
    display: block;
    border: 0;
    padding: 0 0 0 1rem;
    min-width: 0;
  }
  .nav__list--top .nav__list--sub .nav__link { padding: 0.25rem 0; }
}

/* --- Page scaffolding ------------------------------------------------------ */

.site-main { padding-block: 2.5rem 4rem; }

/* No page reserves room for a sidebar any more, so body copy spans the whole
   container and lines its edges up with the card grids. Images are the
   exception: at full width the BluKo graphic and the funding logo would tower
   over the text around them, so they keep the reading measure. */
.page__body { max-width: none; }
.page__body img { max-width: var(--page); }
.page__title { margin-top: 0; }

.breadcrumbs { margin-bottom: 1.5rem; font-size: 0.875rem; color: var(--ink-muted); }
.breadcrumbs ol { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 0.5rem; }
.breadcrumbs li + li::before { content: "/"; margin-right: 0.5rem; color: var(--rule); }
.breadcrumbs a { color: var(--ink-muted); }

/* --- Hero ------------------------------------------------------------------ */

.hero {
  border-bottom: 1px solid var(--rule);
  background: var(--surface-alt);
  padding-block: 3.5rem;
}

/* The hero is the first thing in `<main>` and carries its own background, so it
   butts straight against the header instead of floating on a white strip. */
.layout-home .site-main { padding-top: 0; }

/* `.prose p` has no top margin and `.container` no block padding, so the first
   line of text would otherwise sit flush against the hero's bottom border.
   This is padding on the following block rather than a margin on the hero:
   padding is never collapsed away, so the gap cannot silently vanish. */
.hero + .page { padding-top: 3rem; }

.hero__title { margin: 0 0 0.75rem; font-size: 2rem; line-height: 1.2; color: var(--ink-strong); }
.hero__lead { margin: 0; max-width: var(--measure); font-size: 1.125rem; color: var(--ink-muted); }

/* --- Cards & section listings ---------------------------------------------- */

.home-section { margin-top: 3rem; }
.home-section__title { margin: 0 0 0.25rem; font-size: 1.35rem; }
.home-section__title a { text-decoration: none; }
.home-section__title a:hover { text-decoration: underline; }
.home-section__summary { margin: 0 0 1.25rem; color: var(--ink-muted); }

.card-grid {
  list-style: none;
  margin: 2rem 0 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(17rem, 1fr));
  gap: 1rem;
}

.card {
  border: 1px solid var(--rule);
  padding: 1.25rem;
}
.card__title { margin: 0 0 0.4rem; font-size: 1.05rem; }
.card__title a { text-decoration: none; }
.card__title a:hover { text-decoration: underline; }
.card__summary { margin: 0; color: var(--ink-muted); font-size: 0.95rem; }
.card__children { margin: 0.75rem 0 0; padding-left: 1.1rem; font-size: 0.9rem; }

/* --- Prose ----------------------------------------------------------------- */

.prose h1 { font-size: 1.9rem; line-height: 1.25; color: var(--ink-strong); }
.prose h2 { font-size: 1.35rem; margin-top: 2.25rem; color: var(--ink-strong); }
.prose h3 { font-size: 1.1rem; margin-top: 1.75rem; color: var(--ink-strong); }

.prose p, .prose ul, .prose ol { margin-block: 0 1rem; }
.prose ul, .prose ol { padding-left: 1.4rem; }
.prose li { margin-bottom: 0.35rem; }

.prose .lead { font-size: 1.125rem; color: var(--ink-muted); }

.prose blockquote {
  margin: 1.5rem 0;
  padding-left: 1rem;
  border-left: 3px solid var(--rule);
  color: var(--ink-muted);
}

.prose code {
  background: var(--surface-alt);
  padding: 0.1em 0.35em;
  font-size: 0.9em;
}
.prose pre {
  background: var(--surface-alt);
  padding: 1rem;
  overflow-x: auto;
  border: 1px solid var(--rule);
}
.prose pre code { background: none; padding: 0; }

/* Wide tables must scroll inside themselves, never the page. kramdown emits a
   bare <table> with no wrapper to hang overflow on, so the table is its own
   scroll container — `display: block` is what makes overflow-x apply. */
.prose table {
  display: block;
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  border-collapse: collapse;
  margin-bottom: 1.5rem;
}
.prose th, .prose td { border: 1px solid var(--rule); padding: 0.5rem 0.75rem; text-align: left; }
.prose th { background: var(--surface-alt); }

.prose hr { border: 0; border-top: 1px solid var(--rule); margin-block: 2.5rem; }

/* --- Figures & diagrams ----------------------------------------------------- */

.prose figure { margin: 2rem 0; }
.prose figcaption {
  margin-top: 0.75rem;
  font-size: 0.875rem;
  line-height: 1.5;
  color: var(--ink-muted);
}

/* Same bargain as wide tables: the diagram scrolls inside its own box rather
   than shrinking its labels into illegibility on a phone. `min-width` wins over
   the global `img { max-width: 100% }`, which is what forces the overflow. */
.diagram__scroll { overflow-x: auto; }
.diagram__scroll img { display: block; min-width: 38rem; max-width: 100%; }

/* --- Buttons --------------------------------------------------------------- */

.button {
  display: inline-block;
  padding: 0.45rem 0.9rem;
  border: 1px solid var(--ink);
  text-decoration: none;
  font-size: 0.95rem;
  white-space: nowrap;
}
.button--primary { background: var(--ink-strong); color: #fff; border-color: var(--ink-strong); }
.button--primary:hover { background: var(--ink); color: #fff; }

/* --- Icons ----------------------------------------------------------------- */

/* Sized in `em`, coloured with `currentColor`: an icon takes the size and
   colour of whatever text it sits in, so it needs no variant per context.
   `.icon` is the <span> wrapper and owns the box; the <svg> just fills it.
   See _includes/icon.html for usage and for why the wrapper exists. */
.icon {
  display: inline-block;
  width: 1em;
  height: 1em;
  flex: none;               /* keep its box in a flex row that runs out of space */
  vertical-align: -0.125em; /* optical baseline — `baseline` sits too high */
}

.icon > svg {
  display: block;           /* kill the inline descender gap under the glyph */
  width: 100%;
  height: 100%;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.icon--lg { width: 1.5em; height: 1.5em; }
.icon--xl { width: 2rem;  height: 2rem; }
.icon--xl > svg { stroke-width: 1.5; }  /* thinner lines read better large */

/* An icon above a card's heading rather than inline with it. */
.card__icon { display: block; margin-bottom: 0.6rem; color: var(--ink-muted); }

/* --- Callouts -------------------------------------------------------------- */

/* Written in Markdown as GitHub alerts — `> [!WARNING]` — and converted by
   _plugins/callouts.rb. Every type shares this box and differs only in the
   accent below. */
.callout {
  --callout-accent: var(--ink);
  margin-block: 1.5rem;
  padding: 1rem 1.25rem;
  border: 1px solid var(--rule);
  border-left: 3px solid var(--callout-accent);
  background: var(--surface-alt);
}

/* The body's last paragraph would otherwise push the box 1rem taller than the
   padding at the top of it. */
.callout > :last-child { margin-bottom: 0; }

.callout__label {
  display: flex;
  align-items: center;
  gap: 0.7rem;              /* icon to label text */
  margin: 0 0 0.5rem;
  font-weight: 600;
  color: var(--callout-accent);
}
.callout__label .icon { width: 1.15em; height: 1.15em; vertical-align: 0; }

/* Code shares `--surface-alt` with the callout, so inside one it would be
   invisible. Flip it to the page background to keep the contrast. */
.callout code,
.callout pre { background: var(--surface); }

/* The one place this stylesheet uses colour, because distinguishing a warning
   from a note is the whole job of a callout — and the icon and label alone do
   not carry across a quick scan of the page. Each is dark enough for WCAG AA
   body text on both the callout background and white (≥ 5.4:1). */
.callout--note      { --callout-accent: #2f5f92; }
.callout--tip       { --callout-accent: #1f6b40; }
.callout--important { --callout-accent: #6b4fa0; }
.callout--warning   { --callout-accent: #8a5a00; }
.callout--caution   { --callout-accent: #a33a3a; }

/* --- Footer ---------------------------------------------------------------- */

.site-footer {
  border-top: 1px solid var(--rule);
  padding-block: 2.5rem;
  font-size: 0.9rem;
}

.site-footer__nav {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr));
  gap: 2rem;
}
.site-footer__group ul { list-style: none; margin: 0; padding: 0; }
.site-footer__group li { margin-bottom: 0.3rem; }
.site-footer__group a { color: var(--ink); text-decoration: none; }
.site-footer__group a:hover { text-decoration: underline; }

.site-footer__group-title {
  margin: 0 0 0.6rem;
  font-size: 0.8rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-muted);
}
.site-footer__group-title a { color: inherit; }

.site-footer__legal {
  margin: 2.5rem 0 0;
  padding-top: 1.25rem;
  border-top: 1px solid var(--rule);
  color: var(--ink-muted);
}

/* --- Extra classes to use in markdown --------------------------------------- */

img.centered {
  display: block;
  margin-inline: auto;
}
