:root,
:root[data-theme="dark"] {
  color-scheme: dark;
  --background: #0b0f14;
  --header-background: rgba(11, 15, 20, 0.88);
  --surface: #0e1319;
  --surface-hover: #121820;
  --text: #f5f7f8;
  --muted: #9199a3;
  --muted-strong: #b7bec6;
  --border: rgba(255, 255, 255, 0.1);
  --border-hover: rgba(255, 255, 255, 0.2);
  --toggle-hover: rgba(255, 255, 255, 0.055);
  --menu-shadow: 0 18px 42px rgba(0, 0, 0, 0.34);
  --dev: #56d364;
  --paused: #e3b341;
  --abandoned: #9da7b3;
}

:root[data-theme="light"] {
  color-scheme: light;
  --background: #ffffff;
  --header-background: rgba(255, 255, 255, 0.9);
  --surface: #ffffff;
  --surface-hover: #f6f7f8;
  --text: #111418;
  --muted: #69717a;
  --muted-strong: #4e5660;
  --border: rgba(12, 18, 24, 0.1);
  --border-hover: rgba(12, 18, 24, 0.2);
  --toggle-hover: rgba(12, 18, 24, 0.055);
  --menu-shadow: 0 18px 42px rgba(20, 24, 28, 0.12);
  --dev: #1a7f37;
  --paused: #9a6700;
  --abandoned: #66707b;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--background);
  color: var(--text);
  font-family:
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  transition:
    background-color 280ms ease,
    color 280ms ease;
}

a {
  color: inherit;
}

button {
  font: inherit;
}

.container {
  width: min(1180px, calc(100% - 48px));
  margin: 0 auto;
}

/* Header */

header {
  position: sticky;
  top: 0;
  z-index: 1000;
  border-bottom: 1px solid var(--border);
  background: var(--header-background);
  -webkit-backdrop-filter: blur(16px) saturate(1.15);
  backdrop-filter: blur(16px) saturate(1.15);
  transform: translateY(0);
  transition:
    transform 220ms cubic-bezier(0.2, 0.8, 0.2, 1),
    background-color 280ms ease,
    border-color 280ms ease;
  will-change: transform;
}

header.header-hidden {
  transform: translateY(calc(-100% - 1px));
}

.header-inner {
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 32px;
}

.brand {
  position: relative;
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
  width: 148px;
  text-decoration: none;
}

.brand img {
  display: block;
  width: 148px;
  max-width: 100%;
  height: auto;
  transition:
    opacity 220ms ease,
    transform 280ms ease;
}

.brand-logo-light {
  position: absolute;
  inset: 0;
  opacity: 0;
  transform: translateY(2px);
}

:root[data-theme="light"] .brand-logo-dark {
  opacity: 0;
  transform: translateY(-2px);
}

:root[data-theme="light"] .brand-logo-light {
  opacity: 1;
  transform: translateY(0);
}

.theme-toggle {
  position: relative;
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: transparent;
  color: var(--muted-strong);
  cursor: pointer;
  touch-action: manipulation;
  overflow: hidden;
  transition:
    background-color 180ms ease,
    color 180ms ease,
    border-color 180ms ease,
    transform 180ms ease;
}

.theme-toggle:hover {
  background: var(--toggle-hover);
  color: var(--text);
  border-color: var(--border-hover);
}

.theme-toggle:active {
  transform: scale(0.95);
}

.theme-toggle svg {
  position: absolute;
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition:
    opacity 220ms ease,
    transform 320ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

.theme-toggle .sun {
  opacity: 0;
  transform: rotate(-55deg) scale(0.65);
}

.theme-toggle .moon {
  opacity: 1;
  transform: rotate(0deg) scale(1);
}

:root[data-theme="light"] .theme-toggle .sun {
  opacity: 1;
  transform: rotate(0deg) scale(1);
}

:root[data-theme="light"] .theme-toggle .moon {
  opacity: 0;
  transform: rotate(55deg) scale(0.65);
}

/* Main */

main {
  flex: 1;
}

.projects-page {
  padding: 76px 0 112px;
}

.page-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 28px;
}

.page-heading h1 {
  margin: 0;
  font-size: 28px;
  line-height: 1.15;
  font-weight: 580;
  letter-spacing: -0.025em;
}

/* Filters */

.filters {
  position: relative;
  flex-shrink: 0;
}

.filter-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: transparent;
  color: var(--muted-strong);
  cursor: pointer;
  touch-action: manipulation;
  transition:
    color 160ms ease,
    background-color 160ms ease,
    border-color 160ms ease;
}

.filter-toggle:hover,
.filter-toggle[aria-expanded="true"] {
  color: var(--text);
  background: var(--toggle-hover);
  border-color: var(--border-hover);
}

.filter-icon {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
}

.filter-chevron {
  width: 13px;
  height: 13px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform 180ms ease;
}

.filter-toggle[aria-expanded="true"] .filter-chevron {
  transform: rotate(180deg);
}

.filter-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 50;
  width: 214px;
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  box-shadow: var(--menu-shadow);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-5px) scale(0.985);
  transform-origin: top right;
  transition:
    opacity 140ms ease,
    transform 140ms ease,
    visibility 140ms ease,
    background-color 280ms ease,
    border-color 280ms ease;
}

.filter-menu.open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

.filter-option {
  width: 100%;
  min-height: 38px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 7px 9px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted-strong);
  text-align: left;
  cursor: pointer;
  transition:
    color 140ms ease,
    background-color 140ms ease;
}

.filter-option:hover,
.filter-option:focus-visible {
  color: var(--text);
  background: var(--toggle-hover);
}

.filter-option .check {
  width: 16px;
  flex: 0 0 16px;
  color: var(--text);
  font-size: 12px;
  text-align: center;
  opacity: 0;
}

.filter-option[aria-checked="true"] .check {
  opacity: 1;
}

.filter-divider {
  height: 1px;
  margin: 5px 7px;
  background: var(--border);
}

/* Project table */

.project-table-wrap {
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  transition: border-color 280ms ease;
}

.project-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  table-layout: fixed;
}

.project-table col:nth-child(1) { width: 19%; }
.project-table col:nth-child(2) { width: 14%; }
.project-table col:nth-child(3) { width: 25%; }
.project-table col:nth-child(4) { width: 42%; }

.project-table th,
.project-table td {
  padding: 18px 18px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
  text-align: left;
  transition:
    background-color 160ms ease,
    border-color 280ms ease,
    color 280ms ease;
}

.project-table th {
  padding-top: 11px;
  padding-bottom: 11px;
  color: var(--muted);
  background: transparent;
  font-size: 10px;
  font-weight: 680;
  letter-spacing: 0.075em;
  text-transform: uppercase;
}

.project-table tbody tr:last-child td {
  border-bottom: 0;
}

.project-row td:first-child {
  border-left: 2px solid transparent;
  padding-left: 16px;
}

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

.project-row:hover td:first-child {
  border-left-color: var(--muted-strong);
}

.project-name {
  display: inline-block;
  color: var(--text);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 14px;
  font-weight: 650;
  line-height: 1.5;
  letter-spacing: -0.015em;
  text-decoration: none;
  overflow-wrap: anywhere;
}

.project-name:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.status {
  display: inline-block;
  font-size: 12px;
  font-weight: 650;
  line-height: 1.5;
  white-space: nowrap;
}

.status-development {
  color: var(--dev);
}

.status-paused {
  color: var(--paused);
}

.status-abandoned {
  color: var(--abandoned);
}

.status-archived {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 11px;
  white-space: normal;
}

.repo-link {
  color: var(--muted-strong);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 12px;
  line-height: 1.55;
  text-decoration-line: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  overflow-wrap: anywhere;
  transition: color 140ms ease;
}

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

.description {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.empty-state {
  margin: 0;
  padding: 42px 20px;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

.empty-state[hidden] {
  display: none;
}

/* Footer */

footer {
  border-top: 1px solid var(--border);
  transition: border-color 280ms ease;
}

.footer-inner {
  min-height: 112px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 40px;
}

.footer-copy {
  display: grid;
  gap: 5px;
}

.footer-brand {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.footer-description {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
  transition: color 280ms ease;
}

.footer-link {
  position: relative;
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 8px 0;
  touch-action: manipulation;
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  transition: color 160ms ease;
}

.footer-link::after {
  content: "";
  position: absolute;
  left: 0;
  right: 100%;
  bottom: 5px;
  height: 1px;
  background: var(--text);
  transition:
    right 160ms ease,
    background-color 280ms ease;
}

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

.footer-link:hover::after {
  right: 0;
}

/* Accessibility */

a:focus-visible,
button:focus-visible {
  outline: 2px solid var(--text);
  outline-offset: 4px;
}

/* Responsive */

@media (max-width: 900px) {
  .project-table col:nth-child(1) { width: 19%; }
  .project-table col:nth-child(2) { width: 15%; }
  .project-table col:nth-child(3) { width: 27%; }
  .project-table col:nth-child(4) { width: 39%; }

  .project-table th,
  .project-table td {
    padding-left: 14px;
    padding-right: 14px;
  }
}

@media (max-width: 760px) {
  .container {
    width: min(100% - 36px, 1180px);
  }

  .header-inner {
    min-height: 64px;
  }

  .brand {
    width: 128px;
  }

  .brand img {
    width: 128px;
  }

  .theme-toggle {
    width: 40px;
    height: 40px;
  }

  .projects-page {
    padding: 54px 0 76px;
  }

  .page-heading {
    margin-bottom: 22px;
  }

  .page-heading h1 {
    font-size: 24px;
  }

  .filter-toggle {
    min-height: 40px;
  }

  .filter-menu {
    position: fixed;
    top: auto;
    right: 18px;
    bottom: 18px;
    left: 18px;
    width: auto;
    max-height: calc(100vh - 36px);
    overflow-y: auto;
    transform-origin: bottom center;
    transform: translateY(8px) scale(0.99);
  }

  .filter-menu.open {
    transform: translateY(0) scale(1);
  }

  .filter-option {
    min-height: 44px;
    padding: 9px 11px;
  }

  .project-table,
  .project-table tbody,
  .project-table tr,
  .project-table td {
    display: block;
    width: 100%;
  }

  .project-table colgroup,
  .project-table thead {
    display: none;
  }

  .project-table tbody tr {
    padding: 22px 0;
    border-bottom: 1px solid var(--border);
  }

  .project-table tbody tr:last-child {
    border-bottom: 0;
  }

  .project-table td {
    padding: 0;
    border: 0;
    background: transparent !important;
  }

  .project-row td:first-child {
    border-left: 0;
    padding-left: 0;
  }

  .project-table td + td {
    margin-top: 14px;
  }

  .project-table td::before {
    content: attr(data-label);
    display: block;
    margin-bottom: 5px;
    color: var(--muted);
    font-size: 10px;
    font-weight: 650;
    letter-spacing: 0.055em;
    text-transform: uppercase;
  }

  .project-table td[data-label="Project"]::before {
    display: none;
  }

  .project-name {
    font-size: 16px;
  }

  .repo-link,
  .description {
    font-size: 13px;
  }

  .footer-inner {
    min-height: 0;
    align-items: flex-start;
    flex-direction: column;
    justify-content: center;
    gap: 18px;
    padding: 28px 0;
  }

  .footer-copy {
    max-width: 520px;
  }

  .footer-description {
    font-size: 12px;
    line-height: 1.6;
  }
}

@media (max-width: 440px) {
  .container {
    width: min(100% - 28px, 1180px);
  }

  .projects-page {
    padding: 46px 0 64px;
  }

  .page-heading {
    gap: 14px;
  }

  .page-heading h1 {
    font-size: 23px;
  }

  .filter-toggle {
    padding: 0 10px;
  }

  .filter-toggle-label {
    font-size: 13px;
  }

  .project-table tbody tr {
    padding: 20px 0;
  }

  .footer-description {
    max-width: 34ch;
  }
}

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

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