/* ============================================================
   THEME TOKENS
   ============================================================ */

:root {
  --bg: #f6fbf6;
  --surface: #ffffff;
  --muted: #6b7280;
  --text: #0b4d3a;
  --title: #0f7a5f;
  --accent: #0a58ca;
  --accent-visited: #6f42c1;
  --card-shadow: 0 6px 18px rgba(11,77,58,0.04);
  --border: rgba(11,77,58,0.06);
  --focus-ring: rgba(10,88,202,0.12);

  --hover-overlay-light: rgba(0,0,0,0.06);
  --hover-overlay-dark: rgba(255,255,255,0.03);
  --hover-ease: 180ms;

  --gold-antique: #b08b4f;
  --gold-muted: #a78b56;

  --button-foreground: #ffffff;
}

/* ============================================================
   DARK THEME
   ============================================================ */

:root[data-theme="dark"] {
  --bg: #0f0f10;
  --surface: #161617;
  --muted: #9aa3a8;
  --text: #efe9d6;
  --title: var(--gold-antique);
  --accent: #7fc3ff;
  --accent-visited: #9b7bff;
  --card-shadow: 0 6px 18px rgba(2,6,23,0.6);
  --border: rgba(255,255,255,0.04);
  --focus-ring: rgba(127,195,255,0.12);
  --hover-overlay: var(--hover-overlay-dark);
  --detail-gold: var(--gold-muted);
  --button-foreground: #071827;
}

/* ============================================================
   LIGHT THEME
   ============================================================ */

:root[data-theme="light"] {
  --bg: #f6fbf6;
  --surface: #ffffff;
  --muted: #6b7280;
  --text: #0b4d3a;
  --title: #0f7a5f;
  --accent: #0a58ca;
  --accent-visited: #6f42c1;
  --card-shadow: 0 6px 18px rgba(11,110,253,0.06);
  --border: rgba(11,77,58,0.04);
  --focus-ring: rgba(10,88,202,0.08);
  --hover-overlay: var(--hover-overlay-light);
  --detail-gold: var(--gold-muted);
  --button-foreground: #ffffff;
}

/* ============================================================
   AUTO THEME
   ============================================================ */

@media (prefers-color-scheme: light) {
  :root[data-theme="auto"] {
    --bg: #f6fbf6;
    --surface: #ffffff;
    --muted: #6b7280;
    --text: #0b4d3a;
    --title: #0f7a5f;
    --accent: #0a58ca;
    --accent-visited: #6f42c1;
    --card-shadow: 0 6px 18px rgba(11,110,253,0.06);
    --border: rgba(11,77,58,0.04);
    --focus-ring: rgba(10,88,202,0.08);
    --hover-overlay: var(--hover-overlay-light);
    --detail-gold: var(--gold-muted);
  }
}

@media (prefers-color-scheme: dark) {
  :root[data-theme="auto"] {
    --bg: #0f0f10;
    --surface: #161617;
    --muted: #9aa3a8;
    --text: #efe9d6;
    --title: var(--gold-antique);
    --accent: #7fc3ff;
    --accent-visited: #9b7bff;
    --card-shadow: 0 6px 18px rgba(2,6,23,0.6);
    --border: rgba(255,255,255,0.04);
    --focus-ring: rgba(127,195,255,0.12);
    --hover-overlay: var(--hover-overlay-dark);
    --detail-gold: var(--gold-muted);
  }
}

/* ============================================================
   BASE LAYOUT
   ============================================================ */

html, body { height: 100%; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  line-height: 1.6;
}

/* ============================================================
   LINKS (Markdown + global)
   ============================================================ */

main a,
main :where(.post-body, .content, .markdown) a,
.post-body a,
.content a,
.markdown a,
main a[href^="mailto:"],
main a[href^="/"],
main a[href^="http"] {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 3px;
  transition: color 140ms ease, filter 140ms ease;
}

main a:visited,
.post-body a:visited,
.content a:visited,
.markdown a:visited {
  color: var(--accent-visited);
}

main a:hover,
main a:focus,
.post-body a:hover,
.post-body a:focus {
  filter: brightness(1.06);
  outline: none;
}

/* Mailto + contact link fix */
main a[href^="mailto:"],
main a[href="/contact"] {
  color: var(--accent) !important;
  -webkit-text-fill-color: var(--accent) !important;
  font-weight: 600;
}

/* ============================================================
   HEADER / NAV
   ============================================================ */

header {
  padding: 18px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 1200px;
  margin: 0 auto;
}

nav ul {
  display: flex;
  gap: 18px;
  list-style: none;
  margin: 0;
  padding: 0;
  align-items: center;
}

header a, nav a {
  color: inherit;
  text-decoration: none;
}

header a:hover, nav a:hover {
  text-decoration: underline;
}

/* ============================================================
   CARDS
   ============================================================ */

.card {
  background: linear-gradient(180deg, rgba(255,255,255,0.02), transparent);
  padding: 16px;
  border-radius: 12px;
  box-shadow: var(--card-shadow);
  border: 1px solid var(--border);
  color: var(--text);
}

/* Hover overlay */
.card, .post-card, .index-item {
  position: relative;
  overflow: hidden;
  border-radius: 12px;
}

.card::after,
.post-card::after,
.index-item::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-color: transparent;
  transition: background-color var(--hover-ease) ease, opacity var(--hover-ease) ease;
  opacity: 0;
  z-index: 1;
}

.card > *,
.post-card > *,
.index-item > * {
  position: relative;
  z-index: 2;
}

.card:hover,
.card:focus-within,
.post-card:hover,
.post-card:focus-within,
.index-item:hover,
.index-item:focus-within {
  transform: translateY(-4px);
  box-shadow: 0 10px 30px rgba(2,6,23,0.35);
}

.card:hover::after,
.card:focus-within::after,
.post-card:hover::after,
.post-card:focus-within::after,
.index-item:hover::after,
.index-item:focus-within::after {
  background-color: var(--hover-overlay);
  opacity: 1;
}

/* ============================================================
   TYPOGRAPHY
   ============================================================ */

h1, h2, h3 {
  color: var(--title);
  font-weight: 600;
  letter-spacing: -0.01em;
  margin-top: 1.2em;
  margin-bottom: 0.6em;
}

p, li {
  color: var(--text);
  margin-bottom: 0.9em;
}

/* ============================================================
   BUTTONS
   ============================================================ */

button, .btn {
  background: linear-gradient(180deg, rgba(176,139,79,0.08), rgba(176,139,79,0.03));
  color: var(--title);
  border: 1px solid rgba(176,139,79,0.12);
  padding: 8px 12px;
  border-radius: 8px;
  transition: transform .12s ease, box-shadow .12s ease;
}

button:hover, .btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(0,0,0,0.18);
}

.btn-cta {
  background: linear-gradient(180deg, #b8860b, rgba(184,134,11,0.12));
  color: #0f0f10;
  border: 1px solid rgba(0,0,0,0.18);
}

.btn-cta:hover {
  filter: brightness(1.03);
}

/* ============================================================
   CODE BLOCKS
   ============================================================ */

pre, code {
  background: rgba(0,0,0,0.04);
  color: var(--text);
  border-radius: 6px;
  padding: .25rem .5rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, "Roboto Mono", "Courier New", monospace;
}

/* ============================================================
   ACCESSIBILITY
   ============================================================ */

:focus {
  outline: 3px solid var(--focus-ring);
  outline-offset: 2px;
}

.post-card:focus {
  outline: 3px solid var(--focus-ring);
  outline-offset: 4px;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */

@media (max-width: 720px) {
  header { padding: 12px 16px; }
  main { padding: 16px; }
  nav ul { gap: 12px; }
}

.home-wrap {
  padding: 24px;
  max-width: 980px;
  margin: 0 auto;
}

.hero {
  margin-bottom: 28px;
}

.hero h1 {
  margin: 0 0 12px 0;
  color: var(--text);
  font-size: 2rem;
  line-height: 1.05;
}

.hero p {
  margin: 0 0 8px 0;
  color: var(--muted);
  font-size: 1rem;
}

img {
  max-width: 100%;
  height: auto;
  display: block;
}


/* ============================================================
   FOOTER
   ============================================================ */
footer {
  max-width: 980px;
  margin: 0 auto;
  padding: 24px;
  text-align: center;
  color: var(--muted);
  font-size: 0.9rem;
}

/* ============================================================
   CITAZIONE
   ============================================================ */
.double-quote {
  border-left: 3px solid var(--accent);
  border-right: 3px solid var(--accent);
  padding: 1rem 1.5rem;
  margin: 1.5rem 0;
  font-style: italic;
}
/* ============================================================
   FLAG
   ============================================================ */
  .flag {
    width: 18px;
    height: auto;
    vertical-align: middle;
    margin-right: 6px;
    display: inline-block;
  }

.link-inline {
  white-space: nowrap;
}

/* Forza il testo non formattato all'interno dei blocchi codice a rimanere bianco/chiaro */
pre, code {
  color: #e2e8f0 !important; /* Un grigio molto chiaro/bianco */
}

/* Se usi i token Shiki, assicurati che non vengano sovrascritti, lasciando l'important solo al testo base */
pre code span {
  color: inherit;
}

/* --- STILE FISSO PER IL CODICE INLINE (Backtick singoli) --- */
/* Il selettore :not(pre) garantisce di non toccare i blocchi di codice grandi di Shiki */
:not(pre) > code {
  background-color: #1e1e24 !important; /* Grigio scurissimo / antracite */
  color: #f8f8f2 !important;            /* Bianco panna ad alto contrasto */
  padding: 0.2em 0.45em;
  border-radius: 4px;
  font-size: 0.88em;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  word-break: break-word;               /* Evita che scritte lunghe rompano il layout su mobile */
  border: 1px solid #2d2d34;            /* Un leggero bordo per staccare sui fondi totalmente neri */
}

/* ============================================================
   SOCIAL LINKS COMPONENT
   ============================================================ */
.social-links {
  display: flex;
  gap: 18px;               /* Allineato con il gap della tua nav */
  justify-content: center; /* Centrati. Se li metti nella nav o altrove, puoi rimuoverlo */
  align-items: center;
  padding: 12px 0;
}

.social-links a {
  color: var(--text) !important; /* Eredita il verde scuro in Light mode e il crema in Dark mode */
  text-decoration: none !important; /* Rimuove la sottolineatura globale dei link */
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px;
  border-radius: 8px;
  transition: color var(--hover-ease) ease, transform var(--hover-ease) ease;
}

.social-links a:hover,
.social-links a:focus-visible {
  color: var(--accent) !important; /* Diventa blu in Light e azzurro in Dark mode */
  transform: translateY(-2px);     /* Micro-sollevamento in stile card */
  filter: none !important;         /* Rimuove il filtro brightness globale dei link */
}

.social-links a:focus {
  outline: 3px solid var(--focus-ring);
  outline-offset: 2px;
}

.social-links svg {
  width: 24px;
  height: 24px;
  display: block;
}

/* ============================================================
   FOOTER SOCIALS (In riga ed equidistanti)
   ============================================================ */
.footer-socials {
  display: flex;
  justify-content: center; /* Centra il gruppo di icone nel footer */
  align-items: center;
  gap: 24px;               /* Spazio fisso e identico tra OGNI icona (equidistanza) */
  margin-bottom: 16px;     /* Separa le icone dal testo del copyright */
}

.footer-socials a {
  color: var(--text) !important;       /* Colore dinamico basato sul tuo tema */
  text-decoration: none !important;    /* Rimuove la sottolineatura globale */
  display: inline-flex;
  padding: 4px;
  border-radius: 6px;
  transition: color var(--hover-ease) ease, transform var(--hover-ease) ease;
}

.footer-socials a:hover,
.footer-socials a:focus-visible {
  color: var(--accent) !important;     /* Diventa blu/azzurro all'hover */
  transform: translateY(-2px);         /* Effetto sollevamento coerente con le tue card */
  filter: none !important;
}

.footer-socials a:focus {
  outline: 3px solid var(--focus-ring);
  outline-offset: 2px;
}

.footer-socials svg {
  width: 22px;                         /* Dimensione bilanciata per il footer */
  height: 22px;
  display: block;
}

/* Layout generale del post */
.post-article {
  padding: 24px;
  max-width: 900px;
  margin: 0 auto;
}

.post-header {
  margin-bottom: 18px;
  display: block !important;
}

.post-title {
  margin: 0 0 6px 0;
  color: var(--text);
  line-height: 1.3;
}

/* Meta: data + tag su righe separate */
.post-meta {
  color: var(--muted);
  margin-bottom: 18px;
  display: flex;
  flex-direction: column; /* forza data e tag su righe separate */
  gap: 4px;
}

.post-date {
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--muted);
}

/* Tag: colore neutro, NON azzurro */
.post-tags {
  font-size: 0.9rem;
  color: var(--text); /* colore normale del testo */
}

/* Corpo del post */
.post-body {
  background: var(--surface);
  padding: 20px;
  border-radius: 12px;
  box-shadow: var(--card-shadow);
}

.post-body :global(p) {
  color: var(--text);
  line-height: 1.6;
}

/* Footer */
.post-footer {
  margin-top: 28px;
  color: var(--muted);
}

/* Not found */
.notfound-wrap {
  padding: 24px;
  max-width: 900px;
  margin: 0 auto;
  text-align: center;
}

.notfound-card {
  background: var(--surface);
  padding: 28px;
  border-radius: 12px;
  box-shadow: var(--card-shadow);
}

/* Titolo del post: deve stare SEMPRE su una riga separata */
.post-title {
  display: block !important;
  margin: 0 0 6px 0;
  color: var(--text);
  line-height: 1.3;
}

/* --- NOTE IN APICE NEL TESTO --- */
a[href^="#nota-"] {
  font-size: 0.75em;
  vertical-align: super;
  line-height: 1;
  text-decoration: none;
  margin-left: 2px;
  color: var(--accent);
}

/* --- LINK DI RITORNO DALLE NOTE --- */
.nota-back {
  font-size: 0.75em;
  margin-left: 6px;
  text-decoration: none;
  color: var(--accent);
  opacity: 0.8;
}

.nota-back:hover {
  opacity: 1;
}

/* --- STILE DEL NUMERO DELLA NOTA --- */
.nota-num {
  font-weight: 600;
  margin-right: 4px;
}


