/* Reset and base styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Roboto Mono', monospace;
  line-height: 1.6;
  color: #000;
  background-color: #fff;
  margin: 0;
  padding: 0;
}

/* Header */
.site-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  padding: 1rem 2rem;
  background: white;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.site-title {
  font-size: 1rem;
  font-weight: 400;
  margin: 0;
  color: #000;
}

.view-toggle {
  display: flex;
  gap: 0.5rem;
}

.view-btn {
  padding: 0.5rem 1rem;
  border: none;
  background: white;
  cursor: pointer;
  font-family: 'Roboto Mono', monospace;
  font-size: 0.875rem;
  transition: all 0.3s ease;
}

.view-btn:hover {
  background: #f5f5f5;
}

.view-btn.active {
  background: white;
  color: #000;
  text-decoration: underline;
}

/* Navigation */
.main-nav {
  position: fixed;
  top: var(--grid-unit-y);
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  background: white;
  border-radius: 50px;
  padding: 0.5rem 1rem;
  width: fit-content;
  box-shadow: 0 0 30px 30px rgba(0, 0, 0, 0.15), 0 0 20px 5px inset rgba(0, 0, 0, 0.15);
}

.nav-items {
  display: flex;
  flex-direction: row;
  gap: 1.2rem;
}

.nav-item {
  display: block;
  padding: 0.6rem 0.8rem;
  text-decoration: none;
  color: #666;
  transition: all 0.3s ease;
  position: relative;
  white-space: nowrap;
  font-weight: 400;
  font-size: 0.9rem;
}

.nav-item:hover {
  color: #333;
}

.nav-item.active {
  color: #000;
  text-decoration: underline;
}

.nav-text {
  font-weight: 400;
}


/* View Management */
.gallery-view .list-view-content {
  display: none;
}

.list-view .gallery-view-content {
  display: none;
}

.list-view .main-nav {
  display: none;
}

/* List View Styles */
.list-view-content {
  padding-top: 4rem;
  height: 100vh;
}

.list-layout {
  display: flex;
  height: calc(100vh - 4rem);
}

.list-sidebar {
  width: 50%;
  border-right: 1px solid #eee;
  overflow-y: auto;
  padding: 1rem;
}

.list-nav {
  margin-bottom: 2rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid #eee;
}

.list-nav .nav-items {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}

.list-nav .nav-item {
  padding: 0.4rem 0.8rem;
  text-decoration: none;
  border: none;
  background: transparent;
  color: #666;
  border-radius: 20px;
  transition: all 0.3s ease;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.9rem;
}

.list-nav .nav-item:hover {
  background: #f5f5f5;
  color: #333;
}

.list-nav .nav-item.active {
  color: #000;
  text-decoration: underline;
}

.list-preview {
  width: 50%;
  padding: 2rem;
  display: flex;
  align-items: top;
  justify-content: center;
  background: #ffffff;
}

.preview-carousel {
  width: 100%;
  height: 60vh;
  position: relative;
  overflow: hidden;
  border-radius: 12px;
  background: white;
}

.preview-carousel img,
.preview-carousel video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: none;
}

.preview-carousel img.active,
.preview-carousel video.active,
.preview-carousel .preview-embed.active {
  display: block;
}

.preview-embed {
  width: 100%;
  height: 100%;
  display: none;
}

/* List item styling */
.list-item {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid #eee;
  cursor: grab;
  transition: background 0.3s ease, opacity 0.3s ease, transform 0.3s ease;
  position: relative;
  opacity: 1;
  transform: translateY(0);
}

/* List animation states */
.list-items.fade-out .list-item {
  opacity: 0;
  transform: translateY(-10px);
}

.list-items.fade-in .list-item {
  opacity: 1;
  transform: translateY(0);
  animation: slideInFromTop 0.5s ease forwards;
}

.list-item:nth-child(1) { animation-delay: 0.1s; }
.list-item:nth-child(2) { animation-delay: 0.15s; }
.list-item:nth-child(3) { animation-delay: 0.2s; }
.list-item:nth-child(4) { animation-delay: 0.25s; }
.list-item:nth-child(5) { animation-delay: 0.3s; }
.list-item:nth-child(6) { animation-delay: 0.35s; }
.list-item:nth-child(7) { animation-delay: 0.4s; }
.list-item:nth-child(8) { animation-delay: 0.45s; }
.list-item:nth-child(9) { animation-delay: 0.5s; }
.list-item:nth-child(10) { animation-delay: 0.55s; }

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

/* External link list items */
.list-item.external-link::after {
  content: "↗";
  position: absolute;
  right: 1rem;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.875rem;
  color: #666;
  pointer-events: none;
}

.list-item:hover {
  background: #f5f5f5;
}


.list-item-title {
  font-size: .75rem;
  font-weight: 400;
  margin: 0 0 0.5rem 0;
  color: #000;
}

.list-item-tags {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.tag-pill {
  padding: 0.25rem 0.75rem;
  font-size: 0.75rem;
  border-radius: 20px;
  background: #f0f0f0;
  color: #666;
}

.tag-pill[data-tag="projects"] {
  background: rgba(0, 0, 255, 0.1);
  color: rgb(0, 0, 255);
}

.tag-pill[data-tag="teaching"] {
  background: rgba(0, 128, 0, 0.1);
  color: rgb(0, 128, 0);
}

.tag-pill[data-tag="updates"] {
  background: rgba(255, 165, 0, 0.1);
  color: rgb(255, 140, 0);
}

@media (min-width: 768px) {
  body:not(.view-set) {
    .list-view-content {
      display: block;
    }
    .gallery-view-content {
      display: none;
    }
    .main-nav {
      display: none;
    }
  }
}

@media (max-width: 767px) {
  .site-header {
    position: static;
    padding: 1rem;
  }
  
  .view-toggle {
    display: none;
  }
  
  .list-view-content {
    display: none !important;
  }
  
  .gallery-view-content {
    display: block !important;
  }

  .main-nav {
    background: white;
    border: 1px solid #000;
    padding: 0.25rem 0.5rem;
    width: auto;
    min-width: fit-content;
  }

  .nav-items {
    flex-direction: row;
    justify-content: center;
    gap: 0.5rem;
    flex-wrap: wrap;
  }

  .nav-item {
    flex: 0 1 auto;
    text-align: center;
    padding: 0.5rem 0.75rem;
    font-size: 0.75rem;
    white-space: nowrap;
  }

}

@media (max-width: 480px) {
  .main-nav {
    padding: 0.25rem;
  }
  
  .nav-items {
    gap: 0.25rem;
  }
  
  .nav-item {
    padding: 0.4rem 0.5rem;
    font-size: 0.7rem;
  }
}


body.gallery-view .list-view-content {
  display: none;
}

body.list-view .gallery-view-content {
  display: none;
}

body.list-view .main-nav {
  display: none;
}

/* Main content */
.site-main {
  padding: calc(var(--grid-unit-x) *3);
  padding-top: calc(var(--grid-unit-y) * 2.2);
}

/* Large screens - slightly more spacing */
@media (min-width: 1440px) {
  .site-main {
    padding-top: calc(var(--grid-unit-y) * 2.5);
  }
}

@media (max-width: 767px) {
  .site-main {
    margin-right: 0;
    padding: 1rem;
    padding-top: calc(12vh + 1rem);
  }
}

:root {
  --grid-unit-x: 5vw;
  --grid-unit-y: 10vh;
  --gap-multiplier: .25;
  --size-1-multiplier: 2;
  --size-2-multiplier: 3;
  --size-3-multiplier: 4;
}

.items-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, var(--grid-unit-x));
  grid-auto-rows: var(--grid-unit-y);
  gap: calc(var(--grid-unit-x) * var(--gap-multiplier)) calc(var(--grid-unit-y) * var(--gap-multiplier));
  width: 100%;
  grid-auto-flow: dense;
  justify-content: center;
  padding: 0 calc((var(--grid-unit-x) * var(--gap-multiplier)) * 4);
  opacity: 0;
}

/* Item card base */
.item-card {
  background: white;
  overflow: hidden;
  cursor: pointer;
  position: relative;
  display: flex;
  flex-direction: column;
  padding: 0;
  border-radius: 12px;
  box-shadow: 0 0 15px 15px rgba(0, 0, 0, 0.15), 0 0 10px 5px inset rgba(0, 0, 0, 0.15);
}

/* Desktop gallery: hide text content, show only images */
@media (min-width: 768px) {
  .item-card .item-content {
    display: none;
  }
  
  .item-card .item-images,
  .item-card .item-link-preview {
    border-radius: 12px;
    margin: 0;
    padding: 0;
  }
  
  .item-card .item-images,
  .item-card .item-link-preview {
    width: 100%;
    height: 100%;
  }
  
  .item-card .item-images img,
  .item-card .item-images video,
  .item-card .item-link-preview iframe {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 12px;
  }
  
  
  /* Hover overlay */
  .item-hover-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(to bottom, transparent 0%, rgba(0,0,0,0.7) 100%);
    opacity: 0;
    transition: opacity 0.3s ease;
    display: flex;
    align-items: flex-end;
    padding: 1.5rem;
    border-radius: 12px;
  }
  
  .item-card:hover .item-hover-overlay {
    opacity: 1;
  }
  
  .hover-content {
    width: 100%;
    color: white;
  }
  
  .hover-title {
    font-size: 1rem;
    font-weight: 500;
    margin: 0 0 0.5rem 0;
    line-height: 1.2;
  }
  
  .hover-description {
    font-size: 0.875rem;
    margin: 0 0 1rem 0;
    line-height: 1.4;
    opacity: 0.9;
  }
  
  .hover-tags {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
  }
  
  .hover-tag-pill {
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.75rem;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    backdrop-filter: blur(10px);
  }
}

/* Mobile: keep current layout with text content */
@media (max-width: 767px) {
  .item-card {
    padding: 1rem;
    aspect-ratio: unset;
  }
  
  .item-card[data-size="1"],
  .item-card[data-size="2"], 
  .item-card[data-size="3"] {
    aspect-ratio: unset;
  }
  
  .item-card .item-content {
    display: flex;
    flex-direction: column;
  }
  
  .item-hover-overlay {
    display: none;
  }
  
  .item-card .item-images,
  .item-card .item-link-preview {
    margin-bottom: 0.5rem;
    padding: 0.5rem;
    height: auto;
  }
  
  .item-card .item-images img,
  .item-card .item-images video,
  .item-card .item-link-preview iframe {
    height: auto;
    object-fit: contain;
  }
}

/* External link cards */
.item-card.external-link {
  cursor: grab;
}

/* External link icon for gallery cards */
.item-card.external-link::after {
  content: "↗";
  position: absolute;
  top: 1rem;
  right: 1rem;
  font-size: 0.875rem;
  color: #666;
  pointer-events: none;
  z-index: 10;
}

/* Category label styling */
.item-card[data-size="1"] {
  grid-column: span var(--size-1-multiplier);
  grid-row: span var(--size-1-multiplier);
}

.item-card[data-size="2"] {
  grid-column: span var(--size-2-multiplier);
  grid-row: span var(--size-2-multiplier);
}

.item-card[data-size="3"] {
  grid-column: span var(--size-3-multiplier);
  grid-row: span var(--size-3-multiplier);
}

.item-card:hover {
  background: #fafafa;
}

/* Image carousel */
.item-images {
  position: relative;
  overflow: hidden;
  width: 100%;
  margin-bottom: 0.5rem;
  padding: 0.5rem;
}

.item-link-preview {
  position: relative;
  width: 100%;
  height: 100%;
  margin-bottom: 0.5rem;
  padding: 0.5rem;
}

.item-link-preview iframe {
  width: 100%;
  height: 100%;
  border-radius: 4px;
}

.image-carousel {
  display: flex;
  transition: transform 0.3s ease;
  width: 100%;
}

.carousel-image {
  width: 100%;
  height: auto;
  object-fit: cover;
  flex-shrink: 0;
  display: block;
}

.carousel-image video {
  width: 100%;
  height: auto;
  object-fit: contain;
}

.carousel-arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(255, 255, 255, 0.8);
  border: 1px solid rgba(0, 0, 0, 0.3);
  width: 24px;
  height: 24px;
  cursor: pointer;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.3s ease;
  z-index: 2;
}

.carousel-arrow:hover {
  background: white;
}

.carousel-prev {
  left: 0.5rem;
}

.carousel-next {
  right: 0.5rem;
}

.carousel-nav {
  position: absolute;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 0.5rem;
}

.carousel-dot {
  width: 8px;
  height: 8px;
  background: rgba(255, 255, 255, 0.5);
  cursor: pointer;
  transition: background 0.3s ease;
  border: 1px solid rgba(0, 0, 0, 0.3);
}

.carousel-dot.active {
  background: white;
}

/* Item content */
.item-content {
  padding: 0.5rem 0 0 0;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
}

.item-tags {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.item-title {
  font-size: 0.875rem;
  font-weight: 400;
  margin-bottom: 0.5rem;
  padding: 0.5rem 0.75rem;
  display: inline-block;
  width: fit-content;
}

/* Project page title */
h1.item-title {
  font-family: 'Roboto Mono', monospace;
  font-size: 1.5rem;
  font-weight: 400;
  margin-bottom: 1rem;
  padding: 0;
  display: block;
  width: auto;
}

.item-subtitle {
  font-family: 'Roboto Mono', monospace;
  font-size: 0.875rem;
  font-weight: 300;
  color: #666;
  margin-bottom: 2rem;
  line-height: 1.5;
}

.item-team {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.team-member {
  color: #000;
  padding: 0.25rem 0.5rem;
  font-size: 0.875rem;
  font-family: 'Roboto Mono', monospace;
}

.item-description-tooltip {
  position: relative;
}

.tooltip-content {
  position: fixed;
  background: #fefdf8;
  color: #555;
  font-style: italic;
  padding: 0.5rem;
  border: 1px solid #666;
  font-size: 0.875rem;
  line-height: 1.5;
  max-width: 200px;
  white-space: normal;
  z-index: 1000;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s ease;
}

@media (max-width: 767px) {
  .page-header {
    height: 15vh;
    padding: 0.5rem 1rem;
  }
  
  .page-title {
    font-size: 0.875rem;
  }
  
  .page-description {
    font-size: 0.875rem;
  }
  
  .site-main {
    padding: 1rem;
    padding-top: calc(15vh + 1rem);
    margin-right: 0;
  }
  
  .items-grid {
    display: flex;
    flex-direction: column;
    gap: 1rem;
  }
  
  .item-card {
    width: 100%;
    height: auto;
    min-height: 200px;
  }
  
  .item-card[data-size="1"],
  .item-card[data-size="2"],
  .item-card[data-size="3"] {
    grid-column: unset;
  }
}



/* Individual item page */
.item-detail {
  max-width: min(90vw, 800px);
  margin: 0 auto;
  padding: 2rem;
}

@media (min-width: 1200px) {
  .item-detail {
    max-width: 50vw;
  }
}

@media (max-width: 767px) {
  .item-detail {
    max-width: 95vw;
    padding: 1rem;
  }
}

.item-hero {
  margin-bottom: 3rem;
}

.item-hero img,
.item-hero .carousel-image {
  width: 100%;
  height: 50vh;
  object-fit: contain;
  margin-bottom: 2rem;
}

.item-hero-image {
  width: 100%;
  height: 50vh;
  object-fit: contain;
  margin-bottom: 2rem;
}

.item-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 2rem;
  margin-bottom: 2rem;
  padding-bottom: 1rem;
}

.item-meta-section h3 {
  font-size: 0.875rem;
  color: #000;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 0.5rem;
  font-weight: 400;
  font-family: 'Roboto Mono', monospace;
}

.external-link-meta {
  color: #000;
  text-decoration: none;
  font-size: 0.875rem;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-family: 'Roboto Mono', monospace;
  transition: color 0.3s ease;
}

.external-link-meta:hover {
  color: #333;
}

.link-icon {
  font-size: 0.75rem;
}

/* About content in list view */
.about-content .item-detail {
  max-width: 100%;
  margin: 0;
  padding: 0;
  font-size: 0.875rem;
}

.about-content .item-hero {
  margin-bottom: 1.5rem;
}

.about-content .item-meta {
  display: none;
}

/* About content in gallery view */
.about-content-gallery {
  grid-column: 1 / -1;
  padding: 2rem;
  max-width: 800px;
  margin: 0 auto;
}

.about-content-gallery .item-detail {
  max-width: 100%;
  margin: 0;
  padding: 0;
}

.about-content-gallery .item-meta {
  display: none;
}

.item-body {
  max-width: 800px;
  font-size: 0.875rem;
  line-height: 1.7;
  color: #000;
}

.item-body img {
  max-width: 100%;
  height: auto;
  margin: 2rem 0;
}

/* Image placeholders */
.image-placeholder {
  width: 100%;
  height: 200px;
  background: #f5f5f5;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #666;
  border: 2px dashed #ddd;
}

/* Modal Styles */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.modal-content {
  background: white;
  width: 50vw;
  height: 75vh;
  border-radius: 12px;
  position: relative;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  transform: scale(0.9);
  transition: transform 0.3s ease;
}

.modal-overlay.active .modal-content {
  transform: scale(1);
}

.modal-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: none;
  border: none;
  font-size: 2rem;
  cursor: pointer;
  color: #666;
  z-index: 10;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: all 0.3s ease;
}

.modal-close:hover {
  background: rgba(0, 0, 0, 0.1);
  color: #000;
}

.modal-body {
  height: 100%;
  overflow-y: auto;
  padding: 2rem;
  padding-top: 4rem;
}

.modal-body .item-detail {
  max-width: none;
  margin: 0;
  padding: 0;
}

.modal-body .item-hero {
  margin-bottom: 2rem;
}

.modal-body .item-images {
  margin-bottom: 1rem;
}

.modal-body .item-hero img,
.modal-body .item-hero .carousel-image {
  width: 100%;
  height: 40vh;
  object-fit: contain;
  margin-bottom: 1rem;
}

.modal-body .item-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 2rem;
  margin-bottom: 2rem;
  padding-bottom: 1rem;
}

.modal-body .item-body {
  font-size: 0.875rem;
  line-height: 1.7;
  color: #000;
}

/* Mobile modal styles */
@media (max-width: 767px) {
  .modal-content {
    width: 90vw;
    height: 80vh;
    margin: 5vh auto;
  }
  
  .modal-body {
    padding: 1rem;
    padding-top: 3rem;
  }
  
  .modal-body .item-hero img,
  .modal-body .item-hero .carousel-image {
    height: 25vh;
  }
}

/* Utilities */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}