/* IBM Plex Sans, ospitato localmente (SIL Open Font License, vedi fonts/OFL.txt) */
@font-face { font-family: "Plex"; src: url("fonts/ibm-plex-sans-latin-400-normal.woff2") format("woff2"); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: "Plex"; src: url("fonts/ibm-plex-sans-latin-400-italic.woff2") format("woff2"); font-weight: 400; font-style: italic; font-display: swap; }
@font-face { font-family: "Plex"; src: url("fonts/ibm-plex-sans-latin-600-normal.woff2") format("woff2"); font-weight: 600; font-style: normal; font-display: swap; }
@font-face { font-family: "Plex"; src: url("fonts/ibm-plex-sans-latin-700-normal.woff2") format("woff2"); font-weight: 700; font-style: normal; font-display: swap; }

:root {
  --bg: #ffffff;
  --surface: #f5f7fa;
  --fg: #16202c;
  --muted: #5a6573;
  --rule: #e1e6ed;
  --link: #1557a8;
  --code-bg: #f1f4f8;
  --accent-soft: #e8f0fb;
  --on-accent: #ffffff;
  --sans: "Plex", -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  --radius: 8px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #11161c;
    --surface: #171e26;
    --fg: #e4e9ef;
    --muted: #9aa6b4;
    --rule: #28313c;
    --link: #7fb2ee;
    --code-bg: #1b232d;
    --accent-soft: #1a2838;
    --on-accent: #0d1520;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #11161c;
  --surface: #171e26;
  --fg: #e4e9ef;
  --muted: #9aa6b4;
  --rule: #28313c;
  --link: #7fb2ee;
  --code-bg: #1b232d;
  --accent-soft: #1a2838;
  --on-accent: #0d1520;
  color-scheme: dark;
}
:root[data-theme="light"] { color-scheme: light; }
/* scelta fatta con il pulsante del sito: vince su tema di sistema e su data-theme */
:root[data-scheme="light"] {
  --bg: #ffffff;
  --surface: #f5f7fa;
  --fg: #16202c;
  --muted: #5a6573;
  --rule: #e1e6ed;
  --link: #1557a8;
  --code-bg: #f1f4f8;
  --accent-soft: #e8f0fb;
  --on-accent: #ffffff;
  color-scheme: light;
}
:root[data-scheme="dark"] {
  --bg: #11161c;
  --surface: #171e26;
  --fg: #e4e9ef;
  --muted: #9aa6b4;
  --rule: #28313c;
  --link: #7fb2ee;
  --code-bg: #1b232d;
  --accent-soft: #1a2838;
  --on-accent: #0d1520;
  color-scheme: dark;
}

/* base */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--fg); font: 17px/1.65 var(--sans); }
a { color: var(--link); text-underline-offset: 2px; }
a:hover { text-decoration-thickness: 2px; }
a:focus-visible, summary:focus-visible { outline: 2px solid var(--link); outline-offset: 3px; border-radius: 2px; }
h1, h2, h3 { text-wrap: balance; }

.wrap { max-width: 68rem; margin: 0 auto; padding-inline: 1.25rem; }
main.wrap { padding-block: 2.5rem 4rem; }
/* testi lunghi: colonna di lettura allineata a sinistra con header e footer */
main > article.post, main > .cta, main > .back { max-width: 46rem; }
main > article.post:has(.page-services) { max-width: none; }

.skip { position: absolute; left: -999px; }
.skip:focus { left: 1rem; top: 1rem; background: var(--bg); padding: .25rem .5rem; z-index: 10; }
.root-choice { padding: 20vh 1.25rem; text-align: center; }

/* intestazione */
.site-header { border-bottom: 1px solid var(--rule); background: var(--bg); }
.header-inner { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .75rem 1.5rem; padding-block: 1rem; }
.brand { text-decoration: none; color: var(--fg); display: flex; flex-direction: column; line-height: 1.25; }
.brand-name { font-weight: 700; font-size: 1.1rem; }
.brand-role { font-size: .82rem; color: var(--muted); }
.site-header nav { display: flex; flex-wrap: wrap; align-items: center; gap: .35rem 1.3rem; font-size: .95rem; }
.site-header nav a:not(.button) { color: var(--muted); text-decoration: none; padding-block: .2rem; }
.site-header nav a:not(.button):hover { color: var(--fg); }
.site-header nav a[aria-current] { color: var(--fg); box-shadow: inset 0 -2px 0 var(--link); }
.site-header nav a.lang { font-size: .82rem; font-weight: 600; letter-spacing: .05em; }

.theme-toggle {
  display: inline-flex; align-items: center; justify-content: center; width: 2.1rem; height: 2.1rem;
  border: 1px solid var(--rule); border-radius: 6px; background: transparent; color: var(--muted); cursor: pointer; padding: 0;
}
.theme-toggle:hover { color: var(--fg); border-color: var(--muted); }
.theme-toggle:focus-visible { outline: 2px solid var(--link); outline-offset: 2px; }
.theme-toggle svg { width: 1.1rem; height: 1.1rem; }
.theme-toggle .sun { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .sun { display: block; }
  :root:not([data-theme="light"]) .theme-toggle .moon { display: none; }
}
:root[data-theme="dark"] .theme-toggle .sun { display: block; }
:root[data-theme="dark"] .theme-toggle .moon { display: none; }
:root[data-scheme="light"] .theme-toggle .sun { display: none; }
:root[data-scheme="light"] .theme-toggle .moon { display: block; }
:root[data-scheme="dark"] .theme-toggle .sun { display: block; }
:root[data-scheme="dark"] .theme-toggle .moon { display: none; }

/* pulsanti */
a.button {
  display: inline-block; padding: .6rem 1.15rem; border-radius: 6px; border: 1px solid var(--link);
  background: var(--link); color: var(--on-accent); text-decoration: none; font-weight: 600; font-size: .98rem; line-height: 1.3;
}
a.button:hover { filter: brightness(1.08); }
a.button.button-ghost { background: transparent; color: var(--link); }
a.button.button-ghost:hover { background: var(--accent-soft); filter: none; }
a.button.button-small { padding: .35rem .8rem; font-size: .88rem; }

/* home */
.hero { padding-block: 2.5rem 1rem; max-width: 44rem; }
.hero h1 { font-size: clamp(2rem, 4.5vw, 2.9rem); line-height: 1.12; letter-spacing: -.02em; margin: 0 0 1rem; }
.hero p { font-size: 1.15rem; color: var(--muted); margin: 0 0 1.6rem; }
.hero .hero-actions { display: flex; flex-wrap: wrap; gap: .75rem; margin: 0; }

.home-section { margin-top: 4rem; }
.section-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: .5rem 1rem; margin-bottom: 1.25rem; }
.section-head h2 { font-size: 1.5rem; margin: 0; letter-spacing: -.01em; }
.section-head a { font-size: .95rem; text-decoration: none; }

.service-cards { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; }
.service-card {
  display: flex; flex-direction: column; gap: .5rem; height: 100%; padding: 1.25rem;
  border: 1px solid var(--rule); border-radius: var(--radius); background: var(--surface);
  color: var(--fg); text-decoration: none; transition: border-color .15s;
}
.service-card:hover { border-color: var(--link); }
.service-card strong { font-size: 1.05rem; }
.service-card span:last-child { color: var(--muted); font-size: .93rem; line-height: 1.5; }
.icon { width: 2.5rem; height: 2.5rem; border-radius: 6px; background: var(--accent-soft) var(--icon) center / 1.4rem no-repeat; margin-bottom: .25rem; }

.post-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(2, 1fr); gap: 1rem; }
.post-card { display: flex; flex-direction: column; padding: 1.4rem 1.5rem; border: 1px solid var(--rule); border-radius: var(--radius); background: var(--bg); }
.post-title { font-weight: 600; font-size: 1.15rem; line-height: 1.35; text-decoration: none; margin: .3rem 0 .5rem; }
.post-title:hover { text-decoration: underline; }
.post-card p { margin: 0 0 .9rem; color: var(--muted); font-size: .95rem; line-height: 1.55; flex: 1; }
.tags { display: flex; flex-wrap: wrap; gap: .35rem; }
.tag { font-size: .78rem; line-height: 1; color: var(--link); background: var(--accent-soft); padding: .35rem .55rem; border-radius: 4px; }

/* gli elementi delle griglie non devono allargare la pagina */
.page-services li, .steps li, .service-cards li, .post-card { min-width: 0; overflow-wrap: break-word; }

/* pie' di pagina */
.site-footer { border-top: 1px solid var(--rule); background: var(--surface); font-size: .92rem; color: var(--muted); }
.footer-inner { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 1.5rem 3rem; padding-block: 2.5rem; }
.footer-about { max-width: 26rem; }
.footer-about strong { color: var(--fg); }
.footer-about p { margin: .35rem 0 0; }
.footer-links { display: flex; flex-wrap: wrap; gap: .4rem 1.4rem; align-content: flex-start; max-width: 28rem; }
.footer-links a { color: var(--muted); text-decoration: none; }
.footer-links a:hover { color: var(--fg); text-decoration: underline; }

/* articoli e pagine */
.post-header { margin-bottom: 2rem; }
.post-header h1 { font-size: clamp(1.7rem, 4vw, 2.2rem); line-height: 1.2; margin: .4rem 0 .8rem; letter-spacing: -.015em; }
.post-meta { font-size: .9rem; color: var(--muted); margin: 0; }
.post-summary { font-size: 1.12rem; color: var(--muted); margin: 0 0 1rem; }

.prose h2 { font-size: 1.4rem; line-height: 1.3; margin: 2.6rem 0 .7rem; letter-spacing: -.01em; scroll-margin-top: 1rem; }
.prose h3 { font-size: 1.12rem; margin: 1.9rem 0 .4rem; }
.prose p, .prose ul, .prose ol { margin: 0 0 1rem; }
.prose ul, .prose ol { padding-left: 1.3rem; }
.prose li { margin: .25rem 0; }
.prose blockquote { margin: 1.25rem 0; padding: .1rem 0 .1rem 1rem; border-left: 3px solid var(--rule); color: var(--muted); }
.prose hr { border: 0; border-top: 1px solid var(--rule); margin: 2rem 0; }

code { font-family: var(--mono); font-size: .86em; background: var(--code-bg); padding: .1em .35em; border-radius: 4px; }
pre { background: var(--code-bg); padding: 1rem 1.1rem; border-radius: 6px; overflow-x: auto; font-size: .84rem; line-height: 1.55; margin: 0 0 1.25rem; border: 1px solid var(--rule); }
pre code { background: none; padding: 0; font-size: inherit; }

.table { overflow-x: auto; margin: 0 0 1.25rem; }
table { border-collapse: collapse; width: 100%; font-size: .93rem; }
th, td { text-align: left; vertical-align: top; padding: .55rem .8rem .55rem 0; border-bottom: 1px solid var(--rule); }
th { font-weight: 600; }
.page-about td:first-child { white-space: nowrap; }

.back { margin-top: 2.5rem; font-size: .95rem; }
.cta { margin: 3rem 0 0; padding: 1.1rem 1.25rem; border-radius: var(--radius); background: var(--accent-soft); font-size: .98rem; }
.cta p { margin: 0; }
.cta + .back { margin-top: 1.5rem; }

/* etichette in maiuscoletto: "In breve", indice, esempio */
.tldr > p:first-child, .toc summary, .page-services .example span {
  font-family: var(--sans); font-size: .8rem; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--muted);
}

/* riquadro "in breve" */
.tldr {
  border: 1px solid var(--rule); border-left: 3px solid var(--link);
  background: var(--code-bg); padding: .9rem 1.1rem; margin: 0 0 2rem; border-radius: 0 6px 6px 0;
}
.tldr > p:first-child { line-height: 1; margin: .2rem 0 .6rem; }
.tldr ul { margin: 0; padding-left: 1.2rem; }
.tldr li { margin: .3rem 0; }

/* note per chi è meno tecnico */
.aside { font-size: .95rem; margin: 0 0 1.25rem; color: var(--fg); background: var(--surface); border-left: 3px solid var(--rule); border-radius: 0 6px 6px 0; padding: .8rem 1rem; }
.aside strong { color: var(--fg); }

/* figure / schemi */
figure { margin: 1.75rem 0; }
figure svg { display: block; width: 100%; height: auto; max-width: 100%; margin: 0 auto; color: var(--fg); font-family: var(--sans); }
figure svg.narrow { max-width: 380px; }
figure svg.mid { max-width: 520px; }
figcaption { font-size: .88rem; color: var(--muted); margin-top: .6rem; text-align: center; }
.fg-box { fill: var(--code-bg); stroke: var(--rule); stroke-width: 1.5; }
.fg-acc { fill: none; stroke: var(--link); stroke-width: 2.5; }
.fg-accbox { fill: var(--code-bg); stroke: var(--link); stroke-width: 2; }
.fg-line { fill: none; stroke: currentColor; stroke-width: 1.5; }
.fg-dash { fill: none; stroke: currentColor; stroke-width: 2; stroke-dasharray: 5 4; }
.fg-grid { stroke: var(--rule); stroke-width: 1; }
.fg-ring { fill: none; stroke: var(--muted); stroke-width: 1; stroke-dasharray: 3 3; }
.fg-t { fill: currentColor; font-size: 13px; }
.fg-s { fill: var(--muted); font-size: 11px; }
.fg-m { fill: currentColor; font-size: 12px; font-family: var(--mono); }
.fg-a { fill: var(--link); font-size: 12px; font-family: var(--mono); }
.fg-head { fill: currentColor; stroke: none; }

/* indice dell'articolo */
.toc { margin: 0 0 2rem; font-size: .95rem; border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule); padding: .6rem 0; }
.toc summary { cursor: pointer; line-height: 1.6; }
.toc summary:focus-visible { outline: 2px solid var(--link); outline-offset: 2px; }
.toc ol { margin: .6rem 0 .2rem; padding-left: 1.4rem; }
.toc li { margin: .2rem 0; }
.toc a { text-decoration: none; }
.toc a:hover { text-decoration: underline; }

/* pagina consulenza: introduzione e sezioni a due colonne */
.page-services > p:first-child { font-size: 1.12rem; line-height: 1.6; max-width: 46rem; }
.svc { display: grid; grid-template-columns: minmax(0, 20rem) minmax(0, 1fr); gap: 1.5rem 3rem; align-items: start; padding-top: 2.5rem; margin-top: 2.5rem; border-top: 1px solid var(--rule); }
.page-services .svc h2[id] { margin: 0 0 .6rem; font-size: 1.35rem; }
.page-services h2[id]::before {
  content: ""; display: block; width: 2.6rem; height: 2.6rem; margin-bottom: .9rem; border-radius: 6px;
  background-color: var(--accent-soft);
  background-image: var(--icon); background-repeat: no-repeat; background-position: center; background-size: 1.4rem;
}
.page-services h2#start::before { content: none; }
/* icone: libro, chip, server, scudo (tratto blu leggibile su entrambi i temi) */
.page-services #training, .icon-training { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%234a8fd8' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M2 5h7a3 3 0 0 1 3 3v12a2 2 0 0 0-2-2H2z'/%3E%3Cpath d='M22 5h-7a3 3 0 0 0-3 3v12a2 2 0 0 1 2-2h8z'/%3E%3C/svg%3E"); }
.page-services #ai, .icon-ai { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%234a8fd8' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='6' y='6' width='12' height='12' rx='2'/%3E%3Crect x='9.5' y='9.5' width='5' height='5'/%3E%3Cpath d='M9 2v4M15 2v4M9 18v4M15 18v4M2 9h4M2 15h4M18 9h4M18 15h4'/%3E%3C/svg%3E"); }
.page-services #systems, .icon-systems { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%234a8fd8' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='3' width='18' height='7' rx='1.5'/%3E%3Crect x='3' y='14' width='18' height='7' rx='1.5'/%3E%3Cpath d='M7 6.5h.01M7 17.5h.01M11 6.5h6M11 17.5h6'/%3E%3C/svg%3E"); }
.page-services #security, .icon-security { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%234a8fd8' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 2l8 3v6c0 5-3.5 9-8 11-4.5-2-8-6-8-11V5z'/%3E%3Cpath d='M8.5 12l2.5 2.5 4.5-5'/%3E%3C/svg%3E"); }
.svc-head p { margin: 0; color: var(--muted); }
.svc-body > :first-child { margin-top: 0; }
.svc-body > :last-child { margin-bottom: 0; }
.page-services .svc-body > p { margin: 0 0 1rem; }
.page-services .svc-body > ul { margin: 0 0 1rem; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .75rem; list-style: none; padding: 0; }
.page-services .svc-body > ul li { margin: 0; padding: .9rem 1rem; font-size: .95rem; line-height: 1.55; background: var(--surface); border: 1px solid var(--rule); border-radius: 6px; }
.page-services .svc-body > ul li strong { display: block; margin-bottom: .25rem; color: var(--fg); }

/* esempio collegato */
.page-services .example {
  border-left: 3px solid var(--link); background: var(--accent-soft);
  padding: .8rem 1rem; border-radius: 0 6px 6px 0; font-size: .95rem;
}
.page-services .svc-body .example { margin: 0; }
.page-services .example span { display: block; line-height: 1.4; margin-bottom: .2rem; }
.page-services .example a { font-weight: 600; }

/* passi */
.prose .steps { list-style: none; counter-reset: step; padding: 0; margin: 0 0 2rem; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .75rem; }
.steps li { counter-increment: step; margin: 0; padding: .9rem 1rem; border-top: 3px solid var(--link); background: var(--code-bg); border-radius: 0 0 6px 6px; }
.steps li::before { content: counter(step); display: block; font: 600 .8rem var(--mono); color: var(--link); margin-bottom: .3rem; }
.steps strong { display: block; }
.steps span { display: block; color: var(--muted); font-size: .92rem; margin-top: .2rem; line-height: 1.5; }

/* riquadro contatti */
.contact-box { border: 1px solid var(--rule); border-radius: 8px; padding: 1.4rem 1.5rem; background: var(--accent-soft); }
.contact-box p { margin: 0 0 .9rem; font-size: 1.1rem; font-weight: 600; }
.contact-box p:last-child { margin: 0; display: flex; flex-wrap: wrap; align-items: center; gap: .6rem 1.2rem; font-size: .95rem; font-weight: 400; }

/* schermi stretti */
@media (max-width: 900px) {
  .service-cards { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 860px) {
  .svc { grid-template-columns: 1fr; gap: 1rem; }
}
@media (max-width: 640px) {
  body { font-size: 16px; }
  .service-cards, .post-list { grid-template-columns: 1fr; }
  .hero { padding-top: 1rem; }
  .brand-role { display: none; }
  .site-header nav a.button-small { display: none; }
  .page-services .svc-body > ul, .prose .steps { grid-template-columns: 1fr; }
}

/* articolo con indice laterale sugli schermi larghi */
.post-layout { display: grid; grid-template-columns: minmax(0, 46rem); column-gap: 3.5rem; }
.toc-side { display: none; }
@media (min-width: 1100px) {
  .post-layout { grid-template-columns: minmax(0, 46rem) minmax(0, 1fr); }
  .post-layout .toc { display: none; }
  .toc-side {
    display: block; position: sticky; top: 1.5rem; align-self: start;
    max-height: calc(100vh - 3rem); overflow-y: auto; font-size: .88rem; line-height: 1.4; padding-top: .4rem;
  }
  .toc-side p { margin: 0 0 .7rem; font-size: .8rem; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
  .toc-side ol { list-style: none; margin: 0; padding: 0; border-left: 1px solid var(--rule); }
  .toc-side a { display: block; margin-left: -1px; padding: .35rem 0 .35rem .9rem; border-left: 2px solid transparent; color: var(--muted); text-decoration: none; }
  .toc-side a:hover { color: var(--fg); }
  .toc-side a[aria-current] { color: var(--fg); border-left-color: var(--link); }
}

/* indice degli articoli */
.blog-index .post-header { max-width: 46rem; }

/* home su telefono: schede dei servizi più compatte, icona accanto al titolo */
@media (max-width: 640px) {
  .service-card { display: grid; grid-template-columns: 2.5rem minmax(0, 1fr); gap: .15rem .9rem; align-items: center; padding: 1rem 1.1rem; }
  .service-card .icon { grid-row: span 2; margin: 0; align-self: start; }
}
