/* =========================================================
   Zwergenburg Frömern – mdweb theme stylesheet
   Ported from the original hand-written stylesheet and re-pointed to
   mdweb's template/nav DOM. Colours flow through :root custom properties
   with a prefers-color-scheme: dark override. No external requests.
   ========================================================= */

/* ---------- Colour tokens (light default + dark override) ---------- */
:root {
  --bg: #fafafa;          /* page background behind the content panel */
  --content-bg: #fff;     /* nav bar, content, footer */
  --text: #333;
  --text-strong: #222;    /* links, entry-title, bold headings */
  --muted: #767676;       /* secondary text, hover */
  --heading: #666;        /* h2 */
  --border: #eee;
  --border-strong: #bbb;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121212;
    --content-bg: #1a1a1a;
    --text: #dcdcdc;
    --text-strong: #f2f2f2;
    --muted: #9a9a9a;
    --heading: #bcbcbc;
    --border: #333;
    --border-strong: #555;
  }
}

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

html {
  -webkit-text-size-adjust: 100%;
  -ms-text-size-adjust: 100%;
  overflow-x: hidden;
}

body {
  margin: 0;
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
  font-size: 0.9375rem; /* 15px */
  line-height: 1.66;
  background-color: var(--bg);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

img {
  border-style: none;
  max-width: 100%;
  height: auto;
  vertical-align: bottom;
}

figure {
  margin: 0 0 1em;
}

/* Captions for mdweb's caption feature: figcaption for image/code/quote
   figures, <caption> for tables. Muted italic, below the element. */
figcaption,
caption {
  color: var(--muted);
  font-size: 0.8125rem;
  font-style: italic;
  line-height: 1.5;
  margin-top: 0.5em;
  text-align: center;
}

caption {
  caption-side: bottom;
}

a {
  color: var(--text-strong);
  text-decoration: none;
  box-shadow: 0 1px 0 0 currentColor;
  transition: color 0.2s, box-shadow 0.2s;
}

a:hover,
a:focus {
  color: var(--muted);
  box-shadow: none;
}

h1, h2, h3, h4, h5, h6 {
  clear: both;
  line-height: 1.4;
  margin: 0 0 0.75em;
  padding: 1.5em 0 0;
}

h1:first-child, h2:first-child, h3:first-child,
h4:first-child, h5:first-child, h6:first-child {
  padding-top: 0;
}

h1 { font-size: 1.5rem;  font-weight: 300; }
h2 { font-size: 1.25rem; font-weight: 300; color: var(--heading); }
h3 { font-size: 1.125rem; font-weight: 300; color: var(--text); }
h4 { font-size: 1rem;    font-weight: 800; color: var(--text-strong); }
h5 { font-size: 0.8125rem; font-weight: 800; color: var(--muted);
     letter-spacing: 0.15em; text-transform: uppercase; }
h6 { font-size: 0.9375rem; font-weight: 800; color: var(--text-strong); }

/* Hide the permalink anchors mdweb injects into headings so the pages match
   the original (which has none). They stay reachable for assistive tech. */
.header-anchor {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
  box-shadow: none;
}

p { margin: 0 0 1.5em; padding: 0; }

strong { font-weight: 700; }

blockquote {
  color: var(--heading);
  font-size: 1.125rem;
  font-style: italic;
  line-height: 1.7;
  margin: 0 0 1.5em;
  padding: 0;
  overflow: hidden;
}

blockquote cite {
  display: block;
  font-style: normal;
  font-weight: 600;
  margin-top: 0.5em;
  color: var(--muted);
}

ul, ol { margin: 0 0 1.5em 1.5em; padding: 0; }
ul li, ol li { margin-bottom: 0.25em; }
ul ul, ol ol, ul ol, ol ul { margin-bottom: 0; margin-left: 1.5em; }

table {
  border-collapse: collapse;
  width: 100%;
  margin: 0 0 1.5em;
}

td, th {
  border: 0;
  padding: 0.5em 0.75em;
  vertical-align: top;
}

tr {
  border-bottom: 1px solid var(--border);
}

th {
  border-bottom: 2px solid var(--border-strong);
  text-align: left;
  font-weight: 700;
}

/* ---------- Layout container ---------- */
.wrap {
  margin: 0 auto;
  max-width: 1000px;
  padding: 0 1.5em;
}

/* ---------- Site header ---------- */
.site-header {
  background-color: var(--bg);
  position: relative;
}

/* The header image fills the .custom-header area, with the white-on-dark
   title text overlaid on it. The area sizes itself to its content. */
.custom-header {
  position: relative;
  overflow: hidden;
}

.custom-header-media {
  position: absolute;
  inset: 0;
  z-index: 0;
}

.custom-header-media img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.custom-header-media::after {
  /* dark gradient overlay so the white title text stays readable */
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(to bottom,
    rgba(0, 0, 0, 0) 0%,
    rgba(0, 0, 0, 0.3) 75%,
    rgba(0, 0, 0, 0.3) 100%);
  pointer-events: none;
  z-index: 1;
}

.site-branding {
  position: relative;
  z-index: 2;
  padding: 1.5em 0;
}

.site-branding-text {
  text-align: left;
}

.site-title {
  margin: 0;
  padding: 0;
  font-size: 1.5rem;
  font-weight: 800;
  line-height: 1.25;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* Title text sits on the fixed dark gradient, so white is correct in both
   colour schemes. */
.site-title,
.site-title a,
.site-description {
  color: #fff;
}

.site-title a {
  box-shadow: none;
}

.site-description {
  margin: 0;
  font-size: 0.8125rem;
  font-weight: 400;
  opacity: 0.85;
}

/* ---------- Navigation ---------- */
.navigation-top {
  background: var(--content-bg);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  font-size: 1rem;
  position: relative;
  z-index: 4;
}

.navigation-top .wrap {
  padding: 0;
}

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

.menu-toggle {
  display: block;
  width: 100%;
  background: transparent;
  border: 0;
  color: var(--text-strong);
  font-size: 0.875rem;
  font-weight: 800;
  text-align: center;
  text-transform: none;
  cursor: pointer;
  padding: 1em;
  margin: 0;
  line-height: 1.5;
}

.menu-toggle::before {
  content: "\2630"; /* ≡ */
  display: inline-block;
  margin-right: 0.5em;
  font-weight: 400;
  font-size: 1.1em;
  vertical-align: -1px;
}

.menu-toggle-checkbox:checked ~ .menu-toggle::before {
  content: "\2715"; /* ✕ */
}

.topnav ul {
  list-style: none;
  margin: 0;
  padding: 0;
  border-top: 1px solid var(--border);
  display: none;
}

.menu-toggle-checkbox:checked ~ .topnav ul {
  display: block;
}

.topnav li {
  border-bottom: 1px solid var(--border);
  margin: 0;
  padding: 0 1.5em;
}

.topnav li:last-child {
  border-bottom: 0;
}

.topnav a {
  display: block;
  padding: 0.6em 0;
  color: var(--text-strong);
  font-weight: 600;
  text-decoration: none;
  box-shadow: none;
}

.topnav a:hover,
.topnav a:focus,
.topnav a.active {
  color: var(--muted);
}

/* ---------- Site content area ---------- */
.site-content-contain {
  background-color: var(--content-bg);
  position: relative;
}

.site-content {
  padding: 2.5em 0 0;
}

/* ---------- Article layout ---------- */
.entry-header {
  margin-bottom: 1.5em;
}

.entry-title {
  margin: 0;
  padding: 0;
  color: var(--text-strong);
  font-size: 0.875rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  line-height: 1.4;
}

.entry-content > *:first-child {
  margin-top: 0;
  padding-top: 0;
}

.entry-content h2,
.entry-content h3 {
  padding-top: 1em;
}

.entry-content figure,
.entry-content p > img {
  margin: 1.5em 0;
}

/* Keep the caption flush to a code/quote figure by dropping the element's own
   bottom margin inside a figure. */
.entry-content figure > pre,
.entry-content figure > blockquote {
  margin: 0;
}

.entry-content img {
  display: block;
  margin: 0 auto;
}

/* ---------- Footer ---------- */
.site-footer {
  border-top: 1px solid var(--border);
  background-color: var(--content-bg);
  padding: 1.5em 0;
}

/* ---------- Skip link / a11y helpers ---------- */
.screen-reader-text {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
}

.skip-link:focus {
  left: 0;
  background: var(--content-bg);
  padding: 0.5em 1em;
  z-index: 100;
}

/* ---------- Home page: fixed 75vh hero ----------
   The original site gave ONLY the home page a header image that stays put
   (position: fixed) while the white content panel scrolls up over it. mdweb
   renders one page.html for every page, but it stamps class="active" on the
   current page's nav link, so on the home page the index.html nav link is
   active. We key off that with :has() to scope these rules to the home page
   alone — no template logic, no content markers. Browsers without :has()
   (pre-2023) simply fall back to the uniform header. The branding title link
   also points to index.html, but it is neither .active nor inside .topnav,
   so it is excluded. */
body:has(.topnav a.active[href="index.html"]) .custom-header {
  height: 75vh;
  min-height: 320px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}

/* The stationary image: fixed to the viewport so content slides over it. */
body:has(.topnav a.active[href="index.html"]) .custom-header-media {
  position: fixed;
  inset: 0;
  overflow: hidden;
}

body:has(.topnav a.active[href="index.html"]) .custom-header-media img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Layer branding, nav, and the opaque content panel above the fixed image. */
body:has(.topnav a.active[href="index.html"]) .site-branding,
body:has(.topnav a.active[href="index.html"]) .navigation-top {
  position: relative;
  z-index: 2;
}

body:has(.topnav a.active[href="index.html"]) .site-content-contain {
  position: relative;
  z-index: 2;
  background-color: var(--content-bg);
}

body:has(.topnav a.active[href="index.html"]) .site-branding {
  padding-bottom: 1.5em;
}

/* ---------- Responsive: tablets and up ---------- */
@media (min-width: 30em) {
  body { font-size: 1rem; }

  h1 { font-size: 1.875rem; }
  h2 { font-size: 1.625rem; }
  h3 { font-size: 1.375rem; }
  h4 { font-size: 1.125rem; }
  h6 { font-size: 1rem; }

  .site-branding { padding: 3em 0; }

  body:has(.topnav a.active[href="index.html"]) .site-branding {
    padding: 1.5em 0 2em;
  }
}

@media (min-width: 48em) {
  body {
    font-size: 1rem;
    line-height: 1.5;
  }

  .wrap {
    padding-left: 3em;
    padding-right: 3em;
  }

  /* Larger entry title on desktop, retaining the uppercase look */
  .entry-title {
    font-size: 1.625rem;
    letter-spacing: 0.14em;
  }

  /* ---------- Horizontal navigation ---------- */
  .navigation-top {
    font-size: 0.875rem;
  }

  .navigation-top .wrap {
    padding: 0.75em 3em;
    max-width: 1000px;
  }

  .menu-toggle {
    display: none;
  }

  .topnav ul {
    display: flex !important;
    flex-wrap: wrap;
    justify-content: flex-start;
    border-top: 0;
  }

  .topnav li {
    border-bottom: 0;
    padding: 0;
  }

  .topnav a {
    padding: 0.4em 1.25em;
  }

  /* ---------- Two-column page layout ---------- */
  .site-content { padding: 5.5em 0 0; }

  main > article > .entry-header {
    float: left;
    width: 36%;
    margin-bottom: 0;
    padding-right: 1.5em;
  }

  main > article > .entry-content {
    float: right;
    width: 58%;
  }

  main > article::after {
    content: "";
    display: table;
    clear: both;
  }

  .page-bottom-pad { padding-bottom: 2.5em; }

  /* ---------- Home page: full-height hero (desktop) ---------- */
  body:has(.topnav a.active[href="index.html"]) .custom-header {
    max-height: 1200px;
    padding-bottom: 56px; /* room for the absolute-positioned nav bar */
  }

  body:has(.topnav a.active[href="index.html"]) .site-branding {
    padding: 1.5em 0 2em;
  }

  /* Home branding is larger than on subpages (original scoped these to .home) */
  body:has(.topnav a.active[href="index.html"]) .site-title {
    font-size: 2.25rem;
  }

  body:has(.topnav a.active[href="index.html"]) .site-description {
    font-size: 1rem;
  }

  /* Pin the nav to the bottom edge of the hero. */
  body:has(.topnav a.active[href="index.html"]) .navigation-top {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    border-top: 0;
    background: var(--content-bg);
    z-index: 4;
  }
}
