:root {
  color-scheme: light dark;
  --bg: #fbfaf7;
  --fg: #1b1a18;
  --muted: #6b6760;
  --line: #e4dfd6;
  --accent: #a94f2a;
  --code-bg: #f3f0e9;
  --max: 68rem;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121211;
    --fg: #eae6de;
    --muted: #a39d92;
    --line: #2a2824;
    --accent: #e08a5f;
    --code-bg: #1b1b18;
  }
}

html[data-theme="light"] {
  color-scheme: light;
  --bg: #fbfaf7;
  --fg: #1b1a18;
  --muted: #6b6760;
  --line: #e4dfd6;
  --accent: #a94f2a;
  --code-bg: #f3f0e9;
}

html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #121211;
  --fg: #eae6de;
  --muted: #a39d92;
  --line: #2a2824;
  --accent: #e08a5f;
  --code-bg: #1b1b18;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 16px/1.65 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.wrap {
  max-width: var(--max);
  margin: 0 auto;
  padding: 0 1.5rem;
}

.narrow {
  max-width: 44rem;
  margin: 0 auto;
}

.skip {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--fg);
  color: var(--bg);
  padding: 0.6rem 0.9rem;
  border-radius: 0.35rem;
  z-index: 10;
}

.skip:focus {
  left: 1rem;
  top: 1rem;
}

header.site {
  border-bottom: 1px solid var(--line);
}

header.site .wrap {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  padding-top: 1.5rem;
  padding-bottom: 1.5rem;
}

.brand {
  font-family: ui-serif, Georgia, "Iowan Old Style", "Palatino Linotype", serif;
  font-size: 1.1rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--fg);
  text-decoration: none;
}

nav {
  display: flex;
  gap: 1.25rem;
  font-size: 0.9rem;
}

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

nav a:hover,
nav a[aria-current="page"] {
  color: var(--accent);
}

.theme-toggle {
  padding: 0;
  border: 0;
  background: none;
  color: var(--muted);
  font: inherit;
  line-height: 1;
  cursor: pointer;
}

.theme-toggle:hover {
  color: var(--accent);
}

.theme-icon {
  display: inline-block;
  width: 1em;
  text-align: center;
}

.theme-icon::before {
  content: "☾";
}

html[data-theme="dark"] .theme-icon::before {
  content: "☀";
}

@media (prefers-color-scheme: dark) {
  html:not([data-theme]) .theme-icon::before {
    content: "☀";
  }
}

main {
  flex: 1;
  padding: 4rem 0 5rem;
}

.hero {
  margin-bottom: 4rem;
}

.eyebrow {
  margin: 0 0 1.25rem;
  color: var(--muted);
  font-size: 0.75rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

h1,
h2 {
  font-family: ui-serif, Georgia, "Iowan Old Style", "Palatino Linotype", serif;
  font-weight: 600;
  letter-spacing: -0.025em;
  line-height: 1.1;
}

h1 {
  margin: 0 0 1.25rem;
  font-size: clamp(2.4rem, 7vw, 3.8rem);
}

h2 {
  margin: 0 0 1rem;
  font-size: 1.35rem;
}

p {
  margin: 0 0 1rem;
}

.lede {
  max-width: 60ch;
  margin: 0 0 1.5rem;
  font-size: 1.15rem;
}

main p a,
main li a,
footer a {
  color: var(--accent);
  text-decoration: none;
}

main p a:hover,
main li a:hover,
footer a:hover {
  text-decoration: underline;
  text-underline-offset: 0.18em;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1rem;
  margin-top: 1.75rem;
}

.button {
  display: inline-block;
  padding: 0.65rem 1rem;
  border-radius: 0.35rem;
  background: var(--fg);
  color: var(--bg) !important;
  font-size: 0.9rem;
  font-weight: 500;
  text-decoration: none !important;
}

.button:hover {
  opacity: 0.85;
}

.text-link {
  color: var(--accent);
  font-size: 0.9rem;
  text-decoration: none;
}

.projects {
  margin: 0;
  padding: 0;
  list-style: none;
  border-top: 1px solid var(--line);
}

.project {
  padding: 1.25rem 0;
  border-bottom: 1px solid var(--line);
}

.project-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
}

.project h3 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.project h3 a {
  color: var(--fg);
  text-decoration: none;
}

.project h3 a:hover {
  color: var(--accent);
}

.project p {
  max-width: 60ch;
  margin: 0.35rem 0 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.tag {
  flex: none;
  padding: 0.1rem 0.5rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 0.72rem;
  white-space: nowrap;
}

.more {
  margin-top: 1.5rem;
  font-size: 0.95rem;
}

footer.site {
  padding: 1.5rem 0 2.5rem;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.85rem;
}

footer.site .wrap {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 1rem;
}

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

::selection {
  background: var(--accent);
  color: var(--bg);
}

.eyebrow a {
  color: var(--accent);
  text-decoration: none;
}

.eyebrow a:hover {
  text-decoration: underline;
}

.prose {
  max-width: 42rem;
  overflow-wrap: break-word;
}

.prose h1,
.prose h2,
.prose h3,
.prose h4 {
  font-family: ui-serif, Georgia, "Iowan Old Style", "Palatino Linotype", serif;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.prose h1 {
  margin: 2.5rem 0 1rem;
  font-size: 1.65rem;
}

.prose h2 {
  margin: 2.5rem 0 1rem;
  font-size: 1.45rem;
}

.prose h3 {
  margin: 2rem 0 0.75rem;
  font-size: 1.15rem;
}

.prose h4 {
  margin: 1.5rem 0 0.5rem;
  font-size: 1rem;
}

.prose p,
.prose ul,
.prose ol,
.prose blockquote,
.prose pre,
.prose table {
  margin: 0 0 1.1rem;
}

.prose ul,
.prose ol {
  padding-left: 1.4rem;
}

.prose li {
  margin: 0.3rem 0;
}

.prose code {
  padding: 0.12em 0.35em;
  border-radius: 0.25rem;
  background: var(--code-bg);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  font-size: 0.88em;
  overflow-wrap: anywhere;
}

.prose pre {
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: 0.5rem;
  background: var(--code-bg);
  overflow-x: auto;
}

.prose pre code {
  padding: 0;
  background: none;
  font-size: 0.84rem;
  line-height: 1.55;
  white-space: pre;
}

.prose pre {
  tab-size: 4;
}

.giallo-l {
  display: inline-block;
  min-height: 1lh;
  width: 100%;
}

.giallo-ln {
  display: inline-block;
  user-select: none;
  margin-right: 0.4em;
  padding: 0.4em;
  min-width: 3ch;
  text-align: right;
  opacity: 0.8;
}

.prose blockquote {
  padding: 0.25rem 0 0.25rem 1rem;
  border-left: 2px solid var(--accent);
  color: var(--muted);
}

.prose hr {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 2rem 0;
}

.prose table {
  display: block;
  width: 100%;
  overflow-x: auto;
  border-collapse: collapse;
  font-size: 0.9rem;
}

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

.prose th {
  font-weight: 600;
}

.prose a {
  color: var(--accent);
  text-decoration: none;
}

.prose a:hover {
  text-decoration: underline;
  text-underline-offset: 0.18em;
}

.prose img {
  max-width: 100%;
  height: auto;
  border-radius: 0.4rem;
}

.prose details {
  margin: 0 0 1.1rem;
}

.prose summary {
  cursor: pointer;
  color: var(--accent);
}

.project-layout {
  display: grid;
  grid-template-columns: 12rem minmax(0, 42rem);
  gap: 3.5rem;
  justify-content: center;
  align-items: start;
}

.project-nav {
  position: sticky;
  top: 2rem;
  font-size: 0.9rem;
  line-height: 1.5;
}

.project-nav .eyebrow {
  margin-bottom: 0.75rem;
}

.project-nav ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

.project-nav li {
  margin: 0.3rem 0;
}

.project-nav a {
  color: var(--muted);
  text-decoration: none;
}

.project-nav a:hover,
.project-nav a[aria-current="page"] {
  color: var(--accent);
}

.project-nav a[aria-current="page"] {
  font-weight: 600;
}

.project-nav-more {
  margin-top: 1.25rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--line);
}

.project-nav-more a {
  color: var(--accent);
}

.project-body {
  min-width: 0;
}

.page-toc {
  margin: 0 0 2rem;
  padding: 0.75rem 1rem;
  border: 1px solid var(--line);
  border-radius: 0.5rem;
  font-size: 0.9rem;
}

.page-toc summary {
  cursor: pointer;
  color: var(--accent);
}

.page-toc ul {
  margin: 0.5rem 0 0;
  padding-left: 1.1rem;
}

.page-toc li {
  margin: 0.25rem 0;
}

.page-toc a {
  color: var(--muted);
  text-decoration: none;
}

.page-toc a:hover {
  color: var(--accent);
}

@media (max-width: 860px) {
  .project-layout {
    display: block;
  }

  .project-nav {
    position: static;
    margin-bottom: 2.5rem;
  }

  .project-nav ul {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem 1rem;
  }

  .project-nav li {
    margin: 0;
  }
}

@media (max-width: 560px) {
  header.site .wrap {
    align-items: flex-start;
    flex-direction: column;
  }

  nav {
    gap: 1rem;
  }

  main {
    padding-top: 2.5rem;
  }

  .project-head {
    align-items: flex-start;
  }
}
