/* ------------------------------------------------------------------
   blog.alese.it — same system as www.alese.it: framed page, constellation
   backdrop, display/section/text/mono typefaces, light & dark tokens.
   ------------------------------------------------------------------ */

@font-face {
  font-family: "iA Writer Duospace";
  font-weight: 400;
  font-style: normal;
  font-display: swap;
  src: url("../fonts/iAWriterDuospace-Regular.woff2") format("woff2");
}

:root {
  --font-display: "Heldane Display", "Heldane", "Cormorant Garamond", "Iowan Old Style", Georgia, serif;
  --font-section: "Lyon Text", "Lyon", "EB Garamond", Garamond, Georgia, serif;
  --font-text: "Newsam", "Source Sans 3", "Helvetica Neue", Arial, sans-serif;
  --font-mono: "iA Writer Duospace", Menlo, Consolas, monospace;

  --bg: #ffffff;
  --fg: #1a1a1a;
  --muted: #444444;
  --frame: #dcdcdc;
  --rule: #e8e8e8;
  --net: #e4e4e4;
  --field: #fafafa;
  --control: #6b6b6b;
  --focus: #1a5fb4;
  --chip-dark: #2b2b2b;
  --chip-dark-fg: #ffffff;

  --chip-y: #f6b73c; --chip-y-fg: #282828;
  --chip-g: #4cb56f; --chip-g-fg: #0f2a19;
  --chip-r: #f07a8f; --chip-r-fg: #33101a;

  --frame-inset: 12px;
  --gutter: clamp(24px, 6vw, 80px);
  --content-width: 1120px;
  --measure: 720px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #151515; --fg: #ececec; --muted: #b0b0b0; --frame: #3a3a3a; --rule: #2a2a2a;
    --net: #242424; --field: #1b1b1b; --control: #9a9a9a; --focus: #8ab4f8;
    --chip-dark: #ececec; --chip-dark-fg: #151515;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #151515; --fg: #ececec; --muted: #b0b0b0; --frame: #3a3a3a; --rule: #2a2a2a;
  --net: #242424; --field: #1b1b1b; --control: #9a9a9a; --focus: #8ab4f8;
  --chip-dark: #ececec; --chip-dark-fg: #151515;
  color-scheme: dark;
}

/* ---- base ---- */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  padding: var(--frame-inset);
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-text);
  font-size: 18px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; border-radius: 2px; }
.skip-link {
  position: absolute; left: 16px; top: -100px; z-index: 100;
  padding: 12px 16px; background: var(--fg); color: var(--bg); font-weight: 600;
}
.skip-link:focus { top: 16px; text-decoration: none; }
img { max-width: 100%; height: auto; }

.backdrop { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 0; }
.backdrop-lines { stroke: var(--net); stroke-width: 0.7; fill: none; }
.backdrop-dots { fill: var(--net); }

.frame {
  position: relative; z-index: 1;
  display: flex; flex-direction: column;
  min-height: calc(100vh - 2 * var(--frame-inset));
  border: 1px solid var(--frame);
  padding: 0 var(--gutter);
}
.site-header, .site-main, .site-footer {
  width: 100%; max-width: var(--content-width);
  margin-left: auto; margin-right: auto;
}
.site-main { flex: 1; }

/* ---- header ---- */
.site-header {
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap;
  gap: 12px 24px; padding: 40px 0 0;
}
.logo { font-family: var(--font-mono); font-size: 22px; white-space: nowrap; }
.logo span { color: var(--muted); }
.site-nav { display: flex; flex-wrap: wrap; gap: 0 32px; margin-left: auto; }
.site-nav a { display: inline-flex; align-items: center; min-height: 44px; font-size: 16px; font-weight: 600; }
.site-nav a[aria-current="page"] { text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 6px; }
.header-actions { display: flex; align-items: center; gap: 12px; }
.icon-button {
  display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; padding: 0;
  border: 1px solid var(--control); border-radius: 999px;
  background: transparent; color: var(--fg); cursor: pointer;
}
.icon-button:hover { border-color: var(--fg); }
.icon-sun { display: none; }
/* Language switcher shows the flag of the language you would switch to. */
.flag { display: block; border-radius: 1px; }
.flag-it { display: none; }
:root[data-lang="en"] .flag-en { display: none; }
:root[data-lang="en"] .flag-it { display: block; }
/* Bilingual interface strings: Italian unless the root says English. */
.t[lang="en"] { display: none; }
:root[data-lang="en"] .t[lang="it"] { display: none; }
:root[data-lang="en"] .t[lang="en"] { display: inline; }
:root[data-theme="dark"] .icon-sun { display: block; }
:root[data-theme="dark"] .icon-moon { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .icon-sun { display: block; }
  :root:not([data-theme="light"]) .icon-moon { display: none; }
}

/* ---- hero (home) ---- */
.hero {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 28px; min-height: min(440px, 55vh); padding: 48px 0 40px; text-align: center;
}
.hero-name {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(56px, 9vw, 128px);
  font-weight: 700; line-height: 0.98; letter-spacing: -0.02em;
}
.hero-intro { max-width: 660px; margin: 0; font-size: 19px; line-height: 1.8; }

/* ---- section heads (archive pages, comments) ---- */
.section-head { display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center; padding: 56px 0 16px; }
.section-label { font-family: var(--font-mono); font-size: 15px; color: var(--muted); }
.section-head h1, .section-head h2 {
  margin: 0; font-family: var(--font-section);
  font-size: 40px; font-weight: 600; line-height: 1.1; letter-spacing: -0.01em;
}

/* ---- chips ---- */
.chip {
  display: inline-block; padding: 1px 6px;
  font-family: var(--font-text); font-size: 14px; font-weight: 600; line-height: 1.5;
  color: var(--fg); background: transparent; white-space: nowrap;
}
.chip-y { background: var(--chip-y); color: var(--chip-y-fg); }
.chip-g { background: var(--chip-g); color: var(--chip-g-fg); }
.chip-r { background: var(--chip-r); color: var(--chip-r-fg); }
.chip-d { background: var(--chip-dark); color: var(--chip-dark-fg); }
a.chip { transition: filter 0.15s ease, transform 0.15s ease; }
a.chip:hover, a.chip:focus-visible { text-decoration: none; filter: brightness(0.92); transform: translateY(-1px); }

.ulink {
  display: inline-block; padding-bottom: 2px;
  font-size: 16px; font-weight: 600; border-bottom: 2px solid var(--fg);
}
.ulink:hover { text-decoration: none; opacity: 0.7; }

/* ---- post list ---- */
.post-list { list-style: none; margin: 0 auto; padding: 0 0 64px; max-width: var(--measure); }
.post-list > li { border-top: 1px solid var(--rule); }
.post-list > li:last-child { border-bottom: 1px solid var(--rule); }
.preview { display: flex; flex-direction: column; gap: 10px; padding: 32px 0; }
.post-meta {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; margin: 0;
  font-family: var(--font-mono); font-size: 15px; color: var(--muted);
}
.post-meta .cats { display: flex; flex-wrap: wrap; gap: 6px; }
.preview-title { margin: 0; font-family: var(--font-section); font-size: 30px; font-weight: 600; line-height: 1.2; letter-spacing: -0.01em; }
.preview-title a:hover { text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 4px; }
.preview-excerpt { margin: 0; font-size: 17px; line-height: 1.65; color: var(--fg); }
.preview .ulink { align-self: flex-start; margin-top: 4px; }

.pagination { display: flex; justify-content: center; gap: 6px; margin: 0 0 64px; font-family: var(--font-mono); font-size: 15px; }
.pagination a { display: inline-flex; align-items: center; justify-content: center; min-width: 40px; height: 40px; padding: 0 10px; border: 1px solid var(--rule); }
.pagination a:hover { border-color: var(--fg); text-decoration: none; }
.pagination a.active { background: var(--fg); color: var(--bg); border-color: var(--fg); }

/* ---- single post ---- */
.post { width: 100%; max-width: var(--measure); margin: 0 auto; padding: 48px 0 64px; }
.post-header { display: flex; flex-direction: column; gap: 18px; margin-bottom: 40px; }
.post-title {
  margin: 0; font-family: var(--font-display);
  font-size: clamp(40px, 6vw, 64px); font-weight: 700; line-height: 1.02; letter-spacing: -0.02em;
}
.post-cover { margin: 8px 0 0; }
.post-cover img { display: block; width: 100%; border: 1px solid var(--rule); }

.post-content { font-size: 18px; line-height: 1.7; }
.post-content > * { margin: 0 0 1.25em; }
.post-content > *:last-child { margin-bottom: 0; }
.post-content h2, .post-content h3, .post-content h4 {
  font-family: var(--font-section); font-weight: 600; line-height: 1.2; letter-spacing: -0.01em;
  margin: 2em 0 0.6em;
}
.post-content h2 { font-size: 30px; }
.post-content h3 { font-size: 24px; }
.post-content h4 { font-size: 20px; }
.post-content a { text-decoration: underline; text-decoration-color: var(--control); text-underline-offset: 3px; }
.post-content a:hover { text-decoration-color: var(--fg); }
.post-content strong { font-weight: 600; }
.post-content blockquote {
  margin: 1.5em 0; padding: 4px 0 4px 24px; border-left: 1px solid var(--fg);
  font-family: var(--font-section); font-size: 21px; line-height: 1.55; color: var(--fg);
}
.post-content blockquote > *:last-child { margin-bottom: 0; }
.post-content ul, .post-content ol { padding-left: 1.4em; }
.post-content li { margin: 0.3em 0; }
.post-content hr { border: 0; height: 1px; background: var(--rule); margin: 2.5em auto; width: 120px; }
.post-content img { display: block; margin: 0 auto; }
.post-content figure { margin: 1.5em 0; }
.post-content figcaption { margin-top: 8px; font-family: var(--font-mono); font-size: 14px; color: var(--muted); text-align: center; }
.post-content code, .post-content pre, .post-content kbd { font-family: var(--font-mono); }
.post-content code { font-size: 0.88em; padding: 0.1em 0.35em; background: var(--field); border: 1px solid var(--rule); }
.post-content pre, .post-content .highlight { overflow-x: auto; }
.post-content pre {
  padding: 16px 18px; background: var(--field); border: 1px solid var(--rule);
  font-size: 15px; line-height: 1.55; -webkit-text-size-adjust: none;
}
.post-content pre code { padding: 0; border: 0; background: none; font-size: inherit; }
.post-content table { border-collapse: collapse; font-size: 16px; }
.post-content th, .post-content td { padding: 6px 12px; border-bottom: 1px solid var(--rule); text-align: left; }
.post-content th { font-weight: 600; }
.post-content iframe { max-width: 100%; }

.post-footer { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 16px 32px; margin-top: 56px; padding-top: 24px; border-top: 1px solid var(--rule); }
.post-nav { display: flex; flex-direction: column; gap: 6px; max-width: 48%; margin: 0; }
.post-nav.next { margin-left: auto; text-align: right; }
.post-nav .label { font-family: var(--font-mono); font-size: 14px; color: var(--muted); }
.post-nav a { font-family: var(--font-section); font-size: 20px; font-weight: 600; line-height: 1.3; }

/* ---- comments ---- */
.comments { width: 100%; max-width: var(--measure); margin: 0 auto; padding: 0 0 64px; }
.comments .section-head { padding-top: 24px; }
.comments-note { margin: 0 0 8px; text-align: center; font-size: 15px; color: var(--muted); }
.comment { display: flex; flex-direction: column; gap: 6px; padding: 20px 0 20px 24px; border-left: 1px solid var(--rule); }
.comment header { display: flex; flex-wrap: wrap; gap: 4px 14px; align-items: baseline; }
.comment header strong { font-weight: 600; font-size: 17px; }
.comment header time { font-family: var(--font-mono); font-size: 14px; color: var(--muted); }
.comment-body { font-size: 17px; line-height: 1.65; }
.comment-body p { margin: 0 0 0.75em; }
.comment-body p:last-child { margin-bottom: 0; }
.comment-body a { text-decoration: underline; text-decoration-color: var(--control); }

/* ---- 404 ---- */
.notfound { display: flex; flex-direction: column; align-items: center; gap: 20px; min-height: 50vh; padding: 64px 0; text-align: center; }

/* ---- footer ---- */
.site-footer {
  display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px 24px;
  padding: 28px 0 32px; border-top: 1px solid var(--rule);
  font-size: 15px; color: var(--muted);
}
.site-footer .logo { font-size: 17px; color: var(--fg); }
.site-footer nav { display: flex; gap: 20px; }
.site-footer a:hover { color: var(--fg); }

/* ---- responsive ---- */
@media (max-width: 800px) {
  :root { --frame-inset: 8px; }
  .site-header { padding-top: 24px; }
  .logo { font-size: 20px; }
  .site-nav { gap: 0 20px; margin-left: 0; order: 3; width: 100%; }
  .site-nav a { min-height: 40px; }
  .hero { min-height: 320px; gap: 20px; padding: 32px 0 24px; }
  .hero-intro { font-size: 17px; }
  .section-head { padding-top: 40px; }
  .section-head h1, .section-head h2 { font-size: 32px; }
  .preview { padding: 24px 0; }
  .preview-title { font-size: 26px; }
  .post { padding-top: 32px; }
  .post-content { font-size: 17px; }
  .post-content h2 { font-size: 26px; }
  .post-content blockquote { font-size: 19px; padding-left: 16px; }
  .post-nav, .post-nav.next { max-width: 100%; text-align: left; margin-left: 0; }
  .site-footer { flex-direction: column; text-align: center; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  a.chip { transition: none; }
}
