/* Progetti page */
.progetti-page {
  background: #121212;
}

/* Hero */
.progetti-hero {
  background: #121212;
  flex-direction: column;
  align-items: stretch;
  padding: 8rem 1rem 0;
  height: auto;
  margin-bottom: 10rem;
}

.progetti-hero__header {
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

.progetti-hero__title {
  font-size: clamp(3rem, 7vw, 8rem);
  line-height: 0.9;
  text-align: left;
  display: flex;
  flex-direction: column;
}

.progetti-hero__title-line {
  display: block;
}

.progetti-hero__info {
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

.progetti-hero__text {
  font-size: clamp(1rem, 1vw + 0.5rem, 1.25rem);
  line-height: 1.5;
  font-weight: 500;
  text-wrap: balance;
}

/* ═══ Project Detail ═══ */
.progetto-detail {
  background: #121212;
  height: auto;
  padding: 0 1rem;
  margin-bottom: 10rem;
  flex-direction: column;
  align-items: stretch;
}

.progetto-detail__title {
  font-size: clamp(3rem, 7vw, 8rem);
  line-height: 0.9;
  text-align: left;
  display: flex;
  flex-direction: column;
  margin-bottom: 2rem;
}

.progetto-detail__title-line {
  display: block;
}

/* Carousel */
.progetto-detail__carousel {
  overflow: hidden;
  margin-bottom: 2rem;
}

.progetto-detail__carousel-track {
  display: flex;
  gap: 1rem;
  will-change: transform;
}

.progetto-detail__carousel-img {
  width: 80%;
  flex-shrink: 0;
  border-radius: 16px;
  aspect-ratio: 16 / 9;
  background-size: 115% auto;
  background-position: 50% 50%;
  background-repeat: no-repeat;
}

/* Content: label row + text/buttons row */
.progetto-detail__content {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.progetto-detail__label {
  font-size: clamp(1.5rem, 4vw, 4rem);
  line-height: 1.5;
  font-weight: 500;
  color: #FF6F00;
}

.progetto-detail__row {
  display: flex;
  flex-direction: column;
  gap: 2rem;
  align-items: flex-start;
  justify-content: space-between;
}

.progetto-detail__text {
  font-size: clamp(1rem, 1vw + 0.5rem, 1.25rem);
  line-height: 1.5;
  font-weight: 500;
  color: #e3e3e3;
  max-width: 70ch;
}

.progetto-detail__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.progetto-detail__btn {
  text-decoration: none;
  display: inline-block;
}

.progetto-detail__btn--expand {
  background: rgba(227, 227, 227, 0.3);
  color: #e3e3e3;
}

/* Hero variant without top padding */
.progetti-hero--no-pt {
  padding-top: 0 !important;
}

/* Extra content block (second row under a project) */
.progetto-detail__content--extra {
  margin-top: 2rem;
}

/* Two-column layout (e.g. "Cosa farà" + "Stack previsto") */
.progetto-detail__columns {
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

.progetto-detail__col {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

/* ═══ Dal lavoro quotidiano ═══ */
.progetto-lavoro {
  background: #121212;
  height: auto;
  padding: 0 1rem;
  margin-bottom: 10rem;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
}

.progetto-lavoro__header {
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

.progetto-lavoro__title {
  font-size: clamp(3rem, 7vw, 8rem);
  line-height: 0.9;
  text-align: left;
  display: flex;
  flex-direction: column;
}

.progetto-lavoro__title-line {
  display: block;
}

.progetto-lavoro__text {
  font-size: clamp(1rem, 1vw + 0.5rem, 1.25rem);
  line-height: 1.5;
  font-weight: 500;
  color: #e3e3e3;
  max-width: 70ch;
}

.progetto-lavoro__accordion {
  display: flex;
  flex-direction: column;
  margin-top: 2rem;
}

.progetto-lavoro__item {
  padding: 0;
  overflow: hidden;
}

.progetto-lavoro__item-inner {
  height: 100%;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  justify-content: flex-start;
  padding: 5rem 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.3);
}

.progetto-lavoro__label {
  font-size: clamp(1.5rem, 4vw, 4rem);
  line-height: 1;
  font-weight: 500;
  color: #FF6F00;
  text-align: left;
}

.progetto-lavoro__item-text {
  font-size: clamp(1rem, 1vw + 0.5rem, 1.25rem);
  line-height: 1.5;
  font-weight: 500;
  color: #e3e3e3;
  text-align: left;
  text-wrap: balance;
}

/* ===== DESKTOP ===== */
@media (min-width: 768px) {
  .progetti-hero {
    padding: 8rem 32px 0;
    margin-bottom: 16rem;
  }

  .progetti-hero__header {
    display: grid;
    grid-template-columns: auto 1fr;
    align-items: end;
    gap: 4rem;
  }

  .progetti-hero__title {
    grid-column: 1;
    white-space: nowrap;
  }

  .progetti-hero__info {
    grid-column: 2;
  }

  .progetto-detail {
    padding: 0 32px;
    margin-bottom: 16rem;
  }

  .progetto-detail__title {
    margin-bottom: 4rem;
  }

  .progetto-detail__carousel {
    margin-bottom: 4rem;
  }

  .progetto-detail__carousel-img {
    width: 60%;
  }

  .progetto-detail__row {
    flex-direction: row;
    gap: 4rem;
    align-items: flex-start;
  }

  .progetto-detail__text {
    flex: 1;
  }

  .progetto-detail__actions {
    flex-shrink: 0;
  }

  .progetto-lavoro {
    padding: 0 32px;
    margin-bottom: 16rem;
  }

  .progetto-lavoro__accordion {
    margin-top: 4rem;
  }

  .progetto-lavoro__item-inner {
    padding: 4rem 0;
  }

  .progetto-detail__columns {
    flex-direction: row;
    gap: 4rem;
    align-items: flex-start;
  }

  .progetto-detail__col:first-child {
    flex: 1;
  }

  .progetto-detail__col:last-child {
    flex-shrink: 0;
  }
}

/* ═══ Expand Overlay ═══ */
.expand-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 10000;
  background: rgba(0, 0, 0, 0);
  backdrop-filter: blur(0px);
  -webkit-backdrop-filter: blur(0px);
  overflow-y: auto;
  overflow-x: hidden;
}

.expand-overlay.active {
  display: block;
}

.expand-overlay__header {
  display: none;
  position: fixed;
  top: 0;
  right: 0;
  padding: 1rem;
  z-index: 10001;
}

.expand-overlay__header.active {
  display: block;
}

.expand-overlay__close {
  font-family: "Inter", sans-serif;
  font-weight: 500;
  font-size: clamp(1rem, 1vw + 0.5rem, 1.25rem);
  color: #e3e3e3;
  cursor: pointer;
  transition: opacity 0.3s;
}

.expand-overlay__close:hover {
  opacity: 0.6;
}

.expand-overlay__content {
  padding: 6rem 1rem 100vh;
  color: #e3e3e3;
  font-family: "Inter", sans-serif;
  font-size: clamp(1rem, 1vw + 0.5rem, 1.25rem);
  line-height: 1.6;
  font-weight: 500;
}

@media (min-width: 768px) {
  .expand-overlay__header {
    padding: 2rem;
  }

  .expand-overlay__content {
    padding: 6rem 2rem 100vh;
  }
}

/* ═══ Expand Overlay Content Sections ═══ */
.expand-section {
  margin-bottom: 10rem;
}

.expand-section__title {
  font-size: clamp(3rem, 7vw, 8rem);
  line-height: 0.9;
  margin-bottom: 2rem;
}

.expand-section__rows {
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

.expand-section__row {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.expand-section__label {
  font-size: clamp(1.5rem, 4vw, 4rem);
  line-height: 1;
  font-weight: 500;
  color: #FF6F00;
}

.expand-section__text {
  font-size: clamp(1rem, 1vw + 0.5rem, 1.25rem);
  line-height: 1.5;
  font-weight: 500;
  color: #e3e3e3;
  max-width: 70ch;
}

/* Stats row: label left, value right */
.expand-section__row--stats {
  flex-direction: row;
  align-items: baseline;
  justify-content: space-between;
  border-bottom: 1px solid rgba(255, 255, 255, 0.3);
  padding-bottom: 1rem;
}

.expand-section__value {
  font-size: clamp(1.5rem, 2vw, 4rem);
  line-height: 1.5;
  font-weight: 500;
  color: #e3e3e3;
  flex-shrink: 0;
}

/* 3-column flow layout */
.expand-section__flow {
  display: flex;
  flex-direction: column;
  gap: 2rem;
  margin-top: 2rem;
}

/* Mobile: each flow-col is a row with vertical arrow on the left */
.expand-section__flow-col {
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-rows: auto auto;
  gap: 0 1rem;
}

.expand-section__flow-top {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  grid-column: 2;
  grid-row: 1;
}

.expand-section__flow-top > .expand-section__label {
  margin-bottom: 0.5rem;
}

.expand-section__flow-top .expand-section__flow-lines {
  display: flex;
  flex-direction: row;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.expand-section__flow-line {
  font-size: clamp(1rem, 1vw + 0.5rem, 1.25rem);
  line-height: 1.2;
  font-weight: 500;
  color: #e3e3e3;
}

/* Mobile: vertical arrow on the left */
.expand-section__flow-arrow {
  position: relative;
  width: 1px;
  height: 100%;
  min-height: 40px;
  background: transparent;
  background-image: linear-gradient(to bottom, #e3e3e3 0%, #e3e3e3 0%, transparent 0%);
  grid-column: 1;
  grid-row: 1 / -1;
  justify-self: center;
  --tip-opacity: 0;
}

/* Mobile: arrow tip at bottom */
.expand-section__flow-arrow::before,
.expand-section__flow-arrow::after {
  content: "";
  display: block;
  position: absolute;
  bottom: 0;
  left: 50%;
  width: 8px;
  height: 1px;
  background: #e3e3e3;
  opacity: var(--tip-opacity);
  transition: opacity 0.2s;
}

.expand-section__flow-arrow::before {
  transform-origin: 100% 50%;
  transform: translateX(-100%) rotate(45deg);
}

.expand-section__flow-arrow::after {
  transform-origin: 0% 50%;
  transform: rotate(-45deg);
}

/* ═══ Pipeline layout (shared-errors popup) ═══ */
/* Mobile: grid with vertical arrow left, steps right */
.expand-pipeline {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0 1rem;
  margin-top: 2rem;
}

.expand-pipeline__steps {
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

.expand-pipeline__row {
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

.expand-pipeline__col {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

/* Mobile: single vertical arrow on the left spanning all rows */
.expand-pipeline__arrow--mobile {
  position: relative;
  width: 1px;
  grid-row: 1 / -1;
  background: transparent;
  background-image: linear-gradient(to bottom, #e3e3e3 0%, #e3e3e3 0%, transparent 0%);
  justify-self: center;
  --tip-opacity: 0;
}

.expand-pipeline__arrow--mobile::before,
.expand-pipeline__arrow--mobile::after {
  content: "";
  display: block;
  position: absolute;
  bottom: 0;
  left: 50%;
  width: 8px;
  height: 1px;
  background: #e3e3e3;
  opacity: var(--tip-opacity);
  transition: opacity 0.2s;
}

.expand-pipeline__arrow--mobile::before {
  transform-origin: 100% 50%;
  transform: translateX(-100%) rotate(45deg);
}

.expand-pipeline__arrow--mobile::after {
  transform-origin: 0% 50%;
  transform: rotate(-45deg);
}

/* Desktop arrows hidden on mobile */
.expand-pipeline__arrow--desktop {
  display: none;
}

/* ═══ Expand accordion (shared-errors section 3) ═══ */
/* Mobile: label above text, sequential vertical */
.expand-section__accordion {
  display: flex;
  flex-direction: column;
}

.expand-section__accordion-item {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding: 2rem 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.3);
  overflow: hidden;
}

.expand-section__accordion-item .expand-section__text {
  margin-bottom: 0;
}

/* 2x2 grid accordion — mobile: 1 column, sequential */
.expand-section__grid {
  display: flex;
  flex-direction: column;
}

.expand-section__grid-item {
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  gap: 2rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.3);
  padding: 2rem 0;
  overflow: hidden;
}

.expand-section__grid-item .expand-section__text {
  margin-bottom: 0;
}

@media (min-width: 768px) {
  .expand-section {
    margin-bottom: 16rem;
  }

  .expand-section__title {
    margin-bottom: 4rem;
  }

  .expand-section__rows {
    gap: 3rem;
  }

  .expand-section__row--stats {
    padding-bottom: 2rem;
  }

  .expand-section__flow {
    flex-direction: row;
    gap: 4rem;
    margin-top: 4rem;
  }

  .expand-section__flow-col {
    flex: 1;
    display: flex;
    flex-direction: column;
  }

  /* Desktop: arrow after content (reverse the mobile order) */
  .expand-section__flow-arrow {
    order: 2;
  }

  .expand-section__flow-top {
    order: 1;
  }

  .expand-section__flow-top {
    gap: 1rem;
    margin-bottom: 2rem;
  }

  .expand-section__flow-top > .expand-section__label {
    margin-bottom: 1rem;
  }

  .expand-section__flow-top .expand-section__flow-lines {
    flex-direction: column;
    gap: 1rem;
  }

  /* Desktop: horizontal arrow at the bottom */
  .expand-section__flow-arrow {
    width: 100%;
    height: 1px;
    min-height: auto;
    margin-top: auto;
    margin-bottom: 0.5rem;
    background-image: linear-gradient(to right, #e3e3e3 0%, #e3e3e3 0%, transparent 0%);
    grid-column: unset;
    grid-row: unset;
    justify-self: unset;
  }

  .expand-section__flow-arrow::before,
  .expand-section__flow-arrow::after {
    bottom: auto;
    left: auto;
    right: 0;
    top: 50%;
  }

  .expand-section__flow-arrow::before {
    transform-origin: 100% 50%;
    transform: rotate(40deg);
  }

  .expand-section__flow-arrow::after {
    transform-origin: 100% 50%;
    transform: rotate(-40deg);
  }

  /* Pipeline desktop */
  .expand-pipeline {
    display: block;
    margin-top: 4rem;
  }

  .expand-pipeline__arrow--mobile {
    display: none;
  }

  .expand-pipeline__steps {
    gap: 4rem;
  }

  .expand-pipeline__row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: 1fr auto;
    gap: 2rem;
  }

  .expand-pipeline__col {
    gap: 2rem;
  }

  /* Desktop: horizontal arrows visible */
  .expand-pipeline__arrow--desktop {
    display: block;
    position: relative;
    width: 100%;
    height: 1px;
    grid-column: 1 / -1;
    grid-row: 2;
    background: transparent;
    background-image: linear-gradient(to right, #e3e3e3 0%, #e3e3e3 0%, transparent 0%);
    --tip-opacity: 0;
  }

  .expand-pipeline__arrow--desktop::before,
  .expand-pipeline__arrow--desktop::after {
    content: "";
    display: block;
    position: absolute;
    right: 0;
    top: 50%;
    width: 8px;
    height: 1px;
    background: #e3e3e3;
    opacity: var(--tip-opacity);
    transition: opacity 0.2s;
  }

  .expand-pipeline__arrow--desktop::before {
    transform-origin: 100% 50%;
    transform: rotate(40deg);
  }

  .expand-pipeline__arrow--desktop::after {
    transform-origin: 100% 50%;
    transform: rotate(-40deg);
  }

  .expand-pipeline__arrow--desktop.expand-pipeline__arrow--no-tip::before,
  .expand-pipeline__arrow--desktop.expand-pipeline__arrow--no-tip::after {
    display: none;
  }

  /* Expand accordion desktop: label left (bottom-aligned), text right */
  .expand-section__accordion-item {
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    align-items: flex-end;
    gap: 2rem;
    padding: 2rem 0;
  }

  .expand-section__accordion-item .expand-section__label {
    flex-shrink: 0;
  }

  .expand-section__accordion-item .expand-section__text {
    text-align: right;
  }

  .expand-section__grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    column-gap: 4rem;
    row-gap: 0;
    align-content: start;
  }

  .expand-section__grid-item {
    gap: 4rem;
    padding: 2rem 0;
  }
}
