:root {
  --bg: #000;
  --text: #fff;
  --text-muted: #888;
  --accent: #3366ff;
  --card-bg: #111;
  --card-border: #222;
}

:root.light {
  --bg: #f5f5f5;
  --text: #111;
  --text-muted: #666;
  --accent: #2952cc;
  --card-bg: #fff;
  --card-border: #ddd;
}

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

body {
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-family: 'Space Grotesk', sans-serif;
  overflow-x: hidden;
  transition: background 0.3s, color 0.3s;
}

canvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: -1;
}

#app {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

header {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 40px 60px;
}

.logo {
  font-size: 32px;
  font-weight: 700;
  color: var(--text);
  text-decoration: none;
  transition: color 0.2s;
  justify-self: start;
}

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

nav {
  display: flex;
  gap: 40px;
}

.nav-link {
  font-size: 18px;
  font-weight: 400;
  color: var(--text-muted);
  text-decoration: none;
  transition: color 0.2s;
}

.nav-link:hover,
.nav-link.active {
  color: var(--text);
}

#theme-toggle {
  justify-self: end;
  width: 44px;
  height: 44px;
  border: none;
  background: transparent;
  cursor: pointer;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text);
  transition: background 0.2s, transform 0.2s;
}

#theme-toggle:hover {
  background: var(--card-border);
  transform: scale(1.1);
}

#theme-toggle svg {
  width: 22px;
  height: 22px;
  position: absolute;
  transition: opacity 0.3s, transform 0.3s;
}

#theme-toggle .icon-sun {
  opacity: 0;
  transform: rotate(-90deg) scale(0.5);
}

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

:root.light #theme-toggle .icon-sun {
  opacity: 1;
  transform: rotate(0) scale(1);
}

:root.light #theme-toggle .icon-moon {
  opacity: 0;
  transform: rotate(90deg) scale(0.5);
}

main {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 60px;
}

.section {
  display: none;
  width: 100%;
  max-width: 900px;
  animation: fadeIn 0.15s ease;
}

.section.active {
  display: block;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeOut {
  from {
    opacity: 1;
    transform: translateY(0);
  }
  to {
    opacity: 0;
    transform: translateY(-10px);
  }
}

.section.exiting {
  display: block;
  animation: fadeOut 0.1s ease forwards;
}

#about p {
  font-size: 22px;
  font-weight: 400;
  line-height: 1.6;
  margin-bottom: 8px;
}

#about .highlight {
  color: var(--accent);
  font-weight: 700;
}

.project-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
  width: 100%;
}

.project-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 12px;
  padding: 12px;
  cursor: pointer;
  transition: transform 0.2s ease, background 0.3s, border-color 0.3s,
              max-height 0.25s ease, padding 0.25s ease, opacity 0.2s ease, margin 0.25s ease;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.project-card:hover {
  transform: translateY(-4px);
}

.project-card-thumb {
  width: 100%;
  aspect-ratio: 16 / 10;
  background: var(--bg);
  border-radius: 8px;
  overflow: hidden;
}

.project-card-thumb img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.project-card-info h3 {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 4px;
}

.project-card-info p {
  font-size: 14px;
  color: var(--text-muted);
  line-height: 1.4;
}

#project-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.7);
  padding: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  overflow-y: auto;
}

#project-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.overlay-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 12px;
  overflow: hidden;
  width: 100%;
  max-width: 900px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  position: relative;
}

@media (min-width: 800px) {
  .overlay-card {
    flex-direction: row;
    max-height: 80vh;
  }
}

@keyframes overlayCardIn {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}

#project-overlay.active .overlay-card {
  animation: overlayCardIn 0.25s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

.project-gallery {
  position: relative;
  background: var(--card-bg);
  overflow: hidden;
  border-radius: 0;
  aspect-ratio: 16 / 10;
}

@media (min-width: 800px) {
  .project-gallery {
    flex: 1.2;
    aspect-ratio: auto;
    min-height: 0;
    border-radius: 0;
    margin: 0;
  }
}

.project-gallery-media {
  width: 100%;
  height: 100%;
  display: flex;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
  -webkit-user-select: none;
  user-select: none;
}

.project-gallery-media::-webkit-scrollbar {
  display: none;
}

.project-gallery-media img,
.project-gallery-media video {
  width: 100%;
  height: 100%;
  flex-shrink: 0;
  scroll-snap-align: start;
  object-fit: contain;
}

.project-gallery-media img {
  cursor: zoom-in;
}

.gallery-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.5);
  border-radius: 50%;
  border: none;
  color: #fff;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.1s, transform 0.1s;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.project-gallery:hover .gallery-nav {
  opacity: 1;
}

.gallery-nav:hover {
  transform: translateY(-50%) scale(1.1);
  background: rgba(0, 0, 0, 0.7);
}

.gallery-nav svg {
  width: 20px;
  height: 20px;
}

.gallery-prev {
  left: 12px;
}

.gallery-next {
  right: 12px;
}

.gallery-nav.hidden {
  display: none;
}

.gallery-dots {
  position: absolute;
  bottom: 8px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 8px;
  padding: 4px 8px;
  background: rgba(0, 0, 0, 0.3);
  border-radius: 12px;
}

.gallery-dots.hidden {
  display: none;
}

.gallery-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.4);
  border: none;
  padding: 0;
  cursor: pointer;
  transition: background 0.1s, transform 0.1s;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.gallery-dot:hover {
  background: rgba(255, 255, 255, 0.7);
}

.gallery-dot.active {
  background: #fff;
  transform: scale(1.2);
}

.project-details {
  padding: 12px;
  overflow-y: auto;
}

@media (min-width: 800px) {
  .project-details {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 24px;
    overflow-y: auto;
    min-width: 0;
  }
}

.project-title {
  font-size: 28px;
  font-weight: 700;
  margin-bottom: 16px;
}

.project-close {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 10;
  width: 36px;
  height: 36px;
  border: none;
  background: rgba(0, 0, 0, 0.5);
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  transition: background 0.2s, transform 0.2s;
}

@media (min-width: 800px) {
  .project-close {
    top: 24px;
    right: 24px;
  }
}

.project-close:hover {
  transform: scale(1.1);
  background: rgba(0, 0, 0, 0.7);
}

.project-close svg {
  width: 18px;
  height: 18px;
}

.project-description {
  font-size: 16px;
  line-height: 1.7;
  color: var(--text-muted);
  margin-bottom: 20px;
}

.project-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 20px;
}

.project-tag {
  --tag-hue: 0;
  --tag-sat: 60;
  padding: 6px 12px;
  background: hsl(var(--tag-hue) calc(var(--tag-sat) * 1%) 20%);
  border: 1px solid hsl(var(--tag-hue) calc(var(--tag-sat) * 1% - 10%) 40%);
  border-radius: 20px;
  font-size: 13px;
  font-weight: 500;
  color: hsl(var(--tag-hue) calc(var(--tag-sat) * 1% + 10%) 75%);
}

:root.light .project-tag {
  background: hsl(var(--tag-hue) calc(var(--tag-sat) * 1% + 5%) 92%);
  border-color: hsl(var(--tag-hue) calc(var(--tag-sat) * 1% - 10%) 70%);
  color: hsl(var(--tag-hue) calc(var(--tag-sat) * 1% + 10%) 35%);
}

.project-links {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.project-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  background: var(--accent);
  color: #fff;
  text-decoration: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  transition: transform 0.2s, opacity 0.2s;
}

.project-link:hover {
  transform: translateY(-2px);
  opacity: 0.9;
}

.project-link svg {
  width: 18px;
  height: 18px;
}

.project-link.secondary {
  background: var(--card-border);
  color: var(--text);
}

#image-lightbox {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(0, 0, 0, 0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

#image-lightbox.active {
  opacity: 1;
  pointer-events: auto;
}

#lightbox-img {
  max-width: 95vw;
  max-height: 92vh;
  object-fit: contain;
  border-radius: 6px;
  user-select: none;
}

.lightbox-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 40px;
  height: 40px;
  border: none;
  background: rgba(255, 255, 255, 0.12);
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  transition: background 0.2s, transform 0.2s;
}

.lightbox-close:hover {
  background: rgba(255, 255, 255, 0.25);
  transform: scale(1.1);
}

.lightbox-close svg {
  width: 20px;
  height: 20px;
}

.contact-links {
  display: flex;
  gap: 24px;
  margin-top: 40px;
}

.contact-icon {
  width: 36px;
  height: 36px;
  color: var(--text);
  transition: color 0.2s, transform 0.2s;
}

.contact-icon:hover {
  color: var(--accent);
  transform: scale(1.1);
}

.contact-icon svg {
  width: 100%;
  height: 100%;
}

.blog-list {
  text-align: center;
}

.coming-soon {
  font-size: 18px;
  color: var(--text-muted);
}

@media (max-width: 600px) {
  header {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 24px 20px;
    gap: 16px;
  }

  .logo {
    font-size: 28px;
  }

  nav {
    order: 1;
    gap: 20px;
  }

  .nav-link {
    font-size: 15px;
  }

  #theme-toggle {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 38px;
    height: 38px;
  }

  #theme-toggle svg {
    width: 18px;
    height: 18px;
  }

  main {
    padding: 24px;
  }

  #about p {
    font-size: 22px;
  }

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

  .project-title {
    font-size: 22px;
  }

  .project-tags {
    gap: 6px;
  }

  .project-tag {
    padding: 4px 10px;
    font-size: 12px;
  }
}
