:root {
  /* Sidebar */
  --nav-width: 220px;
  --nav-gap: 25px;              /* space between nav and content */
  --side-margin: 100px;         /* space from window edge to nav */

  /* Content column max-widths */
  --content: 1000px;
  --content-home: 1300px;
  --content-small: 800px;       /* cap for <main class="small"> and .small-width */
  --content-small-width:800px;
  --content-press: 600px;

  /* Layout */
  --top-gap: 85px;              /* desktop: gap above the iframe */
  --topbar-height: 56px;        /* mobile: top bar height */
  --footer-height: 36px;        /* footer bar minimum height, all layouts */

  --page-pad-r: 75px;
  --page-pad-r-mobile: 32px;
  --page-pad-b: 96px;
  --page-pad-b-mobile: 64px;

  /* Animation speed */
  --menu-duration: 0.1s;

  /* Repeated visual values */
  --rule-color: #000;
  --focus-ring: #000;
  --shadow-menu: 0 8px 16px rgba(0, 0, 0, 0.12);

  /* Calculation for padding */
  --page-pad-l: calc(var(--side-margin) + var(--nav-width) + var(--nav-gap));
}

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

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: #000;
  background: #fff;
}

a:focus-visible,
button:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

/* Index / shell */
body.app {
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  display: flex;
  flex-direction: column;

  .topbar { display: none; }   /* mobile only */

  .sidebar {
    position: fixed;
    top: 25px;
    bottom: var(--footer-height);
    left: var(--side-margin);
    width: var(--nav-width);
    padding: 60px 16px;
    background: #fff;
    overflow-y: auto;
    z-index: 1000;

    .brand {
      display: block;
      margin: 0 0 24px;
      font-size: 1.2rem;
      font-weight: 700;
      color: #000;
      text-decoration: none;
    }
  }

  .nav-links {
    list-style: none;
    margin: 0;
    padding: 0;

    a {
      display: block;
      padding: 4px 0;
      color: #000;
      text-decoration: none;
      font-size: 1rem;

      &:hover,
      &:focus { text-decoration: underline; }
    }
  }

  .content {
    margin-top: var(--top-gap);
    flex: 1;
    min-height: 0;

    iframe {
      display: block;
      width: 100%;
      height: 100%;
      border: none;
      background: #fff;
    }
  }

  .footer {
    flex: 0 0 auto;
    min-height: var(--footer-height);
    /* Padding matches the content page so the text centres within the
       content area, not the whole window. */
    padding: 8px var(--page-pad-r) 8px var(--page-pad-l);
    display: flex;
    align-items: center;
    justify-content: center;
    background: #fff;
    font-size: 0.8rem;
    line-height: 1.3;
    text-align: center;
    position: relative;
    z-index: 1001;        /* above the fixed sidebar */
  }
}

/* Content */
body.page {
  padding: 0 var(--page-pad-r) var(--page-pad-b) var(--page-pad-l);
  font-size: 15px;
  line-height: 1.6;

  main {
    max-width: var(--content);
    margin-inline: auto;

    /* Narrower column for whole pages — <main class="small"> */
    &.small { max-width: var(--content-small); }
  }

/* Div class for small-width contnet */
  .small-width {
    max-width: var(--content-small-width);
    margin-inline: auto;
  }
  .press {
  max-width: var(--content-press);
  margin-inline: auto;
}

  h1, h2, h3 {
    margin: 0;
    font-weight: 700;
    text-wrap: balance;
  }
  h1 { margin-bottom: 24px; font-size: 1.9rem;  line-height: 1.2; }
  h2 { margin-bottom: 12px; font-size: 1.25rem; line-height: 1.3; }
  h3 { margin-bottom: 8px;  font-size: 1rem; }

  p { margin: 0 0 16px; }

  p.tight,
  p.nobreak {
    margin: 0 0 -5px;
    font-size: 0.8rem;
    text-align: center;
  }

  /* Centre style */
  p.center,
  h1.center,
  h2.center,
  h3.center { text-align: center; }

  p,
  li { overflow-wrap: anywhere; }

  a {
    color: #000;
    text-decoration: underline;
    text-decoration-thickness: 1px;

    &:hover,
    &:focus { text-decoration-thickness: 2px; }
  }

  ul, ol { margin: 0 0 16px; padding-left: 22px; }
  li     { margin-bottom: 6px; }

  hr {
    width: 50%;
    margin: 50px auto;
    border: 0;
    border-top: 1px solid var(--rule-color);
  }

  blockquote { margin: 0 0 16px; font-style: italic; }

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

  figure {
    margin: 0 0 40px;

    img { width: 100%; }

    &.vertical {
      width: fit-content;
      max-width: 100%;
      margin-inline: auto;

      img {
        width: auto;
        max-height: min(1200px, 80vh);
      }
    }
  }

  /* Figcaptions are always centred */
  figcaption {
    margin-top: 10px;
    margin-bottom: 10%;
    font-size: 0.9rem;
    line-height: 1.45;
    text-align: center;

    .meta { display: block; font-size: 0.85rem; }
  }
}

/* Home page specifics */
body.page.home main {
  max-width: var(--content-home);
}

body.page.home figure {
  margin: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
}

body.page.home figure img {
  max-height: calc(100dvh - 150px); /* caption + margin + padding + slack */
  object-fit: contain;
  object-position: center;
}

body.page.home figcaption {
  margin: 15px 0 0;
}

/* Responsive */
@media (max-width: 1200px) {
  body.page {
    padding: 0 var(--page-pad-r-mobile) var(--page-pad-b-mobile);
    main { max-width: 100%; }
  }

  body.page.home main { max-width: 100%; }

  /* Home: fill the iframe height, image centred, caption below */
  body.page.home {
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
    padding-bottom: 0;
    display: flex;
    flex-direction: column;

    main {
      flex: 1;
      min-height: 0;
      display: flex;
      flex-direction: column;
      padding-bottom: 24px;
    }
    figure {
      flex: 1;
      min-height: 0;
      justify-content: center;
    }
    figure img {
      width: auto;
      flex: 0 0 auto;
      max-height: calc(100% - 45px); /* reserve room for caption */
    }
  }
}

/* Mobile */
@media (max-width: 600px) {
  body.page {
    padding: 0 20px var(--page-pad-b-mobile);
    font-size: 14px;

    figcaption { font-size: 12px; margin-top: 8px; }
    h1 { font-size: 1.6rem; }
  }
}

/* Mobile shell (menu) */
@media (max-width: 1200px) {
  body.app {
    .topbar {
      position: fixed;
      top: 0;
      left: 0;
      right: 0;
      z-index: 1001;
      display: flex;
      align-items: center;
      justify-content: space-between;
      height: var(--topbar-height);
      padding: 0 16px;
      background: #fff;

      .brand {
        color: #000;
        text-decoration: none;
        font-size: 1.1rem;
        font-weight: 700;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
      }
    }

    .menu-toggle {
      display: flex;
      flex-direction: column;
      justify-content: center;
      gap: 5px;
      width: 40px;
      height: 40px;
      padding: 0;
      background: none;
      border: 0;
      cursor: pointer;

      span {
        display: block;
        width: 22px;
        height: 2px;
        margin: 0 auto;
        background: #000;
      }
    }

    .sidebar {
      display: none;
      top: var(--topbar-height);
      bottom: auto;
      left: 0;
      right: 0;
      width: 100%;
      height: auto;
      max-height: calc(100vh  - var(--topbar-height) - var(--footer-height));
      max-height: calc(100dvh - var(--topbar-height) - var(--footer-height));
      padding: 12px 16px 16px;
      overflow-y: auto;

      &.open {
        display: block;
        box-shadow: var(--shadow-menu);
      }

      .brand { display: none; }
    }

    .nav-links {
      text-align: center;
      a { padding: 4px 0; font-size: 1rem; }
    }

    .content {
      margin-top: var(--topbar-height);
      iframe { transition: opacity var(--menu-duration) ease; }
    }

    .footer {
      padding-left: var(--page-pad-r-mobile);
      padding-right: var(--page-pad-r-mobile);
    }

    &.menu-open .content iframe { opacity: 0.55; }
  }
}

@media (prefers-reduced-motion: reduce) {
  .content iframe { transition: none; }
}