/* Projects – Figma "02 Projects" (318:1693) */

/* ---------- Highlights: sticky text + tile stack (Figma 731:10724) ---------- */

.highlights {
  display: flex;
  gap: var(--space-128);
  align-items: flex-start;
  padding: var(--layout-section) max(var(--layout-margin), (100% - var(--layout-content)) / 2);
  background: var(--color-surface-warm);
}

.highlights__text {
  position: sticky;
  top: calc(var(--header-height) + var(--space-48));
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: var(--space-32);
  align-items: flex-start;
}

.highlights__text .text-lead {
  color: var(--color-text-secondary);
}

/* --scale: 1.2 on wide screens (Leoš: tiles were too small), 1 on small desktops */
.tile-stack {
  --scale: 1;
  position: relative;
  flex-shrink: 0;
  width: calc(600px * var(--scale));
  height: calc(1060px * var(--scale));
}

/* small desktops: a bit smaller so the zig-zag stays inside the viewport */
@media (min-width: 1024px) and (max-width: 1279px) {
  .highlights {
    gap: var(--space-64);
  }

  .tile-stack {
    --scale: 0.85;
  }
}

@media (min-width: 1440px) {
  .highlights {
    gap: var(--space-96);
  }

  /* bleeds 72px into the right page margin so the headline keeps its width */
  .tile-stack {
    --scale: 1.2;
    margin-right: -72px;
  }
}

/* narrower tiles (480 of 600), zig-zag offsets, rotations from Figma */
.tile-stack__item {
  container-type: inline-size;
  --rotate: 0deg;
  --x: 0px;
  --shift: 0px;
  position: absolute;
  left: 0;
  width: calc(480px * var(--scale));
  rotate: var(--rotate);
  translate: var(--x) var(--shift);
  transition: rotate 0.7s var(--ease-calm), translate 0.7s var(--ease-calm), scale 0.7s var(--ease-calm);
}

.tile-stack__item:nth-child(1) { top: calc(0px * var(--scale)); --x: calc(0px * var(--scale)); --rotate: 2.5deg; }
.tile-stack__item:nth-child(2) { top: calc(140px * var(--scale)); --x: calc(120px * var(--scale)); --rotate: -2deg; }
.tile-stack__item:nth-child(3) { top: calc(280px * var(--scale)); --x: calc(24px * var(--scale)); --rotate: 1.5deg; }
.tile-stack__item:nth-child(4) { top: calc(420px * var(--scale)); --x: calc(104px * var(--scale)); --rotate: -2.5deg; }
.tile-stack__item:nth-child(5) { top: calc(560px * var(--scale)); --x: calc(8px * var(--scale)); --rotate: 2deg; }
.tile-stack__item:nth-child(6) { top: calc(700px * var(--scale)); --x: calc(120px * var(--scale)); --rotate: -1.5deg; }
.tile-stack__item:nth-child(7) { top: calc(840px * var(--scale)); --x: calc(24px * var(--scale)); --rotate: 2deg; }

@media (hover: hover) {
  /* like "Entdecken": straightens, lifts, 105 %, comes to the front */
  .tile-stack__item:hover,
  .tile-stack__item:focus-within {
    z-index: 10;
    rotate: 0deg;
    translate: var(--x) calc(var(--shift) - 16px);
    scale: 1.03;
  }

  /* neighbours make room: 28px away, 2° more tilt */
  .tile-stack__item:has(+ .tile-stack__item:hover) {
    --shift: -20px;
    rotate: calc(var(--rotate) - 2deg);
  }

  .tile-stack__item:hover + .tile-stack__item {
    --shift: 20px;
    rotate: calc(var(--rotate) + 2deg);
  }
}

/* ---------- Archive (Figma 731:11051) ---------- */

.archive {
  display: flex;
  flex-direction: column;
  gap: var(--space-48);
}

.archive__filter {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-8);
}

/* Pill Type=Filter: raised → hover linen, active moor black */
.filter-pill {
  height: 30px;
  padding-inline: var(--space-16);
  border-radius: var(--radius-pill);
  background: var(--color-surface-raised);
  color: var(--color-text-secondary);
  font-size: var(--font-size-small);
  font-weight: var(--font-weight-semibold);
  letter-spacing: var(--letter-spacing-small);
  transition: background-color 0.2s ease, color 0.2s ease;
}

.filter-pill:hover {
  background: var(--color-surface-warm);
}

.filter-pill[aria-pressed="true"] {
  background: var(--color-fixed-dark);
  color: var(--color-fixed-light);
}

/* two columns while a card keeps at least 420px (desktop), otherwise one, so the text never squeezes */
.archive__list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 420px), 1fr));
  gap: var(--space-24);
}

.archive__item[hidden] {
  display: none;
}

/* Project / Tile / List (Figma 179:298): hover shows the project colors */
.list-tile {
  display: flex;
  gap: var(--space-32);
  align-items: center;
  height: 100%;
  padding: var(--space-16);
  border-radius: var(--radius-24);
  background: var(--color-surface-raised);
  color: var(--color-text-primary);
  transition: background-color 0.5s ease, color 0.5s ease, scale 0.7s var(--ease-calm), box-shadow 0.7s var(--ease-calm);
}

.list-tile__image {
  flex-shrink: 0;
  width: 112px;
  height: 112px;
  overflow: hidden;
  border-radius: var(--radius-16);
}

.list-tile__image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.list-tile__text {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: var(--space-8);
  min-width: 0;
}

.list-tile__lead {
  color: var(--color-text-tertiary);
}

.list-tile__pills {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-8);
}

.pill--list {
  height: 24px;
  background: var(--color-surface-base);
  color: var(--color-text-secondary);
}

.pill--more {
  display: none;
}

@media (hover: hover) {
  .list-tile:hover {
    position: relative;
    z-index: 1;
    background: var(--project-surface, var(--color-surface-warm));
    color: var(--project-text, var(--color-text-primary));
    box-shadow: var(--shadow-button-hover);
    scale: 1.02;
  }

  .list-tile:hover .list-tile__lead {
    color: inherit;
  }

  .list-tile .pill--list {
    transition: background-color 0.5s ease, color 0.5s ease;
  }

  .list-tile:hover .pill--list {
    background: var(--project-text);
    color: var(--project-surface);
  }
}

.archive__more {
  display: flex;
  justify-content: center;
}

/* Mehr zeigen / Weniger anzeigen: chevron turns up when expanded */
.archive__chevron {
  width: 16px;
  height: 10px;
  transition: rotate 0.35s var(--ease-out-soft);
}

.archive__toggle.is-expanded .archive__chevron {
  rotate: 180deg;
}

/* revealed tiles slide in one after another */
@keyframes archive-enter {
  from {
    opacity: 0;
    translate: 0 32px;
    scale: 0.97;
  }
}

.archive__item.is-entering {
  animation: archive-enter 0.7s var(--ease-out-soft) var(--enter-delay, 0ms) both;
}

/* closing: extra tiles fade out while the list height shrinks */
.archive__item.is-leaving {
  opacity: 0;
  translate: 0 16px;
  transition: opacity 0.35s ease, translate 0.5s var(--ease-out-soft);
}

/* while the height animates, clip the content (with room for hover shadows) */
.archive__list.is-resizing {
  overflow: clip;
  overflow-clip-margin: var(--space-24);
}

@media (prefers-reduced-motion: reduce) {
  .archive__chevron {
    transition: none;
  }

  .archive__item.is-entering {
    animation: none;
  }
}

/* ---------- Tablet / mobile ---------- */

.highlights__deck {
  display: contents;
}

@media (max-width: 1023px) {
  .highlights {
    flex-direction: column;
    gap: var(--space-64);
  }

  .highlights__text {
    position: static;
  }

  /* Card index (mobile): each card pins below the header and the next one slides over it */
  .highlights__deck {
    display: block;
    width: 100%;
  }

  .tile-stack {
    display: flex;
    flex-direction: column;
    gap: var(--space-24);
    width: 100%;
    max-width: 560px;
    height: auto;
    margin-inline: auto;
    padding-bottom: 0;
  }

  .tile-stack__item,
  .tile-stack__item:nth-child(n) {
    --x: 0px;
    position: sticky;
    left: auto;
    width: 100%;
    rotate: var(--rotate);
    translate: none;
  }

  .tile-stack__item:nth-child(1) { top: calc(var(--header-height) + 8px);  --rotate: -2deg; }
  .tile-stack__item:nth-child(2) { top: calc(var(--header-height) + 20px); --rotate: 1.5deg; }
  .tile-stack__item:nth-child(3) { top: calc(var(--header-height) + 32px); --rotate: -1deg; }
  .tile-stack__item:nth-child(4) { top: calc(var(--header-height) + 44px); --rotate: 2deg; }
  .tile-stack__item:nth-child(5) { top: calc(var(--header-height) + 56px); --rotate: -1.5deg; }
  .tile-stack__item:nth-child(6) { top: calc(var(--header-height) + 68px); --rotate: 1deg; }
  .tile-stack__item:nth-child(7) { top: calc(var(--header-height) + 80px); --rotate: -2deg; }
}

/* phones: two columns of small stacked tiles (image on top), so the archive reads lighter than the
   case tiles above; thin frame like all case tiles on phones */
@media (max-width: 600px) {
  .archive__list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--space-8);
  }

  .list-tile {
    flex-direction: column;
    gap: var(--space-8);
    align-items: stretch;
    padding: var(--space-8);
    border-radius: var(--radius-16);
  }

  .list-tile__image {
    width: 100%;
    height: auto;
    aspect-ratio: 4 / 3;
    border-radius: var(--radius-8);
  }

  .list-tile__text {
    gap: var(--space-4);
    padding: 0 var(--space-4) var(--space-4);
  }

  .list-tile__title.text-h3 {
    font-size: 1.125rem;
    line-height: 1.15;
  }

  .list-tile__lead {
    font-size: 0.8125rem;
  }

  .list-tile__pills {
    gap: var(--space-4);
    margin-top: var(--space-4);
  }

  /* the first pill shortens with "…" instead of pushing "+N" out of the narrow tile */
  .list-tile .pill--list {
    height: 20px;
    padding-inline: var(--space-8);
    font-size: 0.75rem;
  }

  .list-tile .pill--list:first-child {
    display: block;
    min-width: 0;
    overflow: hidden;
    line-height: 20px;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .list-tile .pill--more {
    flex-shrink: 0;
  }

  /* first discipline + "+N" only, lead clamped to 2 lines */
  .list-tile__pills {
    flex-wrap: nowrap;
  }

  .list-tile__pills .pill--list:not(:first-child):not(.pill--more) {
    display: none;
  }

  .pill--more {
    display: inline-flex;
  }

  .list-tile__lead {
    display: -webkit-box;
    overflow: hidden;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
  }
}
