/*
 * Portfolio Giorgio Palermo — foglio unico del sito pubblico.
 * Riferimento: docs/DESIGN.md (token, tipografia, misure). Pagina vivente: /styleguide.
 * Solo tema chiaro, un solo accento blu, bordi 1px al posto delle ombre, transizioni 150ms.
 */

:root {
  --background: #FAFAF7;
  --foreground: #1A1A1A;
  --muted-foreground: #696966;
  --surface: #F2F1ED;
  --primary: #203953;
  --primary-foreground: #FAFAF7;
  --border: #DFDEDA;
  --destructive: #B33832;

  --radius-sm: 2px;
  --font-sans: "Fira Sans", ui-sans-serif, system-ui, sans-serif;
  --font-serif: "DM Serif Display", ui-serif, Georgia, serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --ease: 150ms ease;
}

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

html {
  scroll-behavior: smooth;
  scroll-padding-top: 80px;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--background);
  color: var(--foreground);
  font-family: var(--font-sans);
  font-size: 16.5px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

main { flex: 1; outline: none; }

h1, h2, h3 {
  margin: 0;
  font-family: var(--font-serif);
  font-weight: 400;
  line-height: 1.05;
  letter-spacing: 0;
}

p, ul, figure { margin: 0; }
ul { padding: 0; list-style: none; }
img { max-width: 100%; display: block; }
a { color: inherit; text-decoration: none; }
table { font-variant-numeric: tabular-nums; border-collapse: collapse; }

:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

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

.skip {
  position: absolute; left: 16px; top: -48px; z-index: 100;
  padding: 8px 12px; background: var(--primary); color: var(--primary-foreground); font-size: 14px;
}
.skip:focus { top: 12px; }

/* ---------- utility ---------- */

.label {
  font-family: var(--font-sans);
  font-size: 11px;
  font-weight: 600;
  line-height: 1.65;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--primary);
}

.muted { color: var(--muted-foreground); }

.domain {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--muted-foreground);
}
.domain--link {
  color: var(--primary);
  text-decoration: underline;
  text-underline-offset: 4px;
}

.status { font-size: 12px; color: var(--muted-foreground); }

.intro {
  max-width: 65ch;
  margin-top: 20px;
  font-size: 18px;
  line-height: 1.65;
  color: var(--muted-foreground);
}

.prose { max-width: 65ch; margin-top: 20px; }
.prose p + p { margin-top: 16px; }

/* comparsa allo scroll: solo con JS attivo, una volta per blocco */
.js .reveal {
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 300ms ease, transform 300ms ease;
}
.js .reveal.is-visible { opacity: 1; transform: none; }

/* ---------- header ---------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  border-bottom: 1px solid transparent;
  transition: background-color var(--ease), border-color var(--ease);
}
.site-header.is-scrolled {
  border-bottom-color: var(--border);
  background: rgba(250, 250, 247, 0.95);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}

.site-header__in {
  max-width: 1100px;
  margin: 0 auto;
  padding: 16px 24px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 16px;
}

.site-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: var(--font-serif);
  font-size: 18px;
  line-height: 1.4;
  color: var(--foreground);
}

.site-header__tools { display: flex; align-items: center; gap: 24px; }

.site-nav { display: none; align-items: center; gap: 24px; font-size: 15px; }
.site-nav a,
.site-nav-mobile a,
.menu-toggle {
  color: var(--muted-foreground);
  transition: color var(--ease);
}
.site-nav a:hover,
.site-nav-mobile a:hover,
.menu-toggle:hover { color: var(--foreground); }

.lang-switch {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 13px;
  letter-spacing: 0.025em;
  text-transform: uppercase;
}
.lang-switch a { color: var(--muted-foreground); transition: color var(--ease); }
.lang-switch a:hover { color: var(--foreground); }
.lang-switch__sep { color: var(--border); }
.lang-switch__current {
  color: var(--primary);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 4px;
}

.menu-toggle {
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  font-size: 15px;
  cursor: pointer;
}

.site-nav-mobile {
  display: none;
  border-top: 1px solid var(--border);
  background: var(--background);
  padding: 12px 24px;
}
.site-nav-mobile.is-open,
.no-js .site-nav-mobile { display: block; }
.site-nav-mobile ul { display: flex; flex-direction: column; gap: 8px; font-size: 15px; }
.site-nav-mobile a { display: block; padding: 4px 0; }
.no-js .menu-toggle { display: none; }

@media (min-width: 640px) {
  .site-name { font-size: 20px; }
}

@media (min-width: 768px) {
  .site-nav { display: flex; }
  .menu-toggle,
  .site-nav-mobile,
  .site-nav-mobile.is-open,
  .no-js .site-nav-mobile { display: none; }
}

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

.site-footer { border-top: 1px solid var(--border); }
.site-footer__in {
  max-width: 1100px;
  margin: 0 auto;
  padding: 40px 24px;
  display: grid;
  gap: 16px;
  font-size: 14px;
  color: var(--muted-foreground);
}
.site-footer nav { display: flex; flex-wrap: wrap; gap: 4px 20px; }
.site-footer a {
  text-decoration: underline;
  text-decoration-color: var(--border);
  text-decoration-thickness: 1px;
  text-underline-offset: 4px;
  transition: color var(--ease);
}
.site-footer a:hover { color: var(--primary); }

@media (min-width: 640px) {
  .site-footer__in { display: flex; align-items: baseline; justify-content: space-between; }
}

/* ---------- home ---------- */

.page-home {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 24px 80px;
}
@media (min-width: 768px) {
  .page-home {
    padding: 0 48px 80px;
    border-left: 1px solid var(--border);
    border-right: 1px solid var(--border);
  }
}

.hero {
  padding: 48px 0 40px;
  border-bottom: 1px solid var(--border);
}
.hero__name {
  margin-top: 20px;
  font-size: 52px;
  line-height: 0.95;
}
.hero__text { margin-top: 28px; }
.hero__position { font-size: 20px; line-height: 1.5; color: var(--foreground); }
.hero__context { margin-top: 12px; color: var(--muted-foreground); }
.hero__cta { margin-top: 20px; }
.hero__cta a {
  font-size: 15px;
  color: var(--primary);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 4px;
  transition: color var(--ease);
}
.hero__cta a:hover { color: var(--foreground); }

@media (min-width: 640px) {
  .hero__name { font-size: 60px; }
}
@media (min-width: 768px) {
  .hero { padding: 64px 0 56px; }
  .hero__name { font-size: 72px; }
  .hero__position { font-size: 24px; }
}

.home-grid {
  display: grid;
  gap: 48px;
  padding-top: 48px;
}
@media (min-width: 768px) {
  .home-grid { grid-template-columns: 7fr 5fr; align-items: start; }
}

.badge {
  margin-top: 32px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 20px;
  border: 1px solid var(--border);
  background: var(--surface);
}
.badge img { width: 64px; height: 64px; border-radius: 50%; flex-shrink: 0; }
.badge figcaption { font-size: 13px; line-height: 1.65; color: var(--muted-foreground); }
@media (min-width: 640px) {
  .badge { flex-direction: row; align-items: center; gap: 20px; }
  .badge img { width: 72px; height: 72px; }
}

.tech {
  padding: 24px;
  background: var(--primary);
  color: var(--primary-foreground);
}
.tech__title {
  font-family: var(--font-sans);
  font-size: 11px;
  font-weight: 600;
  line-height: 1.65;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: rgba(250, 250, 247, 0.85);
}
.tech__list {
  margin-top: 20px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 24px;
  font-size: 15px;
}
.tech__list li { display: flex; align-items: center; gap: 8px; }
.tech__list li::before {
  content: "";
  width: 4px;
  height: 4px;
  flex-shrink: 0;
  background: rgba(250, 250, 247, 0.7);
}

.section {
  margin-top: 56px;
  padding-top: 40px;
  border-top: 1px solid var(--border);
}

/* Progetti che seguo: righe ampie, riga intera cliccabile */
.work-list { margin-top: 40px; }
.work-list li + li { margin-top: 40px; padding-top: 40px; border-top: 1px solid var(--border); }
.work-row {
  display: block;
  margin: 0 -12px;
  padding: 8px 12px;
  transition: background-color var(--ease);
}
.work-row:hover { background: var(--surface); }
.work-row__head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 20px; }
.work-row h3 { font-size: 30px; transition: color var(--ease); }
.work-row:hover h3 { color: var(--primary); }
.work-row__role { margin-top: 12px; font-size: 14px; color: var(--foreground); }
.work-row__desc {
  max-width: 65ch;
  margin-top: 12px;
  font-size: 15px;
  line-height: 1.65;
  color: var(--muted-foreground);
}

.supported {
  margin-top: 56px;
  padding-top: 40px;
  border-top: 1px solid var(--border);
}
.supported__intro {
  max-width: 65ch;
  margin-top: 20px;
  font-size: 15px;
  color: var(--muted-foreground);
}
.supported .card-grid { margin-top: 24px; }
.supported .domain--link { margin-top: 20px; align-self: flex-start; }

/* ---------- card ---------- */

.card {
  display: flex;
  flex-direction: column;
  height: 100%;
  padding: 20px;
  border: 1px solid var(--border);
  transition: border-color var(--ease), background-color var(--ease);
}
a.card:hover,
li.card:hover { border-color: var(--primary); }
.card h3 { font-size: 24px; }
.card__text {
  flex: 1;
  margin-top: 12px;
  font-size: 15px;
  line-height: 1.65;
  color: var(--muted-foreground);
}
.card__foot {
  margin-top: 20px;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

.card--lead {
  margin-top: 32px;
  padding: 24px;
  background: var(--surface);
}
.card--lead h3 { font-size: 30px; }
.card--lead .card__text { max-width: 65ch; margin-top: 16px; }
.card--lead .domain { margin-top: 20px; }
.card__head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.card-grid { display: grid; gap: 16px; margin-top: 16px; }
@media (min-width: 640px) {
  .card-grid--2,
  .card-grid--3 { grid-template-columns: 1fr 1fr; }
}
@media (min-width: 1024px) {
  .card-grid--3 { grid-template-columns: 1fr 1fr 1fr; }
}

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

.contact { padding-bottom: 16px; }
.contact__in { max-width: 520px; margin: 0 auto; }

.contact-form { margin-top: 40px; }
.field + .field { margin-top: 24px; }
.field label { display: block; font-size: 14px; color: var(--foreground); }
.field input,
.field textarea {
  display: block;
  width: 100%;
  margin-top: 8px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--foreground);
  font: inherit;
  font-size: 16px;
  line-height: 1.5;
  transition: border-color var(--ease);
}
.field textarea { resize: vertical; min-height: 8em; }
.field input:focus,
.field textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary); }
.field input:focus-visible,
.field textarea:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.field [aria-invalid="true"] { border-color: var(--destructive); }
.field__error,
.form-error { margin-top: 8px; font-size: 14px; color: var(--destructive); }
.field--trap { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }

.button {
  margin-top: 24px;
  padding: 8px 20px;
  border: 1px solid var(--foreground);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--foreground);
  font: inherit;
  font-size: 14px;
  cursor: pointer;
  transition: color var(--ease), border-color var(--ease);
}
.button:hover { border-color: var(--primary); color: var(--primary); }
.button:disabled { opacity: 0.6; cursor: default; }

.form-note { margin-top: 16px; font-size: 12px; color: var(--muted-foreground); }

.form-success {
  margin-top: 40px;
  padding: 24px;
  border: 1px solid var(--border);
  background: var(--surface);
  line-height: 1.65;
}

.contact__mail { margin-top: 40px; font-size: 14px; color: var(--muted-foreground); }
.contact__mail a { color: var(--primary); text-decoration: underline; text-underline-offset: 4px; }

/* ---------- pagine di dettaglio ---------- */

.detail {
  max-width: 760px;
  margin: 0 auto;
  padding: 40px 24px 80px;
}
.back {
  font-size: 14px;
  color: var(--muted-foreground);
  transition: color var(--ease);
}
.back:hover { color: var(--primary); }

.detail__head {
  margin-top: 32px;
  padding-bottom: 32px;
  border-bottom: 1px solid var(--border);
}
.detail__head h1 { font-size: 48px; }
.detail__meta {
  margin-top: 16px;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 16px;
}
.detail__summary {
  margin-top: 20px;
  font-size: 18px;
  line-height: 1.65;
  color: var(--muted-foreground);
}
@media (min-width: 768px) {
  .detail__head h1 { font-size: 60px; }
}

.detail__section { margin-top: 48px; }
.detail__lead { margin-top: 20px; }
.detail__lead + .detail__text { margin-top: 16px; }
.detail__text { color: var(--muted-foreground); }
.detail__blocks { margin-top: 20px; }
.detail__blocks > div + div { margin-top: 32px; }
.detail__blocks h3 { font-size: 24px; }
.detail__blocks .detail__text { margin-top: 8px; }

.numbers {
  width: 100%;
  margin-top: 20px;
  border: 1px solid var(--border);
  font-size: 14px;
}
.numbers tr { border-bottom: 1px solid var(--border); transition: background-color var(--ease); }
.numbers tr:last-child { border-bottom: 0; }
.numbers tbody tr:hover { background: var(--surface); }
.numbers th,
.numbers td { padding: 12px 16px; text-align: left; font-weight: 400; }
.numbers th { color: var(--muted-foreground); }
.numbers td {
  border-left: 1px solid var(--border);
  text-align: right;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}
.numbers thead th { background: var(--surface); }

.stack { margin-top: 20px; color: var(--muted-foreground); }
.stack li + li { margin-top: 4px; }

.screenshot {
  margin-top: 48px;
  aspect-ratio: 16 / 9;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 12px;
  color: var(--muted-foreground);
}
.screenshot--img { margin-left: 0; margin-right: 0; overflow: hidden; }
.screenshot--img img { width: 100%; height: 100%; object-fit: cover; object-position: top; }

.neighbours {
  margin-top: 48px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
  display: grid;
  gap: 16px;
}
.neighbours__label { font-size: 12px; color: var(--muted-foreground); }
.neighbours__name { margin-top: 4px; font-family: var(--font-serif); font-size: 20px; line-height: 1.3; }
@media (min-width: 640px) {
  .neighbours { grid-template-columns: 1fr 1fr; }
  .neighbours__next { text-align: right; }
}

.attribution { margin-top: 40px; font-size: 12px; color: var(--muted-foreground); }

/* ---------- 404 ---------- */

.not-found {
  max-width: 1100px;
  min-height: 60vh;
  margin: 0 auto;
  padding: 80px 24px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.not-found h1 { margin-top: 16px; font-size: 48px; }
.not-found__text { max-width: 65ch; margin-top: 20px; color: var(--muted-foreground); }
.not-found p:last-child { margin-top: 32px; }
@media (min-width: 768px) {
  .not-found h1 { font-size: 60px; }
}

.text-button {
  font-size: 14px;
  border-bottom: 1px solid var(--foreground);
  transition: color var(--ease), border-color var(--ease);
}
.text-button:hover { color: var(--primary); border-color: var(--primary); }

/* ---------- styleguide ---------- */

.sg-title { margin-top: 20px; font-family: var(--font-serif); font-size: 48px; line-height: 1.05; }
.sg-h3-lg { font-family: var(--font-serif); font-size: 30px; line-height: 1.05; }
.sg-h3 { font-family: var(--font-serif); font-size: 24px; line-height: 1.05; }
@media (min-width: 768px) {
  .sg-title { font-size: 60px; }
}

.sg-table {
  width: 100%;
  border: 1px solid var(--border);
  font-size: 14px;
}
.sg-table th,
.sg-table td { padding: 12px 16px; text-align: left; font-weight: 400; vertical-align: top; }
.sg-table thead tr { background: var(--surface); }
.sg-table thead th { color: var(--muted-foreground); }
.sg-table tr { border-bottom: 1px solid var(--border); transition: background-color var(--ease); }
.sg-table tr:last-child { border-bottom: 0; }
.sg-table tbody tr:hover { background: var(--surface); }
.sg-table .mono { font-family: var(--font-mono); font-size: 12px; }
.sg-swatch { display: inline-block; width: 40px; height: 20px; border: 1px solid var(--border); }
.sg-stack > * + * { margin-top: 16px; }
.sg-block { margin-top: 20px; }

/* ---------- movimento ridotto ---------- */

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