:root {
  --bg: #faf9f5;
  --surface: #ffffff;
  --muted: #f0eee7;
  --text: #20201d;
  --soft-text: #65645f;
  --line: #d7d1c3;
  --accent: #697a64;
  --accent-dark: #405143;
  --accent-soft: #eef3ea;
  --shadow: 0 2px 10px rgba(32, 32, 29, 0.04);
  --radius: 8px;
}

[data-theme="slate"] {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --muted: #e8edf2;
  --text: #18202a;
  --soft-text: #52606f;
  --line: #cfd8e3;
  --accent: #536b82;
  --accent-dark: #24384d;
  --accent-soft: #e1e9f1;
}

[data-theme="amber"] {
  --bg: #fff8ed;
  --surface: #ffffff;
  --muted: #f3dfbf;
  --text: #251b10;
  --soft-text: #74614a;
  --line: #dec391;
  --accent: #b7791f;
  --accent-dark: #744210;
  --accent-soft: #fff0cf;
}

[data-theme="blue"] {
  --bg: #f5f8ff;
  --surface: #ffffff;
  --muted: #e8efff;
  --text: #101827;
  --soft-text: #56657a;
  --line: #cfdaf0;
  --accent: #3157d5;
  --accent-dark: #1e3a8a;
  --accent-soft: #e3ebff;
}

[data-theme="dark"] {
  --bg: #101217;
  --surface: #171a21;
  --muted: #20242d;
  --text: #f1f3f6;
  --soft-text: #a6afbd;
  --line: #303642;
  --accent: #7aa2ff;
  --accent-dark: #9bb8ff;
  --accent-soft: #202a3f;
  --shadow: 0 2px 14px rgba(0, 0, 0, 0.25);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background: var(--bg);
  line-height: 1.6;
  font-size: 14px;
}

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

img {
  max-width: 100%;
}

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

.section-pad {
  padding: 60px 0;
}

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

.muted-bg {
  background: var(--muted);
}

/* HEADER */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: color-mix(in srgb, var(--bg) 92%, white);
  backdrop-filter: blur(18px);
  border-bottom: 1px solid var(--line);
}

[data-theme="dark"] .site-header {
  background: rgba(16, 18, 23, 0.92);
}

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

/* LOGO */
.brand,
.footer-brand {
  line-height: 1;
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

/* NAV */
.nav-links {
  display: flex;
  list-style: none;
  padding: 0;
  margin: 0;
  gap: 18px;
  align-items: center;
}

.nav-links a {
  font-size: 13px;
  font-weight: 600;
  color: var(--soft-text);
}

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

/* THEME DOTS */
.theme-dots {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-left: 4px;
}

.theme-dot {
  width: 15px;
  height: 15px;
  border-radius: 999px;
  border: 1px solid var(--line);
  padding: 0;
  cursor: pointer;
  background: var(--accent);
  box-shadow: inset 0 0 0 2px var(--surface);
}

.theme-dot.active {
  outline: 2px solid var(--accent-dark);
  outline-offset: 2px;
}

.theme-dot-olive {
  background: #697a64;
}

.theme-dot-slate {
  background: #536b82;
}

.theme-dot-amber {
  background: #b7791f;
}

.theme-dot-blue {
  background: #3157d5;
}

.theme-dot-dark {
  background: #101217;
}

/* FIX RETTANGOLO SOPRA MENU */
.nav-toggle {
  display: none;
  background: none;
  border: 0;
  padding: 8px;
  appearance: none;
}

.nav-toggle span {
  display: block;
  width: 24px;
  height: 2px;
  margin: 5px 0;
  background: var(--text);
}

/* HERO */
.hero {
  padding-top: 70px;
}

.hero-grid {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 50px;
  align-items: center;
}

.eyebrow,
.section-kicker,
.project-meta {
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin: 0 0 12px;
}

/* HEADINGS */
h1,
h2,
h3 {
  margin: 0;
  line-height: 1.1;
  letter-spacing: -0.03em;
}

h1 {
  font-size: clamp(28px, 3.2vw, 40px);
  max-width: 700px;
  line-height: 1.15;
  letter-spacing: -0.02em;
}

h2 {
  font-size: clamp(24px, 3vw, 34px);
}

h3 {
  font-size: 18px;
}

/* TEXT */
.lead {
  font-size: 16px;
  color: var(--soft-text);
  max-width: 720px;
  margin: 18px 0 0;
}

/* BUTTONS */
.hero-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 22px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 0 16px;
  border-radius: 6px;
  font-weight: 700;
  font-size: 13px;
  border: 1px solid transparent;
}

.btn.primary {
  background: var(--text);
  color: var(--bg);
}

.btn.secondary {
  border-color: var(--line);
  background: rgba(255, 255, 255, 0.45);
}

[data-theme="dark"] .btn.secondary {
  background: rgba(255, 255, 255, 0.04);
}

/* IMAGE */
.hero-media {
  width: 100%;
}

.portrait-card {
  aspect-ratio: 4 / 5;
  border-radius: var(--radius);
  background: linear-gradient(145deg, var(--muted), var(--surface));
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  overflow: hidden;
  position: relative;
  margin: 0;
}

.portrait-image {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;

  /*
    Questa foto è già 4:5.
    Se la testa appare troppo alta/bassa nel layout reale, modifica solo questo valore:
    center 42%  = leggermente più volto
    center top  = più testa e spalle
    center 50%  = crop perfettamente centrale
  */
  object-position: center 42%;

  filter: saturate(0.96) contrast(1.02);
}

[data-theme="dark"] .portrait-image {
  filter: saturate(0.9) contrast(1.04) brightness(0.96);
}

/* Backward compatibility if old markup remains somewhere */
.portrait-placeholder {
  aspect-ratio: 4 / 5;
  border-radius: var(--radius);
  background: linear-gradient(145deg, var(--muted), var(--surface));
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  display: flex;
  align-items: end;
  justify-content: center;
  padding: 18px;
  font-size: 13px;
  color: var(--soft-text);
  overflow: hidden;
}

/* LAYOUT */
.two-col {
  display: grid;
  grid-template-columns: 0.9fr 1.1fr;
  gap: 50px;
}

.section-heading {
  max-width: 100%;
  margin-bottom: 28px;
}

.section-heading.wide {
  max-width: 100%;
}

.section-heading p {
  max-width: none;
}

/* PARAGRAPHS */
.rich-text p,
.section-heading p,
.project-card p,
.info-card p,
.timeline p,
.cta-box p {
  color: var(--soft-text);
  font-size: 14px;
  line-height: 1.55;
}

/* PROJECTS */
.project-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}

.project-card,
.info-card,
.cta-box {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
}

.project-card {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.project-card p {
  flex-grow: 1;
}

.project-card ul {
  margin-top: 10px;
}

.project-card .text-link {
  margin-top: auto;
}

.project-card h3 {
  min-height: 48px;
}

.project-card.accent {
  background: var(--accent-soft);
  border-color: var(--line);
}

.project-card.large {
  min-height: 100%;
}

/* LIST */
.clean-list {
  padding-left: 18px;
  color: var(--soft-text);
}

.clean-list li {
  margin: 6px 0;
}

/* LINKS */
.text-link {
  display: inline-block;
  margin-top: 12px;
  color: var(--accent-dark);
  font-weight: 800;
}

/* INSIDEBNB */
.insidebnb-card {
  margin-top: 16px;
  display: grid;
  grid-template-columns: 0.9fr 1.1fr;
  gap: 16px;
}

/* GRID */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.info-card h3 {
  font-size: 17px;
}

/* STACK */
.tech-stack {
  display: grid;
  grid-template-columns: 0.9fr 1.1fr;
  gap: 44px;
}

.stack-groups {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.stack-groups div {
  padding: 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
  box-shadow: var(--shadow);
}

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

.stack-groups p {
  font-size: 13px;
  color: var(--soft-text);
  margin: 0;
}

/* TIMELINE */
.timeline {
  display: grid;
  gap: 18px;
}

.timeline-item {
  padding-left: 18px;
  border-left: 2px solid var(--accent);
}

.timeline-item h3 {
  font-size: 18px;
}

/* CTA - LIGHT VERSION */
.cta-section {
  background: var(--muted);
  color: var(--text);
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.cta-box {
  background: var(--surface);
  max-width: 920px;
}

.cta-box h2 {
  color: var(--text);
}

.cta-box p {
  color: var(--soft-text);
}

/* FOOTER - LIGHT VERSION */
.site-footer {
  padding: 40px 0 20px;
  background: var(--bg);
  color: var(--text);
  border-top: 1px solid var(--line);
}

.footer-inner {
  display: flex;
  justify-content: space-between;
  gap: 30px;
}

.footer-inner p,
.footer-bottom {
  color: var(--soft-text);
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  justify-content: flex-end;
}

.footer-links a {
  color: var(--text);
  font-weight: 600;
}

.footer-bottom {
  margin-top: 30px;
  font-size: 12px;
}

/* RIBBON */

.project-card-ribbon {
  position: relative;
  overflow: hidden;
  padding-top: 28px;
}

.ribbon {
  position: absolute;
  top: 14px;
  right: 14px;

  padding: 4px 8px;

  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;

  background: var(--accent-dark);
  color: var(--bg);

  border-radius: 4px;

  z-index: 2;
}



/* RESPONSIVE */
@media (max-width: 860px) {
  .section-pad {
    padding: 48px 0;
  }

  .hero {
    padding-top: 48px;
  }

  .hero-grid,
  .two-col,
  .tech-stack,
  .insidebnb-card {
    grid-template-columns: 1fr;
    gap: 36px;
  }


  .hero-media {
    max-width: 420px;
    margin: 0 auto;
  }

  .project-grid,
  .cards-grid,
  .stack-groups {
    grid-template-columns: 1fr;
  }

  .project-card h3 {
    min-height: 0;
  }

  .nav-toggle {
    display: block;
  }

  .nav-links {
    position: absolute;
    left: 20px;
    right: 20px;
    top: 72px;
    display: none;
    flex-direction: column;
    align-items: flex-start;
    padding: 22px;
    border-radius: 8px;
    background: var(--surface);
    border: 1px solid var(--line);
    box-shadow: var(--shadow);
  }

  .nav-links.open {
    display: flex;
  }

  .theme-dots {
    margin-left: 0;
    margin-top: 4px;
  }

  .footer-inner {
    flex-direction: column;
  }

  .footer-links {
    justify-content: flex-start;
  }
}

@media (max-width: 520px) {
  .container,
  .narrow-container {
    width: min(100% - 28px, 1120px);
  }

  .portrait-card {
    border-radius: 10px;
  }
}

/* LEGAL */
.narrow-container {
  width: min(860px, calc(100% - 40px));
}

.legal-hero {
  padding-bottom: 50px;
}

.legal-hero h1 {
  font-size: clamp(30px, 4vw, 42px);
}

.legal-section {
  padding-top: 50px;
}

.legal-content {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 32px;
  box-shadow: var(--shadow);
}

.legal-content h2 {
  font-size: 22px;
  margin-top: 32px;
  margin-bottom: 10px;
}

.legal-content h2:first-of-type {
  margin-top: 0;
}

.legal-content p,
.legal-content li {
  font-size: 14px;
  color: var(--soft-text);
}

.legal-content a {
  color: var(--accent-dark);
  font-weight: 800;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.legal-content code {
  background: var(--muted);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 2px 6px;
  color: var(--text);
}

.legal-note {
  background: var(--accent-soft);
  border: 1px solid rgba(138, 95, 61, 0.25);
  border-radius: 8px;
  padding: 18px 20px;
  margin-bottom: 36px;
}
