/* /CSS/progetti.css */
:root {
  --proj-bg: #f5f6fb;
  --proj-card: #ffffff;
  --proj-border: #e2e8f0;
  --proj-shadow: 0 10px 24px rgba(15, 23, 42, .12);
  --proj-accent: #34546A;
  --proj-muted: #64748b;
  color-scheme: light;
}
@media (prefers-color-scheme: dark){
  :root{ color-scheme: light; }
  html, body{ background-color:#f5f6fb; color:#1f2937; }
}

html, body {
  margin: 0;
  background: var(--proj-bg);
  font-family: 'Poppins', system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, Cantarell, 'Noto Sans', sans-serif;
  color: #1f2937;
}

a { color: inherit; }

.projects-wrapper {
  max-width: 1120px;
  margin: 36px auto 90px;
  padding: 0 22px;
}

.projects-hero {
  text-align: center;
  margin-bottom: 36px;
}

.projects-hero h1 {
  margin: 0 0 12px;
  font-size: clamp(32px, 4vw, 44px);
  font-weight: 600;
  color: #0f172a;
}

.projects-hero p {
  margin: 0;
  color: var(--proj-muted);
  font-size: 17px;
  line-height: 1.6;
}

.projects-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 24px;
  justify-content: center;
  justify-items: center;
}

.project-card {
  background: var(--proj-card);
  border: 1px solid var(--proj-border);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: var(--proj-shadow);
  display: flex;
  flex-direction: column;
  text-decoration: none;
  color: inherit;
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
  width: min(100%, 420px);
  content-visibility: auto;
  contain-intrinsic-size: 360px 300px;
}

.project-card:hover {
  transform: translateY(-4px);
  border-color: #cbd5f5;
  box-shadow: 0 16px 32px rgba(15, 23, 42, .18);
}

.project-card .cover {
  position: relative;
  aspect-ratio: 3 / 2.2;
  background: linear-gradient(135deg, #cbd5f5, #94a3b8);
  overflow: hidden;
}

.project-card .cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  display: block;
}

@supports not (aspect-ratio: 1 / 1) {
  .project-card .cover {
    height: 0;
    padding-top: calc(100% * (2.2 / 3));
  }
  .project-card .cover img {
    position: absolute;
    inset: 0;
  }
}

.project-card .body {
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.project-card .title {
  font-size: 20px;
  font-weight: 600;
  margin: 0;
  color: #111827;
}

.project-card .excerpt {
  color: var(--proj-muted);
  font-size: 15px;
  line-height: 1.5;
  margin: 0;
}

.project-card .footer {
  margin-top: auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--proj-accent);
  font-weight: 500;
  font-size: 14px;
}

.project-card .footer span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.project-detail {
  max-width: 1280px;
  margin: 32px auto 110px;
  padding: 0 28px 80px;
}

.project-detail .head {
  margin-bottom: 30px;
  text-align: center;
}

.project-detail h1 {
  margin: 0 0 14px;
  font-size: clamp(30px, 4vw, 42px);
  font-weight: 600;
  color: #0f172a;
}

.project-detail .desc {
  color: var(--proj-muted);
  font-size: 16px;
  line-height: 1.7;
  white-space: pre-wrap;
  margin: 0;
}

.project-gallery {
  display: grid;
  gap: 26px;
  grid-template-columns: repeat(auto-fit, minmax(clamp(260px, 42vw, 420px), 1fr));
  justify-content: center;
}

.project-gallery figure {
  margin: 0;
  border-radius: 14px;
  overflow: hidden;
  background: #0b1120;
  position: relative;
  cursor: zoom-in;
  box-shadow: 0 18px 40px rgba(15, 23, 42, .18);
  aspect-ratio: 4 / 3;
}

.project-gallery img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform .3s ease;
}

.project-gallery figure::after {
  content:'';
  position:absolute;
  inset:0;
  pointer-events:none;
  background:linear-gradient(180deg, rgba(15,23,42,0) 0%, rgba(15,23,42,.05) 100%);
}

.project-gallery figure:hover img {
  transform: scale(1.04);
}

.project-gallery figcaption {
  position: absolute;
  bottom: 10px;
  right: 12px;
  background: rgba(15, 23, 42, .65);
  color: #e2e8f0;
  font-size: 12px;
  padding: 4px 8px;
  border-radius: 999px;
}

.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(1, 5, 20, .9);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  padding: 36px;
}

.lightbox.is-visible {
  display: flex;
}

.lightbox__img {
  max-width: min(96vw, 1400px);
  max-height: 90vh;
  object-fit: contain;
  box-shadow: 0 30px 70px rgba(0, 0, 0, .55);
  border-radius: 20px;
  cursor: grab;
  transition: transform .15s ease;
  background:#030712;
}

.lightbox__nav {
  position: fixed;
  top: 0;
  bottom: 0;
  width: 16vw;
  min-width: 96px;
  max-width: 180px;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  color: #fff;
  font-size: 42px;
  cursor: pointer;
  border: none;
  z-index: 3;
  background: linear-gradient(to right, rgba(5, 8, 20, .24) 0%, rgba(5, 8, 20, 0) 60%);
  padding: 0 24px 0 18px;
  transition: background .18s ease;
}
.lightbox__nav--next {
  left: auto;
  right: 0;
  justify-content: flex-end;
  background: linear-gradient(to left, rgba(5, 8, 20, .24) 0%, rgba(5, 8, 20, 0) 60%);
  padding: 0 18px 0 24px;
}
.lightbox__nav--prev { left: 0; }
.lightbox__nav:hover { background: linear-gradient(to right, rgba(8, 12, 32, .36) 0%, rgba(4, 7, 20, 0) 60%); }
.lightbox__nav--next:hover { background: linear-gradient(to left, rgba(8, 12, 32, .36) 0%, rgba(4, 7, 20, 0) 60%); }
.lightbox__nav:focus-visible {
  outline: 2px solid #f8fafc;
  outline-offset: 3px;
}
.lightbox__nav:disabled { display: none; }

.lightbox__close {
  position: fixed;
  top: 22px;
  right: 28px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  background: rgba(15, 23, 42, .8);
  color: #fff;
  font-size: 20px;
  cursor: pointer;
  box-shadow: 0 6px 16px rgba(0,0,0,.35);
  transition: transform .18s ease, background .18s ease;
  z-index: 5;
}

.lightbox__close:hover { background: rgba(30,41,59,.85); transform: scale(1.05); }

.project-empty {
  padding: 60px 0;
  text-align: center;
  color: var(--proj-muted);
  font-size: 17px;
}

@media (max-width: 640px) {
  .projects-wrapper {
    padding: 0 18px;
    margin-top: 24px;
  }
  .project-card .body {
    padding: 14px;
  }
  .projects-grid {
    gap: 16px;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  }
  .project-detail {
    padding: 0 18px 70px;
    margin-top: 26px;
  }
  .project-gallery {
    gap: 18px;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  }
  .lightbox {
    padding: 20px;
  }
  .lightbox__nav {
    width:12vw;
    min-width:70px;
    max-width:110px;
    padding:0 12px;
    font-size:34px;
    opacity:0;
  }
  .lightbox:active .lightbox__nav{
    opacity:0.85;
  }
  .lightbox__close {
    width: 40px;
    height: 40px;
    font-size: 18px;
    right: 20px;
  }
}

@media (hover: none){
  .lightbox__nav{
    opacity:0;
  }
}
