/* Base */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg:           #ffffff;
  --fg:           #030213;
  --muted-bg:     #ececf0;
  --muted-fg:     #717182;
  --border:       rgba(0, 0, 0, 0.1);
  --primary:      #030213;
  --primary-fg:   #ffffff;
  --nav-bg: rgba(255, 255, 255, 0.95);
  --radius:       0.625rem;
  --max-w:        72rem;
  --max-w-prose:  48rem;
  --touch-target: 2.75rem;
}

[data-theme="dark"] {
  --bg: #0e0e11;
  --fg: #f0f0f3;
  --muted-bg: #1c1c21;
  --muted-fg: #a1a1ab;
  --border: rgba(255, 255, 255, 0.12);
  --primary: #f0f0f3;
  --primary-fg: #0e0e11;
  --nav-bg: rgba(14, 14, 17, 0.95);
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

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

  *, *::before, *::after {
    /* Disables animations immediately while still able to track events */
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}

body {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
  background: var(--bg);
  color: var(--fg);
  line-height: 1.6;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
}

main {
  flex: 1;
}

a {
  color: inherit;
  text-decoration: none;
}

img {
  display: block;
  max-width: 100%;
}

ul {
  list-style: none;
}

h1, h2, h3 {
  font-weight: 500;
  line-height: 1.4;
}

h1 {
  font-size: 1.75rem;
}

h2 {
  font-size: 1.375rem;
}

h3 {
  font-size: 1.125rem;
}

/* Focus */
/* Add keyboard navigation outline for accessibility */
:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 3px;
  border-radius: 2px;
}

/* Remove outline for mouse users */
:focus:not(:focus-visible) {
  outline: none;
}

/* Button */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.75rem 1.5rem;
  border-radius: var(--radius);
  font-size: 0.9375rem;
  font-weight: 500;
  min-height: var(--touch-target);
  transition: opacity 0.15s;
  cursor: pointer;
  white-space: nowrap;
}

.btn--primary {
  background: var(--primary);
  color: var(--primary-fg);
}
.btn--primary:hover {
  opacity: 0.85;
}

.btn--outline {
  border: 1px solid var(--border);
  color: var(--fg);
  transition: border color 0.15s;
}
.btn--outline:hover {
  border-color: var(--fg);
}

.btn__icon {
  width: 24px;
  height: 24px;
  margin-right: 8px;
  object-fit: contain;
  flex-shrink: 0;
}

[data-theme="dark"] .btn__icon {
  filter: invert(1);
}

/* Navigation */
.skip-link {
  position: absolute;
  top: -100%;
  left: 1rem;
  z-index: 100;
  padding: 0.75rem 1.25rem;
  background: var(--primary);
  color: var(--primary-fg);
  font-size: 0.9375rem;
  font-weight: 500;
  border-radius: var(--radius);
  text-decoration: none;
  /* Transition for keyboard navigation */
  transition: top 0.15s;
}
.skip-link:focus {
  top: 1rem;
}

.site-nav {
  position: sticky;
  top: 0;
  z-index: 50;
  width: 100%;
  border-bottom: 1px solid var(--border);
  background: var(--nav-bg);
  backdrop-filter: blur(8px);
}

.site-nav__inner {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0 1.5rem;
  height: 4rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.site-nav__brand {
  font-weight: 500;
  transition: opacity 0.15s;
  min-height: var(--touch-target);
  display: inline-flex;
  align-items: center;
}
.site-nav__brand:hover {
  opacity: 0.7;
}

.site-nav__actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.site-nav__links {
  display: flex;
  gap: 1.5rem;
}

.site-nav__links a {
  color: var(--muted-fg);
  font-size: 0.9375rem;
  transition: color 0.15s;
  min-height: var(--touch-target);
  display: inline-flex;
  align-items: center;
}
.site-nav__links a:hover {
  color: var(--fg);
}

/* Navigation - Theme Toggle */
.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--touch-target);
  height: var(--touch-target);
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.5rem;
  border-radius: var(--radius);
}
.theme-toggle:hover {
  background: var(--muted-bg);
}

.theme-toggle__icon-dark {
  display: none;
}

[data-theme="dark"] .theme-toggle__icon-light {
  display: none;
}
[data-theme="dark"] .theme-toggle__icon-dark {
  display: block;
}

/* Navigation - Hamburger Menu */
.site-nav__toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: var(--touch-target);
  height: var(--touch-target);
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.5rem;
  border-radius: var(--radius);
}
.site-nav__toggle:hover {
  background: var(--muted-bg);
}

.site-nav__icon-close {
  display: none;
}

.site-nav__toggle[aria-expanded="true"] .site-nav__icon-open {
  display: none;
}
.site-nav__toggle[aria-expanded="true"] .site-nav__icon-close {
  display: block;
}

[data-theme="dark"] .site-nav__icon-open, 
[data-theme="dark"] .site-nav__icon-close {
  filter: invert(1);
}

/* Footer */
.site-footer {
  padding: 2rem 1.5rem;
  border-top: 1px solid var(--border);
  text-align: center;
  font-size: 0.875rem;
  color: var(--muted-fg);
}

/* Sections */
.section {
  padding: 5rem 1.5rem;
}

.section--muted {
  background: var(--muted-bg);
}

.section__inner {
  max-width: var(--max-w);
  margin: 0 auto;
}

.section__title {
  margin-bottom: 1rem;
}

/* About */
.about__layout {
  display: flex;
  align-items: center;
  gap: 4rem;
}

.about__image-wrap {
  flex-shrink: 0;
  width: 280px;
}

.about__image {
  width: 100%;
  aspect-ratio: 3 / 4;
  border-radius: 12px;
  object-fit: cover;
  object-position: center top;
  border: 1px solid var(--border);
  display: block;
}

.about__body {
  max-width: 44rem;
}

.about__lead {
  font-size: 1.1875rem;
  color: var(--muted-fg);
  margin-bottom: 1.25rem;
  line-height: 1.7;
}

.about__text {
  font-size: 1rem;
  color: var(--muted-fg);
  line-height: 1.7;
}

/* Project */
.project-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 2rem;
}

.project-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--bg);
  transition: box-shadow 0.2s;
  display: flex;
  flex-direction: column;
}
.project-card:hover {
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.08);
}

.project-card__image {
  width: 100%;
  height: 12rem;
  object-fit: cover;
  background: var(--muted-bg);
}

.project-card__body {
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  flex: 1;
}

.project-card__title {
  margin-bottom: 0.75rem;
}

.project-card__desc {
  color: var(--muted-fg);
  font-size: 0.9375rem;
  line-height: 1.6;
  margin-bottom: 1rem;
  flex: 1;
}

.project-card__tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.tag {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.25rem 0.75rem;
  background: var(--muted-bg);
  color: var(--muted-fg);
  border-radius: calc(var(--radius) - 2px);
  font-size: 0.8125rem;
}

.tag__icon {
  width: 14px;
  height: 14px;
  object-fit: contain;
  flex-shrink: 0;
}

.project-card__links {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: auto;
}

.link--primary {
  color: var(--primary);
  font-size: 0.9375rem;
  transition: text-decoration 0.1s;
  min-height: var(--touch-target);
  display: inline-flex;
  align-items: center;
}
.link--primary:hover {
  text-decoration: underline;
}

.link--muted {
  color: var(--muted-fg);
  font-size: 0.9375rem;
  transition: color 0.15s;
  min-height: var(--touch-target);
  display: inline-flex;
  align-items: center;
}
.link--muted:hover {
  color: var(--fg);
  text-decoration: underline;
}

/* Skills */
.skills-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 2rem;
}

.skills-group__label {
  color: var(--muted-fg);
  font-weight: 500;
  margin-bottom: 1rem;
}

.skills-group__list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.skills-group__item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9375rem;
}

.skills-group__icon {
  width: 16px;
  height: 16px;
  object-fit: contain;
  flex-shrink: 0;
}

.skills-group__dot {
  width: 6px;
  height: 6px;
  background: var(--primary);
  border-radius: 50%;
  flex-shrink: 0;
}

/* Contact */
.contact__inner {
  text-align: center;
  max-width: var(--max-w-prose);
  margin: 0 auto;
}

.contact__desc {
  font-size: 1.1875rem;
  color: var(--muted-fg);
  line-height: 1.7;
  margin-bottom: 2rem;
}

.contact__links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 1rem;
}

/* Project article page */
.article {
  padding: 3rem 1.5rem;
}

.article__inner {
  max-width: var(--max-w-prose);
  margin: 0 auto;
}

.article__back {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  color: var(--muted-fg);
  font-size: 0.9375rem;
  margin-bottom: 2rem;
  transition: color 0.15s;
  min-height: var(--touch-target);
}
.article__back:hover {
  color: var(--fg);
}

.article__header {
  margin-bottom: 2rem;
}
.article__header h1 {
  margin-bottom: 1rem;
}

.article__meta {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.875rem;
  color: var(--muted-fg);
  margin-bottom: 1rem;
}

.article__excerpt {
  font-size: 1.1875rem;
  color: var(--muted-fg);
  line-height: 1.7;
}

.article__screenshot {
  width: 100%;
  height: auto;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  margin: 1.5rem 0;
}

.article__tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 1.5rem;
}

.article__footer {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  align-items: flex-end;
  margin-top: 3rem;
  padding-top: 2rem;
  border-top: 1px solid var(--border);
}
.article__footer .article__back {
  align-self: flex-start;
}

/* Prose */
.prose {
  line-height: 1.75;
}

.prose h1,
.prose h2,
.prose h3 {
  scroll-margin-top: 4rem;
}

.prose h2 {
  margin: 2.5rem 0 1rem;
}

.prose h3 {
  margin: 2rem 0 0.75rem;
}

.prose p {
  color: var(--muted-fg);
  margin-bottom: 1.25rem;
}

.prose a {
  color: var(--primary);
  text-decoration: underline;
}
.prose a:hover {
  text-decoration-thickness: 2px;
}

.prose code {
  font-family: "SF Mono", "Fira Code", monospace;
  font-size: 0.875em;
  background: var(--muted-bg);
  padding: 0.125rem 0.375rem;
  border-radius: 4px;
}

.prose pre {
  background: var(--fg);
  color: var(--bg);
  padding: 1.25rem 1.5rem;
  border-radius: var(--radius);
  overflow-x: auto;
  margin-bottom: 1.5rem;
  white-space: pre;
  word-break: normal;
  overflow-wrap: normal;
}
.prose pre code {
  background: none;
  padding: 0;
  color: inherit;
}

.prose ul,
.prose ol {
  padding-left: 1.5rem;
  margin-bottom: 1.25rem;
}

.prose ul {
  list-style: disc;
}

.prose ol {
  list-style: decimal;
}

.prose ul li,
.prose ol li {
  color: var(--muted-fg);
  margin-bottom: 0.375rem;
}

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

.prose th, .prose td {
  padding: 0.625rem 0.875rem;
  border: 1px solid var(--border);
  text-align: left;
}
.prose th {
  background: var(--muted-bg);
  font-weight: 500;
}

/* Responsiveness */
@media (max-width: 768px) {
  .about__image-wrap {
    width: 220px;
  }

  .project-grid {
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  }
}

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

  .btn {
    width: 100%;
    max-width: 20rem;
  }

  /* Navigation - show hamburger, hide link by default */
  .site-nav__toggle {
    display: flex;
  }

  .site-nav__links {
    display: none;
    position: absolute;
    top: 4rem;
    left: 0;
    right: 0;
    flex-direction: column;
    gap: 0;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    padding: 0.5rem 0;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
  }
  
  /* Navigation - show link when toggled */
  .site-nav__links.is-open {
    display: flex;
  }

  .site-nav__links li {
    width: 100%;
  }

  .site-nav__links a {
    display: flex;
    align-items: center;
    padding: 0 1.5rem;
    width: 100%;
    min-height: var(--touch-target);
    font-size: 1rem;
    color: var(--fg);
    border-bottom: 1px solid var(--border);
  }
  .site-nav__links li:last-child a {
    border-bottom: none;
  }

  .section {
    padding: 3rem 1.25rem;
  }
  
  .about__layout {
    flex-direction: column;
    align-items: flex-start;
    gap: 2rem;
  }

  .about__image-wrap {
    width: 140px;
  }

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

  .skills-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .contact__links {
    flex-direction: column;
    align-items: center;
  }

  .article {
    padding: 2rem 1.25 rem;
  }
}

/* High contrast mode support */
@media (forced-colors: active) {
  .project-card, 
  .tag, 
  .btn--outline, 
  .project-card__image[role="img"],
  .site-nav__toggle,
  .site-nav,
  .prose pre {
    border: 1px solid ButtonText;
  }

  .skills-group__dot {
    forced-color-adjust: none;
  }

  :focus-visible {
    outline-color: Highlight;
  }
}