* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --accent: #9c2b2b;
  --ink: #111111;
  --muted: #666666;
  --line: #e5e5e5;
  --bg: #f4f3ef;
  --bg-rgb: 244, 243, 239;
  --bg-soft: #f4f3f0;
  --card-bg: #ffffff;
  --text: #333333;
  --hero-grad-1: #fbfaf7;
  --hero-grad-2: #ece9e2;
  --logo-size: min(46vh, 90vw, 380px);
  --nav-h: 64px;
}

:root[data-theme="dark"] {
  --accent: #c9534f;
  --ink: #f2ede8;
  --muted: #a89f98;
  --line: #3a322f;
  --bg: #15110f;
  --bg-rgb: 21, 17, 15;
  --bg-soft: #1c1716;
  --card-bg: #201a19;
  --text: #e6e1dc;
  --hero-grad-1: #2a201d;
  --hero-grad-2: #120e0d;
}

body {
  font-family: 'Inter', system-ui, sans-serif;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

[data-theme="dark"] .door-logo img,
[data-theme="dark"] .nav-logo {
  filter: invert(1);
}

a { color: inherit; }

/* ---------- nav ---------- */

.site-nav {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--nav-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 clamp(1.5rem, 5vw, 3rem);
  z-index: 40;
  background: rgba(var(--bg-rgb), .85);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid transparent;
  opacity: 0;
  transform: translateY(-8px);
  pointer-events: none;
  transition: opacity .3s ease, transform .3s ease, border-color .3s ease;
}
.site-nav.visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
  border-color: var(--line);
}
.site-nav .nav-logo { width: 28px; height: 28px; }
.site-nav ul { list-style: none; display: flex; gap: clamp(1rem, 3vw, 2.2rem); }
.site-nav a { text-decoration: none; font-size: .95rem; color: var(--ink); }
.site-nav a:hover { color: var(--accent); }

.nav-icon-btn {
  background: none;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: .25rem .55rem;
  font-size: .8rem;
  color: var(--ink);
  cursor: pointer;
  line-height: 1.4;
}
.nav-icon-btn:hover { border-color: var(--accent); color: var(--accent); }

.nav-burger {
  display: none;
  background: none;
  border: 0;
  font-size: 1.3rem;
  cursor: pointer;
  color: var(--ink);
  padding: .2rem .4rem;
}

@media (max-width: 700px) {
  .nav-burger { display: block; }
  .site-nav ul {
    display: none;
    position: fixed;
    top: var(--nav-h);
    left: 0; right: 0;
    flex-direction: column;
    gap: 1rem;
    padding: 1.25rem 1.5rem;
    background: rgba(var(--bg-rgb), .97);
    backdrop-filter: blur(6px);
    border-bottom: 1px solid var(--line);
  }
  .site-nav ul.aperto { display: flex; }
}

/* ---------- hero ---------- */

.hero-wrap { height: 160vh; position: relative; }
.hero-pin {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: hidden;
  background: radial-gradient(circle at 50% 40%, var(--hero-grad-1) 0%, var(--hero-grad-2) 100%);
  perspective: 2000px;
}

.hero-text {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  z-index: 1;
  padding: 0 1.5rem;
}
.hero-text h1 { font-size: clamp(2.5rem, 7vw, 5rem); letter-spacing: -.02em; }
.hero-text p { margin-top: .75rem; font-size: 1.2rem; color: var(--accent); font-weight: 600; }
.hero-scroll-hint {
  position: absolute;
  bottom: 2.5rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 3;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .35rem;
  font-size: .8rem;
  color: var(--muted);
  letter-spacing: .08em;
  text-transform: uppercase;
  appearance: none;
  -webkit-appearance: none;
  background: none;
  border: 0;
  outline: none;
  font-family: inherit;
  cursor: pointer;
  padding: .5rem;
  border-radius: 6px;
}
.hero-scroll-hint:hover { color: var(--accent); }
.hero-scroll-hint:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.hero-scroll-hint svg { animation: hint-bounce 1.6s ease-in-out infinite; }
@keyframes hint-bounce {
  0%, 100% { transform: translateY(0); opacity: .5; }
  50%      { transform: translateY(6px); opacity: 1; }
}
@media (prefers-reduced-motion: reduce) {
  .hero-scroll-hint svg { animation: none; }
}

.door {
  position: absolute;
  top: 0;
  width: 50%;
  height: 100vh;
  background: var(--card-bg);
  z-index: 2;
  overflow: hidden;
}
.door-left  { left: 0;  transform-origin: left center;  box-shadow: inset -14px 0 24px -18px rgba(0,0,0,.35); }
.door-right { right: 0; transform-origin: right center; box-shadow: inset 14px 0 24px -18px rgba(0,0,0,.35); }

.door-logo {
  position: fixed;
  top: 50%;
  width: var(--logo-size);
  height: var(--logo-size);
  transform: translateY(-50%);
}
.door-left  .door-logo { left: calc(100% - var(--logo-size) / 2); }
.door-right .door-logo { left: calc(-1 * var(--logo-size) / 2); }
.door-logo img { width: 100%; height: 100%; display: block; }

@media (prefers-reduced-motion: reduce) {
  .door { transition: none !important; }
}

/* ---------- sezioni generiche ---------- */

section.block {
  max-width: 760px;
  margin: 0 auto;
  padding: 7rem 1.5rem;
  scroll-margin-top: var(--nav-h);
}
section.block h2 {
  font-size: 1.8rem;
  margin-bottom: 1.5rem;
  letter-spacing: -.01em;
}
section.block > p { line-height: 1.75; color: var(--text); font-size: 1.05rem; }

#chi-sono p { max-width: 620px; }

/* ---------- competenze ---------- */

.skills { list-style: none; display: flex; flex-wrap: wrap; gap: .6rem; margin-top: .5rem; }
.skills li {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: .4rem 1rem;
  font-size: .9rem;
  background: var(--card-bg);
}

/* ---------- progetti: mini-browser ---------- */

#progetti { max-width: 900px; }

.browser-bar {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; background: var(--bg-soft); border-bottom: 1px solid var(--line);
}
.browser-dots { display: flex; gap: 6px; }
.browser-dots span { width: 9px; height: 9px; border-radius: 50%; background: var(--line); }
.browser-url {
  flex: 1; background: var(--card-bg); border: 1px solid var(--line); border-radius: 6px;
  padding: 4px 10px; font-size: .8rem; color: var(--muted); text-align: center;
}

.project-grid { display: grid; gap: 2rem; margin-top: 1.5rem; }

.browser-card {
  border-radius: 10px; overflow: hidden; cursor: pointer;
  border: 1px solid var(--line); box-shadow: 0 8px 24px rgba(0,0,0,.06);
  transition: border-color .2s, transform .2s;
}
.browser-card:hover { border-color: var(--accent); transform: translateY(-2px); }
.browser-body { position: relative; aspect-ratio: 16/10; overflow: hidden; background: var(--bg-soft); }
.browser-body iframe {
  position: absolute; top: 0; left: 0; width: 1440px; height: 900px;
  border: 0; transform: scale(.3333); transform-origin: top left; pointer-events: none;
}
.project-meta { padding: 1rem 1.2rem 1.4rem; }
.project-meta h3 { font-size: 1.1rem; margin-bottom: .3rem; }
.project-meta p { font-size: .92rem; color: var(--muted); line-height: 1.5; margin-bottom: .6rem; }
.project-meta a { font-size: .85rem; color: var(--accent); text-decoration: none; }
.project-meta a:hover { text-decoration: underline; }
.tech-stack { display: flex; flex-wrap: wrap; gap: .4rem; list-style: none; padding: 0; margin: 0 0 .6rem; }
.tech-stack li { font-size: .75rem; padding: .15rem .55rem; border-radius: 999px; background: var(--accent-soft, rgba(127,127,127,.15)); color: var(--muted); }
.project-stat { font-size: .85rem; font-weight: 600; margin-bottom: .6rem !important; }
.project-hint { font-size: .82rem; color: var(--accent); font-style: italic; margin-bottom: .6rem !important; }

.project-title-row { display: flex; align-items: center; justify-content: space-between; gap: .5rem; margin-bottom: .3rem; }
.project-title-row h3 { margin-bottom: 0; }
.feature-info { position: relative; }
.feature-info-btn {
  width: 22px; height: 22px; border-radius: 50%; padding: 0;
  border: 1.5px solid var(--accent); background: var(--card-bg);
  display: flex; align-items: center; justify-content: center;
  color: var(--accent); cursor: pointer; flex: none;
}
.feature-info-btn:hover, .feature-info-btn:focus-visible, .feature-info.open .feature-info-btn {
  background: var(--accent); color: var(--card-bg);
}
.feature-info-popup {
  display: none;
  position: absolute; top: 28px; right: 0; z-index: 5; width: 220px;
  background: var(--card-bg); border: 1px solid var(--line); border-radius: 8px;
  padding: .6rem .8rem .6rem 1.4rem; box-shadow: 0 10px 30px rgba(0,0,0,.15);
  font-size: .8rem; color: var(--text); line-height: 1.5;
}
.feature-info-popup li { margin-bottom: .3rem; }
.feature-info-popup li:last-child { margin-bottom: 0; }
.feature-info:hover .feature-info-popup,
.feature-info.open .feature-info-popup { display: block; }

.project-system {
  border: 1px dashed var(--accent); border-radius: 14px; padding: 1.4rem 1.2rem 1.2rem;
}
.system-badge {
  display: inline-flex; align-items: center; gap: .4rem; font-size: .78rem; font-weight: 600;
  color: var(--accent); background: var(--bg-soft); border: 1px solid var(--line);
  border-radius: 999px; padding: .3rem .8rem; margin-bottom: 1rem;
}
.project-system-grid { display: grid; gap: 2rem; }
@media (min-width: 700px) {
  .project-system-grid { grid-template-columns: 1fr 1fr; }
}
.system-link {
  display: block; font-size: .8rem; font-weight: 600; margin-bottom: .5rem !important;
}

.modal {
  position: fixed; inset: 0; background: rgba(20,15,15,.55);
  display: none; align-items: center; justify-content: center;
  padding: 4vh 4vw; z-index: 100;
}
.modal.open { display: flex; }
.modal-frame {
  width: min(1100px, 92vw); height: min(760px, 88vh);
  background: var(--card-bg); border-radius: 12px; overflow: hidden;
  display: flex; flex-direction: column; box-shadow: 0 30px 80px rgba(0,0,0,.35);
}
.modal-frame .browser-bar { flex: none; }
.modal-frame iframe { flex: 1; width: 100%; border: 0; }
.modal-close {
  background: none; border: 0; font-size: 1rem; color: var(--muted); cursor: pointer; line-height: 1;
  padding: 4px 6px;
}
.modal-close:hover { color: var(--accent); }

/* ---------- contatti / footer ---------- */

footer {
  border-top: 1px solid var(--line);
  padding: 3rem 1.5rem 4rem;
  text-align: center;
}
footer .contact-links {
  display: flex; justify-content: center; gap: 1.5rem;
  list-style: none; margin-bottom: 1.2rem; flex-wrap: wrap;
}
footer .contact-links a {
  text-decoration: none; font-size: .95rem; border-bottom: 1px solid var(--line); padding-bottom: 2px;
}
footer .contact-links a:hover { color: var(--accent); border-color: var(--accent); }
footer .copyright { font-size: .8rem; color: var(--muted); }

@media (max-width: 640px) {
  .site-nav ul { gap: 1rem; }
  section.block { padding: 4.5rem 1.25rem; }
}
