/* =========================================================
   1) CSS VARIABLES (Design Tokens)
   ---------------------------------------------------------
   Shared values used across themes and components.
========================================================= */
:root{
  --radius:14px;
  --maxw:1000px;
  --shadow:0 10px 30px rgba(0,0,0,.25);

  /* Fallback colors (same as light theme) */
  --bg:     #F5FAFF;
  --panel:  #FFFFFF;
  --text:   #111827;
  --muted:  #6B7280;
  --brand:  #2563EB;
  --accent: #059669;

  /* Softer shadow used by “modern” cards */
  --shadow-soft: 0 10px 28px rgba(0,0,0,.12);

  /* Home layout/tuning variables */
  --topbar-h: 72px;
  --home-gap-mobile: 22px;
  --home-gap-desktop: clamp(18px, 2.2vw, 34px);

  /* Card style (theme-tuned below) */
  --card-border: rgba(0,0,0,.08);
  --card-bg: rgba(255,255,255,.68);
  --card-shadow: 0 14px 34px rgba(0,0,0,.10);
}

/* =========================================================
   2) THEME OVERRIDES
   ---------------------------------------------------------
   Only override semantic variables (colors, shadows, etc.).
========================================================= */

/* LIGHT THEME – Soft Blue minimal */
html[data-theme="light"] {
  --bg:     #f6f4f1;
  --panel:  #fdfcfa;
  --text:   #1c1410;
  --muted: #5a5550;
  --brand:  #b5460f;  /* ruggine */
  --accent: #c2621a;
}

/* DARK THEME – Minimal Gemini */
html[data-theme="dark"] {
  --bg:         #26272b;
  --panel:      #32333a;
  --text:       #f5f5f5;
  --muted:      #a0a0a5;
  --brand:      #60a5fa;
  --accent:     #4d9ef7;
  --card-border: rgba(255,255,255,.12);
  --card-bg:    #32333a;
  --card-shadow: 0 12px 32px rgba(0,0,0,.35);
}

/* ===== Tags: readable in LIGHT mode ===== */
html[data-theme="light"] .tag {
  color: #7a2a06;
  border-color: rgba(181, 70, 15, .30);
  background: rgba(181, 70, 15, .08);
}
html[data-theme="dark"] .tag {
  color: #9dbfb0;
  border-color: rgba(157, 191, 176, .38);
  background: transparent;
}

/* =========================================================
   3) SCROLLBAR (themed + elegant)
   ---------------------------------------------------------
   Use the viewport scrollbar (html) so it spans the full page
   including fixed topbar area. Keep it subtle and theme-aware.
========================================================= */

/* Ensure the scrolling element is the document (full-height scrollbar) */
html{
  overflow-y: auto;   /* niente gutter riservato */
  overscroll-behavior-y: none;
}

body{
  overscroll-behavior-y: none;
}

/* Firefox */
html{
  scrollbar-width: thin;
  scrollbar-color: rgba(0,0,0,.35) rgba(0,0,0,.06); /* thumb / track */
}
html[data-theme="dark"]{
  scrollbar-color: rgba(255,255,255,.28) rgba(255,255,255,.06);
}

/* WebKit (Chrome/Edge/Safari) */
html::-webkit-scrollbar{
  width: 10px;
}
html::-webkit-scrollbar-track{
  background: rgba(0,0,0,.06);
}
html::-webkit-scrollbar-thumb{
  background: rgba(0,0,0,.30);
  border-radius: 999px;
  border: 3px solid rgba(0,0,0,.06);  /* makes it look “floating” */
}
html::-webkit-scrollbar-thumb:hover{
  background: rgba(0,0,0,.42);
}

/* Dark theme */
html[data-theme="dark"]::-webkit-scrollbar-track{
  background: rgba(255,255,255,.06);
}
html[data-theme="dark"]::-webkit-scrollbar-thumb{
  background: rgba(255,255,255,.22);
  border: 3px solid rgba(255,255,255,.06);
}
html[data-theme="dark"]::-webkit-scrollbar-thumb:hover{
  background: rgba(255,255,255,.32);
}


/* =========================================================
   4) BASE / RESET
   ---------------------------------------------------------
   Minimal reset + app layout baseline.
========================================================= */
html,body{ height:100%; }

/* Safety: prevent horizontal scroll from small overflows */
html, body{ overflow-x:hidden; }

*, *::before, *::after{ box-sizing:border-box; }

body{
  margin:0;
  background:var(--bg);
  color:var(--text);
  font-family:system-ui,-apple-system,Segoe UI,Roboto,Helvetica,Arial;
  line-height:1.6;
  display:flex;
  flex-direction:column;
  min-height:100vh;
  min-height:100dvh;
}

/* Make <main> grow to push footer down */
main{
  flex:1;
  width:100%;
}

img{
  max-width:100%;
  display:block;
}

/* =========================================================
   5) GENERIC LAYOUT UTILITIES
   ---------------------------------------------------------
   Reusable helpers for layout and grids (desktop-first).
========================================================= */
.container{ 
  width:min(100% - 4rem,var(--maxw)); 
  margin-inline:auto; 
}
.row{ display:flex; gap:1rem; align-items:center; flex-wrap:wrap; }
.space-between{ justify-content:space-between; }

.grid{ display:grid; gap:1rem; }
.grid-3{ grid-template-columns:repeat(3,minmax(0,1fr)); }

.two-col{
  display:grid;
  grid-template-columns:1.2fr .8fr;
  gap:2rem;
}

/* =========================================================
   6) GENERIC UI COMPONENTS
   ---------------------------------------------------------
   Buttons, badges, cards, tags, inputs.
========================================================= */
.btn{
  display:inline-flex;
  align-items:center;
  gap:.5rem;
  padding:.75rem 1.1rem;
  border-radius:calc(var(--radius) - 4px);
  background:var(--brand);
  color:#fff;
  border:none;
  box-shadow:0 3px 10px rgba(0,0,0,.15);
  font-weight:600;
  text-decoration:none;
  transition:transform .15s ease, box-shadow .15s ease, filter .15s ease;
}

.btn:hover{
  text-decoration:none;
  transform:translateY(-1px);
  filter:brightness(1.08);
  box-shadow:0 6px 18px rgba(0,0,0,.2);
}

/* Outline variant */
.btn-outline{
  background:transparent;
  color:var(--text);
  box-shadow:none;
}

/* =========================================================
   LIGHT: Research links behave like "ghost buttons"
========================================================= */

/* Base state (no visible button chrome) */
html[data-theme="light"]
.research-panel:not(.research-panel--projects)
.btn,
html[data-theme="light"]
.research-panel:not(.research-panel--projects)
.btn-outline{
  background: transparent;
  border: 2px solid transparent; /* keep button sizing/area */
  box-shadow: none;
  color: var(--brand);
}

/* Research panels: use flat panel color */
.research-panel{
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  box-shadow: var(--card-shadow);
  backdrop-filter: blur(10px);
}

html[data-theme="dark"] .research-panel{
  border-color: rgba(255,255,255,.10);
}

/* Hover state: underline + tiny lift (button feel) */
html[data-theme="light"]
.research-panel:not(.research-panel--projects)
.btn:hover,
html[data-theme="light"]
.research-panel:not(.research-panel--projects)
.btn-outline:hover{
  background: transparent;
  border-color: transparent;
  box-shadow: none;

  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-thickness: 2px;

  transform: translateY(-1px);
  filter: none;
}

/* =========================================================
   DARK: Research links behave like "ghost buttons" (same as light)
========================================================= */

/* Base state (no visible button chrome) */
html[data-theme="dark"]
.research-panel:not(.research-panel--projects)
.btn,
html[data-theme="dark"]
.research-panel:not(.research-panel--projects)
.btn-outline{
  background: transparent;
  border: 2px solid transparent; /* keep button sizing/area */
  box-shadow: none;
  color: var(--brand);
}

/* Hover state: underline + tiny lift (button feel) */
html[data-theme="dark"]
.research-panel:not(.research-panel--projects)
.btn:hover,
html[data-theme="dark"]
.research-panel:not(.research-panel--projects)
.btn-outline:hover{
  background: transparent;
  border-color: transparent;
  box-shadow: none;

  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-thickness: 2px;

  transform: translateY(-1px);
  filter: none;
}

/* ===== Buttons: make btn-outline actually visible in LIGHT mode ===== */
html[data-theme="light"] .btn-outline{
  border: 2px solid var(--brand);
  color: var(--brand);
  background: transparent;
}

html[data-theme="light"] .btn-outline:hover{
  background: var(--brand);
  color: #fff;
}

/* Small pill badge */
.badge{
  display:inline-block;
  padding:.3rem .6rem;
  border-radius:999px;
  background:rgba(79,70,229,.14);
  color:#cdd0ff;
  font-weight:600;
  font-size:.85rem;
}

/* Generic “card” look (used in various places) */
.card{
  background:linear-gradient(180deg,rgba(255,255,255,.04),rgba(255,255,255,.02));
  border:1px solid rgba(255,255,255,.08);
  border-radius:var(--radius);
  padding:1rem;
  box-shadow:var(--shadow);
}

/* Text input */
.input{
  padding:.6rem .8rem;
  border-radius:10px;
  border:1px solid rgba(255,255,255,.16);
  background:rgba(17,19,26,.6);
  color:var(--text);
}

/* Tags */
.tags{ display:flex; flex-wrap:wrap; gap:.4rem; }
.tag{
  padding:.25rem .55rem;
  border:1px solid rgba(255,255,255,.2);
  border-radius:999px;
  font-size:.85rem;
  color:#cfe7d7;
}

/* =========================================================
   7) TYPOGRAPHY & GENERIC SECTIONS
========================================================= */
.hero{ padding:4.5rem 0 3rem; }
.hero h1{ font-size:clamp(2.2rem,2.5vw,3rem); line-height:1.15; margin:.2rem 0; }

.kicker{ color:var(--muted); font-size:1rem; }
.section{ margin:2.2rem 0; }

/* ===== Page titles spacing (STANDARD) ===== */

.section.section-head{
  margin-bottom: 1.4rem;   /* intro -> next section */
}

/* Remove the extra top margin on the section that follows the header */
.section.section-head + .section{
  margin-top: 0;
}

/* Title spacing */
.section.section-head h1{
  margin: 0;
}

/* Intro paragraph spacing (title -> intro, and default intro -> content) */
.page-intro{
  margin: .65rem 0 1.4rem; /* title -> intro AND intro -> content */
  max-width: none;
}

/* If the intro is inside a header section, do not add extra bottom gap
   because the section itself already provides it (margin-bottom: 1.4rem). */
.section.section-head .page-intro{
  margin-bottom: 0;
}

/* =========================================================
   INLINE LINKS — minimal, elegant, academic
========================================================= */

/* External / inline links – clean brand style */
.inline-link{
  color: var(--brand);
  text-decoration: none;
  border-bottom: none;
  transition: text-decoration .15s ease, opacity .15s ease;
}

.inline-link:hover{
  text-decoration: underline;
  text-underline-offset: 2px;
  text-decoration-thickness: 1px;
}

/* =========================================================
   Markdown content styling (figures, captions, etc.)
========================================================= */

/* Markdown content styling */
.markdown-body figure,
.post-page-body figure{
  margin: 1.8rem 0;
  text-align: center;
}

.markdown-body figure img,
.post-page-body figure img{
  width: 100%;
  height: auto;
  display: block;
  border-radius: 16px;
  border: 1px solid rgba(0,0,0,.10);
  box-shadow: var(--shadow-soft);
}

html[data-theme="dark"] .markdown-body figure img,
html[data-theme="dark"] .post-page-body figure img{
  border-color: rgba(255,255,255,.14);
}

.markdown-body figcaption,
.post-page-body figcaption{
  margin-top: .6rem;
  font-size: .9rem;
  color: var(--muted);
  text-align: center;
}

.markdown-body figure img{
  width: 100%;
  height: auto;
  display: block;
  border-radius: 16px;
  border: 1px solid rgba(0,0,0,.10);
  box-shadow: var(--shadow-soft);
}

html[data-theme="dark"] .markdown-body figure img{
  border-color: rgba(255,255,255,.14);
}

.markdown-body figcaption{
  margin-top: .5rem;
  font-size: .92rem;
  color: var(--muted);
  text-align: center;
}

/* =========================================================
   8) CONTENT PATTERNS (lists, timeline, publications)
========================================================= */
.list{ display:grid; gap:.9rem; }

.timeline{ position:relative; }
.timeline::before{
  content:"";
  position:absolute;
  left:.5rem;
  top:0;
  bottom:0;
  width:2px;
  background:rgba(255,255,255,.15);
}

.tl-item{ position:relative; padding-left:2rem; }
.tl-dot{
  position:absolute;
  left:.2rem;
  top:.4rem;
  width:.7rem;
  height:.7rem;
  border-radius:50%;
  background:var(--accent);
}

.pub-card{
  display:grid;
  gap:.35rem;
  padding:1rem;
  border:1px solid rgba(255,255,255,.08);
  border-radius:12px;
}

.pub-meta{ color:var(--muted); font-size:.98rem; }

.toolbar{
  display:flex;
  flex-wrap:wrap;
  gap:.6rem;
  align-items:center;
  margin:.6rem 0;
}

/* =========================================================
   9) SITE CHROME (header/footer/topbar/nav)
   ---------------------------------------------------------
   Global UI that appears across pages.
========================================================= */

/* --- Sticky header wrapper (if used) --- */
.site-header{
  position:sticky;
  top:0;
  z-index:40;
  background:var(--bg);
  border-bottom:1px solid rgba(15,23,42,.06);
  backdrop-filter:blur(4px);
}
html[data-theme="dark"] .site-header{
  border-bottom-color:rgba(255,255,255,.08);
}

/* =========================================================
   FOOTER – single line, centered, aligned
========================================================= */

.site-footer{
  margin-top: 0;
  border-top: none;
  padding: .65rem 0;
  background: var(--bg);
  color: var(--muted);
  font-size: .82rem;
  flex-shrink: 0;
}

#year{
  margin-right: .45rem;
}

.footer-content{
  display: flex;
  justify-content: center;
}

/* ONE ROW */
.footer-inline{
  display: inline-flex;
  align-items: center;           /* same height baseline */
  justify-content: center;
  gap: .75rem;                   /* air between blocks */
  line-height: 1;                /* prevents text sitting lower */
  white-space: nowrap;           /* keep in ONE line */
}

/* Icons group */
.footer-icons{
  display: inline-flex;
  align-items: center;           /* aligns icons with text */
  gap: .55rem;
}

/* Separator dot */
.footer-sep{
  opacity: .40;
  transform: translateY(-.5px);  /* tiny optical alignment */
}

/* Copyright text */
.footer-text{
  display: inline-flex;
  align-items: center;
}

/* Privacy link */
.footer-link{
  color: var(--muted);
  text-decoration: none;
  font-weight: 500;
  transition: color .2s ease;
}
.footer-link:hover{
  color: var(--brand);
}

/* Mono icons (mask) */
.footer-icon{
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.footer-icon--mono{
  width: 28px;
  height: 28px;
  border-radius: 8px;

  background-color: currentColor;
  color: rgba(11,18,32,.55);

  -webkit-mask: var(--icon-url) no-repeat center / 18px 18px;
  mask: var(--icon-url) no-repeat center / 18px 18px;

  transition: color .15s ease, transform .15s ease, opacity .15s ease;
  opacity: .95;
}

html[data-theme="dark"] .footer-icon--mono{
  color: rgba(245,245,245,.72);
}

.footer-icon--mono:hover{
  color: var(--brand);
  transform: translateY(-1px);
  opacity: 1;
}

.footer-icon--mono img{
  display: none;
}

@media (max-width: 520px){
  .site-footer{
    padding: .5rem 0 calc(.65rem + env(safe-area-inset-bottom, 0px));
    font-size: .76rem;
  }

  .footer-content{
    justify-content: center;
  }

  .footer-inline{
    width: auto;
    max-width: 100%;
    gap: .45rem;
    justify-content: center;
    flex-wrap: wrap;
    white-space: normal;
    text-align: center;
  }

  .footer-icons{
    gap: .4rem;
  }

  .footer-icon--mono{
    width: 24px;
    height: 24px;
    -webkit-mask-size: 16px 16px;
    mask-size: 16px 16px;
  }

  .footer-sep{
    opacity: .28;
  }

  .footer-text,
  .footer-link{
    font-size: .76rem;
  }

  #year{
    margin-right: .25rem;
  }

  main{
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }
}

/* --- Topbar (full-width control bar) --- */
.topbar{
  position:sticky;
  top:0;
  left:0;
  z-index:1000;
  width:100%;

  /* same as page background */
  background: var(--bg);

  /* thin separator line (always visible) */
  border-bottom: 1px solid rgba(0,0,0,.10);
}
html[data-theme="dark"] .topbar{
  border-bottom-color: rgba(255,255,255,.12);
}

main{
  padding-top: 0;
}


/* Inner: full-width (no container max-width) */
.topbar-inner{
  display:flex;
  justify-content:space-between;
  align-items:center;
  padding:.7rem 1.4rem;
  max-width:100%;
}

/* Left group: hamburger + brand + nav */
.topbar-left{
  display:flex;
  align-items:center;
  gap:1.2rem;
}

/* Right group: language + theme */
.topbar-right{
  display:flex;
  align-items:center;
  gap:.5rem;
}

/* Brand link */
.brand-link{
  font-size:1.3rem;
  font-weight:850;
  letter-spacing:-0.02em;
  text-decoration:none;
  white-space:nowrap;
  color:var(--text);
  font-family:'Inter', system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial;
  transition:opacity .2s ease, transform .2s ease;
}
.brand-link:hover{
  opacity:.85;
  transform:translateY(-1px);
}
html[data-theme="dark"] .brand-link{
  color:#f5f5f5;
}

/* Desktop primary nav */
.primary-nav{
  display:flex;
  align-items:center;
  gap:.75rem;
}

.nav-item{
  font-size:.93rem;
  font-weight:600;
  text-decoration:none;
  color:var(--muted);
  padding:.25rem .7rem;
  border-radius:999px;
  border:1px solid transparent;
  transition:background .15s ease, color .15s ease, border-color .15s ease;
}


.nav-item:hover{
  border-color: transparent;   /* remove outline */
  background: transparent;     /* no pill effect */
  color: var(--brand);         /* subtle highlight */
}

/* Active link */
/* Active link: text-only highlight (no pill) */
.nav-item.active{
  background: transparent;
  border-color: transparent;
  color: var(--brand);
  font-weight: 800;
}


/* Hamburger toggle (shown on mobile only) */
.nav-toggle{
  display:none;
  align-items:center;
  justify-content:center;
  flex-direction:column;
  width:34px;
  height:34px;
  border-radius:999px;
  border:1px solid transparent;
  background:transparent;
  padding:0;
  cursor:pointer;
}

.nav-toggle span{
  display:block;
  width:18px;
  height:2px;
  border-radius:999px;
  background:#64748b;
  margin:2px 0;
  transition:transform .18s ease, opacity .18s ease;
}
html[data-theme="dark"] .nav-toggle span{
  background:#e5e7eb;
}

/* Mobile drawer nav (side panel) */
.mobile-nav{
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;

  width: min(280px, 82vw);
  padding: 1.0rem 1.0rem 1.2rem;

  background: var(--panel);
  border-right: 1px solid rgba(15,23,42,.10);

  display: flex;
  flex-direction: column;
  gap: .35rem;

  z-index: 1200;

  /* closed by default */
  transform: translateX(-105%);
  transition: transform .22s ease;
}

html[data-theme="dark"] .mobile-nav{
  border-right-color: rgba(255,255,255,.12);
}

.mobile-nav.open{
  transform: translateX(0);
}

.mobile-nav .nav-item{
  width: 100%;
  padding: .55rem .7rem;
  border-radius: 12px;
}

/* Overlay when drawer is open */
body.nav-open::before{
  content:"";
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.35);
  z-index: 1100;
}
html[data-theme="dark"] body.nav-open::before{
  background: rgba(0,0,0,.55);
}

.topbar-btn{
  display:inline-flex;
  align-items:center;
  gap:.35rem;
  padding:.35rem .6rem;

  background: transparent;
  border: none;                      /* no visible border */
  border-radius: 999px;              /* pill but invisible */

  cursor:pointer;
  color: var(--text);

  transition: background .18s ease, transform .15s ease;
}

.topbar-btn:hover{
  background: rgba(0,0,0,.06);
}

html[data-theme="dark"] .topbar-btn:hover{
  background: rgba(255,255,255,.08);
}

.lang-btn .chevron{
  opacity:.6;
  transition: transform .18s ease;
}

.lang-btn[aria-expanded="true"] .chevron{
  transform: rotate(180deg);
}


.theme-btn{
  border:none;
  background:transparent;
  padding:.25rem;
  cursor:pointer;

  color: var(--muted);     /* sempre muted */
  transition: color .15s ease;
}

.theme-btn:hover{
  color: var(--text);     /* brand solo in hover */
}

.theme-btn:focus-visible{
  outline:2px solid var(--brand);
  outline-offset:2px;
}

@media (max-width:1000px){
  .primary-nav{ display:none !important; }
  .nav-toggle{ display:inline-flex !important; }
}


/* =========================================================
   10) LANGUAGE SWITCHER (dropdown)
========================================================= */

/* Inline language switch: EN | IT */
.lang-switch-inline{
  display: inline-flex;
  align-items: center;
  gap: .45rem;
}

.lang-inline{
  background: transparent;
  border: none;
  padding: 0;
  cursor: pointer;

  font-weight: 800;          /* meno pesante */
  font-size: 1rem;         /* leggermente più piccolo */
  letter-spacing: .05em;     /* aria editoriale */

  text-transform: lowercase; /* forza minuscolo */

  color: var(--muted);
  transition: color .15s ease;
}

.lang-inline:hover{
  color: var(--brand);
}

.lang-inline.active{
  color: var(--brand);
  font-weight: 600;          /* leggermente più forte */
}

.lang-sep{
  color: var(--muted);
  opacity: .35;
  user-select: none;
}

.lang-switch-inline{
  display: inline-flex;
  align-items: center;
  gap: .45rem;

  margin-right: .6rem;   /* sposta verso sinistra rispetto al sole/luna */
}



/* =========================================================
   11) SUN ↔ MOON ICON (SVG mask transitions)
   ---------------------------------------------------------
   The icon is driven by CSS transforms + SVG mask properties.
========================================================= */
.sunmoon{
  display:block;
  width:20px;
  height:20px;
  transition:transform .35s ease;
}

.sunmoon .sunCore{ transition:transform .40s ease, opacity .40s ease; }
.sunmoon .rays{ transition:opacity .35s ease; }
.sunmoon .raysDiag{ transition:opacity .35s ease; }
.sunmoon .crescent{ transition:opacity .35s ease; }
.sunmoon .cutout{ transition:cx .40s ease, cy .40s ease, r .40s ease; }
.sunmoon rect{ shape-rendering:crispEdges; }

/* Light state */
html[data-theme="light"] .sunmoon{ transform:rotate(0deg); }
html[data-theme="light"] .sunmoon .sunCore{ transform:scale(1); opacity:1; }
html[data-theme="light"] .sunmoon .rays{ opacity:1; }
html[data-theme="light"] .sunmoon .raysDiag{ opacity:1; }
html[data-theme="light"] .sunmoon .crescent{ opacity:0; }
html[data-theme="light"] .sunmoon .cutout{ cx:28px; cy:-4px; r:9px; }

/* Dark state */
html[data-theme="dark"] .sunmoon{ transform:rotate(18deg); }
html[data-theme="dark"] .sunmoon .sunCore{ transform:scale(.95); opacity:.9; }
html[data-theme="dark"] .sunmoon .rays{ opacity:0; }
html[data-theme="dark"] .sunmoon .raysDiag{ opacity:0; }
html[data-theme="dark"] .sunmoon .crescent{ opacity:1; }
html[data-theme="dark"] .sunmoon .cutout{ cx:14px; cy:10px; r:9px; }

/* =========================================================
   13) SOCIAL BUTTONS (generic)
========================================================= */
.social-row{
  display:flex;
  justify-content:center;
  gap:.7rem;
  margin-top:1rem;
  margin-bottom:1.8rem;
}

.icon-btn{
  width:42px;
  height:42px;
  border-radius:999px;
  border:1px solid rgba(0,0,0,.12);
  background:var(--panel);
  display:inline-flex;
  align-items:center;
  justify-content:center;
  color:var(--brand);
  box-shadow:0 3px 8px rgba(0,0,0,.12);
  transition:transform .15s ease, box-shadow .15s ease, filter .15s ease, background .25s ease;
}
.icon-btn:hover{
  transform:translateY(-1px);
  filter:brightness(1.1);
  box-shadow:0 6px 14px rgba(0,0,0,.18);
}

html[data-theme="dark"] .icon-btn{
  background:#ffffff;
  border-color:rgba(255,255,255,.2);
  color:#000000;
}

.icon-btn img{
  width:20px;
  height:20px;
  display:block;
  filter:none;
}

html[data-theme="dark"] .icon-btn:hover{
  background:#f2f2f2;
}

.icon-text{
  font-size:.9rem;
  font-weight:700;
  text-transform:uppercase;
  letter-spacing:.06em;
}

/* “Wide” variant used in some layouts */
.icon-btn--wide{
  width:100%;
  height:42px;
  border-radius:999px;
  justify-content:flex-start;
  align-items:center;
  gap:.6rem;
  padding:0 .85rem 0 .55rem;
  text-decoration:none;
}

.icon-btn--wide img{
  width:18px;
  height:18px;
  flex:0 0 auto;
}

.icon-label{
  display:inline-block;
  font-size:.92rem;
  font-weight:600;
  color:var(--text);
  line-height:1;
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
}

.social-item{
  display:flex;
  align-items:center;
  gap:.7rem;
}

.social-text{
  font-size:.92rem;
  font-weight:600;
  color:var(--text);
  text-decoration:none;
  white-space:nowrap;
}
.social-text:hover{ text-decoration:underline; }

/* =========================================================
   14) PAGE: CV
========================================================= */

/* Wrapper della sezione */
.cv-gateway-v2{
  max-width: 640px;
  margin-inline: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2rem;
}

/* Extra vertical space between intro and CV panels */
.cv-gateway-v2{
  padding-top: 2.3rem;   /* puoi aumentare a 1.5rem se vuoi più aria */
}

/* ── Due card affiancate ── */
.cv-cards-row{
  display: flex;
  gap: 1.4rem;
  justify-content: center;
  flex-wrap: wrap;
  width: 100%;
}

/* ── Singola card CV ── */
.cv-card{
  flex: 1 1 230px;
  max-width: 290px;
  display: flex;
  flex-direction: column;
  gap: 1rem;

  background: var(--panel);
  border: 1px solid rgba(15, 23, 42, .10);
  border-radius: 18px;
  padding: 1.4rem 1.2rem 1.2rem;
  box-shadow: var(--shadow-soft);
  transition: box-shadow .2s ease, transform .2s ease;
}

.cv-card:hover{
  transform: translateY(-3px);
  box-shadow: 0 18px 40px rgba(0,0,0,.14);
}

html[data-theme="dark"] .cv-card{
  background: var(--card-bg);
  border-color: var(--card-border);
  box-shadow: var(--card-shadow);
}

/* Top area: badge + illustrazione + testo */
.cv-card-top{
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .7rem;
  text-align: center;
}

/* Badge lingua (EN / IT) */
/* DOPO */
.cv-lang-badge{
  align-self: flex-end;
  font-size: .75rem;
  font-weight: 800;
  letter-spacing: .06em;
  padding: .2rem .55rem;
  border-radius: 999px;
  background: color-mix(in srgb, var(--brand) 10%, transparent);
  color: var(--brand);
  border: 1px solid color-mix(in srgb, var(--brand) 25%, transparent);
}

/* Illustrazione "foglio PDF" */
.cv-card-doc-icon{
  padding: .6rem;
}

.cv-doc-sheet{
  width: 64px;
  background: var(--bg);
  border: 1.5px solid rgba(15, 23, 42, .12);
  border-radius: 6px;
  padding: 10px 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  box-shadow: 0 4px 14px rgba(0,0,0,.10);
}

html[data-theme="dark"] .cv-doc-sheet{
  background: #2a2b2f;
  border-color: rgba(255,255,255,.14);
}

.cv-doc-line{
  height: 3px;
  border-radius: 999px;
  background: rgba(15, 23, 42, .15);
}

html[data-theme="dark"] .cv-doc-line{
  background: rgba(255,255,255,.18);
}

.cv-doc-line--title{
  background: var(--brand);
  opacity: .6;
  width: 80%;
}

.cv-doc-line--short{
  width: 55%;
}

/* Label + meta */
.cv-card-label{
  font-weight: 750;
  font-size: 1.02rem;
  letter-spacing: -.01em;
  transition: color .15s ease;
}

/* CV: accent on hover/focus for the card title (English/Italian CV) */
.cv-card:hover .cv-card-label,
.cv-card:focus-within .cv-card-label{
  color: var(--accent);
}

.cv-card-meta{
  color: var(--muted);
  font-size: .88rem;
  margin-top: -.4rem;
}

/* ── Bottoni ── */
.cv-card-actions{
  display: flex;
  flex-direction: column;
  gap: .55rem;
}

.cv-card-btn{
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .45rem;
  padding: .6rem 1rem;
  border-radius: 10px;
  font-size: .92rem;
  font-weight: 650;
  text-decoration: none;
  transition: transform .15s ease, box-shadow .15s ease, filter .15s ease, background .15s ease;
}

.cv-card-btn--primary{
  background: var(--brand);
  color: #fff;
  box-shadow: 0 3px 10px rgba(0,0,0,.15);
}

.cv-card-btn--primary:hover{
  filter: brightness(1.10);
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(0,0,0,.20);
}

.cv-card-btn--outline{
  background: transparent;
  color: var(--brand);
  border: 1.5px solid rgba(29, 78, 216, .35);
}

html[data-theme="dark"] .cv-card-btn--outline{
  border-color: rgba(96, 165, 250, .35);
}

.cv-card-btn--outline:hover{
  background: rgba(29, 78, 216, .06);
  transform: translateY(-1px);
}

html[data-theme="dark"] .cv-card-btn--outline:hover{
  background: rgba(96, 165, 250, .08);
}

/* ── Data aggiornamento ── */
.cv-updated-v2{
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  color: var(--muted);
  font-size: .92rem;
}

/* ── Chip di navigazione ── */
.cv-chips-row{
  display: flex;
  gap: .75rem;
  flex-wrap: wrap;
  justify-content: center;
}

.cv-chip{
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .5rem 1rem;
  border-radius: 999px;
  font-size: .9rem;
  font-weight: 650;
  text-decoration: none;
  color: var(--text);
  background: transparent;
  border: 1px solid rgba(15, 23, 42, .14);
  transition: background .15s ease, border-color .15s ease, color .15s ease, transform .15s ease;
}

.cv-chip:hover{
  background: rgba(29, 78, 216, .06);
  border-color: var(--brand);
  color: var(--brand);
  transform: translateY(-1px);
}

html[data-theme="dark"] .cv-chip{
  border-color: rgba(255,255,255,.14);
}

html[data-theme="dark"] .cv-chip:hover{
  background: rgba(96, 165, 250, .08);
  border-color: var(--brand);
}

/* ── Nota in fondo ── */
.cv-note-v2{
  color: var(--muted);
  font-size: .93rem;
  line-height: 1.75;
  text-align: center;
  margin: 0;
}

/* ── Mobile ── */
@media (max-width: 520px){
  .cv-cards-row{
    flex-direction: column;
    align-items: center;
  }

  .cv-card{
    max-width: 100%;
    width: 100%;
  }
}

/* =========================================================
   16) PAGE: HOME LAYOUT (default/mobile-first)
   ---------------------------------------------------------
   Desktop behaviour is defined in media queries at bottom.
========================================================= */

.home-simple{
  /* More side space + overall cleaner */
  max-width: min(900px, 86vw);
  margin: 0 auto;

  /* Smaller vertical footprint */
  padding: 1.8rem 0 1.4rem;

  display:flex;
  flex-direction:column;
  align-items:center;
  text-align:center;

  /* More separation between top content and latest posts */
  gap: 1.7rem;
}

.home-simple-head{
  display:flex;
  flex-direction:column;
  align-items:center;

  /* Tighter stack */
  gap: .8rem;
}

.home-simple-avatar{
  width: 185px;
  height: 185px;
  border-radius: 999px;
  overflow:hidden;
  border: 3px solid rgba(0,0,0,.06);
  box-shadow: 0 10px 30px rgba(15,23,42,.18);
}

html[data-theme="dark"] .home-simple-avatar{
  border-color: rgba(255,255,255,.08);
  box-shadow: 0 10px 30px rgba(0,0,0,.7);
}

.home-simple-avatar img{
  width:100%;
  height:100%;
  object-fit:cover;
}

/* 1) Smaller name */
.home-simple-name{
  margin: 0;
  font-size: clamp(1.75rem, 2.4vw, 2.15rem);
  font-weight: 850;
  letter-spacing: .02em;
}

/* 2) Two emoji lines */
.home-simple-lines{
  margin-top: .1rem;
  display:flex;
  flex-direction:column;
  gap: .35rem;
}

.home-simple-line{
  font-size: .98rem;
  line-height: 1.5;
  color: var(--text);
  opacity: .92;
}

/* 3) Social row (horizontal) */
.home-social{
  margin-top: .35rem;
  display:flex;
  align-items:center;
  justify-content:center;
  flex-wrap:wrap;
  gap: .65rem;
}

/* HOME social icons (monochrome via mask): icon color = muted, bg = page */
.home-social .icon-btn--mono{
  width: 50px;
  height: 50px;
  border-radius: 999px;

  /* no button background */
  border: none;
  box-shadow: none;

  /* IMPORTANT: paint the icon with currentColor */
  background-color: currentColor;

  color: var(--muted);
  opacity: .95;

  /* robust mask syntax */
  -webkit-mask: var(--icon-url) no-repeat center / 28px 28px;
  mask: var(--icon-url) no-repeat center / 28px 28px;

  transition: transform .15s ease, color .15s ease, opacity .15s ease;
}

.home-social .icon-btn--mono:hover{
  color: var(--brand);
  transform: translateY(-1px);
  opacity: 1;
}

/* Latest post */
.home-latest{
  width:100%;
  display:flex;
  flex-direction:column;
  align-items:center;
  gap: .7rem;
}

.home-latest-title{
  width:100%;
  text-align:left;
  font-weight: 850;
  letter-spacing: -0.01em;
  font-size: 1.08rem;
}

/* =========================================================
   HOME — Latest post card 
========================================================= */

.home-latest-card {
  width: 100%;
  display: block;
  text-decoration: none;
  color: inherit;
  border-radius: 14px;
  border: 1px solid rgba(15, 23, 42, .09);
  background: var(--panel);
  box-shadow: 0 2px 8px rgba(0,0,0,.05);
  padding: 1rem 1.2rem;
  text-align: left;
  transition: border-color .2s ease, box-shadow .2s ease, background .15s ease;
}

.home-latest-card:hover {
  background: rgba(0,0,0,.03);
  box-shadow: 0 4px 18px rgba(0,0,0,.10);
}

html[data-theme="dark"] .home-latest-card {
  border-color: rgba(255,255,255,.08);
  background: var(--card-bg);
  box-shadow: 0 2px 12px rgba(0,0,0,.28);
}

html[data-theme="dark"] .home-latest-card:hover {
  background: rgba(255,255,255,.04);
  box-shadow: 0 4px 22px rgba(0,0,0,.42);
}

.home-latest-card:hover .home-latest-posttitle {
  color: var(--accent);
}

.home-latest-posttitle {
  font-size: 1.18rem;      /* leggermente più grande */
  font-weight: 700;        /* un filo più deciso */
  margin: 0 0 .6rem;       /* più spazio sotto */
  color: var(--text);
  line-height: 1.4;
  transition: color .15s ease;
}

.home-latest-abstract {
  font-size: .93rem;
  line-height: 1.6;
  color: var(--muted);
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
}

.home-latest-tags {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .3rem;
  margin: .4rem 0 .5rem;
}

.home-latest-tags-label {
  font-size: .78rem;
  color: var(--muted);
  font-weight: 500;
}

.home-latest-meta {
  display: flex;
  align-items: center;
  gap: .3rem;
  font-size: .8rem;
  color: var(--muted);
  margin-top: .3rem;
}

/* =========================================================
  17) PAGE: EDUCATION & EXPERIENCE (split modern layout)
========================================================= */

.page-head{
  margin-bottom: 1rem;
}

.page-subtitle{
  margin-top: .35rem;
  color: var(--muted);
  max-width: 70ch;
}

/* Education structured fields */

.edu-spec{
  margin-top: .35rem;
  font-size: .95rem;
  line-height: 1.45;
  font-style: italic;
  color: var(--muted);
}

.edu-line{
  margin-top: .3rem;
  font-size: .95rem;
  line-height: 1.45;
}

.edu-label{
  font-weight: 600;
  margin-right: .25rem;
  color: var(--text);
}

.edu-description{
  margin-top: .35rem;
  font-size: .95rem;
  line-height: 1.55;
}

.edu-desc-text{
  color: var(--muted);
  font-style: italic;
}


.edu-value{
  color: var(--text);
}

.expedu-split{
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.2rem;
  align-items: start;
}

.expedu-panel{
  border-radius: calc(var(--radius) + 4px);
  border: 1px solid var(--card-border);
  background: var(--card-bg);
  box-shadow: var(--card-shadow);
  backdrop-filter: blur(10px);
  padding: 1.1rem 1.1rem .9rem;
}

.expedu-panel-head{
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: .75rem;
  margin-bottom: .7rem;
}

.expedu-panel-head h2{
  margin: 0;
  letter-spacing: -0.02em;
}

.expedu-count{
  font-size: .85rem;
  font-weight: 700;
  color: var(--muted);
  border: 1px solid var(--card-border);
  padding: .2rem .55rem;
  border-radius: 999px;
}

.expedu-timeline{
  margin: 0;
  padding: 0;
  list-style: none;  
}

/* Softer line for this page */
.expedu-timeline.timeline::before{
  left: .55rem;
  background: linear-gradient(
    to bottom,
    rgba(0,0,0,0),
    rgba(0,0,0,.12),
    rgba(0,0,0,0)
  );
}
html[data-theme="dark"] .expedu-timeline.timeline::before{
  background: linear-gradient(
    to bottom,
    rgba(255,255,255,0),
    rgba(255,255,255,.18),
    rgba(255,255,255,0)
  );
}

.expedu-timeline .tl-item{
  padding-left: 2.1rem;
  border-radius: 12px;
  padding-top: .25rem;
  padding-bottom: .25rem;
}

.expedu-timeline .tl-item:hover{
  background: rgba(255,255,255,.04);
}
html[data-theme="light"] .expedu-timeline .tl-item:hover{
  background: rgba(15,23,42,.03);
}

.expedu-timeline .tl-dot{
  top: .55rem;
  width: .72rem;
  height: .72rem;
  box-shadow: 0 0 0 4px rgba(0,0,0,.04);
}
html[data-theme="dark"] .expedu-timeline .tl-dot{
  box-shadow: 0 0 0 4px rgba(255,255,255,.06);
}

@media (max-width: 900px){
  .expedu-split{
    grid-template-columns: 1fr;
  }
}

/* =========================================================
    18) RESEARCH PAGE – PANELS GRID
========================================================= */
.research-grid{
  display:grid;
  gap:1.2rem;
  grid-template-columns: 1fr;
}

@media (min-width:1100px){
  .research-grid{
    grid-template-columns: 1fr 1fr;
    align-items:start;

    grid-template-areas:
      "pubs pubs"
      "left projects";
  }

  .research-panel--pubs{ grid-area: pubs; }
  .research-col-left{ grid-area: left; }
  .research-panel--projects{ grid-area: projects; }

  /* Stack Talks + Topics vertically in the left column */
  .research-col-left{
    display:flex;
    flex-direction:column;
    gap:1.2rem; /* same as .research-grid gap */
  }
}

/* Mobile: keep original vertical order (Talks → Projects → Topics) */
@media (max-width:1099px){
  .research-col-left{
    display:contents;
  }
}

/* Research – bullet lists (instead of mini-cards) */
.research-list{
  margin: .6rem 0 0;
  padding-left: 1.1rem;
}

.research-list li{
  margin: .55rem 0;
}

.research-list a{
  color: var(--brand);
  text-decoration: none;
  font-weight: 600;
}
.research-list a:hover{
  text-decoration: underline;
}

/* =========================================================
   19) PAGE: ABOUT ME (image floats inside the text)
========================================================= */

/* About me in markdown – same side margins as pages */
.aboutme.markdown-body{
  max-width: min(1100px, 90vw);
  margin-inline: auto;
}

@media (max-width: 520px){
  .aboutme.markdown-body figure{
    max-width: 190px;
    margin-left: auto;
    margin-right: auto;
  }

  .aboutme.markdown-body figure img,
  .aboutme.markdown-body > img{
    max-width: 190px;
    width: 100%;
    margin-left: auto;
    margin-right: auto;
  }
}

/* =========================================================
   20) PAGE: POSTS
========================================================= */

.posts-toolbar{
  margin-top: 0;
}

.posts-toolbar-inner{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:1rem;
}

.posts-toolbar-spacer{ flex:1; }

.posts-filter{
  display:flex;
  align-items:center;
  gap:.55rem;
  margin-left:auto; /* keep on the right */
}

.posts-filter-label{
  font-weight:700;
  color:var(--muted);
  font-size:.92rem;
}

.posts-filter-select{
  min-width: 180px;
}

/* Container for the flat list */
.posts-flat-list {
  max-width: 960px;
  margin-inline: auto;
  padding-top: 0;
}

/* Individual post item */
.post-flat-item {
  padding: 1.4rem .6rem;
  border-bottom: 1px solid rgba(0,0,0,.10);
  cursor: pointer;
  border-radius: 6px;
  transition: background .15s ease;
  margin: 0 -.6rem;
}

.post-flat-item:hover {
  background: rgba(0,0,0,.03);
}

html[data-theme="dark"] .post-flat-item {
  border-bottom-color: rgba(255,255,255,.10);
}

html[data-theme="dark"] .post-flat-item:hover {
  background: rgba(255,255,255,.04);
}

.post-flat-item--last {
  border-bottom: none;
}

/* Inner: text on left, image on right */
.post-flat-inner {
  display: flex;
  align-items: stretch;
  gap: 1.4rem;
}

.post-flat-content {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

/* Thumbnail — natural aspect ratio, aligned center */
.post-flat-thumb {
  flex-shrink: 0;
  width: 200px;
  align-self: center;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid rgba(0,0,0,.08);
}

html[data-theme="dark"] .post-flat-thumb {
  border-color: rgba(255,255,255,.10);
}

.post-flat-thumb img {
  width: 100%;
  height: auto;
  aspect-ratio: 3 / 2;
  object-fit: cover;
  display: block;
}

/* Title — accent on item hover */
.post-flat-link {
  text-decoration: none;
  color: inherit;
  display: block;
  margin-bottom: .4rem;
  pointer-events: none;
}

.post-flat-title {
  font-size: 1.15rem;
  font-weight: 600;
  margin: 0;
  color: var(--text);
  transition: color .15s ease;
  line-height: 1.35;
}

.post-flat-item:hover .post-flat-title {
  color: var(--accent);
}

@media (max-width: 600px) {
  .post-flat-thumb {
    width: 120px;
  }
}

/* Abstract */
.post-flat-abstract {
  font-size: .92rem;
  color: var(--muted);
  margin: .4rem 0 .7rem;
  line-height: 1.65;
}

/* Tags row */
.post-flat-tags {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .35rem;
  margin-bottom: .65rem;
}

.post-flat-tags-label {
  font-size: .8rem;
  color: var(--muted);
  font-weight: 500;
  margin-right: .1rem;
}

/* Meta row: date + read time */
.post-flat-meta {
  display: flex;
  align-items: center;
  gap: 1.1rem;
  font-size: .82rem;
  color: var(--muted);
}

.post-flat-date,
.post-flat-readtime {
  display: flex;
  align-items: center;
  gap: .3rem;
}

.post-flat-icon {
  width: 13px;
  height: 13px;
  flex-shrink: 0;
  opacity: .7;
}

.posts-pagination {
  display: flex;
  justify-content: center;
  margin: 1.5rem 0 2.5rem;
}

.pagination {
  display: flex;
  align-items: center;
  gap: .3rem;
}

.pagination-btn {
  min-width: 2.2rem;
  height: 2.2rem;
  padding: 0 .5rem;
  border: 1px solid rgba(0,0,0,.15);
  border-radius: 6px;
  background: transparent;
  color: var(--text);
  font-size: .9rem;
  cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
  font-family: inherit;
  display: flex;
  align-items: center;
  justify-content: center;
}

html[data-theme="dark"] .pagination-btn {
  border-color: rgba(255,255,255,.15);
  color: var(--text);
}

.pagination-btn:hover:not(:disabled) {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.pagination-btn--active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  font-weight: 600;
  cursor: default;
}

.pagination-btn:disabled {
  opacity: .35;
  cursor: not-allowed;
}

/* ===== Opened post: full page (NO panel/card) ===== */
.post-page{
  max-width: 85ch;
  margin-inline: auto;
  padding-bottom: 0;
}

/* ── Post detail: header block ─────────────────────────── */
.post-page-header {
  margin-bottom: 1.5rem;
}

.post-page-title {
  margin-bottom: 0.75rem;
}

/* Meta row (data + lettura) */
.post-page-meta {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  flex-wrap: wrap;
  margin-bottom: 0.85rem;
}

.post-page-meta-item {
  display: inline-flex;
  align-items: center;
  gap: 0.4em;
  font-size: 0.82rem;
  color: var(--muted);          /* colore brand elegante */
  font-variant-numeric: tabular-nums;
}

.post-page-meta-icon {
  width: 13px;
  height: 13px;
  flex-shrink: 0;
  color: var(--muted);
}

/* Tags sotto la meta */
.post-page-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 0;
}

/* Divider sotto l'header */
.post-page-divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 1.5rem 0 1rem;
}

/* Footer con link "Torna ai post" */
.post-page-footer {
  margin-top: 2.2rem;
  padding-top: 1.2rem;
  padding-bottom: 0;
  border-top: 1px solid rgba(0,0,0,.10);
}

html[data-theme="dark"] .post-page-footer{
  border-top-color: rgba(255,255,255,.12);
}

.post-back-link {
  display: inline-flex;
  align-items: center;
  gap: 0.45em;
  font-size: 0.85rem;
  color: var(--muted);
  text-decoration: none;
  font-weight: 500;
  transition: opacity 0.15s;
}

.post-back-link:hover {
  opacity: 0.7;
}

.post-page-figure{
  margin: 1.2rem 0 0;
}

.post-page-img{
  width: 100%;
  height: auto;
  display: block;
  border-radius: 16px;
  border: 1px solid rgba(0,0,0,.10);
  box-shadow: var(--shadow-soft);
}

html[data-theme="dark"] .post-page-img{
  border-color: rgba(255,255,255,.14);
}

.post-page-body{
  margin-top: 1.2rem;
  font-size: 1.02rem;
  line-height: 1.85;
}

.post-page-body p{
  margin: 0 0 1.05rem;
  text-wrap: pretty;
}

/* Remove trailing visual gap at the end of markdown/post content */
.post-page-body > *:last-child,
.markdown-body > *:last-child,
.privacy-page > *:last-child,
.aboutme.markdown-body > *:last-child{
  margin-bottom: 0 !important;
}

html[data-theme="light"] .posts-filter-select{
  background: var(--panel);
  border-color: rgba(0,0,0,.12);
  color: var(--text);
}

html[data-theme="light"] .posts-filter-select option{
  color: var(--text);
}

@media (max-width:900px){
  .container{
    width: min(100% - 2.8rem, var(--maxw));
  }
}

/* =========================================================
   21) PAGE: PRIVACY
========================================================= */

/* Privacy page: same feel as an opened post, no panel */
.privacy-page{
  max-width: 85ch;
  margin-inline: auto;
  font-size: 1.02rem;
  line-height: 1.85;
}

.privacy-page h1{
  margin-top: 0;
}

/* =========================================================
   22) MARKDOWN ENHANCED: code, math, blockquote, tables
========================================================= */

.post-page-body > p:first-of-type{
  font-size: 1.12rem;
  line-height: 1.85;
  color: var(--text);
  margin-bottom: 1.3rem;
}

/* ── Blockquote ──────────────────────────────────────── */
.markdown-body blockquote,
.post-page-body blockquote {
  border-left: 3px solid var(--accent);
  margin: 1.4rem 0;
  padding: 0.5rem 1rem;
  color: var(--muted);
  font-style: italic;
  background: rgba(0,0,0,0.03);
  border-radius: 0 6px 6px 0;
}

html[data-theme="dark"] .markdown-body blockquote,
html[data-theme="dark"] .post-page-body blockquote {
  background: rgba(255,255,255,0.04);
}

/* ── Tabelle ─────────────────────────────────────────── */
.markdown-body table,
.post-page-body table {
  border-collapse: collapse;
  width: 100%;
  margin: 1.4rem 0;
  font-size: 0.92rem;
}

.markdown-body th,
.markdown-body td,
.post-page-body th,
.post-page-body td {
  border: 1px solid rgba(0,0,0,0.12);
  padding: 0.5rem 0.85rem;
  text-align: left;
}

html[data-theme="dark"] .markdown-body th,
html[data-theme="dark"] .markdown-body td,
html[data-theme="dark"] .post-page-body th,
html[data-theme="dark"] .post-page-body td {
  border-color: rgba(255,255,255,0.12);
}

.markdown-body th,
.post-page-body th {
  background: rgba(0,0,0,0.04);
  font-weight: 600;
}

html[data-theme="dark"] .markdown-body th,
html[data-theme="dark"] .post-page-body th {
  background: rgba(255,255,255,0.06);
}

/* ── Code block: modern / GitHub-like ───────────────────── */

.code-block{
  position: relative;
  margin: 1.5rem 0;
  border: 1px solid rgba(0,0,0,.10);
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 8px 22px rgba(0,0,0,.06);
}

html[data-theme="dark"] .code-block{
  border-color: rgba(255,255,255,.10);
  box-shadow: 0 10px 28px rgba(0,0,0,.30);
}

/* Small floating language badge (top-left) */
.code-block-lang-badge{
  position: absolute;
  top: .7rem;
  left: .8rem;
  z-index: 2;

  display: inline-flex;
  align-items: center;

  padding: .16rem .48rem;
  border-radius: 999px;

  font-size: .72rem;
  line-height: 1;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  text-transform: lowercase;
  letter-spacing: .02em;

  background: rgba(255,255,255,.86);
  color: #57606a;
  border: 1px solid rgba(0,0,0,.08);
  backdrop-filter: blur(6px);
}

html[data-theme="dark"] .code-block-lang-badge{
  background: rgba(22,27,34,.88);
  color: #8b949e;
  border-color: rgba(255,255,255,.10);
}

/* Floating copy button (top-right) */
.code-block-copy{
  position: absolute;
  top: .65rem;
  right: .75rem;
  z-index: 2;

  display: inline-flex;
  align-items: center;
  gap: .35rem;

  padding: .28rem .58rem;
  border-radius: 8px;
  border: 1px solid rgba(0,0,0,.10);

  background: rgba(255,255,255,.90);
  color: #57606a;

  font-size: .74rem;
  line-height: 1;
  font-weight: 600;
  cursor: pointer;

  transition: background .15s ease, border-color .15s ease, color .15s ease, transform .15s ease;
  backdrop-filter: blur(6px);
}

html[data-theme="dark"] .code-block-copy{
  background: rgba(22,27,34,.90);
  color: #8b949e;
  border-color: rgba(255,255,255,.10);
}

.code-block-copy:hover{
  transform: translateY(-1px);
  color: var(--text);
  border-color: rgba(0,0,0,.18);
}

html[data-theme="dark"] .code-block-copy:hover{
  color: #c9d1d9;
  border-color: rgba(255,255,255,.18);
}

.code-block-copy.copied{
  color: #1a7f37;
  border-color: rgba(26,127,55,.35);
}

html[data-theme="dark"] .code-block-copy.copied{
  color: #3fb950;
  border-color: rgba(63,185,80,.35);
}

.copy-icon{
  width: 13px;
  height: 13px;
  flex-shrink: 0;
}

.copy-icon--check{ display:none; }
.code-block-copy.copied .copy-icon--default{ display:none; }
.code-block-copy.copied .copy-icon--check{ display:block; }
.code-block-copy.copied .copy-label{ display:none; }

/* The actual code area */
.code-block pre{
  margin: 0;
  padding: 3rem 1.15rem 1.15rem;
  overflow-x: auto;
  border: none;
  border-radius: 0;
  background: #f6f8fa !important;
}

html[data-theme="dark"] .code-block pre{
  background: #161b22 !important;
}

.code-block pre code{
  color: #24292f;
}

html[data-theme="dark"] .code-block pre code{
  color: #c9d1d9;
}

/* Slightly tighter text, more GitHub-like */
.code-block pre code{
  font-size: .90rem;
  line-height: 1.65;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}

/* Inline code stays separate */
.markdown-body code:not(pre code),
.post-page-body code:not(pre code){
  background: rgba(0,0,0,.06);
  padding: 0.15em 0.4em;
  border-radius: 4px;
  font-size: 0.88em;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

html[data-theme="dark"] .markdown-body code:not(pre code),
html[data-theme="dark"] .post-page-body code:not(pre code){
  background: rgba(255,255,255,.10);
}

/* ── Headings dentro un post ─────────────────────────── */
.post-page-body h2,
.post-page-body h3 {
  margin-top: 2rem;
  margin-bottom: 0.6rem;
}

.post-page-body h2,
.post-page-body h3,
.markdown-body h2,
.markdown-body h3{
  scroll-margin-top: 96px;
}

/* =========================================================
   Heading anchors
========================================================= */

.heading-anchor{
  margin-left: .4rem;
  opacity: 0;
  font-size: .8em;
  text-decoration: none;
  color: var(--muted);
  transition: opacity .15s ease;
}

.post-page-body h2:hover .heading-anchor,
.post-page-body h3:hover .heading-anchor{
  opacity: .6;
}

.heading-anchor:hover{
  color: var(--brand);
  opacity: 1;
}

.post-page-body ol,
.markdown-body ol{
  padding-left: 1.35rem;
}

.post-page-body li + li,
.markdown-body li + li{
  margin-top: .5rem;
}

.post-page-body p,
.markdown-body p{
  text-wrap: pretty;
}

.post-page-body hr {
  border: none;
  border-top: 1px solid rgba(0,0,0,0.10);
  margin: 2rem 0;
}

html[data-theme="dark"] .post-page-body hr {
  border-top-color: rgba(255,255,255,0.12);
}

/* =========================================================
   Markdown Callouts (notes, warnings, ideas)
========================================================= */

.callout{
  margin: 1.5rem 0;
  padding: .9rem 1rem;
  border-radius: 10px;
  border-left: 4px solid var(--brand);
  background: rgba(0,0,0,.03);
  font-size: .95rem;
}

html[data-theme="dark"] .callout{
  background: rgba(255,255,255,.05);
}

.callout-title{
  font-weight: 700;
  margin-bottom: .3rem;
}

/* Variants */

.callout.note{
  border-left-color: var(--brand);
}

.callout.warning{
  border-left-color: #e5533d;
}

.callout.idea{
  border-left-color: var(--accent);
}

/* =========================================================
   References / bibliography styling
========================================================= */

/* Slightly improve ordered lists inside markdown */
.post-page-body ol,
.markdown-body ol{
  padding-left: 1.35rem;
}

.post-page-body li + li,
.markdown-body li + li{
  margin-top: .5rem;
}

/* Treat the last h2 + ordered list as a bibliography section */
.post-page-body h2:last-of-type,
.markdown-body h2:last-of-type{
  margin-top: 2.5rem;
  padding-top: .15rem;
}

.post-page-body h2:last-of-type + ol,
.markdown-body h2:last-of-type + ol{
  margin-top: .9rem;
  padding: 0;
  list-style: none;
  counter-reset: refs;
}

.post-page-body h2:last-of-type + ol > li,
.markdown-body h2:last-of-type + ol > li{
  position: relative;
  counter-increment: refs;
  padding-left: 2.3rem;
  color: var(--muted);
  line-height: 1.72;
}

.post-page-body h2:last-of-type + ol > li::before,
.markdown-body h2:last-of-type + ol > li::before{
  content: "[" counter(refs) "]";
  position: absolute;
  left: 0;
  top: 0;
  font-weight: 700;
  color: var(--muted);
}

/* Links inside references */
.post-page-body h2:last-of-type + ol a,
.markdown-body h2:last-of-type + ol a{
  color: var(--brand);
  text-decoration: none;
  font-weight: 500;
}

.post-page-body h2:last-of-type + ol a:hover,
.markdown-body h2:last-of-type + ol a:hover{
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* =========================================================
   Post TOC (desktop only, fixed in left free space)
========================================================= */

.post-shell{
  position: relative;
}

.post-toc{
  display: none;
}

@media (min-width: 1400px){
  .post-toc{
    display: block;
    position: fixed;
    top: 120px;
    left: max(24px, calc((100vw - 85ch) / 2 - 260px));
    width: 210px;

    max-height: calc(100vh - 160px);
    overflow: auto;

    padding-right: .4rem;
  }

  .post-toc-nav{
    display: flex;
    flex-direction: column;
    gap: .2rem;
  }

.post-toc-link{
  position: relative;
  display: block;
  width: 100%;
  padding: .28rem 0 .28rem .85rem;

  border: 0;
  background: transparent;
  appearance: none;
  -webkit-appearance: none;

  color: var(--muted);
  text-decoration: none;
  text-align: left;
  font: inherit;
  font-size: .9rem;
  line-height: 1.35;
  cursor: pointer;

  transition: color .15s ease;
}

  .post-toc-link--h3{
    padding-left: 1.55rem;
    font-size: .84rem;
  }

  .post-toc-link::before{
    content: "";
    position: absolute;
    left: 0;
    top: .38rem;
    bottom: .38rem;
    width: 2px;
    border-radius: 999px;
    background: transparent;
    transition: background .15s ease;
  }

  .post-toc-link:hover{
    color: var(--text);
  }

  .post-toc-link.active{
    color: var(--brand);
    font-weight: 600;
  }

  .post-toc-link.active::before{
    background: var(--brand);
  }
}