:root {
  color-scheme: light;
  --bg: #ffffff;
  --text: #050505;
  --muted: #626976;
  --line: #e8ebf0;
  --soft: #f6f8fb;
  --panel: #ffffff;
  --accent: #1268ff;
  --accent-dark: #064ed0;
  --radius: 8px;
  --shadow: 0 24px 80px rgba(15, 23, 42, 0.08);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #050505;
  --text: #f7f8fb;
  --muted: #a7afbd;
  --line: #24272e;
  --soft: #101216;
  --panel: #0b0d11;
  --accent: #6ca2ff;
  --accent-dark: #9bbfff;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.28);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  scroll-padding-top: 104px;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Inter", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  transition: background 220ms ease, color 220ms ease;
}

body.nav-open {
  overflow: hidden;
}

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

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

button,
select {
  font: inherit;
}

a:focus-visible,
button:focus-visible,
select:focus-visible {
  outline: 3px solid rgba(18, 104, 255, 0.34);
  outline-offset: 3px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}

.preloader {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  background: var(--bg);
  transition: opacity 220ms ease, visibility 220ms ease;
}

.preloader span {
  width: 28px;
  height: 28px;
  border: 2px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 999px;
  animation: spin 700ms linear infinite;
}

body.is-loaded .preloader {
  visibility: hidden;
  opacity: 0;
}

.scroll-progress {
  position: fixed;
  top: 0;
  right: 0;
  left: 0;
  z-index: 80;
  height: 3px;
  background: transparent;
}

.scroll-progress span {
  display: block;
  width: 0%;
  height: 100%;
  background: var(--accent);
}

.shell {
  width: min(1040px, calc(100% - 40px));
  margin: 0 auto;
}

.section {
  padding: 76px 0;
  scroll-margin-top: 104px;
}

.site-header {
  position: fixed;
  top: 0;
  right: 0;
  left: 0;
  z-index: 60;
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  border-bottom: 1px solid color-mix(in srgb, var(--line) 86%, transparent);
  backdrop-filter: blur(18px);
}

.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 72px;
  gap: 24px;
}

.brand {
  position: relative;
  z-index: 62;
  font-size: 15px;
  font-weight: 700;
  white-space: nowrap;
}

.nav-menu {
  display: flex;
  align-items: center;
  gap: 28px;
}

.nav-links,
.nav-controls {
  display: flex;
  align-items: center;
  gap: 18px;
}

.nav-links {
  color: var(--muted);
  font-size: 14px;
  font-weight: 550;
}

.nav-links a {
  position: relative;
  transition: color 180ms ease;
}

.nav-links a::after {
  position: absolute;
  right: 0;
  bottom: -8px;
  left: 0;
  height: 2px;
  background: var(--accent);
  content: "";
  opacity: 0;
  transform: scaleX(0.6);
  transition: opacity 180ms ease, transform 180ms ease;
}

.nav-links a:hover,
.nav-links a.is-active {
  color: var(--text);
}

.nav-links a.is-active::after {
  opacity: 1;
  transform: scaleX(1);
}

.nav-toggle {
  position: relative;
  z-index: 62;
  display: none;
  width: 40px;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--text);
  cursor: pointer;
}

.nav-toggle span {
  position: absolute;
  left: 11px;
  width: 16px;
  height: 2px;
  background: currentColor;
  transition: transform 180ms ease, top 180ms ease;
}

.nav-toggle span:first-child {
  top: 14px;
}

.nav-toggle span:last-child {
  top: 23px;
}

body.nav-open .nav-toggle span:first-child {
  top: 19px;
  transform: rotate(45deg);
}

body.nav-open .nav-toggle span:last-child {
  top: 19px;
  transform: rotate(-45deg);
}

.language-select,
.icon-btn {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--text);
}

.language-select {
  padding: 0 28px 0 10px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
}

.icon-btn {
  position: relative;
  width: 42px;
  cursor: pointer;
}

.theme-toggle .sun,
.theme-toggle .moon {
  position: absolute;
  inset: 0;
  margin: auto;
  width: 16px;
  height: 16px;
  transition: opacity 180ms ease, transform 180ms ease;
}

.theme-toggle .sun {
  border: 2px solid currentColor;
  border-radius: 999px;
}

.theme-toggle .moon {
  border-radius: 999px;
  box-shadow: -5px 0 0 currentColor;
  transform: translateX(5px) rotate(-20deg);
}

:root[data-theme="light"] .theme-toggle .moon,
:root:not([data-theme]) .theme-toggle .moon {
  opacity: 0;
  transform: translateX(8px) rotate(-20deg) scale(0.6);
}

:root[data-theme="dark"] .theme-toggle .sun {
  opacity: 0;
  transform: scale(0.6) rotate(45deg);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 46px;
  padding: 0 18px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 14px;
  font-weight: 650;
  line-height: 1;
  transition: transform 180ms ease, box-shadow 180ms ease, border-color 180ms ease, background 180ms ease, color 180ms ease;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn-primary {
  background: var(--text);
  color: var(--bg);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.14);
}

.btn-secondary {
  background: var(--panel);
  color: var(--text);
  border-color: var(--line);
}

.btn-secondary:hover {
  border-color: color-mix(in srgb, var(--muted) 42%, var(--line));
  box-shadow: 0 10px 26px rgba(15, 23, 42, 0.08);
}

.btn-small {
  min-height: 38px;
  padding: 0 14px;
  font-size: 13px;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 340px);
  align-items: center;
  gap: clamp(42px, 6vw, 76px);
  min-height: auto;
  padding-top: clamp(92px, 9vh, 108px);
  padding-bottom: clamp(28px, 4vh, 42px);
  overflow: clip;
}

#projects {
  padding-top: clamp(34px, 4vw, 52px);
}

.eyebrow {
  margin: 0 0 16px;
  color: var(--accent);
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  max-width: min(100%, 690px);
  margin-bottom: 18px;
  font-size: clamp(2.55rem, 4.55vw, 4.25rem);
  font-weight: 800;
  line-height: 1.03;
  overflow-wrap: normal;
  text-wrap: balance;
}

h2 {
  margin-bottom: 0;
  font-size: clamp(30px, 3.35vw, 48px);
  font-weight: 760;
  line-height: 1.04;
  text-wrap: balance;
}

h3 {
  margin-bottom: 12px;
  font-size: 20px;
  font-weight: 720;
  line-height: 1.15;
}

.hero-text {
  max-width: 620px;
  margin-bottom: 26px;
  color: var(--muted);
  font-size: clamp(17px, 1.45vw, 21px);
  line-height: 1.55;
  overflow-wrap: break-word;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.hero-profile {
  width: min(100%, 340px);
  min-width: 0;
  justify-self: end;
  align-self: center;
  transition: transform 220ms ease;
}

.hero-profile:hover {
  transform: translateY(-4px);
}

.hero-profile img {
  width: 100%;
  height: auto;
  aspect-ratio: 1;
  border: 1px solid var(--line);
  border-radius: 20px;
  object-fit: cover;
  box-shadow: 0 28px 90px rgba(15, 23, 42, 0.14);
}

.profile-note {
  display: grid;
  gap: 8px;
  width: calc(100% - 28px);
  margin: -34px auto 0;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--panel);
  box-shadow: 0 18px 48px rgba(15, 23, 42, 0.1);
  position: relative;
}

.profile-note span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

.profile-note strong {
  font-size: 16px;
  line-height: 1.35;
}

.section-heading {
  max-width: 820px;
  margin-bottom: 30px;
}

.section-heading.compact {
  max-width: 760px;
}

.project-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  align-items: stretch;
}

.project-card {
  position: relative;
  display: flex;
  min-height: 100%;
  overflow: hidden;
  flex-direction: column;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: 0 10px 36px rgba(15, 23, 42, 0.04);
  transition: transform 220ms ease, box-shadow 220ms ease, border-color 220ms ease;
}

.project-card-featured {
  border-color: color-mix(in srgb, var(--accent) 28%, var(--line));
}

.featured-label {
  position: absolute;
  top: 14px;
  left: 14px;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border: 1px solid color-mix(in srgb, var(--accent) 26%, var(--line));
  border-radius: 999px;
  background: color-mix(in srgb, var(--panel) 92%, transparent);
  color: var(--accent);
  font-size: 12px;
  font-weight: 750;
  backdrop-filter: blur(12px);
}

.project-card:hover {
  transform: translateY(-4px);
  border-color: color-mix(in srgb, var(--muted) 34%, var(--line));
  box-shadow: var(--shadow);
}

.project-media {
  display: grid;
  aspect-ratio: 16 / 8.8;
  place-items: center;
  overflow: hidden;
  background: var(--soft);
}

.project-media img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: top center;
  transition: transform 360ms ease;
}

.project-card:hover .project-media img {
  transform: scale(1.015);
}

.project-media::before,
.gallery-item::before {
  content: "Preview unavailable";
  display: none;
  color: var(--muted);
  font-size: 14px;
  font-weight: 650;
}

.project-media.is-empty::before,
.gallery-item.is-empty::before {
  display: block;
}

.project-content {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-width: 0;
  padding: 20px;
}

.project-content p {
  margin-bottom: 14px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.58;
  overflow-wrap: break-word;
}

.project-content .project-meta {
  margin-bottom: 7px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 750;
  line-height: 1.4;
  text-transform: uppercase;
  overflow-wrap: anywhere;
}

.badges,
.stack-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.badges {
  margin-bottom: 16px;
}

.badges span,
.stack-list span,
.meta-list span {
  display: inline-flex;
  align-items: center;
  min-height: 29px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  color: var(--text);
  font-size: 12px;
  font-weight: 650;
  max-width: 100%;
  overflow-wrap: anywhere;
}

.project-open {
  width: fit-content;
  margin-top: auto;
}

.project-open.is-private {
  cursor: default;
  opacity: 0.72;
}

.project-open.is-private:hover {
  transform: none;
  box-shadow: none;
}

.about-section {
  background: var(--soft);
}

.about-grid {
  display: grid;
  grid-template-columns: minmax(0, 0.92fr) minmax(300px, 0.9fr);
  gap: clamp(34px, 5vw, 58px);
  align-items: start;
}

.about-copy p {
  color: var(--muted);
  font-size: 17px;
  line-height: 1.7;
}

.about-copy p:last-child {
  margin-bottom: 0;
}

.stack-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  margin-top: 26px;
}

.stack-group {
  display: flex;
  min-height: 126px;
  flex-direction: column;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
}

.stack-group h3 {
  margin-bottom: 16px;
  font-size: 16px;
}

.stack-list span {
  min-height: 31px;
  padding: 0 11px;
  background: var(--soft);
}

.contact-section {
  padding-top: 62px;
}

.contact-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 0.52fr);
  gap: clamp(30px, 5vw, 52px);
  padding: clamp(30px, 4vw, 44px);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #050505;
  color: #ffffff;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.contact-card .eyebrow {
  color: #7eb0ff;
}

.contact-card h2 {
  font-size: clamp(30px, 3.4vw, 46px);
  overflow-wrap: break-word;
}

.contact-subtitle {
  max-width: 620px;
  margin: 18px 0 0;
  color: #d6dce8;
  font-size: 17px;
  line-height: 1.65;
  overflow-wrap: break-word;
}

.contact-details {
  display: grid;
  align-content: start;
  gap: 14px;
  min-width: 0;
}

.contact-details a {
  overflow-wrap: anywhere;
  color: #d6dce8;
  font-size: 15px;
  font-weight: 550;
}

.contact-details a:hover {
  color: #ffffff;
}

.contact-details .btn:hover {
  color: #050505;
}

.contact-details .btn {
  width: min(100%, 220px);
  margin-top: 8px;
  background: #ffffff;
  color: #050505;
  box-shadow: none;
}

.footer {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  align-items: center;
  gap: 20px;
  padding: 28px 0 42px;
  color: var(--muted);
  border-top: 1px solid var(--line);
  font-size: 14px;
}

.footer p:nth-child(2) {
  text-align: center;
}

.footer p:last-child {
  text-align: right;
}

.timeline {
  display: grid;
  border-top: 1px solid var(--line);
}

.timeline-item {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: 36px;
  padding: 20px 0;
  border-bottom: 1px solid var(--line);
}

.timeline-date {
  margin: 0;
  color: var(--accent);
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
}

.timeline-item h3 {
  margin-bottom: 8px;
  font-size: 19px;
}

.timeline-item p:last-child {
  margin: 0;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.65;
}

.footer p {
  margin-bottom: 0;
}

.back-to-top {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 50;
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--text);
  cursor: pointer;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 180ms ease, transform 180ms ease, border-color 180ms ease;
}

.back-to-top.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.case-main {
  padding-top: 72px;
}

.case-hero {
  padding: 88px 0 56px;
}

.case-hero-grid {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(320px, 0.72fr);
  gap: 60px;
  align-items: end;
}

.case-hero h1 {
  font-size: clamp(44px, 6vw, 78px);
}

.case-summary {
  color: var(--muted);
  font-size: 19px;
  line-height: 1.65;
}

.meta-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 26px;
}

.case-cover,
.gallery-item {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--soft);
  box-shadow: var(--shadow);
}

.case-cover img,
.gallery-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top center;
}

.case-content {
  display: grid;
  gap: 28px;
  padding-bottom: 112px;
}

.case-section {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  gap: 48px;
  padding: 34px 0;
  border-top: 1px solid var(--line);
}

.case-section h2 {
  font-size: 22px;
  line-height: 1.2;
}

.case-section p,
.case-section li {
  color: var(--muted);
  font-size: 17px;
  line-height: 1.72;
}

.gallery {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.gallery-item {
  display: grid;
  min-height: 240px;
  place-items: center;
  box-shadow: none;
}

.case-bottom {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  padding-top: 6px;
}

.can-reveal .reveal {
  opacity: 0;
  transform: translateY(18px);
  transition: opacity 520ms ease, transform 520ms ease;
}

.can-reveal .reveal.is-visible {
  opacity: 1;
  transform: translateY(0);
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }

  .can-reveal .reveal {
    opacity: 1;
    transform: none;
  }
}

@media (max-width: 980px) {
  .section {
    padding: 60px 0;
  }

  .nav {
    min-height: 68px;
  }

  .nav-toggle {
    display: block;
  }

  .nav-menu {
    position: fixed;
    top: 0;
    right: 0;
    left: 0;
    z-index: 61;
    display: grid;
    gap: 26px;
    padding: 92px 20px 26px;
    border-bottom: 1px solid var(--line);
    background: var(--bg);
    opacity: 0;
    pointer-events: none;
    transform: translateY(-12px);
    transition: opacity 180ms ease, transform 180ms ease;
  }

  body.nav-open .nav-menu {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
  }

  .nav-links,
  .nav-controls {
    width: min(1040px, calc(100% - 40px));
    margin: 0 auto;
  }

  .nav-links {
    display: grid;
    gap: 18px;
    font-size: 22px;
  }

  .nav-links a::after {
    display: none;
  }

  .nav-controls {
    flex-wrap: wrap;
  }

  .hero,
  .case-hero-grid {
    grid-template-columns: 1fr;
    gap: 42px;
    min-height: auto;
    padding-top: 100px;
    padding-bottom: 32px;
  }

  #projects {
    padding-top: 38px;
  }

  h1 {
    max-width: 100%;
    font-size: clamp(2.4rem, 7.2vw, 3.75rem);
  }

  .hero-profile {
    width: min(100%, 300px);
    justify-self: start;
  }

  .project-grid,
  .about-grid,
  .contact-card,
  .case-section,
  .timeline-item {
    grid-template-columns: 1fr;
  }

  .stack-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .project-media {
    aspect-ratio: 16 / 11;
  }
}

@media (max-width: 560px) {
  .shell {
    width: min(100% - 28px, 1040px);
  }

  .section {
    padding: 44px 0;
  }

  #projects {
    padding-top: 28px;
  }

  .brand {
    max-width: 150px;
    white-space: normal;
    line-height: 1.2;
  }

  .btn {
    width: 100%;
  }

  .nav-controls .btn {
    width: 100%;
  }

  .hero-actions,
  .case-bottom {
    width: 100%;
  }

  h1 {
    font-size: clamp(2.05rem, 8.9vw, 2.75rem);
    line-height: 1.04;
  }

  h2 {
    font-size: 30px;
  }

  .project-content,
  .contact-card,
  .stack-group {
    padding: 18px;
  }

  .stack-grid,
  .gallery {
    grid-template-columns: 1fr;
  }

  .footer {
    grid-template-columns: 1fr;
  }

  .footer p,
  .footer p:nth-child(2),
  .footer p:last-child {
    text-align: left;
  }
}

@media (min-width: 981px) and (max-width: 1180px) {
  .hero {
    grid-template-columns: minmax(0, 1fr) minmax(270px, 320px);
    gap: 38px;
  }

  h1 {
    font-size: clamp(2.45rem, 4vw, 3.6rem);
  }
}

:root h1 {
  max-width: min(100%, 650px);
  font-size: clamp(2.7rem, 4.8vw, 4.45rem);
}

:root .hero-text {
  max-width: 640px;
}

:root[lang="en"] h1,
:root[lang="it"] h1 {
  max-width: min(100%, 590px);
  font-size: clamp(2.35rem, 4.15vw, 3.85rem);
}

:root[lang="en"] .hero-text,
:root[lang="it"] .hero-text {
  max-width: 600px;
}

@media (max-width: 980px) {
  :root h1,
  :root[lang="en"] h1,
  :root[lang="it"] h1 {
    max-width: 100%;
    font-size: clamp(2.4rem, 7.2vw, 3.75rem);
  }
}

@media (max-width: 560px) {
  :root h1,
  :root[lang="en"] h1,
  :root[lang="it"] h1 {
    font-size: clamp(2.05rem, 8.9vw, 2.75rem);
  }
}
