/* Portfolio main spacing */
.main {
  padding-top: var(--header-h);
}

.scrolling-text-container {
  width: 100%;
  overflow: hidden;
  padding: 30px 0;
  margin-top: var(--header-h);
}

.scrolling-text {
  display: inline-flex;
  align-items: center;
  flex-wrap: nowrap;
  width: max-content;
  animation: scrollText 28s linear infinite;
  will-change: transform;
}

.scroll-inner {
  flex: 0 0 auto;
  display: inline-block;
  font-family: var(--font-retro);
  font-size: 16px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-secondary);
  white-space: nowrap;
  padding-right: 0;
}

/* Sharpen retro font rendering for inline retro pieces */
.scroll-inner,
.about-section-title,
.ascii-creature,
.project-title {
  font-weight: 400;
  line-height: 1;
  text-rendering: geometricPrecision;
}

@keyframes scrollText {
  0%   { transform: translateX(0); }
  100% { transform: translateX(-50%); }
}

/* Ensure consistent spacing for project images across portfolio pages and modals */
:root {
  --portfolio-image-gap: var(--space-md);
}

/* Apply the same gap to the projects grid and dungeon grid when present */
.projects-grid,
.dungeon-grid {
  gap: var(--portfolio-image-gap);
}

/* Ensure modal media uses the same gap value */
.project-modal-media {
  gap: var(--portfolio-image-gap);
}

@media (max-width: 560px) {
  /* On phones, use a slightly smaller gap for tighter layouts but keep it consistent */
  :root { --portfolio-image-gap: var(--space-sm); }

  .projects-grid,
  .dungeon-grid,
  .project-modal-media {
    gap: var(--portfolio-image-gap) !important;
  }

  /* Ensure project preview and modal images have consistent vertical spacing */
  .project-preview,
  .project-modal-image,
  .dungeon-card img {
    margin-bottom: 0;
  }
}

/* Creature & Tags */

.intro-section {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(48px, 1fr) auto;
  gap: var(--space-md);
  padding: var(--space-lg) 0 var(--space-xl);
  margin-bottom: var(--space-lg);
  justify-items: center;
  align-items: start;
}

.intro-spacer {
  width: 100%;
  min-height: 1px;
}

.intro-text {
  text-align: left;
}

.intro-description {
  font-family: var(--font-body);
  font-weight: 400;
  font-size: 18px;
  letter-spacing: -0.012em;
  color: var(--text-secondary);
  text-rendering: optimizeLegibility;
}

/* About Page */

.about-section-title span { background: var(--color-highlight); color: var(--bg-primary); }

.about-section-title {
  font-family: var(--font-retro);
  font-size: 28px;
  font-weight: 400;
  letter-spacing: 2px;
  margin-bottom: var(--space-lg);
  text-transform: uppercase;
  text-rendering: geometricPrecision;
}

.about-section-title span {
  display: inline;
  position: relative;
  cursor: default;
  padding: 0 2px;
}

.about-copy {
  font-size: 18px;
  max-width: 58ch;
  display: inline-block;
}

/* About Background Section */
.about-dates {
  font-family: var(--font-retro);
  font-size: 21px;
  color: var(--color-highlight);
  margin-top: var(--space-xs);
}

.about-parcours {
  font-size: 18px;
  display: inline-block;
  line-height: 1.3;
  margin-top: 3px;
}

.about-descript {
  font-size: 16px;
  line-height: 1.2;
  display: inline-block;
  color: var(--text-dimmed);
  margin-top: 3px;
  margin-bottom: var(--space-sm);
}

.about-link {
  font-size: 20px;
  text-decoration: none;
  color: var(--color-highlight);
  display: inline-flex;
  position: relative;
  transition: color 0.2s ease;
  margin-left: 10px;
}

.about-content {
  grid-template-columns: 1fr;
  justify-items: start;
  max-width: 800px;
  margin: 0 auto;
}

.about-section {
  width: 100%;
}

.about-section + .about-section {
  margin-top: var(--space-xl);
}

/* About Page Links */

.about-link::after {
  content: '';
  position: absolute;
  width: calc(100% + 6px);
  height: 1.1em;
  left: -3px;
  top: 50%;
  transform: translateY(-50%);
  background: var(--color-highlight);
  opacity: 0;
  transition: opacity 0.2s ease;
  z-index: -1;
}

.about-link:hover {
  color: var(--bg-primary);
}

.about-link:hover::after {
  opacity: 1;
}
.about-copy .bio-link {
  display: inline-block;
  position: relative;
  text-decoration: none;
  font-weight: 500;
  box-decoration-break: clone;
}

.about-copy .bio-link:hover {
  color: var(--bg-primary);
  box-decoration-break: clone;
}

.about-copy .bio-red {
  --bio-accent: rgb(255, 71, 86);
  color: var(--rgb-red);
}

.about-copy .bio-green {
  --bio-accent: rgba(46, 213, 115, 1);
  color: var(--rgb-green);
}

.about-copy .bio-blue {
  --bio-accent: rgba(83, 82, 237, 1);
  color: var(--rgb-blue);
}

.about-copy .bio-color {
  --bio-accent: var(--color-highlight);
  color: var(--color-highlight);
}

.about-copy .bio-link::after {
  content: '';
  position: absolute;
  width: calc(100% + 4px);
  height: 1.2em;
  left: -2px;
  top: 50%;
  transform: translateY(-50%);
  background: var(--bio-accent);
  opacity: 0;
  transition: opacity 0.2s ease;
  z-index: -1;
}

.about-copy .bio-link:hover::after {
  opacity: 1;
}

.about-copy + .about-copy {
  margin-top: 20px;
}

/* Highlight spans in description */

.highlight {
  display: inline;
  position: relative;
  cursor: default;
  padding: 0 2px;
}

.highlight-1 { background: rgb(255, 71, 86); color: var(--bg-primary); }
.highlight-2 { background: rgb(82, 82, 237); color: var(--bg-primary); }
.highlight-3 { background: rgb(46, 213, 116); color: var(--bg-primary); }
.highlight-4 { background: rgb(255, 166, 2); color: var(--bg-primary); }

.highlight::after {
  content: '';
  position: absolute;
  width: 100%;
  height: 100%;
  left: 0;
  bottom: 0;
  background: currentColor;
  opacity: 0.08;
  transform: scaleX(0);
  transform-origin: right;
  transition: transform 0.3s ease;
}

.highlight:hover::after {
  transform: scaleX(1);
  transform-origin: left;
}

.ascii-creature {
  font-family: var(--font-retro);
  font-size: 15px;
  color: var(--text-secondary);
  line-height: 1.2;
  white-space: pre;
  min-height: 220px;
}

/* Tags in intro section — right column (3 column desktop) */

.intro-section .tag-filter-container {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-content: flex-start;
  justify-content: flex-end;
  justify-self: end;
  grid-column: 3;
  width: 500px;
  max-width: 100%;
}

/* Tablet: 2 columns */

@media (max-width: 900px) {
  .intro-section {
    grid-template-columns: 1fr;
    gap: var(--space-lg);
    padding: var(--space-lg) 0 var(--space-xl);
    margin-bottom: var(--space-sm);
    justify-items: center;
  }

  .intro-spacer {
    display: none;
  }

  .ascii-creature {
    margin-top: var(--space-md);
    margin-bottom: var(--space-md);
    display: block;
    width: fit-content;
    margin-left: auto;
    margin-right: auto;
    min-height: auto;
  }

  .intro-section .tag-filter-container {
    grid-column: 1 / -1;
    justify-content: center;
    margin: 0 auto;
    width: calc(100% - 32px);
  }
}

.projects-section {
  padding: var(--space-lg) 0;
}

.projects-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-md);
}

/* --- Project Card --- */
.project-card {
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
  transition: transform 0.25s ease;
}
.project-card:hover {
  transform: translateY(-4px);
}

.project-preview {
  width: 100%;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  border-radius: 4px;
  background-color: var(--bg-secondary);
  position: relative;
}

.project-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  display: block;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  filter: grayscale(1) sepia(1) saturate(0.45) hue-rotate(338deg) brightness(0.86) contrast(1.18);
  transition: transform 0.2s ease, filter 0.14s ease;
}

.project-preview::after {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--text-primary);
  opacity: 0.12;
  mix-blend-mode: color;
  pointer-events: none;
  transition: opacity 0.12s ease;
}

.project-card:hover .project-preview img {
  transform: scale(1.04);
  filter: none;
}

.project-card:hover .project-preview::after {
  opacity: 0;
}

.carousel-caption {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 10px;
  padding: var(--space-md);
  background: linear-gradient(180deg, rgba(0, 0, 0, 0) 35%, rgba(0, 0, 0, 0.72) 100%);
  pointer-events: none;
}

.carousel-caption .about-descript {
  margin: 0;
  color: var(--text-primary);
  line-height: 1.35;
}

.project-card-meta-rows {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.project-card .project-info-row {
  margin-top: 0;
  font-size: 14px;
  line-height: 1.35;
  align-items: flex-start;
}

.project-card .project-info-row .info-label {
  min-width: 128px;
  flex: 0 0 128px;
  color: var(--text-primary);
}

.project-card .project-info-row .info-value {
  color: var(--text-secondary);
  min-width: 0;
}

.project-card .project-info-row .info-value,
.project-card .project-info-row .info-label {
  pointer-events: auto;
}

.project-meta {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 0 var(--space-md);
  gap: var(--space-lg);
  flex-wrap: wrap;
  align-content: flex-start;
}

.project-title {
  font-family: var(--font-retro);
  font-size: 18px;
  font-weight: 400;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-primary);
  flex: 0 1 50%;
  word-break: break-word;
}

.project-tag {
  flex: 0 1 calc(50% / 5);
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 300;
  color: var(--text-secondary);
  white-space: nowrap;
  text-align: right;
  min-width: 60px;
}

.project-tags-inline {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  width: 100%;
  margin-top: 4px;
}

.project-tags-inline span {
  display: inline-flex;
  align-items: center;
  padding: 4px 8px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  font-family: var(--font-body);
  font-size: 13px;
  color: var(--text-secondary);
  white-space: nowrap;
}


/* Tablet: 2 columns */
@media (max-width: 900px) {
  .container {
    padding: var(--space-md) var(--space-md);
  }

  .projects-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-sm);
  }

  .tag-filter-container {
    margin-bottom: var(--space-md);
    gap: 10px;
    row-gap: 12px;
  }

  .tag-filter-btn {
    font-size: 14px;
    padding: 7px 13px;
  }
}

/* Mobile: 1 column */
@media (max-width: 700px) {
  html, body {
    overflow-y: auto;
    height: auto;
    min-height: 100vh;
  }

  .scrolling-text-container {
    padding-top: 10px;
  }

  .main {
    height: auto;
    min-height: calc(100vh - var(--header-h));
    padding-top: var(--header-h);
    overflow: visible;
    background: linear-gradient(
      180deg,
      rgba(45, 37, 26, 0.95) 0%,
      rgba(45, 37, 26, 0.3) 100%
    );
    box-sizing: border-box;
  }

  .container {
    padding: var(--space-md) var(--space-sm);
  }

  .intro-section {
    grid-template-columns: 1fr;
    gap: var(--space-lg);
    padding: var(--space-lg) 0 var(--space-xl);
    margin-bottom: var(--space-sm);
    justify-items: start;
  }

  .intro-spacer {
    display: none;
  }

  .ascii-creature {
    font-size: 12px;
    margin-top: -10px;
    margin-bottom: var(--space-md);
    display: block;
    width: fit-content;
    margin-left: auto;
    margin-right: auto;
    min-height: auto;
  }

  .intro-section .tag-filter-container {
    grid-column: 1 / -1;
    justify-content: center;
    margin: 0 auto;
    width: calc(100% - 32px);
  }

  .projects-grid {
    grid-template-columns: 1fr;
    gap: var(--space-md);
  }

  .project-preview {
    aspect-ratio: 16 / 10;
  }

  .tag-filter-container {
    margin-bottom: var(--space-md);
    gap: 12px;
    row-gap: 16px;
    justify-content: center;
    display: flex;
    flex-wrap: wrap;
  }

  .tag-filter-btn {
    font-size: 15px;
    padding: 12px 20px;
  }
}

/* --- Footer --- */
.footer {
  margin-top: var(--space-xxl);
  padding: var(--space-lg) 0 var(--space-xl);
}

.footer-divider {
  width: 100%;
  height: 1px;
  background-color: var(--warm-brown);
  opacity: 0.3;
  margin-bottom: var(--space-md);
}

.footer-content {
  display: flex;
  justify-content: space-between;
  font-family: var(--font-body);
  font-size: 12px;
  color: var(--warm-brown);
  letter-spacing: 0.05em;
}