/* KoveForge visual refresh: navigation restoration, ambient glass, projects and galleries. */
:root {
  --ambient-art: url("../images/visuals/ambient-glass-light.webp?v=20260730");
  --ambient-wash: rgb(248 250 252 / 0.72);
  --ambient-panel: rgb(255 255 255 / 0.68);
  --ambient-line: rgb(99 102 241 / 0.2);
  --ambient-shadow: 0 24px 70px rgb(15 23 42 / 0.12);
}

html.dark-theme {
  --ambient-art: url("../images/visuals/ambient-glass-dark.webp?v=20260730");
  --ambient-wash: rgb(6 7 11 / 0.7);
  --ambient-panel: rgb(10 13 24 / 0.7);
  --ambient-line: rgb(129 140 248 / 0.26);
  --ambient-shadow: 0 28px 80px rgb(0 0 0 / 0.42);
}

/* Original navigation treatment retained after the performance bundle. */
.nav-links.is-open {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
  visibility: visible;
}

.nav-links a {
  position: relative;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: var(--fs-sm);
  font-weight: 600;
  transition: color var(--dur-fast) ease, background var(--dur-fast) ease;
}

.nav-links a:hover,
.nav-links a[aria-current="page"] {
  color: var(--text-primary);
  background: rgb(var(--accent-violet-rgb) / 0.1);
}

.nav-links a::after {
  content: "";
  position: absolute;
  right: 14px;
  bottom: 4px;
  left: 14px;
  height: 2px;
  border-radius: var(--radius-full);
  background: linear-gradient(90deg, var(--accent-violet), var(--accent-cyan));
  background-position: 0% 50%;
  background-size: 200% 100%;
  opacity: 0;
  transform: scaleX(0);
  transition: opacity var(--dur-normal) var(--ease-out-expo), transform var(--dur-normal) var(--ease-out-expo), background-position var(--dur-slow) ease;
}

.nav-links a:hover::after,
.nav-links a[aria-current="page"]::after {
  background-position: 100% 50%;
  opacity: 1;
  transform: scaleX(1);
}

/* Restrained atmospheric depth across the site. */
main {
  isolation: isolate;
}

main > section {
  position: relative;
  isolation: isolate;
}

:is(.page-hero, .brand-hero, .case-hero, .featured-section, .projects-capabilities, .projects-cta-band)::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -2;
  pointer-events: none;
  background: linear-gradient(var(--ambient-wash), var(--ambient-wash)), var(--ambient-art) center / cover no-repeat;
}

:is(.page-hero, .brand-hero, .case-hero)::after {
  content: "";
  position: absolute;
  inset: auto 8% 0;
  z-index: -1;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--accent-violet), var(--accent-cyan), transparent);
  opacity: 0.48;
}

:is(.glass-panel, .featured-card, .contact-band, .projects-cta-inner, .case-gallery, .case-panel, .brand-card, .service-card, .info-card) {
  border-color: rgb(255 255 255 / 0.42);
  background: linear-gradient(145deg, rgb(255 255 255 / 0.1), transparent 44%), var(--ambient-panel);
  box-shadow: var(--ambient-shadow);
  backdrop-filter: blur(22px) saturate(135%);
  -webkit-backdrop-filter: blur(22px) saturate(135%);
}

html.dark-theme :is(.glass-panel, .featured-card, .contact-band, .projects-cta-inner, .case-gallery, .case-panel, .brand-card, .service-card, .info-card) {
  border-color: rgb(148 163 184 / 0.14);
}

:is(.visual-strip, .visual-strip-compact, .process-showcase, .brand-split, .contact-layout, .ai-overview) {
  position: relative;
}

:is(.visual-strip, .visual-strip-compact, .process-showcase)::before {
  content: "";
  position: absolute;
  inset: -1rem;
  z-index: -1;
  border: 1px solid var(--ambient-line);
  border-radius: calc(var(--radius-xl) + 0.5rem);
  background: linear-gradient(135deg, rgb(var(--accent-violet-rgb) / 0.08), rgb(var(--accent-cyan-rgb) / 0.05));
  filter: blur(0.2px);
}

/* Editorial portfolio hierarchy. */
.projects-hero-mosaic {
  min-width: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
  padding: 0.75rem;
  border: 1px solid var(--ambient-line);
  border-radius: var(--radius-xl);
  background: var(--ambient-panel);
  box-shadow: var(--ambient-shadow);
  transform: perspective(1200px) rotateY(-2deg) rotateX(1deg);
  backdrop-filter: blur(22px) saturate(135%);
  -webkit-backdrop-filter: blur(22px) saturate(135%);
}

.projects-hero-shot {
  position: relative;
  overflow: hidden;
  min-height: 7rem;
  border: 1px solid rgb(255 255 255 / 0.34);
  border-radius: var(--radius-md);
  background: var(--surface-600);
  box-shadow: 0 12px 32px rgb(var(--shadow-base-rgb) / 0.16);
}

.projects-hero-shot--primary {
  grid-column: 1 / -1;
  min-height: 12rem;
}

.projects-hero-shot img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top center;
  transition: transform var(--dur-slow) var(--ease-out-expo);
}

.projects-hero-shot:hover img,
.projects-hero-shot:focus-visible img {
  transform: scale(1.025);
}

.featured-section {
  overflow: hidden;
}

.featured-section .featured-grid {
  align-items: stretch;
}

.featured-section .project-card {
  min-height: 100%;
  border-color: var(--ambient-line);
  box-shadow: var(--ambient-shadow);
}

.featured-section .project-card img {
  aspect-ratio: 16 / 9;
}

.featured-section .project-card:first-child {
  grid-column: 1 / -1;
}

.featured-section .project-card:first-child .project-body {
  padding: clamp(1.5rem, 3vw, 2.75rem);
}

.project-card,
.cv-project-card {
  overflow: hidden;
}

.project-card img,
.cv-project-card img,
.featured-card-image img {
  background: linear-gradient(145deg, rgb(var(--accent-violet-rgb) / 0.08), rgb(var(--accent-cyan-rgb) / 0.05));
}

.project-card::before,
.cv-project-card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  z-index: 2;
  height: 2px;
  background: linear-gradient(90deg, var(--accent-violet), var(--accent-cyan));
  opacity: 0;
  transition: opacity var(--dur-normal) ease;
}

.project-card:is(:hover, :focus-within)::before,
.cv-project-card:is(:hover, :focus-within)::before {
  opacity: 0.85;
}

.project-card:is(:hover, :focus-within) {
  transform: translateY(-5px);
  border-color: var(--ambient-line);
  box-shadow: var(--ambient-shadow);
}

/* Gallery: stable stage, bounded rail and meaningful controls. */
.case-gallery {
  overflow: hidden;
}

.gallery-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: clamp(0.8rem, 2vw, 1.5rem);
}

.gallery-stage {
  position: relative;
  min-width: 0;
  overflow: hidden;
  border-color: var(--ambient-line);
  background: var(--surface-900);
}

.gallery-main-link {
  position: relative;
  display: grid;
  place-items: center;
  min-height: clamp(14rem, 52vw, 38rem);
  isolation: isolate;
  cursor: zoom-in;
}

.gallery-main-link::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background-image: var(--gallery-backdrop);
  background-position: center;
  background-size: cover;
  filter: blur(28px) saturate(115%);
  opacity: 0.22;
  transform: scale(1.08);
}

.gallery-main-link img {
  width: 100%;
  max-height: min(68vh, 46rem);
  aspect-ratio: 16 / 9;
  object-fit: contain;
  background: rgb(var(--surface-600-rgb) / 0.58);
}

.gallery-caption {
  align-items: center;
  background: var(--ambient-panel);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

.gallery-caption-copy {
  display: grid;
  gap: 0.2rem;
}

.gallery-caption-description {
  max-width: 68ch;
  color: var(--text-secondary) !important;
  font-family: var(--ff-body) !important;
  font-size: var(--fs-sm) !important;
  font-weight: 400 !important;
  letter-spacing: 0 !important;
  text-transform: none !important;
}

.gallery-thumbs {
  display: flex;
  gap: 0.7rem;
  min-width: 0;
  padding: 0.25rem 0.15rem 0.65rem;
  overflow-x: auto;
  overscroll-behavior-inline: contain;
  scroll-snap-type: x mandatory;
  scrollbar-width: thin;
}

.gallery-thumb {
  flex: 0 0 min(72vw, 14rem);
  grid-template-columns: 4rem minmax(0, 1fr);
  scroll-snap-align: start;
}

.gallery-thumb.is-active {
  box-shadow: inset 0 0 0 1px var(--accent-violet), 0 8px 24px rgb(var(--accent-violet-rgb) / 0.14);
}

.gallery-thumb-copy {
  min-width: 0;
  display: grid;
  gap: 0.15rem;
}

.gallery-thumb small {
  overflow: hidden;
  color: var(--text-muted);
  font-size: var(--fs-xs);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.gallery-controls {
  justify-content: flex-end;
}

.gallery-control[data-gallery-expand] {
  min-width: 2.75rem;
}

.gallery-dialog {
  width: min(96vw, 92rem);
  max-width: none;
  max-height: 94vh;
  padding: 0;
  overflow: hidden;
  border: 1px solid rgb(255 255 255 / 0.2);
  border-radius: var(--radius-xl);
  background: rgb(6 8 16 / 0.9);
  color: white;
  box-shadow: 0 36px 120px rgb(0 0 0 / 0.68);
  backdrop-filter: blur(28px) saturate(125%);
  -webkit-backdrop-filter: blur(28px) saturate(125%);
}

.gallery-dialog::backdrop {
  background: rgb(2 4 10 / 0.76);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

.gallery-dialog-inner {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  max-height: 94vh;
}

.gallery-dialog-bar,
.gallery-dialog-caption {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.8rem 1rem;
}

.gallery-dialog-bar {
  border-bottom: 1px solid rgb(255 255 255 / 0.12);
}

.gallery-dialog-caption {
  border-top: 1px solid rgb(255 255 255 / 0.12);
}

.gallery-dialog-stage {
  position: relative;
  min-height: 0;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.6rem;
  padding: 0.75rem;
}

.gallery-dialog-image {
  width: 100%;
  height: min(72vh, 52rem);
  object-fit: contain;
}

.gallery-dialog-button {
  min-width: 2.75rem;
  min-height: 2.75rem;
  padding: 0.55rem 0.8rem;
  border: 1px solid rgb(255 255 255 / 0.2);
  border-radius: 999px;
  background: rgb(255 255 255 / 0.08);
  color: white;
  font-weight: 800;
}

.gallery-dialog-button:hover,
.gallery-dialog-button:focus-visible {
  border-color: var(--accent-cyan);
  background: rgb(var(--accent-violet-rgb) / 0.36);
}

@media (min-width: 48rem) {
  .featured-section .featured-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .gallery-thumb {
    flex-basis: 15rem;
  }
}

@media (min-width: 64rem) {
  .nav-links a {
    padding: 8px 12px;
  }

  .featured-section .featured-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .projects-hero {
    grid-template-columns: minmax(0, 0.9fr) minmax(24rem, 1.1fr);
    align-items: center;
  }

  .projects-stats {
    grid-column: 1 / -1;
  }

  .featured-section .project-card:first-child {
    grid-template-columns: minmax(0, 1.16fr) minmax(20rem, 0.84fr);
  }

  .featured-section .project-card:first-child img {
    height: 100%;
    min-height: 24rem;
    border-right: 1px solid var(--border-subtle);
    border-bottom: 0;
  }

  .gallery-shell {
    grid-template-columns: minmax(0, 1fr) minmax(14rem, 18rem);
    align-items: stretch;
  }

  .gallery-thumbs {
    max-height: min(68vh, 46rem);
    padding: 0.15rem 0.45rem 0.15rem 0.15rem;
    flex-direction: column;
    overflow-x: hidden;
    overflow-y: auto;
    scroll-snap-type: y proximity;
  }

  .gallery-thumb {
    flex: 0 0 auto;
    width: 100%;
    scroll-snap-align: start;
  }
}

@media (max-width: 39.999rem) {
  .case-gallery {
    padding: 1rem;
  }

  .case-gallery-heading {
    margin-bottom: 1.25rem;
  }

  .gallery-controls {
    display: grid;
    grid-template-columns: 2.75rem minmax(0, 1fr) 2.75rem 2.75rem;
    width: 100%;
  }

  .gallery-main-link {
    min-height: 12rem;
  }

  .gallery-caption {
    align-items: flex-start;
    flex-direction: column;
  }

  .gallery-dialog-stage {
    grid-template-columns: 1fr;
  }

  .gallery-dialog-stage .gallery-dialog-button {
    position: absolute;
    top: 50%;
    z-index: 2;
  }

  .gallery-dialog-stage [data-dialog-prev] {
    left: 0.75rem;
  }

  .gallery-dialog-stage [data-dialog-next] {
    right: 0.75rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .project-card,
  .gallery-main-link img,
  .gallery-thumb {
    scroll-behavior: auto;
    transition: none !important;
  }
}
