/*
  Base theme for the static site (see docs/next-steps-wp-2-static-migration.md, Sprint 2).
  Expected markup contract for build-static.mjs to generate on every page:

  <header class="site-header">
    <div class="site-header__bar">
      <a class="site-header__title" href="/">Site Title</a>
      <button class="nav-toggle" aria-expanded="false" aria-controls="site-nav">
        <span class="nav-toggle__box"><span class="nav-toggle__bar"></span></span>
        <span class="visually-hidden">Menu</span>
      </button>
    </div>
    <nav id="site-nav" class="site-nav">
      <div class="site-nav__group">
        <ul class="site-nav__list">
          <li><a href="/about/">About Me</a></li>
          ... category links ...
          <li class="site-nav__item--has-submenu">
            <span class="site-nav__submenu-label" tabindex="0">JenLi Concept</span>
            <ul class="site-nav__submenu">
              <li><a href="/jenli/">Background</a></li>
              ... JenLi Manifesto / JenLi Foundation links ...
            </ul>
          </li>
          <li><a href="/in-the-media/">In the Media</a></li>
        </ul>
      </div>
    </nav>
  </header>
  <img class="site-header__banner" src="/assets/site/images/site-header.jpg" alt="...">
  <main class="site-main">...</main>
  <footer class="site-footer">...</footer>

  No build step, no webfonts, no framework — plain CSS + one small JS file
  (nav.js) for progressive enhancement. The nav is a normal list of links,
  so it works even before JS runs; JS only toggles visibility on narrow screens.
*/

:root {
  --color-bg: #fbfaf7;
  --color-surface: #ffffff;
  --color-text: #24272b;
  --color-text-muted: #838383;
  --color-accent: #838383;
  --color-accent-hover: #000;
  --color-accent-contrast: #ffffff;
  --color-border: #e3e1db;

  /* Reserved for future use — not yet applied anywhere. */
  --color-grey-light: #acacac;

  /* Shared by article headings and the nav menu, so they always match --
     change this once and both follow. */
  --color-heading: var(--color-text);

  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-serif: Georgia, "Times New Roman", serif;

  --measure: 42rem;
  --space-1: 0.5rem;
  --space-2: 1rem;
  --space-3: 1.5rem;
  --space-4: 2.5rem;

  --header-height: 3.5rem;
}

@media (prefers-color-scheme: dark) {
  :root {
    --color-bg: #16191c;
    --color-surface: #1f2327;
    --color-text: #e8e6e1;
    --color-text-muted: #a7adb3;
    --color-accent: #6fc7bd;
    --color-accent-hover: #4fa89f;
    --color-accent-contrast: #0b1a1a;
    --color-border: #2c3136;
    --color-grey-light: #3a3f44;
  }
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-sans);
  line-height: 1.6;
}

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

a {
  color: var(--color-accent);
}

a:hover,
a:focus-visible {
  color: var(--color-accent-hover);
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* Header + hamburger nav */

.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
}

.site-header__bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--header-height);
  padding: 0 var(--space-2);
  max-width: 60rem;
  margin: 0 auto;
}

.site-header__title {
  font-family: var(--font-serif);
  font-size: 1.25rem;
  font-weight: 700;
  text-decoration: none;
  color: var(--color-accent);
}

.site-header__title:hover,
.site-header__title:focus-visible {
  color: var(--color-accent-hover);
}

/* Site header banner photo — not part of the sticky header, so it only
   takes up screen space once, at the top of the page, not on every scroll. */
.site-header__banner {
  display: block;
  width: 100%;
  height: auto;
  max-width: 60rem;
  margin: 0 auto;
}

.nav-toggle {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  background: none;
  border: 0;
  padding: var(--space-1);
  cursor: pointer;
  color: var(--color-text);
}

.nav-toggle__box {
  display: block;
  width: 1.5rem;
  height: 1px;
  background: currentColor;
  position: relative;
}

.nav-toggle__box::before,
.nav-toggle__box::after {
  content: "";
  position: absolute;
  left: 0;
  width: 100%;
  height: 1px;
  background: currentColor;
}

.nav-toggle__box::before {
  top: -6px;
}

.nav-toggle__box::after {
  top: 6px;
}

.site-nav[hidden] {
  display: none;
}

/* Mobile off-canvas nav can grow taller than the viewport (e.g. the full
   #Tags submenu) — scroll within the nav itself rather than letting content
   run off-screen with no way to reach it. Desktop's horizontal nav never
   needs this (overridden back to visible/unconstrained below). */
.site-nav {
  max-height: calc(100vh - var(--header-height));
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.site-nav__list {
  list-style: none;
  margin: 0;
  padding: var(--space-2);
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  border-top: 1px solid var(--color-border);
}

.site-nav__list a {
  display: block;
  padding: var(--space-1) 0;
  text-decoration: none;
  font-family: var(--font-serif);
  font-weight: 700;
  color: var(--color-accent);
}

.site-nav__list a:hover,
.site-nav__list a:focus-visible {
  color: var(--color-accent-hover);
}

.site-nav__group + .site-nav__group {
  margin-top: var(--space-1);
}

.site-nav__group-label {
  margin: 0;
  padding: var(--space-1) var(--space-2) 0;
  font-size: 0.75rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--color-text-muted);
}

/* JenLi Model submenu — on mobile it's just a nested, always-visible list
   (matches the rest of the off-canvas nav); the desktop dropdown treatment
   is added in the min-width block below. */
.site-nav__submenu-label {
  display: block;
  padding: var(--space-1) 0;
  font-family: var(--font-serif);
  font-weight: 700;
  color: var(--color-accent);
}

.site-nav__submenu-label:hover,
.site-nav__submenu-label:focus-visible {
  color: var(--color-accent-hover);
}

.site-nav__submenu {
  list-style: none;
  margin: 0;
  padding: 0 0 0 var(--space-2);
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

/* Desktop: horizontal nav, hamburger hidden */
@media (min-width: 900px) {
  .nav-toggle {
    display: none;
  }

  .site-nav[hidden] {
    display: block;
  }

  .site-nav__list {
    flex-direction: row;
    border-top: 0;
    padding: 0;
    gap: var(--space-3);
  }

  .site-nav__list a {
    padding: 0;
  }

  .site-nav {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    max-height: none;
    overflow-y: visible;
    /* Same inset as .site-header__bar, so the first menu item lines up
       under "Karl H Richter" instead of sitting flush against the
       viewport edge. */
    max-width: 60rem;
    margin: 0 auto;
    padding: 0 var(--space-2);
  }

  .site-nav__group {
    display: flex;
    align-items: center;
  }

  .site-nav__group + .site-nav__group {
    margin-top: 0;
    padding-left: var(--space-3);
    border-left: 1px solid var(--color-border);
  }

  .site-nav__group-label {
    padding: 0 var(--space-1) 0 0;
  }

  /* JenLi Model becomes a hover/focus dropdown, like the rest of the desktop
     nav being a single row rather than a stacked list. */
  .site-nav__item--has-submenu {
    position: relative;
  }

  .site-nav__submenu-label {
    padding: 0;
    cursor: default;
  }

  .site-nav__submenu {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    /* No margin-top: any gap here is a dead zone the pointer crosses while
       moving from the label to the submenu, breaking :hover before it ever
       reaches the links. The breathing room instead comes from padding-top,
       which is still part of the hoverable box. */
    margin-top: 0;
    padding: var(--space-2) var(--space-1) var(--space-1);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    min-width: 14rem;
    z-index: 10;
  }

  .site-nav__submenu a {
    white-space: nowrap;
    padding: var(--space-1);
  }

  .site-nav__item--has-submenu:hover .site-nav__submenu,
  .site-nav__item--has-submenu:focus-within .site-nav__submenu {
    display: flex;
    flex-direction: column;
  }
}

/* Main content */

.site-main {
  max-width: var(--measure);
  margin: 0 auto;
  padding: var(--space-4) var(--space-2);
}

/* Small inline logo (e.g. JenLi) that floats with text wrapping around it. */
.inline-logo {
  float: left;
  width: 75px;
  max-width: 10%;
  height: auto;
  margin: 0 var(--space-1) var(--space-1) 0;
}

.site-main h1,
.site-main h2,
.site-main h3 {
  font-family: var(--font-serif);
  font-weight: 700;
  color: var(--color-heading);
  line-height: 1.25;
}

.site-main p,
.site-main ul,
.site-main ol,
.site-main blockquote {
  margin: 0 0 var(--space-1);
}

.site-main blockquote {
  margin-left: 0;
  padding-left: var(--space-2);
  border-left: 3px solid var(--color-accent);
  color: var(--color-text-muted);
}

/* Footnote reference markers use <sup> — stop the taller line box that
   would otherwise nudge surrounding line-height in most browsers. */
.site-main sup {
  line-height: 0;
}

.post-list__item {
  padding-bottom: var(--space-3);
  margin-bottom: var(--space-3);
  border-bottom: 1px solid var(--color-border);
}

/* Post summary thumbnails (home, category and tag archives) — title and date
   stay full-width above; the thumbnail sits fixed-width (natural aspect
   ratio, no cropping) to the left of the excerpt, top-aligned with it. */
.post-list__item--with-thumb h2 {
  margin-top: 0;
}

.post-list__row {
  display: flex;
  gap: var(--space-2);
  align-items: flex-start;
}

.post-list__thumb-link {
  flex-shrink: 0;
}

.post-list__thumb {
  width: 9rem;
  height: auto;
}

.post-list__content {
  min-width: 0;
}

/* Date-prefixed list items (e.g. "in the media" listings) — a grey divider
   line below each entry to separate it from the next. See
   formatMediaItemDates in build-static.mjs, which adds this class at build
   time. */
.media-item {
  padding-bottom: var(--space-2);
  margin-bottom: var(--space-2);
  border-bottom: 1px solid var(--color-border);
}

.media-item:last-child {
  border-bottom: 0;
}

.post-list__meta {
  color: var(--color-text-muted);
  font-size: 0.875rem;
  margin: 0 0 var(--space-1);
}

/* Tighten the gap specifically between adjacent meta rows (e.g. Categories
   directly above Tags), without affecting spacing before/after other content. */
.post-list__meta + .post-list__meta {
  margin-top: calc(var(--space-1) * -0.75);
}

.post-list__meta--date {
  text-align: right;
}

/* Footer */

.site-footer {
  max-width: 60rem;
  margin: 0 auto;
  padding: var(--space-3) var(--space-2) var(--space-4);
  color: var(--color-text-muted);
  font-size: 0.875rem;
  border-top: 1px solid var(--color-border);
}
