/* Divisions page: four cards that stack as they are scrolled, then what each division is working on. */

.stack {
  padding: 0 var(--gutter) var(--section-space);
}

.stack-anchor {
  display: block;
  height: 0;
}

.division {
  position: relative;
  display: grid;
  overflow: hidden;
  max-width: 1280px;
  grid-template-columns: minmax(0, 5fr) minmax(0, 7fr);
  margin: 0 0 28px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  /* opaque, because stacked cards sit directly on top of each other */
  background: linear-gradient(160deg, #1c0a3a, #0c0619 70%);
  transition: border-color 0.4s;
}

.division:hover {
  border-color: rgba(201, 167, 255, 0.5);
}

/*
 * motion.js adds .is-stacked when every card fits the viewport, and runs --cover from 0 to 1
 * while the next card slides over this one. Offsets: keep in sync with STACK_TOP / STACK_STEP.
 */
.stack.is-stacked .division {
  position: sticky;
  top: calc(88px + var(--i) * 12px);
  transform: scale(calc(1 - var(--cover, 0) * 0.07));
  transform-origin: 50% 0;
}

.division::after {
  position: absolute;
  inset: 0;
  background: var(--bg);
  content: "";
  opacity: 0;
  pointer-events: none;
}

.stack.is-stacked .division::after {
  opacity: calc(var(--cover, 0) * 0.6);
}

.division-photo {
  position: relative;
  overflow: hidden;
  min-height: 280px;
  margin: 0;
}

.division-photo img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  filter: saturate(0.92) contrast(1.04);
  object-fit: cover;
  transition: transform 1.1s var(--ease);
}

.division-photo::after {
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(116, 21, 201, 0.35), transparent 62%);
  content: "";
}

.division:hover .division-photo img {
  transform: scale(1.05);
}

/* photos alternate sides */
.division:nth-of-type(even) {
  grid-template-columns: minmax(0, 7fr) minmax(0, 5fr);
}

.division:nth-of-type(even) .division-photo {
  order: 2;
}

.division-body {
  display: grid;
  align-content: center;
  justify-items: start;
  gap: 16px;
  padding: clamp(28px, 3.2vw, 44px);
}

.division h2 {
  font-size: clamp(1.7rem, 2.8vw, 2.6rem);
}

.division-body p {
  max-width: 68ch;
  color: rgba(246, 240, 255, 0.82);
}

/* each division in three lines; the marker carries the division's colour */
.division-points {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  color: rgba(246, 240, 255, 0.86);
  list-style: none;
}

.division-points li {
  position: relative;
  padding-left: 20px;
}

.division-points li::before {
  position: absolute;
  top: 0.62em;
  left: 0;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--c, var(--lilac));
  content: "";
}

.division-body .division-for {
  width: 100%;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  color: var(--mute);
}

.division-for strong {
  color: var(--c, var(--lilac));
  font-weight: 500;
}

.division-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 28px;
}

/* ---------- what we are working on: the title stays pinned while its projects scroll ---------- */

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

.project-lead {
  position: sticky;
  top: 110px;
  display: grid;
  align-self: start;
  justify-items: start;
  gap: 12px;
}

.project-lead h3 {
  font-size: clamp(1.5rem, 2.4vw, 2.2rem);
}

.project-lead p {
  max-width: 32ch;
  color: var(--mute);
  font-size: 0.95rem;
}

.project-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.project {
  padding: 22px 0;
  border-top: 1px solid var(--line);
}

.project:first-child {
  padding-top: 0;
  border-top: 0;
}

.project h4 {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  margin: 0 0 6px;
  font-size: clamp(1.1rem, 1.5vw, 1.35rem);
  font-weight: var(--display-weight);
  line-height: 1.3;
}

.project p {
  max-width: 62ch;
  color: var(--mute);
}

.flag {
  padding: 3px 10px;
  border: 1px solid var(--c, var(--lilac));
  border-radius: 999px;
  color: var(--c, var(--lilac));
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

@media (max-width: 800px) {
  .project-lead {
    position: static;
  }
}

@media (max-width: 900px) {
  .division,
  .division:nth-of-type(even) {
    grid-template-columns: minmax(0, 1fr);
  }

  .division:nth-of-type(even) .division-photo {
    order: 0;
  }

  .division-photo {
    min-height: 0;
    aspect-ratio: 16 / 9;
  }
}
