/* IMF UG site styles (no framework) */

/* ---------- Colours: light by default, dark when the system asks for it ---------- */
:root {
  color-scheme: light dark;
  --text: #212529;
  --text-muted: rgba(33, 37, 41, .75);
  --text-strong: #000;
  --bg: #fff;
  --bg-subtle: #f8f9fa;
  --hover: rgba(0, 0, 0, .075);
  --border: #dee2e6;
  --border-soft: rgba(0, 0, 0, .175);
  --link: #0d6efd;
  --link-hover: #0a58ca;
  --accent: #0d6efd;   /* active menu item */
  --on-accent: #fff;
  --code: #d63384;
  --radius: .375rem;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", "Noto Sans", "Liberation Sans", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
  --mono: SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}
@media (prefers-color-scheme: dark) {
  :root {
    --text: #dee2e6;
    --text-muted: rgba(222, 226, 230, .75);
    --text-strong: #fff;
    --bg: #212529;
    --bg-subtle: #2b3035;
    --hover: rgba(255, 255, 255, .075);
    --border: #495057;
    --border-soft: rgba(255, 255, 255, .15);
    --link: #6ea8fe;
    --link-hover: #8bb9fe;
    --code: #e685b5;
  }
}

/* ---------- Base ---------- */
*, ::before, ::after { box-sizing: border-box; }
body {
  margin: 0;
  font-family: var(--font); font-size: 1rem; line-height: 1.5;
  color: var(--text); background-color: var(--bg);
  -webkit-text-size-adjust: 100%;
}
h1, h2, h3, h4, h5, h6 { margin: 0 0 .5rem; font-weight: 500; line-height: 1.2; }
h1 { font-size: calc(1.375rem + 1.5vw); }
h2 { font-size: calc(1.325rem + .9vw); }
h3 { font-size: calc(1.3rem + .6vw); }
h4 { font-size: calc(1.275rem + .3vw); }
h5 { font-size: 1.25rem; }
h6 { font-size: 1rem; }
@media (min-width: 1200px) {
  h1 { font-size: 2.5rem; }
  h2 { font-size: 2rem; }
  h3 { font-size: 1.75rem; }
  h4 { font-size: 1.5rem; }
}
p, ul, ol, dl, pre, blockquote, figure { margin: 0 0 1rem; }
ul, ol { padding-left: 2rem; }
li > ul, li > ol { margin-bottom: 0; }
small { font-size: .875em; }
b, strong { font-weight: bolder; }
a { color: var(--link); }
a:hover { color: var(--link-hover); }
img, svg { vertical-align: middle; }
img { max-width: 100%; height: auto; }
iframe { border: 0; max-width: 100%; }
.content iframe { height: auto; aspect-ratio: 16 / 9; } /* embedded videos keep their shape when narrowed */
hr { margin: 1rem 0; border: 0; border-top: 1px solid; opacity: .25; }
code, pre { font-family: var(--mono); font-size: .875em; }
code { color: var(--code); overflow-wrap: break-word; }
pre { overflow: auto; }
pre code, a > code { color: inherit; font-size: inherit; }
table { border-collapse: collapse; }
th { text-align: inherit; }

/* ---------- Page layout: sidebar + main column, stacked on narrow screens ---------- */
.site { max-width: 64rem; margin: 0 auto; }
@media (min-width: 768px) {
  .site { display: grid; grid-template-columns: 1fr 3fr; }
}
.sidebar { padding: 1rem; border-right: 1px solid var(--border); }
.main { padding: 0 .75rem; min-width: 0; }
@media (min-width: 768px) {
  .main { padding: 0 1.5rem; }
}
main { padding: 1.5rem 0; }
footer {
  padding: 1rem 0; border-top: 1px solid var(--border);
  font-size: .875em; color: var(--text-muted);
}

/* ---------- Sidebar ---------- */
.brand { display: block; margin-bottom: .5rem; }
.brand img { display: block; width: 10rem; }
.site-title {
  display: block; font-size: calc(1.325rem + .9vw); font-weight: 700;
  color: var(--text); text-decoration: none;
}
@media (min-width: 1200px) {
  .site-title { font-size: 2rem; }
}
.site-title:hover { color: var(--text); }

.nav-toggle {
  display: none; padding: .375rem; flex: none;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: none; color: var(--text); cursor: pointer;
}
.nav-toggle svg { display: block; width: 1.5rem; height: 1.5rem; }
.tagline { margin: .25rem 0 1rem; font-size: .875em; color: var(--text-muted); }

.social { display: flex; gap: 1.25rem; margin: -.25rem 0 1rem; }
.social a { display: block; color: var(--text-muted); transition: color .15s ease-in-out; }
.social a:hover { color: var(--link); }
.social svg { display: block; width: 1.5rem; height: 1.5rem; }

.menu { display: flex; flex-wrap: wrap; gap: .25rem; }
@media (min-width: 768px) {
  .menu { flex-direction: column; }
}
.submenu { display: flex; flex-direction: column; gap: .25rem; margin-left: 1rem; }
.menu-link {
  display: block; padding: .25rem 1rem; border-radius: var(--radius);
  color: var(--link); text-decoration: none;
  transition: color .15s ease-in-out, background-color .15s ease-in-out;
}
.menu-link.active, .menu-link.active:hover { color: var(--on-accent); background-color: var(--accent); }
summary.menu-link { cursor: pointer; list-style: none; }
summary.menu-link::-webkit-details-marker { display: none; }
.caret { display: inline-block; font-size: .875em; transition: transform .15s ease-in-out; }
details:not([open]) > summary .caret { transform: rotate(-90deg); }
#search { margin-top: 1rem; }

/* Pagefind search uses the site colours */
.pagefind-ui {
  --pagefind-ui-primary: var(--accent);
  --pagefind-ui-text: var(--text);
  --pagefind-ui-background: var(--bg);
  --pagefind-ui-border: var(--border);
  --pagefind-ui-tag: var(--bg-subtle);
}

/* Narrow screens: logo, title, search and menu button share one row, the tagline sits below,
   and the social links and menu collapse behind the button */
@media (max-width: 767.98px) {
  .sidebar {
    display: flex; flex-wrap: wrap; align-items: center; column-gap: .75rem;
    border-right: 0; border-bottom: 1px solid var(--border);
  }
  .sidebar-head { display: contents; }
  .brand { order: 1; margin-bottom: 0; flex: none; }
  .brand img { width: 3rem; }
  .site-title { order: 2; font-size: 1.25rem; }
  #search { order: 3; flex: 1; min-width: 0; margin-top: 0; }
  .nav-toggle { order: 4; }
  .tagline { order: 5; flex-basis: 100%; margin: .75rem 0 0; }
  .sidebar-nav { order: 6; flex-basis: 100%; padding-top: 1rem; }
  .sidebar-nav .social { margin-top: 0; }
  .sidebar-nav .menu { flex-direction: column; }
  .js .nav-toggle { display: block; }
  .js .sidebar-nav:not(.open) { display: none; }

  /* Compact search box whose results drop down across the full width of the page */
  .pagefind-ui { --pagefind-ui-scale: .75; }
  #search .pagefind-ui__drawer {
    position: absolute; z-index: 10; top: calc(100% + .5rem);
    right: calc(-3rem - 2px); width: calc(100vw - 2rem);
    max-height: 70vh; overflow-y: auto; padding: 0 1rem 1rem;
    background-color: var(--bg); border: 1px solid var(--border); border-radius: var(--radius);
    box-shadow: 0 .5rem 1rem rgba(0, 0, 0, .15);
  }
}

/* ---------- Front page hero ---------- */
.hero {
  margin-bottom: 2rem; padding: 2rem 1.5rem;
  border-radius: var(--radius); background-color: var(--bg-subtle);
  border: 1px solid var(--border-soft);
}
.hero h1 { margin-bottom: .75rem; font-weight: 700; }
.hero .lead { max-width: 40rem; font-size: 1.15rem; color: var(--text-muted); }
.hero .lead > :last-child { margin-bottom: 0; }
.buttons { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: 1.25rem; }
.button {
  display: inline-block; padding: .5rem 1rem; border-radius: var(--radius);
  border: 1px solid var(--accent); color: var(--link); text-decoration: none; font-weight: 500;
  transition: color .15s ease-in-out, background-color .15s ease-in-out;
}
.button:hover { color: var(--on-accent); background-color: var(--accent); }
.button.primary { color: var(--on-accent); background-color: var(--accent); }
.button.primary:hover { background-color: var(--link-hover); border-color: var(--link-hover); }

/* ---------- Posts and lists ---------- */
.meta { font-size: .875em; color: var(--text-muted); }
.banner { display: block; margin-top: 1rem; border-radius: var(--radius); }

.post-card {
  margin-bottom: 1.5rem; overflow: hidden;
  border: 1px solid var(--border-soft); border-radius: var(--radius);
  box-shadow: 0 .125rem .25rem rgba(0, 0, 0, .075);
}
.post-card > header { padding: .5rem 1rem; background-color: var(--bg-subtle); border-bottom: 1px solid var(--border-soft); }
.post-card .banner { width: 100%; margin: 0; border-radius: 0; }
.post-card .content { margin: 0; padding: 1rem; }
.post-title { margin: .25rem 0 0; font-weight: 600; }
.post-title a { color: var(--text); text-decoration: none; }

.post-list { padding-left: 0; list-style: none; }
.post-list .meta { margin-right: .5rem; }
.events { margin-top: 1rem; }
.events li { margin-bottom: .5rem; }
.events .meta { display: block; margin-right: 0; }

/* Page contents list (front matter: toc: true) */
.toc { margin-top: 1rem; padding: .5rem 1rem; border: 1px solid var(--border); border-radius: var(--radius); }
.toc-title { margin-bottom: .25rem; font-size: .875em; font-weight: 600; color: var(--text-muted); }
.toc ol { margin: 0; padding-left: 0; list-style: none; }
.toc ol ol { padding-left: 1rem; }
.toc li { margin: .15rem 0; }
.toc a { text-decoration: none; }

/* ---------- Rendered Markdown content ---------- */
.content { margin-top: 1rem; }
.content h2 { margin-top: 3rem; font-size: calc(1.3rem + .6vw); }
@media (min-width: 1200px) {
  .content h2 { font-size: 1.75rem; }
}
.content li { margin-top: 1rem; }
.content blockquote {
  padding-left: 1rem; font-size: 1.25rem;
  border-left: 1px solid var(--border); color: var(--text-muted);
}
.content blockquote > :last-child { margin-bottom: 0; }

.content table { width: 100%; margin-bottom: 1rem; vertical-align: top; }
.content th, .content td { padding: .25rem; color: var(--text-strong); border-bottom: 1px solid var(--border); }
.content thead { vertical-align: bottom; }
.content tbody { vertical-align: inherit; }
.content tbody tr:hover > * { background-color: var(--hover); }
.content thead:not(:has(th:not(:empty))) { display: none; } /* empty header rows from Markdown tables */
.content td:has(> img, > a > img) { width: 25%; }            /* cells holding an image get a bounded width */

/* Framed images, e.g. on the Logo page: <img class="thumbnail"> (add "wide" for a quarter-width image) */
.thumbnail { padding: .25rem; background-color: var(--bg); border: 1px solid var(--border); border-radius: var(--radius); }
.thumbnail.wide { width: 25%; }
