/* ==========================================================================
   Blog Enhancements – Cloud Native / Technical Blog Look & Feel
   Overrides for hugo-theme-nightfall
   ========================================================================== */

/* ── CSS Custom Properties ────────────────────────────────────────────────── */
:root {
  --accent: #58a6ff;           /* vivid electric blue */
  --accent-dim: #388bfd;       /* slightly darker for hover */
  --accent-glow: rgba(88, 166, 255, 0.15);
  --bg-dark: #292a2d;          /* theme background */
  --bg-darker: #252627;        /* darker panels */
  --bg-card: #2f2f2f;          /* card / post list items */
  --bg-surface: #1c1d1f;       /* blockquotes, callouts */
  --text-primary: #e6edf3;     /* brighter white for body */
  --text-secondary: #8b949e;   /* muted text */
  --border-subtle: #30363d;    /* subtle borders */
  --green: #3fb950;
  --orange: #d29922;
  --red: #f85149;
  --purple: #bc8cff;
}

/* ── Base Typography ──────────────────────────────────────────────────────── */
/*
   IMPORTANTE: overflow-x NON va su html/body — rompe backdrop-filter.
   Il browser tratta overflow su html/body come scroll container della pagina,
   creando un nuovo containing block che invalida backdrop-filter su tutti i figli.
   Gestiamo l'overflow solo sui contenitori interni.
*/
body {
  color: var(--text-primary);
  line-height: 1.75;
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ── Box sizing globale ───────────────────────────────────────────────────── */
*,
*::before,
*::after {
  box-sizing: border-box;
}

/* ── Contenitori interni: qui l'overflow è sicuro ─────────────────────────── */
.content,
.main {
  max-width: 100vw;
  overflow-x: hidden;
}

.flexWrapper {
  max-width: 100vw;
  /* NON overflow: hidden — romperebbe position:sticky dell'header */
}

/* ── Header – sticky con glassmorphism / frosted glass iOS-style ──────────── */
.headerWrapper {
  position: sticky !important;
  top: 2px; /* sotto la accent line */
  z-index: 100;
  background-color: rgba(37, 38, 39, 0.75) !important;
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  backdrop-filter: blur(20px) saturate(180%);
  border-bottom: 1px solid rgba(48, 54, 61, 0.5);
  overflow: visible !important;
  transition: background-color 0.3s ease;
  /* isolation: isolate crea stacking context senza rompere backdrop-filter */
  isolation: isolate;
}

/* ── Headings ─────────────────────────────────────────────────────────────── */
.postWrapper h1,
.postWrapper h2,
.postWrapper h3,
.postWrapper h4,
.postWrapper h5,
.postWrapper h6 {
  color: var(--text-primary);
  letter-spacing: -0.01em;
  margin-top: 2em;
  margin-bottom: 0.75em;
  line-height: 1.3;
}

.postWrapper h2 {
  font-size: 1.55em;
  padding-bottom: 0.35em;
  border-bottom: 1px solid var(--border-subtle);
}

.postWrapper h3 {
  font-size: 1.3em;
}

.postWrapper h4 {
  font-size: 1.1em;
  color: var(--text-secondary);
}

/* ── Paragraphs & Text ────────────────────────────────────────────────────── */
.postWrapper p {
  margin: 1em 0;
  line-height: 1.8;
}

.postWrapper strong {
  color: #ffffff;
  font-weight: 600;
}

/* strong inside links should inherit the link color, not override to white */
.postWrapper a strong,
.postWrapper a:link strong,
.postWrapper a:visited strong {
  color: inherit;
}

.postWrapper em {
  color: var(--text-secondary);
  font-style: italic;
}

/* ── Global link color override (consistent across all pages) ─────────────── */
a,
a:link,
a:visited,
a:active {
  color: var(--accent) !important;
}

a:hover {
  color: var(--accent-dim) !important;
}

/* ── Post content links ───────────────────────────────────────────────────── */
.postWrapper a {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: border-color 0.2s ease, color 0.2s ease;
}

.postWrapper a:hover {
  color: var(--accent-dim);
  border-bottom-color: var(--accent-dim);
  text-decoration: none;
}

/* ── Header links stay white ──────────────────────────────────────────────── */
.headerWrapper a,
.headerWrapper a:link,
.headerWrapper a:visited {
  color: #f8f8ff !important;
}

/* ── Blockquotes ──────────────────────────────────────────────────────────── */
.postWrapper blockquote {
  margin: 1.5em 0;
  padding: 1em 1.25em;
  background: var(--bg-surface);
  border-left: 3px solid var(--accent);
  border-radius: 0;
  color: var(--text-secondary);
  font-style: normal;
}

.postWrapper blockquote p {
  margin: 0.5em 0;
}

.postWrapper blockquote p:first-child {
  margin-top: 0;
}

.postWrapper blockquote p:last-child {
  margin-bottom: 0;
}

.postWrapper blockquote strong {
  color: var(--text-primary);
}

/* Note / Important callouts inside blockquotes */
.postWrapper blockquote p:first-child strong:first-child {
  display: inline-block;
  margin-bottom: 0.25em;
}

/* ── Lists ────────────────────────────────────────────────────────────────── */
.postWrapper ul,
.postWrapper ol {
  padding-left: 1.5em;
  margin: 1em 0;
}

.postWrapper li {
  margin: 0.4em 0;
  line-height: 1.7;
}

.postWrapper li::marker {
  color: var(--accent);
}

/* ── Horizontal Rule ──────────────────────────────────────────────────────── */
.postWrapper hr {
  border: none;
  height: 1px;
  background: var(--border-subtle);
  margin: 2.5em 0;
}

/* ── Images & Figures – Cloud Native Neon Style ───────────────────────────── */

/* Auto-numbering for figures */
.postWrapper {
  counter-reset: figure-counter;
}

.postWrapper figure {
  margin: 2em 0;
  position: relative;
  counter-increment: figure-counter;
}

.postWrapper img {
  border-radius: 6px;
  border: 1px solid rgba(88, 166, 255, 0.35);
  box-shadow:
    0 0 0 1px rgba(88, 166, 255, 0.08),
    0 0 20px rgba(88, 166, 255, 0.06),
    0 4px 16px rgba(0, 0, 0, 0.3);
  transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.postWrapper img:hover {
  border-color: var(--accent);
  box-shadow:
    0 0 0 1px rgba(88, 166, 255, 0.2),
    0 0 30px rgba(88, 166, 255, 0.12),
    0 0 60px rgba(88, 166, 255, 0.04),
    0 8px 32px rgba(0, 0, 0, 0.4);
}

.postWrapper figure img {
  border-radius: 6px;
  border: 1px solid rgba(88, 166, 255, 0.35);
  box-shadow:
    0 0 0 1px rgba(88, 166, 255, 0.08),
    0 0 20px rgba(88, 166, 255, 0.06),
    0 4px 16px rgba(0, 0, 0, 0.3);
}

/* Figcaption with auto-numbering and gradient underline */
.postWrapper figcaption {
  text-align: center;
  color: var(--text-secondary);
  font-size: 0.82em;
  margin-top: 0.75em;
  padding-bottom: 0.6em;
  letter-spacing: 0.01em;
  border-bottom: 2px solid transparent;
  border-image: linear-gradient(90deg,
    transparent 0%,
    var(--accent) 25%,
    var(--purple) 75%,
    transparent 100%) 1;
}

.postWrapper figcaption::before {
  content: "Figure " counter(figure-counter) ": ";
  color: var(--text-secondary);
  font-weight: 400;
  font-style: italic;
  opacity: 0.65;
}

/* ── Image Zoom Button ────────────────────────────────────────────────────── */
.img-zoom-btn {
  position: absolute;
  top: 12px;
  right: 12px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 12px;
  background: rgba(28, 29, 31, 0.85);
  color: var(--accent);
  border: 1px solid rgba(88, 166, 255, 0.4);
  border-radius: 6px;
  font-size: 0.75rem;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  letter-spacing: 0.03em;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.25s ease, background-color 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
  z-index: 2;
  -webkit-backdrop-filter: blur(12px) saturate(180%);
  backdrop-filter: blur(12px) saturate(180%);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.img-zoom-btn svg {
  flex-shrink: 0;
}

.postWrapper figure:hover .img-zoom-btn {
  opacity: 1;
}

.img-zoom-btn:hover {
  background: rgba(88, 166, 255, 0.15);
  border-color: var(--accent);
  box-shadow:
    0 0 12px rgba(88, 166, 255, 0.2),
    0 2px 8px rgba(0, 0, 0, 0.3);
}

/* ── Lightbox Overlay ─────────────────────────────────────────────────────── */
.img-lightbox {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.88);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s ease, visibility 0.25s ease;
}

.img-lightbox.is-active {
  opacity: 1;
  visibility: visible;
}

.img-lightbox__content {
  display: flex;
  flex-direction: column;
  align-items: center;
  max-width: 92vw;
  max-height: 94vh;
}

.img-lightbox__img {
  max-width: 92vw;
  max-height: 85vh;
  object-fit: contain;
  border: 1px solid rgba(88, 166, 255, 0.6);
  border-radius: 6px;
  box-shadow:
    0 0 0 1px rgba(88, 166, 255, 0.2),
    0 0 40px rgba(88, 166, 255, 0.15),
    0 0 80px rgba(88, 166, 255, 0.05),
    0 8px 40px rgba(0, 0, 0, 0.5);
}

.img-lightbox__caption {
  margin-top: 12px;
  padding: 8px 16px;
  color: var(--text-secondary);
  font-size: 0.88rem;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  text-align: center;
  letter-spacing: 0.02em;
  background: rgba(28, 29, 31, 0.6);
  border: 1px solid rgba(88, 166, 255, 0.15);
  border-radius: 4px;
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  max-width: 80vw;
}

.img-lightbox__close {
  position: absolute;
  top: 16px;
  right: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  background: rgba(28, 29, 31, 0.8);
  color: var(--text-primary);
  border: 1px solid var(--border-subtle);
  border-radius: 50%;
  cursor: pointer;
  transition: background-color 0.2s ease, border-color 0.2s ease;
}

.img-lightbox__close:hover {
  background: rgba(88, 166, 255, 0.15);
  border-color: var(--accent);
  color: var(--accent);
}

/* ── Post Metadata ────────────────────────────────────────────────────────── */
.postMetadata {
  border-radius: 0;
  border: 1px solid var(--border-subtle);
  padding: 14px 18px !important;
  margin-bottom: 1.5em;
  font-size: 0.88em;
}

.postMetadata a {
  color: var(--accent) !important;
  transition: opacity 0.2s ease;
  text-transform: lowercase;
}

.postMetadata a:hover {
  opacity: 0.8;
  text-decoration: none !important;
}

/* ── Post List Items ──────────────────────────────────────────────────────── */
.postListItem {
  border-radius: 0;
  border: 1px solid var(--border-subtle);
  border-left: 3px solid transparent;
  transition: border-color 0.2s ease, transform 0.15s ease, box-shadow 0.2s ease, border-left-color 0.2s ease;
}

.postListItem:hover {
  border-color: var(--accent);
  border-left-color: var(--accent);
  box-shadow: 0 2px 12px rgba(88, 166, 255, 0.06);
}

/* ── Force left-align for post titles and headers ─────────────────────────── */
.postHeader {
  text-align: left !important;
}

.postTitle {
  font-size: 1.25em !important;
  text-align: left !important;
  float: none !important;
  display: block;
  margin-bottom: 0.25em;
  color: var(--accent) !important;
}

.postDate {
  float: none !important;
  text-align: left !important;
  display: block;
  color: var(--text-secondary) !important;
  font-size: 0.85em;
  margin-bottom: 0.5em;
}

.postExcerpt {
  color: var(--text-secondary) !important;
  line-height: 1.6;
  text-align: left !important;
}

.readingTime {
  color: var(--text-secondary) !important;
  font-size: 0.85em !important;
  text-align: left !important;
}

/* ── Post single page title alignment ─────────────────────────────────────── */
.postWrapper {
  text-align: left !important;
}

.listHeader,
.listContent {
  text-align: left !important;
}

/* ── Tables ───────────────────────────────────────────────────────────────── */
.postWrapper table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5em 0;
  font-size: 0.92em;
}

.postWrapper th {
  background: var(--bg-darker);
  color: var(--text-primary);
  font-weight: 600;
  text-align: left;
  padding: 10px 14px;
  border-bottom: 2px solid var(--accent);
}

.postWrapper td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-subtle);
}

.postWrapper tr:hover td {
  background: var(--bg-surface);
}

/* ── Definition Lists (post metadata) ─────────────────────────────────────── */
.postWrapper dt {
  color: var(--text-secondary);
  font-weight: 400;
}

.postWrapper dd {
  color: var(--text-primary);
}

/* ── Selection ────────────────────────────────────────────────────────────── */
::selection {
  background: var(--accent-glow);
  color: #ffffff;
}

/* ── Post hero / custom sections ──────────────────────────────────────────── */
.post-hero {
  border-color: var(--border-subtle) !important;
  background: var(--bg-surface);
}

/* ── Blog page heading ────────────────────────────────────────────────────── */
.listHeader h1 {
  font-size: 2em;
  background: linear-gradient(135deg, var(--accent) 0%, var(--purple) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  display: inline-block;
}

/* ── Single post page title ───────────────────────────────────────────────── */
.postWrapper > h1:first-child {
  font-size: 1.8em;
  margin-top: 0;
  line-height: 1.25;
}

/* ── Accent line at top of page ───────────────────────────────────────────── */
body::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--accent) 0%, var(--purple) 50%, var(--green) 100%);
  z-index: 9999;
}

/* ── Better strong emphasis in specific contexts ──────────────────────────── */
.postExcerpt strong {
  color: var(--text-primary) !important;
}

/* ── Footer ───────────────────────────────────────────────────────────────── */
footer {
  border-top: 1px solid var(--border-subtle);
  margin-top: 2em;
  opacity: 1 !important;
}

footer a,
footer a:link,
footer a:visited {
  color: var(--accent) !important;
  transition: color 0.2s ease;
}

footer a:hover {
  color: var(--accent-dim) !important;
}

/* ── Details / Summary (expandable sections) ──────────────────────────────── */
.postWrapper details summary {
  cursor: pointer;
  color: var(--accent);
  font-weight: 500;
  transition: color 0.2s ease;
}

.postWrapper details summary:hover {
  color: var(--accent-dim);
}

/* ── Focus styles for accessibility ───────────────────────────────────────── */
a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 2px;
}

/* ==========================================================================
   Reading Progress Bar
   ========================================================================== */
#reading-progress {
  position: fixed;
  top: 2px;
  left: 0;
  width: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--accent), var(--purple));
  z-index: 9998;
  pointer-events: none;
  transition: width 0.15s ease-out;
}

/* ==========================================================================
   Back to Top Button
   ========================================================================== */
#back-to-top {
  position: fixed;
  bottom: 28px;
  right: 28px;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(28, 29, 31, 0.85);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  color: var(--accent);
  border: 1px solid rgba(88, 166, 255, 0.4);
  border-radius: 50%;
  cursor: pointer;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease,
              box-shadow 0.25s ease, border-color 0.25s ease,
              background-color 0.25s ease;
  z-index: 900;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.3);
}

#back-to-top.is-visible {
  opacity: 1;
  visibility: visible;
}

#back-to-top:hover {
  background: rgba(88, 166, 255, 0.12);
  border-color: var(--accent);
  box-shadow:
    0 0 16px rgba(88, 166, 255, 0.25),
    0 0 40px rgba(88, 166, 255, 0.08),
    0 4px 16px rgba(0, 0, 0, 0.35);
}

#back-to-top svg {
  flex-shrink: 0;
}

/* ==========================================================================
   Anchor Links on Headings
   ========================================================================== */
.postWrapper h2.has-anchor,
.postWrapper h3.has-anchor,
.postWrapper h4.has-anchor {
  position: relative;
}

.heading-anchor {
  position: absolute;
  left: -1.3em;
  top: 0;
  color: var(--text-secondary) !important;
  text-decoration: none !important;
  border-bottom: none !important;
  font-weight: 400;
  opacity: 0;
  transition: opacity 0.2s ease, color 0.2s ease;
  font-size: 0.85em;
  line-height: inherit;
}

.postWrapper h2:hover > .heading-anchor,
.postWrapper h3:hover > .heading-anchor,
.postWrapper h4:hover > .heading-anchor,
.heading-anchor:focus {
  opacity: 1;
}

.heading-anchor:hover {
  color: var(--accent) !important;
}

/* ==========================================================================
   Table of Contents – Inline Collapsible
   ========================================================================== */
.toc-nav {
  margin: 1.5em 0 2em;
  border-left: 3px solid var(--accent);
  border-radius: 0 8px 8px 0;
  background: var(--bg-surface);
  overflow: hidden;
}

.toc-details {
  padding: 0;
}

.toc-summary {
  display: flex;
  align-items: center;
  gap: 0.4em;
  padding: 0.85em 1.25em;
  font-size: 0.95em;
  font-weight: 600;
  color: var(--accent) !important;
  cursor: pointer;
  user-select: none;
  list-style: none;
  border-bottom: 1px solid transparent;
  transition: background-color 0.2s ease, border-color 0.2s ease;
}

.toc-summary::-webkit-details-marker {
  display: none;
}

.toc-summary::after {
  content: '';
  display: inline-block;
  width: 6px;
  height: 6px;
  border-right: 2px solid var(--accent);
  border-bottom: 2px solid var(--accent);
  transform: rotate(-45deg);
  margin-left: auto;
  transition: transform 0.25s ease;
}

.toc-details[open] > .toc-summary::after {
  transform: rotate(45deg);
}

.toc-summary:hover {
  background: rgba(88, 166, 255, 0.06);
}

.toc-details[open] > .toc-summary {
  border-bottom-color: var(--border-subtle);
}

.toc-list {
  list-style: none;
  margin: 0;
  padding: 0.6em 1.25em 0.85em;
}

.toc-list li {
  margin: 0;
  padding: 0;
  line-height: 1.5;
}

.toc-list li.toc-h2 {
  margin-top: 0.35em;
}

.toc-list li.toc-h3 {
  padding-left: 1.2em;
  border-left: 1px solid var(--border-subtle);
  margin-left: 0.4em;
}

.toc-link {
  display: block;
  padding: 0.3em 0.5em;
  color: var(--text-secondary) !important;
  font-size: 0.88em;
  text-decoration: none !important;
  border-bottom: none !important;
  border-radius: 4px;
  transition: color 0.2s ease, background-color 0.2s ease, padding-left 0.2s ease;
}

.toc-link:hover {
  color: var(--accent) !important;
  background: rgba(88, 166, 255, 0.06);
}

.toc-link.toc-active {
  color: var(--accent) !important;
  background: rgba(88, 166, 255, 0.1);
  padding-left: 0.8em;
  font-weight: 500;
}

/* ==========================================================================
   Callout / Admonition Blocks
   ========================================================================== */

/* Note – blue / accent */
.postWrapper blockquote.callout-note {
  border-left-color: var(--accent);
  background: rgba(88, 166, 255, 0.06);
}

.postWrapper blockquote.callout-note p:first-child strong:first-child::before {
  content: '💡 ';
}

.postWrapper blockquote.callout-note p:first-child strong:first-child {
  color: var(--accent);
}

/* Warning / Important – orange */
.postWrapper blockquote.callout-warning {
  border-left-color: var(--orange);
  background: rgba(210, 153, 34, 0.08);
}

.postWrapper blockquote.callout-warning p:first-child strong:first-child::before {
  content: '⚠️ ';
}

.postWrapper blockquote.callout-warning p:first-child strong:first-child {
  color: var(--orange);
}

/* Tip – green */
.postWrapper blockquote.callout-tip {
  border-left-color: var(--green);
  background: rgba(63, 185, 80, 0.06);
}

.postWrapper blockquote.callout-tip p:first-child strong:first-child::before {
  content: '✅ ';
}

.postWrapper blockquote.callout-tip p:first-child strong:first-child {
  color: var(--green);
}

/* Info – purple */
.postWrapper blockquote.callout-info {
  border-left-color: var(--purple);
  background: rgba(188, 140, 255, 0.06);
}

.postWrapper blockquote.callout-info p:first-child strong:first-child::before {
  content: 'ℹ️ ';
}

.postWrapper blockquote.callout-info p:first-child strong:first-child {
  color: var(--purple);
}

/* Danger – red */
.postWrapper blockquote.callout-danger {
  border-left-color: var(--red);
  background: rgba(248, 81, 73, 0.08);
}

.postWrapper blockquote.callout-danger p:first-child strong:first-child::before {
  content: '🚨 ';
}

.postWrapper blockquote.callout-danger p:first-child strong:first-child {
  color: var(--red);
}

/* ==========================================================================
   Terminal-Style Command Blocks
   ========================================================================== */
.highlight.terminal-block {
  position: relative;
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  overflow: hidden;
  background: #1a1b1e;
}

.highlight.terminal-block pre {
  border-radius: 0 0 8px 8px;
  margin-top: 0;
}

.terminal-header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 14px;
  background: var(--bg-darker);
  border-bottom: 1px solid var(--border-subtle);
  user-select: none;
}

.terminal-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
}

.terminal-dot--red {
  background: #ff5f57;
}

.terminal-dot--yellow {
  background: #febc2e;
}

.terminal-dot--green {
  background: #28c840;
}

.terminal-title {
  margin-left: 8px;
  font-size: 0.75em;
  color: var(--text-secondary);
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI', sans-serif;
  letter-spacing: 0.03em;
}

/* Dim the $ prompt character in terminal blocks */
.highlight.terminal-block .line:first-child .cl::first-letter,
.highlight.terminal-block code .line .tok-gp {
  color: var(--text-secondary);
  opacity: 0.6;
}

/* ==========================================================================
   Mermaid Diagram Containers
   ========================================================================== */
.mermaid {
  display: flex;
  justify-content: center;
  padding: 1.5em 1em;
  margin: 1.5em 0;
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  background: #22242a;
  overflow-x: auto;
  min-width: 0;
}

.mermaid svg {
  max-width: 100%;
  width: 100%;
  height: auto;
}

/* ==========================================================================
   Social Share Buttons – Compact techy bar
   ========================================================================== */
.share-buttons {
  display: flex;
  justify-content: center;
  gap: 0.75rem;
  margin-top: 2.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border-subtle);
}

.share-label {
  font-size: 0.72em;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-right: 2px;
  white-space: nowrap;
  flex-shrink: 0;
}

.share-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 12px;
  font-size: 0.75rem;
  font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
  color: var(--text-secondary);
  background: rgba(28, 29, 31, 0.85);
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  cursor: pointer;
  -webkit-backdrop-filter: blur(12px) saturate(180%);
  backdrop-filter: blur(12px) saturate(180%);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
  transition: color 0.2s ease, background-color 0.2s ease,
              border-color 0.2s ease, box-shadow 0.2s ease;
  letter-spacing: 0.02em;
  white-space: nowrap;
  flex-shrink: 0;
}

.share-btn:hover {
  color: var(--accent);
  background: rgba(88, 166, 255, 0.1);
  border-color: rgba(88, 166, 255, 0.5);
  box-shadow:
    0 0 12px rgba(88, 166, 255, 0.15),
    0 2px 8px rgba(0, 0, 0, 0.3);
}

.share-btn svg {
  flex-shrink: 0;
  width: 14px;
  height: 14px;
}

.share-btn--copied {
  color: var(--green) !important;
  border-color: rgba(63, 185, 80, 0.5) !important;
  background: rgba(63, 185, 80, 0.1) !important;
}

/* On mobile: icon-only compact buttons */
@media screen and (max-width: 768px) {
  .share-buttons {
    gap: 6px;
    padding-top: 1.2em;
    margin-top: 2em;
  }

  .share-label {
    font-size: 0.65em;
    margin-right: 0;
  }

  .share-btn {
    padding: 6px 9px;
    gap: 4px;
    font-size: 0.68rem;
    border-radius: 5px;
  }

  .share-btn span {
    display: none;
  }

  .share-btn svg {
    width: 16px;
    height: 16px;
  }
}

/* ==========================================================================
   Reading Time Remaining Indicator
   ========================================================================== */
#reading-time-left {
  position: fixed;
  top: 14px;
  right: 28px;
  padding: 5px 12px;
  font-size: 0.72rem;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-weight: 500;
  color: var(--text-secondary);
  background: rgba(28, 29, 31, 0.85);
  border: 1px solid var(--border-subtle);
  border-radius: 14px;
  -webkit-backdrop-filter: blur(12px) saturate(180%);
  backdrop-filter: blur(12px) saturate(180%);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
  z-index: 101;  /* above header (z-index:100) */
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
  letter-spacing: 0.02em;
  pointer-events: none;
}

#reading-time-left.is-visible {
  opacity: 1;
  visibility: visible;
}

/* On mobile: shift reading time left of the hamburger button */
@media screen and (max-width: 768px) {
  #reading-time-left {
    right: 60px;
  }
}

/* ==========================================================================
   Mobile Menu – Professional slide-down overlay
   backdrop-filter crea un nuovo containing block, quindi usiamo
   position:absolute invece di fixed, con max-height animata.
   ========================================================================== */
@media screen and (max-width: 768px) {

  /* ── Make header the positioning context for the dropdown ───────────── */
  .header {
    position: relative;
  }

  /* ── Hamburger button ──────────────────────────────────────────────── */
  .hamb {
    display: block !important;
    z-index: 1001;
    padding: 12px 6px;
  }

  .hamb-line {
    width: 22px;
    height: 2px;
    background: var(--text-primary) !important;
  }

  .hamb-line::before,
  .hamb-line::after {
    background: var(--text-primary) !important;
  }

  .side-menu:checked ~ .hamb .hamb-line {
    background: transparent !important;
  }

  .side-menu:checked ~ .hamb .hamb-line::before,
  .side-menu:checked ~ .hamb .hamb-line::after {
    background: var(--text-primary) !important;
  }

  /* ── Slide-down nav panel ──────────────────────────────────────────── */
  .headerLinks {
    position: absolute !important;
    top: 60px !important;
    left: 0 !important;
    right: 0 !important;
    width: 100% !important;
    height: auto !important;
    max-height: 0 !important;
    overflow: hidden !important;
    background: rgba(28, 29, 31, 0.97) !important;
    -webkit-backdrop-filter: blur(24px) saturate(180%);
    backdrop-filter: blur(24px) saturate(180%);
    border-bottom: 1px solid transparent;
    box-shadow: none;
    transition: max-height 0.35s cubic-bezier(0.4, 0, 0.2, 1),
                border-color 0.3s ease,
                box-shadow 0.3s ease !important;
    z-index: 999;
    display: block !important;
    padding: 0 !important;
  }

  .side-menu:checked ~ .headerLinks {
    max-height: 400px !important;
    border-bottom-color: var(--border-subtle) !important;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
  }

  /* ── Menu list layout ──────────────────────────────────────────────── */
  .headerLinks ul {
    display: flex !important;
    flex-direction: column !important;
    align-items: stretch !important;
    justify-content: flex-start !important;
    padding: 0.75rem 0 !important;
    margin: 0 !important;
    gap: 0 !important;
    list-style: none !important;
  }

  .headerLinks ul li {
    display: block !important;
    margin: 0 !important;
  }

  /* ── Menu links ────────────────────────────────────────────────────── */
  .headerWrapper .headerLinks a,
  .headerWrapper .headerLinks a:link,
  .headerWrapper .headerLinks a:visited {
    display: block !important;
    padding: 0.9rem 1.75rem !important;
    font-size: 1.05rem !important;
    color: var(--text-primary) !important;
    text-decoration: none !important;
    border-left: 3px solid transparent;
    transition: background-color 0.2s ease,
                color 0.2s ease,
                border-left-color 0.2s ease;
    letter-spacing: 0.02em;
  }

  .headerWrapper .headerLinks a:hover,
  .headerWrapper .headerLinks a:active {
    background: rgba(88, 166, 255, 0.08) !important;
    color: var(--accent) !important;
    border-left-color: var(--accent) !important;
    text-decoration: none !important;
  }

  /* ── Subtle dividers between items ─────────────────────────────────── */
  .headerLinks ul li + li {
    border-top: 1px solid var(--border-subtle);
  }
}

/* ==========================================================================
   Mobile Responsive Fixes – Content
   ========================================================================== */
@media screen and (max-width: 992px) {
  .main {
    padding: 0 16px;
    width: 100% !important;
    max-width: 100vw;
  }

  .postWrapper {
    padding: 12px !important;
  }

  .listHeader {
    padding: 0 4px;
    margin-bottom: 0.5em;
  }

  .listContent {
    padding: 0;
  }

  .postListItem {
    margin-bottom: 16px;
    padding: 16px !important;
    word-wrap: break-word;
    overflow-wrap: break-word;
  }

  .postTitle {
    font-size: 1.1em !important;
    word-wrap: break-word;
    overflow-wrap: break-word;
  }

  .highlight pre {
    max-width: calc(100vw - 64px);
  }

  code {
    word-break: break-all;
  }

  img {
    max-width: 100%;
    height: auto;
  }

  .postMetadata dl {
    grid-template-columns: max-content auto;
    gap: 0 10px;
  }
}

@media screen and (max-width: 480px) {
  .main {
    padding: 0 12px;
  }

  .postWrapper {
    padding: 8px !important;
  }

  .postListItem {
    padding: 12px !important;
  }

  .postWrapper h2 {
    font-size: 1.3em;
  }

  .postWrapper h3 {
    font-size: 1.15em;
  }

  .highlight pre {
    font-size: 0.78rem;
    padding: 0.75rem;
    max-width: calc(100vw - 48px);
  }
}
