<head>
  <meta charset="UTF-8" />
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  <script>(function(){var s=localStorage.getItem('theme')||(window.matchMedia('(prefers-color-scheme: light)').matches?'light':'dark');document.documentElement.classList.add('theme-'+s);})();</script>

  {{/* ── Primary Meta ──────────────────────────────── */}}
  <title>{{ .Site.Title }}</title>
  {{ $desc := .Params.description | default .Site.Params.description }}
  <meta name="description" content="{{ $desc }}" />
  <meta name="author"      content="{{ .Site.Params.name }}" />
  <meta name="robots"      content="index, follow" />
  <link rel="canonical"    href="{{ .Permalink }}" />

  {{/* ── Hreflang (multilingual) ───────────────────── */}}
  {{ range .Site.Home.AllTranslations }}
  <link rel="alternate" hreflang="{{ .Language.Lang }}" href="{{ .Permalink }}" />
  {{ end }}
  <link rel="alternate" hreflang="x-default" href="{{ .Site.Home.Permalink }}" />

  {{/* ── Open Graph ───────────────────────────────── */}}
  {{ $ogImage := .Params.og_image | default .Site.Params.og_image }}
  <meta property="og:type"        content="website" />
  <meta property="og:url"         content="{{ .Permalink }}" />
  <meta property="og:title"       content="{{ .Site.Title }}" />
  <meta property="og:description" content="{{ $desc }}" />
  {{ with $ogImage }}<meta property="og:image" content="{{ . | absURL }}" />{{ end }}
  <meta property="og:locale"      content="{{ .Site.Language.Params.og_locale | default .Site.Language.Lang }}" />
  {{ range .Site.Home.AllTranslations }}{{ if ne .Language.Lang $.Site.Language.Lang }}
  <meta property="og:locale:alternate" content="{{ .Language.Params.og_locale | default .Language.Lang }}" />
  {{ end }}{{ end }}

  {{/* ── Twitter / X Card ────────────────────────── */}}
  <meta name="twitter:card"        content="summary_large_image" />
  <meta name="twitter:title"       content="{{ .Site.Title }}" />
  <meta name="twitter:description" content="{{ $desc }}" />
  {{ with $ogImage }}<meta name="twitter:image" content="{{ . | absURL }}" />{{ end }}

  {{/* ── Geo (local SEO — Italy) ────────────────── */}}
  <meta name="geo.region"    content="IT" />
  <meta name="geo.placename" content="Italy" />

  {{/* ── Favicon & icons ─────────────────────────── */}}
  {{ with .Site.Params.favicon }}<link rel="icon" href="{{ . }}">{{ end }}
  <link rel="apple-touch-icon" href="{{ .Site.Params.favicon | default "/img/fav.png" }}" />
  <meta name="theme-color" content="#06080b" media="(prefers-color-scheme: dark)" />
  <meta name="theme-color" content="#f0f4f8" media="(prefers-color-scheme: light)" />

  {{/* ── JSON-LD: Person schema ───────────────────── */}}
  {{- $photo := .Params.about_photo | default "/img/Danilo_profile.jpg" -}}
  {{- $links := slice -}}
  {{- range hugo.Data.contact -}}{{- with .href -}}{{- $links = $links | append . -}}{{- end -}}{{- end -}}
  <script type="application/ld+json">
  {
    "@context": "https://schema.org",
    "@type": "Person",
    "name": {{ .Site.Params.name | jsonify }},
    "url": {{ .Site.BaseURL | strings.TrimSuffix "/" | jsonify }},
    "image": {{ $photo | absURL | jsonify }},
    "jobTitle": {{ i18n "terminal_role" | jsonify }},
    "description": {{ $desc | jsonify }},
    "sameAs": [{{ range $i, $link := $links }}{{ if $i }},{{ end }}{{ $link | jsonify }}{{ end }}]
  }
  </script>

  {{/* ── Preconnect ───────────────────────────────── */}}
  <link rel="preconnect" href="https://fonts.googleapis.com" />
  <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
  <link rel="preconnect" href="https://cdnjs.cloudflare.com" />

  {{/* ── Stylesheets ──────────────────────────────── */}}
  <link href="https://fonts.googleapis.com/css2?family=JetBrains+Mono:ital,wght@0,300;0,400;0,500;0,700;1,300&family=Oxanium:wght@700;800&display=swap" rel="stylesheet" />
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.7.2/css/all.min.css" integrity="sha384-nRgPTkuX86pH8yjPJUAFuASXQSSl2/bBUiNV47vSYpKFxHJhbcrGnmlYpYJMeD7a" crossorigin="anonymous" />
  <link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/lipis/flag-icons@7.2.3/css/flag-icons.min.css" integrity="sha384-aQuvIWWIbpu/mSqULLDiUveyYiPoJzPKAWjUmGJ+Elm+N/LJhzfZqsutsfw870JS" crossorigin="anonymous" />
  {{ $css := resources.Get "css/main.css" }}
  {{ if hugo.IsProduction }}{{ $css = $css | minify | fingerprint }}{{ end }}
  <link rel="stylesheet" href="{{ $css.RelPermalink }}" />
</head>
