/* Blog pubblico — /blog/categoria/{categoria} e /blog/{slug}.
 *
 * Stessi token e stessi componenti della landing (bottoni, footer, tipografia):
 * il blog e' la stessa vetrina, non un'altra cosa. La testata invece e' diversa
 * di proposito: sulla landing e' una pillola con il menu delle sezioni, qui sono
 * due cose sole — logo e Accedi — perche' su una pagina che si legge un menu
 * pieno di ancore che portano altrove distrae e basta.
 *
 * La landing tiene il suo CSS inline nel <head> perche' e' una pagina sola e
 * self-contained; qui e un file a parte perche' le pagine cresceranno a ogni articolo.
 *
 * Se cambi i colori qui, guarda anche templates/shared/landing.html.twig: sono le
 * stesse variabili, duplicate di proposito per non dover toccare la landing.
 */

*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

:root {
    --bg:            #ffffff;
    --fg:            #0f0f0f;
    --muted:         #737373;
    --muted-soft:    #a3a3a3;
    --border:        #e5e5e5;
    --border-soft:   #f0f0f0;
    --surface:       #fafafa;
    --accent:        #2f7cf6;
    --accent-strong: #1f5fd0;
    --radius-card:   1.5rem;
}

html { -webkit-text-size-adjust: 100%; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg);
    color: var(--fg);
    font-size: 15px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: clip;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

img { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }

::selection { background: color-mix(in srgb, var(--accent) 22%, transparent); }

:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 3px;
    border-radius: 4px;
}

/* ─── Impalcatura ───────────────────────────────────────── */

.wrap {
    width: 100%;
    max-width: 64rem;
    margin-inline: auto;
    padding-inline: 1.25rem;
}

.wrap--narrow { max-width: 44rem; }

.headline {
    font-weight: 600;
    letter-spacing: -0.035em;
    line-height: 1.1;
    text-wrap: balance;
}

.kicker {
    font-size: 0.8125rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.14em;
    /* Il tono forte, non l'accento pieno: questo è testo, per quanto piccolo.
       Vale anche per il blu, che così passa da 4:1 a 5.9:1 di contrasto. */
    color: var(--accent-strong);
}

.lead {
    font-size: 1.0625rem;
    line-height: 1.65;
    color: var(--muted);
    text-wrap: pretty;
}

main { flex: 1 0 auto; }

/* ─── Colore per sezione ────────────────────────────────── */

/* Ogni sezione ha il suo accento, così si riconosce a colpo d'occhio da quale
   arriva un articolo: Informative resta il blu di Konnexa, Sviluppo è arancio.
   Si fa ridefinendo le due variabili invece di riscrivere le regole: badge,
   kicker, link nel testo e bordo delle citazioni le leggono già tutti.
   La classe la mette il template, da `articolo.categoria`.

   I due valori sono l'arancione dell'area admin (`--admin-primary` e
   `--admin-secondary` in colors.css). Sono due e non uno perché
   `--accent-strong` porta il TESTO: #f59e0b su bianco è 2.2:1, illeggibile;
   #b45309 arriva a 5:1 e passa. L'arancione pieno resta per sfondi, bordi e
   decorazioni, dove il contrasto non è un requisito. */
.cat--sviluppo {
    --accent:        #f59e0b;
    --accent-strong: #b45309;
}

/* ─── Testata ───────────────────────────────────────────── */

.testata { padding-block: 1.75rem 0.5rem; }

/* Larghezza piena, senza `.wrap`: le due voci vanno ai bordi della pagina, non
   incolonnate con il testo. Il padding e' solo il margine di sicurezza dal bordo
   dello schermo. */
.testata-in {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding-inline: clamp(1.25rem, 3vw, 2.5rem);
}

.nav-brand { display: flex; align-items: center; flex: 0 0 auto; }
.nav-brand img { height: 22px; width: auto; }

.nav-cta {
    flex: 0 0 auto;
    padding: 0.4375rem 1rem;
    border-radius: 999px;
    background: var(--fg);
    color: var(--bg);
    font-size: 0.75rem;
    font-weight: 500;
    white-space: nowrap;
    transition: opacity 0.2s ease;
}

.nav-cta:hover { opacity: 0.8; }

/* ─── Bottoni ───────────────────────────────────────────── */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.55rem;
    height: 3rem;
    padding-inline: 1.5rem;
    border-radius: 999px;
    font-size: 0.9375rem;
    font-weight: 500;
    white-space: nowrap;
    transition: background-color 0.2s ease, color 0.2s ease,
                border-color 0.2s ease, transform 0.15s ease, opacity 0.2s ease;
}

.btn i { font-size: 0.8125rem; }
.btn:hover { transform: translateY(-1px); }
.btn--solid { background: var(--fg); color: var(--bg); }
.btn--solid:hover { opacity: 0.85; }
.btn--ghost { border: 1px solid var(--border); background: var(--bg); }
.btn--ghost:hover { background: var(--surface); border-color: var(--muted-soft); }

/* ─── Testata delle pagine blog ─────────────────────────── */

.blog-head { padding-block: clamp(3rem, 8vw, 5rem) clamp(2rem, 5vw, 3rem); }
.blog-head h1 { margin-top: 1rem; font-size: clamp(2.25rem, 6vw, 3.5rem); }
.blog-head .lead { margin-top: 1.25rem; max-width: 38rem; }

/* ─── Sezioni (Tutti / Informative / Sviluppo) ──────────── */

.sezioni {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 2rem;
}

.sezione {
    padding: 0.4375rem 1rem;
    border: 1px solid var(--border);
    border-radius: 999px;
    font-size: 0.875rem;
    color: var(--muted);
    transition: border-color 0.2s ease, background-color 0.2s ease, color 0.2s ease;
}

.sezione:hover { border-color: var(--muted-soft); color: var(--fg); }

.sezione--attiva {
    background: var(--fg);
    border-color: var(--fg);
    color: var(--bg);
}

.sezione--attiva:hover { color: var(--bg); border-color: var(--fg); }

/* ─── Lista articoli ────────────────────────────────────── */

.articoli { display: grid; gap: 1rem; padding-bottom: clamp(4rem, 9vw, 7rem); list-style: none; }

.articolo-card {
    display: block;
    padding: 1.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-card);
    background: var(--bg);
    transition: border-color 0.2s ease, background-color 0.2s ease, transform 0.15s ease;
}

.articolo-card:hover {
    border-color: var(--muted-soft);
    background: var(--surface);
    transform: translateY(-2px);
}

.articolo-card h2 {
    margin-top: 0.75rem;
    font-size: clamp(1.25rem, 2.6vw, 1.625rem);
    font-weight: 600;
    letter-spacing: -0.02em;
    line-height: 1.25;
    text-wrap: balance;
}

.articolo-card p {
    margin-top: 0.625rem;
    color: var(--muted);
    line-height: 1.6;
    text-wrap: pretty;
}

.meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem 0.75rem;
    font-size: 0.8125rem;
    color: var(--muted-soft);
}

.meta-sep { color: var(--border); }

.badge {
    display: inline-block;
    padding: 0.25rem 0.625rem;
    border-radius: 999px;
    background: color-mix(in srgb, var(--accent) 10%, transparent);
    color: var(--accent-strong);
    font-size: 0.75rem;
    font-weight: 500;
    letter-spacing: 0.02em;
}

.badge--bozza { background: color-mix(in srgb, #f59e0b 16%, transparent); color: #92400e; }

.vuoto {
    padding: 3rem 1.75rem;
    border: 1px dashed var(--border);
    border-radius: var(--radius-card);
    text-align: center;
    color: var(--muted);
}

/* ─── Articolo ──────────────────────────────────────────── */

.briciole { padding-top: clamp(1.5rem, 4vw, 2.25rem); font-size: 0.8125rem; color: var(--muted-soft); }
.briciole a:hover { color: var(--fg); }

.articolo-head { padding-block: 1.25rem clamp(1.5rem, 4vw, 2.25rem); }
.articolo-head h1 { margin-top: 1rem; font-size: clamp(2rem, 5.4vw, 3.125rem); }
.articolo-head .lead { margin-top: 1.25rem; }
.articolo-head .meta { margin-top: 1.5rem; }

.copertina {
    margin-block: clamp(1.5rem, 4vw, 2.5rem);
    border-radius: var(--radius-card);
    overflow: hidden;
    border: 1px solid var(--border-soft);
}

/* ─── Corpo dell'articolo (HTML generato dal Markdown) ──── */

.prosa {
    padding-bottom: clamp(3rem, 7vw, 5rem);
    font-size: 1.0625rem;
    line-height: 1.75;
    color: #202020;
}

.prosa > * + * { margin-top: 1.25rem; }

.prosa h2 {
    margin-top: 2.75rem;
    font-size: clamp(1.5rem, 3.2vw, 1.875rem);
    font-weight: 600;
    letter-spacing: -0.025em;
    line-height: 1.25;
    text-wrap: balance;
}

.prosa h3 {
    margin-top: 2rem;
    font-size: 1.1875rem;
    font-weight: 600;
    letter-spacing: -0.015em;
}

.prosa a { color: var(--accent-strong); text-decoration: underline; text-underline-offset: 0.2em; }
.prosa a:hover { color: var(--accent); }

.prosa strong { font-weight: 600; }

.prosa ul, .prosa ol { padding-left: 1.375rem; }
.prosa li + li { margin-top: 0.5rem; }
.prosa li::marker { color: var(--muted-soft); }

.prosa blockquote {
    padding: 1rem 1.375rem;
    border-left: 3px solid var(--accent);
    background: var(--surface);
    border-radius: 0 0.75rem 0.75rem 0;
    color: var(--muted);
}

.prosa code {
    padding: 0.125rem 0.375rem;
    border-radius: 0.375rem;
    background: var(--surface);
    border: 1px solid var(--border-soft);
    font-size: 0.9em;
}

.prosa pre {
    padding: 1.125rem 1.25rem;
    border-radius: 0.875rem;
    background: #0f0f0f;
    color: #f5f5f5;
    overflow-x: auto;
}

.prosa pre code { padding: 0; border: 0; background: none; color: inherit; }

/* Una tabella larga scorre dentro il suo contenitore: la pagina non deve mai
   scorrere in orizzontale su telefono. Il wrapper lo mette il template. */
.prosa .tabella-scroll { overflow-x: auto; }
.prosa table { width: 100%; border-collapse: collapse; font-size: 0.9375rem; }
.prosa th, .prosa td { padding: 0.625rem 0.875rem; border-bottom: 1px solid var(--border); text-align: left; }
.prosa th { font-weight: 600; background: var(--surface); }

.prosa hr { margin-block: 2.5rem; border: 0; border-top: 1px solid var(--border); }

.prosa img { margin-block: 1.75rem; border-radius: 0.875rem; }

/* ─── Fondo articolo ────────────────────────────────────── */

.correlati { padding-block: clamp(2.5rem, 6vw, 4rem); border-top: 1px solid var(--border); }
.correlati h2 { font-size: 1.25rem; font-weight: 600; letter-spacing: -0.02em; }
.correlati .articoli { margin-top: 1.5rem; padding-bottom: 0; }

.cta-blog {
    margin-block: clamp(2rem, 5vw, 3rem);
    padding: clamp(2rem, 5vw, 3rem);
    border-radius: var(--radius-card);
    background: var(--surface);
    border: 1px solid var(--border-soft);
    text-align: center;
}

.cta-blog h2 { font-size: clamp(1.375rem, 3vw, 1.75rem); font-weight: 600; letter-spacing: -0.025em; }
.cta-blog p { margin-top: 0.75rem; color: var(--muted); }
.cta-blog .azioni { display: flex; flex-wrap: wrap; justify-content: center; gap: 0.75rem; margin-top: 1.75rem; }

/* ─── Footer (stesso della landing) ─────────────────────── */

.site-footer { flex: 0 0 auto; border-top: 1px solid var(--border); padding-block: 2.5rem; }

.footer-in {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    align-items: center;
    text-align: center;
    font-size: 0.8125rem;
    color: var(--muted);
}

.footer-in a:hover { color: var(--fg); }

@media (prefers-reduced-motion: reduce) {
    * { animation: none !important; transition: none !important; }
    .articolo-card:hover, .btn:hover { transform: none; }
}
