/* =========================
   PAGINE SINGOLO PROGETTO (V2)
   Coerente con style.css
   - Sidebar sticky desktop
   - TOC mobile in alto (non nel testo)
   - Hero cover + centro verticale
   - Lightbox robusta
   ========================= */

.project-page{
  background: #fff;
  color: var(--color-text, #111);
}

/* wrapper */
.project-wrap{
  max-width: 1200px;
  margin: 0 auto;
  padding-inline: var(--page-pad);
}

/* Offset ancore: evita che i titoli finiscano sotto header */
.project-page .project-section{
  scroll-margin-top: calc(var(--header-h, 72px) + 18px);
}

/* =========================
   HERO
   ========================= */

.project-hero{
  padding: 0;
  background: #fff;
  border-bottom: 3px solid #000;
}

.project-hero__media{
  margin: 0;
  overflow: hidden;
  background: #f4f4f4;
  border-radius: 0;
  height: clamp(260px, 38vw, 520px); /* altezza stabile hero */
}

.project-hero__media img{
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  object-position: center center; /* centro verticale + orizzontale */
}

/* =========================
   LAYOUT PRINCIPALE
   ========================= */

.project-main{ background: #fff; }

.project-layout{
  display: grid;
  grid-template-columns: minmax(0, 220px) minmax(0, 1fr);
  column-gap: 3rem;
  align-items: start;
  padding-block: 2.5rem 3.5rem;
}

.project-layout--no-border{ border-top: none; }

/* =========================
   SIDEBAR (desktop)
   ========================= */

.project-sidebar{
  font-size: 0.75rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--color-muted, #625d5d);
}

/* Sticky SOLO desktop/tablet */
@media (min-width: 901px){
  .project-sidebar{
    position: sticky;
    top: calc(var(--header-h, 72px) + 22px);
    align-self: start;
  }
}

.project-sidebar__meta{
  margin: 0 0 1.8rem;
  display: grid;
  row-gap: 0.25rem;
  padding-left: 0.75rem;
  border-left: 2px solid var(--rule, rgba(0,0,0,0.16));
}

.project-sidebar__label{ font-weight: 800; }
.project-sidebar__value{ margin-bottom: 0.5rem; }

.project-toc ul{
  list-style: none;
  margin: 0;
  padding-left: 0.75rem;
  border-left: 2px solid var(--rule, rgba(0,0,0,0.16));
}

.project-toc li + li{ margin-top: 0.35rem; }

.project-toc a{
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  color: #666;
  text-decoration: none;
  display: inline-block;
  padding: 0.2rem 0;
}

.project-toc a:hover,
.project-toc a:focus-visible{ color: #111; }

/* =========================
   CONTENUTO
   ========================= */

.project-content{
  max-width: 72ch;
  min-width: 0;
}

.project-content p,
.project-content ul,
.project-content ol{
  margin: 0;
  font-size: 1rem;
  line-height: 1.65;
  color: var(--color-text, #111);
}

.project-content p + p{ margin-top: 0.9rem; }
.project-content p + ul,
.project-content ul + p{ margin-top: 0.9rem; }

.project-content ul,
.project-content ol{ padding-left: 1.15rem; }
.project-content li + li{ margin-top: 0.45rem; }

.project-eyebrow{
  margin: 0 0 0.5rem;
  font-size: 0.75rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--color-muted, #625d5d);
}

.project-title{
  margin: 0;
  font-size: clamp(2.1rem, 3.2vw, 3.1rem);
  font-weight: 800;
  letter-spacing: -0.01em;
  text-transform: uppercase;
  line-height: 1.02;
}

.project-subtitle{
  margin-top: 1rem;
  font-size: 1.05rem;
  line-height: 1.55;
  color: var(--color-muted, #625d5d);
}

/* =========================
   SEZIONI
   ========================= */

.project-section{ margin-top: 2.4rem; }

.project-section__title{
  margin: 0 0 0.6rem;
  font-size: 0.85rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  font-weight: 800;
}

.project-section__title::after{
  content:"";
  display:block;
  width: 34px;
  height: 2px;
  background: var(--color-accent, #922A5E);
  margin-top: 0.45rem;
}

/* =========================
   QUOTE
   ========================= */

.project-quote{
  background: #fff;
  border-top: 1px solid var(--rule, rgba(0,0,0,0.16));
  border-bottom: 1px solid var(--rule, rgba(0,0,0,0.16));
}

.project-quote__inner{ padding-block: 2.4rem; }

.project-quote__text,
.project-quote__byline{
  max-width: 72ch;
  margin-left: auto;
  margin-right: auto;
}

.project-quote__text{
  margin: 0;
  font-weight: 700;
  font-size: clamp(1.15rem, 2vw, 1.6rem);
  padding-left: 1rem;
  border-left: 3px solid var(--color-accent, #922A5E);
  color: #111;
}

.project-quote__byline{
  margin: 0.85rem auto 0;
  font-size: 0.7rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--color-muted, #625d5d);
}

/* =========================
   GALLERIA
   ========================= */

.project-gallery__grid{
  margin-top: 1.2rem;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.9rem;
}

.project-gallery__item{
  border: 0;
  padding: 0;
  background: transparent;
  cursor: pointer;
  text-align: left;
}

.project-gallery__item figure{ margin: 0; }

.project-gallery__img{
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  display: block;
  border: 1px solid rgba(0,0,0,0.10);
  transition: transform 0.25s ease;
}

@media (hover: hover){
  .project-gallery__item:hover .project-gallery__img{ transform: scale(1.03); }
}

@media (prefers-reduced-motion: reduce){
  .project-gallery__img{ transition: none; }
}

/* =========================
   LIGHTBOX
   ========================= */

.lightbox{
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: none;
}

.lightbox.is-open{ display: block; }

.lightbox__backdrop{
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.7);
}

.lightbox__dialog{
  position: relative;
  z-index: 1;
  max-width: 1100px;
  margin: 5vh auto;
  background: #fff;
  border: 1px solid rgba(0,0,0,0.12);
  padding: 0.75rem;
  max-height: 90vh;
  overflow: hidden;
}

.lightbox__figure{
  margin: 0;
  display: grid;
  grid-template-rows: 1fr auto;
  gap: 0.6rem;
  max-height: calc(90vh - 3.2rem);
}

.lightbox__img{
  width: 100%;
  height: auto;
  max-height: calc(90vh - 7rem);
  object-fit: contain;
  display: block;
}

.lightbox__caption{
  margin: 0;
  color: var(--color-muted, #625d5d);
  line-height: 1.5;
}

.lightbox__close{
  position: absolute;
  top: 0.4rem;
  right: 0.4rem;
  width: 44px;
  height: 44px;
  border: 1px solid rgba(0,0,0,0.15);
  background: #fff;
  cursor: pointer;
  font-size: 1.8rem;
  line-height: 1;
}

.lightbox__arrow{
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 44px;
  height: 44px;
  border: 1px solid rgba(0,0,0,0.15);
  background: #fff;
  cursor: pointer;
  font-size: 1.6rem;
  line-height: 1;
}

.lightbox__arrow--prev{ left: 0.4rem; }
.lightbox__arrow--next{ right: 0.4rem; }

@media (prefers-reduced-motion: reduce){
  .lightbox__arrow,
  .lightbox__close{ transition: none; }
}

/* =========================
   RESPONSIVE (MOBILE)
   - TOC in alto sticky
   - meta nascosta
   ========================= */

@media (max-width: 900px){

  /* riga nera SOLO sotto immagine */
  .project-hero{ border-bottom: 0; }
  .project-hero__media{ border-bottom: 3px solid #000; }

  .project-layout{
    grid-template-columns: 1fr;
    row-gap: 1rem;
    padding-block: 1.25rem 2.25rem;
  }

  /* Sidebar IN ALTO (non nel testo) */
  .project-sidebar{
    order: -1; /* chiave: sta sopra il contenuto */
    position: sticky;
    top: calc(var(--header-h, 72px) + 8px);
    z-index: 20;

    background: #fff;
    border-bottom: 1px solid #eee;

    padding: 0.75rem 0; /* no doppio padding: lo dà già project-wrap */
    margin: 0;
  }

  /* Nascondi meta su mobile */
  .project-sidebar__meta{
    display: none;
  }

  /* TOC orizzontale */
  .project-toc ul{
    display: flex;
    flex-wrap: nowrap;
    gap: 1rem;
    list-style: none;

    margin: 0;
    padding: 0;
    border-left: 0;

    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .project-toc ul::-webkit-scrollbar{ display: none; }

  .project-toc li + li{ margin-top: 0; }

  .project-toc a{
    white-space: nowrap;
    display: inline-flex;
    padding: 0.25rem 0;
  }

  /* gallery */
  .project-gallery__grid{
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  /* spacer sidebar non serve */
  .project-sidebar--spacer{
    display: none !important;
  }

  /* lightbox full-screen */
  .lightbox__dialog{
    margin: 0;
    height: 100%;
    max-width: none;
    max-height: none;
    border: 0;
    padding: 0.75rem;
    display: grid;
    grid-template-rows: auto 1fr auto;
  }

  .lightbox__figure{
    max-height: none;
    grid-template-rows: 1fr auto;
  }

  .lightbox__img{
    max-height: 70vh;
  }

  .lightbox__arrow{
    top: auto;
    bottom: 0.6rem;
    transform: none;
  }
  .lightbox__arrow--prev{ left: 0.6rem; }
  .lightbox__arrow--next{ right: 0.6rem; }
}

@media (max-width: 480px){
  .project-gallery__grid{ grid-template-columns: 1fr; }
}
/* =========================
   FIX OVERFLOW MOBILE (testo che esce fuori)
   ========================= */

/* evita scroll orizzontale generato da qualche elemento più largo */
.project-page{
  overflow-x: clip;
}

/* su mobile: il testo deve poter restringersi e andare a capo */
@media (max-width: 900px){
  .project-content{
    max-width: 100%;
    min-width: 0;
  }

  /* forza wrap anche su parole lunghe / trattini / numeri */
  .project-content,
  .project-content p,
  .project-content li,
  .project-title,
  .project-subtitle{
    overflow-wrap: anywhere;
    word-break: break-word;
  }

  /* immagini/media non devono mai sforare */
  .project-content img,
  .project-hero__media img{
    max-width: 100%;
    height: auto;
  }
}
@media (max-width: 900px){
  .project-wrap{ overflow-x: clip; }
}
/* =========================
   FIX OVERFLOW ORIZZONTALE MOBILE (taglio a destra)
   ========================= */
@media (max-width: 900px){

  /* se in style.css c’è width:100vw sulla main-content, qui lo annulliamo */
  .main-content.project-page{
    width: 100% !important;
    max-width: 100% !important;
  }

  /* contenitori principali: mai oltre viewport */
  .main-content.project-page .project-hero,
  .main-content.project-page .project-main,
  .main-content.project-page .project-quote,
  .main-content.project-page .project-wrap{
    width: 100% !important;
    max-width: 100% !important;
  }

  /* grid items: evita espansioni “min-width:auto” */
  .main-content.project-page .project-layout > *{
    min-width: 0;
  }

  /* sicurezza: media sempre contenuti */
  .main-content.project-page img,
  .main-content.project-page svg{
    max-width: 100%;
    height: auto;
  }
}
