/* ==========================================================
   Cristina Cavicchini — Designer
   Valori presi dal file Figma "lezione #3" (frame 1512 × 982 / 402 × 874)
   ========================================================== */

:root {
  --bg: #ffffff;
  --fg: #000000;
  --fg-50: rgba(0, 0, 0, 0.5);
  --fg-20: rgba(0, 0, 0, 0.2);
  --muted: #707070; /* contrasto 4,95:1 sul bianco (WCAG AA) */
  --row-hover: #f5f5f5;
  --accent: #4bfb00;
  --bar: #1b1b20;

  --gutter: 48px;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
  --sans: "Inter", system-ui, sans-serif;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

/* Pagine scure: Contact e Zara */
body[data-theme="dark"] {
  --bg: #000000;
  --fg: #ffffff;
  --fg-50: rgba(255, 255, 255, 0.5);
  --fg-20: rgba(255, 255, 255, 0.2);
  --muted: rgba(255, 255, 255, 0.5);
  --row-hover: rgba(255, 255, 255, 0.08);
}

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

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--mono);
  font-weight: 500;
  font-size: 16px;
  line-height: normal;
  transition: background-color 0.6s var(--ease), color 0.6s var(--ease);
  overflow-x: hidden;
}

a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
img { display: block; max-width: 100%; }
ul { list-style: none; margin: 0; padding: 0; }
p { margin: 0; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

/* ---------- Viste ---------- */
.view { display: none; }
body[data-route="home"] .view-home,
body[data-route="works"] .view-works,
body[data-route="project"] .view-project,
body[data-route="contact"] .view-contact { display: block; }

/* Immagine che vola dalla griglia/carosello alla prima slide (motion.js) */
.flip-clone {
  position: fixed;
  z-index: 60;
  margin: 0;
  object-fit: cover;
  pointer-events: none;
}

/* ==========================================================
   HEADER — Inter Black 38.15px, letter-spacing -5%
   ========================================================== */
.site-header {
  position: absolute;
  top: var(--gutter);
  left: var(--gutter);
  width: 329px;
  display: flex;
  flex-direction: column;
  gap: 26px;
  z-index: 20;
}

.title {
  display: flex;
  flex-direction: column;
  font-family: var(--sans);
  font-weight: 900;
  font-size: 38.15px;
  line-height: 46px;
  letter-spacing: -0.05em;
  color: var(--fg);
  white-space: nowrap;
}
.title span + span { margin-top: -22px; }

.menu {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 24px;
}
.menu a {
  color: var(--fg-50);
  transition: color 0.6s var(--ease);
}
.menu a.is-active { color: var(--fg); }
/* Hover: la voce sotto il mouse diventa attiva, le altre al 50% */
.menu:hover a { color: var(--fg-50); }
.menu:hover a:hover { color: var(--fg); }

/* Works: header dentro una fascia bianca fissa ("Sticky", 185px) */
body[data-route="works"] .site-header { position: fixed; }
.works-sticky {
  position: fixed;
  inset: 0 0 auto 0;
  height: 185px;
  background: var(--bg);
  z-index: 10;
}

/* Pagine progetto: solo menu centrato in alto */
body[data-route="project"] .site-header {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
}
body[data-route="project"] .title { display: none; }

/* ==========================================================
   MUSIC PLAYER — 339 × 67, bordo 1px 20%, raggio 4
   ========================================================== */
.player {
  position: absolute;
  top: 56px;
  right: var(--gutter);
  width: 339px;
  z-index: 20;
  display: none;
}
/* Presente in tutte le pagine; su Works resta fisso nella fascia bianca in alto */
body .player { display: block; }
body[data-route="works"] .player { position: fixed; }

.player-box {
  border: 1px solid var(--fg-20);
  border-radius: 4px;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 9px;
}
.player-main {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 27px;
}
.progress {
  height: 3px;
  border-radius: 4px;
  background: var(--fg-20);
  overflow: hidden;
}
.progress span {
  display: block;
  height: 100%;
  width: 66%;
  border-radius: 4px;
  background: var(--bar);
  transition: width 0.25s linear;
}
body[data-theme="dark"] .progress span { background: rgba(255, 255, 255, 0.35); }

.player-toggle-list {
  display: flex;
  align-items: center;
  gap: 16px;
  text-align: left;
  min-width: 0;
}
.cover {
  width: 37px;
  height: 37px;
  border-radius: 2px;
  object-fit: cover;
  flex: none;
}
.cover-wrap { position: relative; flex: none; display: block; }
.cover-icon { display: none; }

/* Pagine progetto: variante "ICON" (188 × 47) in basso a destra.
   Clic = play/pausa; al passaggio del mouse l'icona compare sulla copertina. */
body[data-route="project"] .player {
  position: fixed;
  top: auto;
  bottom: 27px;
  width: auto;
}
body[data-route="project"] .player-box { padding: 4px 16px 4px 4px; min-width: 188px; }
body[data-route="project"] .player-play,
body[data-route="project"] .progress,
body[data-route="project"] .playlist { display: none !important; }
body[data-route="project"] .cover-icon {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  border-radius: 2px;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  opacity: 0;
  transition: opacity 0.3s var(--ease);
}
body[data-route="project"] .player:hover .cover-icon,
body[data-route="project"] .player-toggle-list:focus-visible .cover-icon { opacity: 1; }
.cover-icon .i-play { display: none; }
.player.is-paused .cover-icon .i-pause { display: none; }
.player.is-paused .cover-icon .i-play { display: block; }
.track {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  height: 29px;
  font-family: var(--sans);
  white-space: nowrap;
}
.song {
  font-weight: 600;
  font-size: 13.5px;
  line-height: 17px;
  letter-spacing: -0.03em;
  color: var(--fg);
}
.artist {
  font-weight: 400;
  font-size: 11.5px;
  line-height: 12px;
  color: var(--muted);
}
.player-play {
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  color: var(--fg);
  flex: none;
}
.player-play .i-play { display: none; }
.player.is-paused .i-pause { display: none; }
.player.is-paused .i-play { display: block; }

/* Stato "Open": playlist sotto al player */
.playlist {
  margin-top: 12px;
  border: 1px solid var(--fg-20);
  border-radius: 4px;
  overflow: hidden;
  display: none;
}
.player.is-open .playlist { display: block; animation: drop 0.3s var(--ease); }
@keyframes drop { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }

.playlist li + li { border-top: 1px solid var(--fg-20); }
.playlist button {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 4px;
  height: 45px;
  text-align: left;
  transition: background-color 0.3s var(--ease);
}
.playlist button:hover,
.playlist button:focus-visible { background: var(--row-hover); }

/* ==========================================================
   HOME — carosello in basso (369 × 228, gap 12)
   ========================================================== */
.view-home { min-height: 100vh; min-height: 100svh; position: relative; }

.carousel {
  position: absolute;
  left: 0;
  right: 0;
  bottom: var(--gutter);
  overflow: hidden;
  z-index: 2;
}
.carousel-track {
  display: flex;
  gap: 12px;
  width: max-content;
  animation: marquee 40s linear infinite;
}
.carousel:hover .carousel-track { animation-play-state: paused; }
.carousel a {
  display: block;
  width: 369px;
  height: 228px;
  flex: none;
  overflow: hidden;
}
.carousel img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.6s var(--ease);
}
.carousel a:hover img { transform: scale(1.04); }

@keyframes marquee {
  from { transform: translateX(-161px); }
  to { transform: translateX(calc(-161px - 50% - 6px)); }
}

.mobile-stack { display: none; }

/* ==========================================================
   WORKS — griglia 2 colonne (696 × 473), gap 24 / 44
   ========================================================== */
.works-grid {
  padding: 194px var(--gutter) 64px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  column-gap: 24px;
  row-gap: 44px;
}
.work-card { display: flex; flex-direction: column; gap: 24px; }
.work-card .thumb {
  display: block;
  aspect-ratio: 696 / 473;
  overflow: hidden;
}
.work-card .thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.6s var(--ease);
}
.work-card .thumb:hover img { transform: scale(1.03); }

.work-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 24px;
}
.work-meta .name { display: flex; gap: 24px; }

.explore {
  text-decoration: underline;
  text-underline-offset: 2px;
  transition: background-color 0.6s var(--ease);
}
.explore:hover,
.explore:focus-visible { background: var(--accent); color: #000; }

/* ==========================================================
   PROGETTO — fascia "About" fissa, slide 940px, gap 25
   ========================================================== */
.project-sticky {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--bg);
  padding: 139px var(--gutter) 48px;
  transition: background-color 0.6s var(--ease);
}
.about {
  width: min(940px, 100%);
  margin: 0 auto;
  display: grid;
  grid-template-columns: auto 1fr;
  column-gap: 71px;
}
.about-label { color: var(--fg-50); }
.about-text {
  font-weight: 600;
  text-align: justify;
  min-height: 64px;
}

.slides {
  width: min(940px, calc(100% - 2 * var(--gutter)));
  margin: 0 auto;
  padding-bottom: 64px;
  display: flex;
  flex-direction: column;
  gap: 25px;
}
.slide { width: 100%; height: auto; }

/* Firme in alto (Figma y = 35), sopra la fascia "About" */
.signature {
  position: fixed;
  top: 35px;
  font-family: var(--sans);
  font-weight: 900;
  font-size: 38.15px;
  line-height: 46px;
  letter-spacing: -0.05em;
  color: var(--fg-50);
  z-index: 15;
}
.signature.left { left: var(--gutter); }
.signature.right { right: var(--gutter); }

/* ==========================================================
   CONTACT — sfondo nero, bio 821px a 369px dall'alto
   ========================================================== */
.view-contact { min-height: 100vh; min-height: 100svh; }
.bio {
  width: min(821px, calc(100% - 2 * var(--gutter)));
  margin-left: var(--gutter);
  padding: 369px 0 var(--gutter);
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.roles {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  color: var(--fg-20);
}
.bio-text { font-weight: 600; text-align: justify; }
.contact-row {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  color: rgba(255, 255, 255, 0.6);
}
.email-link {
  text-decoration: underline;
  text-underline-offset: 2px;
  transition: color 0.3s var(--ease), background-color 0.6s var(--ease);
}
.email-link:hover { color: #000; background: var(--accent); }

/* ==========================================================
   CURSORE "CLick me?" — segue il mouse (solo dispositivi con mouse)
   ========================================================== */
.cursor,
.cursor-label {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 100;
  pointer-events: none;
  display: none;
}
.cursor svg { display: block; }
/* Testo bianco in "difference": nero sul bianco, bianco su nero e sulle immagini */
.cursor-label {
  white-space: nowrap;
  color: #fff;
  mix-blend-mode: difference;
}

@media (hover: hover) and (pointer: fine) and (min-width: 768px) {
  body.has-cursor, body.has-cursor a, body.has-cursor button { cursor: none; }
  body.has-cursor .cursor,
  body.has-cursor .cursor-label { display: block; }
}

/* ==========================================================
   Desktop stretti: firme nascoste se toccherebbero il menu centrato
   ========================================================== */
@media (max-width: 1080px) {
  .signature { display: none; }
}

@media (max-width: 1100px) and (min-width: 768px) {
  .about { column-gap: 40px; }
  .player { width: 300px; }
}

/* ==========================================================
   MOBILE — frame iPhone 402 × 874
   ========================================================== */
@media (max-width: 767px) {
  :root { --gutter: 16px; }

  /* Titolo centrato in alto, in "exclusion" sopra le immagini */
  /* L'header non crea un contesto proprio: titolo e menu sono fissati
     separatamente, così il "exclusion" del titolo si fonde con la pagina */
  .site-header { display: contents; }

  .title,
  body[data-route="project"] .title {
    position: fixed;
    top: 34px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 20;
    align-items: center;
    text-align: center;
    color: #fff;
    mix-blend-mode: exclusion;
  }
  body[data-route="project"] .title { display: flex; }
  body[data-route="home"] .title { top: 67px; }

  /* Barra menu in basso: nera su pagine chiare, bianca su Contact */
  .menu {
    position: fixed;
    bottom: 34px;
    left: 50%;
    transform: translateX(-50%);
    width: min(327px, calc(100% - 32px));
    z-index: 20;
    background: #000;
    padding: 8px;
  }
  .menu a {
    color: rgba(255, 255, 255, 0.5);
    -webkit-tap-highlight-color: transparent;
    transition: color 0.3s var(--ease), background-color 0.3s var(--ease), box-shadow 0.3s var(--ease);
  }
  .menu a.is-active { color: #fff; }
  .menu:hover a { color: rgba(255, 255, 255, 0.5); }
  .menu:hover a.is-active { color: #fff; }
  /* Voce toccata: evidenziata in bianco (lo shadow allarga il fondo senza spostare il layout) */
  .menu a:hover,
  .menu a:active,
  .menu:hover a:hover,
  .menu a:focus-visible {
    color: #000;
    background: #fff;
    box-shadow: 0 0 0 4px #fff;
    outline: none;
  }

  body[data-theme="dark"] .menu { background: #fff; }
  body[data-theme="dark"] .menu a { color: rgba(0, 0, 0, 0.5); }
  body[data-theme="dark"] .menu a.is-active { color: #000; }
  /* Su Contact la barra è bianca: la voce toccata si inverte in nero */
  body[data-theme="dark"] .menu a:hover,
  body[data-theme="dark"] .menu a:active,
  body[data-theme="dark"] .menu a:focus-visible {
    color: #fff;
    background: #000;
    box-shadow: 0 0 0 4px #000;
  }

  .player { display: none !important; }
  .works-sticky { display: none; }
  .signature { display: none; }

  /* Home: immagini a tutta larghezza (402 × 204, gap 16) */
  .carousel { display: none; }
  .mobile-stack {
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding: 156px 0 120px;
  }
  .mobile-stack a { display: block; aspect-ratio: 402 / 204; overflow: hidden; }
  .mobile-stack img { width: 100%; height: 100%; object-fit: cover; }

  /* Works: griglia 2 colonne (177 × 163) */
  .works-grid {
    padding: 151px 16px 120px;
    column-gap: 16px;
    row-gap: 29px;
  }
  .work-card { gap: 12.8px; }
  .work-card .thumb { aspect-ratio: 177 / 163; }
  .work-meta {
    flex-direction: column;
    align-items: flex-start;
    gap: 6.4px;
    font-size: 11.2px;
  }
  .work-meta .name { width: 100%; justify-content: space-between; gap: 8px; }

  /* Progetto */
  .project-sticky { position: static; padding: 140px 16px 24px; }
  .about { grid-template-columns: 1fr; row-gap: 12px; }
  .about-text { font-size: 14px; }
  .slides { width: 100%; gap: 12px; padding-bottom: 120px; }

  /* Contact (Bio 280px) */
  .bio {
    width: min(280px, calc(100% - 32px));
    margin: 0 auto;
    padding: 147px 0 120px;
  }
  .roles {
    flex-direction: column;
    gap: 16px;
    font-size: 14px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
