/* ---------- Token ---------- */
:root {
  --bg: #f0f0f0;
  --ink: #1a1a1a;
  --brand-red: #a02a2a;
  --brand-granata: #a02a2a;
  --arrow-border: 3px;      /* spessore del bordo (frecce e rettangoli principali) */
  --brand-gray: #555555;
  --rule: #1a1a1a;
  --video-tone: #0c0c0c;
  --font: "Avenir Next", "Century Gothic", "Nunito", "Trebuchet MS", system-ui, sans-serif;
  --gutter: clamp(1rem, 3vw, 2.5rem);
}

*, *::before, *::after { box-sizing: border-box; }

html { height: 100%; }

body {
  position: relative;
  min-height: 100%;
  margin: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 1.0625rem;
  line-height: 1.55;
}

main { flex: 1; }

a { color: inherit; }

:focus-visible {
  outline: 3px solid var(--brand-red);
  outline-offset: 3px;
}

/* ---------- Voci di menu (header e footer) ---------- */
.nav-link {
  font: inherit;
  font-weight: 700;
  color: var(--ink);
  background: none;
  border: 0;
  padding: 0.25rem 0;
  cursor: pointer;
  text-decoration: none;
}

.nav-link:hover {
  color: var(--brand-red);
  text-decoration: underline;
  text-underline-offset: 0.3em;
}

.nav-link.active {
  color: var(--brand-red);
}

.inline-form { margin: 0; }

/* ---------- Header ---------- */
.site-header {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 1rem;
  padding: 1.75rem var(--gutter) 0.9rem;
  border-bottom: 1px solid var(--rule);
}

.header-logo {
  justify-self: start;
  display: inline-flex;
  line-height: 0;
  margin-left: 25px;
}

/* Logo in alto a sinistra: valore per ingrandirlo/rimpicciolirlo */
.site-header .header-logo img.logo-mark {
  width: clamp(2.5rem, 4vw, 3.5rem) !important;
  height: auto;
}

.main-nav {
  justify-self: center;
  display: flex;
  gap: clamp(1rem, 3vw, 2.5rem);
}

.account-nav { justify-self: end; }

.site-header .nav-link,
.site-header .login-btn {
  font-size: 1.60rem;
  font-weight: 600;
  position: relative;
  top: 0.1rem;
}

.site-header a.login-btn,
.site-header button.login-btn {
  font-size: 1.25rem;
}

/* ---------- Logo Immagine ---------- */
.logo-mark { display: block; height: auto; width: 100%; }
/* Logo centrale grande */
.logo-mark--large { width: clamp(35rem, 85vw, 62rem); }

.wordmark {
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0;
}

/* ---------- Footer ---------- */
.site-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem var(--gutter);
  border-top: 1px solid var(--rule);
}
.footer-nav { display: flex; gap: 1.5rem; }

.legal-head {
  font-weight: bold;
  font-size: 1.1rem;
  color: var(--ink);
  margin-bottom: 6px;
  display: block;
}

.legal-address {
  font-weight: normal;
  font-size: 0.95rem;
  color: var(--brand-gray);
  line-height: 1.5;
  display: block;
}

/* ---------- Home: video a schermo intero ---------- */
.home .site-header,
.hero {
  --ink: #ffffff;
  --brand-red: #e04a41;
  --brand-gray: #f4f4f4;
}

.home .site-header {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 3;
  border-bottom: 0;
}

.home .site-header .nav-link {
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.6);
}

.home .site-header .nav-link:hover,
.home .site-header .login-btn:hover {
  color: #a02a2a;
}

.home .site-footer {
  --ink: #ffffff;
  background: var(--video-tone);
  border-top: 0;
}

.home .site-footer .legal-head { color: #ffffff; }
.home .site-footer .legal-address { color: #cbd5e0; }

.hero {
  position: relative;
  min-height: 100vh;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  overflow: hidden;
  background: var(--video-tone);
  color: var(--ink);
}

.hero-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scale(1.05);
  transform-origin: right center;
}

.hero::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(to bottom, rgba(0, 0, 0, 0.6), rgba(0, 0, 0, 0.15) 50%, rgba(0, 0, 0, 0.1));
  pointer-events: none;
}

.hero-content {
  position: relative;
  z-index: 2;
  width: 100%;
  padding: clamp(2rem, 5vh, 4rem) var(--gutter) 0;
  display: flex;
  justify-content: center;
}

.video-placeholder {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  margin: 0;
  font-size: clamp(2.5rem, 9vw, 6rem);
  letter-spacing: 0.08em;
  color: #777;
}

/* ---------- Pagine interne e login ---------- */
.page { max-width: 70rem; margin: 0 auto; padding: clamp(2rem, 6vw, 4rem) var(--gutter); }
.page--narrow { max-width: 26rem; }
.page--wide { max-width: 62rem; }
.page h1 { margin-top: 0; }

.login-form { display: grid; gap: 0.5rem; }
.login-form label { font-weight: 600; margin-top: 0.75rem; }
.login-form input[type="text"],
.login-form input[type="password"] {
  width: 100%;
  padding: 0.65rem 0.75rem;
  font: inherit;
  color: var(--ink);
  background: #ffffff;
  border: 1px solid var(--rule);
  border-radius: 0.25rem;
}
.form-error { color: #a02a2a; font-weight: 600; margin: 0; }

.button {
  margin-top: 1.25rem;
  padding: 0.75rem 1.25rem;
  font: inherit;
  font-weight: 600;
  color: #fff;
  background: var(--brand-red);
  border: 0;
  border-radius: 0.25rem;
  cursor: pointer;
}
.button:hover { background: #a02a2a; }

/* ---------- Services ---------- */
.service-row {
  --arrow-tip: 1.75rem;     /* quanto è sporgente la punta */

  display: grid;
  grid-template-columns: minmax(15rem, 20rem);
  justify-content: center;
  align-items: center;
  gap: clamp(1.5rem, 4vw, 3rem);
  margin-bottom: clamp(1.5rem, 3vw, 2.25rem);
}

.service-row[open] {
  grid-template-columns: minmax(15rem, 20rem) 1fr;
  justify-content: stretch;
}

.service-arrow {
  position: relative;
  isolation: isolate;              /* tiene il ::before dentro l'elemento */
  margin: 0;
  min-height: 5rem;
  padding: 1rem 3.5rem 1rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  text-transform: uppercase;
  font-size: 1.15rem;
  font-weight: 800;
  line-height: 1.25;
  color: #a02a2a;
  background: #a02a2a; /* colore del bordo dei rettangoli */
  cursor: pointer;
  list-style: none;
  user-select: none;

  /* chiuso: rettangolo (stessi 5 punti della freccia, così si anima) */
  clip-path: polygon(0 0, 100% 0, 100% 50%, 100% 100%, 0 100%);
  transition: clip-path 0.3s ease, min-height 0.3s ease, font-size 0.3s ease;
}
.service-arrow::-webkit-details-marker { display: none; }

/* riempimento bianco, un po' più piccolo: lascia visibile il bordo granata */
.service-arrow::before {
  content: "";
  position: absolute;
  inset: var(--arrow-border);
  z-index: -1;
  background: var(--bg);
  clip-path: polygon(0 0, 100% 0, 100% 50%, 100% 100%, 0 100%);
  transition: clip-path 0.3s ease, background 0.2s;
}

/* aperto: diventa freccia (stessa forma, sia fuori che dentro) */
.service-row[open] > .service-arrow {
  clip-path: polygon(0 0, calc(100% - var(--arrow-tip)) 0, 100% 50%, calc(100% - var(--arrow-tip)) 100%, 0 100%);
}
.service-row[open] > .service-arrow::before {
  clip-path: polygon(0 0, calc(100% - var(--arrow-tip)) 0, 100% 50%, calc(100% - var(--arrow-tip)) 100%, 0 100%);
}

/* tastino: "+" da chiuso, "−" da aperto */
.service-arrow::after {
  content: "+";
  position: absolute;
  right: 1.1rem;
  top: 50%;
  transform: translateY(-50%);
  width: 1.6rem;
  height: 1.6rem;
  display: grid;
  place-items: center;
  font-size: 1.3rem;
  font-weight: 700;
  line-height: 1;
  color: #a02a2a;
  background: var(--bg);
  border: 2px solid #a02a2a;
  border-radius: 50%;
  box-sizing: border-box;
  transition: right 0.3s ease, color 0.2s, background 0.2s;
}
.service-arrow:hover::after {
  color: var(--bg);
  background: #a02a2a;
}
.service-row[open] > .service-arrow::after {
  content: "−";
  right: 2.1rem;   /* si sposta per non finire sulla punta */
}

.service-arrow:focus-visible { outline-offset: -6px; outline-color: #a02a2a; }

/* elenco */
.service-row > .service-list {
  margin: 0;
  padding-left: 1.25rem;
  color: var(--brand-gray);
  font-size: 1rem;
  line-height: 1.6;
}
.service-list li::marker { color: var(--brand-gray); }

/* ---------- Gruppi di servizi (contenitori) ---------- */
.service-group {
  margin-bottom: clamp(1.5rem, 3vw, 2.25rem);
}

.service-group-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.5rem;
  font-size: 1.4rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--brand-granata);
  /*background: #ffffff;*/
  border: var(--arrow-border) solid #a02a2a;
  cursor: pointer;
  list-style: none;
  user-select: none;
  transition: background 0.2s;
}
.service-group-title::-webkit-details-marker { display: none; }
/*.service-group-title:hover { background: #a02a2a; }*/

.service-group-title::after {
  content: "+";
  font-size: 1.8rem;
  line-height: 1;
}
.service-group[open] > .service-group-title::after { content: "−"; }

.service-group-title:focus-visible { outline-offset: 3px; outline-color: #a02a2a; }

.service-group-body {
  padding-top: clamp(1.5rem, 3vw, 2.25rem);
}
.service-group[open] > .service-group-body {
  animation: serviceFadeIn 0.35s ease;
}
@keyframes serviceFadeIn {
  from { opacity: 0; transform: translateY(-14px); }
  to   { opacity: 1; transform: none; }
}

/* ---------- Ciclo di vita del progetto (tabella) ---------- */
.lifecycle { --lc-line: #6f9bc4; }

.lifecycle-labels {
  display: flex;
  justify-content: space-between;
  margin-bottom: 0.4rem;
  font-size: 1.1rem;
  font-weight: 500;
}

.lifecycle-track {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  grid-template-rows: auto 1fr;
  column-gap: 0.75rem;
  padding: 0 2rem;
  align-items: start;
}

/* rettangolo che finisce a freccia */
.lifecycle-line {
  grid-column: 1 / -1;
  grid-row: 1;
  align-self: stretch;
  margin: 0 -2rem;
  border-top: 1px solid var(--lc-line);
  border-bottom: 1px solid var(--lc-line);
  position: relative;
}
.lifecycle-line::before,
.lifecycle-line::after {
  content: "";
  position: absolute;
  top: 50%;
  width: 0.9rem;
  height: 1.3rem;
  background: var(--brand-gray);
  clip-path: polygon(50% 0, 100% 50%, 50% 100%, 0 50%);
  transform: translateY(-50%);
}
.lifecycle-line::before { left: 0.6rem; }
.lifecycle-line::after  { right: 0.6rem; }

/* le fasi sono "trasparenti" per la griglia: titolo in riga 1, elenco in riga 2 */
.lifecycle-phase { display: contents; }

.lifecycle-phase:nth-of-type(2) > * { grid-column: 1; }
.lifecycle-phase:nth-of-type(3) > * { grid-column: 2; }
.lifecycle-phase:nth-of-type(4) > * { grid-column: 3; }
.lifecycle-phase:nth-of-type(5) > * { grid-column: 4; }
.lifecycle-phase:nth-of-type(6) > * { grid-column: 5; }

.lifecycle-title {
  grid-row: 1;
  z-index: 1;
  align-self: center;
  margin: 0.6rem 0;
  padding: 0.3rem 0.4rem;
  text-align: center;
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--brand-red);
  background: #ffffff;
  border: 1.5px solid var(--brand-red);
}

.lifecycle-list {
  grid-row: 2;
  margin: 0.9rem 0 0;
  padding: 0.8rem 0.7rem 0.8rem 1.6rem;
  font-size: 0.85rem;
  line-height: 1.35;
  color: var(--ink);
  background: linear-gradient(to bottom, #ffffff, #dcdcdc);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.18);
}
.lifecycle-list li { margin-bottom: 0.35rem; }
.lifecycle-list li::marker { color: var(--ink); }

/* ---------- Projects ---------- */
.proj-cats {
  display: flex;
  flex-direction: column;
  gap: 2.5rem;
}

.proj-cat {
  display: flex;
  align-items: center;
  width: min(100%, 42rem);
  color: var(--brand-red);
  text-decoration: none;
}

/* quelle a destra: foto a destra, scritta allineata a destra */
.proj-cat--right {
  flex-direction: row-reverse;
  margin-left: auto;
  margin-top: -1.5rem;
}

.proj-cat-img {
  flex: none;
  width: 14rem;
  height: 9.5rem;
  object-fit: cover;
  transition: transform 0.25s ease, box-shadow 0.25s ease;
}
.proj-cat:hover .proj-cat-img {
  transform: scale(1.03);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.25);
}

.proj-cat-label {
  flex: 1;
  padding: 0 1rem 0.2rem;
  font-size: 1.5rem;
  line-height: 1.4;
  text-transform: uppercase;
  border-bottom: 1px solid var(--brand-gray);
  transition: color 0.2s;
}
.proj-cat--right .proj-cat-label { text-align: right; }
.proj-cat:hover .proj-cat-label { color: #a02a2a; }


/* ---------- Projects: elenco opere + dettaglio ---------- */
.crumbs { font-size: 0.85rem; color: var(--brand-gray); margin-bottom: 1rem; }
.crumbs a { color: var(--brand-red); text-decoration: none; }
.crumbs a:hover { color: #a02a2a; }
.crumbs span { margin: 0 0.35rem; }

.proj-title { color: var(--brand-red); text-transform: uppercase; font-weight: 700; margin: 0 0 2rem; }

.proj-op-name { margin: 0; font-size: 1.5rem; font-weight: inherit; text-transform: uppercase; }
.proj-op-sub { margin: 0.35rem 0 0; font-size: 0.95rem; text-transform: none; color: var(--brand-gray); }

.opera-cover { display: block; width: 100%; max-height: 32rem; object-fit: cover; margin-bottom: 1.5rem; }

.opera-meta { display: flex; flex-wrap: wrap; gap: 0.75rem 2.5rem; margin: 0 0 1.5rem; padding-bottom: 1rem; border-bottom: 1px solid var(--brand-gray); }
.opera-meta dt { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--brand-gray); }
.opera-meta dd { margin: 0.1rem 0 0; font-weight: 700; }

.opera-h { color: var(--brand-red); text-transform: uppercase; font-size: 1.1rem; margin: 1.75rem 0 0.5rem; }
.opera-list { margin: 0; padding-left: 1.2rem; line-height: 1.6; max-width: 44rem; }

.opera-gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(16rem, 1fr)); gap: 1rem; margin-top: 0.75rem; }
.opera-gallery figure { margin: 0; }
.opera-gallery img { display: block; width: 100%; height: 12rem; object-fit: cover; }
.opera-gallery figcaption { font-size: 0.85rem; color: var(--brand-gray); margin-top: 0.35rem; }

.opera-back { margin-top: 2.5rem; }
.opera-back a { color: var(--brand-red); text-decoration: none; font-weight: 700; }
.opera-back a:hover { color: #a02a2a; }

.service-group-title {
  display: flex;
  align-items: center;
  cursor: pointer;
  padding: 1rem 1.25rem;
  font-weight: 600;
}

.service-group-icon {
  margin-right: 0.85rem;
  stroke: currentColor;
  flex-shrink: 0;
}

.service-group-title span {
  flex-grow: 1;
}

.work-section { max-width: 700px; margin: 60px auto; padding: 0 20px; }
.work-section h1 { font-weight: bold; margin-bottom: 30px; }

.work-form .form-row { display: flex; gap: 20px; }
.work-form .form-group { flex: 1; display: flex; flex-direction: column; margin-bottom: 20px; }
.work-form label { font-weight: bold; margin-bottom: 6px; }
.work-form input, .work-form textarea {
  padding: 10px; border: 1px solid #ccc; border-radius: 4px; font-size: 1rem;
}
.work-form button {
  background: #a02a2a; color: #fff; border: none; padding: 12px 28px;
  font-weight: bold; cursor: pointer; border-radius: 4px;
}
.work-form button:hover { background: #a02a2a; }

.alert-success { background: #e6f4ea; padding: 12px; border-radius: 4px; margin-bottom: 20px; }
.errorlist { color: #a02a2a; list-style: none; padding: 0; margin: 4px 0 0; }

@media (max-width: 600px) {
  .work-form .form-row { flex-direction: column; gap: 0; }
}

/* ---------- Mobile ---------- */
@media (max-width: 40rem) {
  .home .site-header,
  .site-header {
    display: grid;
    grid-template-columns: 1fr auto;
    grid-template-areas:
      "logo account"
      "nav  nav";
    row-gap: 0.5rem;
    position: relative !important;
    background-color: rgba(0, 0, 0, 0.95);
    padding: 0.75rem 1rem;
    align-items: center;
    z-index: 100;
  }
  
  .header-logo  { 
    grid-area: logo; 
    min-width: 0;
    margin-left: 0 !important;
  }

  .header-logo img, 
  .header-logo svg {
    max-width: 100%;
    height: auto;
    display: block;
  }

  .account-nav  { 
    grid-area: account; 
    justify-self: end; 
  }

  .main-nav     { 
    grid-area: nav; 
  }

  .main-nav ul {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    padding: 0;
    margin: 0;
    list-style: none;
  }

  /* Ridimensionare il logo grande centrale invece di nasconderlo */
  .logo-mark--large {
    width: clamp(16rem, 75vw, 24rem) !important; /* Si restringe drasticamente per entrare nello schermo */
  }

  .wordmark {
    flex-direction: column;
    padding: 0 1rem;
  }

  .hero-content { 
    padding-top: 3.5rem; 
  }

  .service-row,
  .service-row--compact,
  .service-row[open] { grid-template-columns: minmax(0, 24rem); justify-content: center; gap: 0.75rem; }

  .lifecycle-track { display: block; padding: 0; }
  .lifecycle-line { display: none; }
  .lifecycle-phase { display: block; margin-bottom: 1.25rem; }
  .lifecycle-title { margin: 0 0 0.5rem; }
  .lifecycle-list { margin-top: 0; }

  .proj-cat,
  .proj-cat--right { flex-direction: column; align-items: stretch; margin-left: 0; margin-top: 0; }
  .proj-cat-img { width: 100%; height: 12rem; }
  .proj-cat--right .proj-cat-label { text-align: left; }
  .proj-cat-label { padding: 0.5rem 0; font-size: 1.25rem; }
}