/* ── Reset & base ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --max-width: 1100px;
  --header-height: 60px;
}

html { font-size: 18px; scroll-behavior: smooth; scroll-padding-top: calc(var(--header-height) + 1rem); }

/* ── Skip link ────────────────────────────────────────────── */
.skip-link {
  position: absolute;
  top: -100%;
  left: 0;
  background: var(--color-header-bg);
  color: var(--color-header-text);
  padding: 0.5rem 1rem;
  z-index: 200;
  text-decoration: none;
  font-size: 0.95rem;
}
.skip-link:focus { top: 0; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition: none !important; }
}

body {
  font-family: var(--font-sans);
  color: var(--color-text);
  background: var(--color-body-bg);
  line-height: 1.7;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ── Header ───────────────────────────────────────────────── */
.site-header {
  background: var(--color-header-bg);
  height: var(--header-height);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 6px rgba(0,0,0,0.25);
}

.header-inner {
  max-width: 1300px;
  margin: 0 auto;
  padding: 0 1.5rem;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.site-brand img { display: block; }
.site-brand .site-name {
  color: var(--color-header-text);
  font-size: 1.2rem;
  font-weight: 700;
  text-decoration: none;
}
.site-brand { text-decoration: none; }

.site-nav ul {
  list-style: none;
  display: flex;
  gap: 0.25rem;
}

.site-nav a {
  color: var(--color-header-text);
  text-decoration: none;
  font-size: 0.85rem;
  white-space: nowrap;
  padding: 0.4rem 0.5rem;
  border-radius: 4px;
  transition: background 0.15s;
}

.site-nav a:hover {
  background: rgba(255,255,255,0.15);
}

.site-nav a:focus-visible {
  outline: 2px solid var(--color-header-text);
  outline-offset: 2px;
  text-decoration: underline;
}

.site-nav a.active {
  background: var(--color-nav-active);
}

/* ── Dropdown submenus ────────────────────────────────────── */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.site-nav > ul > li {
  display: flex;
  align-items: center;
}

.site-nav li.has-submenu { position: relative; }

.submenu-toggle {
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.4rem 0.3rem;
  margin-left: -0.5rem;
  color: var(--color-header-text);
}

.submenu-caret {
  display: block;
  width: 0;
  height: 0;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 5px solid currentColor;
}

.site-nav .submenu {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  min-width: 12rem;
  flex-direction: column;
  gap: 0;
  padding: 0.5rem;
  background: var(--color-header-bg);
  border-radius: 0 0 4px 4px;
  box-shadow: 0 4px 8px rgba(0,0,0,0.3);
}

.site-nav .submenu a {
  display: block;
  white-space: nowrap;
}

.site-nav li.has-submenu:hover .submenu,
.site-nav li.has-submenu:focus-within .submenu,
.site-nav li.has-submenu.is-open .submenu {
  display: flex;
}

/* ── Hamburger toggle ─────────────────────────────────────── */
.nav-toggle {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.5rem;
  flex-direction: column;
  gap: 5px;
}

.nav-toggle span {
  display: block;
  width: 24px;
  height: 2px;
  background: var(--color-header-text);
  transition: transform 0.2s, opacity 0.2s;
}

.nav-toggle[aria-expanded="true"] span:nth-child(1) {
  transform: translateY(7px) rotate(45deg);
}
.nav-toggle[aria-expanded="true"] span:nth-child(2) {
  opacity: 0;
}
.nav-toggle[aria-expanded="true"] span:nth-child(3) {
  transform: translateY(-7px) rotate(-45deg);
}

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

/* ── Page layout ──────────────────────────────────────────── */
.page-wrap {
  flex: 1;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 2.5rem 1.5rem;
  width: 100%;
}

.page-wrap.with-aside {
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: 3rem;
  align-items: start;
}

/* ── Page content ─────────────────────────────────────────── */
.page-content {
  min-width: 0;
}

.typeset .page-title {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--color-heading);
  margin-top: 0;
  margin-bottom: 1.5rem;
  padding-bottom: 0.5rem;
  border-bottom: 3px solid var(--color-heading-border);
}

/* ── Aside ────────────────────────────────────────────────── */
.page-aside {
  position: sticky;
  top: calc(var(--header-height) + 1.5rem);
}

.aside-section {
  background: var(--color-aside-bg);
  border: 1px solid var(--color-border);
  border-left: 4px solid var(--color-aside-border);
  border-radius: 6px;
  padding: 1.25rem;
}

.aside-section h3 {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 0.75rem;
  color: var(--color-heading);
}

.aside-logo {
  display: block;
  width: 100%;
  max-width: 180px;
  margin: 0 auto 1rem;
}

.aside-section p {
  font-size: 1rem;
  color: var(--color-text-light);
  line-height: 1.6;
}

.aside-section a {
  color: var(--color-aside-link);
}

/* ── Typography (typeset) ─────────────────────────────────── */
.typeset h1, .typeset h2, .typeset h3,
.typeset h4, .typeset h5, .typeset h6 {
  font-weight: 700;
  line-height: 1.3;
  margin: 1.5rem 0 0.75rem;
  color: var(--color-heading);
}

.typeset h2 { font-size: 1.5rem; border-bottom: 2px solid var(--color-heading-border); padding-bottom: 0.35rem; }
.typeset h3 { font-size: 1.2rem; border-bottom: 1px solid var(--color-border); padding-bottom: 0.25rem; }
.typeset h4 { font-size: 1.05rem; }
.typeset h5 { font-size: 0.95rem; color: var(--color-text-light); font-weight: 600; }

.typeset p { margin-bottom: 1rem; }

.typeset a { color: var(--color-accent); text-decoration: underline; }
.typeset a:hover { color: var(--color-accent-hover); }

.typeset ul, .typeset ol {
  margin: 0.75rem 0 1rem 1.5rem;
}

.typeset li { margin-bottom: 0.35rem; }

.typeset em { font-style: italic; }
.typeset strong { font-weight: 700; }

.typeset hr {
  border: none;
  border-top: 1px solid var(--color-border);
  margin: 2rem 0;
}

.typeset blockquote {
  border-left: 3px solid var(--color-blockquote);
  padding-left: 1rem;
  color: var(--color-text-light);
  margin: 1rem 0;
}

/* ── People / figure floats ───────────────────────────────── */
.typeset img[style*="float:left"],
.typeset img[style*="float: left"] {
  margin: 0.25rem 1.25rem 1rem 0;
}

.typeset img[style*="float:right"],
.typeset img[style*="float: right"] {
  margin: 0.25rem 0 1rem 1.25rem;
}

/* Headshots: fixed box so landscape photos don't leave text wrapping under them */
.typeset img[width="120"] {
  height: 150px;
  object-fit: cover;
}

/* Person blocks: clear floats after each h2/h3/h4 section */
.typeset h2, .typeset h3, .typeset h4 { clear: both; }

/* ── Figures with captions ────────────────────────────────── */
.typeset figure {
  margin: 1.5rem auto;
  text-align: center;
}

.typeset figure img {
  display: block;
  margin: 0 auto;
}

.typeset figcaption {
  margin-top: 0.5rem;
  font-size: 0.875rem;
  font-style: italic;
  color: var(--color-text-light);
  border-top: 1px solid var(--color-border);
  padding-top: 0.5rem;
}

/* Floated figures: shrink and let body text wrap alongside */
.typeset figure.float-left,
.typeset figure.float-right {
  max-width: 480px;
  margin: 0.25rem 0 1rem;
}

.typeset figure.float-left  { float: left;  margin-right: 1.5rem; }
.typeset figure.float-right { float: right; margin-left: 1.5rem; }

.typeset figure.float-left img,
.typeset figure.float-right img { width: 100%; }

/* On narrow screens, don't float — stack full-width and center */
@media (max-width: 820px) {
  .typeset figure.float-left,
  .typeset figure.float-right {
    float: none;
    max-width: 100%;
    margin: 1.5rem auto;
  }
}

/* ── Footer ───────────────────────────────────────────────── */
.site-footer {
  background: var(--color-footer-bg);
  border-top: 3px solid var(--color-footer-border);
  padding: 1.5rem;
  text-align: center;
  font-size: 1rem;
  color: var(--color-text-light);
}

.footer-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
}

.footer-logo img { display: block; }

/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 1240px) {
  .nav-toggle { display: flex; }

  .site-nav ul {
    display: none;
    position: absolute;
    top: var(--header-height);
    left: 0;
    right: 0;
    flex-direction: column;
    background: var(--color-header-bg);
    padding: 0.5rem 1rem 1rem;
    box-shadow: 0 4px 8px rgba(0,0,0,0.3);
    gap: 0;
  }

  .site-nav.is-open ul { display: flex; }

  .site-nav li { border-bottom: 1px solid rgba(255,255,255,0.1); }

  .site-nav a {
    display: block;
    font-size: 1rem;
    padding: 0.6rem 0.75rem;
  }

  /* Submenus are always expanded and indented in the mobile menu */
  .site-nav > ul > li { display: block; }
  .submenu-toggle { display: none; }
  .site-nav .submenu {
    display: flex;
    position: static;
    box-shadow: none;
    padding: 0 0 0.25rem 1rem;
  }
  .site-nav .submenu li:last-child { border-bottom: none; }
}

@media (max-width: 768px) {
  .page-wrap.with-aside {
    grid-template-columns: 1fr;
  }

  .page-aside {
    position: static;
    order: -1;
  }
}

/* ── Tables ───────────────────────────────────────────────── */
.typeset table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5rem 0;
  font-size: 0.95rem;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  overflow: hidden;
}

.typeset thead tr {
  background: var(--color-header-bg);
  color: var(--color-header-text);
}

.typeset thead th {
  padding: 0.7rem 1rem;
  text-align: left;
  font-weight: 600;
  letter-spacing: 0.02em;
  border-right: 1px solid rgba(255,255,255,0.15);
}

.typeset thead th:last-child { border-right: none; }

.typeset tbody tr {
  border-top: 1px solid var(--color-border);
}

.typeset tbody tr:nth-child(even) {
  background: var(--color-aside-bg);
}

.typeset tbody tr:hover {
  background: var(--color-aside-bg);
  filter: brightness(0.97);
}

.typeset td,
.typeset tbody th {
  padding: 0.65rem 1rem;
  vertical-align: top;
  border-right: 1px solid var(--color-border);
  font-weight: normal;
}

.typeset td:last-child,
.typeset tbody th:last-child { border-right: none; }

@media (max-width: 640px) {
  .typeset table { font-size: 0.85rem; }
  .typeset th, .typeset td { padding: 0.5rem 0.6rem; }
}

/* ── News list ────────────────────────────────────────────── */
.news-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.news-item {
  padding: 1.5rem 0;
  border-bottom: 1px solid var(--color-border);
}

.news-item:first-child { padding-top: 0; }

.news-item-title {
  display: block;
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--color-accent);
  text-decoration: underline;
  margin-bottom: 0.25rem;
}

.news-item-title:hover {
  color: var(--color-accent-hover);
}

.news-item-meta {
  font-size: 0.875rem;
  color: var(--color-text-light);
  margin-bottom: 0.5rem;
}

.news-item-summary { margin: 0 0 0.5rem; }

/* Post images show as thumbnails in the news list (full size on the post) */
.news-item-summary img {
  float: right;
  width: 180px;
  max-height: 140px;
  object-fit: cover;
  object-position: center top;
  margin: 0.25rem 0 0.75rem 1.25rem;
  border-radius: 4px;
}

.news-item::after {
  content: "";
  display: block;
  clear: both;
}

.news-item-more {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--color-accent);
  text-decoration: none;
}

.news-item-more:hover {
  color: var(--color-accent-hover);
  text-decoration: underline;
}

.news-archive-link {
  margin-top: 1.5rem;
  font-weight: 600;
}

/* Archive: compact date + title rows grouped under year headings */
.typeset .news-archive-list {
  list-style: none;
  margin-left: 0;
}

.typeset .news-archive-list li {
  display: flex;
  gap: 1rem;
  margin-bottom: 0.5rem;
}

.news-archive-list time {
  flex: 0 0 3.5rem;
  font-size: 0.875rem;
  color: var(--color-text-light);
  padding-top: 0.15rem;
}

/* ── Article ──────────────────────────────────────────────── */
.article-meta {
  font-size: 0.875rem;
  color: var(--color-text-light);
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--color-border);
}

.article-back {
  margin-top: 2rem;
  padding-top: 1rem;
  border-top: 1px solid var(--color-border);
}
