:root {
  color-scheme: dark;
  --background: #11110f;
  --surface: #191916;
  --surface-raised: #20201c;
  --text: #e8e3d7;
  --text-strong: #fffaf0;
  --muted: #9d998e;
  --faint: #858178;
  --accent: #dc7b45;
  --accent-bright: #f09a68;
  --danger: #d45b4e;
  --rule: #36352f;
  --serif: Charter, "Bitstream Charter", "Sitka Text", Cambria, Georgia, serif;
  --sans: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}

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

html {
  font-size: 100%;
  scroll-behavior: smooth;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(circle at 15% 0%, rgba(220, 123, 69, 0.055), transparent 29rem),
    var(--background);
  font-family: var(--sans);
  font-size: 1.0625rem;
  line-height: 1.7;
  text-rendering: optimizeLegibility;
}

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

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

a {
  color: var(--accent-bright);
  text-decoration-color: color-mix(in srgb, var(--accent) 65%, transparent);
  text-underline-offset: 0.18em;
}

a:hover {
  color: var(--text-strong);
  text-decoration-color: var(--accent-bright);
}

/* Masthead */
.site-header {
  border-bottom: 1px solid var(--rule);
  background: rgba(17, 17, 15, 0.92);
}

.masthead {
  display: grid;
  grid-template-columns: minmax(14rem, 1fr) auto auto;
  gap: clamp(2rem, 5vw, 5rem);
  align-items: center;
  width: min(100% - 3rem, 76rem);
  min-height: 8.5rem;
  margin: 0 auto;
}

.site-title,
.tagline {
  margin: 0;
}

.site-title {
  font-family: var(--serif);
  font-size: clamp(1.7rem, 3vw, 2.25rem);
  font-weight: 700;
  line-height: 1.05;
}

.site-title a {
  color: var(--text-strong);
  text-decoration: none;
}

.site-title a::after {
  color: var(--accent);
  content: ".";
}

.tagline {
  margin-top: 0.45rem;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0.02em;
}

.primary-nav,
.social-links {
  display: flex;
  align-items: center;
}

.primary-nav {
  gap: clamp(1rem, 2.5vw, 2rem);
}

.nav-link {
  position: relative;
  padding: 0.6rem 0;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-decoration: none;
  text-transform: uppercase;
}

.nav-link::after {
  position: absolute;
  right: 0;
  bottom: 0.25rem;
  left: 0;
  height: 1px;
  background: var(--accent);
  content: "";
  opacity: 0;
  transform: scaleX(0.5);
  transition: opacity 160ms ease, transform 160ms ease;
}

.nav-link:hover,
.nav-link.active {
  color: var(--text-strong);
}

.nav-link:hover::after,
.nav-link.active::after {
  opacity: 1;
  transform: scaleX(1);
}

.draft-link {
  color: var(--accent-bright);
}

.social-links {
  gap: 0.9rem;
}

.social-link {
  display: flex;
  color: var(--faint);
  transition: color 160ms ease;
}

.social-link:hover {
  color: var(--text-strong);
}

.social-icon {
  width: 1.05rem;
  height: 1.05rem;
}

/* Page frame */
.main-content {
  width: min(100% - 3rem, 76rem);
  margin: 0 auto;
  padding: clamp(3rem, 6vw, 5rem) 0 7rem;
}

.page-content {
  width: 100%;
}

.page-header {
  position: relative;
  display: grid;
  grid-template-columns: minmax(6rem, 9rem) minmax(0, 1fr);
  gap: clamp(1.5rem, 4vw, 3rem);
  align-items: end;
  margin-bottom: clamp(2.75rem, 5vw, 4rem);
  padding-bottom: 1.25rem;
  border-bottom: 1px solid var(--rule);
}

.page-header::after {
  position: absolute;
  bottom: -1px;
  left: 0;
  width: 5rem;
  height: 1px;
  background: var(--accent);
  content: "";
}

.eyebrow {
  margin: 0 0 0.35rem;
  color: var(--accent-bright);
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.page-header h1,
.page-content > h1,
.container > h1 {
  max-width: 14ch;
  margin: 0;
  color: var(--text-strong);
  font-family: var(--serif);
  font-size: clamp(2.75rem, 5vw, 4.75rem);
  font-weight: 500;
  letter-spacing: -0.035em;
  line-height: 1;
}

.page-content h2,
.container h2 {
  color: var(--text-strong);
  font-family: var(--serif);
}

/* Post index */
.posts-list,
.posts {
  width: 100%;
}

.post-preview {
  display: grid;
  grid-template-columns: 3.5rem minmax(0, 1fr) minmax(10rem, 15rem);
  gap: clamp(1rem, 3vw, 2.5rem);
  align-items: start;
  padding: clamp(2rem, 4vw, 3rem) 0;
  border-bottom: 1px solid var(--rule);
}

.post-preview:first-child {
  padding-top: 0;
}

.post-marker {
  padding-top: 0.55rem;
  color: var(--accent);
  font-family: var(--mono);
  font-size: 0.7rem;
}

.post-preview h2 {
  margin: 0;
  font-size: clamp(1.7rem, 3vw, 2.5rem);
  font-weight: 500;
  letter-spacing: -0.025em;
  line-height: 1.1;
}

.post-preview h2 a {
  color: var(--text-strong);
  text-decoration: none;
}

.post-preview h2 a:hover {
  color: var(--accent-bright);
}

.post-preview h2 code,
.post-header h1 code,
.post-navigation-link strong code {
  padding: 0;
  color: var(--accent-bright);
  background: transparent;
  font-family: var(--mono);
  font-size: 0.78em;
  font-weight: 500;
  letter-spacing: -0.04em;
}

.post-description {
  color: var(--muted);
}

.post-preview .post-description {
  max-width: 52rem;
  margin: 0.9rem 0 0;
  line-height: 1.6;
}

.post-meta {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.post-preview-meta {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  align-items: flex-end;
  padding-top: 0.45rem;
  text-align: right;
}

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem 0.85rem;
}

.post-preview-meta .tags {
  justify-content: flex-end;
}

.tag {
  position: relative;
  color: var(--muted);
  text-decoration: none;
}

.tag::before {
  color: var(--accent);
  content: "#";
}

.tag:hover {
  color: var(--text-strong);
}

/* Article */
.post {
  width: min(100%, 48rem);
  margin: 0 auto;
}

.post-header {
  margin-bottom: clamp(3rem, 6vw, 4rem);
  padding-bottom: 2rem;
  border-bottom: 1px solid var(--rule);
}

.post-header h1 {
  margin: 0;
  color: var(--text-strong);
  font-family: var(--serif);
  font-size: clamp(2.75rem, 7vw, 4.5rem);
  font-weight: 500;
  letter-spacing: -0.045em;
  line-height: 0.98;
}

.post-header .post-description {
  max-width: 38rem;
  margin: 1.5rem 0 0;
  color: var(--muted);
  font-family: var(--serif);
  font-size: clamp(1.15rem, 2.5vw, 1.4rem);
  font-style: italic;
  line-height: 1.5;
}

.post-header .post-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem 2rem;
  align-items: center;
  justify-content: space-between;
  margin-top: 2rem;
}

.post-content {
  font-family: var(--serif);
  font-size: clamp(1.08rem, 2vw, 1.2rem);
  line-height: 1.8;
}

.post-content p,
.post-content ul,
.post-content ol,
.post-content pre,
.post-content blockquote {
  margin-top: 0;
  margin-bottom: 1.65em;
}

.post-content h1,
.post-content h2,
.post-content h3 {
  margin: 2.4em 0 0.75em;
  color: var(--text-strong);
  font-family: var(--serif);
  line-height: 1.15;
}

.post-content h2 {
  font-size: 1.75em;
}

.post-content h3 {
  font-size: 1.35em;
}

.post-content blockquote {
  margin-left: 0;
  padding: 0.2rem 0 0.2rem 1.5rem;
  border-left: 2px solid var(--accent);
  color: var(--muted);
  font-style: italic;
}

.post-content code,
.no-projects code {
  padding: 0.16rem 0.35rem;
  color: var(--text-strong);
  background: var(--surface-raised);
  font-family: var(--mono);
  font-size: 0.82em;
}

.post-content pre {
  overflow-x: auto;
  padding: 1.4rem;
  border: 1px solid var(--rule);
  background: var(--surface);
  font-size: 0.88rem;
  line-height: 1.65;
}

.post-content pre code {
  padding: 0;
  background: transparent;
}

.post-content img {
  max-width: 100%;
  height: auto;
}

.post-footer {
  margin-top: 4rem;
  border-top: 1px solid var(--rule);
  font-family: var(--mono);
}

.post-footer a {
  text-decoration: none;
}

.post-navigation {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 1.5rem;
  align-items: center;
}

.post-navigation-link {
  display: grid;
  gap: 0.35rem;
  padding: 1.5rem 0;
}

.post-navigation-link span {
  color: var(--accent-bright);
  font-size: 0.65rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.post-navigation-link strong {
  color: var(--text-strong);
  font-family: var(--serif);
  font-size: 1rem;
  font-weight: 500;
  line-height: 1.3;
}

.post-navigation-link:hover strong {
  color: var(--accent-bright);
}

.previous-post {
  grid-column: 1;
}

.next-post {
  grid-column: 3;
  text-align: right;
}

.posts-return-link {
  grid-column: 2;
  color: var(--muted);
  font-size: 0.7rem;
  white-space: nowrap;
}

.draft-notice {
  margin-bottom: 2rem;
  padding: 0.8rem 1rem;
  border: 1px solid var(--accent);
  color: var(--text-strong);
  font-family: var(--mono);
  font-size: 0.75rem;
  text-transform: uppercase;
}

/* Projects */
.projects-section > p:first-child {
  max-width: 44rem;
  margin: -2.5rem 0 4rem;
  color: var(--muted);
}

.activity-section {
  margin-bottom: 5rem;
}

.activity-header {
  display: flex;
  gap: 1rem;
  align-items: center;
  margin: 0 0 1.5rem;
  padding-bottom: 0.7rem;
  border-bottom: 1px solid var(--rule);
  font-family: var(--mono) !important;
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.activity-header::before {
  width: 0.45rem;
  height: 0.45rem;
  background: currentColor;
  content: "";
}

.activity-header.high-activity {
  color: var(--danger);
}

.activity-header.medium-activity {
  color: var(--accent-bright);
}

.activity-header.low-activity {
  color: var(--muted);
}

.project-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  border-top: 1px solid var(--rule);
  border-left: 1px solid var(--rule);
}

.project-card {
  min-width: 0;
  padding: clamp(1.5rem, 3vw, 2.25rem);
  border-right: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
  background: var(--background);
  transition: background 160ms ease;
}

.project-card:hover {
  background: var(--surface);
}

.project-header {
  display: flex;
  flex-direction: column-reverse;
  gap: 1.25rem;
}

.project-header h3 {
  margin: 0;
  font-size: clamp(1.45rem, 3vw, 2rem);
  font-weight: 500;
  line-height: 1.1;
}

.project-link {
  color: var(--text-strong);
  text-decoration: none;
}

.project-link::after,
.external-link::after {
  margin-left: 0.35em;
  color: var(--accent);
  content: "↗";
  font-family: var(--sans);
  font-size: 0.7em;
}

.project-link:hover {
  color: var(--accent-bright);
}

.project-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.25rem;
  color: var(--faint);
  font-family: var(--mono);
  font-size: 0.65rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.commit-count {
  color: var(--accent-bright);
}

.project-description {
  margin: 1.1rem 0 1.5rem;
  color: var(--muted);
  line-height: 1.6;
}

.project-tech {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.tech-tag {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.66rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.tech-tag::before {
  color: var(--accent);
  content: "[";
}

.tech-tag::after {
  color: var(--accent);
  content: "]";
}

.no-projects {
  padding: 3rem 0;
  color: var(--muted);
}

/* About and link index */
.about-section,
.links-section {
  width: min(100%, 48rem);
}

.about-sections {
  width: min(100%, 58rem);
}

.about-section {
  font-family: var(--serif);
  font-size: clamp(1.08rem, 2vw, 1.2rem);
  line-height: 1.8;
}

.about-sections .about-section {
  width: 100%;
  padding: 0 0 clamp(3.5rem, 8vw, 6rem);
}

.about-sections .about-section + .about-section {
  padding-top: clamp(3.5rem, 8vw, 6rem);
  border-top: 1px solid var(--rule);
}

.about-section h2 {
  margin: 0 0 1.5rem;
  color: var(--text-strong);
  font-size: clamp(1.8rem, 4vw, 2.5rem);
  font-weight: 500;
  letter-spacing: -0.025em;
}

.about-section p {
  margin: 0 0 1.6em;
}

.about-lede {
  max-width: 42rem;
  color: var(--text-strong);
  font-size: clamp(1.35rem, 3vw, 1.75rem);
  line-height: 1.5;
}

.archive-link {
  position: relative;
  display: grid;
  gap: 0.45rem;
  padding: clamp(1.5rem, 4vw, 2.25rem);
  border: 1px solid var(--rule);
  color: var(--text);
  background: var(--background);
  text-decoration: none;
  transition: border-color 160ms ease, background 160ms ease;
}

.archive-link::after {
  position: absolute;
  top: 1.5rem;
  right: 1.5rem;
  color: var(--accent);
  content: "↗";
  font-family: var(--sans);
}

.archive-link:hover {
  border-color: var(--accent);
  color: var(--text);
  background: var(--surface);
}

.archive-kicker {
  color: var(--accent-bright);
  font-family: var(--mono);
  font-size: 0.65rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.archive-link strong {
  color: var(--text-strong);
  font-family: var(--serif);
  font-size: clamp(1.6rem, 4vw, 2.25rem);
  font-weight: 500;
}

.archive-link > span:last-child {
  max-width: 38rem;
  color: var(--muted);
  font-family: var(--sans);
  font-size: 0.95rem;
}

.page-content > .page-header + p {
  max-width: 48rem;
}

.links-category {
  margin-top: 4rem;
}

.links-category h2 {
  margin: 0 0 1rem;
  padding-bottom: 0.7rem;
  border-bottom: 1px solid var(--rule);
  font-size: 1.8rem;
  font-weight: 500;
}

.links-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.links-list li {
  padding: 1.4rem 0;
  border-bottom: 1px solid var(--rule);
}

.external-link {
  color: var(--text-strong);
  font-family: var(--serif);
  font-size: 1.25rem;
  font-weight: 600;
  text-decoration: none;
}

.link-url {
  overflow: hidden;
  margin-top: 0.2rem;
  color: var(--faint);
  font-family: var(--mono);
  font-size: 0.65rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.link-description {
  display: block;
  margin-top: 0.65rem;
  color: var(--muted);
}

/* Forms and private utility pages */
input:not([type="submit"]),
textarea,
select {
  width: 100%;
  max-width: 28rem;
  padding: 0.75rem;
  border: 1px solid var(--rule) !important;
  border-radius: 0 !important;
  color: var(--text) !important;
  background: var(--surface) !important;
  font: inherit;
}

input[type="submit"],
button {
  padding: 0.75rem 1.2rem !important;
  border: 1px solid var(--accent) !important;
  border-radius: 0 !important;
  color: var(--background) !important;
  background: var(--accent-bright) !important;
  font-family: var(--mono) !important;
  cursor: pointer;
}

table {
  color: var(--text);
}

th,
td {
  border-color: var(--rule) !important;
}

.analytics-filters .active {
  color: var(--text-strong);
  text-decoration-color: var(--accent);
}

@media (max-width: 900px) {
  .masthead {
    grid-template-columns: 1fr auto;
    gap: 1rem 2rem;
    padding: 1.5rem 0;
  }

  .primary-nav {
    grid-column: 1 / -1;
    grid-row: 2;
    justify-content: space-between;
    border-top: 1px solid var(--rule);
  }

  .post-preview {
    grid-template-columns: 2.5rem minmax(0, 1fr);
  }

  .post-preview-meta {
    grid-column: 2;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    padding-top: 0;
    text-align: left;
  }

  .post-preview-meta .tags {
    justify-content: flex-start;
  }
}

@media (max-width: 640px) {
  body {
    font-size: 1rem;
  }

  .masthead,
  .main-content {
    width: min(100% - 2rem, 76rem);
  }

  .masthead {
    grid-template-columns: 1fr;
    min-height: 0;
  }

  .social-links {
    position: absolute;
    top: 1.8rem;
    right: 1rem;
  }

  .primary-nav {
    grid-column: 1;
    overflow-x: auto;
    justify-content: flex-start;
    padding-top: 0.7rem;
    scrollbar-width: none;
  }

  .primary-nav::-webkit-scrollbar {
    display: none;
  }

  .main-content {
    padding-top: 3.5rem;
  }

  .page-header {
    grid-template-columns: 1fr;
    gap: 0.35rem;
    margin-bottom: 3rem;
  }

  .page-header h1,
  .page-content > h1,
  .container > h1 {
    font-size: clamp(2.6rem, 13vw, 3.5rem);
  }

  .post-preview {
    grid-template-columns: 1fr;
    gap: 0.75rem;
  }

  .post-marker,
  .post-preview-meta {
    grid-column: 1;
  }

  .post-marker {
    padding-top: 0;
  }

  .post-preview-meta {
    gap: 0.6rem 1rem;
  }

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

  .post-navigation {
    grid-template-columns: 1fr 1fr;
  }

  .previous-post,
  .next-post {
    grid-row: 1;
  }

  .next-post {
    grid-column: 2;
  }

  .posts-return-link {
    grid-column: 1 / -1;
    grid-row: 2;
    padding-top: 1rem;
    border-top: 1px solid var(--rule);
    text-align: center;
  }

  .project-grid {
    grid-template-columns: 1fr;
  }

}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
  }
}
