/* ============================================================
   Blog personale — tema chiaro
   Palette identica ad antirez.com: nessuno sfondo dichiarato lì,
   quindi il bianco di default del browser (#fff), testo nero,
   grigi #666/#999, bordi #ccc, blocchi #eee.
   Titoli: Palatino (serif di sistema, come antirez)
   Corpo del post: Inconsolata (self-hosted), come `.comment pre` da lui
   ============================================================ */

:root {
  color-scheme: light;

  --bg:          #ffffff;
  --bg-elev:     #eeeeee;
  --surface:     #fbfbfb;
  --fg:          #000000;
  --muted:       #999999;
  --accent:      #666666;   /* link, come `a { color:#666 }` su antirez */
  --accent-2:    #1f7a52;   /* verde scuro: testo su bianco */
  --accent-2-bg: #d7f0e4;   /* verde chiaro: sfondo dei badge */
  --danger:      #c0392b;
  --border:      #cccccc;

  /* Dichiarazione identica ad antirez: se Palatino non è installato,
     il browser usa il proprio serif predefinito. */
  --font-serif: 'Palatino';
  /* Inconsolata self-hosted per codice e textarea */
  --font-mono: 'Inconsolata', ui-monospace, 'Courier New', monospace;
  --font-menu: var(--font-serif);
  --font-body: var(--font-serif);

  /* 800px di testo + 48px di padding: colonna identica a `#content`
     di antirez, che con box-sizing content-box mette il padding fuori. */
  --maxw: 848px;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; font-size: 20px; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.7;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

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

.container {
  width: 100%;
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 24px;
}

main.container { flex: 1; padding-top: 56px; padding-bottom: 80px; }

/* ----------------------------- Header / nav ----------------------------- */
.site-header {
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}
.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 70px;
}
.nav-brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: var(--fg);
}
.nav-brand:hover { text-decoration: none; color: var(--accent); }
.site-logo {
  display: block;
  width: 44px;
  height: 44px;
  object-fit: contain;
}
.site-wordmark {
  font-family: var(--font-mono);
  font-size: 0.9rem;
  font-weight: 400;
  line-height: 1;
}
.nav-links {
  display: flex;
  gap: 28px;
  list-style: none;
  margin: 0;
  padding: 0;
}
.nav-links a {
  font-family: var(--font-menu);
  font-weight: 400;
  font-size: 1rem;
  color: var(--fg);
}
.nav-links a:hover { color: var(--accent); text-decoration: none; }

/* -------------------------------- Hero ---------------------------------- */
.hero { padding: 40px 0 24px; }
.hero-title {
  font-family: var(--font-menu);
  font-weight: 400;
  font-size: clamp(2.6rem, 7vw, 4rem);
  margin: 0 0 24px;
}
.hero-body p { margin: 0 0 18px; }
.hero-contacts { color: var(--muted); }

/* ------------------------------ Sezioni --------------------------------- */
.section-title {
  font-family: var(--font-menu);
  font-weight: 700;
  letter-spacing: 0.06em;
  font-size: 1.3rem;
  margin: 0 0 24px;
}
.latest { margin-top: 56px; border-top: 1px solid var(--border); padding-top: 32px; }
.page-head { margin-bottom: 8px; }

/* ----------------------------- Lista post ------------------------------- */
.post-list { list-style: none; margin: 0; padding: 0; }
.post-item { padding: 20px 0; border-bottom: 1px solid var(--border); }
.post-link {
  font-family: var(--font-menu);
  font-weight: 400;
  font-style: normal;
  font-size: 1.5rem;
  line-height: 1.2;
  color: var(--fg);
  display: inline-block;
}
.post-link:hover { color: var(--accent); text-decoration: none; }
.post-date {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
  letter-spacing: 0.05em;
  margin-top: 4px;
}
.post-meta {
  display: flex;
  align-items: baseline;
  gap: 6px;
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.78rem;
  letter-spacing: 0.03em;
}
.post-meta .post-date {
  display: inline;
  font-size: inherit;
  letter-spacing: inherit;
  margin-top: 0;
}
.post-author { color: var(--fg); }
.post-excerpt {
  /* Stesso colore di `.post-content`: aprendo il post il testo non deve
     cambiare aspetto. Su antirez lista e post sono lo stesso `pre` nero. */
  color: var(--fg);
  font-family: var(--font-mono);
  font-weight: 400;
  font-style: normal;
  font-size: 0.9rem;
  line-height: 1.3;
  margin: 14px 0 0 10px;
  white-space: pre-line;
}
.read-more {
  display: inline-block;
  margin: 14px 0 0 10px;
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 0.85rem;
  font-weight: 700;
  font-style: normal;
}
.read-more:hover { color: var(--fg); text-decoration: underline; }
.more-link { font-family: var(--font-menu); font-weight: 700; letter-spacing: 0.05em; font-size: 0.85rem; }
.empty { color: var(--muted); }

/* ------------------------------ Singolo post ---------------------------- */
.post-header { margin-bottom: 28px; }
.post-title {
  font-family: var(--font-menu);
  font-weight: 400;
  font-style: normal;
  font-size: 1.5rem;   /* 30px, come `article h2` su antirez e come `.post-link` */
  line-height: 1.2;
  margin: 0 0 10px;
}
.post-cover { width: 100%; border-radius: 8px; border: 1px solid var(--border); margin-bottom: 28px; }
.draft-badge {
  display: inline-block;
  font-family: var(--font-menu);
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent-2);
  background: var(--accent-2-bg);
  padding: 3px 10px;
  border-radius: 999px;
  margin: 0 0 16px;
}
.post-editlink { margin-top: 40px; color: var(--muted); font-size: 0.85rem; }

/* Contenuto markdown reso */
.post-content {
  /* Identico a `.post-excerpt` (colore compreso): stesso font, stesso
     corpo, stesso peso, così il testo non cambia aprendo il post. */
  color: var(--fg);
  font-family: var(--font-mono);
  font-weight: 400;
  font-style: normal;
  font-size: 0.9rem;
  line-height: 1.3;
}
.post-content h1, .post-content h2, .post-content h3 {
  font-family: var(--font-menu);
  font-weight: 700;
  line-height: 1.3;
  margin: 1.8em 0 0.6em;
}
.post-content h2 { font-size: 1.4rem; }
.post-content h3 { font-size: 1.15rem; }
.post-content p { margin: 0 0 1.2em; }
.post-content a { text-decoration: underline; }
.post-content img { max-width: 100%; height: auto; border-radius: 6px; border: 1px solid var(--border); }
.post-content blockquote {
  margin: 1.4em 0;
  padding: 4px 18px;
  border-left: 3px solid var(--accent);
  color: var(--muted);
}
.post-content code {
  background: var(--bg-elev);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 0.92em;
}
.post-content pre {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
  overflow-x: auto;
  font-family: var(--font-mono);
}
.post-content pre code { background: none; padding: 0; }
.post-content ul, .post-content ol { padding-left: 1.4em; margin: 0 0 1.2em; }
.post-content hr { border: none; border-top: 1px solid var(--border); margin: 2em 0; }
.post-content table { border-collapse: collapse; width: 100%; margin: 1.2em 0; }
.post-content th, .post-content td { border: 1px solid var(--border); padding: 8px 12px; text-align: left; }

/* -------------------------------- Footer -------------------------------- */
.site-footer {
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.8rem;
  letter-spacing: 0;
  padding: 14px 0;
}
.footer-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.footer-admin { color: var(--muted); }
.footer-admin:hover { color: var(--fg); text-decoration: none; }

/* --------------------------- Form / pulsanti ---------------------------- */
.btn {
  font-family: var(--font-menu);
  font-weight: 700;
  letter-spacing: 0.05em;
  font-size: 0.82rem;
  background: var(--fg);
  color: var(--bg);
  border: none;
  border-radius: 6px;
  padding: 9px 18px;
  cursor: pointer;
  display: inline-block;
}
.btn:hover { text-decoration: none; opacity: 0.82; }
.btn-ghost { background: transparent; color: var(--fg); border: 1px solid var(--border); }

.field { display: block; margin-bottom: 16px; }
.field span {
  display: block;
  font-size: 0.78rem;
  color: var(--muted);
  margin-bottom: 6px;
  letter-spacing: 0.03em;
}
.field input, .field textarea, .editor-title, .editor-status, .editor-area {
  width: 100%;
  background: var(--surface);
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 12px;
  font-family: var(--font-body);
  font-size: 0.95rem;
}
.field input:focus, .field textarea:focus, .editor-area:focus, .editor-title:focus {
  outline: none;
  border-color: var(--accent);
}
.form { max-width: 420px; }
.form-error { color: var(--danger); margin-bottom: 16px; }
.form-success { color: var(--accent-2); margin-bottom: 16px; }
.form-hint { color: var(--muted); font-size: 0.78rem; margin: 10px 0 0; }
.auth { padding-top: 24px; }
.inline-form { display: inline; }
.link-danger {
  background: none;
  border: none;
  color: var(--danger);
  cursor: pointer;
  font-family: var(--font-body);
  font-size: 0.85rem;
  padding: 0;
}
.link-danger:hover { text-decoration: underline; }

/* ------------------------------ Dashboard ------------------------------- */
.dash-head { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; }
.dash-actions { display: flex; gap: 10px; align-items: center; }
.dash-table { width: 100%; border-collapse: collapse; margin-top: 16px; }
.dash-table th, .dash-table td { text-align: left; padding: 12px 8px; border-bottom: 1px solid var(--border); }
.dash-table th { font-family: var(--font-menu); font-size: 0.75rem; letter-spacing: 0.08em; color: var(--muted); text-transform: uppercase; }
.row-actions { display: flex; gap: 14px; align-items: center; }
.muted { color: var(--muted); }
.badge {
  font-family: var(--font-menu);
  font-size: 0.68rem;
  letter-spacing: 0.06em;
  padding: 2px 9px;
  border-radius: 999px;
  text-transform: uppercase;
}
.badge-published { background: var(--accent-2-bg); color: var(--accent-2); }
.badge-draft { background: #ececec; color: #555; }
.badge-pending { background: #f7e2b0; color: #7a5600; }
.badge-approved { background: var(--accent-2-bg); color: var(--accent-2); }

/* ------------------------------- Commenti ------------------------------- */
.comments { border-top: 1px solid var(--border); margin-top: 56px; padding-top: 32px; }
.comment-list { list-style: none; margin: 0 0 40px; padding: 0; }
.comment { border-bottom: 1px solid var(--border); padding: 18px 0; }
.comment-meta { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; }
.comment-meta time { color: var(--muted); font-size: 0.75rem; }
.comment-body {
  font-family: var(--font-mono);
  font-size: 0.86rem;
  line-height: 1.45;
  margin: 8px 0 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.comment-form { margin-top: 32px; width: 100%; max-width: 560px; position: relative; }
.comment-form textarea { resize: vertical; min-height: 130px; }
.hp-field,
.hp-field[hidden] { display: none !important; }
.moderation-list { margin-top: 20px; }
.moderation-item { border-bottom: 1px solid var(--border); padding: 22px 0; }
.moderation-post { color: var(--muted); font-size: 0.8rem; margin: 5px 0 10px; }
.moderation-item .row-actions { margin-top: 16px; }
.moderation-item form { margin: 0; }

/* -------------------------------- Editor -------------------------------- */
.editor { max-width: 100%; }
.editor-bar { display: flex; gap: 12px; align-items: center; margin-bottom: 16px; }
.editor-title { font-family: var(--font-menu); font-weight: 700; font-size: 1.2rem; }
.editor-bar-actions { display: flex; gap: 10px; align-items: center; }
.editor-status { width: auto; }
.editor-meta { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 12px; }
.editor-toolbar { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.editor-toolbar button {
  font-family: var(--font-menu);
  font-weight: 700;
  font-size: 0.78rem;
  background: var(--surface);
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 6px 12px;
  cursor: pointer;
  min-width: 32px;
}
.editor-toolbar button:hover { border-color: var(--accent); color: var(--accent); }
.editor-toolbar .toggle.active { background: var(--fg); color: var(--bg); border-color: var(--fg); }
.editor-panes { position: relative; }
.editor-area { min-height: 460px; resize: vertical; line-height: 1.6; font-family: var(--font-mono); }
.editor-preview {
  min-height: 460px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 16px 20px;
}
.editor-hint { color: var(--muted); font-size: 0.8rem; min-height: 1.2em; margin-top: 8px; }
.editor-delete { margin-top: 28px; }

/* ------------------------------- Errori --------------------------------- */
.error-page { padding-top: 32px; }
.error-message { color: var(--muted); white-space: pre-wrap; }

@media (max-width: 600px) {
  .editor-meta { grid-template-columns: 1fr; }
  .nav-links { gap: 16px; }
  .nav-brand { gap: 10px; }
  .site-logo { width: 38px; height: 38px; }
  .site-wordmark { font-size: 0.8rem; }
  .post-title { font-size: 1.3rem; }
  main.container { padding-top: 36px; }
}
