/* ============================================================
   Elena Cavallin — portfolio
   Tokens + shared layout (dark, accento verdeacqua)
   ============================================================ */

/* Recursive — file VARIABILE completo (tutti gli assi: MONO, CASL, slnt, CRSV, wght).
   Le css2 di Google servono solo istanze statiche con slnt/CASL/CRSV bloccati a 0,
   quindi il corsivo inclinato non funzionava: qui carichiamo il vero variable font. */
@font-face {
  font-family: "Recursive";
  font-style: normal;
  font-weight: 300 1000;
  font-display: swap;
  src: url("https://cdn.jsdelivr.net/npm/@fontsource-variable/recursive/files/recursive-latin-full-normal.woff2") format("woff2");
}

:root {
  --accent: #7df3e1;
  --bg: #101213;
  --bg-2: #16191a;
  --ink: #eceae6;
  --ink-dim: #9b9f9e;
  --line: #2a2e2f;
  --card: #1a1e1f;
  --radius: 14px;
  --pad: clamp(20px, 4vw, 56px);
  --font-display: "Recursive", "Helvetica Neue", Helvetica, Arial, sans-serif;
  --font-body: "Helvetica Neue", Helvetica, Arial, sans-serif;
  --font-mono: "Recursive", "SF Mono", ui-monospace, Menlo, monospace;
  --display-variation: "CASL" 1, "MONO" 0;
  --mono-variation: "CASL" 0.5, "MONO" 1;
  /* trattamento "firma": Recursive casual + corsivo inclinato (come da reference) */
  --name-variation: "MONO" 0, "CASL" 0.5, "slnt" -15, "CRSV" 1, "wght" 820;
  /* lista progetti: stessa firma corsiva della figura, peso tarato per molti titoli */
  --list-variation: "MONO" 0, "CASL" 0.5, "slnt" -15, "CRSV" 1, "wght" 700;
}

html[data-theme="light"] {
  --bg: #f2efe9;
  --bg-2: #eae6de;
  --ink: #161616;
  --ink-dim: #6f6d68;
  --line: #d8d3c9;
  --card: #faf8f4;
}

html[data-type="grotesk"] {
  --font-display: "Helvetica Neue", Helvetica, Arial, sans-serif;
  --font-mono: "SF Mono", ui-monospace, Menlo, monospace;
  --display-variation: normal;
  --mono-variation: normal;
}
html[data-type="editorial"] {
  --font-display: "Instrument Serif", Georgia, serif;
  --display-variation: normal;
}
html[data-type="tech"] {
  --font-display: "Space Grotesk", "Helvetica Neue", sans-serif;
  --font-body: "Space Grotesk", "Helvetica Neue", sans-serif;
  --display-variation: normal;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 17px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  transition: background 0.4s ease, color 0.4s ease;
}

::selection { background: var(--accent); color: #0b0d0d; }

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

img { display: block; max-width: 100%; }

/* ---------- language toggle ---------- */
html[data-lang="it"] .lang-en { display: none !important; }
html[data-lang="en"] .lang-it { display: none !important; }

/* ---------- header ---------- */
.site-header {
  position: fixed;
  inset: 0 0 auto 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px var(--pad);
  mix-blend-mode: difference;
  color: #fff;
}

.site-header .logo {
  font-family: var(--font-display);
  font-size: 13px;
  letter-spacing: 0;
  font-variation-settings: "MONO" 0, "CASL" 0.5, "slnt" -15, "CRSV" 1, "wght" 640;
}

.site-nav { display: flex; align-items: center; gap: 26px; }

.site-nav a, .lang-switch button {
  font-size: 14px;
  letter-spacing: 0.02em;
  position: relative;
  cursor: pointer;
}

.site-nav a::after {
  content: "";
  position: absolute;
  left: 0; right: 100%;
  bottom: -4px;
  height: 1px;
  background: currentColor;
  transition: right 0.35s cubic-bezier(0.22, 1, 0.36, 1);
}
.site-nav a:hover::after, .site-nav a[aria-current="page"]::after { right: 0; }

.lang-switch {
  display: flex;
  gap: 2px;
  border: 1px solid rgba(255, 255, 255, 0.4);
  border-radius: 99px;
  padding: 2px;
}
.lang-switch button {
  border: 0;
  background: transparent;
  color: inherit;
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 4px 10px;
  border-radius: 99px;
}
.lang-switch button.on { background: #fff; color: #000; }

/* ---------- marquee ---------- */
.marquee {
  overflow: hidden;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  padding: 14px 0;
  white-space: nowrap;
}
.marquee .track {
  display: inline-flex;
  gap: 48px;
  padding-right: 48px;
  animation: marquee-scroll 28s linear infinite;
  will-change: transform;
}
.marquee span {
  font-family: var(--font-mono);
  font-size: 13px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-dim);
}
.marquee span b { color: var(--accent); font-weight: 500; }
@keyframes marquee-scroll {
  from { transform: translateX(0); }
  to { transform: translateX(-50%); }
}
html[data-motion="min"] .marquee .track { animation: none; }

/* ---------- reveal on scroll ---------- */
.reveal {
  opacity: 0;
  transform: translateY(26px);
  transition: opacity 0.7s ease, transform 0.7s cubic-bezier(0.22, 1, 0.36, 1);
}
.reveal.in { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) {
  .reveal { opacity: 1; transform: none; transition: none; }
  .marquee .track { animation: none; }
}
html[data-motion="min"] .reveal { opacity: 1; transform: none; transition: none; }

/* ---------- section scaffolding ---------- */
.section { padding: clamp(60px, 9vw, 130px) var(--pad); }

.section-tag {
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 0 0 28px 0;
  display: flex;
  align-items: center;
  gap: 12px;
}
.section-tag::after {
  content: "";
  height: 1px;
  flex: 1;
  background: var(--line);
}

h1, h2, h3 {
  font-family: var(--font-display);
  font-weight: 520;
  font-variation-settings: var(--display-variation);
  margin: 0;
}

.section-tag, .marquee span, .footer-cta, .work-meta .year,
.overlay-head .year, .overlay-role {
  font-variation-settings: var(--mono-variation);
}

/* ---------- works grid ---------- */
.works-grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: clamp(18px, 2.6vw, 36px);
}

.work-card { grid-column: span 6; cursor: pointer; }
.work-card.w-lg { grid-column: span 7; }
.work-card.w-sm { grid-column: span 5; }
.work-card.w-third { grid-column: span 4; }

@media (max-width: 900px) {
  .work-card, .work-card.w-lg, .work-card.w-sm, .work-card.w-third { grid-column: span 12; }
}

.work-media {
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  aspect-ratio: 16 / 10;
  background: var(--card);
}
.work-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.8s cubic-bezier(0.22, 1, 0.36, 1), filter 0.5s ease;
}
.work-card:hover .work-media img { transform: scale(1.045); }

.work-media .view-tag {
  position: absolute;
  inset: auto auto 14px 14px;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  background: var(--accent);
  color: #0b0d0d;
  padding: 7px 13px;
  border-radius: 99px;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.35s ease, transform 0.35s ease;
}
.work-card:hover .view-tag { opacity: 1; transform: none; }

.work-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: repeating-linear-gradient(
    -45deg,
    var(--card) 0 14px,
    color-mix(in oklab, var(--card) 88%, var(--ink)) 14px 15px
  );
}
.work-placeholder span {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--ink-dim);
  background: var(--bg);
  border: 1px solid var(--line);
  padding: 6px 12px;
  border-radius: 8px;
}

.work-meta {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 4px 0 4px;
}
.work-meta h3 { font-size: clamp(20px, 2.1vw, 26px); letter-spacing: 0.01em; }
.work-meta .year {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--ink-dim);
}
.work-tags {
  padding: 4px 4px 0 4px;
  font-size: 13.5px;
  color: var(--ink-dim);
}

/* ---------- project overlay ---------- */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: color-mix(in oklab, var(--bg) 72%, black);
  backdrop-filter: blur(6px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.35s ease;
  overflow-y: auto;
}
.overlay.open { opacity: 1; pointer-events: auto; }

.overlay-panel {
  max-width: 1060px;
  margin: 7vh auto 8vh auto;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 20px;
  overflow: hidden;
  transform: translateY(40px);
  transition: transform 0.45s cubic-bezier(0.22, 1, 0.36, 1);
}
.overlay.open .overlay-panel { transform: none; }

.overlay-hero { aspect-ratio: 16 / 8; background: var(--card); }
.overlay-hero img { width: 100%; height: 100%; object-fit: cover; }

.overlay-body { padding: clamp(26px, 4vw, 52px); }

.overlay-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 18px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}
.overlay-head h2 { font-size: clamp(30px, 4vw, 48px); }
.overlay-head .year { font-family: var(--font-mono); font-size: 13px; color: var(--accent); }

.overlay-role {
  font-family: var(--font-mono);
  font-size: 12.5px;
  letter-spacing: 0.04em;
  color: var(--ink-dim);
  text-transform: uppercase;
  margin: 0 0 22px 0;
}

.overlay-desc { max-width: 64ch; font-size: 16.5px; color: var(--ink); }
.overlay-desc p { margin: 0 0 14px 0; }

.overlay-extra { margin-top: 30px; border-radius: var(--radius); overflow: hidden; }

.overlay-close {
  position: sticky;
  top: 16px;
  margin-left: calc(100% - 60px);
  margin-right: 16px;
  margin-top: -52px;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 0;
  background: var(--accent);
  color: #0b0d0d;
  font-size: 18px;
  cursor: pointer;
  z-index: 5;
}

/* ---------- footer ---------- */
.site-footer {
  padding: clamp(50px, 7vw, 100px) var(--pad) 40px var(--pad);
}
.footer-cta { font-size: clamp(18px, 1.8vw, 24px); color: var(--ink-dim); margin: 0 0 10px 0; font-family: var(--font-display); font-variation-settings: var(--list-variation); text-transform: none; letter-spacing: 0; }
.footer-mail {
  font-family: var(--font-display);
  font-variation-settings: var(--list-variation);
  font-size: clamp(30px, 5.4vw, 72px);
  letter-spacing: 0;
  display: inline-block;
  position: relative;
  /* non può mai essere più larga della colonna: era lei a far scorrere la
     pagina di lato sul telefono */
  max-width: 100%;
  line-height: 1.06;
}
.footer-mail::after {
  content: "";
  position: absolute;
  left: 0; right: 100%;
  bottom: 0;
  height: 2px;
  background: var(--accent);
  transition: right 0.4s cubic-bezier(0.22, 1, 0.36, 1);
}
.footer-mail:hover::after { right: 0; }

.footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 28px;
  margin-top: 40px;
}
.footer-links a {
  font-size: 14px;
  max-width: 100%;
  overflow-wrap: anywhere;
  color: var(--ink-dim);
  border-bottom: 1px solid transparent;
  transition: color 0.25s ease, border-color 0.25s ease;
}
.footer-links a:hover { color: var(--accent); border-color: var(--accent); }

.footer-base {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 56px;
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--ink-dim);
}

/* ---------- menu mobile ----------
   Sotto i 700px l'header non regge logo + voci + lingua: le voci passano in un
   pannello a tutto schermo aperto dal segno ✲, che ruota in croce quando è aperto.
   Il pannello sta sotto l'header (z 55 contro 60) così il segno resta cliccabile. */
.nav-toggle { display: none; }
.nav-panel { display: none; }

@media (max-width: 700px) {
  .site-header .site-nav { display: none; }

  .nav-toggle {
    display: block;
    border: 0;
    background: transparent;
    color: inherit;
    font-family: var(--font-display);
    /* asterisco di Recursive, diritto: la variante «firma» del nome porta con sé
       corsivo e inclinazione, qui non servono */
    font-variation-settings: "CASL" 1, "MONO" 0, "wght" 500;
    font-size: 30px;
    line-height: 1;
    cursor: pointer;
    /* riquadro fisso: dentro ci stanno sia l'asterisco sia il pallino, così
       passando da uno all'altro il segno non si sposta */
    width: 30px;
    height: 30px;
    padding: 0;
    box-sizing: border-box;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.45s cubic-bezier(0.22, 1, 0.36, 1);
  }
  /* il glifo * ha l'inchiostro in alto nella riga: lo scendo dentro il riquadro
     finché il suo centro coincide con quello del pallino */
  .nav-toggle > span {
    display: block;
    transform: translate(1px, 5px);   /* calibrato sul centro del pallino */
  }
  /* aperto: il ✲ lascia il posto a un pallino disegnato, stesso peso di segno */
  html.nav-open .nav-toggle { transform: rotate(90deg); }
  html.nav-open .nav-toggle > span { display: none; }
  html.nav-open .nav-toggle::before {
    content: "";
    display: block;
    width: 11px;
    height: 11px;
    border-radius: 50%;
    background: currentColor;
  }

  .nav-panel {
    display: flex;
    position: fixed;
    inset: 0;
    z-index: 55;
    flex-direction: column;
    justify-content: center;
    align-items: flex-start;
    gap: 18px;
    padding: 0 var(--pad);
    background: var(--bg);
    color: var(--ink);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
  }
  html.nav-open .nav-panel { opacity: 1; pointer-events: auto; }
  html.nav-open body { overflow: hidden; }

  .nav-panel a {
    font-family: var(--font-display);
    font-variation-settings: var(--list-variation);
    font-size: clamp(34px, 12vw, 54px);
    line-height: 1.02;
    color: var(--ink);
    opacity: 0.55;
    transform: translateY(12px);
    transition: opacity 0.4s ease, transform 0.4s cubic-bezier(0.22, 1, 0.36, 1);
  }
  .nav-panel a[aria-current="page"] { opacity: 1; }
  html.nav-open .nav-panel a { transform: none; }
  .nav-panel a:nth-child(2) { transition-delay: 0.05s; }

  .nav-panel .lang-switch {
    margin-top: 18px;
    border-color: var(--line);
    color: var(--ink);
  }
  .nav-panel .lang-switch button.on { background: var(--ink); color: var(--bg); }

  /* lo switch spirale/lista sta nella stessa fascia dell'header: sul telefono
     scende in basso, dove il pollice arriva, e sparisce a menu aperto */
  body .view-toggle {
    top: auto;
    bottom: calc(18px + env(safe-area-inset-bottom, 0px));
  }
  html.nav-open .view-toggle { opacity: 0; pointer-events: none; }

  /* ---------- footer sul telefono ---------- */
  /* 27 caratteri a 30px non stanno in 390px di schermo: la mail sbordava e la
     pagina si poteva trascinare di lato. Corpo ridotto + a capo alla chiocciola. */
  .footer-mail { font-size: clamp(22px, 8.4vw, 40px); }
  .footer-links { gap: 10px 20px; margin-top: 28px; }
  .footer-links a { font-size: 13px; }

  /* rete di sicurezza: niente scorrimento orizzontale sulle pagine lunghe.
     `clip` e non `hidden`: hidden trasformerebbe il body in contenitore di
     scroll e romperebbe il position:sticky dell'intro di about. */
  body { overflow-x: clip; }
}


/* ---------- cursore a pallino ----------
   Solo su puntatore fine (mouse/trackpad): il dito non ha un cursore da sostituire.
   Stesso pallino ovunque: verdeacqua sul fondo, bianco su ciò che si può cliccare. */
@media (hover: hover) and (pointer: fine) {
  html,
  html body {
    cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='22' height='22'%3E%3Ccircle cx='11' cy='11' r='9' fill='%237df3e1'/%3E%3C/svg%3E") 11 11, auto;
  }
  html a,
  html button,
  html [role="button"],
  html .work-card,
  html .spiral-card,
  html .pub,
  html .biglist-row,
  html .next-preview,
  html .nav-toggle,
  html body .spiral-stage,
  html body .spiral-stage:active,
  html .view-toggle button,
  html .view-toggle a,
  html .ps-rail,
  html .ps-rail.ps-dragging,
  html .ps-card,
  html .pm-close,
  html .car-nav button,
  html .car-dots span,
  html .work-card,
  html .site-nav a {
    cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='22' height='22'%3E%3Ccircle cx='11' cy='11' r='9' fill='%23f2efe9'/%3E%3C/svg%3E") 11 11, pointer;
  }
  html input,
  html textarea,
  html select {
    cursor: text;
  }

  /* tema chiaro: il pallino bianco sparirebbe sul fondo chiaro, lì diventa scuro */
  html[data-theme="light"] a,
  html[data-theme="light"] button,
  html[data-theme="light"] [role="button"],
  html[data-theme="light"] .work-card,
  html[data-theme="light"] .spiral-card,
  html[data-theme="light"] .pub,
  html[data-theme="light"] .biglist-row,
  html[data-theme="light"] .next-preview,
  html[data-theme="light"] .nav-toggle,
  html[data-theme="light"] body .spiral-stage,
  html[data-theme="light"] .view-toggle button,
  html[data-theme="light"] .view-toggle a,
  html[data-theme="light"] .ps-rail,
  html[data-theme="light"] .ps-card,
  html[data-theme="light"] .pm-close,
  html[data-theme="light"] .car-nav button,
  html[data-theme="light"] .car-dots span,
  html[data-theme="light"] .site-nav a {
    cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='22' height='22'%3E%3Ccircle cx='11' cy='11' r='9' fill='%23161616'/%3E%3C/svg%3E") 11 11, pointer;
  }
}
