:root {
  --bg: #ffffff;
  --fg: #000000;
  --muted: #555555;
  --font-body: 'IBM Plex Sans', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'IBM Plex Mono', 'Courier New', monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-body);
}

/* ---------- Header ---------- */

.site-header {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 2.5rem 3rem;
}

.site-header.detail {
  display: flex;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--bg);
  border-bottom: 1px solid var(--fg);
}

.back-link {
  color: var(--fg);
  text-decoration: none;
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.back-link:hover {
  text-decoration: underline;
}

.identity {
  display: flex;
  flex-direction: column;
  line-height: 1.3;
}

.identity .name {
  font-weight: 700;
  font-size: 1.1rem;
  letter-spacing: 0.02em;
}

.identity .handle {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--muted);
}

.categories {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  justify-self: center;
}

.category {
  appearance: none;
  -webkit-appearance: none;
  background-color: var(--bg);
  border: none;
  color: var(--fg);
  font-family: inherit;
  font-size: 0.95rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.35rem 0.9rem;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.category:hover,
.category.active {
  background-color: var(--fg);
  color: var(--bg);
}

.dot {
  opacity: 0.5;
}

.clear-filter {
  appearance: none;
  -webkit-appearance: none;
  justify-self: end;
  background: none;
  border: none;
  color: var(--fg);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
}

.clear-filter[hidden] {
  display: none;
}

.handle a {
  color: var(--muted);
  text-decoration: none;
  font-family: var(--font-mono);
  font-size: 0.85rem;
}
.handle a:hover {
  text-decoration: underline;
  text-decoration-color: var(--fg);
}

.handle a:visited {
  text-decoration: underline;
  text-decoration-color: var(--fg);
  color: var(--fg);
}

/* ---------- Grid ---------- */

.grid {
  display: grid;
  grid-template-columns: repeat(var(--cols, 3), 1fr);
  border-top: 1px solid var(--fg);
  border-left: 1px solid var(--fg);
}

.project-card {
  display: block;
  color: inherit;
  text-decoration: none;
}

.project-card.is-hidden {
  display: none;
}

.loading,
.load-error {
  padding: 3rem;
  font-size: 0.9rem;
}

.polaroid {
  display: flex;
  flex-direction: column;
  aspect-ratio: 3 / 4;
  border-right: 1px solid var(--fg);
  border-bottom: 1px solid var(--fg);
}

.polaroid-photo {
  flex: 1;
  overflow: hidden;
}

.polaroid-photo img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: grayscale(100%) contrast(1.05);
  transition: filter 0.3s ease;
}

.project-card:hover .polaroid-photo img {
  filter: contrast(1.05);
}

.project-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.6rem 0.9rem;
  border-top: 1px solid var(--fg);
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

/* ---------- Project detail ---------- */

.detail-cover img {
  display: block;
  width: 100%;
  max-height: 70vh;
  object-fit: cover;
  filter: grayscale(100%) contrast(1.05);
}

.detail-body {
  max-width: 720px;
  margin: 0 auto;
  padding: 3rem 1.5rem 3rem;
}

.detail-body a {
  font: inherit;
  color: inherit;
  text-decoration: underline;
  text-decoration-color: var(--muted);
  text-underline-offset: 2px;
  transition: text-decoration-color 0.15s ease;
}

.detail-body a:hover {
  text-decoration-color: currentColor;
}

.detail-body a:visited {
  color: inherit;
}

.detail-heading {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  border-bottom: 1px solid var(--fg);
  padding-bottom: 1rem;
  margin-bottom: 2.5rem;
}

.detail-heading h1 {
  font-size: 1.8rem;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.detail-year {
  font-size: 0.95rem;
  color: var(--muted);
}

.detail-section {
  margin-bottom: 2.5rem;
}

.detail-section h2 {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 1rem;
  color: var(--muted);
}

.prose p {
  line-height: 1.6;
  margin-bottom: 1rem;
}

.prose p:last-child {
  margin-bottom: 0;
}

.feature-list {
  list-style: none;
}

.feature-list li {
  line-height: 1.6;
  padding-left: 1.2rem;
  position: relative;
}

.feature-list li::before {
  content: '—';
  position: absolute;
  left: 0;
}

.specs {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 0.5rem 1.5rem;
}

.specs dt {
  font-weight: 700;
}

.specs dd {
  color: var(--muted);
  overflow-wrap: break-word;
}

.detail-gallery-heading {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  border-top: 1px solid var(--fg);
  border-left: 1px solid var(--fg);
}

.gallery-item {
  position: relative;
  aspect-ratio: 1 / 1;
  cursor: pointer;
  overflow: hidden;
  border-right: 1px solid var(--fg);
  border-bottom: 1px solid var(--fg);
}

.video-icon {
  position: absolute;
  bottom: 8px;
  left: 8px;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.55);
  border-radius: 50%;
  pointer-events: none;
  z-index: 1;
}

.video-icon svg {
  width: 14px;
  height: 14px;
  fill: #ffffff;
}

.gallery-item img,
.gallery-item video {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s ease;
}

.gallery-item:hover img,
.gallery-item:hover video {
  transform: scale(1.04);
}

/* ---------- Lightbox ---------- */

.lightbox {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.94);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 4rem 5rem;
}

.lightbox.is-open {
  display: flex;
}

.lightbox-content {
  max-width: 100%;
  max-height: 100%;
}

.lightbox-content img,
.lightbox-content video {
  display: block;
  max-width: 100%;
  max-height: calc(100vh - 8rem);
  object-fit: contain;
}

.lightbox-close,
.lightbox-nav {
  appearance: none;
  -webkit-appearance: none;
  background: none;
  border: none;
  color: #fff;
  cursor: pointer;
}

.lightbox-close {
  position: absolute;
  top: 1.5rem;
  right: 2rem;
  font-size: 2rem;
  line-height: 1;
}

.lightbox-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  font-size: 2.5rem;
  padding: 1rem;
}

.lightbox-prev { left: 1rem; }
.lightbox-next { right: 1rem; }

.lightbox-nav[hidden],
.lightbox-close[hidden] {
  display: none;
}

/* ---------- Responsive ---------- */

@media (max-width: 600px) {
  .grid {
    grid-template-columns: 1fr;
  }

  .site-header {
    grid-template-columns: 1fr;
    text-align: center;
    gap: 1rem;
    padding: 2rem 1.5rem;
  }

  .site-header.detail {
    flex-direction: column;
  }

  .categories {
    flex-wrap: wrap;
    justify-content: center;
  }

  .clear-filter {
    justify-self: center;
  }
}
