/* Tutti i valori chiave arrivano dalle CSS variables impostate
   da ThemeContext — modificare il tema aggiorna l'intera UI. */

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 16px;
  line-height: 1.6;
  transition: background 0.25s ease, color 0.25s ease;
}

a {
  color: var(--accent);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}

button {
  font-family: var(--font-ui);
  cursor: pointer;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
  }
}

/* ---------- Layout ---------- */

.container {
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 1.25rem;
}

.site-header {
  border-bottom: 1px solid var(--border);
  padding: 1.5rem 0;
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 50;
}

.site-header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.site-title {
  font-family: var(--font-heading);
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--text);
}
.site-title:hover {
  text-decoration: none;
  color: var(--accent);
}
.site-brand {
  display: inline-flex;
  align-items: center;
}
.site-logo {
  max-height: 52px;
  width: auto;
  display: block;
}

.site-tagline {
  color: var(--text-muted);
  font-size: 0.85rem;
}

.main-nav {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.nav-link {
  padding: 0.45rem 0.9rem;
  border-radius: var(--radius);
  color: var(--text);
  font-weight: 500;
  font-size: 0.9rem;
}
.nav-link:hover {
  background: var(--accent-soft);
  text-decoration: none;
}
.nav-link.active {
  background: var(--accent);
  color: #fff;
}

.site-footer {
  border-top: 1px solid var(--border);
  margin-top: 4rem;
  padding: 2rem 0;
  color: var(--text-muted);
  font-size: 0.85rem;
  text-align: center;
}

/* ---------- Buttons & form ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.55rem 1.1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: transparent;
  color: var(--text);
  font-size: 0.9rem;
  font-weight: 500;
  transition: background 0.15s ease;
}
.btn:hover {
  background: var(--accent-soft);
}
.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.btn-primary:hover {
  background: var(--accent);
  filter: brightness(1.1);
}
.btn-danger {
  color: #c0392b;
  border-color: rgba(192, 57, 43, 0.4);
}
.btn-danger:hover {
  background: rgba(192, 57, 43, 0.1);
}
.btn-sm {
  padding: 0.3rem 0.7rem;
  font-size: 0.8rem;
}

input[type='text'],
input[type='search'],
input[type='url'],
input[type='number'],
input[type='email'],
input[type='date'],
select,
textarea {
  width: 100%;
  padding: 0.6rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 0.95rem;
}
textarea {
  resize: vertical;
  line-height: 1.6;
}

label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  margin-bottom: 0.3rem;
  color: var(--text-muted);
}

.field {
  margin-bottom: 1.1rem;
}

/* ---------- Post cards ---------- */

.post-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1.5rem;
  margin-top: 2rem;
}

.post-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: transform 0.15s ease, border-color 0.15s ease;
}
.post-card:hover {
  transform: translateY(-3px);
  border-color: var(--accent);
}

.post-card-cover {
  width: 100%;
  height: 160px;
  object-fit: cover;
  display: block;
}

.post-card-body {
  padding: 1.4rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  flex: 1;
}

.post-card h2 {
  font-family: var(--font-heading);
  font-size: 1.3rem;
  line-height: 1.3;
}
.post-card h2 a {
  color: var(--text);
}
.post-card h2 a:hover {
  color: var(--accent);
  text-decoration: none;
}

.post-card .excerpt {
  color: var(--text-muted);
  font-size: 0.92rem;
  flex: 1;
}

/* ----- Postcard con immagine di sfondo (titolo/sottotitolo sopra) ----- */
.post-card-bg {
  position: relative;
  min-height: 260px;
  background-size: cover;
  background-position: center;
  border: none;
}
.post-card-bg-link {
  display: flex;
  align-items: flex-end;
  width: 100%;
  text-decoration: none;
}
.post-card-bg-overlay {
  width: 100%;
  padding: 1.4rem;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.8) 0%, rgba(0, 0, 0, 0.4) 55%, rgba(0, 0, 0, 0) 100%);
}
.post-card-bg-overlay h2 {
  color: #fff;
  font-family: var(--font-heading);
  font-size: 1.4rem;
  line-height: 1.25;
}
.post-card-bg-overlay .excerpt {
  color: rgba(255, 255, 255, 0.9);
  margin-top: 0.3rem;
}
.post-card-bg-overlay .post-meta {
  color: rgba(255, 255, 255, 0.92);
  margin-bottom: 0.4rem;
}

/* ----- Versione grande (in evidenza) ----- */
.post-card-featured {
  min-height: 420px;
}
.post-card-featured .post-card-body {
  justify-content: flex-end;
}
.post-card-featured h2,
.post-card-featured.post-card-bg .post-card-bg-overlay h2 {
  font-size: 2rem;
}
.post-card-featured .post-card-cover {
  height: 280px;
}

/* ----- Layout della home ----- */
.layout-featured {
  display: grid;
  grid-template-columns: 1.6fr 1fr;
  gap: 1.5rem;
  margin-top: 2rem;
  align-items: start;
}
.layout-featured.featured-right {
  grid-template-columns: 1fr 1.6fr;
}
.featured-side {
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
}
.layout-hero {
  margin-top: 2rem;
}
.layout-hero .post-grid {
  margin-top: 1.5rem;
}

/* ----- Sezioni della home (stile magazine) ----- */
/* Layout della home con eventuale colonna laterale (ricerca + tag) */
.home-layout.with-sidebar {
  display: grid;
  gap: 2rem;
  align-items: start;
  margin-top: 1.5rem;
}
.home-layout.sidebar-left {
  grid-template-columns: 250px minmax(0, 1fr);
}
.home-layout.sidebar-right {
  grid-template-columns: minmax(0, 1fr) 250px;
}
.home-layout.sidebar-right .home-side {
  order: 2;
}
.home-layout.sidebar-right .home-main {
  order: 1;
}
.home-layout.with-sidebar .home-side {
  position: sticky;
  top: var(--header-h, 92px);
}
/* In colonna: ricerca e tag impilati verticalmente */
.home-layout.with-sidebar .filters-bar {
  flex-direction: column;
  align-items: stretch;
}
.home-layout.with-sidebar .home-side .tag-cloud {
  margin-top: 1rem;
}

/* Blocchi nella colonna laterale */
.home-side .side-block {
  margin-top: 1.6rem;
}
.side-title {
  font-family: var(--font-heading);
  font-size: 1.05rem;
  margin-bottom: 0.7rem;
  padding-bottom: 0.3rem;
  border-bottom: 2px solid var(--accent);
}
.home-side .latest-list {
  font-size: 0.88rem;
}
.home-side .latest-list li {
  padding: 0.55rem 0.8rem;
}
/* Newsletter compatta quando è nella colonna laterale */
.with-sidebar .home-side .subscribe-box {
  margin-top: 1.6rem;
  padding: 1.1rem 1.2rem;
  text-align: left;
}
.with-sidebar .home-side .subscribe-form {
  flex-direction: column;
  max-width: none;
  margin-top: 0.8rem;
}
@media (max-width: 760px) {
  .home-layout.with-sidebar {
    grid-template-columns: 1fr;
  }
  .home-layout.with-sidebar .home-side {
    position: static;
    order: 0;
  }
}

.home-section {
  margin-top: 2.5rem;
}
.section-title {
  font-family: var(--font-heading);
  font-size: 1.4rem;
  margin-bottom: 1.1rem;
  padding-bottom: 0.4rem;
  border-bottom: 3px solid var(--accent);
  display: inline-block;
}
.category-section .section-title {
  border-bottom-width: 3px;
}
.latest-list {
  list-style: none;
  margin: 0;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.latest-list li {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  padding: 0.7rem 1.1rem;
  border-bottom: 1px solid var(--border);
}
.latest-list li:last-child {
  border-bottom: none;
}
.latest-list li:nth-child(odd) {
  background: var(--surface);
}
.latest-list a {
  color: var(--text);
  font-weight: 500;
}
.latest-list a:hover {
  color: var(--accent);
}
.latest-list time {
  color: var(--text-muted);
  font-size: 0.8rem;
  white-space: nowrap;
}
@media (max-width: 760px) {
  .layout-featured,
  .layout-featured.featured-right {
    grid-template-columns: 1fr;
  }
}

.post-meta {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.category-pill {
  display: inline-block;
  padding: 0.15rem 0.6rem;
  border-radius: 99px;
  font-size: 0.72rem;
  font-weight: 600;
  color: #fff;
}

.tag {
  display: inline-block;
  padding: 0.12rem 0.55rem;
  border-radius: 99px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.74rem;
  font-weight: 500;
}
.tag:hover {
  text-decoration: none;
  filter: brightness(0.92);
}

/* ---------- Single post ---------- */

.post-view {
  max-width: var(--content-width);
  margin: 3rem auto 0;
}

.post-view-header h1 {
  font-family: var(--font-heading);
  font-size: clamp(1.9rem, 4vw, 2.7rem);
  line-height: 1.15;
  margin: 0.8rem 0;
}

.post-cover {
  width: 100%;
  border-radius: var(--radius);
  margin: 1.5rem 0;
  max-height: 420px;
  object-fit: cover;
}

.post-content {
  font-family: var(--font-body);
  font-size: var(--font-size);
  line-height: 1.75;
  margin-top: 2rem;
}
.post-content h2,
.post-content h3,
.post-content h4 {
  font-family: var(--font-heading);
  margin: 1.8em 0 0.6em;
  line-height: 1.3;
}
.post-content p {
  margin-bottom: 1.1em;
}
.post-content ul,
.post-content ol {
  margin: 0 0 1.1em 1.4em;
}
.post-content blockquote {
  border-left: 3px solid var(--accent);
  padding: 0.3em 0 0.3em 1.2em;
  margin: 1.4em 0;
  color: var(--text-muted);
  font-style: italic;
}
.post-content pre {
  background: rgba(127, 127, 127, 0.12);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1em;
  overflow-x: auto;
  margin: 1.4em 0;
  font-size: 0.85em;
}
.post-content code {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.88em;
  background: rgba(127, 127, 127, 0.12);
  padding: 0.12em 0.35em;
  border-radius: 4px;
}
.post-content pre code {
  background: none;
  padding: 0;
}
.post-content img {
  max-width: 100%;
  border-radius: var(--radius);
}
.post-content hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 2em 0;
}

/* ---------- Comments ---------- */

.comments-section {
  max-width: var(--content-width);
  margin: 3rem auto 0;
  border-top: 1px solid var(--border);
  padding-top: 2rem;
}

.comments-section h3 {
  font-family: var(--font-heading);
  margin-bottom: 1.2rem;
}

.comment {
  padding: 1rem 0;
  border-bottom: 1px solid var(--border);
}
.comment:last-child {
  border-bottom: none;
}

.comment-replies {
  margin-left: 1.8rem;
  border-left: 2px solid var(--border);
  padding-left: 1.2rem;
}

.comment-head {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 0.35rem;
}

.comment-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
  flex-shrink: 0;
}

.comment-author {
  font-weight: 600;
  font-size: 0.9rem;
}

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

.comment-body {
  font-size: 0.94rem;
  margin: 0.3rem 0 0.5rem;
}

.comment-actions {
  display: flex;
  gap: 0.8rem;
}
.comment-actions button {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 0.78rem;
  font-weight: 500;
}
.comment-actions button:hover {
  color: var(--accent);
}

.comment-form {
  margin-top: 1.5rem;
  display: grid;
  gap: 0.8rem;
}

/* ---------- Filters / search ---------- */

.filters-bar {
  display: flex;
  gap: 0.8rem;
  align-items: center;
  flex-wrap: wrap;
  margin-top: 2rem;
}
.filters-bar input[type='search'] {
  max-width: 320px;
}
.filters-bar select {
  width: auto;
}

.tag-cloud {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-top: 1rem;
}

.empty-state {
  text-align: center;
  color: var(--text-muted);
  padding: 4rem 1rem;
}

/* ---------- Admin / editor ---------- */

.admin-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 1.5rem;
  font-size: 0.9rem;
}
.admin-table th {
  text-align: left;
  padding: 0.6rem 0.8rem;
  border-bottom: 2px solid var(--border);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}
.admin-table td {
  padding: 0.7rem 0.8rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.status-badge {
  padding: 0.15rem 0.6rem;
  border-radius: 99px;
  font-size: 0.72rem;
  font-weight: 600;
}
.status-published {
  background: rgba(46, 160, 67, 0.15);
  color: #2ea043;
}
.status-draft {
  background: rgba(210, 153, 34, 0.15);
  color: #b8860b;
}

/* ---------- Editor WYSIWYG (Quill) ---------- */
.quill-host {
  margin-top: 0.4rem;
}
.quill-host .ql-toolbar {
  border-color: var(--border);
  border-top-left-radius: var(--radius);
  border-top-right-radius: var(--radius);
  background: var(--bg);
  /* Resta visibile durante lo scroll: si aggancia subito sotto l'header
     (l'altezza dell'header è misurata via JS in --header-h). */
  position: sticky;
  top: var(--header-h, 92px);
  z-index: 30;
}
.quill-host .ql-container {
  border-color: var(--border);
  border-bottom-left-radius: var(--radius);
  border-bottom-right-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 1rem;
}
.quill-host .ql-editor {
  min-height: 420px;
}
.quill-host .ql-editor.ql-blank::before {
  color: var(--text-muted);
  font-style: normal;
}
/* Icone della toolbar adattate al tema (anche in modalità scura) */
.quill-host .ql-snow .ql-stroke { stroke: var(--text); }
.quill-host .ql-snow .ql-fill { fill: var(--text); }
.quill-host .ql-snow .ql-picker { color: var(--text); }
.quill-host .ql-snow .ql-picker-options {
  background: var(--surface);
  border-color: var(--border);
}

/* Pulsante "mostra HTML" nella toolbar */
.quill-host .ql-toolbar button.ql-html-toggle {
  width: auto;
  padding: 0 6px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text);
}
.quill-host .ql-toolbar button.ql-html-toggle.ql-active {
  color: var(--accent);
}

/* Textarea del sorgente HTML */
.ql-html-source {
  width: 100%;
  min-height: 420px;
  border: 1px solid var(--border);
  border-top: none;
  border-bottom-left-radius: var(--radius);
  border-bottom-right-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.85rem;
  line-height: 1.5;
  padding: 0.9rem 1rem;
  resize: vertical;
}

/* Maniglie di ridimensionamento immagine */
.quill-host .ql-editor img {
  cursor: pointer;
}
.ql-resize-overlay {
  position: fixed;
  box-sizing: border-box;
  border: 1.5px solid var(--accent);
  pointer-events: none;
  z-index: 1000;
  display: none;
}
.ql-resize-handle {
  position: absolute;
  width: 12px;
  height: 12px;
  background: var(--accent);
  border: 2px solid #fff;
  border-radius: 2px;
  pointer-events: auto;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}
.ql-resize-nw { top: -7px; left: -7px; cursor: nwse-resize; }
.ql-resize-ne { top: -7px; right: -7px; cursor: nesw-resize; }
.ql-resize-sw { bottom: -7px; left: -7px; cursor: nesw-resize; }
.ql-resize-se { bottom: -7px; right: -7px; cursor: nwse-resize; }

/* Barra contestuale per affiancare l'immagine al testo */
.ql-img-toolbar {
  position: absolute;
  top: -40px;
  left: 0;
  display: flex;
  gap: 2px;
  background: var(--accent);
  border-radius: 6px;
  padding: 3px;
  pointer-events: auto;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  white-space: nowrap;
}
.ql-img-toolbar button {
  border: none;
  background: transparent;
  color: #fff;
  font-size: 0.72rem;
  padding: 3px 7px;
  cursor: pointer;
  border-radius: 4px;
}
.ql-img-toolbar button:hover {
  background: rgba(255, 255, 255, 0.22);
}

/* Immagini affiancate al testo (float) — nell'editor e nel sito pubblico */
.ql-editor img.img-wrap-left,
.post-content img.img-wrap-left {
  float: left;
  margin: 0.3rem 1.4rem 0.8rem 0;
}
.ql-editor img.img-wrap-right,
.post-content img.img-wrap-right {
  float: right;
  margin: 0.3rem 0 0.8rem 1.4rem;
}
/* Immagine con didascalia (figure) — editor e sito pubblico */
.image-figure {
  display: block;
  margin: 1.4em auto;
  max-width: 100%;
}
.image-figure img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: var(--radius);
}
.image-figure figcaption {
  margin-top: 0.45em;
  font-size: 0.85em;
  line-height: 1.4;
  color: var(--text-muted);
  font-style: italic;
  text-align: center;
}
.image-figure figcaption:empty,
.image-figure:not(.has-caption) figcaption {
  display: none;
}
.image-figure.img-wrap-left {
  float: left;
  margin: 0.3rem 1.4rem 0.8rem 0;
}
.image-figure.img-wrap-right {
  float: right;
  margin: 0.3rem 0 0.8rem 1.4rem;
}
@media (max-width: 600px) {
  .post-content .image-figure.img-wrap-left,
  .post-content .image-figure.img-wrap-right {
    float: none;
    margin: 1.4em auto;
  }
}

/* Contiene i float dentro l'area di contenuto */
.ql-editor::after,
.post-content::after {
  content: '';
  display: block;
  clear: both;
}
@media (max-width: 600px) {
  .post-content img.img-wrap-left,
  .post-content img.img-wrap-right {
    float: none;
    margin: 1rem 0;
  }
}

/* Rendering nel sito pubblico dell'output prodotto da Quill */
.post-content .ql-align-center { text-align: center; }
.post-content .ql-align-right { text-align: right; }
.post-content .ql-align-justify { text-align: justify; }
.post-content .ql-indent-1 { padding-left: 3em; }
.post-content .ql-indent-2 { padding-left: 6em; }
.post-content .ql-indent-3 { padding-left: 9em; }
.post-content .ql-video {
  width: 100%;
  aspect-ratio: 16 / 9;
  height: auto;
  border: none;
  border-radius: var(--radius);
  margin: 1.4em 0;
}
.post-content iframe {
  max-width: 100%;
}

.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 2.5rem;
  flex-wrap: wrap;
}
.page-head h1 {
  font-family: var(--font-heading);
  font-size: 1.8rem;
}

/* ---------- Theme customizer ---------- */

.customizer {
  max-width: 720px;
  margin: 0 auto;
}

.customizer-section {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.4rem;
  margin-top: 1.5rem;
  background: var(--surface);
}
.customizer-section h3 {
  font-family: var(--font-heading);
  margin-bottom: 1rem;
  font-size: 1.1rem;
}

.customizer-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
}

.color-input {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}
.color-input input[type='color'] {
  width: 42px;
  height: 36px;
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) * 0.6);
  background: none;
  padding: 2px;
  cursor: pointer;
}

.range-row {
  display: flex;
  align-items: center;
  gap: 0.8rem;
}
.range-row input[type='range'] {
  flex: 1;
  accent-color: var(--accent);
}
.range-value {
  font-size: 0.82rem;
  color: var(--text-muted);
  min-width: 50px;
  text-align: right;
}

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.4rem 0;
}
.toggle-row label {
  margin: 0;
}

.mode-switch {
  display: flex;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.mode-switch button {
  flex: 1;
  padding: 0.5rem 1rem;
  border: none;
  background: transparent;
  color: var(--text);
  font-weight: 500;
  font-size: 0.85rem;
}
.mode-switch button.active {
  background: var(--accent);
  color: #fff;
}

/* Combinazioni di colori (preset) */
.scheme-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 0.7rem;
}
.scheme-swatch {
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) * 0.7);
  background: var(--surface);
  padding: 0.4rem;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  align-items: center;
}
.scheme-swatch:hover {
  border-color: var(--accent);
}
.scheme-swatch.active {
  border-color: var(--accent);
  outline: 2px solid var(--accent);
}
.scheme-bars {
  display: flex;
  width: 100%;
  height: 26px;
  border-radius: 4px;
  overflow: hidden;
}
.scheme-bars span {
  flex: 1;
}
.scheme-name {
  font-size: 0.75rem;
  color: var(--text);
}
.logo-preview {
  background: repeating-conic-gradient(#0001 0% 25%, transparent 0% 50%) 50% / 16px 16px;
  object-fit: contain;
}

/* ---------- Pagination ---------- */

.pagination {
  display: flex;
  justify-content: center;
  gap: 0.4rem;
  margin-top: 2.5rem;
}
.pagination button {
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  border-radius: var(--radius);
  padding: 0.4rem 0.8rem;
  font-size: 0.85rem;
}
.pagination button.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.pagination button:disabled {
  opacity: 0.4;
  cursor: default;
}

/* ---------- Aggiunte specifiche Blazor ---------- */

.muted {
  color: var(--text-muted);
  font-size: 0.9rem;
}

.inline-form {
  display: inline;
}

.nav-button {
  border: none;
  background: transparent;
  font-size: 0.9rem;
}

.action-row {
  display: flex;
  gap: 0.4rem;
  align-items: center;
  flex-wrap: wrap;
}

.saved-message {
  color: var(--accent);
  font-size: 0.85rem;
}

.alert-error {
  background: rgba(192, 57, 43, 0.1);
  border: 1px solid rgba(192, 57, 43, 0.4);
  color: #c0392b;
  border-radius: var(--radius);
  padding: 0.7rem 1rem;
  margin: 1rem 0;
  font-size: 0.9rem;
}

.validation-message {
  color: #c0392b;
  font-size: 0.8rem;
  display: block;
  margin-top: 0.25rem;
}

.login-card {
  max-width: 420px;
  margin: 4rem auto 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 2rem;
}
.login-card h1 {
  font-family: var(--font-heading);
  margin-bottom: 0.3rem;
}
.login-hint {
  color: var(--text-muted);
  font-size: 0.88rem;
  margin-bottom: 1.4rem;
}
.checkbox-field {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.checkbox-field label {
  margin: 0;
}
.btn-block {
  width: 100%;
  justify-content: center;
}

.title-field input {
  font-size: 1.2rem;
  font-family: var(--font-heading);
}

.editor-meta-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 1.1rem;
}
.editor-meta-grid .field {
  margin: 0;
}
/* Stessa altezza per categoria (select), tag (testo) e data, così sono allineati */
.editor-meta-grid input,
.editor-meta-grid select {
  height: 44px;
  line-height: normal;
}

/* Caricamento immagini (copertina / postcard) nell'editor */
.image-upload-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1.2rem;
  margin-bottom: 1.1rem;
}
.image-upload {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.image-upload-preview {
  width: 100%;
  max-height: 150px;
  object-fit: cover;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.image-upload-actions {
  display: flex;
  gap: 0.6rem;
  align-items: center;
  flex-wrap: wrap;
}
.image-upload input[type='file'] {
  font-size: 0.82rem;
  width: auto;
  padding: 0;
  border: none;
  background: none;
}

.color-swatch {
  width: 42px;
  height: 38px;
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) * 0.6);
  background: none;
  padding: 2px;
  cursor: pointer;
}

.new-category {
  max-width: 560px;
}

.categories-table {
  max-width: 680px;
}

.tag-active {
  outline: 2px solid var(--accent);
}

.comment-form-compact {
  margin-top: 0.8rem;
}

.post-tags-footer {
  margin-top: 2rem;
}

/* ---------- Iscrizione newsletter ---------- */
.subscribe-box {
  margin-top: 3rem;
  padding: 1.6rem 1.8rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  text-align: center;
}
.subscribe-box h3 {
  font-family: var(--font-heading);
  margin-bottom: 0.3rem;
}
.subscribe-form {
  display: flex;
  gap: 0.5rem;
  max-width: 460px;
  margin: 1rem auto 0;
}
.subscribe-form input {
  flex: 1;
}
@media (max-width: 520px) {
  .subscribe-form { flex-direction: column; }
}

.alert-success {
  background: rgba(46, 160, 67, 0.12);
  color: #2ea043;
  border: 1px solid rgba(46, 160, 67, 0.3);
  border-radius: var(--radius);
  padding: 0.6rem 0.9rem;
  margin-bottom: 0.8rem;
  font-size: 0.9rem;
}

.info-page {
  max-width: var(--content-width);
  margin: 3rem auto;
  text-align: center;
}
.info-page h1 {
  font-family: var(--font-heading);
  margin-bottom: 0.6rem;
}

.settings-subhead {
  font-family: var(--font-heading);
  font-size: 0.95rem;
  margin: 1.4rem 0 0.6rem;
  padding-top: 1rem;
  border-top: 1px dashed var(--border);
}
.template-editor {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.82rem;
  line-height: 1.5;
}

/* ---------- Anteprima articolo (modale) ---------- */
.preview-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 2000;
  display: flex;
  padding: 2rem;
  overflow: auto;
}
.preview-modal {
  background: var(--bg);
  color: var(--text);
  max-width: 860px;
  width: 100%;
  margin: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem 2.4rem;
  box-shadow: 0 12px 48px rgba(0, 0, 0, 0.35);
}
.preview-modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.4rem;
  padding-bottom: 0.8rem;
  border-bottom: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.85rem;
}
.preview-article h1 {
  font-family: var(--font-heading);
  line-height: 1.2;
}
.preview-article .post-cover {
  width: 100%;
  max-height: 360px;
  object-fit: cover;
  border-radius: var(--radius);
  margin: 1.2rem 0;
}

/* ---------- Lightbox immagini articolo ---------- */
.post-content img {
  cursor: zoom-in;
}
.lightbox-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 3000;
  cursor: zoom-out;
  padding: 2rem;
}
.lightbox-overlay.open {
  display: flex;
}
.lightbox-img {
  max-width: 95vw;
  max-height: 95vh;
  object-fit: contain;
  border-radius: 4px;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.5);
}

/* ---------- Condivisione social ---------- */
.share-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-top: 2.2rem;
  padding-top: 1.3rem;
  border-top: 1px solid var(--border);
}
.share-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-right: 0.2rem;
}
.share-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  color: #fff;
  font-size: 0.95rem;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.12s ease, filter 0.12s ease;
}
.share-btn:hover {
  transform: translateY(-2px);
  filter: brightness(1.1);
  text-decoration: none;
}
.sb-fb { background: #1877f2; }
.sb-x  { background: #000; }
.sb-in { background: #0a66c2; font-size: 0.8rem; }
.sb-wa { background: #25d366; }
.sb-tg { background: #229ed9; }
.sb-em { background: #6b7068; }
.sb-cp { background: var(--accent); }

#blazor-error-ui {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: #b32121;
  color: #fff;
  padding: 0.8rem 1.2rem;
  z-index: 1000;
  font-size: 0.9rem;
}
