/* ── Theme variables ── */
:root,
[data-theme='dark'] {
  --bg: #0a0a0a;
  --fg: #e0ddd8;
  --muted: #807b74;
  --accent: #ff6b35;
  --border: rgba(255, 255, 255, 0.06);
  --row-hover: rgba(255, 255, 255, 0.04);
  --tag-border: rgba(255, 255, 255, 0.08);
  --tag-border-hover: rgba(255, 255, 255, 0.2);
  --font: monospace;
  --theme-icon: '[ dark ]';
}

[data-theme='light'] {
  --bg: #f5f0eb;
  --fg: #1a1a1a;
  --muted: #6b655d;
  --accent: #c45d3e;
  --border: rgba(0, 0, 0, 0.08);
  --row-hover: rgba(0, 0, 0, 0.03);
  --tag-border: rgba(0, 0, 0, 0.1);
  --tag-border-hover: rgba(0, 0, 0, 0.25);
  --theme-icon: '[ light ]';
}

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

body {
  font-family: var(--font);
  font-size: 13px;
  line-height: 1.6;
  color: var(--fg);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  padding: 3rem 3rem 2rem;
  min-height: 100vh;
  transition:
    background 0.3s,
    color 0.3s;
}

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

button {
  border: none;
  background: none;
  font: inherit;
  color: inherit;
  cursor: pointer;
}

/* ── Skip link ── */
.skip-link {
  position: absolute;
  top: -100%;
  left: 1rem;
  padding: 0.4rem 0.8rem;
  background: var(--accent);
  color: var(--bg);
  font-size: 0.75rem;
  border-radius: 0 0 4px 4px;
  z-index: 999;
  transition: top 0.2s;
}

.skip-link:focus {
  top: 0;
}

/* ── Focus styles ── */
:focus-visible {
  outline: 1.5px solid var(--accent);
  outline-offset: 3px;
  border-radius: 3px;
}

.row:focus-visible {
  background: var(--row-hover);
}

.row:focus-visible .name {
  color: var(--accent);
}

.row:focus-visible .arrow {
  opacity: 1;
  transform: translateX(0);
}

/* ── Header ── */
.header {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  padding-bottom: 2rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 3rem;
}

.header h1 {
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1;
}

.cursor {
  color: var(--accent);
  animation: blink 1s step-end infinite;
}

@keyframes blink {
  50% {
    opacity: 0;
  }
}

.role {
  color: var(--muted);
  margin-top: 0.4rem;
  font-size: 0.8125rem;
}

.header nav {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  font-size: 0.75rem;
}

.header nav a {
  color: var(--muted);
  position: relative;
  transition: color 0.25s;
}

.header nav a::before {
  content: '~/';
  position: absolute;
  right: 100%;
  color: var(--accent);
  opacity: 0;
  transition: opacity 0.25s;
  pointer-events: none;
}

.header nav a:hover {
  color: var(--fg);
}

.header nav a:hover::before {
  opacity: 1;
}

/* ── Theme toggle ── */
.theme-toggle {
  color: var(--muted);
  font-size: 0.75rem;
  transition: color 0.25s;
  padding: 0;
  line-height: 1;
}

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

.theme-icon::after {
  content: var(--theme-icon);
}

/* ── Grid layout ── */
.grid {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr));
  gap: 2.5rem 3rem;
  align-items: start;
}

/* ── Groups ── */
.group h2 {
  font-size: 0.6875rem;
  font-weight: 400;
  color: var(--muted);
  margin-bottom: 0.75rem;
  letter-spacing: 0.02em;
}

/* ── Project Rows ── */
.row {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
  padding: 0.5rem 0.6rem;
  margin: 0 -0.6rem;
  border-radius: 5px;
  transition:
    background 0.25s,
    color 0.25s;
}

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

.row .name {
  font-weight: 500;
  white-space: nowrap;
  transition: color 0.25s;
}

.row:hover .name {
  color: var(--accent);
}

.row .line {
  flex: 1;
  border-bottom: 1px solid var(--muted);
  opacity: 0.2;
  min-width: 1rem;
  align-self: center;
  margin-bottom: 0.15em;
}

.row .desc {
  color: var(--muted);
  font-size: 0.75rem;
  white-space: nowrap;
  transition: color 0.25s;
}

.row:hover .desc {
  color: var(--fg);
}

.row .arrow {
  color: var(--accent);
  opacity: 0;
  transform: translateX(-4px);
  transition:
    opacity 0.25s,
    transform 0.25s;
  font-size: 0.875rem;
}

.row:hover .arrow {
  opacity: 1;
  transform: translateX(0);
}

/* ── About / text blocks ── */
.about-text {
  color: var(--muted);
  font-size: 0.8125rem;
  line-height: 1.75;
}

.about-text + .about-text {
  margin-top: 0.75rem;
}

/* ── Tags ── */
.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.tags span {
  font-size: 0.6875rem;
  padding: 0.25rem 0.6rem;
  border: 1px solid var(--tag-border);
  border-radius: 3px;
  color: var(--muted);
  transition:
    color 0.25s,
    border-color 0.25s;
}

.tags span:hover {
  color: var(--fg);
  border-color: var(--tag-border-hover);
}

/* ── Footer ── */
.footer {
  position: relative;
  z-index: 1;
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
  font-size: 0.625rem;
  color: var(--muted);
  letter-spacing: 0.04em;
}

/* ── Staggered entrance ── */
.group {
  opacity: 0;
  transform: translateY(10px);
  animation: enter 0.45s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

.group:nth-child(1) {
  animation-delay: 0.06s;
}
.group:nth-child(2) {
  animation-delay: 0.12s;
}
.group:nth-child(3) {
  animation-delay: 0.18s;
}
.group:nth-child(4) {
  animation-delay: 0.24s;
}
.group:nth-child(5) {
  animation-delay: 0.3s;
}
.group:nth-child(6) {
  animation-delay: 0.36s;
}
.group:nth-child(7) {
  animation-delay: 0.42s;
}
.group:nth-child(8) {
  animation-delay: 0.48s;
}

@keyframes enter {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ── Selection ── */
::selection {
  background: var(--accent);
  color: var(--bg);
}

/* ── Scrollbar ── */
::-webkit-scrollbar {
  width: 4px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--muted);
  border-radius: 2px;
}

/* ── Responsive ── */
@media (max-width: 700px) {
  body {
    padding: 1.25rem 0.875rem 1.5rem;
    font-size: 11px;
  }

  .header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
    margin-bottom: 1.75rem;
    padding-bottom: 1.25rem;
  }

  .header h1 {
    font-size: 0.875rem;
  }

  .role {
    font-size: 0.6875rem;
    margin-top: 0.2rem;
  }

  .header nav {
    gap: 1rem;
    font-size: 0.625rem;
  }

  .header nav a::before {
    display: none;
  }

  .grid {
    grid-template-columns: 1fr;
    gap: 1.5rem;
  }

  .group h2 {
    font-size: 0.5625rem;
    margin-bottom: 0.5rem;
  }

  .row {
    flex-wrap: wrap;
    padding: 0.35rem 0;
    margin: 0;
    gap: 0.15rem;
  }

  .row .line {
    display: none;
  }

  .row .name {
    width: 100%;
    font-size: 0.8125rem;
  }

  .row .desc {
    white-space: normal;
    width: 100%;
    font-size: 0.625rem;
  }

  .row .arrow {
    display: none;
  }

  .about-text {
    font-size: 0.6875rem;
  }

  .tags {
    gap: 0.25rem;
  }

  .tags span {
    font-size: 0.5625rem;
    padding: 0.15rem 0.4rem;
  }

  .footer {
    margin-top: 2rem;
    padding-top: 1rem;
  }
}

/* ── Reduced motion ── */
@media (prefers-reduced-motion: reduce) {
  .group {
    animation: none;
    opacity: 1;
    transform: none;
  }

  .cursor {
    animation: none;
  }
}

/* ── Print ── */
@media print {
  body {
    background: #fff;
    color: #000;
    padding: 1rem;
    font-size: 11px;
  }

  .header nav,
  .theme-toggle,
  .cursor,
  .arrow {
    display: none;
  }

  .header {
    border-bottom-color: #ccc;
  }

  .row {
    margin: 0;
    padding: 0.3rem 0;
  }

  .row .line {
    border-color: #ccc;
    opacity: 0.4;
  }

  .group h2,
  .role,
  .row .desc,
  .about-text,
  .footer {
    color: #555;
  }

  .tags span {
    border-color: #ccc;
    color: #555;
  }

  .footer {
    border-top-color: #ccc;
  }

  .group {
    animation: none;
    opacity: 1;
    transform: none;
  }
}
