/* ==========================================================================
/* ==========================================================================
   Mindglass — Alex Calcatelli · portfolio index
   Static stylesheet. All page styling lives here (no inline styles in HTML).

   Theme is switched by toggling the  data-paper  attribute on <html>
   ("dark" default, "white" light) — see assets/js/app.js.
   ========================================================================== */

/* Web fonts (Geist, Geist Mono, Instrument Serif) are loaded from Google
   Fonts via the <link> in index.html <head>. The font-family stacks below
   keep system fallbacks in case the CDN is unavailable.                    */

/* --------------------------------------------------------------- Tokens -- */
:root {
  --mg-display: "Instrument Serif", "Times New Roman", serif;
  --mg-sans:    "Geist", -apple-system, system-ui, sans-serif;
  --mg-mono:    "Geist Mono", ui-monospace, monospace;

  /* dark theme (default) */
  --mg-paper: #15140f;
  --mg-ink:   #f0ebde;
  --mg-rule:  rgba(240, 235, 222, 0.14);
  --mg-mute:  rgba(240, 235, 222, 0.5);
  --mg-accent: #2fc5d6;
}

html[data-paper="white"] {
  --mg-paper: #fafaf8;
  --mg-ink:   #0e0e0c;
  --mg-rule:  rgba(14, 14, 12, 0.12);
  --mg-mute:  rgba(14, 14, 12, 0.5);
}

/* --------------------------------------------------------------- Reset --- */
html,
body {
  margin: 0;
  padding: 0;
  background: var(--mg-paper);
}

body {
  font-family: var(--mg-sans);
  color: var(--mg-ink);
}

img {
  display: block;
}

svg {
  display: block;
}

/* Logo is a dark SVG — invert it on the dark paper so it stays legible */
.mg-logo {
  transition: filter 160ms ease;
}

html[data-paper="dark"] .mg-logo {
  filter: invert(1) brightness(1.05);
}

/* --------------------------------------------------------------- Page ---- */
.page {
  width: 100%;
  background: var(--mg-paper);
  color: var(--mg-ink);
  font-family: var(--mg-mono);
  position: relative;
  overflow: hidden;
}

.muted {
  color: var(--mg-mute);
}

/* ========================================================== Header ====== */
.site-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  padding: 20px 40px;
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 24px;
  align-items: center;
  font-size: 12px;
  letter-spacing: 0.04em;
  background: color-mix(in oklab, var(--mg-paper) 85%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  transform: translateY(0);
  transition: transform 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.site-header.hdr-hidden {
  transform: translateY(-100%);
}

.hdr-logo {
  grid-column: 1 / span 3;
  display: flex;
  align-items: center;
  gap: 10px;
}

.hdr-logo a {
  display: inline-flex;
  align-items: center;
  color: inherit;
  text-decoration: none;
}

.hdr-logo .mg-logo {
  height: 32px;
  width: auto;
}

.hdr-tagline {
  grid-column: 4 / span 5;
  color: var(--mg-mute);
  align-self: center;
}

.hdr-nav {
  grid-column: 9 / span 4;
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 22px;
}

.hdr-open {
  color: var(--mg-accent);
}

/* ----------------------------------------------------- Theme toggle ----- */
.theme-pill {
  position: relative;
  width: 38px;
  height: 22px;
  padding: 0;
  margin: 0;
  border: none;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.16);
  cursor: pointer;
  line-height: 0;
  vertical-align: middle;
  box-sizing: border-box;
  overflow: hidden;
  transition: background 220ms ease;
}

html[data-paper="white"] .theme-pill {
  background: rgba(0, 0, 0, 0.12);
}

.theme-thumb {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  border-radius: 999px;
  background: #fafaf8;
  transition: transform 260ms cubic-bezier(0.32, 0.72, 0.18, 1),
              background 220ms ease;
}

.theme-pill[aria-checked="true"] .theme-thumb {
  transform: translateX(16px);
  background: #fafaf8;
}

.theme-pill[aria-checked="false"] .theme-thumb {
  transform: translateX(0);
  background: #15140f;
}

/* ============================================================= Bio ====== */
.bio {
  padding: 120px 40px 100px;
  border-bottom: 1px solid var(--mg-rule);
}

.bio-headline {
  margin: 0;
  font-family: var(--mg-mono);
  font-weight: 400;
  font-size: 22px;
  line-height: 1.45;
  letter-spacing: 0;
  max-width: 720px;
}

/* ====================================================== Works label ==== */
.works-label {
  padding: 40px 40px 24px;
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--mg-mute);
}
.works-label-mob { display: none; }

/* =========================================================== Works ===== */
.works {
  padding: 0 40px 96px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.project {
  position: relative;
}

/* ------------------------------------------------- Hover image slider --- */
/* Stepped slider. While the row is hovered the track advances ONE image at a
   time (dwell -> slide -> dwell ...) and loops seamlessly. The motion itself
   is driven by assets/js/app.js, which sets the inline transform/transition
   on .v3-track. CSS here only sizes the slides and clips the viewport.
   Direction alternates per project via the data-dir attribute.            */
.v3-slider {
  /* size container so 'cqw' resolves against the slider's own width */
  container-type: inline-size;
  position: relative;
  overflow: hidden;
  width: 100%;
}

.v3-track {
  display: flex;
  gap: 16px;
  will-change: transform;
  /* transform + transition are applied at runtime by app.js */
}

.v3-slide {
  /* two slides visible at rest on desktop: (viewport - 1 gap) / 2 */
  width: calc((100cqw - 16px) / 2);
  flex-shrink: 0;
}

/* ----------------------------------------------------------- Cover ----- */
.cover {
  width: 100%;
  aspect-ratio: 4 / 3;
  position: relative;
  overflow: hidden;
  border-radius: 4px;
  background: oklch(0.92 0.04 var(--hue, 0));
}

.cover img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* ---------------------------------------------------------- Caption ---- */
.caption {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 16px;
  margin-top: 12px;
  padding: 0 6px;
  font-family: var(--mg-mono);
  font-size: 12px;
  letter-spacing: 0.02em;
}

.caption-left {
  display: flex;
  gap: 14px;
  align-items: baseline;
  min-width: 0;
}

.caption-n {
  color: var(--mg-mute);
}

.caption-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.caption-client {
  color: var(--mg-mute);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.caption-year {
  color: var(--mg-mute);
  white-space: nowrap;
}

/* ========================================================== Footer ===== */
.site-footer {
  border-top: 1px solid var(--mg-rule);
  padding: 80px 40px 48px;
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 32px;
  color: var(--mg-ink);
}

.foot-brand {
  grid-column: 1 / span 5;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 18px;
}

.foot-logo {
  height: 96px;
  width: auto;
}

.foot-tagline {
  font-family: var(--mg-mono);
  font-size: 15px;
  letter-spacing: 0.02em;
  color: var(--mg-mute);
}

.foot-contact {
  grid-column: 7 / span 6;
  display: flex;
  flex-direction: column;
  gap: 14px;
  font-family: var(--mg-sans);
  font-size: 14px;
  line-height: 1.5;
}

.foot-row {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 16px;
}

.foot-key {
  font-family: var(--mg-mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--mg-mute);
  padding-top: 3px;
}

.foot-copy {
  margin-top: 18px;
  font-family: var(--mg-mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  color: var(--mg-mute);
}

/* ======================================================== Responsive === */
@media (max-width: 760px) {

  /* one image per row on narrow screens */
  .v3-slide {
    width: 100cqw;
  }

  .site-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 18px 20px;
    font-size: 11px;
  }

  .hdr-logo .mg-logo {
    height: 14px;
  }

  .hdr-tagline {
    display: none;
  }

  .hdr-nav {
    gap: 14px;
  }

  .hdr-nav > span:nth-child(1),
  .hdr-nav > span:nth-child(2),
  .hdr-nav > span:nth-child(3) {
    display: none;
  }

  .bio {
    padding: 56px 20px 44px;
  }

  .bio-headline {
    font-size: 14px;
    line-height: 1.5;
  }

  .works-label {
    padding: 24px 20px 16px;
    font-size: 10px;
  }
  .works-label-desk { display: none; }
  .works-label-mob  { display: inline; }

  .works {
    padding: 0 20px 48px;
    gap: 12px;
  }

  .site-footer {
    grid-template-columns: 1fr;
    padding: 40px 20px 32px;
    gap: 24px;
  }

  .foot-brand,
  .foot-contact {
    grid-column: auto;
  }

  .foot-logo {
    height: 56px;
  }
}


/* ========================================================== About ====== */

.about {
  padding: 80px 40px 120px;
  min-height: 60vh;
}

.about-grid {
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: 80px;
  max-width: 960px;
}

.about-label {
  font-family: var(--mg-mono);
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-bottom: 32px;
}

.about-bio {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.about-text {
  font-family: var(--mg-mono);
  font-size: 14px;
  line-height: 1.75;
  letter-spacing: 0.01em;
  margin: 0 0 24px;
  max-width: 600px;
}

.about-text:last-of-type {
  margin-bottom: 0;
}

/* CV — attivare rimuovendo il commento in about.html */
.about-cv {
  margin-top: 40px;
}

.about-cv-link {
  font-family: var(--mg-mono);
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--mg-ink);
  border-bottom: 0.5px solid var(--mg-ink);
  padding-bottom: 2px;
  text-decoration: none;
  transition: opacity 0.2s;
}

.about-cv-link:hover {
  opacity: 0.5;
}

.about-contact {
  padding-top: 0;
}

.about-links {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.about-links li {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.about-link-key {
  font-family: var(--mg-mono);
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.about-link-val {
  font-family: var(--mg-mono);
  font-size: 13px;
  letter-spacing: 0.02em;
  color: var(--mg-ink);
  text-decoration: none;
  transition: opacity 0.2s;
}

.about-link-val:hover {
  opacity: 0.5;
}


/* ======================================================== Grain ========= */

.grain {
  display: none;
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 999;
  opacity: 0.08;
  mix-blend-mode: screen;
}

html[data-paper="dark"] .grain {
  display: block;
}


/* ======================================================== Cursor ======== */

.v3-slider,
.v3-slider * {
  cursor: none;
}

.cursor-pill {
  position: fixed;
  top: 0;
  left: 0;
  pointer-events: none;
  z-index: 1000;
  opacity: 0;
  transition: opacity 0.2s ease;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.cursor-pill.visible {
  opacity: 1;
}

.cursor-pill-label {
  background: var(--mg-paper);
  color: var(--mg-ink);
  font-family: var(--mg-mono);
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding: 6px 14px;
  border-radius: 999px;
  white-space: nowrap;
}

.cursor-pill-award {
  background: var(--mg-paper);
  color: var(--mg-ink);
  font-family: var(--mg-mono);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 4px 14px;
  border-radius: 999px;
  white-space: nowrap;
  display: none;
}


/* ======================================================== Bio Glitch ==== */

.bio-headline .letter,
.cs-headline .letter {
  display: inline;
  transition: color 0.05s;
}

.bio-headline .letter.glitch,
.cs-headline .letter.glitch {
  color: var(--mg-accent);
}


/* ======================================================== Responsive ==== */

@media (max-width: 760px) {

  .v3-slide {
    width: 100cqw;
  }

  .site-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 18px 20px;
    font-size: 11px;
  }

  .hdr-logo .mg-logo {
    height: 14px;
  }

  .hdr-tagline {
    display: none;
  }

  .hdr-nav {
    gap: 14px;
  }

  .hdr-nav > span:nth-child(1),
  .hdr-nav > span:nth-child(2),
  .hdr-nav > span:nth-child(3) {
    display: none;
  }

  .bio {
    padding: 56px 20px 44px;
  }

  .bio-headline {
    font-size: 14px;
    line-height: 1.5;
  }

  .works-label {
    padding: 24px 20px 16px;
    font-size: 10px;
  }
  .works-label-desk { display: none; }
  .works-label-mob  { display: inline; }

  .works {
    padding: 0 20px 48px;
    gap: 12px;
  }

  .site-footer {
    grid-template-columns: 1fr;
    padding: 40px 20px 32px;
    gap: 24px;
  }

  .foot-brand,
  .foot-contact {
    grid-column: auto;
  }

  .foot-logo {
    height: 56px;
  }

  .about {
    padding: 60px 20px 80px;
  }

  .about-grid {
    grid-template-columns: 1fr;
    gap: 48px;
  }

  .about-text {
    font-size: 13px;
  }
}


/* ======================================================= Project page === */

.proj-hero {
  padding: 80px 40px 48px;
  border-bottom: 1px solid var(--mg-rule);
}

.proj-meta {
  display: flex;
  align-items: baseline;
  gap: 24px;
  margin-bottom: 32px;
}

.proj-index {
  font-family: var(--mg-mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  flex-shrink: 0;
}

.proj-titles {
  flex: 1;
}

.proj-title {
  font-family: var(--mg-mono);
  font-size: clamp(28px, 4vw, 28px);
  font-weight: 400;
  letter-spacing: -0.02em;
  line-height: 1;
  margin: 0 0 4px;
}

.proj-client {
  font-family: var(--mg-mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  margin: 0;
}

.proj-tags {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.proj-tags span {
  font-family: var(--mg-mono);
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  border: 0.5px solid var(--mg-rule);
  padding: 3px 10px;
  border-radius: 999px;
}

.proj-abstract {
  font-family: var(--mg-mono);
  font-size: 13px;
  font-weight: 400;
  line-height: 1.8;
  letter-spacing: 0.01em;
  max-width: 640px;
}

/* Opening image */
.proj-opening {
  width: 100%;
  aspect-ratio: 16 / 7;
  overflow: hidden;
  cursor: zoom-in;
}

.proj-opening img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Body text */
.proj-body {
  padding: 64px 40px;
  border-bottom: 1px solid var(--mg-rule);
}

.proj-body-grid {
  display: grid;
  grid-template-columns: 1fr 220px;
  gap: 64px;
  max-width: 960px;
}

.proj-body-text p {
  font-family: var(--mg-mono);
  font-size: 13px;
  line-height: 1.8;
  letter-spacing: 0.01em;
  margin: 0 0 20px;
  max-width: 560px;
}

.proj-body-text p:last-child {
  margin-bottom: 0;
}

.proj-aside-block {
  margin-bottom: 20px;
}

.proj-aside-key {
  font-family: var(--mg-mono);
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin: 0 0 2px;
}

.proj-aside-val {
  font-family: var(--mg-mono);
  font-size: 12px;
  line-height: 1.5;
  margin: 0;
  color: var(--mg-ink);
}

/* Image grid */
.proj-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  padding: 0 40px;
  margin: 16px 0;
}

.proj-grid-item {
  position: relative;
  cursor: zoom-in;
  overflow: hidden;
}

.proj-grid-item img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  display: block;
}

.proj-caption {
  font-family: var(--mg-mono);
  font-size: 10px;
  letter-spacing: 0.06em;
  padding: 8px 0 0;
  margin: 0;
}

/* Slideshow */
.proj-slideshow {
  padding: 64px 40px;
  border-top: 1px solid var(--mg-rule);
}

.proj-slideshow-label {
  font-family: var(--mg-mono);
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin: 0 0 24px;
}

.proj-slides-track-wrap {
  overflow: hidden;
  width: 100%;
}

.proj-slides-track {
  display: flex;
  gap: 16px;
  transition: transform 600ms cubic-bezier(0.65, 0, 0.35, 1);
  will-change: transform;
}

.proj-slide {
  flex: 0 0 calc(50% - 8px);
  cursor: zoom-in;
  overflow: hidden;
}

.proj-slide img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  display: block;
}

.proj-slide {
  cursor: zoom-in;
}

.proj-slides-nav {
  display: flex;
  align-items: center;
  gap: 20px;
  margin-top: 20px;
}

.proj-slides-prev,
.proj-slides-next {
  background: none;
  border: 0.5px solid var(--mg-rule);
  color: var(--mg-ink);
  font-family: var(--mg-mono);
  font-size: 14px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.2s, opacity 0.2s;
}

.proj-slides-prev:hover,
.proj-slides-next:hover {
  border-color: var(--mg-ink);
}

.proj-slides-prev:disabled,
.proj-slides-next:disabled {
  opacity: 0.25;
  cursor: default;
}

.proj-slides-counter {
  font-family: var(--mg-mono);
  font-size: 11px;
  letter-spacing: 0.06em;
}

/* Project nav */
.proj-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 32px 40px;
  border-top: 1px solid var(--mg-rule);
  font-family: var(--mg-mono);
  font-size: 12px;
  letter-spacing: 0.04em;
}

.proj-nav a {
  color: var(--mg-ink);
  text-decoration: none;
  transition: opacity 0.2s;
}

.proj-nav a:hover {
  opacity: 0.5;
}

.proj-nav-back {
  color: var(--mg-mute) !important;
}

/* Lightbox */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 2000;
  background: var(--mg-paper);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.lightbox.active {
  opacity: 1;
  pointer-events: all;
}

.lightbox-img-wrap {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 60px;
}

.lightbox-img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  display: block;
}

.lightbox-close,
.lightbox-prev,
.lightbox-next {
  position: absolute;
  background: none;
  border: none;
  color: var(--mg-ink);
  font-family: var(--mg-mono);
  font-size: 16px;
  cursor: pointer;
  padding: 12px;
  opacity: 0.5;
  transition: opacity 0.2s;
}

.lightbox-close:hover,
.lightbox-prev:hover,
.lightbox-next:hover {
  opacity: 1;
}

.lightbox-close { top: 20px; right: 28px; font-size: 18px; }
.lightbox-prev  { left: 28px; top: 50%; transform: translateY(-50%); font-size: 20px; }
.lightbox-next  { right: 28px; top: 50%; transform: translateY(-50%); font-size: 20px; }

.lightbox-counter {
  position: absolute;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  font-family: var(--mg-mono);
  font-size: 11px;
  letter-spacing: 0.08em;
}

/* ======================================================= Responsive ===== */
@media (max-width: 760px) {
  .proj-hero    { padding: 60px 20px 36px; }
  .proj-meta    { flex-wrap: wrap; gap: 12px; }
  .proj-tags    { justify-content: flex-start; }
  .proj-body    { padding: 40px 20px; }
  .proj-body-grid { grid-template-columns: 1fr; gap: 32px; }
  .proj-grid    { grid-template-columns: 1fr; }
  .proj-slideshow { padding: 40px 20px; }
  .proj-slide   { flex: 0 0 85%; }
  .proj-nav     { padding: 24px 20px; }
  .lightbox-img-wrap { padding: 60px 20px; }
  .lightbox-prev { left: 12px; }
  .lightbox-next { right: 12px; }
}

/* ─── LINK RESET GLOBALE ─────────────────────────────────────── */
a {
  color: var(--mg-ink);
  text-decoration: none;
}

a:hover {
  opacity: 0.6;
}

.hdr-nav a:hover,
.site-footer a:hover {
  opacity: 1;
  color: var(--mg-accent);
}

.site-footer,
.site-footer a,
.foot-key,
.foot-val,
.foot-copy,
.foot-tagline {
  font-family: var(--mg-mono);
}


/* ======================================================= 404 =========== */

.error-page {
  padding: 140px 40px 120px;
  min-height: 60vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.error-ascii {
  font-family: var(--mg-mono);
  font-size: clamp(14px, 2vw, 26px);
  line-height: 1.25;
  color: var(--mg-mute);
  white-space: pre;
  margin: 0 0 48px;
}

.error-back {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 48px;
  font-family: var(--mg-mono);
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--mg-ink);
  text-decoration: none;
  transition: opacity 0.2s;
}

.error-back:hover {
  opacity: 0.5;
}

@media (max-width: 760px) {
  .error-page {
    padding: 100px 20px 80px;
  }

  .error-num {
    font-size: clamp(72px, 20vw, 96px);
    margin-bottom: 28px;
  }
}