/* ---------------------------------------------------------------
   matibonfanti.github.io/mb
   Single stylesheet for every page. Keep it small and readable.
   --------------------------------------------------------------- */

:root {
  --bg: #fefefe;
  --fg: #333;
  --muted: #555;
  --faint: #888;
  --rule: #e4e4e4;
  --link: #007acc;
}

/* Dark is opt-in via the toggle only — it does not follow the OS setting. */
:root[data-theme="dark"] {
  --bg: #16181a;
  --fg: #d8d8d6;
  --muted: #a8a8a4;
  --faint: #7d7d79;
  --rule: #2c2f32;
  --link: #5cb3f0;
}

* { box-sizing: border-box; }

body {
  font-family: "Fira Code", ui-monospace, SFMono-Regular, Menlo, monospace;
  color: var(--fg);
  background-color: var(--bg);
  margin: auto;
  padding: 2rem 1.25rem 4rem;
  max-width: 700px;
  line-height: 1.6;
  font-size: 1rem;
}

/* ---------- headings ---------- */

h1 {
  font-size: 2rem;
  font-weight: 700;
  text-align: left;
  margin: 0 0 0.25rem;
  line-height: 1.2;
}

h2 {
  font-size: 1.3rem;
  font-weight: 600;
  margin-top: 2.5rem;
  margin-bottom: 0.5rem;
}

h3 {
  font-size: 1rem;
  font-weight: 700;
  text-decoration: underline;
  margin-top: 1.75rem;
  margin-bottom: 0.5rem;
  color: var(--fg);
}

.description {
  font-size: 1rem;
  color: var(--muted);
  margin-top: 0.5rem;
  line-height: 1.5;
}

/* ---------- nav ---------- */

nav.site {
  margin: 1.5rem 0 0;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid var(--rule);
  font-size: 0.9rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 1.1rem;
}

nav.site a[aria-current="page"] {
  color: var(--fg);
  font-weight: 600;
  text-decoration: underline;
}

/* theme toggle sits at the top right, above everything else */
.topbar {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.topbar .back-home { margin-bottom: 0; }

#theme-toggle {
  margin-left: auto;
  font-family: inherit;
  font-size: 0.85rem;
  color: var(--faint);
  background: none;
  border: 1px solid var(--rule);
  border-radius: 3px;
  padding: 0.1rem 0.5rem;
  cursor: pointer;
  line-height: 1.5;
}

#theme-toggle:hover {
  color: var(--fg);
  border-color: var(--faint);
}

.back-home {
  display: inline-block;
  margin-bottom: 1.5rem;
  font-size: 0.9rem;
}

/* ---------- sections ---------- */

section { margin-bottom: 1rem; }

section p { margin: 0 0 1rem; }

/* ---------- lists ---------- */

ul { padding-left: 1.2rem; }

ul.plain {
  list-style: none;
  padding-left: 0;
}

li { margin-bottom: 0.8rem; }

/* ---------- entry index (research listing) ---------- */

ul.entries {
  list-style: none;
  padding-left: 0;
}

ul.entries li {
  padding-bottom: 1rem;
  margin-bottom: 1rem;
  border-bottom: 1px solid var(--rule);
}

ul.entries li:last-child { border-bottom: none; }

.entry-title {
  font-weight: 600;
  font-size: 1.05rem;
}

.entry-meta {
  display: block;
  font-size: 0.8rem;
  color: var(--faint);
  margin-top: 0.15rem;
}

.entry-summary {
  margin: 0.4rem 0 0;
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.5;
}

/* ---------- empty state ---------- */

.empty {
  border: 1px dashed var(--rule);
  padding: 1.25rem;
  color: var(--muted);
  font-size: 0.95rem;
}

.empty p:last-child { margin-bottom: 0; }

/* ---------- figures ---------- */

figure {
  margin: 2.25rem 0;
}

figure img {
  display: block;
  width: 100%;
  height: auto;
  background: #fff;
  border: 1px solid var(--rule);
  border-radius: 3px;
}

figcaption {
  font-size: 0.8rem;
  color: var(--faint);
  line-height: 1.45;
  margin-top: 0.5rem;
}

/* ---------- tables ---------- */

.table-wrap {
  overflow-x: auto;
  margin: 1.5rem 0;
}

table {
  border-collapse: collapse;
  width: 100%;
  min-width: 34rem;
  font-size: 0.85rem;
  line-height: 1.45;
}

th, td {
  border: 1px solid var(--rule);
  padding: 0.5rem 0.6rem;
  text-align: left;
  vertical-align: top;
}

th {
  font-weight: 600;
  color: var(--fg);
}

/* ---------- links ---------- */

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

a:hover { text-decoration: underline; }

/* ---------- footer ---------- */

footer {
  text-align: left;
  margin-top: 3.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--rule);
  font-size: 0.8rem;
  color: var(--faint);
}

footer a { color: var(--faint); text-decoration: underline; }

footer p { margin: 0.3rem 0; }

/* ---------- small screens ---------- */

@media (max-width: 480px) {
  body { padding: 1.5rem 1rem 3rem; }
  h1 { font-size: 1.6rem; }
  h2 { font-size: 1.15rem; }
}
