/* ============================================================================
   CSS VARIABLES
   ============================================================================ */
:root {
  --bg-color: #000000;
  --text-color: #ffffff;
  --highlight-color: #3d479c;
  --border-color: #e6e6e0;
  --image-border: #e6e6e0;
  --button-color: #e6e6e0;
  --button-hover-color: #a49ce0;

  --heading-font: "Inter", sans-serif;
  --content-font: "Open Sans", sans-serif;

  --font-size-h1: clamp(1.8rem, 4.5vw, 2.5rem);
  --font-size-h2: clamp(1.5rem, 3.5vw, 2.5rem);
  --font-size-h3: clamp(1.25rem, 3vw, 1.75rem);
  --font-size-details-titles: clamp(0.85rem, 2.5vw, 1rem);
  --font-size-paragraph: 1rem;
  --font-size-button: 1rem;
  --font-size-button-small: 0.8rem;
  --font-size-button-large: 1.1rem;

  --spacing-xs: 0.5rem; /* 8px */
  --spacing-sm: 0.75rem; /* 12px */
  --spacing-md: 1rem; /* 16px */
  --spacing-lg: 1.5rem; /* 24px */
  --spacing-xl: 2rem; /* 32px */
  --spacing-2xl: 2.5rem; /* 40px */
  --spacing-3xl: 3rem; /* 48px */

  /* Container Spacing */
  --page-margin: clamp(1rem, 5vw, 5%);
  --container-gap: clamp(1rem, 3vw, 2rem);
  --gallery-spacing: clamp(1rem, 2vw, 1.5rem);
  --mobile-padding: var(--spacing-md);
  --border-radius: 10px;

  /* Mobile Touch Targets */
  --touch-target-min: 44px; /* Minimum touch target size */
  --touch-target-comfortable: 48px;

  /* Sticky layout sizing */
  --project-sticky-top: calc(var(--nav-height, 75px) + 5rem);
  --nextprev-sticky-height: 10px;
}

/* ============================================================================
   BASE STYLING
   ============================================================================ */
body {
  background-color: var(--bg-color);
  margin: var(--page-margin);
  padding-bottom: calc(var(--nextprev-sticky-height) + var(--spacing-lg));
  color: var(--text-color);
  font-family: var(--heading-font);
  line-height: 1.2;
  min-height: 100vh;
  box-sizing: border-box;
  overscroll-behavior-y: contain;
  -webkit-overflow-scrolling: touch;
}

::selection {
  background-color: var(--highlight-color);
}

/* ============================================================================
   KEYFRAME ANIMATIONS
   ============================================================================ */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeInScale {
  from {
    opacity: 0;
    transform: scale(0.95);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

/* ============================================================================
   PROJECT VISUAL AND TITLE STYLING
   ============================================================================ */
.project-visual {
  width: 100%;
  height: auto;
  object-fit: cover;
  border-radius: 15px;
  margin-bottom: clamp(0.25rem, 1vw, 0.5rem);
  justify-content: start;
  animation: fadeInScale 0.8s ease-out 0.2s both;
}

#main-img {
  width: 100%;
  height: auto;
  max-height: 70vh;
  object-fit: cover;
  display: block;
  margin: 0 auto;
  border-radius: 15px;
  animation: fadeInScale 0.8s ease-out 0.2s both;
}

.video-container {
  width: 100%;
  max-height: 70vh;
  position: relative;
  padding-top: 56.25%;
  margin: 0 auto;
}

.video-container iframe {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border: none;
}

.title {
  margin-top: clamp(2rem, 1vw, 3.5rem);
  margin-bottom: clamp(1rem, 1vw, 1.5rem);
  animation: fadeInUp 1s ease-out 0.4s both;
}

.title h1 {
  color: var(--text-color);
  text-transform: uppercase;
  font-size: var(--font-size-h1);
  margin-top: 0;
  margin-bottom: 0;
}

/* ============================================================================
   PROJECT CONTAINER STYLING
   ============================================================================ */

.project-container {
  display: flex;
  flex-direction: row;
  justify-content: space-between;
  align-items: stretch;
  position: sticky;
  top: var(--project-sticky-top);
  gap: 20px;
  height: calc(
    100vh - var(--project-sticky-top) - var(--nextprev-sticky-height)
  );
  animation: fadeInUp 1s ease-out 0.6s both;
}

/* ============================================================================
   DETAILS SECTION
   ============================================================================ */

.details {
  flex: 1;
  width: 20%;
  max-height: calc(100% - var(--spacing-md));
  overflow-y: auto;
  overflow-x: hidden;
  margin-top: var(--spacing-lg);
  padding-bottom: clamp(var(--spacing-lg), 3vw, var(--spacing-xl));
  display: flex;
  flex-direction: column;
  gap: clamp(var(--spacing-md), 2vw, var(--spacing-lg));
  animation: fadeInUp 0.8s ease-out 0.8s both;
}

/* ============================================================================
   KEYWORDS CONTAINER STYLING
   ============================================================================ */
.keywords {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-sm);
  padding: clamp(var(--spacing-sm), 2vw, var(--spacing-md));
  border: 1px dashed var(--border-color);
  border-radius: var(--border-radius);
  margin-bottom: 0;
  background-color: rgba(255, 255, 255, 0.02);
  transition:
    background-color 0.3s ease,
    border-color 0.3s ease;
}

.keywords:hover {
  background-color: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.9);
}

.keywords h2 {
  margin: 0;
  font-size: var(--font-size-details-titles);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  line-height: 1.4;
  padding: clamp(var(--spacing-xs), 1vw, var(--spacing-sm)) 0;
  transition:
    transform 0.2s ease,
    opacity 0.2s ease;
}

.keywords h2:not(:last-child) {
  border-bottom: 1px dashed rgba(255, 255, 255, 0.2);
}

/* ============================================================================
   PROJJECT ROLE STYLING
   ============================================================================ */
.project-role {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-xs);
  margin-bottom: 0;
  padding: clamp(var(--spacing-sm), 2vw, var(--spacing-sm));
  border: 1px dashed var(--border-color);
  border-radius: var(--border-radius);
}

.project-role p {
  color: var(--text-color);
  margin: 0;
  display: flex;
  flex-direction: column;
  width: 100%;
  gap: clamp(var(--spacing-xs), 1vw, var(--spacing-sm));
}

.project-role p span {
  display: block;
  line-height: 1.6;
  margin: 0;
  padding: clamp(var(--spacing-xs), 0.7vw, var(--spacing-xs)) 0;
  font-size: var(--font-size-paragraph);
  color: var(--text-color);
  opacity: 0.9;
  transition:
    opacity 0.2s ease,
    transform 0.2s ease,
    padding-left 0.2s ease;
  border-left: 2px solid transparent;
  padding-left: var(--spacing-xs);
}

.project-role p span:not(:last-child) {
  border-bottom: 1px dashed rgba(255, 255, 255, 0.1);
  padding-bottom: clamp(var(--spacing-xs), 0.8vw, var(--spacing-sm));
}

/* ============================================================================
   COLLABORATORS LIST STYLING
   ============================================================================ */
.collaborators-list {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-xs);
  margin-bottom: 0;
  padding: clamp(var(--spacing-sm), 2vw, var(--spacing-sm));
  border: 1px dashed var(--border-color);
  border-radius: var(--border-radius);
  background-color: rgba(255, 255, 255, 0.02);
  transition:
    background-color 0.3s ease,
    border-color 0.3s ease;
}

.collaborators-list p {
  color: var(--text-color);
  margin: 0;
  display: flex;
  flex-direction: column;
  width: 100%;
  gap: clamp(var(--spacing-xs), 1vw, var(--spacing-sm));
}

.collaborators-list p span {
  display: block;
  line-height: 1.6;
  margin: 0;
  padding: clamp(var(--spacing-xs), 0.7vw, var(--spacing-xs)) 0;
  font-size: var(--font-size-paragraph);
  color: var(--text-color);
  opacity: 0.9;
  transition:
    opacity 0.2s ease,
    transform 0.2s ease,
    padding-left 0.2s ease;
  border-left: 2px solid transparent;
  padding-left: var(--spacing-xs);
}

.collaborators-list p span:not(:last-child) {
  border-bottom: 1px dashed rgba(255, 255, 255, 0.1);
  padding-bottom: clamp(var(--spacing-xs), 0.8vw, var(--spacing-sm));
}

/* ============================================================================
   TOOLS CONTAINER STYLING
   ============================================================================ */
.tools-container {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-xs);
  margin-bottom: 0;
  padding: clamp(var(--spacing-sm), 2vw, var(--spacing-sm));
  border: 1px dashed var(--border-color);
  border-radius: var(--border-radius);
  background-color: rgba(255, 255, 255, 0.02);
  transition:
    background-color 0.3s ease,
    border-color 0.3s ease;
}

.tools-container p {
  color: var(--text-color);
  margin: 0;
  display: flex;
  flex-direction: column;
  width: 100%;
  gap: clamp(var(--spacing-xs), 1vw, var(--spacing-sm));
}

.tools-container p span {
  display: block;
  line-height: 1.6;
  margin: 0;
  padding: clamp(var(--spacing-xs), 0.7vw, var(--spacing-xs)) 0;
  font-size: var(--font-size-paragraph);
  color: var(--text-color);
  opacity: 0.9;
  transition:
    opacity 0.2s ease,
    transform 0.2s ease,
    padding-left 0.2s ease;
  border-left: 2px solid transparent;
  padding-left: var(--spacing-xs);
}

.tools-container p span:not(:last-child) {
  border-bottom: 1px dashed rgba(255, 255, 255, 0.1);
  padding-bottom: clamp(var(--spacing-xs), 0.8vw, var(--spacing-sm));
}

/* Override for role, collaborators, and toolkit titles */
#project-role-title,
.project-role p span:first-child,
#collaborators-title,
.collaborators-list p span:first-child #toolkit-title,
.tools-container p span:first-child {
  border-left: none;
  padding-left: 0;
  border-bottom: 1px dashed rgba(255, 255, 255, 0.2);
}

#collaborators-title,
#toolkit-title,
.collaborators-list p span:first-child,
.tools-container p span:first-child {
  margin: 0;
  font-size: var(--font-size-details-titles);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  line-height: 1.4;
  padding: clamp(var(--spacing-xs), 1vw, var(--spacing-sm)) 0;
  color: var(--text-color);
  opacity: 1;
  transition:
    transform 0.2s ease,
    opacity 0.2s ease;
  border-left: none;
  padding-left: 0;
  font-family: var(--heading-font);
}

/* ============================================================================
   PROJECT LINKS STYLING
   ============================================================================ */
.project-links {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-xs);
  margin-bottom: 0;
  background-color: rgba(255, 255, 255, 0.02);
  transition:
    background-color 0.3s ease,
    border-color 0.3s ease;
  width: 100%;
}

.project-links:hover {
  background-color: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.9);
}

.project-link {
  border-radius: 10px;
  border: 1px dashed white;
  color: #fff;
  display: flex;
  position: relative;
  text-align: center;
  font-size: var(--font-size-button);
  padding: var(--spacing-sm) var(--spacing-sm);
  margin-bottom: 0;
  width: 100%;
  transition:
    color 0.5s,
    padding 0.5s,
    transform 0.2s;
  cursor: pointer;
  box-shadow: 0 10px 20px -8px rgba(0, 0, 0, 0.7);
  text-decoration: none;
  -webkit-tap-highlight-color: rgba(255, 255, 255, 0.2);
  touch-action: manipulation;
  user-select: none;
  min-height: var(--touch-target-min);
  align-items: center;
  justify-content: center;
  line-height: var(--line-height-normal);
  box-sizing: border-box;
}

.project-link:not(:last-child) {
  margin-bottom: var(--spacing-xs);
}

.project-link:after {
  content: " \2197 ";
  position: absolute;
  opacity: 0;
  right: -10px;
  transition: 0.5s;
  font-variant-emoji: text;
  font-family: inherit;
}

.project-link:hover {
  color: rgb(196, 172, 230);
  padding-right: 25px;
  padding-left: 8px;
}

.project-link:active {
  transform: scale(0.95);
  opacity: 0.9;
}

.project-link:focus {
  outline: 2px solid var(--hover-color);
  outline-offset: 2px;
}

.project-link:hover:after {
  opacity: 1;
  right: 10px;
}

/* ============================================================================
   DOCUMENTATION SECTION
   ============================================================================ */

.documentation {
  flex: 3;
  font-family: var(--content-font);
  padding: 2% 4%;
  border: 1px dashed var(--border-color);
  border-radius: var(--border-radius);
  line-height: 1.8;
  scrollbar-width: thin;
  scrollbar-color: var(--border-color) transparent;
  max-height: calc(100% - var(--spacing-lg));
  overflow-y: auto;
  margin-top: var(--spacing-lg);
  /* See note above re: bfcache restore visibility */
  animation: fadeInUp 1s ease-out 1s both;
}

.documentation h3 {
  font-family: var(--heading-font);
  font-size: var(--font-size-h3);
  font-weight: 600;
  margin-bottom: var(--spacing-md);
  color: var(---text-color);
  border-bottom: 1px solid var(--border-color);
  padding-bottom: var(--spacing-xs);
  line-height: var(--line-height-tight);
}

.documentation h3:first-child {
  margin-top: 0;
}

.documentation p {
  margin-bottom: var(--spacing-lg);
  color: var(--text-color);
  font-size: var(--font-size-paragraph);
  line-height: var(--line-height-loose);
}

.documentation ul {
  margin: 1.25rem 0;
  padding-left: 0;
  list-style: none;
}

.documentation li {
  margin-bottom: var(--spacing-sm);
  line-height: var(--line-height-relaxed);
  color: var(--project-desc-text-color);
  font-size: var(--font-size-paragraph);
  padding-left: 1.5rem;
  position: relative;
}

.documentation li::before {
  content: "•";
  color: var(--border-color);
  position: absolute;
  left: 0.5rem;
  font-size: 1.1em;
  font-weight: 600;
  line-height: inherit;
  vertical-align: baseline;
}

.documentation li:last-child {
  margin-bottom: 1.25rem;
}

.documentation p:last-child {
  margin-bottom: var(--spacing-md);
}

/* ============================================================================
   IMAGE CONTAINER STYLING
   ============================================================================ */
.project-container .documentation img {
  width: 100%;
  height: auto;
  object-fit: cover;
  border-radius: 5px;
  margin-bottom: 10px;
  justify-content: start;
}

.documentation .inline-img-container {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  margin: 1rem 0;
  padding: 0.5rem;
  margin-bottom: var(--spacing-md);
  position: relative;
}

.documentation .inline-img-container img {
  width: 100%;
  height: auto;
  object-fit: cover;
  border-radius: 5px;
  margin-bottom: 10px;
}

.documentation .inline-img {
  max-width: 100%;
  height: auto;
  border-radius: 8px;
  box-shadow:
    rgba(0, 0, 0, 0.25) 0px 14px 28px,
    rgba(0, 0, 0, 0.22) 0px 10px 10px;
  border: 1px solid var(--border-color);
  opacity: 1;
  display: block;
  margin: 0 auto;
  max-height: 50vh;
  object-fit: contain;
  position: relative;
}

.documentation .inline-img[src*=".png"],
.documentation .inline-img[src*=".PNG"] {
  border: none;
}

.documentation .inline-img-container .inline-img-caption {
  font-family: var(--content-font);
  font-size: clamp(0.75rem, 1.5vw, 0.9rem);
  color: var(--project-desc-text-color);
  opacity: 0.7;
  text-align: center;
  line-height: 1.4;
  margin-top: 0.5rem;
  width: 100%;
  max-width: 100%;
  align-self: center;
  word-wrap: break-word;
  overflow-wrap: break-word;
  white-space: normal;
  hyphens: auto;
}

/* ============================================================================
Inline Image Grid Layout
============================================================================ */

.documentation .inline-img-grid {
  display: grid;
  grid-template-columns: repeat(2, auto);
  gap: clamp(var(--spacing-xs), 1vw, var(--spacing-sm));
  margin: 1rem 0;
  margin-bottom: var(--spacing-md);
  width: 100%;
  justify-content: center;
  align-items: start;
}

.documentation .inline-img-grid-three {
  display: grid;
  grid-template-columns: repeat(3, auto);
  gap: clamp(var(--spacing-xs), 1vw, var(--spacing-sm));
  margin: 1rem 0;
  margin-bottom: var(--spacing-md);
  width: 100%;
  justify-content: center;
  align-items: start;
}

.documentation .inline-img-grid .inline-img-container {
  margin: 0;
  margin-bottom: 0;
  width: auto;
  display: flex;
  flex-direction: column;
}

.documentation .inline-img-grid-three .inline-img-container {
  margin: 0;
  margin-bottom: 0;
  width: auto;
  display: flex;
  flex-direction: column;
}

.documentation .inline-img-grid .inline-img-container figure {
  width: auto;
  height: 400px;
  padding: 0;
  display: flex;
  flex-direction: column;
  margin: 0;
}

.documentation .inline-img-grid-three .inline-img-container figure {
  width: auto;
  height: 400px;
  padding: 0;
  display: flex;
  flex-direction: column;
  margin: 0;
}

.documentation .inline-img-grid .inline-img {
  width: auto;
  height: 400px;
  object-fit: cover;
  display: block;
}

.documentation .inline-img-grid-three .inline-img {
  width: auto;
  height: 400px;
  object-fit: cover;
  display: block;
}

/* ============================================================================
   INLINE VIDEO GRID (3-column)
   ============================================================================ */
.documentation .inline-video-grid {
  display: grid;
  grid-template-columns: repeat(3, auto);
  gap: clamp(var(--spacing-xs), 1vw, var(--spacing-sm));
  margin: 1rem 0;
  margin-bottom: var(--spacing-md);
  width: 100%;
  justify-content: center;
  align-items: start;
}

.documentation .inline-video-grid .inline-video-container {
  margin: 0;
  margin-bottom: 0;
  width: auto;
  display: flex;
  flex-direction: column;
}

.documentation .inline-video-grid .inline-video-container figure {
  position: relative;
  width: auto;
  height: 400px;
  padding: 0;
  display: flex;
  flex-direction: column;
  margin: 0;
}

.documentation .inline-video-grid .inline-video {
  width: auto;
  height: 400px;
  object-fit: cover;
  display: block;
}

/* ============================================================================
     INLINE IMAGE GALLERY WITH AUTO-ROTATION
     ============================================================================ */
.documentation .inline-img-gallery {
  margin: 1.5rem 0;
  margin-bottom: var(--spacing-lg);
  width: 100%;
  position: relative;
}

.documentation .inline-img-gallery .gallery-container {
  position: relative;
  width: 100%;
}

.documentation .inline-img-gallery .gallery-slides {
  position: relative;
  width: 100%;
  overflow: hidden;
  min-height: 400px;
}

.documentation .inline-img-gallery .gallery-slide {
  display: none;
  width: 95%;
  opacity: 0;
  transition: opacity 0.6s ease-in-out;
  position: absolute;
  top: 0;
  left: 0;
}

.documentation .inline-img-gallery .gallery-slide.active {
  display: block;
  opacity: 1;
  position: relative;
}

.documentation .inline-img-gallery .gallery-slide .inline-img-container {
  margin: 0;
  margin-bottom: 0;
  width: 100%;
  padding: 0.5rem;
}

.documentation .inline-img-gallery .gallery-slide .inline-img-container figure {
  padding: 0;
  width: 100%;
  height: auto;
  max-height: none;
}

.documentation .inline-img-gallery .gallery-slide .inline-img {
  width: 100%;
  height: auto;
  max-height: 70vh;
  object-fit: contain;
}

/* Gallery Navigation Dots */
.documentation .inline-img-gallery .gallery-dots {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.75rem;
  margin-top: 1rem;
  padding: 0.75rem 0;
  flex-wrap: wrap;
}

.documentation .inline-img-gallery .gallery-dots .dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background-color: rgba(255, 255, 255, 0.3);
  cursor: pointer;
  transition: all 0.3s ease;
  border: 2px solid rgba(255, 255, 255, 0.5);
  flex-shrink: 0;
}

.documentation .inline-img-gallery .gallery-dots .dot:hover {
  background-color: rgba(255, 255, 255, 0.6);
  transform: scale(1.2);
  border-color: rgba(255, 255, 255, 0.8);
}

.documentation .inline-img-gallery .gallery-dots .dot.active {
  background-color: rgba(255, 255, 255, 0.95);
  border-color: rgba(255, 255, 255, 0.95);
  transform: scale(1.3);
  box-shadow: 0 0 8px rgba(255, 255, 255, 0.5);
}

.documentation .inline-img-gallery .gallery-caption {
  font-family: var(--content-font);
  font-size: clamp(0.75rem, 1.5vw, 0.9rem);
  color: var(--project-desc-text-color);
  opacity: 0.7;
  text-align: center;
  line-height: 1.4;
  margin-top: 0.5rem;
  width: 100%;
  max-width: 100%;
  align-self: center;
  word-wrap: break-word;
  overflow-wrap: break-word;
  white-space: normal;
  hyphens: auto;
}

/* ============================================================================
   INLINE IMAGE HOVER EFFECT
   ============================================================================ */

.documentation .inline-img-container figure {
  position: relative;
  padding: clamp(5px, 2vw, 15px);
  flex: 0 0 auto;
  width: auto;
  min-width: fit-content;
  height: 90%;
  max-height: calc(100% - 60px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  scroll-snap-align: center;
  scroll-snap-stop: normal;
  outline: none;
  -webkit-tap-highlight-color: rgba(255, 255, 255, 0.1);
  touch-action: pan-x pinch-zoom;
  user-select: none;
  cursor: pointer;
  pointer-events: auto;
}

/* Override figure padding for grid images */
.documentation .inline-img-grid .inline-img-container figure {
  padding: 0;
  width: 100%;
  height: auto;
  max-height: none;
}

.documentation .inline-img-container figure:hover,
.documentation .inline-video-container figure:hover {
  position: relative;
  object-fit: contain;
  cursor: pointer;
  z-index: 1;
  transition: all 0.3s ease;
}

.documentation .inline-img-container figure div,
.documentation .inline-video-container figure div {
  position: absolute;
  background: transparent;
  pointer-events: none;
  z-index: 1000;
  display: none;
}

.documentation .inline-img-container:hover figure div:nth-child(2),
.documentation .inline-video-container:hover figure div:nth-child(2) {
  top: 0;
  left: 0;
  display: block;
  width: clamp(60px, 4vw, 80px);
  height: clamp(60px, 4vw, 80px);
  border-left: 0.1px solid var(--image-border);
  border-top: 0.1px solid var(--image-border);
  border-radius: 15px 0px 0px 0px;
  opacity: 1;
  transition: all 0.3s ease;
}

.documentation .inline-img-container:hover figure div:nth-child(3),
.documentation .inline-video-container:hover figure div:nth-child(3) {
  top: 0;
  right: 0;
  display: block;
  width: clamp(60px, 4vw, 80px);
  height: clamp(60px, 4vw, 80px);
  border-top: 0.1px solid var(--image-border);
  border-right: 0.1px solid var(--image-border);
  border-radius: 0px 15px 0px 0px;
  opacity: 1;
  transition: all 0.3s ease;
}

.documentation .inline-img-container:hover figure div:nth-child(4),
.documentation .inline-video-container:hover figure div:nth-child(4) {
  bottom: 0;
  right: 0;
  display: block;
  width: clamp(60px, 4vw, 80px);
  height: clamp(60px, 4vw, 80px);
  border-bottom: 0.1px solid var(--image-border);
  border-right: 0.1px solid var(--image-border);
  border-radius: 0px 0px 15px 0px;
  opacity: 1;
  transition: all 0.3s ease;
}

.documentation .inline-img-container:hover figure div:nth-child(5),
.documentation .inline-video-container:hover figure div:nth-child(5) {
  bottom: 0;
  left: 0;
  display: block;
  width: clamp(60px, 4vw, 80px);
  height: clamp(60px, 4vw, 80px);
  border-bottom: 0.1px solid var(--image-border);
  border-left: 0.1px solid var(--image-border);
  border-radius: 0px 0px 0px 15px;
  opacity: 1;
  transition: all 0.3s ease;
}

/* Adjust borders for inline-img-grid, inline-img-grid-three, and inline-video-grid */
.documentation
  .inline-img-grid
  .inline-img-container:hover
  figure
  div:nth-child(2),
.documentation
  .inline-img-grid-three
  .inline-img-container:hover
  figure
  div:nth-child(2),
.documentation
  .inline-video-grid
  .inline-video-container:hover
  figure
  div:nth-child(2) {
  top: -8px;
  left: -8px;
  width: clamp(30px, 3vw, 40px);
  height: clamp(30px, 3vw, 40px);
  border-left: 0.1px solid rgba(255, 255, 255, 0.9);
  border-top: 0.1px solid rgba(255, 255, 255, 0.9);
  border-radius: 15px 0px 0px 0px;
}

.documentation
  .inline-img-grid
  .inline-img-container:hover
  figure
  div:nth-child(3),
.documentation
  .inline-img-grid-three
  .inline-img-container:hover
  figure
  div:nth-child(3),
.documentation
  .inline-video-grid
  .inline-video-container:hover
  figure
  div:nth-child(3) {
  top: -8px;
  right: -8px;
  width: clamp(30px, 3vw, 40px);
  height: clamp(30px, 3vw, 40px);
  border-top: 0.1px solid rgba(255, 255, 255, 0.9);
  border-right: 0.1px solid rgba(255, 255, 255, 0.9);
  border-radius: 0px 15px 0px 0px;
}

.documentation
  .inline-img-grid
  .inline-img-container:hover
  figure
  div:nth-child(4),
.documentation
  .inline-img-grid-three
  .inline-img-container:hover
  figure
  div:nth-child(4),
.documentation
  .inline-video-grid
  .inline-video-container:hover
  figure
  div:nth-child(4) {
  bottom: -8px;
  right: -8px;
  width: clamp(30px, 3vw, 40px);
  height: clamp(30px, 3vw, 40px);
  border-bottom: 0.1px solid rgba(255, 255, 255, 0.9);
  border-right: 0.1px solid rgba(255, 255, 255, 0.9);
  border-radius: 0px 0px 15px 0px;
}

.documentation
  .inline-img-grid
  .inline-img-container:hover
  figure
  div:nth-child(5),
.documentation
  .inline-img-grid-three
  .inline-img-container:hover
  figure
  div:nth-child(5),
.documentation
  .inline-video-grid
  .inline-video-container:hover
  figure
  div:nth-child(5) {
  bottom: -8px;
  left: -8px;
  width: clamp(30px, 3vw, 40px);
  height: clamp(30px, 3vw, 40px);
  border-bottom: 0.1px solid rgba(255, 255, 255, 0.9);
  border-left: 0.1px solid rgba(255, 255, 255, 0.9);
  border-radius: 0px 0px 0px 15px;
}

/* Adjust borders for inline-img-gallery */
.documentation
  .inline-img-gallery
  .inline-img-container:hover
  figure
  div:nth-child(2) {
  top: -8px;
  left: -8px;
  width: clamp(30px, 3vw, 40px);
  height: clamp(30px, 3vw, 40px);
  border-left: 0.1px solid rgba(255, 255, 255, 0.9);
  border-top: 0.1px solid rgba(255, 255, 255, 0.9);
  border-radius: 15px 0px 0px 0px;
}

.documentation
  .inline-img-gallery
  .inline-img-container:hover
  figure
  div:nth-child(3) {
  top: -8px;
  right: -8px;
  width: clamp(30px, 3vw, 40px);
  height: clamp(30px, 3vw, 40px);
  border-top: 0.1px solid rgba(255, 255, 255, 0.9);
  border-right: 0.1px solid rgba(255, 255, 255, 0.9);
  border-radius: 0px 15px 0px 0px;
}

.documentation
  .inline-img-gallery
  .inline-img-container:hover
  figure
  div:nth-child(4) {
  bottom: -8px;
  right: -8px;
  width: clamp(30px, 3vw, 40px);
  height: clamp(30px, 3vw, 40px);
  border-bottom: 0.1px solid rgba(255, 255, 255, 0.9);
  border-right: 0.1px solid rgba(255, 255, 255, 0.9);
  border-radius: 0px 0px 15px 0px;
}

.documentation
  .inline-img-gallery
  .inline-img-container:hover
  figure
  div:nth-child(5) {
  bottom: -8px;
  left: -8px;
  width: clamp(30px, 3vw, 40px);
  height: clamp(30px, 3vw, 40px);
  border-bottom: 0.1px solid rgba(255, 255, 255, 0.9);
  border-left: 0.1px solid rgba(255, 255, 255, 0.9);
  border-radius: 0px 0px 0px 15px;
}

/* ============================================================================
   VIDEO CONTAINER STYLING
   ============================================================================ */
.documentation .inline-video-container {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  margin: 0.75rem 0;
  padding: 0;
  width: 100%;
  max-width: 100%;
  min-width: 0; /* allow flex shrink on narrow viewports */
  box-sizing: border-box;
}

.documentation .inline-video-container figure {
  position: relative;
  margin: 0;
  padding: clamp(5px, 2vw, 15px);
  width: 100%;
  max-width: 100%;
  min-width: 0;
  cursor: pointer;
  outline: none;
  -webkit-tap-highlight-color: rgba(255, 255, 255, 0.1);
  user-select: none;
}

.documentation .inline-video-container video {
  width: 100%;
  max-width: 100%;
  display: block;
  box-sizing: border-box;
}

.documentation .inline-video {
  width: 100%;
  max-width: 100%;
  height: auto;
  min-height: 200px;
  border-radius: 8px;
  box-shadow:
    rgba(0, 0, 0, 0.25) 0px 14px 28px,
    rgba(0, 0, 0, 0.22) 0px 10px 10px;
  border: 1px solid var(--border-color);
  opacity: 1;
  display: block;
  margin: 0 auto;
  max-height: 50vh;
  vertical-align: middle;
  object-fit: cover;
}

.documentation .inline-video-container .inline-video-caption {
  font-family: var(--content-font);
  font-size: clamp(0.75rem, 1.5vw, 0.9rem);
  color: var(--project-desc-text-color);
  opacity: 0.7;
  text-align: center;
  line-height: 1.4;
  margin-top: 0.5rem;
  width: 100%;
  max-width: 100%;
  align-self: center;
  word-wrap: break-word;
  overflow-wrap: break-word;
  white-space: normal;
  hyphens: auto;
}

/* ============================================================================
   AUDIO CONTAINER STYLING
   ============================================================================ */
.documentation .inline-audio-container {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  margin: 1.5rem 0;
  padding: 0.5rem;
  width: 100%;
}

.documentation .inline-audio-container audio {
  width: 100%;
  max-width: 100%;
  display: block;
  background-color: transparent;
  border: 1px solid black;
  border-radius: 8px;
  outline: none;
  box-shadow: none;
  margin: 0;
  padding: 0;
  cursor: pointer;
  filter: invert(1);
}

.documentation .inline-audio {
  width: 100%;
  max-width: 100%;
  height: auto;
  min-height: 48px;
  border-radius: 8px;
  box-shadow:
    rgba(0, 0, 0, 0.25) 0px 14px 28px,
    rgba(0, 0, 0, 0.22) 0px 10px 10px;
  border: 1px solid var(--border-color);
  opacity: 1;
  display: block;
  margin: 0 auto;
  background-color: #d74b4b;
  vertical-align: middle;
}

.documentation .inline-audio-container .inline-audio-caption {
  font-family: var(--content-font);
  font-size: clamp(0.75rem, 1.5vw, 0.9rem);
  color: var(--project-desc-text-color);
  opacity: 0.7;
  text-align: center;
  line-height: 1.4;
  margin-top: 0.5rem;
  width: 100%;
  max-width: 100%;
  align-self: center;
  word-wrap: break-word;
  overflow-wrap: break-word;
  white-space: normal;
  hyphens: auto;
}

/* ============================================================================
   CREDITS AND REFERENCES SECTION STYLING
   ============================================================================ */
.documentation .credits-container {
  margin-top: 1.5rem;
  padding-top: 1rem;
}

.documentation .credits-container h3 {
  font-size: clamp(0.9rem, 1.8vw, 1rem);
  font-weight: 400;
  margin-bottom: 0.75rem;
  opacity: 0.6;
  border-bottom: 1px dotted rgba(255, 255, 255, 0.7);
  padding-bottom: 0.5rem;
}

.documentation .credits-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0 2rem;
  column-gap: clamp(1.5rem, 3vw, 3rem);
}

.documentation .credits-list li {
  list-style: none;
  padding: 0.5rem 0;
  padding-left: 0;
  border-bottom: 1px dotted rgba(255, 255, 255, 0.45);
  margin-bottom: 0.4rem;
  break-inside: avoid;
  page-break-inside: avoid;
}

.documentation .credits-list li::before {
  content: none;
  display: none;
}

.documentation .credits-list li:last-child {
  border-bottom: none;
  margin-bottom: 0;
}

.documentation .credits-list .credits-category {
  font-weight: 400;
  color: rgba(255, 255, 255, 0.85);
  margin-bottom: 0.35rem;
  margin-top: 0.2rem;
  font-size: clamp(0.7rem, 1.2vw, 0.8rem);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  opacity: 0.7;
}

.documentation .credits-list li:first-child .credits-category {
  margin-top: 0;
}

.documentation .credits-list .credits-detail {
  color: rgba(255, 255, 255, 0.8);
  margin-bottom: 0.5rem;
  font-size: clamp(0.7rem, 1.2vw, 0.8rem);
  line-height: 1.5;
  opacity: 0.7;
}

.documentation .credits-list .credits-detail:last-child {
  margin-bottom: 0;
}

.documentation .credits-list .credits-detail em {
  font-style: italic;
  color: rgba(255, 255, 255, 0.8);
  opacity: 0.8;
}

.documentation .credits-list .credits-detail a {
  color: rgba(255, 255, 255, 0.9);
  text-decoration: none;
  transition:
    color 0.3s ease,
    opacity 0.3s ease;
  opacity: 0.7;
}

.documentation .credits-list .credits-detail a:hover {
  color: rgba(255, 255, 255, 1);
  opacity: 1;
  text-decoration: underline;
}

/* ============================================================================
   FULLSCREEN OVERLAY STYLING
   ============================================================================ */
.inline-fullscreen {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.95);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
}

.inline-fullscreen.active {
  opacity: 1;
  pointer-events: all;
}

.inline-fullscreen-content {
  position: relative;
  max-width: 90vw;
  max-height: 90vh;
  display: grid;
  grid-template-columns: auto auto;
  grid-template-rows: auto auto;
  column-gap: 0.75rem;
  row-gap: 1.25rem;
  align-items: start;
  justify-content: center;
  padding: 2rem;
}

.inline-fullscreen-close {
  position: static;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(5px);
  border: none;
  color: white;
  font-size: 1.6rem;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10001;
  transition: all 0.3s ease;
  line-height: 1;
  padding: 0;
  box-shadow: 0 2px 8px rgba(255, 255, 255, 0.2);
  user-select: none;
  grid-column: 2;
  grid-row: 1;
  align-self: start;
  margin-top: -2.2rem; /* Nudge slightly above the media top edge */
}

.inline-fullscreen-img,
.inline-fullscreen-video {
  grid-column: 1;
  grid-row: 1;
}

.inline-fullscreen-caption {
  grid-column: 1 / -1;
  grid-row: 2;
}

.inline-fullscreen-close:hover {
  background: rgba(255, 255, 255, 0.1);
  transform: translateY(-2px) scale(1.05);
  box-shadow: 0 4px 16px rgba(255, 255, 255, 0.4);
}

.inline-fullscreen-close:active {
  opacity: 0.9;
  transform: translateY(-2px) scale(0.95);
  background: rgba(255, 255, 255, 0.15);
}

.inline-fullscreen-close:focus {
  outline: none;
}

.inline-fullscreen-close:focus-visible {
  outline: 2px solid var(--button-hover-color);
  outline-offset: 3px;
}

.inline-fullscreen-prev,
.inline-fullscreen-next {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(10px);
  border: none;
  color: white;
  font-size: 3rem;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 10001;
  transition: all 0.3s ease;
  line-height: 1;
  padding: 0;
  user-select: none;
  box-shadow: 0 2px 8px rgba(255, 255, 255, 0.2);
}

.inline-fullscreen-prev {
  left: 1rem;
}

.inline-fullscreen-next {
  right: 1rem;
}

.inline-fullscreen-prev:hover:not(:disabled),
.inline-fullscreen-next:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.1);
  transform: translateY(calc(-50% - 2px)) scale(1.05);
  box-shadow: 0 4px 16px rgba(255, 255, 255, 0.4);
}

.inline-fullscreen-prev:active:not(:disabled),
.inline-fullscreen-next:active:not(:disabled) {
  opacity: 0.9;
  transform: translateY(calc(-50% - 2px)) scale(0.95);
  background: rgba(255, 255, 255, 0.15);
}

.inline-fullscreen-prev:focus,
.inline-fullscreen-next:focus {
  outline: none;
}

.inline-fullscreen-prev:disabled,
.inline-fullscreen-next:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.inline-fullscreen-img,
.inline-fullscreen-video {
  max-width: 100%;
  max-height: calc(90vh - 100px);
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: 8px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}

.inline-fullscreen-video {
  width: 100%;
  max-width: 90vw;
}

.inline-fullscreen-caption {
  margin-top: 1.5rem;
  color: rgba(255, 255, 255, 0.8);
  font-family: var(--content-font);
  font-size: clamp(0.9rem, 1.5vw, 1.1rem);
  text-align: center;
  max-width: 80%;
  line-height: 1.5;
}

/* ============================================================================
   NEXT AND PREVIOUS BUTTONS
   ============================================================================ */

.nextPrev {
  display: flex;
  width: 100%;
  justify-content: space-between;
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 15;
  box-sizing: border-box;
  height: 65px;
  padding: var(--spacing-sm) var(--page-margin);
  margin-top: 0;
  margin-bottom: 0;
  background-color: var(--bg-color);
}

/* Remove divider line directly under Next/Prev */
.nextPrev + hr {
  display: none;
}

.prev-project,
.next-project {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.previous,
.next {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  background-color: var(--button-color);
  color: black;
  border-radius: 50%;
  text-decoration: none;
  padding: 0;
  font-size: 1.2rem;
  line-height: 1;
  box-shadow: 0 2px 8px rgba(255, 255, 255, 0.2);
  z-index: 10;
  text-decoration: none;
  /* Enhanced touch interactions */
  -webkit-tap-highlight-color: rgba(255, 255, 255, 0.2);
  touch-action: manipulation;
  user-select: none;
  transition:
    transform 0.2s ease,
    background-color 0.2s ease;
  /* Minimum touch target */
  min-width: var(--touch-target-min);
  min-height: var(--touch-target-min);
}

.previous:hover,
.next:hover {
  color: var(--text-color);
  box-shadow: 0 4px 16px rgba(255, 255, 255, 0.4);
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(5px);
}

.previous:active,
.next:active {
  opacity: 0.9;
  transform: translateY(-2px) scale(0.95);
  background: rgba(255, 255, 255, 0.15);
}

.previous:focus,
.next:focus {
  outline: none;
}

.prev-project p,
.next-project p {
  margin: 0;
  font-size: var(--font-size-paragraph);
  line-height: 1.3;
  white-space: normal;
  word-wrap: break-word;
}

/* ============================================================================
   MEDIA QUERIES FOR RESPONSIVE DESIGN
   ============================================================================ */

@media (max-width: 768px) {
  body {
    margin: 0;
    padding-bottom: 0;
  }

  .project-link:after {
    display: none;
    content: none;
  }
  .project-container {
    display: flex;
    flex-direction: column;
    padding: 0;
    position: static;
    top: auto;
    height: auto;
  }
  .nextPrev {
    position: static;
    height: auto;
    padding: 0;
    margin-top: var(--spacing-lg);
    margin-bottom: var(--spacing-lg);
  }

  .details {
    width: 100%;
    height: auto;
    overflow-y: visible;
    padding: 0;
  }

  .project-role,
  .collaborators-list,
  .tools-container {
    width: 100%;
    min-width: 0;
    box-sizing: border-box;
  }

  .collaborators-list,
  .tools-container {
    display: flex;
    flex-direction: column;
  }

  .project-visual {
    width: 100%;
    height: auto;
    object-fit: cover;
    border-radius: 0;
    margin-top: 10vh;
  }

  .documentation .inline-img-grid {
    grid-template-columns: 1fr;
    gap: var(--spacing-md);
  }

  .documentation .inline-img-grid .inline-img-container figure,
  .documentation .inline-img-grid .inline-img {
    height: auto;
    width: 100%;
    max-height: 70vh;
  }

  .documentation .inline-img-grid .inline-img {
    object-fit: contain;
  }

  .documentation .inline-img-grid-three,
  .documentation .inline-video-grid {
    grid-template-columns: 1fr;
    gap: var(--spacing-md);
  }

  .documentation .inline-img-grid-three .inline-img-container figure,
  .documentation .inline-img-grid-three .inline-img,
  .documentation .inline-video-grid .inline-video-container figure,
  .documentation .inline-video-grid .inline-video {
    height: auto;
    width: 100%;
    max-height: 70vh;
  }

  .documentation .inline-img-grid-three .inline-img,
  .documentation .inline-video-grid .inline-video {
    object-fit: contain;
  }
  /* Responsive adjustments for gallery */
  .documentation .inline-img-gallery .gallery-slides {
    min-height: 300px;
  }

  .documentation .inline-img-gallery .gallery-dots {
    gap: 0.3rem;
  }

  .documentation .inline-img-gallery .gallery-dots .dot {
    width: 5px;
    height: 5px;
  }

  /* Standalone inline images: scale better on mobile (not in grid/gallery) */
  .documentation > .inline-img-container figure {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    height: auto;
    max-height: none;
    padding: 0.5rem;
  }

  .documentation > .inline-img-container .inline-img {
    width: 100%;
    max-width: 100%;
    height: auto;
    max-height: 70vh;
    object-fit: contain;
  }

  /* Inline video container: better fit and touch on mobile */
  .documentation .inline-video-container {
    margin: 0.5rem 0;
    padding: 0;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
  }

  .documentation .inline-video-container figure {
    width: 100%;
    max-width: 100%;
    min-width: 0;
  }

  .documentation .inline-video-container .inline-video {
    max-height: 55vh;
    min-height: 180px;
    border-radius: 6px;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
  }

  .documentation .inline-video-container .inline-video-caption {
    padding: 0 0.25rem;
    margin-top: 0.4rem;
    font-size: clamp(0.7rem, 2.5vw, 0.85rem);
  }

  .documentation .inline-img-gallery .gallery-caption {
    padding: 0 0.25rem;
    margin-top: 0.4rem;
    font-size: clamp(0.7rem, 2.5vw, 0.85rem);
  }

  /* Single column credits list on smaller screens */
  .documentation .credits-list {
    grid-template-columns: 1fr;
    column-gap: 0;
  }
}

/* ============================================================================
   REDUCED MOTION SUPPORT
   ============================================================================ */
@media (prefers-reduced-motion: reduce) {
  .project-visual,
  #main-img,
  .title,
  .project-container,
  .details,
  .documentation {
    animation: none !important;
    opacity: 1 !important;
  }
}
