/* ========== BASE ========== */
html[data-font-size="small"] { font-size: 14px; }
html[data-font-size="medium"] { font-size: 16px; }
html[data-font-size="large"] { font-size: 18px; }

body {
  margin: 0 auto;
  padding: 2rem 1.2rem;
  max-width: 720px;
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
  line-height: 1.6;
  background-color: var(--bg);
  color: var(--text);
}

/* ========== TEMI ========== */
body[data-theme="light"] {
  --bg: #ffffff;
  --text: #000000;
  --link: #0000ee;
  --highlight: #f0f0f0;
}
body[data-theme="night"] {
  --bg: #0a0a0a;
  --text: #e0e0e0;
  --link: #8ab4f8;
  --highlight: #1a1a1a;
}
body[data-theme="sepia"] {
  --bg: #f4ecd8;
  --text: #3b2e1f;
  --link: #8b4513;
  --highlight: #e8ddc8;
}

/* ========== ELEMENTI GENERALI ========== */
a { color: var(--link); text-decoration: underline; }
h1 { font-size: 2em; font-weight: normal; margin: 0; }

a:focus-visible,
button:focus-visible {
  outline: 2px solid var(--link);
  outline-offset: 2px;
}

/* ========== HEADER ========== */
.header-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 1rem;
  position: relative;
}
.subhead { opacity: 0.8; }
.nav-line { margin-bottom: 1.5rem; }

.aa-button {
  background: none;
  border: none;
  color: var(--text);
  font-size: 1.2em;
  cursor: pointer;
  padding: 0;
}

/* ========== MENU IMPOSTAZIONI ========== */
.settings-menu {
  position: absolute;
  top: 2em;
  right: 0;
  background: var(--bg);
  border: 1px solid var(--text);
  padding: 0.8rem;
  display: none;
  z-index: 10;
}
.settings-menu.show { display: block; }
.settings-section { margin-bottom: 0.8rem; }
.settings-label { font-size: 0.8em; text-transform: uppercase; }

.theme-buttons,
.font-buttons { display: flex; gap: 0.8rem; flex-wrap: wrap; }

.theme-btn,
.font-btn {
  background: none;
  border: none;
  color: var(--text);
  cursor: pointer;
  font-size: 0.9em;
  padding: 0;
  text-decoration: underline;
}
.theme-btn.active,
.font-btn.active { font-weight: bold; color: var(--link); }

/* ========== HOME PAGE ========== */
.post { margin-bottom: 2rem; }
.post-title { font-weight: bold; font-size: 1.2em; }
/* Regola specifica per la home: margine inferiore ridotto */
.post .post-meta {
  font-size: 0.9em;
  opacity: 0.8;
  margin: 0 0 0.3rem 0;  /* prima era 0, ma ora piccolo margine per staccare leggermente */
}
.post-excerpt { margin: 0; }
.read-more { display: inline-block; margin-top: 0.3rem; }

/* ========== PAGINA ARTICOLO ========== */
.article-title { font-size: 1.8em; font-weight: bold; margin: 1rem 0 0.2rem; }
.post-meta { font-size: 0.9em; opacity: 0.8; margin-bottom: 1.5rem; }
.article-content p { margin-bottom: 1.2rem; }
.article-content h2 { font-size: 1.4em; font-weight: bold; margin: 1.5rem 0 0.5rem; }
.article-content h3 { font-size: 1.2em; font-weight: bold; margin: 1rem 0 0.5rem; }
.article-content ul,
.article-content ol { margin: 0 0 1.2rem 2rem; }
.article-content li { margin-bottom: 0.3rem; }
.article-content blockquote {
  margin: 0 0 1.2rem 2rem;
  padding-left: 1rem;
  border-left: 2px solid var(--text);
  opacity: 0.8;
}
.article-content pre {
  background: rgba(128,128,128,0.1);
  padding: 0.8rem;
  overflow-x: auto;
  margin-bottom: 1.2rem;
  font-family: monospace;
}
.article-content code {
  font-family: monospace;
  background: rgba(128,128,128,0.1);
  padding: 0.1rem 0.3rem;
}
.article-content figure { margin: 0 0 1.5rem 0; }
.article-content img {
  max-width: 100%;
  height: auto;
  display: block;
  margin: 0 auto;
}
.article-content figcaption {
  text-align: center;
  font-size: 0.9em;
  opacity: 0.7;
  margin-top: 0.5rem;
}
.article-content table {
  border-collapse: collapse;
  width: 100%;
  margin-bottom: 1.5rem;
}
.article-content th,
.article-content td {
  border: 1px solid var(--text);
  padding: 0.5rem;
  text-align: left;
}
.article-content hr {
  border: none;
  border-top: 1px solid var(--text);
  opacity: 0.5;
  margin: 2rem 0;
}
.back-link { margin-top: 2rem; display: block; }

/* Contenuti speciali nell'articolo */
.article-content audio {
  display: block;
  margin: 0 auto 0.5rem;
}

.video-container {
  position: relative;
  padding-bottom: 56.25%;
  height: 0;
  overflow: hidden;
  max-width: 100%;
  margin-bottom: 1.5rem;
}
.video-container iframe {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

.text-red { color: #ff5555; }
.text-blue { color: #5588ff; }
.text-green { color: #55cc55; }
.text-yellow { color: #ffcc00; }

.spoiler {
  background: var(--text);
  color: var(--text);
  cursor: pointer;
  padding: 0 0.2rem;
  border-radius: 3px;
  user-select: none;
}
.spoiler.revealed {
  background: var(--highlight);
  color: inherit;
  cursor: auto;
}

/* ========== PAGINA LINKS ========== */
.link-list { margin-top: 1rem; }
.link-item { margin-bottom: 1.2rem; }
.link-label { font-weight: bold; }
.link-desc { display: block; margin-top: 0.2rem; }