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

html {
  height: 100%;
  scroll-behavior: smooth;
}

body {
  min-height: 100vh;
  min-height: 100svh;
  background: #000;
  color: #fff;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  -webkit-text-size-adjust: 100%;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

.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;
}

/* —— Header ——————————————————————————————————————————————— */

.bar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.7rem 1.5rem;
  padding-left: max(1.5rem, env(safe-area-inset-left));
  padding-right: max(1.5rem, env(safe-area-inset-right));
  padding-top: max(0.7rem, env(safe-area-inset-top));
  background: rgba(0, 0, 0, 0.88);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.bar__home {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  text-decoration: none;
  min-height: 44px;
  letter-spacing: 0.02em;
}

.bar__home:link,
.bar__home:visited {
  color: #fff;
}

.bar__home:hover,
.bar__home:focus-visible {
  color: #fff;
  text-decoration: underline;
}

.bar__mark {
  width: 28px;
  height: auto;
  display: block;
}

.bar__name {
  font-size: 0.92rem;
  font-weight: 400;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bar__here {
  font-size: 0.92rem;
  color: rgba(255, 255, 255, 0.55);
  letter-spacing: 0.04em;
}

/* —— Intro ———————————————————————————————————————————————— */

.intro {
  position: relative;
  isolation: isolate;
  max-width: 1280px;
  width: 100%;
  margin: 0 auto;
  padding: clamp(2.5rem, 6vw, 5rem) 1.5rem clamp(2rem, 4vw, 3.25rem);
  padding-left: max(1.5rem, env(safe-area-inset-left));
  padding-right: max(1.5rem, env(safe-area-inset-right));
  overflow: hidden;
}

.intro__portrait {
  display: none;
  position: absolute;
  z-index: 0;
  top: 0;
  right: max(-1.5rem, calc(env(safe-area-inset-right) * -1));
  bottom: 0;
  width: min(48%, 520px);
  pointer-events: none;
  user-select: none;
  opacity: 0.6;
  -webkit-mask-image:
    linear-gradient(to right, transparent 0%, rgba(0, 0, 0, 0.35) 22%, #000 48%, #000 78%, transparent 100%),
    linear-gradient(to bottom, transparent 0%, #000 12%, #000 88%, transparent 100%);
  mask-image:
    linear-gradient(to right, transparent 0%, rgba(0, 0, 0, 0.35) 22%, #000 48%, #000 78%, transparent 100%),
    linear-gradient(to bottom, transparent 0%, #000 12%, #000 88%, transparent 100%);
  -webkit-mask-composite: source-in;
  mask-composite: intersect;
}

.intro__portrait-img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 58% 18%;
  filter: brightness(0.78) contrast(1.05) saturate(0.92);
  animation: intro-portrait-float 14s ease-in-out infinite;
}

.intro__portrait-img--cars {
  object-position: 50% 22%;
}

.intro__portrait-img--machines {
  object-position: 42% 48%;
}

.intro__portrait-img--sound {
  object-position: 32% 22%;
}

.intro__portrait-img--spark {
  object-position: 42% 58%;
  filter: brightness(0.74) contrast(1.06);
}

.intro__portrait:has(.intro__portrait-img--spark) {
  display: block;
}

@media (max-width: 859px) {
  .intro__portrait:has(.intro__portrait-img--spark) {
    opacity: 0.38;
    width: min(70%, 360px);
  }
}

.intro__portrait--slot {
  background: radial-gradient(ellipse 72% 78% at 62% 36%, rgba(255, 255, 255, 0.05), transparent 70%);
}

@keyframes intro-portrait-float {
  0%,
  100% {
    transform: translate3d(0, 0, 0) scale(1.04);
  }
  50% {
    transform: translate3d(0, -1.4%, 0) scale(1.06);
  }
}

.intro__copy {
  position: relative;
  z-index: 1;
  max-width: 36rem;
}

.intro__title {
  font-size: clamp(2.1rem, 6vw, 3.6rem);
  font-weight: 400;
  letter-spacing: 0.04em;
  line-height: 1.15;
}

.intro__lede {
  margin-top: 0.85rem;
  color: rgba(255, 255, 255, 0.58);
  font-size: clamp(1.02rem, 2.1vw, 1.2rem);
  line-height: 1.55;
}

.intro__body {
  margin-top: 1rem;
  color: rgba(255, 255, 255, 0.48);
  font-size: clamp(0.95rem, 1.9vw, 1.05rem);
  line-height: 1.55;
}

.intro__body p + p {
  margin-top: 0.85rem;
}

.intro__body a {
  text-decoration: none;
  box-shadow: inset 0 -1px 0 rgba(255, 255, 255, 0.35);
}

.intro__body a:link,
.intro__body a:visited {
  color: rgba(255, 255, 255, 0.72);
}

.intro__body a:hover,
.intro__body a:focus-visible {
  color: #fff;
  box-shadow: inset 0 -1px 0 rgba(255, 255, 255, 0.9);
}

.intro__jump {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 1.25rem;
  margin-top: 1.6rem;
  font-size: 0.95rem;
  letter-spacing: 0.03em;
}

.intro__jump a {
  text-decoration: none;
  box-shadow: inset 0 -1px 0 rgba(255, 255, 255, 0.28);
  padding-bottom: 0.08em;
}

.intro__jump a:link,
.intro__jump a:visited {
  color: rgba(255, 255, 255, 0.72);
}

.intro__jump a:hover,
.intro__jump a:focus-visible {
  color: #fff;
  box-shadow: inset 0 -1px 0 rgba(255, 255, 255, 0.85);
}

@media (min-width: 860px) {
  .intro__portrait {
    display: block;
  }

  .intro__copy {
    max-width: min(36rem, 54%);
  }
}

@media (min-width: 1100px) {
  .intro__portrait {
    width: min(46%, 560px);
    opacity: 0.6;
  }

  .intro__copy {
    max-width: 36rem;
  }
}

/* Text-only motif on .intro__portrait--slot (ki/, code/). Drop .topic--text when a photo portrait lands. */

.topic--text .intro__portrait--slot {
  display: block;
}

.topic--text .intro__portrait--slot::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
}

/* Unrelated periods so the dots don't form a lattice. */
.topic--text.topic--ki .intro__portrait--slot::before {
  background-image:
    radial-gradient(circle at 50% 50%, rgba(255, 255, 255, 0.3) 0.7px, transparent 1.4px),
    radial-gradient(circle at 50% 50%, rgba(255, 255, 255, 0.18) 0.6px, transparent 1.3px),
    repeating-linear-gradient(to bottom, rgba(255, 255, 255, 0.1) 0 1px, transparent 1px 7px);
  background-size: 27px 27px, 43px 38px, 100% 7px;
  background-position: 0 0, 11px 17px, 0 0;
}

/* Same 27px rhythm as a rule grid; heavier column every fifth step. */
.topic--text.topic--code .intro__portrait--slot::before {
  background-image:
    repeating-linear-gradient(to right, rgba(255, 255, 255, 0.26) 0 1px, transparent 1px 135px),
    repeating-linear-gradient(to right, rgba(255, 255, 255, 0.12) 0 1px, transparent 1px 27px),
    repeating-linear-gradient(to bottom, rgba(255, 255, 255, 0.1) 0 1px, transparent 1px 27px);
}

@media (max-width: 720px) {
  .topic--text .intro__portrait--slot {
    left: max(-1.5rem, calc(env(safe-area-inset-left) * -1));
    width: auto;
    opacity: 0.4;
  }
}

/* —— Projects ————————————————————————————————————————————— */

.project {
  max-width: 1280px;
  width: 100%;
  margin: 0 auto;
  padding: 0 1.5rem 4.5rem;
  padding-left: max(1.5rem, env(safe-area-inset-left));
  padding-right: max(1.5rem, env(safe-area-inset-right));
  scroll-margin-top: 4.5rem;
}

.project__head {
  margin-bottom: 1.35rem;
}

.project__title {
  font-size: clamp(1.35rem, 3vw, 1.85rem);
  font-weight: 400;
  letter-spacing: 0.03em;
  line-height: 1.3;
}

.project__meta {
  margin-top: 0.4rem;
  color: rgba(255, 255, 255, 0.5);
  font-size: 0.95rem;
  line-height: 1.5;
}

.project__aside {
  margin: 2.25rem 0 0.85rem;
  color: rgba(255, 255, 255, 0.45);
  font-size: 0.8rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  scroll-margin-top: 4.5rem;
}

.mosaic {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.55rem;
}

.mosaic--drei {
  grid-template-columns: 1fr 1fr 1fr;
}

.shot {
  margin: 0;
  background: #111;
}

.shot--full {
  grid-column: 1 / -1;
}

.shot__link {
  display: block;
  color: inherit;
  line-height: 0;
}

.shot__link:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 3px;
}

.shot img {
  width: 100%;
  height: auto;
  display: block;
  cursor: zoom-in;
  transition: filter 0.25s ease;
}

.shot__link:hover img {
  filter: brightness(1.06);
}

.shot figcaption {
  padding: 0.55rem 0.1rem 0.15rem;
  color: rgba(255, 255, 255, 0.45);
  font-size: 0.78rem;
  letter-spacing: 0.03em;
  line-height: 1.4;
}

/* —— Dense thumbnail wall ————————————————————————————————— */
/* Declared after .mosaic--drei so dense columns win when both classes apply. */

.mosaic--dense {
  grid-template-columns: repeat(4, 1fr);
  grid-auto-flow: dense;
  gap: 0.4rem;
}

.mosaic--dense .shot {
  position: relative;
  overflow: hidden;
  isolation: isolate;
  aspect-ratio: 1 / 1;
  background: #111;
}

.mosaic--dense .shot--full {
  grid-column: span 2;
  grid-row: span 2;
}

.mosaic--dense .shot__link {
  position: absolute;
  inset: 0;
  line-height: 0;
}

.mosaic--dense .shot__link:focus-visible {
  outline-offset: -3px;
}

.mosaic--dense .shot img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.5s ease, filter 0.3s ease;
}

.mosaic--dense .shot:hover img,
.mosaic--dense .shot:focus-within img {
  transform: scale(1.07);
  filter: brightness(0.82);
}

.mosaic--dense .shot__mark {
  position: absolute;
  z-index: 2;
  top: 0.55rem;
  right: 0.55rem;
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(255, 255, 255, 0.55);
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.4);
  color: rgba(255, 255, 255, 0.9);
  opacity: 0.55;
  transform: scale(0.85);
  transition: opacity 0.3s ease, transform 0.3s ease;
  pointer-events: none;
}

.mosaic--dense .shot:hover .shot__mark,
.mosaic--dense .shot:focus-within .shot__mark {
  opacity: 1;
  transform: scale(1);
}

.mosaic--dense .shot figcaption {
  position: absolute;
  z-index: 1;
  left: 0;
  right: 0;
  bottom: 0;
  margin: 0;
  padding: 1.75rem 0.65rem 0.6rem;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.88), rgba(0, 0, 0, 0) 100%);
  color: rgba(255, 255, 255, 0.92);
  font-size: 0.76rem;
  letter-spacing: 0.02em;
  line-height: 1.35;
}

/* Touch: captions always visible. Fine pointer: reveal on hover/focus. */
@media (hover: hover) and (pointer: fine) {
  .mosaic--dense .shot figcaption {
    opacity: 0;
    transform: translateY(100%);
    transition: opacity 0.35s ease, transform 0.35s ease;
  }

  .mosaic--dense .shot:hover figcaption,
  .mosaic--dense .shot:focus-within figcaption {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 980px) {
  .mosaic--dense {
    grid-template-columns: repeat(3, 1fr);
  }
}

.closing {
  max-width: 1280px;
  width: 100%;
  margin: 0 auto;
  padding: 0 1.5rem 3rem;
  padding-left: max(1.5rem, env(safe-area-inset-left));
  padding-right: max(1.5rem, env(safe-area-inset-right));
  text-align: center;
}

.closing__note {
  color: rgba(255, 255, 255, 0.5);
  font-size: 1rem;
  line-height: 1.6;
  margin-bottom: 1rem;
}

.contact {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  font-size: 1.05rem;
  line-height: 1.5;
}

.contact__link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0.2rem 0.5rem;
  text-decoration: none;
  letter-spacing: 0.02em;
}

.contact__link:link,
.contact__link:visited {
  color: #fff;
}

.contact__link:hover,
.contact__link:focus-visible {
  color: #fff;
  text-decoration: underline;
}

.contact__fallback {
  color: rgba(255, 255, 255, 0.65);
}

.impressum {
  padding: 1.25rem 1.5rem;
  padding-bottom: max(1.25rem, env(safe-area-inset-bottom));
  text-align: center;
  font-size: 0.75rem;
  line-height: 1.6;
  color: rgba(255, 255, 255, 0.5);
}

.impressum__link {
  text-decoration: underline;
}

.impressum__link:link,
.impressum__link:visited {
  color: rgba(255, 255, 255, 0.5);
}

.impressum__link:hover,
.impressum__link:focus-visible {
  color: rgba(255, 255, 255, 0.8);
}

.impressum__copy {
  margin-top: 0.15rem;
}

/* —— Lightbox ————————————————————————————————————————————— */

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.96);
  padding: 3.5rem 3.5rem 4rem;
}

.lightbox[hidden] {
  display: none;
}

.lightbox__img {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.06);
}

.lightbox__close,
.lightbox__prev,
.lightbox__next {
  position: absolute;
  background: transparent;
  border: 0;
  color: rgba(255, 255, 255, 0.85);
  cursor: pointer;
  font-size: 1.8rem;
  line-height: 1;
  min-width: 44px;
  min-height: 44px;
}

.lightbox__close {
  top: 0.4rem;
  right: 0.6rem;
  font-size: 2rem;
}

.lightbox__prev,
.lightbox__next {
  top: 50%;
  transform: translateY(-50%);
  font-size: 2.4rem;
  padding: 0.4rem;
}

.lightbox__prev {
  left: 0.35rem;
}

.lightbox__next {
  right: 0.35rem;
}

.lightbox__close:hover,
.lightbox__prev:hover,
.lightbox__next:hover,
.lightbox__close:focus-visible,
.lightbox__prev:focus-visible,
.lightbox__next:focus-visible {
  color: #fff;
}

.lightbox__meta {
  position: absolute;
  bottom: 0.85rem;
  left: 0;
  right: 0;
  text-align: center;
  color: rgba(255, 255, 255, 0.5);
  font-size: 0.8rem;
  letter-spacing: 0.04em;
}

body.lightbox-open {
  overflow: hidden;
}

@media (max-width: 720px) {
  .bar__name {
    max-width: 11rem;
  }

  .intro {
    padding-top: clamp(1.75rem, 5vw, 3rem);
  }

  .intro__jump {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
  }

  .mosaic,
  .mosaic--drei {
    grid-template-columns: 1fr;
    gap: 0.4rem;
  }

  .mosaic--dense {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.3rem;
  }

  .project {
    padding-bottom: 3rem;
  }

  .lightbox {
    padding: 3.25rem 0.75rem 3.5rem;
  }

  .lightbox__prev,
  .lightbox__next {
    top: auto;
    bottom: 0.15rem;
    transform: none;
    font-size: 2rem;
  }

  .lightbox__prev {
    left: 0.5rem;
  }

  .lightbox__next {
    right: 0.5rem;
  }

  .lightbox__meta {
    bottom: 2.6rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  .intro__portrait-img {
    animation: none;
    transform: scale(1.04);
  }

  .shot__link:hover img {
    filter: none;
  }

  .mosaic--dense .shot:hover img,
  .mosaic--dense .shot:focus-within img {
    transform: none;
    filter: none;
  }
}
