/* ===== Base ===== */
*,
*::before,
*::after { box-sizing: border-box; }

:root{
  --bg: #f7f7fb;
  --card: #ffffff;
  --text: #0f1222;
  --muted: #6b7280;
  --border: #e7e9f0;
  /* --accent: #4d7c5b;    verde salvia */
  --accent: #3c3f46;  /* grigio bluastro */
  --shadow: 0 8px 24px rgba(15,18,34,.06);
  --inset-top: max(14px, env(safe-area-inset-top));
  --inset-right: max(14px, env(safe-area-inset-right));
  --inset-bottom: max(14px, env(safe-area-inset-bottom));
}
/* ===== Palette scura attivata dal toggle ===== */
:root[data-theme="dark"] {
    --bg: #0e1117;
    --card: #121620;
    --text: #e8ebf2;
    --muted: #a2a9b6;
    --border: #1f2533;
    --shadow: 0 10px 28px rgba(0, 0, 0, .45);
}

/* ===== Pulsante toggle ===== */
/* Toggle sempre cliccabile e comodo al tocco */
.theme-toggle {
    position: fixed;
    top: var(--inset-top);
    right: var(--inset-right);
    z-index: 9999;
    border: 1px solid var(--border);
    background: var(--card);
    color: var(--text);
    border-radius: 999px;
    padding: 10px 12px;
    /* tap area più grande */
    min-width: 44px;
    min-height: 44px;
    /* target consigliato mobile */
    line-height: 1;
    font-size: 18px;
    cursor: pointer;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    box-shadow: var(--shadow);
}

/* Se preferisci in basso a destra su mobile (opzionale) */
@media (max-width: 600px) {
    .theme-toggle {
        top: auto;
        bottom: var(--inset-bottom);
    }
}

.theme-toggle:hover {
    transform: translateY(-1px);
    box-shadow: 0 12px 30px rgba(15, 18, 34, .1);
    border-color: color-mix(in oklab, var(--border), var(--accent) 25%);
}

@media print {
    .theme-toggle {
        display: none;
    }
}
@media (prefers-color-scheme: dark){
  :root{
    --bg: #0e1117;
    --card: #121620;
    --text: #e8ebf2;
    --muted: #a2a9b6;
    --border: #1f2533;
    --shadow: 0 10px 28px rgba(0,0,0,.45);
  }
}

html, body { margin: 0; padding: 0; }
body{
  background: var(--bg);
  color: var(--text);
  font: 16px/1.6 "Inter", system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Apple Color Emoji","Segoe UI Emoji";
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* ===== Layout ===== */
header, main, footer { width: 100%; }
header, footer { padding: 28px 16px; }
header { text-align: center; }

main{
  max-width: 880px;
  margin: 0 auto;
  padding: 8px 16px 40px;
}

section { margin: 28px 0; }

/* ===== Typography ===== */
h1, h2, h3{
  margin: 0 0 .5em 0;
  line-height: 1.2;
  letter-spacing: -0.01em;
}

h1{ font-weight: 700; font-size: clamp(1.9rem, 3vw, 2.3rem); }
h2{ font-weight: 600; font-size: clamp(1.15rem, 2vw, 1.35rem); color: var(--muted); }
h3{ font-weight: 700; font-size: 1.05rem; }

header h3{ color: var(--muted); font-weight: 600; margin-top: .25em; }
header p { color: var(--muted); margin-top: .25em; }

p{ margin: 0 0 .9em 0; }
code{
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  background: rgba(127,127,127,.08);
  border: 1px solid var(--border);
  padding: .08em .45em;
  border-radius: 6px;
}

/* ===== Projects: LIST view (no grid) ===== */
.projects{
  display: flex;
  flex-direction: column;
  gap: 16px;         /* spaziatura tra card */
  align-items: stretch;
}

/* Card base */
.project.card{
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 18px 18px 16px;
  display: flex;
  transition: transform .08s ease-out, box-shadow .18s ease-out, border-color .18s ease-out;
}

.project.card:hover{
  transform: translateY(-2px);
  box-shadow: 0 12px 30px rgba(15,18,34,.1);
  border-color: color-mix(in oklab, var(--border), var(--accent) 20%);
}

/* Contenuto card */
.project-info{
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.project-info h3{
  margin-bottom: 2px;
  line-height: 1.15;
}

/* Testo secondario più neutro (utile per recruiter) */
.project-info p + p{
  color: var(--muted);
}

/* Link/CTA */
.project-links{ margin-top: 6px; }
.project-links a{
  display: inline-block;
  text-decoration: none;
  color: var(--accent);
  font-weight: 600;
  border: 1px solid color-mix(in oklab, var(--accent), var(--card) 70%);
  padding: 8px 12px;
  border-radius: 10px;
  transition: background .15s ease, border-color .15s ease, transform .08s ease;
}
.project-links a:hover{
  background: color-mix(in oklab, var(--card), var(--accent) 8%);
  border-color: color-mix(in oklab, var(--accent), var(--card) 20%);
  transform: translateY(-1px);
}

/* ===== Featured: prima card in evidenza ===== */
.projects .project.card:first-of-type{
  position: relative;
  border-left: 4px solid var(--accent);
  padding-left: 16px;
}

.projects .project.card:first-of-type .project-info h3{
  font-size: 1.12rem;         /* leggermente più grande */
}

/* Badge “Nuovo” automatico sul primo titolo (non tocca l’HTML) */
.projects .project.card:first-of-type .project-info h3::after{
  content: "Nuovo";
  margin-left: .6rem;
  font-size: .72rem;
  font-weight: 700;
  color: var(--accent);
  background: color-mix(in oklab, var(--accent), var(--card) 85%);
  border: 1px solid color-mix(in oklab, var(--accent), var(--card) 65%);
  padding: .15rem .45rem;
  border-radius: 999px;
  vertical-align: middle;
}

/* ===== Contact ===== */
.contact ul{
  list-style: none;
  padding: 0;
  margin: 10px 0 0 0;
}
.contact li{ margin: 6px 0; }
.contact a{
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px dashed color-mix(in oklab, var(--accent), var(--card) 70%);
}
.contact a:hover{ border-bottom-style: solid; }

/* ===== Footer ===== */
footer{
  text-align: center;
  color: var(--muted);
  border-top: 1px solid var(--border);
}

/* ===== Stampa (per recruiter) ===== */
@media print{
  body{ background: #fff; color: #000; }
  header, footer{ border: 0; padding: 0; }
  .project.card{
    box-shadow: none !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
  .project-links a{
    color: #000;
    border: 1px solid #000;
  }
}

/* ===== Motion prefs ===== */
@media (prefers-reduced-motion: reduce){
  * { transition: none !important; }
}
