/* ==========================================================================
   Richard Zowalla - personal site
   Self-contained styles. No external resources are referenced.
   Theming is driven by the data-theme attribute on <html>
   (set by assets/js/theme.js before first paint).
   ========================================================================== */

/* --- Design tokens -------------------------------------------------------- */
:root {
  --bg: #f7f7f5;
  --bg-accent: #ffffff;
  --fg: #1d1d1f;
  --fg-muted: #555555;
  --link: #2a6fb3;
  --link-hover: #14406e;
  --avatar-ring: rgba(0, 0, 0, 0.08);
  --shadow: rgba(0, 0, 0, 0.12);
  --toggle-bg: #ffffff;
  --toggle-border: rgba(0, 0, 0, 0.12);
}

html[data-theme="dark"] {
  --bg: #15171a;
  --bg-accent: #1e2126;
  --fg: #e8e8ea;
  --fg-muted: #a8adb5;
  --link: #6fb3ff;
  --link-hover: #a9d2ff;
  --avatar-ring: rgba(255, 255, 255, 0.12);
  --shadow: rgba(0, 0, 0, 0.5);
  --toggle-bg: #1e2126;
  --toggle-border: rgba(255, 255, 255, 0.15);
}

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

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

body {
  /* System font stack: no web fonts are loaded over the network. Drop a
     @font-face into assets/fonts and reference it here to self-host one. */
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica,
    Arial, sans-serif;
  background-color: var(--bg);
  color: var(--fg);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  transition: background-color 0.25s ease, color 0.25s ease;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

a {
  color: var(--link);
  text-decoration: none;
}

a:hover,
a:focus-visible {
  color: var(--link-hover);
  text-decoration: underline;
}

/* --- Site header / navigation -------------------------------------------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background-color: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(180%) blur(10px);
  border-bottom: 1px solid var(--toggle-border);
}

.header-inner {
  max-width: 880px;
  margin: 0 auto;
  padding: 0.75rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.brand {
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--fg);
}
.brand:hover {
  text-decoration: none;
  color: var(--link);
}

.site-nav {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.25rem 0.9rem;
}

.site-nav a {
  color: var(--fg-muted);
  font-size: 0.95rem;
  padding: 0.2rem 0;
  border-bottom: 2px solid transparent;
}
.site-nav a:hover,
.site-nav a:focus-visible {
  color: var(--fg);
  text-decoration: none;
}
.site-nav a.active {
  color: var(--fg);
  border-bottom-color: var(--link);
}

/* --- Main / layout -------------------------------------------------------- */
.site-main {
  flex: 1 1 auto;
  width: 100%;
}

.landingpage {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1.25rem;
  min-height: calc(100vh - 8rem);
}

.hero-card {
  display: flex;
  align-items: center;
  gap: 2.25rem;
  max-width: 720px;
  width: 100%;
  background-color: var(--bg-accent);
  border-radius: 18px;
  padding: 2.5rem 2.75rem;
  box-shadow: 0 12px 40px var(--shadow);
}

/* --- Content pages -------------------------------------------------------- */
.page {
  max-width: 760px;
  margin: 0 auto;
  padding: 2.5rem 1.25rem 3.5rem;
}
.page h1 {
  font-size: 1.9rem;
  margin: 0 0 1.25rem;
}
.page h2 {
  font-size: 1.25rem;
  margin: 2rem 0 0.5rem;
}
.page a {
  text-decoration: underline;
}

.avatar {
  width: 150px;
  height: 150px;
  border-radius: 50%;
  object-fit: cover;
  flex: 0 0 auto;
  box-shadow: 0 0 0 6px var(--avatar-ring);
}

#bio h1 {
  font-size: 1.6rem;
  margin: 0 0 0.5rem;
  font-weight: 700;
}

#bio p {
  margin: 0;
  color: var(--fg-muted);
}

.reset-margin {
  margin: 0;
}

/* --- Contact icons -------------------------------------------------------- */
.icons {
  margin-top: 1.25rem;
}

.icons .icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.4rem;
  height: 2.4rem;
  margin-right: 0.35rem;
  border-radius: 50%;
  color: var(--fg-muted);
  transition: color 0.2s ease, background-color 0.2s ease, transform 0.2s ease;
}

.icons .icon:hover,
.icons .icon:focus-visible {
  color: var(--link);
  background-color: var(--avatar-ring);
  transform: translateY(-2px);
  text-decoration: none;
}

.icons .icon svg {
  width: 1.4rem;
  height: 1.4rem;
  fill: currentColor;
}

/* --- Theme toggle --------------------------------------------------------- */
.theme-toggle {
  width: 2rem;
  height: 2rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  border: 1px solid var(--toggle-border);
  background-color: var(--toggle-bg);
  color: var(--fg);
  cursor: pointer;
  padding: 0;
  transition: transform 0.2s ease, background-color 0.25s ease, color 0.25s ease;
}

.theme-toggle:hover {
  transform: rotate(15deg) scale(1.05);
}

.theme-toggle svg {
  width: 1.05rem;
  height: 1.05rem;
  fill: currentColor;
}

/* Show the correct glyph for the active theme. */
.theme-toggle .icon-moon {
  display: none;
}
.theme-toggle .icon-sun {
  display: block;
}
html[data-theme="dark"] .theme-toggle .icon-moon {
  display: block;
}
html[data-theme="dark"] .theme-toggle .icon-sun {
  display: none;
}

/* --- Project list (Open Source) ------------------------------------------ */
.project-list {
  list-style: none;
  padding: 0;
  margin: 1.5rem 0;
  display: grid;
  gap: 1rem;
}
.project {
  background-color: var(--bg-accent);
  border: 1px solid var(--toggle-border);
  border-radius: 12px;
  padding: 1rem 1.25rem;
}
.project-head {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-bottom: 0.25rem;
}
.project-head a {
  font-weight: 600;
  font-size: 1.05rem;
}
.project .role {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.12rem 0.5rem;
  border-radius: 999px;
  background-color: var(--avatar-ring);
  color: var(--fg-muted);
}
/* Role colour coding: committer / PMC member / chair. */
.role-c {
  background-color: rgba(42, 111, 179, 0.15);
  color: #1f5d99;
}
.role-cp {
  background-color: rgba(31, 122, 77, 0.16);
  color: #1f7a4d;
}
.role-chair {
  background-color: rgba(176, 122, 16, 0.18);
  color: #8a5e00;
}
html[data-theme="dark"] .role-c {
  background-color: rgba(111, 179, 255, 0.16);
  color: #8cc4ff;
}
html[data-theme="dark"] .role-cp {
  background-color: rgba(116, 211, 155, 0.16);
  color: #80dba6;
}
html[data-theme="dark"] .role-chair {
  background-color: rgba(230, 193, 74, 0.18);
  color: #e9c95a;
}
.project p {
  margin: 0;
  color: var(--fg-muted);
}

.contact-list {
  list-style: none;
  padding: 0;
}
.contact-list li {
  margin: 0.4rem 0;
}

/* --- Publications (rendered from data/publications.json) ------------------ */
.publications {
  list-style: none;
  padding: 0;
  margin: 1rem 0;
  display: grid;
  gap: 0.9rem;
}
.pub {
  padding-left: 0.9rem;
  border-left: 3px solid var(--link);
}
.pub-title {
  font-weight: 600;
}
.pub-meta {
  color: var(--fg-muted);
  font-size: 0.92rem;
}
.pub-links a {
  font-size: 0.85rem;
  margin-right: 0.75rem;
}

.pub-pager {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 1.25rem;
}
.pub-page-btn {
  min-width: 2rem;
  padding: 0.3rem 0.6rem;
  border: 1px solid var(--toggle-border);
  border-radius: 8px;
  background-color: var(--bg-accent);
  color: var(--fg);
  font: inherit;
  font-size: 0.9rem;
  cursor: pointer;
  transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}
.pub-page-btn:hover:not(:disabled) {
  border-color: var(--link);
  color: var(--link);
}
.pub-page-btn.active {
  background-color: var(--link);
  border-color: var(--link);
  color: #fff;
}
.pub-page-btn:disabled {
  opacity: 0.45;
  cursor: default;
}

/* --- Content figure ------------------------------------------------------- */
.content-figure {
  margin: 1.5rem 0;
}
.content-figure img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 12px;
  background-color: var(--bg-accent);
  box-shadow: 0 6px 20px var(--shadow);
}
.content-figure figcaption {
  margin-top: 0.6rem;
  color: var(--fg-muted);
  font-size: 0.9rem;
}
/* Smaller, floated variant that sits within the running text. */
.content-figure.figure-float {
  float: right;
  width: 240px;
  max-width: 45%;
  margin: 0.25rem 0 1rem 1.5rem;
}
.content-figure.figure-float figcaption {
  font-size: 0.82rem;
}
@media (max-width: 540px) {
  .content-figure.figure-float {
    float: none;
    width: auto;
    max-width: 100%;
    margin: 1.25rem 0;
  }
}

/* --- Image gallery (About) ----------------------------------------------- */
.gallery {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
  margin: 1.25rem 0;
}
.gallery-item {
  margin: 0;
  border-radius: 12px;
  overflow: hidden;
  background-color: var(--bg-accent);
  box-shadow: 0 6px 20px var(--shadow);
}
.gallery-item img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.gallery-wide {
  grid-column: 1 / -1;
}
@media (max-width: 540px) {
  .gallery {
    grid-template-columns: 1fr;
  }
}

/* --- Footer --------------------------------------------------------------- */
.site-footer {
  border-top: 1px solid var(--toggle-border);
  color: var(--fg-muted);
  font-size: 0.88rem;
}
.footer-inner {
  max-width: 880px;
  margin: 0 auto;
  padding: 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.footer-meta {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.4rem 0.9rem;
}
.footer-meta a {
  color: var(--fg-muted);
}
.footer-meta a:hover,
.footer-meta a:focus-visible {
  color: var(--link);
}
.footer-links {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}
.footer-links .icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  color: var(--fg-muted);
  transition: color 0.2s ease, background-color 0.2s ease;
}
.footer-links .icon:hover,
.footer-links .icon:focus-visible {
  color: var(--link);
  background-color: var(--avatar-ring);
}
.footer-links .icon svg {
  width: 1.1rem;
  height: 1.1rem;
  fill: currentColor;
}

/* --- Responsive ----------------------------------------------------------- */
@media (max-width: 540px) {
  .hero-card {
    flex-direction: column;
    text-align: center;
    gap: 1.5rem;
    padding: 2rem 1.5rem;
  }

  .icons .icon {
    margin: 0 0.15rem;
  }

  .header-inner {
    flex-direction: column;
    align-items: flex-start;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
  }
}
