/*
 * BILLFINNELL.COM - shared site style (V2.0)
 * Change the look of the header, menu and footer HERE ONLY.
 * Colors and fonts follow the original 2018 design by H. H. Finnell:
 *   header #333 / white, menu #ccc with bold Arial links, content #f1f1f1,
 *   footer #777 / white in a typewriter-style font.
 */

:root {
  --header-bg: #333;
  --header-fg: #fff;
  --menu-bg: #ccc;
  --menu-link: #0000ee;
  --menu-current-bg: #fff;
  --content-bg: #f1f1f1;
  --footer-bg: #777;
  --footer-fg: #fff;
  --menu-width: 250px;
  --font: Arial, Helvetica, sans-serif;
}

* { box-sizing: border-box; }

html, body { height: 100%; margin: 0; }

body {
  font-family: var(--font);
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  background: var(--content-bg);
}

a { text-decoration: none; }

.skip-link {
  position: absolute; left: -9999px; top: 0;
  background: #fff; color: #000; padding: 8px 12px; z-index: 100;
}
.skip-link:focus { left: 8px; top: 8px; }

/* ---------- Header ---------- */
.site-header {
  flex: 0 0 auto;
  position: relative;
  background: var(--header-bg);
  color: var(--header-fg);
  text-align: center;
  overflow: hidden;
}
.site-header h2 {
  margin: 0;
  padding: 16px 8px;
  font-size: 1.5em;
  font-weight: bold;
}
.site-header h2 a { color: inherit; }
.menu-button { display: none; }
.test-badge {
  position: absolute; right: 12px; top: 50%; transform: translateY(-50%);
  background: #c00; color: #fff; font: bold 12px var(--font);
  padding: 4px 8px; border-radius: 3px; letter-spacing: 1px;
}

/* ---------- Layout: menu | content, footer under the menu ---------- */
.site-body {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  grid-template-columns: var(--menu-width) 1fr;
  grid-template-rows: 1fr auto;
  grid-template-areas:
    "nav    content"
    "footer content";
}

.sidebar {
  grid-area: nav;
  background: var(--menu-bg);
  overflow-y: auto;
  padding: 10px;
  font-size: 0.875em;
  font-weight: bold;
  min-height: 0;
}

.content {
  grid-area: content;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background: var(--content-bg);
}
#content-frame {
  flex: 1 1 auto;
  width: 100%;
  border: 0;
  background: #fff;
  display: block;
}

/* ---------- Footer ---------- */
.site-footer {
  grid-area: footer;
  background: var(--footer-bg);
  color: var(--footer-fg);
  text-align: center;
}
.site-footer p {
  margin: 0;
  padding: 8px 6px;
  font-family: "Courier New", Courier, monospace;
  font-size: 12px;
  line-height: 1.35;
}
.site-footer .br { display: block; height: 0; }

/* ---------- Menu tree ---------- */
.tree { list-style: none; margin: 0; padding: 0 5px; }
.tree.top { padding-bottom: 6px; }
.tree.level-0 > li {
  border-top: 1px solid #a3a3a3;      /* like the original <hr> lines */
  box-shadow: 0 -1px 0 #e6e6e6 inset;
}
.tree.level-0 { border-bottom: 1px solid #a3a3a3; margin-bottom: 8px; }
.tree ul { list-style: none; margin: 0; padding: 0 0 4px 1.1em; } /* indent sub-levels */

.sidebar summary,
.sidebar a {
  display: block;
  color: var(--menu-link);
  padding: 5px 4px;
  border-radius: 2px;
  cursor: pointer;
  line-height: 1.25;
}
.sidebar summary { list-style: none; }
.sidebar summary::-webkit-details-marker { display: none; }
.sidebar summary::before {
  content: "\25B8";               /* right-pointing triangle = closed */
  display: inline-block;
  width: 1.1em;
  color: #333;
}
.sidebar details[open] > summary::before { content: "\25BE"; } /* down-pointing = open */
.tree .page > a { padding-left: calc(4px + 1.1em); }   /* line up with folder names */
.tree.top .page > a { padding-left: 4px; }

.sidebar a:hover, .sidebar summary:hover { text-decoration: underline; }
.sidebar a[aria-current="page"] {
  background: var(--menu-current-bg);
  color: #000;
  box-shadow: inset 3px 0 0 var(--header-bg);
}
.sidebar a:focus-visible, .sidebar summary:focus-visible,
.menu-button:focus-visible, .fullscreen-link:focus-visible {
  outline: 2px solid #000;
  outline-offset: 1px;
}

/* ---------- "Open full screen" bar (phones/tablets only) ---------- */
.doc-bar { display: none; }

/* ---------- Phones and small tablets ---------- */
@media (max-width: 767px) {
  .site-header h2 { font-size: 1.15em; padding: 14px 8px 14px 96px; text-align: left; }
  .menu-button {
    display: inline-flex; align-items: center; gap: 6px;
    position: absolute; left: 8px; top: 50%; transform: translateY(-50%);
    background: transparent; color: #fff; border: 1px solid #888; border-radius: 4px;
    font: bold 14px var(--font); padding: 8px 10px; cursor: pointer;
  }
  .menu-icon { font-size: 18px; line-height: 1; }

  .site-body {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr auto;
    grid-template-areas: "content" "footer";
    position: relative;
  }
  .content { grid-area: content; }

  /* The menu becomes a full-width panel that slides over the content */
  .sidebar {
    position: absolute; inset: 0;
    z-index: 20;
    font-size: 1rem;
    transform: translateX(-100%);
    visibility: hidden;
    transition: transform 0.2s ease, visibility 0s linear 0.2s;
  }
  body.nav-open .sidebar {
    transform: none; visibility: visible;
    transition: transform 0.2s ease;
  }
  .sidebar summary, .sidebar a { padding-top: 11px; padding-bottom: 11px; } /* easy to tap */

  .site-footer p { font-size: 11px; padding: 5px 6px; }
  .site-footer .br { display: inline; }

  .doc-bar:not([hidden]) {
    display: block;
    background: #e4e4e4;
    border-bottom: 1px solid #ccc;
    text-align: right;
    padding: 6px 10px;
    font-size: 14px;
  }
  .fullscreen-link { color: var(--menu-link); font-weight: bold; }
}

@media (prefers-reduced-motion: reduce) {
  .sidebar, body.nav-open .sidebar { transition: none; }
}
