:root {
  /* fallback: verranno sovrascritte da colors.json via JS */
  --bg-color: #f5f5f3;
  --text-color: #111111;
  --accent-color: #e4a15a;
  --overlay-color: rgba(196, 123, 47, 0.7);
  --about-overlay-bg: rgba(255, 255, 255, 0.90);

  --header-border-color: rgba(0, 0, 0, 0.05);
  --project-card-bg: #dddddd;

  --about-btn-inactive: rgba(0,0,0,0.2);
  --about-btn-hover: rgba(0,0,0,0.35);
  --about-btn-active: rgba(0,0,0,0.5);

  --close-btn-bg: rgba(0,0,0,0.35);
  --close-btn-hover-bg: rgba(0,0,0,0.55);

  /* Overlay cycle (masonry hover) */
  --overlay-cycle-1: rgba(20, 120, 128, 0.9);
  --overlay-cycle-2: rgba(96, 238, 227, 0.9);
  --overlay-cycle-3: rgba(37, 191, 148, 0.9);
  --overlay-cycle-4: rgba(233, 225, 46, 0.9);
  --overlay-cycle-5: rgba(255, 107, 65, 0.9);

  /* ✅ Switch Masonry Mobile: cambia qui se cambi idea */
  --masonry-cols-768: 2;  /* <=768px: 1 oppure 2 colonne */
  --masonry-cols-420: 1;  /* <=420px: 1 oppure 2 colonne */

  /* ✅ PDF viewer heights */
  --pdf-viewer-h-desktop: 65vh;
  --pdf-viewer-h-desktop-lg: 55vh;
  --pdf-viewer-h-tablet: 45vh;
  --pdf-viewer-h-mobile: 45vh;
  --pdf-viewer-h-mobile-sm: 45vh;
}

/* RESET */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  font-family: "Inter", system-ui, -apple-system, BlinkMacSystemFont,
    "Helvetica Neue", Arial, sans-serif;
  background-color: var(--bg-color);
  color: var(--text-color);
  line-height: 1.4;
}

a {
  color: inherit;
  text-decoration: none;
}

/* =========================
   HEADER
   ========================== */

header {
  position: sticky;
  top: 0;
  z-index: 100;
  background-color: var(--bg-color);
  border-bottom: 1px solid var(--header-border-color);
}

.header-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  text-transform: uppercase;
  font-size: 1.1rem;
  letter-spacing: 0.12em;
}

.header-left,
.header-right {
  display: flex;
  align-items: center;
}

.header-left {
  flex: 1;
}

.header-right {
  flex: 1;
  justify-content: flex-end;
  text-align: right;
}

.header-center {
  display: none;
}

.about-link {
  cursor: pointer;
  opacity: 0.8;
  border: none;
  background: transparent;
  padding: 0;
  font: inherit;
  text-transform: inherit;
  letter-spacing: inherit;
}
.about-link:hover {
  opacity: 1;
}
.about-link.active {
  opacity: 1;
  text-decoration: underline;
}

/* =========================
   MAIN LAYOUT
   ========================== */

main {
  max-width: 1200px;
  margin: 1.5rem auto 3rem;
  padding: 0 1.5rem;
}

/* =========================
   FOOTER
   ========================== */

footer {
  border-top: 1px solid var(--header-border-color);
  background-color: var(--bg-color);
  margin-top: 2rem;
}

.footer-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 3rem 2rem;
  text-align: center;
  text-transform: uppercase;
  font-size: 1.1rem;
  letter-spacing: 0.12em;
}

/* =========================
   MASONRY HOME
   ========================== */

.gallery {
  display: flex;
  align-items: flex-start;
  gap: 3rem;
}

.gallery-column {
  flex: 1;
  display: flex;
  flex-direction: column;
}

/* la colonna destra parte più in basso */
.gallery-column-right {
  margin-top: 120px;
}

.gallery-item {
  display: block;
  margin-bottom: 32px;
}

/* CARD IMMAGINE */
.gallery-column .project-card {
  position: relative;
  overflow: hidden;
  border-radius: 4px;
  background-color: var(--project-card-bg);
  cursor: pointer;
  width: 75%;
  display: block;
}

/* ===== NO ZOOM ===== */
.project-card img {
  width: 100%;
  height: auto;
  display: block;      /* elimina gap/baseline */
  transform: none;     /* niente scale */
  transition: none;    /* niente animazione zoom */
}
.project-card:hover img {
  transform: none;
}

/* OVERLAY TITOLO HOVER */
.project-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: var(--overlay-color);
  color: #ffffff;
  opacity: 0;
  transition: opacity 0.25s ease;
  text-align: center;
}

/* Overlay color per card (assegnato via classi in JS) */
.project-card.overlay-c1 .project-overlay { background: var(--overlay-cycle-1); }
.project-card.overlay-c2 .project-overlay { background: var(--overlay-cycle-2); }
.project-card.overlay-c3 .project-overlay { background: var(--overlay-cycle-3); }
.project-card.overlay-c4 .project-overlay { background: var(--overlay-cycle-4); }
.project-card.overlay-c5 .project-overlay { background: var(--overlay-cycle-5); }

.project-card:hover .project-overlay {
  opacity: 1;
}

.project-title {
  font-size: 1.2rem;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-weight: 700;
}

/* Alternanza sinistra/destra */
.gallery-column-left .gallery-item:nth-child(odd) .project-card {
  margin-right: auto;
}
.gallery-column-left .gallery-item:nth-child(even) .project-card {
  margin-left: auto;
}
.gallery-column-right .gallery-item:nth-child(odd) .project-card {
  margin-left: auto;
}
.gallery-column-right .gallery-item:nth-child(even) .project-card {
  margin-right: auto;
}

/* =========================
   OVERLAY ABOUT
   ========================== */

#about-overlay {
  position: fixed;
  inset: 0;
  background: var(--about-overlay-bg);
  backdrop-filter: blur(2px);
  z-index: 200;
  display: none;
  overflow-y: auto;
  padding: 4rem 2rem;
}
#about-overlay.active {
  display: block;
}

.about-content {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1.5rem;
}

/* Bottoni categorie */
.about-categories {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  justify-content: center;
  margin-top: 2.5rem;
  margin-bottom: 3rem;
}

.about-cat-btn {
  background: transparent;
  border: 0px solid transparent;
  padding: 0.5rem 1rem;
  border-radius: 999px;

  /* ✅ TIPOGRAFIA COME HEADER */
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 1.1rem;
  font-weight: 400;

  cursor: pointer;
  color: #000;
  transition: background 0.2s ease;
}
.about-cat-btn:hover {
  background: rgba(0, 0, 0, 0.08);
}
.about-cat-btn.active {
  background: rgba(0, 0, 0, 0.15);
}

/* Titolo */
.about-title {
  font-size: 2.2rem;
  font-weight: bold;
  margin-top: 8rem;
  margin-bottom: 0;
  text-transform: uppercase;
}

/* EMAIL sotto il titolo */
.about-email {
  margin-top: 0.75rem;
  margin-bottom: 4rem;
  font-size: 1rem;
}
.about-email a {
  text-decoration: none;
  text-underline-offset: 2px;
}

/* Sezioni About */
.about-subtitle {
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 1rem;
}
.about-text {
  font-size: 1rem;
  line-height: 1.6;
  width: 100%;
  margin-bottom: 1rem;
  text-align: justify;
}

.about-section {
  margin-bottom: 2.5rem;
}
.about-section img {
  margin-top: 1rem;
  max-width: 100%;
  border-radius: 4px;
}

/* Pulsante X */
#about-close {
  position: absolute;
  top: 3rem;
  left: 5rem;
  background: transparent;
  color: var(--text-color);
  border: none;
  font-size: 2rem;
  cursor: pointer;
}
#about-close:hover {
  color: rgba(0, 0, 0, 0.65);
}

/* =========================
   RESPONSIVE HOME (HEADER svincolato + MASONRY switch)
   ========================== */

/* <=768px: Header resta in riga; Masonry configurabile (default 2 colonne) */
@media (max-width: 768px) {
  /* HEADER: resta come desktop */
  .header-inner{
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
  }

  .header-left{
    flex: 0 1 auto;
  }

  .header-right{
    flex: 0 1 auto;
    margin-left: auto;
    justify-content: flex-end;
    text-align: right;
    white-space: nowrap;
  }

  /* MASONRY: colonne switchabili */
  .gallery{
    display: flex;
    flex-direction: row;
    align-items: flex-start;
    gap: 1rem;
  }

  .gallery-column{
    flex: 0 0 calc(100% / var(--masonry-cols-768));
    width: calc(100% / var(--masonry-cols-768));
  }

  .gallery-column-right{
    margin-top: 0;
  }

  .gallery-column .project-card{
    width: 100%;
    margin: 0 !important;
  }

  #about-overlay{
    padding: 4.5rem 1.5rem 3rem;
  }

  .about-categories {
    gap: 0.45rem;
    margin-bottom: 2rem;
    margin-top: -1.0rem;
  }

  .about-cat-btn {
    padding: 0.35rem 0.9rem;
    line-height: 1.2;
  }

  html { font-size: 92%; }   /* ≈ 13.8px */
}

/* <=420px: Masonry a 1 colonna (switch) */
@media (max-width: 420px) {
  .gallery{
    flex-direction: column;
  }

  .gallery-column{
    width: calc(100% / var(--masonry-cols-420));
    flex-basis: calc(100% / var(--masonry-cols-420));
  }

  html { font-size: 82%; }   /* ≈ 12.8px */
}

/* =========================
   PAGINA PROGETTO
   ========================== */

body.project-page {
  line-height: 1.5;
  padding-bottom: 4rem;
}

/* Back link */
.back-link {
  display: inline-block;
  margin-bottom: 6px;
  opacity: 0.7;
  transition: opacity .2s;
}
.back-link:hover {
  opacity: 1;
}

/* Titolo progetto */
body.project-page .project-title {
  font-size: 2rem;
  font-weight: 800;
  margin-top: 3.0rem;   /* ← distanza dalle categorie */
  margin-bottom: 2.0rem;
  text-transform: uppercase;
  letter-spacing: .1em;
}

/* Sottotitolo */
.project-subtitle {
  font-size: 1.05rem;
  line-height: 1.65;
  margin-bottom: 3rem;
  max-width: 60ch;
  opacity: 0.95;
}

/* Meta-info */
.project-meta {
  margin-bottom: 2.5rem;
  font-size: 1.05rem;
  line-height: 1.65;
  max-width: 60ch;
}
.project-meta-line {
  margin-bottom: 0.3rem;
}

/* Tag categorie */
.project-tags {
  margin: 1rem 0 2.5rem;
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

/* ✅ Tag: niente bordo nero + sfondo grigio chiaro */
.tag {
  background: rgba(0,0,0,0.12);  /* grigio chiaro */
  padding: 0.3rem 0.8rem;
  border-radius: 999px;
  font-size: 0.75rem;
  text-transform: uppercase;
  cursor: pointer;

  border: none;
  outline: none;
}

.tag:hover {
  background: rgba(0,0,0,0.18);
}

.tag:focus,
.tag:focus-visible {
  outline: none;
  box-shadow: none;
}

/* Descrizione progetto */
.project-description {
  margin-bottom: 0;
  font-size: 1.05rem;
  line-height: 1.65;
  text-align: justify;
}

/* Meta + Discover dentro la descrizione (blocchi clamped) */
.project-description .project-meta {
  margin-top: 1rem;
  margin-bottom: 0.75rem;
}

.project-description .project-discover {
  margin-bottom: 0;
}

/* Immagini 2 colonne */
.project-images {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.5rem;
}
.project-images img {
  width: 100%;
  border-radius: 4px;
  cursor: zoom-in;
}

/* LIGHTBOX */
.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.8);
  display: none;
  place-items: center;
  z-index: 300;
}
.lightbox.active {
  display: grid;
}
.lightbox-inner img {
  max-width: 100vw;
  max-height: 100vh;
  border-radius: 4px;
}
.lightbox-close {
  position: fixed;
  top: 1.5rem;
  right: 1.5rem;
  background: rgba(0,0,0,0.6);
  color: white;
  border-radius: 50%;
  width: 36px;
  height: 36px;
  font-size: 1.4rem;
  cursor: pointer;
}

/* Responsive Project Page */
@media (max-width: 768px) {
  body.project-page .project-images {
    grid-template-columns: 1fr;
  }
}

/* Video */
.project-media {
  margin: 2rem 0 2.5rem;
  display: grid;
  gap: 1.5rem;
}

.project-video {
  width: 100%;
  border-radius: 4px;
  overflow: hidden;
}

.project-video iframe {
  width: 100%;
  aspect-ratio: 16 / 9;
  border: 0;
  display: block;
}

/* =========================
   PDF IN PAGINA (PDF.js – viewer con lazy loading)
   ========================== */

.project-pdf {
  width: 100%;
  border-radius: 4px;
  overflow: hidden;
  background: rgba(0,0,0,0.06);
}

/* viewer scrollabile: altezze diverse per device */
.pdfjs-host {
  width: 100%;
  max-height: var(--pdf-viewer-h-desktop);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;

  /* evita che lo scroll “scappi” alla pagina */
  overscroll-behavior: contain;

  /* riduce layout shift quando compare la scrollbar (supportato da molti browser) */
  scrollbar-gutter: stable;
}

/* wrapper pagine */
.pdfjs-pages {
  display: grid;
  gap: 12px;
  padding: 12px;
}

/* placeholder pagina (lazy loading) */
.pdfjs-page {
  background: rgba(0,0,0,0.03);
  border-radius: 2px;
}

/* canvas responsive */
.pdfjs-canvas {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 2px;
}

/* stati */
.pdfjs-loading,
.pdfjs-error {
  padding: 18px 12px;
  text-align: center;
  font-size: 0.9rem;
  opacity: 0.8;
}

/* Desktop grandi */
@media (min-width: 1200px) {
  .pdfjs-host {
    max-height: var(--pdf-viewer-h-desktop-lg);
  }
}

/* Tablet / small desktop */
@media (max-width: 1024px) {
  .pdfjs-host {
    max-height: var(--pdf-viewer-h-tablet);
  }
}

/* Mobile */
@media (max-width: 768px) {
  .pdfjs-host {
    max-height: var(--pdf-viewer-h-mobile);
  }
}

/* Mobile piccoli */
@media (max-width: 420px) {
  .pdfjs-host {
    max-height: var(--pdf-viewer-h-mobile-sm);
  }
}

/* PDF nel lightbox (se lo lasciamo per altri usi: non fa danni) */
.lightbox-inner iframe#lightbox-pdf {
  width: 100vw;
  height: 100vh;
  border: 0;
  border-radius: 0;
}

/* Toolbar sopra al PDF */
.pdf-toolbar {
  display: flex;
  justify-content: flex-end;
  padding: 0.5rem 0.75rem;
  background: rgba(0,0,0,0.04);
  border-bottom: 1px solid rgba(0,0,0,0.08);
}

/* Pulsante "Open PDF" */
.pdf-open-btn {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-weight: 600;
  padding: 0.35rem 0.7rem;
  border-radius: 999px;
  background: rgba(0,0,0,0.12);
  transition: background 0.2s ease;
}

.pdf-open-btn:hover {
  background: rgba(0,0,0,0.2);
}


/* =========================
   PROJECT BOTTOM NAV (Prev/Next)
   ========================== */

.project-bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 120;
  background-color: var(--bg-color);
  border-top: 1px solid var(--header-border-color);
}

.project-bottom-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  text-transform: uppercase;
  font-size: 0.8rem;
  letter-spacing: 0.12em;
}

.project-nav-link {
  opacity: 0.8;
}
.project-nav-link:hover {
  opacity: 1;
}
.project-nav-link.is-disabled {
  opacity: 0.25;
  pointer-events: none;
}

/* lascia spazio alla barra fissa in basso */
body.project-page {
  padding-bottom: 5.5rem;
}

/* Email in fondo alla pagina progetto */
.project-email {
  margin-top: 4rem;
  text-align: center;
  font-size: 1rem;
  letter-spacing: 0.08em;
}

.project-email a {
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* =========================
   READ MORE / DISCOVER / AWARDS
   ========================= */

/* --- Descrizione --- */
.project-description {
  margin-bottom: 0;
  font-size: 1.05rem;
  line-height: 1.65;
  text-align: justify;
}

.project-description-wrap {
  margin-top: 0;
}

.project-description p:last-child {
  margin-bottom: 0 !important;
}

/* Clamp sempre a 6 righe */
.project-description.is-collapsed {
  overflow: hidden;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 6;
}

/* --- Read more / Read less --- */
.project-description-toggle {
  display: block;
  margin-top: 1.0rem;
  margin-bottom: 3.0rem;
  margin-left: auto;      /* allinea a destra */
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  font-weight: 700;       /* grassetto */
  cursor: pointer;
  text-decoration: none;
}

.project-description-toggle:hover {
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* --- Discover more --- */
.project-discover {
  margin-top: 0;        /* attaccato a Read more */
  margin-bottom: 28px; /* separa da Logos / media */
}

.project-discover a {
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* --- Logos --- */
.project-logos {
  width: 100%;
  margin: 2.0rem 0 32px;
}

.project-logos-title {
  margin-bottom: 10px;
  font-weight: 600;
}

.logos-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 12px;
  align-items: center;
}

.logos-grid img {
  width: 100%;
  max-width: none;
  height: auto;
  display: block;
  object-fit: contain;
}

/* Responsive */
@media (max-width: 900px) {
  .logos-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 600px) {
  .logos-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* Categorie progetto (sotto Back) */
.project-categories {
  margin-top: 0px;     /* distanza Back → categorie */
  margin-bottom: 0.5rem;
}

.about-category-title-link {
  text-decoration: underline;
  text-decoration-thickness: 0.06em;
  text-underline-offset: 0.15em;
  color: inherit;
}

/* About categories: stesso identico stile dei tag nella pagina project */
.about-cat-btn {
  background: rgba(0,0,0,0.12);
  padding: 0.3rem 0.8rem;
  border-radius: 999px;
  font-size: 0.75rem;
  text-transform: uppercase;
  cursor: pointer;

  border: none;
  outline: none;
  color: inherit;
}

.about-cat-btn:hover {
  background: rgba(0,0,0,0.18);
}

.about-cat-btn:focus,
.about-cat-btn:focus-visible {
  outline: none;
  box-shadow: none;
}

/* Stato attivo: un filo più “pieno” */
.about-cat-btn.active {
  background: rgba(0,0,0,0.22);
}

@media (max-width: 768px) {
  #about-close {
    left: 1.5rem;   /* allineata al padding laterale */
    top: 1.0rem;
  }
}