:root {
  --text: #e9e5e2;
  --background: #0b0a09;
  --primary: #c7bdb4;
  --secondary: #486060;
  --accent: #8486a2;
  --container-background: color-mix(in srgb, var(--secondary) 18%, var(--background));
  --page-background: color-mix(in srgb, var(--container-background) 97%, white);
  --muted-text: color-mix(in srgb, var(--text) 68%, var(--background));
  --code-background: #1e1e1e;
  --code-text: #dfdfdf;
  --code-keyword: #569cd6;
  --code-type: #4ec9b0;
  --code-struct: #86c691;
  --code-method: #dcdcaa;
  --code-local: #9cdcfe;
  --code-comment: #6a9955;
  --code-string: #ce9178;
  --code-number: #b8d7a3;
  --code-control: #c586c0;
  color-scheme: dark;
}

@media (prefers-color-scheme: light) {
  :root {
    --text: #1a2028;
    --background: #f7f8fb;
    --primary: #506a80;
    --secondary: #e8e0f3;
    --accent: #76568b;

    color-scheme: light;
  }
}

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

html {
  scroll-behavior: smooth;
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  background: var(--page-background);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.6;
  transition: background-color 180ms ease, color 180ms ease;
}

a {
  color: inherit;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--background);
  box-shadow: 0 4px 16px rgb(0 0 0 / 20%);
}

.top-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  width: min(100% - 3rem, 1120px);
  min-height: 4.5rem;
  margin: 0 auto;
}

.nav-links {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(1.5rem, 5vw, 3rem);
}

.nav-links a {
  color: var(--text);
  font-size: 0.9rem;
  font-weight: 600;
  text-decoration: none;
}

.nav-links a:hover,
.nav-links a:focus-visible {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 0.2em;
}

.social-links {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: clamp(1.25rem, 4vw, 2.5rem);
  margin-top: 2rem;
  margin-bottom: 2rem;
}

.blog-container {
  padding-top: clamp(3rem, 8vw, 6rem);
}

.projects-container {
  width: min(100% - 3rem, 1120px);
  padding-top: clamp(3rem, 8vw, 6rem);
}

.project-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.25rem;
  margin-top: 3rem;
}

.project-card {
  display: flex;
  min-width: 0;
  flex-direction: column;
  overflow: hidden;
  background: color-mix(in srgb, var(--primary) 7%, transparent);
}

.project-image {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 10;
  background: var(--background);
  object-fit: cover;
}

.project-card-body {
  display: flex;
  flex: 1;
  flex-direction: column;
  align-items: flex-start;
  padding: 1.25rem;
}

.project-card h2 {
  margin: 0 0 0.75rem;
  color: var(--text);
  font-size: 1.35rem;
  letter-spacing: -0.03em;
  line-height: 1.15;
}

.project-title-link {
  text-decoration: underline;
}

.project-title-link:hover,
.project-title-link:focus-visible {
  color: var(--accent);
}

.project-links {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1rem;
  margin-top: auto;
  padding-top: 1rem;
}

.project-link {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  text-decoration: underline;
}

.project-link:hover,
.project-link:focus-visible {
  color: var(--accent);
}

.project-link-icon {
  display: block;
  width: 1rem;
  height: 1rem;
  background: currentColor;
  color: var(--accent);
  -webkit-mask: url("content/projects/github.svg") center / contain no-repeat;
  mask: url("content/projects/github.svg") center / contain no-repeat;
}

.project-card p {
  margin: 0;
  color: var(--muted-text);
  font-size: 0.95rem;
}

.back-link {
  display: inline-block;
  margin-bottom: 2.5rem;
  color: var(--muted-text);
  font-size: 0.9rem;
  text-decoration: none;
}

.back-link:hover,
.back-link:focus-visible {
  color: var(--accent);
}

.blog-list {
  display: grid;
  gap: 0.75rem;
  margin-top: 3rem;
}

.blog-card {
  display: flex;
  align-items: center;
  padding: 1.25rem;
  background: color-mix(in srgb, var(--primary) 7%, transparent);
  color: var(--text);
  text-decoration: none;
}

.blog-card:hover,
.blog-card:focus-visible {
  background: color-mix(in srgb, var(--accent) 16%, transparent);
}

.blog-card strong,
.blog-card small {
  display: block;
}

.blog-card strong {
  font-size: 1rem;
  font-weight: 600;
}

.blog-card small,
.post-date {
  margin-top: 0.25rem;
  color: var(--muted-text);
  font-size: 0.8rem;
}

.markdown-body {
  color: var(--muted-text);
  line-height: 1.75;
}

.markdown-body img {
  display: block;
  max-width: 100%;
  height: auto;
}

.markdown-body h1,
.markdown-body h2,
.markdown-body h3,
.markdown-body h4 {
  max-width: none;
  margin-top: 2.5rem;
  margin-bottom: 1rem;
  font-size: clamp(1.4rem, 3vw, 2rem);
}

.markdown-body pre {
  max-width: 100%;
  overflow-x: auto;
}

.markdown-body pre.syntax-highlight {
  padding: 1rem;
  background: var(--code-background);
  color: var(--code-text);
  font-family: Monaco, Consolas, "Lucida Console", monospace;
  line-height: 1.5;
}

.syntax-highlight .syntax-keyword {
  color: var(--code-keyword);
}

.syntax-highlight .syntax-type {
  color: var(--code-type);
}

.syntax-highlight .syntax-struct {
  color: var(--code-struct);
}

.syntax-highlight .syntax-method {
  color: var(--code-method);
}

.syntax-highlight .syntax-local {
  color: var(--code-local);
}

.syntax-highlight .syntax-comment {
  color: var(--code-comment);
}

.comments-section {
  margin-top: 4rem;
}

.social-links a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.35rem;
  border-radius: 0.5rem;
  text-decoration: none;
  transition: background-color 160ms ease;
}

.social-links a:hover,
.social-links a:focus-visible {
  background: color-mix(in srgb, var(--accent) 16%, transparent);
}

.social-icon {
  display: block;
  width: 1.5rem;
  height: 1.5rem;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

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

.text-container {
  width: min(100% - 3rem, 960px);
  min-height: calc(100vh - 4.5rem);
  margin: 0 auto;
  padding: clamp(5rem, 12vh, 9rem) clamp(2rem, 6vw, 5rem) 5rem;
  background: var(--container-background);
}

h1,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  color: var(--text);
  font-size: clamp(2rem, 5vw, 3.5rem);
  font-weight: 700;
  letter-spacing: -0.05em;
  line-height: 1.05;
}

.intro {
  max-width: 34rem;
  margin-bottom: 0;
  color: var(--muted-text);
  font-size: clamp(1.1rem, 2vw, 1.3rem);
}

.home-intro {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(0, 1fr);
  align-items: start;
  gap: clamp(2rem, 6vw, 4rem);
}

.misty {
  width: 100%;
  margin: 0;
}

.misty img {
  display: block;
  width: 100%;
  height: auto;
}

.misty figcaption {
  margin-top: 0.5rem;
  color: var(--muted-text);
  font-size: 0.9rem;
  font-weight: 700;
  text-align: center;
}

.sticky-notes {
  margin-top: 4rem;
}

.sticky-notes-heading h2 {
  margin: 0;
  color: var(--text);
  font-size: clamp(1.5rem, 3vw, 2rem);
  letter-spacing: -0.03em;
}

.sticky-notes-heading p {
  margin: 0.35rem 0 0;
  color: var(--muted-text);
}

.sticky-form {
  width: 100%;
  aspect-ratio: 1;
}

.sticky-input {
  position: relative;
  width: 100%;
  height: 100%;
}

.sticky-input::before,
.sticky-input::after {
  position: absolute;
  z-index: 0;
  content: "";
  pointer-events: none;
}

.sticky-input::before {
  inset: 0.35rem -0.45rem -0.45rem 0.35rem;
  background: #f4d35e;
  transform: rotate(2deg);
}

.sticky-input::after {
  inset: 0.2rem -0.25rem -0.25rem 0.2rem;
  background: #f4d35e;
  transform: rotate(-1.2deg);
}

.sticky-form textarea {
  display: block;
  position: relative;
  width: 100%;
  height: 100%;
  padding: 1.25rem;
  border: 0;
  background: #f4d35e;
  box-shadow: 0.25rem 0.35rem 0.8rem rgb(0 0 0 / 26%);
  color: #3f351d;
  font-family: "Caveat", cursive;
  font-size: 1.5rem;
  line-height: 1.2;
  resize: none;
  align-content: center;
  text-align: center;
  z-index: 1;
}

.sticky-form textarea::placeholder {
  color: #75653a;
}

.sticky-form textarea:focus-visible {
  outline: none;
}

.sticky-count {
  position: absolute;
  top: 0.75rem;
  right: 1.25rem;
  z-index: 2;
  pointer-events: none;
  font-family: "Caveat", cursive;
  font-size: 1.15rem;
  color: #75653a;
}

.sticky-status {
  min-height: 1.25rem;
  margin: 0.75rem 0 0;
  color: var(--muted-text);
  font-size: 0.85rem;
}

.sticky-form button {
  position: absolute;
  right: 0.7rem;
  bottom: 0.7rem;
  display: grid;
  width: 2.25rem;
  height: 2.25rem;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--accent);
  font-family: "Caveat", cursive;
  font-size: 1.45rem;
  font-weight: 700;
  line-height: 1;
  place-items: center;
  cursor: pointer;
  z-index: 2;
}

.sticky-form button:hover,
.sticky-form button:focus-visible {
  background: transparent;
  color: color-mix(in srgb, var(--accent) 82%, white);
}

.sticky-form button:disabled {
  cursor: wait;
  opacity: 0.6;
}

.sticky-status[data-error="true"] {
  color: #c78080;
}

.sticky-list {
  display: grid;
  width: 100%;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 14rem), 1fr));
  gap: clamp(1.25rem, 3vw, 2rem);
  margin-top: 2.5rem;
}

.sticky-note {
  display: flex;
  flex-direction: column;
  align-items: center;
  aspect-ratio: 1;
  padding: 1.15rem 1.25rem 1rem;
  background: #f4d35e;
  box-shadow: 0.25rem 0.35rem 0.8rem rgb(0 0 0 / 26%);
  color: #3f351d;
  font-family: "Caveat", cursive;
  text-align: center;
}

.sticky-note:nth-child(3n + 2) {
  background: #f7dc76;
  transform: rotate(1deg);
}

.sticky-note:nth-child(3n) {
  background: #efd05a;
  transform: rotate(-0.7deg);
}

.sticky-note-content {
  display: flex;
  flex: 1;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 0;
  margin: 0;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
  font-size: 1.7rem;
  line-height: 1.1;
}

.sticky-note-time {
  margin-top: auto;
  padding-top: 1rem;
  font-size: 1rem;
  opacity: 0.65;
}

.sticky-state {
  margin: 0;
  color: var(--muted-text);
}

.sticky-state-error {
  color: #c78080;
}

@media (max-width: 640px) {
  .top-bar {
    width: min(100% - 2rem, 1120px);
    padding: 1rem 0;
  }

  .text-container {
    width: 100%;
    min-height: calc(100vh - 4.5rem);
    padding: 5rem 1.25rem 4rem;
  }

  .social-links {
    flex-wrap: wrap;
    gap: 0.35rem 1rem;
  }

  .home-intro {
    grid-template-columns: 1fr;
  }

  .misty {
    display: none;
  }

  .blog-card {
    padding: 1rem;
  }

  .projects-container {
    width: 100%;
  }

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

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

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