/* Pagina capitolo — card, tabelle, immagini, gate visivo (full-text sempre nel sorgente, vedi briefs/ceoManual/project.md 3.5) */

.chapter-page {
  display: flex;
  align-items: flex-start;
  gap: 2.5rem;
  max-width: 1200px;
  margin: 0 auto;
  padding: 3rem 2rem;
}

.chapter-sidebar {
  width: 300px;
  flex-shrink: 0;
  position: sticky;
  top: 1.5rem;
  background: var(--panel-bg);
  border-radius: 8px;
  padding: 1.3rem 1.5rem;
  max-height: calc(100vh - 3rem);
  overflow-y: auto;
}
.chapter-sidebar h2 {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--grey);
  margin: 0 0 0.8rem;
}
.chapter-sidebar ul { list-style: none; margin: 0; padding: 0; }
.chapter-sidebar li { margin-bottom: 0.3rem; }
.chapter-sidebar a {
  display: block;
  color: var(--text);
  text-decoration: none;
  font-size: 0.9rem;
  padding: 0.45rem 0.6rem;
  border-radius: 4px;
  line-height: 1.3;
}
.chapter-sidebar a:hover { background: var(--orange-light); }
.chapter-sidebar li.active a { background: var(--navy); color: var(--white); font-weight: 600; }

.floating-buttons {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  gap: 0.8rem;
  z-index: 200;
}
.floating-btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--orange);
  color: var(--white);
  padding: 0.8rem 1.2rem;
  border-radius: 30px;
  text-decoration: none;
  font-weight: 700;
  font-size: 0.88rem;
  box-shadow: 0 4px 16px rgba(0,0,0,0.28);
  white-space: nowrap;
}
.floating-btn:hover { background: var(--navy); }
.floating-badge {
  background: rgba(255,255,255,0.3);
  border-radius: 999px;
  padding: 0.1rem 0.55rem;
  font-size: 0.8rem;
}

@media (max-width: 640px) {
  .floating-buttons { left: 16px; right: 16px; justify-content: center; }
  .floating-btn { flex: 1; justify-content: center; }
}

@media (max-width: 900px) {
  .chapter-page { flex-direction: column; padding: 1.5rem; }
  .chapter-sidebar { width: 100%; position: static; max-height: none; }
}

.chapter { max-width: 760px; flex: 1; min-width: 0; }
.chapter-meta { color: var(--grey); font-size: 0.9rem; margin-bottom: 0.5rem; }
.chapter h1 { font-size: 1.8rem; margin-top: 0; }

.chapter-body h2 { margin-top: 2rem; }
.chapter-body h3 { color: #595959; font-weight: 500; }

.table-wrap { overflow-x: auto; margin: 1.5rem 0; -webkit-overflow-scrolling: touch; }
.table-wrap table { margin: 0; }

.chapter-body table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5rem 0;
  font-size: 0.92rem;
}
.chapter-body th {
  background: var(--navy);
  color: var(--white);
  text-align: left;
  padding: 0.6rem 0.8rem;
}
.chapter-body td {
  padding: 0.6rem 0.8rem;
  border-bottom: 1px solid #E2E5EA;
}
.chapter-body tr:nth-child(even) td { background: var(--panel-bg); }

.chapter-image { margin: 1.5rem 0; text-align: center; }
.chapter-image img { max-width: 100%; border-radius: 6px; }

.chapter-body blockquote {
  margin: 1.5rem 0;
  padding: 1rem 1.2rem;
  border-left: 4px solid var(--orange);
  background: var(--panel-bg);
  font-style: italic;
  color: var(--text);
}
.chapter-body blockquote.card-warning { border-left-color: #C0392B; }
.chapter-body blockquote.card-tip { border-left-color: #2E7D32; }
.chapter-body blockquote.card-data { border-left-color: var(--navy); }
.chapter-body blockquote.card-todo { border-left-color: var(--orange); }
.chapter-body blockquote.card-where { border-left-color: var(--grey); }
.chapter-body blockquote.card-example { border-left-color: #6C4EBE; }

/* Gate: il testo resta SEMPRE nell'HTML (SEO/GEO), qui lo nascondiamo solo visivamente a chi non e' loggato */
.chapter-body-wrap { position: relative; }
body.guest .chapter-body {
  max-height: 620px;
  overflow: hidden;
}
.gate-overlay {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  padding: 4rem 1.5rem 1.5rem;
  background: linear-gradient(to bottom, rgba(246,247,249,0) 0%, var(--white) 55%);
  text-align: center;
}
.gate-overlay .btn { margin: 0 0.4rem; }
body.member .gate-overlay { display: none; }

.faq-card {
  margin-top: 3rem;
  background: var(--white);
  border: 1px solid #E2E5EA;
  border-radius: 10px;
  padding: 1.8rem 2rem;
}
.faq-card h2 { margin-top: 0; }
.faq-item { border-bottom: 1px solid #E2E5EA; padding: 0.9rem 0; }
.faq-item:last-child { border-bottom: none; }
.faq-item summary { font-weight: 600; cursor: pointer; color: var(--navy); }
.faq-item p { margin: 0.6rem 0 0; color: var(--text); }

.sources-card {
  margin-top: 3rem;
  background: var(--panel-bg);
  border: 1px solid #E2E5EA;
  border-radius: 10px;
  padding: 1.8rem 2rem;
}
.sources-card h2 { margin-top: 0; text-align: center; color: var(--grey); font-weight: 500; font-size: 1rem; text-transform: uppercase; letter-spacing: 0.05em; }
.sources-card ul { list-style: none; padding: 0; margin: 0; }
.sources-card li { margin: 0.6rem 0; }
.sources-card li a { color: var(--text); text-decoration: none; }
.sources-card li a:hover { text-decoration: underline; }

.comments { margin-top: 3rem; padding-top: 1.5rem; border-top: 1px solid #E2E5EA; }
.comment-posted-note { background: var(--orange-light); color: var(--navy); padding: 0.7rem 1rem; border-radius: 6px; }
.comment { padding: 1rem 0; border-bottom: 1px solid #EFF1F4; }
.comment-head { display: flex; align-items: center; gap: 0.6rem; margin-bottom: 0.3rem; }
.comment-rating { color: var(--orange); letter-spacing: 1px; }
.comment-author-reply { background: var(--orange-light); padding: 1rem; border-radius: 6px; border-bottom: none; }
.comment-form { margin-top: 1.5rem; display: flex; flex-direction: column; gap: 0.5rem; max-width: 500px; }
.comment-form textarea, .comment-form select {
  padding: 0.6rem; border: 1px solid #ccc; border-radius: 4px; font-family: inherit;
}
.comment-form button { align-self: flex-start; margin-top: 0.5rem; }

.chapter-pager {
  display: flex;
  justify-content: space-between;
  margin-top: 2.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid #E2E5EA;
  font-weight: 600;
}
.chapter-pager a { color: var(--orange); text-decoration: none; }
