/* ==========================================================================
   Carlo Finelli — Portfolio
   Design concept: a technical design document / project dossier.
   Dark "desk" surface, cream "paper" cards pinned to it, mono for
   structure & labels (spec-sheet voice), serif for reading copy.
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@400;500;600;700&family=Source+Serif+4:opsz,wght@8..60,400;8..60,500;8..60,600&display=swap');

:root {
  --bg: #14151a;
  --bg-alt: #1a1c23;
  --paper: #f1ecdd;
  --paper-dim: #e7e1cd;
  --ink: #221f1a;
  --ink-soft: #5a5340;
  --line: #33363f;
  --line-soft: #24262e;
  --line-paper: #d7cfb6;
  --fg: #ece7d8;
  --muted: #8b93a3;
  --accent: #c1432e;
  --accent-dim: #7a3226;
  --mono: 'IBM Plex Mono', 'SFMono-Regular', Consolas, monospace;
  --serif: 'Source Serif 4', Georgia, serif;
  --max: 920px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; }
}

body {
  margin: 0;
  background:
    linear-gradient(rgba(255,255,255,.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.035) 1px, transparent 1px),
    var(--bg);
  background-size: 48px 48px, 48px 48px, auto;
  color: var(--fg);
  font-family: var(--serif);
  font-size: 17px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; }
a:focus-visible, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

.wrap { max-width: var(--max); margin: 0 auto; padding: 0 28px; }

/* ---------- Header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 20;
  backdrop-filter: blur(8px);
  background: rgba(20,21,26,.82);
  border-bottom: 1px solid var(--line);
}
.site-header .wrap { display: flex; align-items: center; justify-content: space-between; padding-top: 16px; padding-bottom: 16px; }
.site-header .id {
  font-family: var(--mono); font-weight: 600; font-size: 14px; letter-spacing: .02em;
  text-decoration: none;
}
.site-header .id .role { color: var(--muted); font-weight: 400; }
.site-header nav { display: flex; gap: 22px; font-family: var(--mono); font-size: 12.5px; letter-spacing: .06em; }
.site-header nav a { text-decoration: none; color: var(--muted); }
.site-header nav a:hover { color: var(--accent); }
.back-link { font-family: var(--mono); font-size: 12.5px; letter-spacing: .06em; color: var(--muted); text-decoration: none; }
.back-link:hover { color: var(--accent); }

/* ---------- Hero ---------- */
.hero { padding: 32px 0 48px; }
.doc-tag {
  display: inline-block; font-family: var(--mono); font-size: 12.5px; letter-spacing: .12em;
  color: var(--accent); border: 1px solid var(--accent-dim); padding: 4px 10px; border-radius: 2px;
  margin-bottom: 22px; text-transform: uppercase;
}
.hero h1 {
  font-family: var(--mono); font-weight: 700; font-size: clamp(34px, 6vw, 56px);
  letter-spacing: -0.01em; margin: 0 0 6px; color: var(--paper);
}
.hero .cursor { color: var(--accent); animation: blink 1.1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }
.hero .role-line {
  font-family: var(--mono); font-size: 20px; color: var(--muted); margin: 0 0 32px; letter-spacing: .02em;
}
.hero .statement {
  font-size: clamp(19px, 2.4vw, 23px); line-height: 1.55; max-width: 62ch; margin: 0 0 40px;
  color: var(--fg);
}
.meta-row {
  display: flex; flex-wrap: wrap; gap: 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line);
  margin-bottom: 34px;
}
.meta-row div { padding: 14px 24px 14px 0; margin-right: 24px; border-right: 1px solid var(--line); }
.meta-row div:last-child { border-right: none; margin-right: 0; }
.meta-row .k { display: block; font-family: var(--mono); font-size: 10.5px; letter-spacing: .1em; color: var(--muted); margin-bottom: 4px; text-transform: uppercase; }
.meta-row .v { font-family: var(--mono); font-size: 13.5px; color: var(--paper); }

.cta-row { display: flex; flex-wrap: wrap; gap: 12px; }
.btn {
  font-family: var(--mono); font-size: 13px; letter-spacing: .04em; text-decoration: none;
  padding: 10px 18px; border: 1px solid var(--line); color: var(--fg); border-radius: 2px;
  transition: border-color .15s ease, color .15s ease, background-color .15s ease;
}
.btn:hover { border-color: var(--accent); color: var(--paper); background: rgba(193,67,46,.08); }
.btn.primary { border-color: var(--accent); color: var(--paper); background: rgba(193,67,46,.12); }
.btn.primary:hover { background: rgba(193,67,46,.22); }

/* ---------- Section eyebrow ---------- */
.section { padding: 64px 0; }
.eyebrow { display: flex; align-items: baseline; gap: 16px; margin-bottom: 34px; }
.eyebrow .num { font-family: var(--mono); font-size: 13px; color: var(--accent); letter-spacing: .08em; }
.eyebrow .label { font-family: var(--mono); font-size: 13px; letter-spacing: .14em; text-transform: uppercase; color: var(--paper); }
.eyebrow .rule { flex: 1; height: 1px; background: var(--line); }

/* ---------- Skills ---------- */
.skills-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1px; background: var(--line); border: 1px solid var(--line); }
.skill-card { background: var(--bg); padding: 26px 28px; }
.skill-card .label { font-family: var(--mono); font-size: 12px; letter-spacing: .08em; text-transform: uppercase; color: var(--accent); margin-bottom: 10px; border-left: 2px solid var(--accent); padding-left: 10px; }
.skill-card p { margin: 0; color: var(--fg); font-size: 15.5px; line-height: 1.6; }
@media (max-width: 640px) { .skills-grid { grid-template-columns: 1fr; } }

/* ---------- Project dossier cards ---------- */
.dossier-grid { display: grid; grid-template-columns: 1fr; gap: 34px; }
.dossier {
  background: var(--paper); color: var(--ink); border-radius: 3px; padding: 32px 34px;
  box-shadow: 0 14px 30px rgba(0,0,0,.35);
  position: relative;
}
.dossier:nth-child(odd) { transform: rotate(-0.4deg); }
.dossier:nth-child(even) { transform: rotate(0.35deg); }
.dossier::before {
  content: ''; position: absolute; top: 14px; left: 22px; width: 8px; height: 8px; border-radius: 50%;
  background: var(--accent); box-shadow: 0 1px 2px rgba(0,0,0,.4);
}
.dossier-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; flex-wrap: wrap; gap: 10px; }
.dossier h3 { font-family: var(--mono); font-size: 21px; margin: 0; color: var(--ink); letter-spacing: -0.01em; }
.status-pill {
  font-family: var(--mono); font-size: 10.5px; letter-spacing: .08em; text-transform: uppercase;
  padding: 4px 10px; border-radius: 20px; border: 1px solid var(--ink); color: var(--ink);
}
.status-pill.live { background: var(--accent); border-color: var(--accent); color: var(--paper); }
.dossier p.blurb { font-size: 16px; line-height: 1.6; margin: 0 0 18px; color: var(--ink); }
.dossier .meta { font-family: var(--mono); font-size: 12px; color: var(--ink-soft); margin-bottom: 18px; }
.dossier .meta span:not(:last-child)::after { content: ' · '; }
.dossier a.open {
  font-family: var(--mono); font-size: 13px; text-decoration: none; color: var(--ink); font-weight: 600;
  border-bottom: 1px solid var(--ink);
}
.dossier a.open:hover { color: var(--accent); border-color: var(--accent); }

/* ---------- Footer ---------- */
footer.section { border-top: 1px solid var(--line-soft); }
.contact-list { display: flex; flex-direction: column; gap: 10px; margin-bottom: 38px; }
.contact-list a { font-family: var(--mono); font-size: 15px; text-decoration: none; color: var(--fg); width: fit-content; border-bottom: 1px solid transparent; }
.contact-list a:hover { color: var(--accent); border-color: var(--accent); }
.end-mark { text-align: center; font-family: var(--mono); font-size: 11px; letter-spacing: .2em; color: var(--muted); text-transform: uppercase; }

/* ---------- Case study pages ---------- */
.case-hero { padding-top: 40px;}
.case-body { padding-top: 0px; }
.case-body h4 {
  font-family: var(--mono); font-size: 12.5px; letter-spacing: .1em; text-transform: uppercase; color: var(--accent);
  margin: 0 0 16px;
}
.case-body .lede { font-size: 18px; max-width: 68ch; margin: 0 0 46px; }
.role-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 26px; margin-bottom: 46px; }
.role-card { border-left: 2px solid var(--line); padding-left: 20px; }
.role-card .who { font-family: var(--mono); font-size: 13px; color: var(--paper); letter-spacing: .04em; margin-bottom: 8px; }
.role-card p { margin: 0; font-size: 15.5px; color: var(--fg); }
@media (max-width: 640px) { .role-grid { grid-template-columns: 1fr; } }

.figure {
  border: 1px dashed var(--line); border-radius: 2px; padding: 46px 20px; text-align: center;
  font-family: var(--mono); font-size: 12.5px; color: var(--muted); letter-spacing: .04em; margin-bottom: 46px;
}

/* ---------- Carousel (mixed image / YouTube slides) ---------- */
.carousel {
  position: relative; width: 100%; padding-bottom: 56.25%; height: 0; overflow: hidden;
  border: 1px solid var(--line); border-radius: 2px; background: var(--bg-alt); margin-bottom: 20px;
}
.carousel-slide { position: absolute; inset: 0; opacity: 0; transition: opacity .7s ease; }
.carousel-slide.active { opacity: 1; z-index: 1; }

/* MODIFICA: Questo impedisce alle immagini verticali di zoommare e deformarsi */
.carousel-slide img { 
  width: 100%; 
  height: 100%; 
  object-fit: contain; 
  display: block; 
}

.carousel-slide iframe { position: absolute; top: 0; left: 0; width: 100%; height: 100%; border: 0; }
.carousel-dots { position: absolute; bottom: 14px; left: 50%; transform: translateX(-50%); display: flex; gap: 8px; z-index: 2; }
.carousel-dots button {
  width: 8px; height: 8px; border-radius: 50%; border: 1px solid var(--paper); background: transparent;
  padding: 0; cursor: pointer; opacity: .55;
}
.carousel-dots button.active { background: var(--accent); border-color: var(--accent); opacity: 1; }

/* ---------- Single video embed (used standalone, e.g. showcase grid) ---------- */
.video-embed {
  position: relative; width: 100%; padding-bottom: 56.25%; height: 0; overflow: hidden;
  border: 1px solid var(--line); border-radius: 2px; background: var(--bg-alt);
}
.video-embed iframe { position: absolute; top: 0; left: 0; width: 100%; height: 100%; border: 0; }

/* ---------- Showcase grid (archive of older titles) ---------- */
.showcase-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 30px; }
.showcase-item .video-embed { margin-bottom: 10px; }
.showcase-item h5 { font-family: var(--mono); font-size: 14.5px; margin: 0; color: var(--paper); letter-spacing: .01em; }
@media (max-width: 640px) { .showcase-grid { grid-template-columns: 1fr; } }

/* ---------- Hero photo ---------- */
.hero-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 30px; flex-wrap: wrap; }
.hero-text { flex: 1; min-width: 280px; }
.hero-photo {
  width: 176px; height: 176px; border-radius: 50%; overflow: hidden; flex-shrink: 0;
  border: 2px solid var(--line); background: var(--bg-alt);
}
.hero-photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
@media (max-width: 640px) { .hero-photo { width: 120px; height: 120px; } }

.stat-row { display: flex; flex-wrap: wrap; gap: 0; margin-bottom: 20px; }
.stat-row div { padding: 0 30px 0 0; margin-right: 30px; border-right: 1px solid var(--line); }
.stat-row div:last-child { border-right: none; }
.stat-row .n { display: block; font-family: var(--mono); font-weight: 700; font-size: 30px; color: var(--paper); }
.stat-row .l { font-family: var(--mono); font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.pub-line { font-family: var(--mono); font-size: 13.5px; color: var(--fg); margin-bottom: 46px; }

.titles-list { display: flex; flex-direction: column; gap: 30px; margin-bottom: 10px; }
.title-block h5 { font-family: var(--mono); font-size: 17px; margin: 0 0 6px; color: var(--paper); }
.title-block p { margin: 0; font-size: 15.5px; color: var(--fg); }

@media (max-width: 560px) {
  .wrap { padding: 0 20px; }
  .meta-row div, .stat-row div { border-right: none; margin-right: 0; padding-right: 0; width: 50%; margin-bottom: 14px; }
}