/* =============================================================================
   blog-post.css  — Styles specific to blog post and blog index pages.
   Extracted from template_post.html inline <style> block.
   Loaded via <link> in template_post.html and template_index.html.
   ============================================================================= */

/* Remove text-decoration on the nav back/home logo link */
.navbar .logo {
  text-decoration: none;
}

/* Blog index: ensure main container is block-level and sections fill width */
main.container {
  display: block;
  overflow: visible;
  padding-top: 0.5rem; /* Spazio per il translateY dell'hover senza clip navbar */
}

.services-section.blog-listing {
  width: 100%;
}

#blog-list {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

/* --------------------------------------------------------------------------
   Tag filter bar
   -------------------------------------------------------------------------- */
.tag-filter-container {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  width: 100%;
  margin-bottom: 2rem;
  /* Wrap the row in a subtle segmented-control track */
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 0.35rem 0.4rem;
}

#tag-filter {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-wrap: nowrap;
  gap: 0.3rem;
  overflow-x: auto;
  padding: 0;
  scroll-behavior: smooth;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

#tag-filter::-webkit-scrollbar {
  display: none;
}

/* Scroll navigation arrows */
.tag-nav-btn {
  flex-shrink: 0;
  width: 26px;
  height: 26px;
  border-radius: 7px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.68rem;
  font-family: inherit;
  transition: background 0.15s, color 0.15s, opacity 0.2s;
}

.tag-nav-btn:hover {
  background: var(--tag-bg-hover);
  color: var(--accent-primary);
}

.tag-nav-hidden {
  opacity: 0;
  pointer-events: none;
}

/* Vertical divider between arrow and tag list */
.tag-nav-prev {
  order: -1;
}

.tag-nav-next {
  order: 99;
}

.tag-btn {
  scroll-snap-align: start;
  flex-shrink: 0;
  cursor: pointer;
  padding: 0.4rem 0.85rem 0.25rem;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  line-height: 1;
  display: inline-flex;
  justify-content: center;
  align-items: center;
  transition: background 0.15s, color 0.15s, box-shadow 0.15s;
  white-space: nowrap;
}

/* Prevent layout shift when switching between "Tutti" and "All" */
.tag-btn[data-tag="all"] {
  min-width: 72px;
  box-sizing: border-box;
  text-align: center;
}

.tag-btn:hover {
  background: var(--tag-bg-hover);
  color: var(--accent-primary);
}

.tag-btn.active {
  background: var(--accent-primary);
  color: #fff;
  font-weight: 600;
  box-shadow: 0 2px 10px rgba(0, 212, 255, 0.3);
}

[data-theme="light"] .tag-btn.active {
  background: var(--accent-primary);
  color: #fff;
  box-shadow: 0 2px 8px rgba(0, 102, 204, 0.25);
}

[data-theme="light"] .tag-filter-container {
  background: rgba(0, 0, 0, 0.04);
  border-color: rgba(0, 0, 0, 0.08);
}

/* --------------------------------------------------------------------------
   Blog card
   -------------------------------------------------------------------------- */
.blog-card {
  text-decoration: none;
  width: 100%;
}

.blog-card-hidden {
  display: none !important;
}

.blog-card-date {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-bottom: 0.5rem;
}

.no-articles {
  color: var(--text-muted);
}

/* --------------------------------------------------------------------------
   Pagination (Static)
   -------------------------------------------------------------------------- */
.static-pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.5rem;
  margin-top: 2rem;
  padding: 1rem 0;
}

.static-pagination .page-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  height: 36px;
  padding: 0 0.5rem;
  text-decoration: none;
  border-radius: 8px;
  border: 1px solid var(--border-color);
  background: var(--bg-surface);
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 500;
  transition: all 0.2s ease;
}

.static-pagination .page-btn:hover:not(.disabled) {
  background: var(--bg-hover);
  color: var(--text-primary);
  border-color: var(--accent-primary);
}

.static-pagination .page-btn.active {
  background: var(--accent-primary);
  color: #fff;
  border-color: var(--accent-primary);
  pointer-events: none;
}

.static-pagination .page-btn.disabled {
  opacity: 0.5;
  cursor: not-allowed;
  background: transparent;
}

/* --------------------------------------------------------------------------
   Article layout
   -------------------------------------------------------------------------- */
.article-card {
  padding: 3rem 4rem;
  display: block;
  box-sizing: border-box;
  width: 100%;
  cursor: default;
  border-radius: 20px;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
}

[data-theme="light"] .article-card {
  background: #ffffff;
  box-shadow: 0 2px 16px rgba(0, 0, 0, 0.07);
}

.article-wrapper {
  max-width: 800px;
  margin: 0 auto;
  width: 100%;
  min-width: 0;
  overflow: hidden;
}

/* Prevent mobile layout overflow bugs */
body {
  max-width: 100vw;
  width: 100%;
  margin: 0;
  padding: 0;
}

/* Force Flexbox children to respect boundaries */
main.container,
.bio-section {
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
  overflow-x: hidden;
}

/* Responsive images and tables — always applied */
.blog-content img {
  max-width: 100%;
  height: auto;
  display: block;
}

.blog-content table {
  display: block;
  overflow-x: auto;
  max-width: 100%;
}

.blog-content pre {
  overflow-x: auto;
  max-width: 100%;
  word-break: normal;
  white-space: pre;
}

@media (max-width: 768px) {
  .article-card {
    padding: 2rem 1.5rem;
  }

  .blog-header h1 {
    font-size: 1.4rem;
    line-height: 1.3;
    overflow-wrap: break-word;
    word-wrap: break-word;
    word-break: normal;
  }

  .blog-cover {
    max-height: 220px;
    border-radius: 8px;
    margin-bottom: 1.5rem;
    aspect-ratio: 16 / 9;
  }

  .blog-header {
    padding: 0 0.25rem;
  }

  .article-wrapper {
    max-width: 100%;
  }

  .blog-content {
    font-size: 1.05rem;
    line-height: 1.6;
  }
}

/* --------------------------------------------------------------------------
   Blog content typography
   -------------------------------------------------------------------------- */
.blog-content {
  line-height: 1.85;
  font-size: 1.125rem;
  color: var(--text-primary);
  text-align: left;
  overflow-wrap: break-word;
  word-break: normal;
  max-width: 100%;
}

.blog-content p {
  text-align: left;
  margin-bottom: 2rem;
}

.blog-content code {
  background: var(--bg-surface);
  padding: 0.2rem 0.4rem;
  border-radius: 4px;
  font-family: 'Fira Code', 'Cascadia Code', Consolas, monospace;
  font-size: 0.9em;
  color: var(--accent-primary);
}

.blog-content pre {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  padding: 1.5rem;
  border-radius: 12px;
  overflow-x: auto;
  margin-bottom: 1.5rem;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.blog-content pre code {
  background: transparent;
  padding: 0;
  color: inherit;
  font-size: 0.85em;
  border-radius: 0;
}

/* Custom Scrollbar for Code Blocks */
.blog-content pre::-webkit-scrollbar {
  height: 8px;
  width: 8px;
}

.blog-content pre::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.05);
  border-radius: 4px;
}

[data-theme="light"] .blog-content pre::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.05);
}

.blog-content pre::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.2);
  border-radius: 4px;
}

[data-theme="light"] .blog-content pre::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.2);
}

.blog-content pre::-webkit-scrollbar-thumb:hover {
  background: var(--accent-primary);
}

/* Force break long URLs and code strings */
.blog-content a,
.blog-content code,
.blog-content h1,
.blog-content h2,
.blog-content h3,
.blog-content h4,
.blog-content h5,
.blog-content h6 {
  overflow-wrap: break-word;
  word-wrap: break-word;
  word-break: normal;
}

.blog-content h1,
.blog-content h2,
.blog-content h3,
.blog-content h4,
.blog-content h5,
.blog-content h6 {
  text-align: left;
  hyphens: none;
}

.blog-content h2 {
  color: var(--accent-primary);
  margin-top: 2.2rem;
  margin-bottom: 1.2rem;
  font-size: 1.7rem;
}

.blog-content h3 {
  color: var(--accent-secondary);
  margin-top: 1.8rem;
  margin-bottom: 0.9rem;
  font-size: 1.4rem;
}

.blog-content p {
  margin-bottom: 1.4rem;
}

.blog-content ul {
  margin-bottom: 1.2rem;
  padding-left: 1.5rem;
  list-style-type: disc;
}

.blog-content ol {
  margin-bottom: 1.2rem;
  padding-left: 1.5rem;
  list-style-type: decimal;
}

.blog-content li {
  margin-bottom: 0.5rem;
}

/* ==========================================================================
   Enterprise Tables
   ========================================================================== */
.blog-content table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 2rem;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--border-color);
}

.blog-content th,
.blog-content td {
  padding: 1rem 1.2rem;
  text-align: left;
  border: 1px solid var(--border-color);
}

.blog-content th {
  background-color: var(--bg-surface);
  font-weight: 600;
  color: var(--text-primary);
  font-size: 0.95rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.blog-content td {
  font-size: 0.95rem;
  color: var(--text-secondary);
}

.blog-content tbody tr:hover {
  background-color: rgba(255, 255, 255, 0.02);
}

[data-theme="light"] .blog-content tbody tr:hover {
  background-color: rgba(0, 0, 0, 0.02);
}

.blog-content pre {
  background: rgba(0, 0, 0, 0.3);
  padding: 1rem;
  border-radius: 8px;
  overflow-x: auto;
  margin-bottom: 1.2rem;
  border: 1px solid var(--border-color);
}

.blog-content code {
  font-family: monospace;
  background: rgba(0, 0, 0, 0.3);
  padding: 0.2rem 0.4rem;
  border-radius: 4px;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.blog-content pre code {
  background: none;
  padding: 0;
}

/* --------------------------------------------------------------------------
   Blog header & cover image
   -------------------------------------------------------------------------- */
.blog-header {
  text-align: center;
  margin-bottom: 2rem;
}

.blog-header h1 {
  font-size: 2.2rem;
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: -0.03em;
  margin-bottom: 0.8rem;
  overflow-wrap: break-word;
  word-wrap: break-word;
  word-break: normal;
}

.blog-cover {
  width: 100%;
  max-height: 520px;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border-radius: 16px;
  margin-bottom: 2.5rem;
  display: block;
}

.blog-date {
  color: var(--text-muted);
  font-size: 0.95rem;
}

[data-theme="light"] .blog-content pre,
[data-theme="light"] .blog-content code {
  background: rgba(255, 255, 255, 0.5);
}

/* --------------------------------------------------------------------------
   Share Section
   -------------------------------------------------------------------------- */
.share-section {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  margin-top: 2.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border-color);
  flex-wrap: wrap;
}

.share-label {
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  flex-shrink: 0;
}

.share-buttons {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.share-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  padding: 0;
  border-radius: 8px;
  font-size: 1rem;
  font-family: inherit;
  cursor: pointer;
  text-decoration: none;
  border: 1px solid transparent;
  transition: all 0.2s ease;
}

.share-btn i {
  font-size: 0.85rem;
}

/* LinkedIn (Dark Theme default) */
.share-btn--linkedin {
  background: rgba(10, 102, 194, 0.2);
  /* Sfondo più marcato per farsi notare */
  border-color: rgba(10, 102, 194, 0.5);
  /* Bordo molto più solido */
  color: #4da6ff;
  /* Azzurro più brillante per leggibilità sul nero */
}

.share-btn--linkedin:hover {
  background: #0a66c2;
  border-color: #0a66c2;
  color: #fff;
  box-shadow: 0 4px 12px rgba(10, 102, 194, 0.4);
}

/* X (Dark Theme default - Off-white Brand) */
.share-btn--x {
  background: rgba(231, 233, 234, 0.15);
  border-color: rgba(231, 233, 234, 0.4);
  color: #e7e9ea;
}

.share-btn--x:hover {
  background: #e7e9ea;
  border-color: #e7e9ea;
  color: #000;
  box-shadow: 0 4px 12px rgba(231, 233, 234, 0.35);
}

/* Copia link (Dark Theme default - Cyan Accent) */
.share-btn--copy {
  background: rgba(0, 212, 255, 0.15);
  border-color: rgba(0, 212, 255, 0.4);
  color: var(--accent-primary);
}

.share-btn--copy:hover {
  background: var(--accent-primary);
  border-color: var(--accent-primary);
  color: #0f0f13;
  box-shadow: 0 4px 12px rgba(0, 212, 255, 0.35);
}

/* Stato copiato */
.share-btn--copy.copied {
  background: #22c55e;
  border-color: #22c55e;
  color: #fff;
  box-shadow: 0 4px 12px rgba(34, 197, 94, 0.35);
}

/* =========================================
   Light Theme Overrides
   ========================================= */

[data-theme="light"] .share-btn {
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.03);
}

/* LinkedIn Light */
[data-theme="light"] .share-btn--linkedin {
  background: rgba(10, 102, 194, 0.12);
  /* Visibile ma elegante */
  border-color: rgba(10, 102, 194, 0.35);
  /* Bordo ben definito */
  color: #0a66c2;
}

[data-theme="light"] .share-btn--linkedin:hover {
  background: #0a66c2;
  border-color: #0a66c2;
  color: #fff;
  box-shadow: 0 4px 12px rgba(10, 102, 194, 0.3);
}

/* X Light (Pitch Black Brand) */
[data-theme="light"] .share-btn--x {
  background: rgba(15, 20, 25, 0.08);
  border-color: rgba(15, 20, 25, 0.25);
  color: #0f1419;
}

[data-theme="light"] .share-btn--x:hover {
  background: #0f1419;
  border-color: #0f1419;
  color: #fff;
  box-shadow: 0 4px 12px rgba(15, 20, 25, 0.25);
}

/* Copia link Light */
[data-theme="light"] .share-btn--copy {
  background: rgba(0, 212, 255, 0.12);
  border-color: rgba(0, 212, 255, 0.35);
  color: #0088b3;
}

[data-theme="light"] .share-btn--copy:hover {
  background: var(--accent-primary);
  border-color: var(--accent-primary);
  color: #fff;
  box-shadow: 0 4px 12px rgba(0, 212, 255, 0.35);
}

.podcast-subtitle {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
  min-height: 2.8rem;
}

/* --------------------------------------------------------------------------
   Custom Audio Player (Podcast)
   -------------------------------------------------------------------------- */
.podcast-player-wrapper {
  margin: 2rem 0;
  width: 100%;
}

.player-container {
  display: flex !important;
  flex-direction: column;
}

.podcast-player-wrapper .lang-it,
.podcast-player-wrapper .lang-en {
  display: none !important;
  /* Managed by JS lang toggle */
}

html[lang="it"] .podcast-player-wrapper .lang-it {
  display: flex !important;
}

html[lang="en"] .podcast-player-wrapper .lang-en {
  display: flex !important;
}

.custom-audio-player {
  display: flex;
  align-items: center;
  gap: 1rem;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  padding: 0.8rem 1.2rem;
  border-radius: 50px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.05);
}

[data-theme="light"] .custom-audio-player {
  background: #ffffff;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.04);
}

.play-pause-btn {
  background: var(--accent-primary);
  color: #fff;
  border: none;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.2s, background 0.2s;
  flex-shrink: 0;
}

.play-pause-btn:hover {
  transform: scale(1.05);
  background: var(--accent-secondary);
}

.time-display {
  font-family: 'Fira Code', monospace;
  font-size: 0.8rem;
  color: var(--text-secondary);
  flex-shrink: 0;
  min-width: 85px;
  text-align: center;
}

.progress-wrap {
  flex-grow: 1;
  height: 6px;
  position: relative;
  cursor: pointer;
  border-radius: 3px;
  display: flex;
  align-items: center;
}

.progress-bg {
  position: absolute;
  width: 100%;
  height: 100%;
  background: var(--border-color);
  border-radius: 3px;
}

.progress-fill {
  position: absolute;
  height: 100%;
  background: var(--accent-primary);
  width: 0%;
  border-radius: 3px;
  transition: width 0.1s linear;
}

.mute-btn,
.download-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1rem;
  cursor: pointer;
  padding: 0.2rem;
  transition: color 0.2s;
  text-decoration: none;
}

.mute-btn:hover,
.download-btn:hover {
  color: var(--accent-primary);
}