/*
 * Shared stylesheet for the personal website and the Maximally Mixed blog.
 * Fonts are loaded in each page's <head> via <link> (EB Garamond, Funnel Sans).
 */

/* ---------- Tokens ---------- */

:root {
  color-scheme: light dark;

  --font-body: "Funnel Sans", system-ui, sans-serif;
  --font-heading: "EB Garamond", Georgia, serif;

  --color-bg: #ffffff;
  --color-panel: #f2f2f2;
  --color-text: #444444;
  --color-muted: #5c5c5c;     /* 5.97:1 on panel */
  --color-link: #1a7059;      /* 5.35:1 on panel */
  --color-visited: #1c5d99;   /* 6.10:1 on panel */
  --color-border: #d6d6d6;
  --color-quote: #e4e4e4;
  --color-focus: #1c5d99;
  --logo-filter: none;

  --gutter: 16px;
  --measure: 46rem;
  --radius: 4px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --color-bg: #1a1c1e;
    --color-panel: #25282b;
    --color-text: #dddddd;
    --color-muted: #a8a8a8;
    --color-link: #5fd3b4;
    --color-visited: #8ab8e8;
    --color-border: #3b3f43;
    --color-quote: #31353a;
    --color-focus: #8ab8e8;
    --logo-filter: invert(0.87);
  }
}

/* ---------- Base ---------- */

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

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

body {
  margin: 0 auto;
  padding: 0 var(--gutter);
  max-width: calc(var(--measure) + 2 * var(--gutter));
  font: 1rem/1.5 var(--font-body);
  color: var(--color-text);
  background-color: var(--color-bg);
  overflow-wrap: break-word;
}

h1, h2, h3 {
  font-family: var(--font-heading);
  font-weight: 500;
  line-height: 1.2;
  text-wrap: balance;
}

h1 { font-size: 2rem; }
h2 { font-size: 1.6rem; margin-top: 2em; }
h3 { font-size: 1.25rem; }

p {
  hyphens: auto;
}

img, svg {
  max-width: 100%;
  height: auto;
}

/* ---------- Links & focus ---------- */

a {
  color: var(--color-link);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.15em;
}

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

a:hover {
  text-decoration-thickness: 2px;
}

:focus-visible {
  outline: 3px solid var(--color-focus);
  outline-offset: 2px;
  border-radius: 2px;
}

.skip-link {
  position: absolute;
  left: var(--gutter);
  top: -100px;
  z-index: 10;
  padding: 0.5em 1em;
  background: var(--color-panel);
  color: var(--color-text);
}

.skip-link:focus {
  top: var(--gutter);
}

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* ---------- Header, main, footer ---------- */

site-header,
site-footer {
  display: block;
}

site-header > header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem 1.5rem;
  padding: 1rem 0;
}

.site-title {
  font-family: var(--font-heading);
  font-size: 1.5rem;
  line-height: 1.2;
  color: var(--color-text);
  text-decoration: none;
}

.site-title:visited {
  color: var(--color-text);
}

.site-logo {
  display: block;
  height: 28px;
  width: auto;
  filter: var(--logo-filter);
}

site-header nav ul {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

site-header nav a,
site-header nav a:visited {
  display: inline-block;
  min-height: 24px;
  padding: 0.15em 0.25em;
  color: var(--color-text);
  text-decoration: none;
}

site-header nav a:hover {
  background-color: var(--color-panel);
}

site-header nav a[aria-current="page"] {
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 0.3em;
}

main {
  padding: clamp(20px, 5vw, 36px) clamp(16px, 5vw, 48px);
  background-color: var(--color-panel);
}

main > :first-child {
  margin-top: 0;
}

site-footer > footer {
  padding: 1.5rem 0 2rem;
  font-size: 0.85rem;
  color: var(--color-muted);
}

site-footer p {
  margin: 0;
}

/* ---------- Profile card ---------- */

profile-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 1.5rem;
  align-items: start;
}

@media (min-width: 40rem) {
  profile-card {
    grid-template-columns: 11rem minmax(0, 1fr);
  }
}

.portrait {
  display: block;
  width: 11rem;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 50%;
}

profile-card h1 {
  margin: 0 0 0.25rem;
}

.affiliation {
  margin: 0 0 1rem;
  color: var(--color-muted);
}

.profile-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1.25rem;
  margin: 1rem 0 0;
  padding: 0;
  list-style: none;
}

/* ---------- News ---------- */

news-feed,
news-item {
  display: block;
}

news-feed > ol {
  margin: 0;
  padding: 0;
  list-style: none;
}

news-item article {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0 1rem;
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--color-border);
}

news-feed li:last-child news-item article {
  border-bottom: 0;
}

@media (min-width: 34rem) {
  news-item article {
    grid-template-columns: 7.5rem minmax(0, 1fr);
  }
}

news-item time {
  color: var(--color-muted);
  font-variant-numeric: tabular-nums;
}

news-item p {
  margin: 0;
}

/* ---------- Publications ---------- */

pub-list,
pub-entry {
  display: block;
}

pub-list > ol {
  margin: 0;
  padding: 0;
  list-style: none;
}

pub-entry {
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--color-border);
}

pub-list li:last-child pub-entry {
  border-bottom: 0;
}

pub-entry h3 {
  margin: 0 0 0.2rem;
  font-size: 1.2rem;
}

pub-entry cite {
  font-style: normal;
}

pub-entry p {
  margin: 0;
}

.pub-authors strong {
  font-weight: 600;
}

.pub-venue {
  color: var(--color-muted);
  font-style: italic;
}

.pub-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1rem;
  margin: 0.35rem 0 0;
  padding: 0;
  list-style: none;
  font-size: 0.9rem;
}

.pub-links a {
  display: inline-block;
  min-height: 24px;
}

details {
  margin-top: 0.35rem;
  font-size: 0.9rem;
}

summary {
  cursor: pointer;
  min-height: 24px;
  color: var(--color-link);
}

details pre {
  padding: 0.75rem;
  background: var(--color-bg);
  border-radius: var(--radius);
  font-size: 0.8rem;
}

.section-more {
  margin-top: 1rem;
}

/* ---------- Blog ---------- */

.article-list {
  padding: 0;
  list-style: none;
}

.article-list li {
  margin: 0.4rem 0;
  font-size: 1.2rem;
}

.article-list time {
  display: block;
  font-size: 0.85rem;
  color: var(--color-muted);
}

site-footer nav ul {
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

blockquote {
  margin: 0;
  padding: 0.05px 0.75em;
  background-color: var(--color-quote);
}

code {
  font-size: 0.9em;
}

/* Wrap long lines instead of scrolling: scroll containers would need
   tabindex (not possible in generated markup) to be keyboard-accessible. */
pre {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

table {
  margin: 10px auto;
  border-collapse: collapse;
}

td {
  padding: 0.3em;
  vertical-align: middle;
  text-align: center;
  border-right: 1px solid currentColor;
}

td:last-child {
  border-right: none;
}

tbody tr:nth-child(odd) {
  background-color: color-mix(in srgb, currentColor 7%, transparent);
}

/* ---------- Motion ---------- */

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